Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index b14ca43..abc80d4 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -206,101 +206,98 @@ void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) mAlarmSoundButton->setPixmap(SmallIcon("playsound")); mAlarmSoundButton->setToggleButton(true); QToolTip::add(mAlarmSoundButton, i18n("No sound set")); connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); alarmLayout->addWidget(mAlarmSoundButton); mAlarmProgramButton = new QPushButton(parent); mAlarmProgramButton->setPixmap(SmallIcon("run")); mAlarmProgramButton->setToggleButton(true); QToolTip::add(mAlarmProgramButton, i18n("No program set")); connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); alarmLayout->addWidget(mAlarmProgramButton); mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); // if ( KOPrefs::instance()->mCompactDialogs ) { // mAlarmSoundButton->hide(); // mAlarmProgramButton->hide(); // } } void KOEditorGeneral::pickAlarmSound() { qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); - //QString prefix = mAlarmSound; - if (!mAlarmSoundButton->isOn()) { + + bool oldState = mAlarmSoundButton->isOn(); + + QString fileName(KFileDialog::getOpenFileName(mAlarmSound, + i18n("*.wav|Wav Files"), 0)); + if (!fileName.isEmpty()) { + mAlarmSound = fileName; + QToolTip::remove(mAlarmSoundButton); + QString dispStr = i18n("Playing '%1'").arg(fileName); + QToolTip::add(mAlarmSoundButton, dispStr); + mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); + QToolTip::add(mAlarmProgramButton, i18n("No program set")); } else { - QString fileName(KFileDialog::getOpenFileName(mAlarmSound, - i18n("*.wav|Wav Files"), 0)); - if (!fileName.isEmpty()) { - mAlarmSound = fileName; - QToolTip::remove(mAlarmSoundButton); - QString dispStr = i18n("Playing '%1'").arg(fileName); - QToolTip::add(mAlarmSoundButton, dispStr); - mAlarmProgramButton->setOn(false); - mAlarmSoundButton->setOn(true); - } else { - mAlarmProgramButton->setOn(true); - mAlarmSoundButton->setOn(false); - - } + mAlarmProgramButton->setOn(oldState); + mAlarmSoundButton->setOn(!oldState); + + } -#if 0 + if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if ( mAlarmSoundButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); -#endif + } void KOEditorGeneral::pickAlarmProgram() { - if (!mAlarmProgramButton->isOn()) { + bool oldState = mAlarmProgramButton->isOn(); + + QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); + if (!fileName.isEmpty()) { + mAlarmProgram = fileName; + QToolTip::remove(mAlarmProgramButton); + QString dispStr = i18n("Running '%1'").arg(fileName); + QToolTip::add(mAlarmProgramButton, dispStr); + mAlarmSoundButton->setOn(false); mAlarmProgramButton->setOn(true); - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); - } else { - QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); - if (!fileName.isEmpty()) { - mAlarmProgram = fileName; - QToolTip::remove(mAlarmProgramButton); - QString dispStr = i18n("Running '%1'").arg(fileName); - QToolTip::add(mAlarmProgramButton, dispStr); - mAlarmSoundButton->setOn(false); - mAlarmProgramButton->setOn(true); - } else { - mAlarmProgramButton->setOn(false); - mAlarmSoundButton->setOn(true); - } + QToolTip::add(mAlarmSoundButton, i18n("No sound set")); + } else { + mAlarmProgramButton->setOn(!oldState); + mAlarmSoundButton->setOn(oldState); } -#if 0 + if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if ( mAlarmSoundButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); -#endif + } QString KOEditorGeneral::getFittingPath( const QString s ) { int maxlen = 50; if ( QApplication::desktop()->width() < 640 ) { if ( QApplication::desktop()->width() < 320 ) maxlen = 22; else maxlen = 35; } if ( s.length() > maxlen ) { return "..."+s.right(maxlen -3); } return s; } void KOEditorGeneral::enableAlarmEdit(bool enable) { if ( enable ) { if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { mAlarmSoundButton->setOn( true ); if ( mAlarmSound.isEmpty() ) |