Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 496f125..4ee5292 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -204,217 +204,224 @@ void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | |||
204 | mAlarmSoundButton = new QPushButton(parent); | 204 | mAlarmSoundButton = new QPushButton(parent); |
205 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 205 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
206 | mAlarmSoundButton->setToggleButton(true); | 206 | mAlarmSoundButton->setToggleButton(true); |
207 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 207 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
208 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 208 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
209 | alarmLayout->addWidget(mAlarmSoundButton); | 209 | alarmLayout->addWidget(mAlarmSoundButton); |
210 | 210 | ||
211 | mAlarmProgramButton = new QPushButton(parent); | 211 | mAlarmProgramButton = new QPushButton(parent); |
212 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 212 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
213 | mAlarmProgramButton->setToggleButton(true); | 213 | mAlarmProgramButton->setToggleButton(true); |
214 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 214 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
215 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 215 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
216 | alarmLayout->addWidget(mAlarmProgramButton); | 216 | alarmLayout->addWidget(mAlarmProgramButton); |
217 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 217 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
218 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 218 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
219 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 219 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
220 | // mAlarmSoundButton->hide(); | 220 | // mAlarmSoundButton->hide(); |
221 | // mAlarmProgramButton->hide(); | 221 | // mAlarmProgramButton->hide(); |
222 | // } | 222 | // } |
223 | } | 223 | } |
224 | 224 | ||
225 | void KOEditorGeneral::pickAlarmSound() | 225 | void KOEditorGeneral::pickAlarmSound() |
226 | { | 226 | { |
227 | 227 | ||
228 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | ||
228 | //QString prefix = mAlarmSound; | 229 | //QString prefix = mAlarmSound; |
229 | if (!mAlarmSoundButton->isOn()) { | 230 | if (!mAlarmSoundButton->isOn()) { |
230 | //mAlarmSound = ""; | 231 | //mAlarmSound = ""; |
231 | QToolTip::remove(mAlarmSoundButton); | 232 | QToolTip::remove(mAlarmSoundButton); |
232 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 233 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
233 | mAlarmProgramButton->setOn(true); | 234 | mAlarmProgramButton->setOn(true); |
234 | mAlarmSoundButton->setOn(false); | 235 | mAlarmSoundButton->setOn(false); |
236 | pickAlarmProgram(); | ||
235 | } else { | 237 | } else { |
236 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 238 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
237 | i18n("*.wav|Wav Files"), 0)); | 239 | i18n("*.wav|Wav Files"), 0)); |
238 | if (!fileName.isEmpty()) { | 240 | if (!fileName.isEmpty()) { |
239 | mAlarmSound = fileName; | 241 | mAlarmSound = fileName; |
240 | QToolTip::remove(mAlarmSoundButton); | 242 | QToolTip::remove(mAlarmSoundButton); |
241 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 243 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
242 | QToolTip::add(mAlarmSoundButton, dispStr); | 244 | QToolTip::add(mAlarmSoundButton, dispStr); |
243 | mAlarmProgramButton->setOn(false); | 245 | mAlarmProgramButton->setOn(false); |
244 | mAlarmSoundButton->setOn(true); | 246 | mAlarmSoundButton->setOn(true); |
245 | } else { | 247 | } else { |
246 | mAlarmProgramButton->setOn(true); | 248 | mAlarmProgramButton->setOn(true); |
247 | mAlarmSoundButton->setOn(false); | 249 | mAlarmSoundButton->setOn(false); |
248 | 250 | ||
249 | } | 251 | } |
250 | } | 252 | } |
251 | 253 | ||
252 | if (mAlarmProgramButton->isOn()) | 254 | if (mAlarmProgramButton->isOn()) |
253 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 255 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
254 | if ( mAlarmSoundButton->isOn()) | 256 | if ( mAlarmSoundButton->isOn()) |
255 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + getFittingPath(mAlarmSound) ); | 257 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
256 | } | 258 | } |
257 | 259 | ||
258 | void KOEditorGeneral::pickAlarmProgram() | 260 | void KOEditorGeneral::pickAlarmProgram() |
259 | { | 261 | { |
260 | if (!mAlarmProgramButton->isOn()) { | 262 | if (!mAlarmProgramButton->isOn()) { |
261 | //mAlarmProgram = ""; | 263 | //mAlarmProgram = ""; |
262 | QToolTip::remove(mAlarmProgramButton); | 264 | QToolTip::remove(mAlarmProgramButton); |
263 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 265 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
264 | mAlarmProgramButton->setOn(false); | 266 | mAlarmProgramButton->setOn(false); |
265 | mAlarmSoundButton->setOn(true); | 267 | mAlarmSoundButton->setOn(true); |
268 | pickAlarmSound(); | ||
266 | } else { | 269 | } else { |
267 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); | 270 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
268 | if (!fileName.isEmpty()) { | 271 | if (!fileName.isEmpty()) { |
269 | mAlarmProgram = fileName; | 272 | mAlarmProgram = fileName; |
270 | QToolTip::remove(mAlarmProgramButton); | 273 | QToolTip::remove(mAlarmProgramButton); |
271 | QString dispStr = i18n("Running '%1'").arg(fileName); | 274 | QString dispStr = i18n("Running '%1'").arg(fileName); |
272 | QToolTip::add(mAlarmProgramButton, dispStr); | 275 | QToolTip::add(mAlarmProgramButton, dispStr); |
273 | mAlarmSoundButton->setOn(false); | 276 | mAlarmSoundButton->setOn(false); |
274 | mAlarmProgramButton->setOn(true); | 277 | mAlarmProgramButton->setOn(true); |
275 | } else { | 278 | } else { |
276 | mAlarmProgramButton->setOn(false); | 279 | mAlarmProgramButton->setOn(false); |
277 | mAlarmSoundButton->setOn(true); | 280 | mAlarmSoundButton->setOn(true); |
278 | } | 281 | } |
279 | } | 282 | } |
280 | if (mAlarmProgramButton->isOn()) | 283 | if (mAlarmProgramButton->isOn()) |
281 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 284 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
282 | if ( mAlarmSoundButton->isOn()) | 285 | if ( mAlarmSoundButton->isOn()) |
283 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + getFittingPath(mAlarmSound) ); | 286 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
284 | } | 287 | } |
285 | 288 | ||
286 | 289 | ||
287 | QString KOEditorGeneral::getFittingPath( const QString s ) | 290 | QString KOEditorGeneral::getFittingPath( const QString s ) |
288 | { | 291 | { |
289 | int maxlen = 50; | 292 | int maxlen = 50; |
290 | if ( QApplication::desktop()->width() < 640 ) { | 293 | if ( QApplication::desktop()->width() < 640 ) { |
291 | if ( QApplication::desktop()->width() < 320 ) | 294 | if ( QApplication::desktop()->width() < 320 ) |
292 | maxlen = 22; | 295 | maxlen = 22; |
293 | else | 296 | else |
294 | maxlen = 35; | 297 | maxlen = 35; |
295 | } | 298 | } |
296 | if ( s.length() > maxlen ) { | 299 | if ( s.length() > maxlen ) { |
297 | return "..."+s.right(maxlen -3); | 300 | return "..."+s.right(maxlen -3); |
298 | } | 301 | } |
299 | return s; | 302 | return s; |
300 | } | 303 | } |
301 | 304 | ||
302 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 305 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
303 | { | 306 | { |
304 | if ( enable ) { | 307 | if ( enable ) { |
305 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 308 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
306 | mAlarmSoundButton->setOn( true ); | 309 | mAlarmSoundButton->setOn( true ); |
307 | if ( mAlarmSound.isEmpty() ) | 310 | if ( mAlarmSound.isEmpty() ) |
308 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 311 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
309 | else { | 312 | else { |
310 | if ( ! QFile::exists( mAlarmSound ) ) | 313 | if ( ! QFile::exists( mAlarmSound ) ) |
311 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 314 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
312 | } | 315 | } |
313 | } | 316 | } |
314 | if (mAlarmProgramButton->isOn()) | 317 | if (mAlarmProgramButton->isOn()) |
315 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 318 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
316 | if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 319 | if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
317 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 320 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
318 | } | 321 | } |
319 | else { | 322 | else { |
320 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled for this item")); | 323 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
324 | //((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Edit item: ") + mSummaryEdit->currentText()); | ||
325 | |||
321 | 326 | ||
322 | } | 327 | } |
323 | mAlarmTimeEdit->setEnabled(enable); | 328 | mAlarmTimeEdit->setEnabled(enable); |
324 | mAlarmSoundButton->setEnabled(enable); | 329 | mAlarmSoundButton->setEnabled(enable); |
325 | mAlarmProgramButton->setEnabled(enable); | 330 | mAlarmProgramButton->setEnabled(enable); |
326 | mAlarmIncrCombo->setEnabled(enable); | 331 | mAlarmIncrCombo->setEnabled(enable); |
327 | } | 332 | } |
328 | 333 | ||
329 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 334 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
330 | { | 335 | { |
331 | enableAlarmEdit( !disable ); | 336 | enableAlarmEdit( !disable ); |
332 | } | 337 | } |
333 | 338 | ||
334 | void KOEditorGeneral::enableAlarm( bool enable ) | 339 | void KOEditorGeneral::enableAlarm( bool enable ) |
335 | { | 340 | { |
336 | enableAlarmEdit( enable ); | 341 | enableAlarmEdit( enable ); |
337 | } | 342 | } |
338 | 343 | ||
339 | void KOEditorGeneral::alarmDisable(bool disable) | 344 | void KOEditorGeneral::alarmDisable(bool disable) |
340 | { | 345 | { |
341 | if (!disable) { | 346 | if (!disable) { |
342 | //mAlarmBell->setEnabled(true); | 347 | //mAlarmBell->setEnabled(true); |
343 | mAlarmButton->setEnabled(true); | 348 | mAlarmButton->setEnabled(true); |
344 | } else { | 349 | } else { |
345 | //mAlarmBell->setEnabled(false); | 350 | //mAlarmBell->setEnabled(false); |
346 | mAlarmButton->setEnabled(false); | 351 | mAlarmButton->setEnabled(false); |
347 | mAlarmButton->setChecked(false); | 352 | mAlarmButton->setChecked(false); |
348 | mAlarmTimeEdit->setEnabled(false); | 353 | mAlarmTimeEdit->setEnabled(false); |
349 | mAlarmSoundButton->setEnabled(false); | 354 | mAlarmSoundButton->setEnabled(false); |
350 | mAlarmProgramButton->setEnabled(false); | 355 | mAlarmProgramButton->setEnabled(false); |
351 | mAlarmIncrCombo->setEnabled(false); | 356 | mAlarmIncrCombo->setEnabled(false); |
352 | } | 357 | } |
353 | } | 358 | } |
354 | 359 | ||
355 | void KOEditorGeneral::setCategories(const QString &str) | 360 | void KOEditorGeneral::setCategories(const QString &str) |
356 | { | 361 | { |
357 | mCategoriesLabel->setText(str); | 362 | mCategoriesLabel->setText(str); |
358 | } | 363 | } |
359 | 364 | ||
360 | void KOEditorGeneral::setDefaults(bool allDay) | 365 | void KOEditorGeneral::setDefaults(bool allDay) |
361 | { | 366 | { |
362 | #if 0 | 367 | #if 0 |
363 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 368 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
364 | #endif | 369 | #endif |
365 | 370 | ||
371 | mAlarmMessage = i18n("Edit new item"); | ||
366 | enableAlarmEdit( !allDay ); | 372 | enableAlarmEdit( !allDay ); |
367 | 373 | ||
368 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 374 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
369 | int alarmTime; | 375 | int alarmTime; |
370 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 376 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
371 | int index = KOPrefs::instance()->mAlarmTime; | 377 | int index = KOPrefs::instance()->mAlarmTime; |
372 | if (index < 0 || index > 7) { | 378 | if (index < 0 || index > 7) { |
373 | alarmTime = 15; | 379 | alarmTime = 15; |
374 | } else { | 380 | } else { |
375 | alarmTime = a[index]; | 381 | alarmTime = a[index]; |
376 | } | 382 | } |
377 | mAlarmButton ->setChecked( false ); | 383 | mAlarmButton ->setChecked( false ); |
378 | mAlarmTimeEdit->setValue(alarmTime); | 384 | mAlarmTimeEdit->setValue(alarmTime); |
379 | mAlarmIncrCombo->setCurrentItem(0); | 385 | mAlarmIncrCombo->setCurrentItem(0); |
380 | enableAlarmEdit( false ); | 386 | enableAlarmEdit( false ); |
381 | //alarmDisable (false); | 387 | //alarmDisable (false); |
382 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 388 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
383 | mCancelBox->setChecked( false ); | 389 | mCancelBox->setChecked( false ); |
384 | mSummaryEdit->setEditText(""); | 390 | mSummaryEdit->setEditText(""); |
385 | mLocationEdit->setEditText(""); | 391 | mLocationEdit->setEditText(""); |
386 | mDescriptionEdit->setText(""); | 392 | mDescriptionEdit->setText(""); |
387 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 393 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
388 | setCategories(""); | 394 | setCategories(""); |
389 | } | 395 | } |
390 | void KOEditorGeneral::setSecrecy( int num ) | 396 | void KOEditorGeneral::setSecrecy( int num ) |
391 | { | 397 | { |
392 | mSecrecyCombo->setCurrentItem(num); | 398 | mSecrecyCombo->setCurrentItem(num); |
393 | } | 399 | } |
394 | void KOEditorGeneral::readIncidence(Incidence *event) | 400 | void KOEditorGeneral::readIncidence(Incidence *event) |
395 | { | 401 | { |
396 | 402 | ||
403 | mAlarmMessage = i18n("Edit") +" "+event->summary(); | ||
397 | mAlarmIncrCombo->setCurrentItem(0); | 404 | mAlarmIncrCombo->setCurrentItem(0); |
398 | mSummaryEdit->setEditText(event->summary()); | 405 | mSummaryEdit->setEditText(event->summary()); |
399 | mLocationEdit->setEditText(event->location()); | 406 | mLocationEdit->setEditText(event->location()); |
400 | mDescriptionEdit->setText(event->description()); | 407 | mDescriptionEdit->setText(event->description()); |
401 | 408 | ||
402 | #if 0 | 409 | #if 0 |
403 | // organizer information | 410 | // organizer information |
404 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 411 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
405 | #endif | 412 | #endif |
406 | 413 | ||
407 | enableAlarmEdit( event->isAlarmEnabled() ); | 414 | enableAlarmEdit( event->isAlarmEnabled() ); |
408 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 415 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
409 | if(!event->isAlarmEnabled()) { | 416 | if(!event->isAlarmEnabled()) { |
410 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 417 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
411 | int alarmTime; | 418 | int alarmTime; |
412 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 419 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
413 | int index = KOPrefs::instance()->mAlarmTime; | 420 | int index = KOPrefs::instance()->mAlarmTime; |
414 | if (index < 0 || index > 7) { | 421 | if (index < 0 || index > 7) { |
415 | alarmTime = 15; | 422 | alarmTime = 15; |
416 | } else { | 423 | } else { |
417 | alarmTime = a[index]; | 424 | alarmTime = a[index]; |
418 | } | 425 | } |
419 | mAlarmTimeEdit->setValue(alarmTime); | 426 | mAlarmTimeEdit->setValue(alarmTime); |
420 | } | 427 | } |