1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
/*
This file is part of Kontact.
Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <kaboutdata.h>
#include <kapplication.h>
#include <kaccelmanager.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <klocale.h>
#include "kcmkorgsummary.h"
#include <kdepimmacros.h>
extern "C"
{
KDE_EXPORT KCModule *create_korgsummary( QWidget *parent, const char * )
{
return new KCMKOrgSummary( parent, "kcmkorgsummary" );
}
}
KCMKOrgSummary::KCMKOrgSummary( QWidget *parent, const char *name )
: KCModule( parent, name )
{
initGUI();
customDaysChanged( 1 );
connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) );
connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) );
connect( mTodoGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) );
connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( modified() ) );
connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( customDaysChanged( int ) ) );
KAcceleratorManager::manage( this );
load();
KAboutData *about = new KAboutData( I18N_NOOP( "kcmkorgsummary" ),
I18N_NOOP( "Schedule Configuration Dialog" ),
0, 0, KAboutData::License_GPL,
I18N_NOOP( "(c) 2003 - 2004 Tobias Koenig" ) );
about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
setAboutData( about );
}
void KCMKOrgSummary::modified()
{
emit changed( true );
}
void KCMKOrgSummary::buttonClicked( int id )
{
mCustomDays->setEnabled( id == 4 );
}
void KCMKOrgSummary::customDaysChanged( int value )
{
mCustomDays->setSuffix( i18n( " day", " days", value ) );
}
void KCMKOrgSummary::initGUI()
{
QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
mCalendarGroup = new QButtonGroup( 0, Vertical, i18n( "Appointments" ), this );
QVBoxLayout *boxLayout = new QVBoxLayout( mCalendarGroup->layout(),
KDialog::spacingHint() );
QLabel *label = new QLabel( i18n( "How many days should the calendar show at once?" ), mCalendarGroup );
boxLayout->addWidget( label );
QRadioButton *button = new QRadioButton( i18n( "One day" ), mCalendarGroup );
boxLayout->addWidget( button );
button = new QRadioButton( i18n( "Five days" ), mCalendarGroup );
boxLayout->addWidget( button );
button = new QRadioButton( i18n( "One week" ), mCalendarGroup );
boxLayout->addWidget( button );
button = new QRadioButton( i18n( "One month" ), mCalendarGroup );
boxLayout->addWidget( button );
QHBoxLayout *hbox = new QHBoxLayout( boxLayout, KDialog::spacingHint() );
button = new QRadioButton( "", mCalendarGroup );
hbox->addWidget( button );
mCustomDays = new QSpinBox( 1, 365, 1, mCalendarGroup );
mCustomDays->setEnabled( false );
hbox->addWidget( mCustomDays );
hbox->addStretch( 1 );
layout->addWidget( mCalendarGroup );
mTodoGroup = new QButtonGroup( 2, Horizontal, i18n( "To-dos" ), this );
new QRadioButton( i18n( "Show all to-dos" ), mTodoGroup );
new QRadioButton( i18n( "Show today's to-dos only" ), mTodoGroup );
layout->addWidget( mTodoGroup );
layout->addStretch();
}
void KCMKOrgSummary::load()
{
KConfig config( "kcmkorgsummaryrc" );
config.setGroup( "Calendar" );
int days = config.readNumEntry( "DaysToShow", 1 );
if ( days == 1 )
mCalendarGroup->setButton( 0 );
else if ( days == 5 )
mCalendarGroup->setButton( 1 );
else if ( days == 7 )
mCalendarGroup->setButton( 2 );
else if ( days == 31 )
mCalendarGroup->setButton( 3 );
else {
mCalendarGroup->setButton( 4 );
mCustomDays->setValue( days );
mCustomDays->setEnabled( true );
}
config.setGroup( "Todo" );
bool allTodos = config.readBoolEntry( "ShowAllTodos", false );
if ( allTodos )
mTodoGroup->setButton( 0 );
else
mTodoGroup->setButton( 1 );
emit changed( false );
}
void KCMKOrgSummary::save()
{
KConfig config( "kcmkorgsummaryrc" );
config.setGroup( "Calendar" );
int days;
switch ( mCalendarGroup->selectedId() ) {
case 0: days = 1; break;
case 1: days = 5; break;
case 2: days = 7; break;
case 3: days = 31; break;
case 4:
default: days = mCustomDays->value(); break;
}
config.writeEntry( "DaysToShow", days );
config.setGroup( "Todo" );
config.writeEntry( "ShowAllTodos", mTodoGroup->selectedId() == 0 );
config.sync();
emit changed( false );
}
void KCMKOrgSummary::defaults()
{
mCalendarGroup->setButton( 0 );
mTodoGroup->setButton( 1 );
emit changed( true );
}
#include "kcmkorgsummary.moc"
|