Commit ce24ad9a authored by David Jarvie's avatar David Jarvie
Browse files

When resetting to defaults for current tab, only reset the visible tab

For settings sections with multiple subsidiary tabs, only reset the
current subsidiary tab when the user clicks Defaults and selects
Current tab.
parent 4cf5b9c8
......@@ -271,7 +271,7 @@ void KAlarmPrefDlg::slotDefault()
break;
case KMessageBox::No:
Preferences::self()->useDefaults(true);
static_cast<PrefsTabBase*>(currentPage()->widget())->restore(true);
static_cast<PrefsTabBase*>(currentPage()->widget())->restore(true, false);
Preferences::self()->useDefaults(false);
break;
default:
......@@ -285,12 +285,12 @@ void KAlarmPrefDlg::restore(bool defaults)
kDebug() << (defaults ? "defaults" : "");
if (defaults)
Preferences::self()->useDefaults(true);
mEmailPage->restore(defaults);
mViewPage->restore(defaults);
mEditPage->restore(defaults);
mStorePage->restore(defaults);
mTimePage->restore(defaults);
mMiscPage->restore(defaults);
mEmailPage->restore(defaults, true);
mViewPage->restore(defaults, true);
mEditPage->restore(defaults, true);
mStorePage->restore(defaults, true);
mTimePage->restore(defaults, true);
mMiscPage->restore(defaults, true);
if (defaults)
Preferences::self()->useDefaults(false);
}
......@@ -505,7 +505,7 @@ MiscPrefTab::MiscPrefTab(StackedScrollGroup* scrollGroup)
topLayout()->addStretch(); // top adjust the widgets
}
void MiscPrefTab::restore(bool defaults)
void MiscPrefTab::restore(bool defaults, bool)
{
mAutoStart->setChecked(defaults ? true : Preferences::autoStart());
mQuitWarn->setChecked(Preferences::quitWarn());
......@@ -754,7 +754,7 @@ TimePrefTab::TimePrefTab(StackedScrollGroup* scrollGroup)
topLayout()->addStretch(); // top adjust the widgets
}
void TimePrefTab::restore(bool)
void TimePrefTab::restore(bool, bool)
{
#if 1
mTimeZone->setTimeZone(Preferences::timeZone());
......@@ -892,7 +892,7 @@ StorePrefTab::StorePrefTab(StackedScrollGroup* scrollGroup)
topLayout()->addStretch(); // top adjust the widgets
}
void StorePrefTab::restore(bool defaults)
void StorePrefTab::restore(bool defaults, bool)
{
mCheckKeepChanges = defaults;
if (Preferences::askResource())
......@@ -1085,7 +1085,7 @@ EmailPrefTab::EmailPrefTab(StackedScrollGroup* scrollGroup)
topLayout()->addStretch(); // top adjust the widgets
}
void EmailPrefTab::restore(bool defaults)
void EmailPrefTab::restore(bool defaults, bool)
{
mEmailClient->setButton(Preferences::emailClient());
mEmailCopyToKMail->setChecked(Preferences::emailCopyToKMail());
......@@ -1199,20 +1199,20 @@ EditPrefTab::EditPrefTab(StackedScrollGroup* scrollGroup)
{
KLocalizedString defsetting = ki18nc("@info:whatsthis", "The default setting for <interface>%1</interface> in the alarm edit dialog.");
KTabWidget* tabs = new KTabWidget(topWidget());
StackedGroupT<KVBox>* tabgroup = new StackedGroupT<KVBox>(tabs);
mTabs = new KTabWidget(topWidget());
StackedGroupT<KVBox>* tabgroup = new StackedGroupT<KVBox>(mTabs);
StackedWidgetT<KVBox>* topGeneral = new StackedWidgetT<KVBox>(tabgroup);
topGeneral->setMargin(KDialog::marginHint()/2);
topGeneral->setSpacing(KDialog::spacingHint());
tabs->addTab(topGeneral, i18nc("@title:tab", "General"));
mTabGeneral = mTabs->addTab(topGeneral, i18nc("@title:tab", "General"));
StackedWidgetT<KVBox>* topTypes = new StackedWidgetT<KVBox>(tabgroup);
topTypes->setMargin(KDialog::marginHint()/2);
topTypes->setSpacing(KDialog::spacingHint());
tabs->addTab(topTypes, i18nc("@title:tab", "Alarm Types"));
mTabTypes = mTabs->addTab(topTypes, i18nc("@title:tab", "Alarm Types"));
StackedWidgetT<KVBox>* topFontColour = new StackedWidgetT<KVBox>(tabgroup);
topFontColour->setMargin(KDialog::marginHint()/2);
topFontColour->setSpacing(KDialog::spacingHint());
tabs->addTab(topFontColour, i18nc("@title:tab", "Font && Color"));
mTabFontColour = mTabs->addTab(topFontColour, i18nc("@title:tab", "Font && Color"));
// MISCELLANEOUS
// Show in KOrganizer
......@@ -1395,46 +1395,55 @@ EditPrefTab::EditPrefTab(StackedScrollGroup* scrollGroup)
mFontChooser = new FontColourChooser(topFontColour, QStringList(), i18nc("@title:group", "Message Font && Color"), true);
}
void EditPrefTab::restore(bool)
void EditPrefTab::restore(bool, bool allTabs)
{
int index;
mAutoClose->setChecked(Preferences::defaultAutoClose());
mConfirmAck->setChecked(Preferences::defaultConfirmAck());
switch (Preferences::defaultReminderUnits())
if (allTabs || mTabs->currentIndex() == mTabGeneral)
{
case TimePeriod::Weeks: index = 3; break;
case TimePeriod::Days: index = 2; break;
default:
case TimePeriod::HoursMinutes: index = 1; break;
case TimePeriod::Minutes: index = 0; break;
mCopyToKOrganizer->setChecked(Preferences::defaultCopyToKOrganizer());
mLateCancel->setChecked(Preferences::defaultLateCancel());
switch (Preferences::defaultRecurPeriod())
{
case Preferences::Recur_Yearly: index = 6; break;
case Preferences::Recur_Monthly: index = 5; break;
case Preferences::Recur_Weekly: index = 4; break;
case Preferences::Recur_Daily: index = 3; break;
case Preferences::Recur_SubDaily: index = 2; break;
case Preferences::Recur_Login: index = 1; break;
case Preferences::Recur_None:
default: index = 0; break;
}
mRecurPeriod->setCurrentIndex(index);
mFeb29->setButton(Preferences::defaultFeb29Type());
}
mReminderUnits->setCurrentIndex(index);
mSpecialActionsButton->setActions(Preferences::defaultPreAction(), Preferences::defaultPostAction(),
Preferences::defaultCancelOnPreActionError(), Preferences::defaultDontShowPreActionError());
mSound->setCurrentIndex(soundIndex(Preferences::defaultSoundType()));
mSoundFile->setText(Preferences::defaultSoundFile());
mSoundRepeat->setChecked(Preferences::defaultSoundRepeat());
mCmdScript->setChecked(Preferences::defaultCmdScript());
mCmdXterm->setChecked(Preferences::defaultCmdLogType() == Preferences::Log_Terminal);
mEmailBcc->setChecked(Preferences::defaultEmailBcc());
mCopyToKOrganizer->setChecked(Preferences::defaultCopyToKOrganizer());
mLateCancel->setChecked(Preferences::defaultLateCancel());
switch (Preferences::defaultRecurPeriod())
if (allTabs || mTabs->currentIndex() == mTabTypes)
{
case Preferences::Recur_Yearly: index = 6; break;
case Preferences::Recur_Monthly: index = 5; break;
case Preferences::Recur_Weekly: index = 4; break;
case Preferences::Recur_Daily: index = 3; break;
case Preferences::Recur_SubDaily: index = 2; break;
case Preferences::Recur_Login: index = 1; break;
case Preferences::Recur_None:
default: index = 0; break;
mConfirmAck->setChecked(Preferences::defaultConfirmAck());
mAutoClose->setChecked(Preferences::defaultAutoClose());
switch (Preferences::defaultReminderUnits())
{
case TimePeriod::Weeks: index = 3; break;
case TimePeriod::Days: index = 2; break;
default:
case TimePeriod::HoursMinutes: index = 1; break;
case TimePeriod::Minutes: index = 0; break;
}
mReminderUnits->setCurrentIndex(index);
mSpecialActionsButton->setActions(Preferences::defaultPreAction(), Preferences::defaultPostAction(),
Preferences::defaultCancelOnPreActionError(), Preferences::defaultDontShowPreActionError());
mSound->setCurrentIndex(soundIndex(Preferences::defaultSoundType()));
mSoundFile->setText(Preferences::defaultSoundFile());
mSoundRepeat->setChecked(Preferences::defaultSoundRepeat());
mCmdScript->setChecked(Preferences::defaultCmdScript());
mCmdXterm->setChecked(Preferences::defaultCmdLogType() == Preferences::Log_Terminal);
mEmailBcc->setChecked(Preferences::defaultEmailBcc());
}
if (allTabs || mTabs->currentIndex() == mTabFontColour)
{
mFontChooser->setFgColour(Preferences::defaultFgColour());
mFontChooser->setBgColour(Preferences::defaultBgColour());
mFontChooser->setFont(Preferences::messageFont());
}
mRecurPeriod->setCurrentIndex(index);
mFeb29->setButton(Preferences::defaultFeb29Type());
mFontChooser->setFgColour(Preferences::defaultFgColour());
mFontChooser->setBgColour(Preferences::defaultBgColour());
mFontChooser->setFont(Preferences::messageFont());
}
void EditPrefTab::apply(bool syncToDisc)
......@@ -1567,15 +1576,15 @@ QString EditPrefTab::validate()
ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
: PrefsTabBase(scrollGroup)
{
KTabWidget* tabs = new KTabWidget(topWidget());
mTabs = new KTabWidget(topWidget());
KVBox* topGeneral = new KVBox();
topGeneral->setMargin(KDialog::marginHint()/2);
topGeneral->setSpacing(KDialog::spacingHint());
tabs->addTab(topGeneral, i18nc("@title:tab", "General"));
mTabGeneral = mTabs->addTab(topGeneral, i18nc("@title:tab", "General"));
KVBox* topWindows = new KVBox();
topWindows->setMargin(KDialog::marginHint()/2);
topWindows->setSpacing(KDialog::spacingHint());
tabs->addTab(topWindows, i18nc("@title:tab", "Alarm Windows"));
mTabWindows = mTabs->addTab(topWindows, i18nc("@title:tab", "Alarm Windows"));
// Run-in-system-tray radio button
KHBox* box = new KHBox(topGeneral); // this is to allow left adjustment
......@@ -1723,18 +1732,24 @@ ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
lay->addStretch(); // top adjust the widgets
}
void ViewPrefTab::restore(bool)
void ViewPrefTab::restore(bool, bool allTabs)
{
mDisabledColour->setColor(Preferences::disabledColour());
mArchivedColour->setColor(Preferences::archivedColour());
setTooltip(Preferences::tooltipAlarmCount(),
Preferences::showTooltipAlarmTime(),
Preferences::showTooltipTimeToAlarm(),
Preferences::tooltipTimeToPrefix());
mShowInSystemTray->setChecked(Preferences::showInSystemTray());
mWindowPosition->setButton(Preferences::messageButtonDelay() ? 1 : 0);
mWindowButtonDelay->setValue(Preferences::messageButtonDelay());
mModalMessages->setChecked(Preferences::modalMessages());
if (allTabs || mTabs->currentIndex() == mTabGeneral)
{
mShowInSystemTray->setChecked(Preferences::showInSystemTray());
setTooltip(Preferences::tooltipAlarmCount(),
Preferences::showTooltipAlarmTime(),
Preferences::showTooltipTimeToAlarm(),
Preferences::tooltipTimeToPrefix());
mDisabledColour->setColor(Preferences::disabledColour());
mArchivedColour->setColor(Preferences::archivedColour());
}
if (allTabs || mTabs->currentIndex() == mTabWindows)
{
mWindowPosition->setButton(Preferences::messageButtonDelay() ? 1 : 0);
mWindowButtonDelay->setValue(Preferences::messageButtonDelay());
mModalMessages->setChecked(Preferences::modalMessages());
}
}
void ViewPrefTab::apply(bool syncToDisc)
......
/*
* prefdlg_p.h - private classes for program preferences dialog
* Program: kalarm
* Copyright © 2001-2010 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2011 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -54,7 +54,7 @@ class PrefsTabBase : public StackedScrollWidget
PrefsTabBase(StackedScrollGroup*);
void setPreferences();
virtual void restore(bool defaults) = 0;
virtual void restore(bool defaults, bool allTabs) = 0;
virtual void apply(bool syncToDisc) = 0;
void addAlignedLabel(QLabel*);
KVBox* topWidget() const { return mTopWidget; }
......@@ -80,7 +80,7 @@ class MiscPrefTab : public PrefsTabBase
public:
MiscPrefTab(StackedScrollGroup*);
virtual void restore(bool defaults);
virtual void restore(bool defaults, bool allTabs);
virtual void apply(bool syncToDisc);
private slots:
......@@ -108,7 +108,7 @@ class TimePrefTab : public PrefsTabBase
public:
TimePrefTab(StackedScrollGroup*);
virtual void restore(bool defaults);
virtual void restore(bool defaults, bool allTabs);
virtual void apply(bool syncToDisc);
private:
......@@ -132,7 +132,7 @@ class StorePrefTab : public PrefsTabBase
public:
StorePrefTab(StackedScrollGroup*);
virtual void restore(bool defaults);
virtual void restore(bool defaults, bool allTabs);
virtual void apply(bool syncToDisc);
private slots:
......@@ -162,7 +162,7 @@ class EmailPrefTab : public PrefsTabBase
EmailPrefTab(StackedScrollGroup*);
QString validate();
virtual void restore(bool defaults);
virtual void restore(bool defaults, bool allTabs);
virtual void apply(bool syncToDisc);
private slots:
......@@ -203,13 +203,14 @@ class EditPrefTab : public PrefsTabBase
EditPrefTab(StackedScrollGroup*);
QString validate();
virtual void restore(bool defaults);
virtual void restore(bool defaults, bool allTabs);
virtual void apply(bool syncToDisc);
private slots:
void slotBrowseSoundFile();
private:
KTabWidget* mTabs;
QCheckBox* mAutoClose;
QCheckBox* mConfirmAck;
KComboBox* mReminderUnits;
......@@ -227,6 +228,9 @@ class EditPrefTab : public PrefsTabBase
KComboBox* mRecurPeriod;
ButtonGroup* mFeb29;
FontColourChooser* mFontChooser;
int mTabGeneral; // index of General tab
int mTabTypes; // index of Alarm Types tab
int mTabFontColour; // index of Font & Color tab
static int soundIndex(Preferences::SoundType);
};
......@@ -239,7 +243,7 @@ class ViewPrefTab : public PrefsTabBase
public:
ViewPrefTab(StackedScrollGroup*);
virtual void restore(bool defaults);
virtual void restore(bool defaults, bool allTabs);
virtual void apply(bool syncToDisc);
private slots:
......@@ -252,6 +256,7 @@ class ViewPrefTab : public PrefsTabBase
private:
void setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix);
KTabWidget* mTabs;
ColourButton* mDisabledColour;
ColourButton* mArchivedColour;
QCheckBox* mShowInSystemTray;
......@@ -266,6 +271,8 @@ class ViewPrefTab : public PrefsTabBase
QSpinBox* mWindowButtonDelay;
QLabel* mWindowButtonDelayLabel;
QCheckBox* mModalMessages;
int mTabGeneral; // index of General tab
int mTabWindows; // index of Alarm Windows tab
};
#endif // PREFDLG_P_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment