Remove double margin
[kdepim.git] / kalarm / specialactions.h
blob63a491d18b413a960c97a149cd01a310e958c7e5
1 /*
2 * specialactions.h - widget to specify special alarm actions
3 * Program: kalarm
4 * Copyright © 2004-2010,2012 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef SPECIALACTIONS_H
22 #define SPECIALACTIONS_H
24 #include <kalarmcal/kaevent.h>
25 #include <QDialog>
26 #include <QWidget>
27 #include <QPushButton>
29 using namespace KAlarmCal;
31 class QResizeEvent;
32 class QLineEdit;
33 class CheckBox;
36 class SpecialActionsButton : public QPushButton
38 Q_OBJECT
39 public:
40 explicit SpecialActionsButton(bool enableCheckboxes, QWidget* parent = Q_NULLPTR);
41 void setActions(const QString& pre, const QString& post, KAEvent::ExtraActionOptions);
42 const QString& preAction() const { return mPreAction; }
43 const QString& postAction() const { return mPostAction; }
44 KAEvent::ExtraActionOptions options() const { return mOptions; }
45 virtual void setReadOnly(bool ro) { mReadOnly = ro; }
46 virtual bool isReadOnly() const { return mReadOnly; }
48 Q_SIGNALS:
49 /** Signal emitted whenever the widget has been changed. */
50 void selected();
52 protected Q_SLOTS:
53 void slotButtonPressed();
55 private:
56 QString mPreAction;
57 QString mPostAction;
58 KAEvent::ExtraActionOptions mOptions;
59 bool mEnableCheckboxes;
60 bool mReadOnly;
64 // Pre- and post-alarm actions widget
65 class SpecialActions : public QWidget
67 Q_OBJECT
68 public:
69 explicit SpecialActions(bool enableCheckboxes, QWidget* parent = Q_NULLPTR);
70 void setActions(const QString& pre, const QString& post, KAEvent::ExtraActionOptions);
71 QString preAction() const;
72 QString postAction() const;
73 KAEvent::ExtraActionOptions options() const;
74 void setReadOnly(bool);
75 bool isReadOnly() const { return mReadOnly; }
77 private Q_SLOTS:
78 void slotPreActionChanged(const QString& text);
80 private:
81 QLineEdit* mPreAction;
82 QLineEdit* mPostAction;
83 CheckBox* mCancelOnError;
84 CheckBox* mDontShowError;
85 CheckBox* mExecOnDeferral;
86 bool mEnableCheckboxes; // enable checkboxes even if mPreAction is blank
87 bool mReadOnly;
91 // Pre- and post-alarm actions dialog displayed by the push button
92 class SpecialActionsDlg : public QDialog
94 Q_OBJECT
95 public:
96 SpecialActionsDlg(const QString& preAction, const QString& postAction,
97 KAEvent::ExtraActionOptions, bool enableCheckboxes,
98 QWidget* parent = Q_NULLPTR);
99 QString preAction() const { return mActions->preAction(); }
100 QString postAction() const { return mActions->postAction(); }
101 KAEvent::ExtraActionOptions options() const { return mActions->options(); }
102 void setReadOnly(bool ro) { mActions->setReadOnly(ro); }
103 bool isReadOnly() const { return mActions->isReadOnly(); }
105 protected:
106 void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
108 protected Q_SLOTS:
109 virtual void slotOk();
111 private:
112 SpecialActions* mActions;
115 #endif // SPECIALACTIONS_H
117 // vim: et sw=4: