34 #include <kcal/alarm.h>
35 #include <kcal/journal.h>
37 #include <KDateComboBox>
39 #include <KTimeComboBox>
42 #include <QButtonGroup>
44 #include <QRadioButton>
45 #include <QVBoxLayout>
50 setCaption( caption );
51 setButtons( Ok | Cancel );
52 KVBox *page =
new KVBox(
this );
53 setMainWidget( page );
55 m_buttons =
new QButtonGroup(
this );
56 QGroupBox *group =
new QGroupBox( i18n(
"Scheduled Alarm" ), page );
57 QVBoxLayout *layout =
new QVBoxLayout;
58 QRadioButton *none =
new QRadioButton( i18n(
"&No alarm" ) );
59 layout->addWidget( none );
60 m_buttons->addButton( none, 0 );
62 group->setLayout( layout );
64 KHBox *at =
new KHBox;
65 QRadioButton *label_at =
new QRadioButton( i18n(
"Alarm &at:" ), at );
66 m_atDate =
new KDateComboBox( at );
67 m_atTime =
new KTimeComboBox( at );
68 at->setStretchFactor( m_atDate, 1 );
69 layout->addWidget( at );
70 m_buttons->addButton( label_at, 1 );
72 connect( m_buttons, SIGNAL(buttonClicked(
int)),
73 SLOT(slotButtonChanged(
int)) );
74 connect(
this, SIGNAL(okClicked()), SLOT(slotOk()) );
82 if ( !m_journal->alarms().isEmpty() ) {
83 KCal::Alarm *alarm = m_journal->alarms().first();
84 if ( alarm->hasTime() ) {
85 m_buttons->button( 1 )->setChecked(
true );
86 m_atDate->setDate( alarm->time().date() );
87 m_atTime->setTime( alarm->time().time() );
89 m_buttons->button( 0 )->setChecked(
true );
92 m_buttons->button( 0 )->setChecked(
true );
93 slotButtonChanged( m_buttons->checkedId() );
97 void KNoteAlarmDialog::slotButtonChanged(
int id )
102 m_atDate->setEnabled(
false );
103 m_atTime->setEnabled(
false );
107 m_atDate->setEnabled(
true );
108 m_atTime->setEnabled(
true );
113 void KNoteAlarmDialog::slotOk()
115 if ( m_buttons->checkedId() == 0 ) {
116 m_journal->clearAlarms();
121 if ( m_journal->alarms().isEmpty() ) {
122 alarm = m_journal->newAlarm();
123 alarm->setEnabled(
true );
124 alarm->setType( KCal::Alarm::Display );
126 alarm = m_journal->alarms().first();
129 if ( m_buttons->checkedId() == 1 ) {
130 alarm->setTime( KDateTime( m_atDate->date(), m_atTime->time(),
131 KDateTime::LocalZone ) );
135 #include "knotealarmdialog.moc"
KNoteAlarmDialog(const QString &caption, QWidget *parent=0)
void setIncidence(KCal::Journal *journal)