author | harlekin <harlekin> | 2002-03-07 11:06:58 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-07 11:06:58 (UTC) |
commit | 69d2df15c2dbd280f6ed99d5eecf487345f1de08 (patch) (unidiff) | |
tree | 7a4f07836247e50c1cd2ed112010c172f4f9a371 | |
parent | a2f42b6df21b2e5d52b49376542d0f4c7443a897 (diff) | |
download | opie-69d2df15c2dbd280f6ed99d5eecf487345f1de08.zip opie-69d2df15c2dbd280f6ed99d5eecf487345f1de08.tar.gz opie-69d2df15c2dbd280f6ed99d5eecf487345f1de08.tar.bz2 |
support for the launcher autostart feature
-rw-r--r-- | core/pim/today/today.cpp | 41 | ||||
-rw-r--r-- | core/pim/today/today.h | 1 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 14 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 2 |
4 files changed, 48 insertions, 10 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 6a0e9fc..0fa7ad5 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -41,53 +41,71 @@ | |||
41 | 41 | ||
42 | //#include <iostream.h> | 42 | //#include <iostream.h> |
43 | //#include <unistd.h> | 43 | //#include <unistd.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | 45 | ||
46 | int MAX_LINES_TASK; | 46 | int MAX_LINES_TASK; |
47 | int MAX_CHAR_CLIP; | 47 | int MAX_CHAR_CLIP; |
48 | int MAX_LINES_MEET; | 48 | int MAX_LINES_MEET; |
49 | int SHOW_LOCATION; | 49 | int SHOW_LOCATION; |
50 | int SHOW_NOTES; | 50 | int SHOW_NOTES; |
51 | // show only later dates | 51 | // show only later dates |
52 | int ONLY_LATER; | 52 | int ONLY_LATER; |
53 | int AUTOSTART; | ||
53 | /* | 54 | /* |
54 | * Constructs a Example which is a child of 'parent', with the | 55 | * Constructs a Example which is a child of 'parent', with the |
55 | * name 'name' and widget flags set to 'f' | 56 | * name 'name' and widget flags set to 'f' |
56 | */ | 57 | */ |
57 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 58 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
58 | : TodayBase( parent, name, fl ) { | 59 | : TodayBase( parent, name, fl ) { |
59 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 60 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
60 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 61 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
61 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 62 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
62 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 63 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
63 | 64 | ||
65 | |||
66 | autoStart(); | ||
64 | draw(); | 67 | draw(); |
65 | } | 68 | } |
66 | 69 | ||
67 | 70 | ||
71 | void Today::autoStart() { | ||
72 | Config cfg("today"); | ||
73 | cfg.setGroup("Autostart"); | ||
74 | AUTOSTART = cfg.readNumEntry("autostart",1); | ||
75 | if (AUTOSTART) { | ||
76 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | ||
77 | e << QString("add"); | ||
78 | e << QString("today"); | ||
79 | } else { | ||
80 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | ||
81 | e << QString("remove"); | ||
82 | e << QString("today"); | ||
83 | } | ||
84 | } | ||
85 | |||
68 | void Today::draw() { | 86 | void Today::draw() { |
69 | init(); | 87 | init(); |
70 | getDates(); | 88 | getDates(); |
71 | getMail(); | 89 | getMail(); |
72 | getTodo(); | 90 | getTodo(); |
73 | // how often refresh | 91 | // how often refresh |
74 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); | 92 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); |
75 | } | 93 | } |
76 | 94 | ||
77 | void Today::init() { | 95 | void Today::init() { |
78 | QDate date = QDate::currentDate(); | 96 | QDate date = QDate::currentDate(); |
79 | QString time = (date.toString()); | 97 | QString time = (tr( date.toString() ), white); |
80 | 98 | ||
81 | TextLabel1->setText("<qt><font color=white>" +time + "<font></qt>"); | 99 | TextLabel1->setText(time); |
82 | db = new DateBookDB; | 100 | db = new DateBookDB; |
83 | 101 | ||
84 | // read config | 102 | // read config |
85 | Config cfg("today"); | 103 | Config cfg("today"); |
86 | cfg.setGroup("BaseConfig"); | 104 | cfg.setGroup("BaseConfig"); |
87 | 105 | ||
88 | // how many lines should be showed in the task section | 106 | // how many lines should be showed in the task section |
89 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 107 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
90 | // after how many chars should the be cut off on tasks and notes | 108 | // after how many chars should the be cut off on tasks and notes |
91 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); | 109 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); |
92 | // how many lines should be showed in the datebook section | 110 | // how many lines should be showed in the datebook section |
93 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 111 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
@@ -114,42 +132,47 @@ void Today::startConfig() { | |||
114 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 132 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
115 | // location show box | 133 | // location show box |
116 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 134 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
117 | // notes show box | 135 | // notes show box |
118 | conf->CheckBox2->setChecked(SHOW_NOTES); | 136 | conf->CheckBox2->setChecked(SHOW_NOTES); |
119 | // task lines | 137 | // task lines |
120 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 138 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
121 | // clip when? | 139 | // clip when? |
122 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 140 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
123 | // only later | 141 | // only later |
124 | conf->CheckBox3->setChecked(ONLY_LATER); | 142 | conf->CheckBox3->setChecked(ONLY_LATER); |
125 | 143 | ||
144 | conf->CheckBoxAuto->setChecked(AUTOSTART); | ||
145 | |||
126 | conf->exec(); | 146 | conf->exec(); |
127 | 147 | ||
128 | int maxlinestask = conf->SpinBox2->value(); | 148 | int maxlinestask = conf->SpinBox2->value(); |
129 | int maxmeet = conf->SpinBox1->value(); | 149 | int maxmeet = conf->SpinBox1->value(); |
130 | int location = conf->CheckBox1->isChecked(); | 150 | int location = conf->CheckBox1->isChecked(); |
131 | int notes = conf->CheckBox2->isChecked(); | 151 | int notes = conf->CheckBox2->isChecked(); |
132 | int maxcharclip = conf->SpinBox7->value(); | 152 | int maxcharclip = conf->SpinBox7->value(); |
133 | int onlylater = conf->CheckBox3->isChecked(); | 153 | int onlylater = conf->CheckBox3->isChecked(); |
134 | 154 | int autostart =conf->CheckBoxAuto->isChecked(); | |
155 | |||
135 | cfg.writeEntry("maxlinestask",maxlinestask); | 156 | cfg.writeEntry("maxlinestask",maxlinestask); |
136 | cfg.writeEntry("maxcharclip", maxcharclip); | 157 | cfg.writeEntry("maxcharclip", maxcharclip); |
137 | cfg.writeEntry("maxlinesmeet",maxmeet); | 158 | cfg.writeEntry("maxlinesmeet",maxmeet); |
138 | cfg.writeEntry("showlocation",location); | 159 | cfg.writeEntry("showlocation",location); |
139 | cfg.writeEntry("shownotes", notes); | 160 | cfg.writeEntry("shownotes", notes); |
140 | cfg.writeEntry("onlylater", onlylater); | 161 | cfg.writeEntry("onlylater", onlylater); |
162 | cfg.setGroup("Autostart"); | ||
163 | cfg.writeEntry("autostart", autostart); | ||
141 | // sync it to "disk" | 164 | // sync it to "disk" |
142 | cfg.write(); | 165 | cfg.write(); |
143 | 166 | autoStart(); | |
144 | draw(); | 167 | draw(); |
145 | } | 168 | } |
146 | 169 | ||
147 | 170 | ||
148 | /* | 171 | /* |
149 | * Get all events that are in the datebook xml file for today | 172 | * Get all events that are in the datebook xml file for today |
150 | */ | 173 | */ |
151 | void Today::getDates() { | 174 | void Today::getDates() { |
152 | QDate date = QDate::currentDate(); | 175 | QDate date = QDate::currentDate(); |
153 | QTime time = QTime::currentTime(); | 176 | QTime time = QTime::currentTime(); |
154 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 177 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
155 | 178 | ||
@@ -215,25 +238,25 @@ void Today::getDates() { | |||
215 | // end time of event | 238 | // end time of event |
216 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | 239 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); |
217 | } | 240 | } |
218 | msg += "<BR>"; | 241 | msg += "<BR>"; |
219 | // include possible note or not | 242 | // include possible note or not |
220 | if (SHOW_NOTES == 1) { | 243 | if (SHOW_NOTES == 1) { |
221 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 244 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
222 | } | 245 | } |
223 | } | 246 | } |
224 | } | 247 | } |
225 | } | 248 | } |
226 | if (msg.isEmpty()) { | 249 | if (msg.isEmpty()) { |
227 | msg = "No more appointments today"; | 250 | msg = tr("No more appointments today"); |
228 | } | 251 | } |
229 | DatesField->setText(msg); | 252 | DatesField->setText(msg); |
230 | } | 253 | } |
231 | } | 254 | } |
232 | 255 | ||
233 | /* | 256 | /* |
234 | * Parse in the todolist.xml | 257 | * Parse in the todolist.xml |
235 | */ | 258 | */ |
236 | QList<TodoItem> Today::loadTodo(const char *filename) { | 259 | QList<TodoItem> Today::loadTodo(const char *filename) { |
237 | DOM *todo; | 260 | DOM *todo; |
238 | ELE *tasks; | 261 | ELE *tasks; |
239 | ELE **tasklist; | 262 | ELE **tasklist; |
@@ -331,34 +354,34 @@ void Today::getTodo() { | |||
331 | for( item = todolist.first(); item; item = todolist.next()) { | 354 | for( item = todolist.first(); item; item = todolist.next()) { |
332 | if (!(item->getCompleted() == 1) ) { | 355 | if (!(item->getCompleted() == 1) ) { |
333 | count++; | 356 | count++; |
334 | if (count <= MAX_LINES_TASK) { | 357 | if (count <= MAX_LINES_TASK) { |
335 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | 358 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); |
336 | } | 359 | } |
337 | } | 360 | } |
338 | } | 361 | } |
339 | } | 362 | } |
340 | 363 | ||
341 | if (count > 0) { | 364 | if (count > 0) { |
342 | if( count == 1 ) { | 365 | if( count == 1 ) { |
343 | output = QString("There is <b> 1</b> active task: <br>" ); | 366 | output = tr("There is <b> 1</b> active task: <br>" ); |
344 | } else { | 367 | } else { |
345 | output = QString("There are <b> %1</b> active tasks: <br>").arg(count); | 368 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
346 | } | 369 | } |
347 | output += tmpout; | 370 | output += tmpout; |
348 | } else { | 371 | } else { |
349 | output = ("No active tasks"); | 372 | output = tr("No active tasks"); |
350 | } | 373 | } |
351 | 374 | ||
352 | TodoField->setText(output); | 375 | TodoField->setText(tr(output)); |
353 | } | 376 | } |
354 | 377 | ||
355 | /* | 378 | /* |
356 | * launches datebook | 379 | * launches datebook |
357 | */ | 380 | */ |
358 | void Today::startDatebook() { | 381 | void Today::startDatebook() { |
359 | QCopEnvelope e("QPE/System", "execute(QString)"); | 382 | QCopEnvelope e("QPE/System", "execute(QString)"); |
360 | e << QString("datebook"); | 383 | e << QString("datebook"); |
361 | } | 384 | } |
362 | 385 | ||
363 | /* | 386 | /* |
364 | * launches todolist | 387 | * launches todolist |
diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 6b8c0bf..07bfd61 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h | |||
@@ -39,24 +39,25 @@ class Today : public TodayBase | |||
39 | 39 | ||
40 | private slots: | 40 | private slots: |
41 | void startConfig(); | 41 | void startConfig(); |
42 | void startTodo(); | 42 | void startTodo(); |
43 | void startDatebook(); | 43 | void startDatebook(); |
44 | void startMail(); | 44 | void startMail(); |
45 | void draw(); | 45 | void draw(); |
46 | private: | 46 | private: |
47 | void init(); | 47 | void init(); |
48 | void getDates(); | 48 | void getDates(); |
49 | void getTodo(); | 49 | void getTodo(); |
50 | void getMail(); | 50 | void getMail(); |
51 | void autoStart(); | ||
51 | QList<TodoItem> loadTodo(const char *filename); | 52 | QList<TodoItem> loadTodo(const char *filename); |
52 | private: | 53 | private: |
53 | DateBookDB *db; | 54 | DateBookDB *db; |
54 | todayconfig *conf; | 55 | todayconfig *conf; |
55 | //Config cfg; | 56 | //Config cfg; |
56 | int MAX_LINES_TASK; | 57 | int MAX_LINES_TASK; |
57 | int MAX_CHAR_CLIP; | 58 | int MAX_CHAR_CLIP; |
58 | int MAX_LINES_MEET; | 59 | int MAX_LINES_MEET; |
59 | int SHOW_LOCATION; | 60 | int SHOW_LOCATION; |
60 | int SHOW_NOTES; | 61 | int SHOW_NOTES; |
61 | }; | 62 | }; |
62 | #endif // TODAY_H | 63 | #endif // TODAY_H |
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 4f2633d..7c690a7 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -113,23 +113,35 @@ todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags | |||
113 | Frame14->setFrameShape( QFrame::StyledPanel ); | 113 | Frame14->setFrameShape( QFrame::StyledPanel ); |
114 | Frame14->setFrameShadow( QFrame::Raised ); | 114 | Frame14->setFrameShadow( QFrame::Raised ); |
115 | 115 | ||
116 | TextLabel1 = new QLabel( Frame14, "TextLabel1" ); | 116 | TextLabel1 = new QLabel( Frame14, "TextLabel1" ); |
117 | TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); | 117 | TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); |
118 | TextLabel1->setText( tr( "Clip after how\n" | 118 | TextLabel1->setText( tr( "Clip after how\n" |
119 | "many letters" ) ); | 119 | "many letters" ) ); |
120 | 120 | ||
121 | SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); | 121 | SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); |
122 | SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); | 122 | SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); |
123 | SpinBox7->setMaxValue( 80 ); | 123 | SpinBox7->setMaxValue( 80 ); |
124 | SpinBox7->setValue( 30 ); | 124 | SpinBox7->setValue( 30 ); |
125 | TabWidget3->insertTab( tab_3, tr( "All" ) ); | 125 | |
126 | TextLabel2 = new QLabel( Frame14, "AutoStart" ); | ||
127 | TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); | ||
128 | TextLabel2->setText( tr( "Should today be\n" | ||
129 | "autostarted on\n" | ||
130 | "resume ?" | ||
131 | " (Opie only)" ) ); | ||
132 | |||
133 | CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); | ||
134 | CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); | ||
135 | |||
136 | TabWidget3->insertTab( tab_3, tr( "Misc" ) ); | ||
137 | |||
126 | } | 138 | } |
127 | 139 | ||
128 | /* | 140 | /* |
129 | * Destroys the object and frees any allocated resources | 141 | * Destroys the object and frees any allocated resources |
130 | */ | 142 | */ |
131 | todayconfig::~todayconfig() | 143 | todayconfig::~todayconfig() |
132 | { | 144 | { |
133 | // no need to delete child widgets, Qt does it all for us | 145 | // no need to delete child widgets, Qt does it all for us |
134 | } | 146 | } |
135 | 147 | ||
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index 7facf85..020097d 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h | |||
@@ -25,27 +25,29 @@ class todayconfig : public QDialog | |||
25 | { | 25 | { |
26 | Q_OBJECT | 26 | Q_OBJECT |
27 | 27 | ||
28 | public: | 28 | public: |
29 | todayconfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 29 | todayconfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
30 | ~todayconfig(); | 30 | ~todayconfig(); |
31 | 31 | ||
32 | QTabWidget* TabWidget3; | 32 | QTabWidget* TabWidget3; |
33 | QWidget* tab; | 33 | QWidget* tab; |
34 | QFrame* Frame8; | 34 | QFrame* Frame8; |
35 | QLabel* TextLabel4; | 35 | QLabel* TextLabel4; |
36 | QLabel* TextLabel5; | 36 | QLabel* TextLabel5; |
37 | QLabel* TextLabel2; | ||
37 | QCheckBox* CheckBox3; | 38 | QCheckBox* CheckBox3; |
38 | QCheckBox* CheckBox2; | 39 | QCheckBox* CheckBox2; |
39 | QCheckBox* CheckBox1; | 40 | QCheckBox* CheckBox1; |
41 | QCheckBox* CheckBoxAuto; | ||
40 | QSpinBox* SpinBox1; | 42 | QSpinBox* SpinBox1; |
41 | QLabel* TextLabel3; | 43 | QLabel* TextLabel3; |
42 | QWidget* tab_2; | 44 | QWidget* tab_2; |
43 | QFrame* Frame9; | 45 | QFrame* Frame9; |
44 | QLabel* TextLabel6; | 46 | QLabel* TextLabel6; |
45 | QSpinBox* SpinBox2; | 47 | QSpinBox* SpinBox2; |
46 | QWidget* tab_3; | 48 | QWidget* tab_3; |
47 | QFrame* Frame14; | 49 | QFrame* Frame14; |
48 | QLabel* TextLabel1; | 50 | QLabel* TextLabel1; |
49 | QSpinBox* SpinBox7; | 51 | QSpinBox* SpinBox7; |
50 | 52 | ||
51 | }; | 53 | }; |