summaryrefslogtreecommitdiff
path: root/core/pim/today/todayconfig.cpp
Unidiff
Diffstat (limited to 'core/pim/today/todayconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/todayconfig.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index 4f23471..532d126 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -26,25 +26,24 @@
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qheader.h> 28#include <qheader.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qvbox.h> 30#include <qvbox.h>
31#include <qtoolbutton.h> 31#include <qtoolbutton.h>
32 32
33class ToolButton : public QToolButton { 33class ToolButton : public QToolButton {
34 34
35public: 35public:
36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
37 : QToolButton( parent, name ) { 37 : QToolButton( parent, name ) {
38 // setTextLabel( name );
39 setPixmap( Resource::loadPixmap( icon ) ); 38 setPixmap( Resource::loadPixmap( icon ) );
40 setAutoRaise( TRUE ); 39 setAutoRaise( TRUE );
41 setFocusPolicy( QWidget::NoFocus ); 40 setFocusPolicy( QWidget::NoFocus );
42 setToggleButton( t ); 41 setToggleButton( t );
43 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 42 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
44 } 43 }
45}; 44};
46 45
47 46
48/** 47/**
49 * The class has currently quite some duplicate code. 48 * The class has currently quite some duplicate code.
50 * By that way it would be real easy to have it as seperate app in settings tab 49 * By that way it would be real easy to have it as seperate app in settings tab
@@ -60,127 +59,133 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags
60 TabWidget3->setAutoMask( FALSE ); 59 TabWidget3->setAutoMask( FALSE );
61 TabWidget3->setTabShape( QTabWidget::Rounded ); 60 TabWidget3->setTabShape( QTabWidget::Rounded );
62 layout->addWidget( TabWidget3 ); 61 layout->addWidget( TabWidget3 );
63 62
64 tab_2 = new QWidget( TabWidget3, "tab_2" ); 63 tab_2 = new QWidget( TabWidget3, "tab_2" );
65 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); 64 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 );
66 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); 65 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 );
67 tab2Layout->addWidget( l ); 66 tab2Layout->addWidget( l );
68 QHBox *hbox1 = new QHBox( tab_2 ); 67 QHBox *hbox1 = new QHBox( tab_2 );
69 m_appletListView = new QListView( hbox1 ); 68 m_appletListView = new QListView( hbox1 );
70 m_appletListView->addColumn( "PluginList" ); 69 m_appletListView->addColumn( "PluginList" );
71 m_appletListView->header()->hide(); 70 m_appletListView->header()->hide();
71 m_appletListView->setSorting( -1 );
72 QVBox *vbox1 = new QVBox( hbox1 ); 72 QVBox *vbox1 = new QVBox( hbox1 );
73 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) ); 73 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) );
74 new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) ); 74 new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) );
75 tab2Layout->addWidget( hbox1 ); 75 tab2Layout->addWidget( hbox1 );
76
77 TabWidget3->insertTab( tab_2, tr( "active/order" ) ); 76 TabWidget3->insertTab( tab_2, tr( "active/order" ) );
77
78 tab_3 = new QWidget( TabWidget3, "tab_3" ); 78 tab_3 = new QWidget( TabWidget3, "tab_3" );
79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); 79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 );
80 QHBox *hbox_clip = new QHBox( tab_3 ); 80 tab3Layout->setMargin( 20 );
81 TextLabel1 = new QLabel( hbox_clip, "TextLabel1" );
82 TextLabel1->setText( tr( "Clip after how\n"
83 "many letters" ) );
84 SpinBox7 = new QSpinBox( hbox_clip, "SpinBox7" );
85 SpinBox7->setMaxValue( 80 );
86 QHBox *hbox_auto = new QHBox( tab_3 ); 81 QHBox *hbox_auto = new QHBox( tab_3 );
87 TextLabel2 = new QLabel( hbox_auto, "AutoStart" ); 82 TextLabel2 = new QLabel( hbox_auto, "AutoStart" );
88 TextLabel2->setText( tr( "autostart on \nresume? (Opie only)" ) ); 83 TextLabel2->setText( tr( "autostart on \nresume?\n (Opie only)" ) );
89 CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" ); 84 CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" );
90 QHBox *hbox_inactive = new QHBox( tab_3 ); 85 QHBox *hbox_inactive = new QHBox( tab_3 );
91 TimeLabel = new QLabel( hbox_inactive , "TimeLabel" ); 86 TimeLabel = new QLabel( hbox_inactive , "TimeLabel" );
92 TimeLabel->setText( tr( "minutes inactive" ) ); 87 TimeLabel->setText( tr( "minutes inactive" ) );
93 SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner"); 88 SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner" );
94 tab3Layout->addWidget( hbox_clip );
95 tab3Layout->addWidget( hbox_auto ); 89 tab3Layout->addWidget( hbox_auto );
96 tab3Layout->addWidget( hbox_inactive ); 90 tab3Layout->addWidget( hbox_inactive );
97 TabWidget3->insertTab( tab_3, tr( "Misc" ) ); 91 TabWidget3->insertTab( tab_3, tr( "Misc" ) );
98 92
99 m_applets_changed = false; 93 m_applets_changed = false;
100 94
101 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); 95 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) );
102 96
103 readConfig(); 97 readConfig();
104 showMaximized(); 98 showMaximized();
105} 99}
106 100
107 101
108/** 102/**
109 * Autostart, uses the new (opie only) autostart method in the launcher code. 103 * Autostart, uses the new (opie only) autostart method in the launcher code.
110 * If registered against that today ist started on each resume. 104 * If registered against that today ist started on each resume.
111 */ 105 */
112void TodayConfig::setAutoStart() { 106void TodayConfig::setAutoStart() {
113 Config cfg( "today" ); 107 Config cfg( "today" );
114 cfg.setGroup( "Autostart" ); 108 cfg.setGroup( "Autostart" );
115 int autostart = cfg.readNumEntry( "autostart", 1); 109 int autostart = cfg.readNumEntry( "autostart", 1 );
116 if ( autostart ) { 110 if ( autostart ) {
117 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); 111 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" );
118 e << QString( "add" ); 112 e << QString( "add" );
119 e << QString( "today" ); 113 e << QString( "today" );
120 e << m_autoStartTimer; 114 e << m_autoStartTimer;
121 } else { 115 } else {
122 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); 116 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" );
123 e << QString( "remove" ); 117 e << QString( "remove" );
124 e << QString( "today" ); 118 e << QString( "today" );
125 } 119 }
126} 120}
127 121
128/** 122/**
129 * Read the config part 123 * Read the config part
130 */ 124 */
131void TodayConfig::readConfig() { 125void TodayConfig::readConfig() {
132 Config cfg( "today" ); 126 Config cfg( "today" );
133 cfg.setGroup( "Autostart" ); 127 cfg.setGroup( "Autostart" );
134 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 128 m_autoStart = cfg.readNumEntry( "autostart", 1 );
135 CheckBoxAuto->setChecked( m_autoStart ); 129 CheckBoxAuto->setChecked( m_autoStart );
136 m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" ); 130 m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" );
137 SpinBoxTime->setValue( m_autoStartTimer.toInt() ); 131 SpinBoxTime->setValue( m_autoStartTimer.toInt() );
138 132
139 cfg.setGroup( "Applets" ); 133 cfg.setGroup( "Plugins" );
140 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
141} 135}
142 136
143/** 137/**
144 * Write the config part 138 * Write the config part
145 */ 139 */
146void TodayConfig::writeConfig() { 140void TodayConfig::writeConfig() {
147 Config cfg( "today" ); 141 Config cfg( "today" );
148 cfg. setGroup ( "Applets" ); 142 cfg.setGroup( "Plugins" );
149 if ( m_applets_changed ) { 143 if ( m_applets_changed ) {
150 QStringList exclude; 144 QStringList exclude;
151 QStringList include; 145 QStringList include;
152 QMap <QString, QCheckListItem *>::Iterator it; 146 QStringList all_applets;
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 147
154 if ( !(*it)-> isOn () ) { 148 QListViewItemIterator list_it( m_appletListView );
155 exclude << it.key(); 149
156 } else { 150 // this makes sure the names get saved in the order selected
157 include << it.key(); 151 for ( ; list_it.current(); ++list_it ) {
152 QMap <QString, QCheckListItem *>::Iterator it;
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) {
154 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
155 exclude << it.key();
156 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
157 include << it.key();
158 }
159 if ( list_it.current() == (*it) ) {
160 all_applets << it.key();
161 }
158 } 162 }
159 } 163 }
160 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 164 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
161 cfg.writeEntry( "IncludeApplets", include, ',' ); 165 cfg.writeEntry( "IncludeApplets", include, ',' );
166 cfg.writeEntry( "AllApplets", all_applets, ',' );
162 } 167 }
163 168
164 cfg.setGroup( "Autostart" ); 169 cfg.setGroup( "Autostart" );
165 m_autoStart = CheckBoxAuto->isChecked(); 170 m_autoStart = CheckBoxAuto->isChecked();
166 cfg.writeEntry( "autostart", m_autoStart ); 171 cfg.writeEntry( "autostart", m_autoStart );
167 m_autoStartTimer = SpinBoxTime->value(); 172 m_autoStartTimer = SpinBoxTime->value();
168 cfg.readEntry( "autostartdelay", m_autoStartTimer ); 173 cfg.readEntry( "autostartdelay", m_autoStartTimer );
169} 174}
170 175
171 176
172void TodayConfig::moveSelectedUp() { 177void TodayConfig::moveSelectedUp() {
173 QListViewItem *item = m_appletListView->selectedItem(); 178 QListViewItem *item = m_appletListView->selectedItem();
174 if ( item && item->itemAbove() ) { 179 if ( item && item->itemAbove() ) {
175 item->itemAbove()->moveItem( item ); 180 item->itemAbove()->moveItem( item );
176 } 181 }
177} 182}
178 183
179 184
180void TodayConfig::moveSelectedDown() { 185void TodayConfig::moveSelectedDown() {
181 QListViewItem *item = m_appletListView->selectedItem(); 186 QListViewItem *item = m_appletListView->selectedItem();
182 if ( item && item->itemBelow() ) { 187 if ( item && item->itemBelow() ) {
183 item->moveItem( item->itemBelow() ); 188 item->moveItem( item->itemBelow() );
184 } 189 }
185} 190}
186 191
@@ -188,28 +193,28 @@ void TodayConfig::moveSelectedDown() {
188/** 193/**
189 * Set up the 194 * Set up the
190 */ 195 */
191void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { 196void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) {
192 197
193 QCheckListItem *item; 198 QCheckListItem *item;
194 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); 199 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox );
195 200
196 if ( !icon.isNull() ) { 201 if ( !icon.isNull() ) {
197 item->setPixmap( 0, icon ); 202 item->setPixmap( 0, icon );
198 } 203 }
199 204
200 qDebug (" SUCHNAME: " + name );
201 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { 205 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) {
202 item->setOn( TRUE ); 206 item->setOn( TRUE );
203 } 207 }
208
204 m_applets[libName] = item; 209 m_applets[libName] = item;
205} 210}
206 211
207 212
208void TodayConfig::appletChanged() { 213void TodayConfig::appletChanged() {
209 m_applets_changed = true; 214 m_applets_changed = true;
210} 215}
211 216
212 217
213TodayConfig::~TodayConfig() { 218TodayConfig::~TodayConfig() {
214} 219}
215 220