Diffstat (limited to 'core/pim/today/todayconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/today/todayconfig.cpp | 315 |
1 files changed, 192 insertions, 123 deletions
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 905ec4b..08e59c0 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -1,14 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * todayconfig.cpp | 2 | * todayconfig.cpp |
3 | * | 3 | * |
4 | * --------------------- | ||
5 | * | ||
6 | * begin : Sun 10 17:20:00 CEST 2002 | ||
7 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
8 | * email : max.reiss@gmx.de | 5 | * email : harlekin@handhelds.org |
9 | * | 6 | * |
10 | */ | 7 | */ |
11 | /*************************************************************************** | 8 | /*************************************************************************** |
12 | * * | 9 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
@@ -16,136 +13,208 @@ | |||
16 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
17 | * * | 14 | * * |
18 | ***************************************************************************/ | 15 | ***************************************************************************/ |
19 | 16 | ||
20 | #include "todayconfig.h" | 17 | #include "todayconfig.h" |
21 | 18 | ||
19 | #include <qpe/config.h> | ||
20 | #include <qpe/resource.h> | ||
21 | #include <qpe/qcopenvelope_qws.h> | ||
22 | |||
22 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
23 | #include <qframe.h> | ||
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qspinbox.h> | 25 | #include <qspinbox.h> |
26 | #include <qtabwidget.h> | 26 | #include <qtabwidget.h> |
27 | #include <qwidget.h> | ||
28 | #include <qlayout.h> | 27 | #include <qlayout.h> |
29 | #include <qvariant.h> | 28 | #include <qheader.h> |
30 | //#include <qwhatsthis.h> | 29 | #include <qhbox.h> |
31 | 30 | #include <qvbox.h> | |
32 | todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags fl ) | 31 | #include <qtoolbutton.h> |
32 | |||
33 | // for getenv | ||
34 | #include <stdlib.h> | ||
35 | |||
36 | class ToolButton : public QToolButton { | ||
37 | public: | ||
38 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | ||
39 | : QToolButton( parent, name ) { | ||
40 | setTextLabel( name ); | ||
41 | setPixmap( Resource::loadPixmap( icon ) ); | ||
42 | setAutoRaise( TRUE ); | ||
43 | setFocusPolicy( QWidget::NoFocus ); | ||
44 | setToggleButton( t ); | ||
45 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | ||
46 | } | ||
47 | }; | ||
48 | |||
49 | |||
50 | /** | ||
51 | * The class has currently quite some duplicate code. | ||
52 | * By that way it would be real easy to have it as seperate app in settings tab | ||
53 | * | ||
54 | */ | ||
55 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
33 | : QDialog( parent, name, modal, fl ) { | 56 | : QDialog( parent, name, modal, fl ) { |
34 | if ( !name ) | ||
35 | setName( "todayconfig" ); | ||
36 | resize( 175, 232 ); | ||
37 | setCaption( tr( "Today config" ) ); | ||
38 | |||
39 | TabWidget3 = new QTabWidget( this, "TabWidget3" ); | ||
40 | TabWidget3->setGeometry( QRect( 0, 0, 220, 320 ) ); | ||
41 | TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); | ||
42 | TabWidget3->setAutoMask( FALSE ); | ||
43 | TabWidget3->setTabShape( QTabWidget::Rounded ); | ||
44 | |||
45 | tab = new QWidget( TabWidget3, "tab" ); | ||
46 | |||
47 | Frame8 = new QFrame( tab, "Frame8" ); | ||
48 | Frame8->setGeometry( QRect( -5, 0, 200, 300 ) ); | ||
49 | Frame8->setFrameShape( QFrame::StyledPanel ); | ||
50 | Frame8->setFrameShadow( QFrame::Raised ); | ||
51 | |||
52 | TextLabel4 = new QLabel( Frame8, "TextLabel4" ); | ||
53 | TextLabel4->setGeometry( QRect( 20, 65, 100, 60 ) ); | ||
54 | TextLabel4->setText( tr( "Should the \n" | ||
55 | "location \n" | ||
56 | "be shown?" ) ); | ||
57 | |||
58 | TextLabel5 = new QLabel( Frame8, "TextLabel5" ); | ||
59 | TextLabel5->setGeometry( QRect( 20, 160, 120, 40 ) ); | ||
60 | TextLabel5->setText( tr( "Should the notes \n" | ||
61 | "be shown?" ) ); | ||
62 | |||
63 | CheckBox2 = new QCheckBox( Frame8, "CheckBox2" ); | ||
64 | CheckBox2->setGeometry( QRect( 158, 170, 27, 21 ) ); | ||
65 | //CheckBox2->setText( tr( "" ) ); | ||
66 | |||
67 | CheckBox1 = new QCheckBox( Frame8, "CheckBox1" ); | ||
68 | CheckBox1->setGeometry( QRect( 158, 65, 27, 50 ) ); | ||
69 | //CheckBox1->setText( tr( "" ) ); | ||
70 | |||
71 | CheckBox3 = new QCheckBox (Frame8, "CheckBox3" ); | ||
72 | CheckBox3->setGeometry( QRect( 158, 125, 27, 21 ) ); | ||
73 | |||
74 | TextLabel6 = new QLabel( Frame8, "All Day"); | ||
75 | TextLabel6->setGeometry( QRect( 20, 120, 100, 30 ) ); | ||
76 | TextLabel6->setText( tr( "Show only later\n" | ||
77 | "appointments") ); | ||
78 | |||
79 | SpinBox1 = new QSpinBox( Frame8, "SpinBox1" ); | ||
80 | SpinBox1->setGeometry( QRect( 115, 20, 58, 25 ) ); | ||
81 | SpinBox1->setMaxValue( 10 ); | ||
82 | SpinBox1->setValue( 5 ); | ||
83 | |||
84 | TextLabel3 = new QLabel( Frame8, "TextLabel3" ); | ||
85 | TextLabel3->setGeometry( QRect( 20, 10, 90, 60 ) ); | ||
86 | TextLabel3->setText( tr( "How many \n" | ||
87 | "appointment\n" | ||
88 | "should\n" | ||
89 | "be shown?" ) ); | ||
90 | TabWidget3->insertTab( tab, tr( "Calendar" ) ); | ||
91 | |||
92 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | ||
93 | |||
94 | Frame9 = new QFrame( tab_2, "Frame9" ); | ||
95 | Frame9->setGeometry( QRect( -5, 0, 230, 310 ) ); | ||
96 | Frame9->setFrameShape( QFrame::StyledPanel ); | ||
97 | Frame9->setFrameShadow( QFrame::Raised ); | ||
98 | |||
99 | TextLabel6 = new QLabel( Frame9, "TextLabel6" ); | ||
100 | TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) ); | ||
101 | TextLabel6->setText( tr( "How many\n" | ||
102 | "tasks should \n" | ||
103 | "be shown?" ) ); | ||
104 | |||
105 | SpinBox2 = new QSpinBox( Frame9, "SpinBox2" ); | ||
106 | SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) ); | ||
107 | SpinBox2->setMaxValue( 20 ); | ||
108 | SpinBox2->setValue( 5 ); | ||
109 | TabWidget3->insertTab( tab_2, tr( "Tasks" ) ); | ||
110 | |||
111 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | ||
112 | |||
113 | Frame14 = new QFrame( tab_3, "Frame14" ); | ||
114 | Frame14->setGeometry( QRect( -5, 0, 200, 220 ) ); | ||
115 | Frame14->setFrameShape( QFrame::StyledPanel ); | ||
116 | Frame14->setFrameShadow( QFrame::Raised ); | ||
117 | |||
118 | TextLabel1 = new QLabel( Frame14, "TextLabel1" ); | ||
119 | TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); | ||
120 | TextLabel1->setText( tr( "Clip after how\n" | ||
121 | "many letters" ) ); | ||
122 | |||
123 | SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); | ||
124 | SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); | ||
125 | SpinBox7->setMaxValue( 80 ); | ||
126 | |||
127 | TextLabel2 = new QLabel( Frame14, "AutoStart" ); | ||
128 | TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); | ||
129 | TextLabel2->setText( tr( "Should today be\n" | ||
130 | "autostarted on\n" | ||
131 | "resume?" | ||
132 | " (Opie only)" ) ); | ||
133 | |||
134 | CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); | ||
135 | CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); | ||
136 | |||
137 | TimeLabel = new QLabel( Frame14, "TimeLabel" ); | ||
138 | TimeLabel->setGeometry( QRect ( 20, 120, 120, 45 ) ); | ||
139 | TimeLabel->setText( tr( "Activate the \n" | ||
140 | "autostart after how\n" | ||
141 | "many minutes?" ) ); | ||
142 | SpinBoxTime = new QSpinBox( Frame14, "TimeSpinner"); | ||
143 | SpinBoxTime->setGeometry( QRect( 115, 120, 58, 25 ) ); | ||
144 | |||
145 | TabWidget3->insertTab( tab_3, tr( "Misc" ) ); | ||
146 | 57 | ||
58 | if ( !name ) { | ||
59 | setName( "todayconfig" ); | ||
60 | } | ||
61 | setCaption( tr( "Today config" ) ); | ||
62 | |||
63 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
64 | TabWidget3 = new QTabWidget( this, "TabWidget3" ); | ||
65 | TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); | ||
66 | TabWidget3->setAutoMask( FALSE ); | ||
67 | TabWidget3->setTabShape( QTabWidget::Rounded ); | ||
68 | layout->addWidget( TabWidget3 ); | ||
69 | |||
70 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | ||
71 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); | ||
72 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); | ||
73 | tab2Layout->addWidget( l ); | ||
74 | QHBox *hbox1 = new QHBox( tab_2 ); | ||
75 | m_appletListView = new QListView( hbox1 ); | ||
76 | m_appletListView->addColumn( "PluginList" ); | ||
77 | m_appletListView->header()->hide(); | ||
78 | QVBox *vbox1 = new QVBox( hbox1 ); | ||
79 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) ); | ||
80 | new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) ); | ||
81 | tab2Layout->addWidget( hbox1 ); | ||
82 | |||
83 | TabWidget3->insertTab( tab_2, tr( "active/order" ) ); | ||
84 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | ||
85 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); | ||
86 | QHBox *hbox_clip = new QHBox( tab_3 ); | ||
87 | TextLabel1 = new QLabel( hbox_clip, "TextLabel1" ); | ||
88 | TextLabel1->setText( tr( "Clip after how\n" | ||
89 | "many letters" ) ); | ||
90 | SpinBox7 = new QSpinBox( hbox_clip, "SpinBox7" ); | ||
91 | SpinBox7->setMaxValue( 80 ); | ||
92 | QHBox *hbox_auto = new QHBox( tab_3 ); | ||
93 | TextLabel2 = new QLabel( hbox_auto, "AutoStart" ); | ||
94 | TextLabel2->setText( tr( "autostart on \nresume? (Opie only)" ) ); | ||
95 | CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" ); | ||
96 | QHBox *hbox_inactive = new QHBox( tab_3 ); | ||
97 | TimeLabel = new QLabel( hbox_inactive , "TimeLabel" ); | ||
98 | TimeLabel->setText( tr( "minutes inactive" ) ); | ||
99 | SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner"); | ||
100 | tab3Layout->addWidget( hbox_clip ); | ||
101 | tab3Layout->addWidget( hbox_auto ); | ||
102 | tab3Layout->addWidget( hbox_inactive ); | ||
103 | TabWidget3->insertTab( tab_3, tr( "Misc" ) ); | ||
104 | |||
105 | m_applets_changed = false; | ||
106 | |||
107 | connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); | ||
108 | |||
109 | readConfig(); | ||
110 | } | ||
111 | |||
112 | |||
113 | /** | ||
114 | * Autostart, uses the new (opie only) autostart method in the launcher code. | ||
115 | * If registered against that today ist started on each resume. | ||
116 | */ | ||
117 | void TodayConfig::setAutoStart() { | ||
118 | Config cfg( "today" ); | ||
119 | cfg.setGroup( "Autostart" ); | ||
120 | int autostart = cfg.readNumEntry( "autostart", 1); | ||
121 | if ( autostart ) { | ||
122 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); | ||
123 | e << QString( "add" ); | ||
124 | e << QString( "today" ); | ||
125 | e << m_autoStartTimer; | ||
126 | } else { | ||
127 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); | ||
128 | e << QString( "remove"); | ||
129 | e << QString( "today" ); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * Read the config part | ||
135 | */ | ||
136 | void TodayConfig::readConfig() { | ||
137 | Config cfg( "today" ); | ||
138 | cfg.setGroup( "Autostart" ); | ||
139 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); | ||
140 | CheckBoxAuto->setChecked( m_autoStart ); | ||
141 | m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" ); | ||
142 | SpinBoxTime->setValue( m_autoStartTimer.toInt() ); | ||
143 | |||
144 | cfg.setGroup( "Applets" ); | ||
145 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * Write the config part | ||
150 | */ | ||
151 | void TodayConfig::writeConfig() { | ||
152 | Config cfg( "today" ); | ||
153 | cfg. setGroup ( "Applets" ); | ||
154 | if ( m_applets_changed ) { | ||
155 | QStringList exclude; | ||
156 | QStringList include; | ||
157 | QMap <QString, QCheckListItem *>::Iterator it; | ||
158 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { | ||
159 | if ( !(*it)-> isOn () ) { | ||
160 | exclude << it.key(); | ||
161 | } else { | ||
162 | include << it.key(); | ||
163 | } | ||
164 | } | ||
165 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | ||
166 | cfg.writeEntry( "IncludeApplets", include, ',' ); | ||
167 | } | ||
168 | |||
169 | cfg.setGroup( "Autostart" ); | ||
170 | m_autoStart = CheckBoxAuto->isChecked(); | ||
171 | cfg.writeEntry( "autostart", m_autoStart ); | ||
172 | m_autoStartTimer = SpinBoxTime->value(); | ||
173 | cfg.readEntry( "autostartdelay", m_autoStartTimer ); | ||
174 | } | ||
175 | |||
176 | |||
177 | void TodayConfig::moveSelectedUp() { | ||
178 | QListViewItem *item = m_appletListView->selectedItem(); | ||
179 | if ( item && item->itemAbove() ) { | ||
180 | item->itemAbove()->moveItem( item ); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | |||
185 | void TodayConfig::moveSelectedDown() { | ||
186 | QListViewItem *item = m_appletListView->selectedItem(); | ||
187 | if ( item && item->itemBelow() ) { | ||
188 | item->moveItem( item->itemBelow() ); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Set up the | ||
195 | */ | ||
196 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { | ||
197 | |||
198 | QCheckListItem *item; | ||
199 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); | ||
200 | |||
201 | if ( !icon.isNull() ) { | ||
202 | item->setPixmap( 0, icon ); | ||
203 | } | ||
204 | |||
205 | qDebug (" SUCHNAME: " + name ); | ||
206 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { | ||
207 | item->setOn( TRUE ); | ||
208 | } | ||
209 | m_applets[libName] = item; | ||
147 | } | 210 | } |
148 | 211 | ||
149 | todayconfig::~todayconfig() { | 212 | |
213 | void TodayConfig::appletChanged() { | ||
214 | m_applets_changed = true; | ||
215 | } | ||
216 | |||
217 | |||
218 | TodayConfig::~TodayConfig() { | ||
150 | } | 219 | } |
151 | 220 | ||