25 #include <tqwhatsthis.h>
27 #include <klineedit.h>
28 #include <tdeapplication.h>
29 #include <tdeaboutdata.h>
30 #include <tdelocale.h>
34 #include "shellprocess.h"
35 #include "specialactions.moc"
43 SpecialActionsButton::SpecialActionsButton(
const TQString& caption, TQWidget* parent,
const char* name)
44 : TQPushButton(caption, parent, name),
47 setToggleButton(
true);
49 connect(
this, TQ_SIGNAL(clicked()), TQ_SLOT(slotButtonPressed()));
50 TQWhatsThis::add(
this,
51 i18n(
"Specify actions to execute before and after the alarm is displayed."));
58 void SpecialActionsButton::setActions(
const TQString& pre,
const TQString& post)
62 setOn(!mPreAction.isEmpty() || !mPostAction.isEmpty());
69 void SpecialActionsButton::slotButtonPressed()
71 SpecialActionsDlg dlg(mPreAction, mPostAction,
72 i18n(
"Special Alarm Actions"),
this,
"actionsDlg");
73 dlg.setReadOnly(mReadOnly);
74 if (dlg.exec() == TQDialog::Accepted)
76 mPreAction = dlg.preAction();
77 mPostAction = dlg.postAction();
80 setOn(!mPreAction.isEmpty() || !mPostAction.isEmpty());
89 static const char SPEC_ACT_DIALOG_NAME[] =
"SpecialActionsDialog";
92 SpecialActionsDlg::SpecialActionsDlg(
const TQString& preAction,
const TQString& postAction,
93 const TQString& caption, TQWidget* parent,
const char* name)
94 : KDialogBase(parent, name, true, caption, Ok|Cancel, Ok, false)
96 TQWidget* page =
new TQWidget(
this);
98 TQVBoxLayout* layout =
new TQVBoxLayout(page, 0, spacingHint());
100 mActions =
new SpecialActions(page);
101 mActions->setActions(preAction, postAction);
102 layout->addWidget(mActions);
103 layout->addSpacing(KDialog::spacingHint());
106 if (KAlarm::readConfigWindowSize(SPEC_ACT_DIALOG_NAME, s))
113 void SpecialActionsDlg::slotOk()
115 if (mActions->isReadOnly())
124 void SpecialActionsDlg::resizeEvent(TQResizeEvent* re)
127 KAlarm::writeConfigWindowSize(SPEC_ACT_DIALOG_NAME, re->size());
128 KDialog::resizeEvent(re);
137 SpecialActions::SpecialActions(TQWidget* parent,
const char* name)
138 : TQWidget(parent, name),
141 TQBoxLayout* topLayout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint());
144 TQLabel* label =
new TQLabel(i18n(
"Pre-a&larm action:"),
this);
145 label->setFixedSize(label->sizeHint());
146 topLayout->addWidget(label, 0, TQt::AlignAuto);
148 mPreAction =
new KLineEdit(
this);
149 label->setBuddy(mPreAction);
150 TQWhatsThis::add(mPreAction,
151 i18n(
"Enter a shell command to execute before the alarm is displayed.\n"
152 "Note that it is executed only when the alarm proper is displayed, not when a reminder or deferred alarm is displayed.\n"
153 "N.B. KAlarm will wait for the command to complete before displaying the alarm."));
154 topLayout->addWidget(mPreAction);
155 topLayout->addSpacing(KDialog::spacingHint());
158 label =
new TQLabel(i18n(
"Post-alar&m action:"),
this);
159 label->setFixedSize(label->sizeHint());
160 topLayout->addWidget(label, 0, TQt::AlignAuto);
162 mPostAction =
new KLineEdit(
this);
163 label->setBuddy(mPostAction);
164 TQWhatsThis::add(mPostAction,
165 i18n(
"Enter a shell command to execute after the alarm window is closed.\n"
166 "Note that it is not executed after closing a reminder window. If you defer "
167 "the alarm, it is not executed until the alarm is finally acknowledged or closed."));
168 topLayout->addWidget(mPostAction);
171 void SpecialActions::setActions(
const TQString& pre,
const TQString& post)
173 mPreAction->setText(pre);
174 mPostAction->setText(post);
177 TQString SpecialActions::preAction()
const
179 return mPreAction->text();
182 TQString SpecialActions::postAction()
const
184 return mPostAction->text();
187 void SpecialActions::setReadOnly(
bool ro)
190 mPreAction->setReadOnly(mReadOnly);
191 mPostAction->setReadOnly(mReadOnly);