23 #include <tqwidgetstack.h>
25 #include <tqwhatsthis.h>
26 #include <tdelocale.h>
30 #include "latecancel.moc"
35 TQString LateCancelSelector::i18n_CancelIfLate() {
return i18n(
"Cancel if late"); }
36 TQString LateCancelSelector::i18n_n_CancelIfLate() {
return i18n(
"Ca&ncel if late"); }
37 TQString LateCancelSelector::i18n_AutoCloseWin() {
return i18n(
"Auto-close window after this time"); }
38 TQString LateCancelSelector::i18n_AutoCloseWinLC() {
return i18n(
"Auto-close window after late-cancelation time"); }
39 TQString LateCancelSelector::i18n_i_AutoCloseWinLC() {
return i18n(
"Auto-close w&indow after late-cancelation time"); }
42 LateCancelSelector::LateCancelSelector(
bool allowHourMinute, TQWidget* parent,
const char* name)
43 : TQFrame(parent, name),
46 mAutoCloseShown(false)
48 TQString whatsThis = i18n(
"If checked, the alarm will be canceled if it cannot be triggered within the "
49 "specified period after its scheduled time. Possible reasons for not triggering "
50 "include your being logged off, X not running, or the alarm daemon not running.\n\n"
51 "If unchecked, the alarm will be triggered at the first opportunity after "
52 "its scheduled time, regardless of how late it is.");
54 setFrameStyle(TQFrame::NoFrame);
55 mLayout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint());
57 mStack =
new TQWidgetStack(
this);
58 mCheckboxFrame =
new TQFrame(mStack);
59 mCheckboxFrame->setFrameStyle(TQFrame::NoFrame);
60 mStack->addWidget(mCheckboxFrame, 1);
61 TQBoxLayout* layout =
new TQVBoxLayout(mCheckboxFrame, 0, 0);
62 mCheckbox =
new CheckBox(i18n_n_CancelIfLate(), mCheckboxFrame);
63 mCheckbox->setFixedSize(mCheckbox->sizeHint());
64 connect(mCheckbox, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotToggled(
bool)));
65 TQWhatsThis::add(mCheckbox, whatsThis);
66 layout->addWidget(mCheckbox, 0, TQt::AlignAuto);
68 mTimeSelectorFrame =
new TQFrame(mStack);
69 mTimeSelectorFrame->setFrameStyle(TQFrame::NoFrame);
70 mStack->addWidget(mTimeSelectorFrame, 2);
71 layout =
new TQVBoxLayout(mTimeSelectorFrame, 0, 0);
72 mTimeSelector =
new TimeSelector(i18n(
"Cancel if late by 10 minutes",
"Ca&ncel if late by"), TQString(),
73 whatsThis, i18n(
"Enter how late will cause the alarm to be canceled"),
74 allowHourMinute, mTimeSelectorFrame);
75 connect(mTimeSelector, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotToggled(
bool)));
76 layout->addWidget(mTimeSelector);
77 mLayout->addWidget(mStack);
79 layout =
new TQHBoxLayout(mLayout, KDialog::spacingHint());
80 layout->addSpacing(3*KDialog::spacingHint());
81 mAutoClose =
new CheckBox(i18n_AutoCloseWin(),
this);
82 mAutoClose->setFixedSize(mAutoClose->sizeHint());
83 TQWhatsThis::add(mAutoClose, i18n(
"Automatically close the alarm window after the expiry of the late-cancelation period"));
84 layout->addWidget(mAutoClose);
88 mAutoClose->setEnabled(
false);
94 void LateCancelSelector::setReadOnly(
bool ro)
96 if ((
int)ro != (
int)mReadOnly)
99 mCheckbox->setReadOnly(mReadOnly);
100 mTimeSelector->setReadOnly(mReadOnly);
101 mAutoClose->setReadOnly(mReadOnly);
105 int LateCancelSelector::minutes()
const
107 return mTimeSelector->minutes();
110 void LateCancelSelector::setMinutes(
int minutes,
bool dateOnly, TimePeriod::Units defaultUnits)
112 slotToggled(minutes);
113 mTimeSelector->setMinutes(minutes, dateOnly, defaultUnits);
116 void LateCancelSelector::setDateOnly(
bool dateOnly)
118 if (dateOnly != mDateOnly)
120 mDateOnly = dateOnly;
121 if (mTimeSelector->isChecked())
122 mTimeSelector->setDateOnly(dateOnly);
126 void LateCancelSelector::showAutoClose(
bool show)
132 mAutoCloseShown = show;
136 bool LateCancelSelector::isAutoClose()
const
138 return mAutoCloseShown && mAutoClose->isEnabled() && mAutoClose->isChecked();
141 void LateCancelSelector::setAutoClose(
bool autoClose)
143 mAutoClose->setChecked(autoClose);
149 void LateCancelSelector::slotToggled(
bool on)
151 mCheckbox->setChecked(on);
152 mTimeSelector->setChecked(on);
155 mTimeSelector->setDateOnly(mDateOnly);
156 mStack->raiseWidget(mTimeSelectorFrame);
159 mStack->raiseWidget(mCheckboxFrame);
160 mAutoClose->setEnabled(on);