Diffstat (limited to 'core/pim/today/todayconfig.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/today/todayconfig.cpp | 117 |
1 files changed, 68 insertions, 49 deletions
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 4f0877c..c9823d4 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -7,39 +7,47 @@ | |||
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * 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 * |
11 | * 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 * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #include "todayconfig.h" | 17 | #include "todayconfig.h" |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <opie2/oconfig.h> |
20 | #include <opie2/opluginloader.h> | ||
21 | #include <opie2/todayplugininterface.h> | ||
22 | |||
20 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
23 | 26 | ||
24 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
25 | #include <qlabel.h> | 28 | #include <qlabel.h> |
26 | #include <qspinbox.h> | 29 | #include <qspinbox.h> |
27 | #include <qlayout.h> | 30 | #include <qlayout.h> |
28 | #include <qheader.h> | 31 | #include <qheader.h> |
29 | #include <qvbox.h> | 32 | #include <qvbox.h> |
30 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
31 | #include <qwhatsthis.h> | 34 | #include <qwhatsthis.h> |
32 | 35 | ||
33 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
37 | using Opie::Core::OConfig; | ||
38 | using Opie::Core::OPluginManager; | ||
39 | using Opie::Core::OPluginLoader; | ||
40 | using Opie::Core::OPluginItem; | ||
41 | |||
34 | class ToolButton : public QToolButton { | 42 | class ToolButton : public QToolButton { |
35 | 43 | ||
36 | public: | 44 | public: |
37 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 45 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
38 | : QToolButton( parent, name ) { | 46 | : QToolButton( parent, name ) { |
39 | setPixmap( Resource::loadPixmap( icon ) ); | 47 | setPixmap( Resource::loadPixmap( icon ) ); |
40 | setAutoRaise( TRUE ); | 48 | setAutoRaise( TRUE ); |
41 | setFocusPolicy( QWidget::NoFocus ); | 49 | setFocusPolicy( QWidget::NoFocus ); |
42 | setToggleButton( t ); | 50 | setToggleButton( t ); |
43 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 51 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
44 | } | 52 | } |
45 | }; | 53 | }; |
@@ -59,173 +67,184 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | |||
59 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 67 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
60 | layout->addWidget( TabWidget3 ); | 68 | layout->addWidget( TabWidget3 ); |
61 | 69 | ||
62 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 70 | tab_2 = new QWidget( TabWidget3, "tab_2" ); |
63 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); | 71 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); |
64 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); | 72 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); |
65 | tab2Layout->addWidget( l ); | 73 | tab2Layout->addWidget( l ); |
66 | QHBox *hbox1 = new QHBox( tab_2 ); | 74 | QHBox *hbox1 = new QHBox( tab_2 ); |
67 | m_appletListView = new QListView( hbox1 ); | 75 | m_appletListView = new QListView( hbox1 ); |
68 | m_appletListView->addColumn( "PluginList" ); | 76 | m_appletListView->addColumn( "PluginList" ); |
69 | m_appletListView->header()->hide(); | 77 | m_appletListView->header()->hide(); |
70 | m_appletListView->setSorting( -1 ); | 78 | m_appletListView->setSorting( -1 ); |
71 | QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); | 79 | QWhatsThis::add |
80 | ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); | ||
72 | QVBox *vbox1 = new QVBox( hbox1 ); | 81 | QVBox *vbox1 = new QVBox( hbox1 ); |
73 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); | 82 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); |
74 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); | 83 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); |
75 | tab2Layout->addWidget( hbox1 ); | 84 | tab2Layout->addWidget( hbox1 ); |
76 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); | 85 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); |
77 | 86 | ||
78 | // Misc tab | 87 | // Misc tab |
79 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | 88 | tab_3 = new QWidget( TabWidget3, "tab_3" ); |
80 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); | 89 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); |
81 | 90 | ||
82 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); | 91 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); |
83 | 92 | ||
84 | tab3Layout->addWidget( m_guiMisc ); | 93 | tab3Layout->addWidget( m_guiMisc ); |
85 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); | 94 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); |
86 | 95 | ||
87 | m_applets_changed = false; | ||
88 | |||
89 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); | 96 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); |
90 | 97 | previousItem = 0l; | |
91 | readConfig(); | 98 | readConfig(); |
92 | QPEApplication::showDialog( this ); | 99 | QPEApplication::showDialog( this ); |
93 | } | 100 | } |
94 | 101 | ||
95 | 102 | ||
103 | void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { | ||
104 | |||
105 | |||
106 | m_pluginManager = plugManager; | ||
107 | m_pluginLoader = plugLoader; | ||
108 | |||
109 | OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); | ||
110 | |||
111 | OPluginItem::List lst; | ||
112 | for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { | ||
113 | lst.prepend((*it)); | ||
114 | |||
115 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | ||
116 | |||
117 | if ( iface->guiPart()->configWidget(this) != 0l ) { | ||
118 | TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 ); | ||
119 | TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() | ||
120 | , iface->guiPart()->appName() ); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
125 | pluginManagement( (*it) ); | ||
126 | } | ||
127 | |||
128 | TabWidget3->setCurrentTab( tab_2 ); | ||
129 | } | ||
130 | |||
96 | /** | 131 | /** |
97 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 132 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
98 | * If registered against that today ist started on each resume. | 133 | * If registered against that today ist started on each resume. |
99 | */ | 134 | */ |
100 | void TodayConfig::setAutoStart() { | 135 | void TodayConfig::setAutoStart() { |
101 | Config cfg( "today" ); | 136 | OConfig cfg( "today" ); |
102 | cfg.setGroup( "Autostart" ); | 137 | cfg.setGroup( "Autostart" ); |
103 | if ( m_autoStart ) { | 138 | if ( m_autoStart ) { |
104 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); | 139 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); |
105 | e << QString( "add" ); | 140 | e << QString( "add" ); |
106 | e << QString( "today" ); | 141 | e << QString( "today" ); |
107 | e << QString( "%1" ).arg( m_autoStartTimer ); | 142 | e << QString( "%1" ).arg( m_autoStartTimer ); |
108 | } else { | 143 | } else { |
109 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); | 144 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); |
110 | e << QString( "remove" ); | 145 | e << QString( "remove" ); |
111 | e << QString( "today" ); | 146 | e << QString( "today" ); |
112 | } | 147 | } |
113 | } | 148 | } |
114 | 149 | ||
115 | /** | 150 | /** |
116 | * Read the config part | 151 | * Read the config part |
117 | */ | 152 | */ |
118 | void TodayConfig::readConfig() { | 153 | void TodayConfig::readConfig() { |
119 | Config cfg( "today" ); | 154 | OConfig cfg( "today" ); |
120 | cfg.setGroup( "Autostart" ); | 155 | cfg.setGroup( "Autostart" ); |
121 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); | 156 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); |
122 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); | 157 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); |
123 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); | 158 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); |
124 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); | 159 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); |
125 | 160 | ||
126 | cfg.setGroup( "General" ); | 161 | cfg.setGroup( "General" ); |
127 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 162 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
128 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); | 163 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); |
129 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); | 164 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); |
130 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); | 165 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); |
131 | |||
132 | |||
133 | cfg.setGroup( "Plugins" ); | ||
134 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | ||
135 | } | 166 | } |
136 | 167 | ||
137 | /** | 168 | /** |
138 | * Write the config part | 169 | * Write the config part |
139 | */ | 170 | */ |
140 | void TodayConfig::writeConfig() { | 171 | void TodayConfig::writeConfig() { |
141 | Config cfg( "today" ); | 172 | OConfig cfg( "today" ); |
142 | cfg.setGroup( "Plugins" ); | ||
143 | if ( m_applets_changed ) { | ||
144 | QStringList exclude; | ||
145 | QStringList include; | ||
146 | QStringList all_applets; | ||
147 | 173 | ||
148 | QListViewItemIterator list_it( m_appletListView ); | 174 | int position = m_appletListView->childCount(); |
149 | 175 | ||
176 | QListViewItemIterator list_it( m_appletListView ); | ||
177 | // | ||
150 | // this makes sure the names get saved in the order selected | 178 | // this makes sure the names get saved in the order selected |
151 | for ( ; list_it.current(); ++list_it ) { | 179 | for ( ; list_it.current(); ++list_it ) { |
152 | QMap <QString, QCheckListItem *>::Iterator it; | 180 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); |
153 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { | 181 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
154 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { | 182 | if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { |
155 | exclude << it.key(); | 183 | (*it).setPosition(position--); |
156 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ | 184 | m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); |
157 | include << it.key(); | ||
158 | } | ||
159 | if ( list_it.current() == (*it) ) { | ||
160 | all_applets << it.key(); | ||
161 | } | 185 | } |
162 | } | 186 | } |
163 | } | 187 | } |
164 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 188 | |
165 | cfg.writeEntry( "IncludeApplets", include, ',' ); | 189 | m_pluginManager->save(); |
166 | cfg.writeEntry( "AllApplets", all_applets, ',' ); | ||
167 | } | ||
168 | 190 | ||
169 | cfg.setGroup( "Autostart" ); | 191 | cfg.setGroup( "Autostart" ); |
170 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); | 192 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); |
171 | cfg.writeEntry( "autostart", m_autoStart ); | 193 | cfg.writeEntry( "autostart", m_autoStart ); |
172 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); | 194 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); |
173 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); | 195 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); |
174 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); | 196 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); |
175 | 197 | ||
176 | cfg.setGroup( "General" ); | 198 | cfg.setGroup( "General" ); |
177 | cfg.writeEntry( "IconSize", m_iconSize ); | 199 | cfg.writeEntry( "IconSize", m_iconSize ); |
178 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); | 200 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); |
179 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); | 201 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); |
180 | 202 | ||
181 | // set autostart settings | 203 | // set autostart settings |
182 | setAutoStart(); | 204 | setAutoStart(); |
205 | |||
206 | OPluginItem::List lst = m_pluginManager->managedPlugins(); | ||
207 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
208 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | ||
209 | if ( iface->guiPart()->configWidget(this) != 0l ) { | ||
210 | iface->guiPart()->configWidget(this)->writeConfig(); | ||
211 | } | ||
212 | } | ||
183 | } | 213 | } |
184 | 214 | ||
185 | 215 | ||
186 | void TodayConfig::moveSelectedUp() { | 216 | void TodayConfig::moveSelectedUp() { |
187 | QListViewItem *item = m_appletListView->selectedItem(); | 217 | QListViewItem *item = m_appletListView->selectedItem(); |
188 | if ( item && item->itemAbove() ) { | 218 | if ( item && item->itemAbove() ) { |
189 | item->itemAbove()->moveItem( item ); | 219 | item->itemAbove()->moveItem( item ); |
190 | } | 220 | } |
191 | } | 221 | } |
192 | 222 | ||
193 | 223 | ||
194 | void TodayConfig::moveSelectedDown() { | 224 | void TodayConfig::moveSelectedDown() { |
195 | QListViewItem *item = m_appletListView->selectedItem(); | 225 | QListViewItem *item = m_appletListView->selectedItem(); |
196 | if ( item && item->itemBelow() ) { | 226 | if ( item && item->itemBelow() ) { |
197 | item->moveItem( item->itemBelow() ); | 227 | item->moveItem( item->itemBelow() ); |
198 | } | 228 | } |
199 | } | 229 | } |
200 | 230 | ||
201 | 231 | ||
202 | /** | 232 | /** |
203 | * Set up the icons in the order/active tab | 233 | * Set up the icons in the order/active tab |
204 | */ | 234 | */ |
205 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { | 235 | void TodayConfig::pluginManagement( OPluginItem plugItem ) { |
206 | 236 | ||
207 | QCheckListItem *item; | 237 | QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); |
208 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); | ||
209 | 238 | ||
239 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); | ||
240 | QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); | ||
210 | if ( !icon.isNull() ) { | 241 | if ( !icon.isNull() ) { |
211 | item->setPixmap( 0, icon ); | 242 | item->setPixmap( 0, icon ); |
212 | } | 243 | } |
213 | 244 | item->setOn( plugItem.isEnabled() ); | |
214 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { | 245 | previousItem = item; |
215 | item->setOn( TRUE ); | ||
216 | } | 246 | } |
217 | 247 | ||
218 | m_applets[libName] = item; | ||
219 | |||
220 | // kind of hack to get the first tab as default. | ||
221 | TabWidget3->setCurrentTab( tab_2 ); | ||
222 | } | ||
223 | 248 | ||
224 | void TodayConfig::appletChanged() { | ||
225 | m_applets_changed = true; | ||
226 | } | ||
227 | |||
228 | |||
229 | TodayConfig::~TodayConfig() { | ||
230 | } | ||
231 | 249 | ||
250 | TodayConfig::~TodayConfig() {} | ||