Diffstat (limited to 'core/pim/today/todayconfig.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/today/todayconfig.cpp | 273 |
1 files changed, 171 insertions, 102 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 | |||
@@ -3,7 +3,4 @@ | |||
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 | * |
@@ -21,4 +18,7 @@ | |||
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> |
@@ -26,16 +26,40 @@ | |||
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> |
30 | #include <qvbox.h> | ||
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 | }; | ||
31 | 48 | ||
32 | todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags fl ) | 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 ) | 57 | |
58 | if ( !name ) { | ||
35 | setName( "todayconfig" ); | 59 | setName( "todayconfig" ); |
36 | resize( 175, 232 ); | 60 | } |
37 | setCaption( tr( "Today config" ) ); | 61 | setCaption( tr( "Today config" ) ); |
38 | 62 | ||
63 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
39 | TabWidget3 = new QTabWidget( this, "TabWidget3" ); | 64 | 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() ) ); | 65 | TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); |
@@ -43,108 +67,153 @@ todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags | |||
43 | TabWidget3->setTabShape( QTabWidget::Rounded ); | 67 | TabWidget3->setTabShape( QTabWidget::Rounded ); |
44 | 68 | layout->addWidget( TabWidget3 ); | |
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 | 69 | ||
92 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 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" ) ); | ||
93 | 104 | ||
94 | Frame9 = new QFrame( tab_2, "Frame9" ); | 105 | m_applets_changed = false; |
95 | Frame9->setGeometry( QRect( -5, 0, 230, 310 ) ); | ||
96 | Frame9->setFrameShape( QFrame::StyledPanel ); | ||
97 | Frame9->setFrameShadow( QFrame::Raised ); | ||
98 | 106 | ||
99 | TextLabel6 = new QLabel( Frame9, "TextLabel6" ); | 107 | connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); |
100 | TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) ); | ||
101 | TextLabel6->setText( tr( "How many\n" | ||
102 | "tasks should \n" | ||
103 | "be shown?" ) ); | ||
104 | 108 | ||
105 | SpinBox2 = new QSpinBox( Frame9, "SpinBox2" ); | 109 | readConfig(); |
106 | SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) ); | 110 | } |
107 | SpinBox2->setMaxValue( 20 ); | ||
108 | SpinBox2->setValue( 5 ); | ||
109 | TabWidget3->insertTab( tab_2, tr( "Tasks" ) ); | ||
110 | 111 | ||
111 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | ||
112 | 112 | ||
113 | Frame14 = new QFrame( tab_3, "Frame14" ); | 113 | /** |
114 | Frame14->setGeometry( QRect( -5, 0, 200, 220 ) ); | 114 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
115 | Frame14->setFrameShape( QFrame::StyledPanel ); | 115 | * If registered against that today ist started on each resume. |
116 | Frame14->setFrameShadow( QFrame::Raised ); | 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 | } | ||
117 | 132 | ||
118 | TextLabel1 = new QLabel( Frame14, "TextLabel1" ); | 133 | /** |
119 | TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); | 134 | * Read the config part |
120 | TextLabel1->setText( tr( "Clip after how\n" | 135 | */ |
121 | "many letters" ) ); | 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 | } | ||
122 | 147 | ||
123 | SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); | 148 | /** |
124 | SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); | 149 | * Write the config part |
125 | SpinBox7->setMaxValue( 80 ); | 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 | } | ||
126 | 168 | ||
127 | TextLabel2 = new QLabel( Frame14, "AutoStart" ); | 169 | cfg.setGroup( "Autostart" ); |
128 | TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); | 170 | m_autoStart = CheckBoxAuto->isChecked(); |
129 | TextLabel2->setText( tr( "Should today be\n" | 171 | cfg.writeEntry( "autostart", m_autoStart ); |
130 | "autostarted on\n" | 172 | m_autoStartTimer = SpinBoxTime->value(); |
131 | "resume?" | 173 | cfg.readEntry( "autostartdelay", m_autoStartTimer ); |
132 | " (Opie only)" ) ); | 174 | } |
133 | 175 | ||
134 | CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); | ||
135 | CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); | ||
136 | 176 | ||
137 | TimeLabel = new QLabel( Frame14, "TimeLabel" ); | 177 | void TodayConfig::moveSelectedUp() { |
138 | TimeLabel->setGeometry( QRect ( 20, 120, 120, 45 ) ); | 178 | QListViewItem *item = m_appletListView->selectedItem(); |
139 | TimeLabel->setText( tr( "Activate the \n" | 179 | if ( item && item->itemAbove() ) { |
140 | "autostart after how\n" | 180 | item->itemAbove()->moveItem( item ); |
141 | "many minutes?" ) ); | 181 | } |
142 | SpinBoxTime = new QSpinBox( Frame14, "TimeSpinner"); | 182 | } |
143 | SpinBoxTime->setGeometry( QRect( 115, 120, 58, 25 ) ); | ||
144 | 183 | ||
145 | TabWidget3->insertTab( tab_3, tr( "Misc" ) ); | ||
146 | 184 | ||
185 | void TodayConfig::moveSelectedDown() { | ||
186 | QListViewItem *item = m_appletListView->selectedItem(); | ||
187 | if ( item && item->itemBelow() ) { | ||
188 | item->moveItem( item->itemBelow() ); | ||
147 | } | 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; | ||
210 | } | ||
211 | |||
212 | |||
213 | void TodayConfig::appletChanged() { | ||
214 | m_applets_changed = true; | ||
215 | } | ||
216 | |||
148 | 217 | ||
149 | todayconfig::~todayconfig() { | 218 | TodayConfig::~TodayConfig() { |
150 | } | 219 | } |