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 <[email protected]>
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 TQt, and distribute the resulting executable,
without including the source code for TQt in the source distribution.
*/
#include <tqbuttongroup.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqradiobutton.h>
#include <tqspinbox.h>
#include <tdeaboutdata.h>
#include <tdeapplication.h>
#include <tdeaccelmanager.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <tdelocale.h>
#include "kcmkorgsummary.h"
#include <kdemacros.h>
extern "C"
{
TDE_EXPORT TDECModule *create_korgsummary( TQWidget *parent, const char * )
{
return new KCMKOrgSummary( parent, "kcmkorgsummary" );
}
}
KCMKOrgSummary::KCMKOrgSummary( TQWidget *parent, const char *name )
: TDECModule( parent, name )
{
initGUI();
customDaysChanged( 1 );
connect( mCalendarGroup, TQ_SIGNAL( clicked( int ) ), TQ_SLOT( modified() ) );
connect( mCalendarGroup, TQ_SIGNAL( clicked( int ) ), TQ_SLOT( buttonClicked( int ) ) );
connect( mTodoGroup, TQ_SIGNAL( clicked( int ) ), TQ_SLOT( modified() ) );
connect( mCustomDays, TQ_SIGNAL( valueChanged( int ) ), TQ_SLOT( modified() ) );
connect( mCustomDays, TQ_SIGNAL( valueChanged( int ) ), TQ_SLOT( customDaysChanged( int ) ) );
TDEAcceleratorManager::manage( this );
load();
TDEAboutData *about = new TDEAboutData( I18N_NOOP( "kcmkorgsummary" ),
I18N_NOOP( "Schedule Configuration Dialog" ),
0, 0, TDEAboutData::License_GPL,
I18N_NOOP( "(c) 2003 - 2004 Tobias Koenig" ) );
about->addAuthor( "Tobias Koenig", 0, "[email protected]" );
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()
{
TQVBoxLayout *layout = new TQVBoxLayout( this, 0, KDialog::spacingHint() );
mCalendarGroup = new TQButtonGroup( 0, TQt::Vertical, i18n( "Appointments" ), this );
TQVBoxLayout *boxLayout = new TQVBoxLayout( mCalendarGroup->layout(),
KDialog::spacingHint() );
TQLabel *label = new TQLabel( i18n( "How many days should the calendar show at once?" ), mCalendarGroup );
boxLayout->addWidget( label );
TQRadioButton *button = new TQRadioButton( i18n( "One day" ), mCalendarGroup );
boxLayout->addWidget( button );
button = new TQRadioButton( i18n( "Five days" ), mCalendarGroup );
boxLayout->addWidget( button );
button = new TQRadioButton( i18n( "One week" ), mCalendarGroup );
boxLayout->addWidget( button );
button = new TQRadioButton( i18n( "One month" ), mCalendarGroup );
boxLayout->addWidget( button );
TQHBoxLayout *hbox = new TQHBoxLayout( boxLayout, KDialog::spacingHint() );
button = new TQRadioButton( "", mCalendarGroup );
hbox->addWidget( button );
mCustomDays = new TQSpinBox( 1, 365, 1, mCalendarGroup );
mCustomDays->setEnabled( false );
hbox->addWidget( mCustomDays );
hbox->addStretch( 1 );
layout->addWidget( mCalendarGroup );
mTodoGroup = new TQButtonGroup( 2, TQt::Horizontal, i18n( "To-dos" ), this );
new TQRadioButton( i18n( "Show all to-dos" ), mTodoGroup );
new TQRadioButton( i18n( "Show today's to-dos only" ), mTodoGroup );
layout->addWidget( mTodoGroup );
layout->addStretch();
}
void KCMKOrgSummary::load()
{
TDEConfig 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()
{
TDEConfig 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"
|