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

Return to last used tab in Configuration dialogue when it's reopened

parent d5856546
KAlarm Change Log
=== Version 3.0.0 --- 26 April 2020 ===
=== Version 3.0.0 --- 14 May 2020 ===
+ Provide option to use file system resources instead of Akonadi resources.
+ Enable selection of multiple calendar files in Import Alarms dialogue.
+ Show alarm calendars sorted by name in calendars list.
+ Return to last used tab in Configuration dialogue when it is reopened.
+ Refactor AlarmCalendar to split out resources and display calendars.
=== Version 2.14.2 (KDE Applications 20.04.2) --- 13 May 2020 ===
......
/*
* prefdlg.cpp - program preferences dialog
* Program: kalarm
* Copyright © 2001-2019 David Jarvie <djarvie@kde.org>
* Copyright © 2001-2020 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
......@@ -115,7 +115,8 @@ static QString xtermCommands[] = {
= Class KAlarmPrefDlg
=============================================================================*/
KAlarmPrefDlg* KAlarmPrefDlg::mInstance = nullptr;
KAlarmPrefDlg* KAlarmPrefDlg::mInstance = nullptr;
KAlarmPrefDlg::TabType KAlarmPrefDlg::mLastTab = AnyTab;
void KAlarmPrefDlg::display()
{
......@@ -125,10 +126,12 @@ void KAlarmPrefDlg::display()
QSize s;
if (Config::readWindowSize(PREF_DIALOG_NAME, s))
mInstance->resize(s);
mInstance->restoreTab();
mInstance->show();
}
else
{
mInstance->restoreTab();
#if KDEPIM_HAVE_X11
KWindowInfo info = KWindowInfo(mInstance->winId(), NET::WMGeometry | NET::WMDesktop);
KWindowSystem::setCurrentDesktop(info.desktop());
......@@ -190,6 +193,7 @@ KAlarmPrefDlg::KAlarmPrefDlg()
connect(button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &KAlarmPrefDlg::slotApply);
connect(button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &KAlarmPrefDlg::slotDefault);
connect(button(QDialogButtonBox::Help), &QAbstractButton::clicked, this, &KAlarmPrefDlg::slotHelp);
connect(this, &KPageDialog::currentPageChanged, this, &KAlarmPrefDlg::slotTabChanged);
restore(false);
adjustSize();
}
......@@ -336,6 +340,39 @@ void KAlarmPrefDlg::resizeEvent(QResizeEvent* re)
KPageDialog::resizeEvent(re);
}
/******************************************************************************
* Called when a new tab is selected, to note which one it is.
*/
void KAlarmPrefDlg::slotTabChanged(KPageWidgetItem* item)
{
mLastTab = (item == mMiscPageItem) ? Misc
: (item == mTimePageItem) ? Time
: (item == mStorePageItem) ? Store
: (item == mEditPageItem) ? Edit
: (item == mEmailPageItem) ? Email
: (item == mViewPageItem) ? View : AnyTab;
}
/******************************************************************************
* Selects the tab noted in mLastTab.
*/
void KAlarmPrefDlg::restoreTab()
{
KPageWidgetItem* item = nullptr;
switch (mLastTab)
{
case Misc: item = mMiscPageItem; break;
case Time: item = mTimePageItem; break;
case Store: item = mStorePageItem; break;
case Edit: item = mEditPageItem; break;
case Email: item = mEmailPageItem; break;
case View: item = mViewPageItem; break;
default:
return;
}
setCurrentPage(item);
}
/*=============================================================================
= Class PrefsTabBase
......
/*
* prefdlg.h - program preferences dialog
* Program: kalarm
* Copyright © 2001-2013 David Jarvie <djarvie@kde.org>
* Copyright © 2001-2020 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
......@@ -35,45 +35,50 @@ class StackedScrollGroup;
// The Preferences dialog
class KAlarmPrefDlg : public KPageDialog
{
Q_OBJECT
public:
static void display();
~KAlarmPrefDlg();
QSize minimumSizeHint() const override;
Q_OBJECT
public:
static void display();
~KAlarmPrefDlg();
QSize minimumSizeHint() const override;
MiscPrefTab* mMiscPage;
TimePrefTab* mTimePage;
StorePrefTab* mStorePage;
EditPrefTab* mEditPage;
EmailPrefTab* mEmailPage;
ViewPrefTab* mViewPage;
protected:
void showEvent(QShowEvent*) override;
void resizeEvent(QResizeEvent*) override;
KPageWidgetItem* mMiscPageItem;
KPageWidgetItem* mTimePageItem;
KPageWidgetItem* mStorePageItem;
KPageWidgetItem* mEditPageItem;
KPageWidgetItem* mEmailPageItem;
KPageWidgetItem* mViewPageItem;
protected Q_SLOTS:
virtual void slotOk();
virtual void slotApply();
virtual void slotHelp();
virtual void slotDefault();
virtual void slotCancel();
void slotTabChanged(KPageWidgetItem*);
protected:
void showEvent(QShowEvent*) override;
void resizeEvent(QResizeEvent*) override;
private:
KAlarmPrefDlg();
void restore(bool defaults);
void restoreTab();
protected Q_SLOTS:
virtual void slotOk();
virtual void slotApply();
virtual void slotHelp();
virtual void slotDefault();
virtual void slotCancel();
static KAlarmPrefDlg* mInstance;
enum TabType { AnyTab, Misc, Time, Store, Edit, Email, View };
static TabType mLastTab;
StackedScrollGroup* mTabScrollGroup;
private:
KAlarmPrefDlg();
void restore(bool defaults);
MiscPrefTab* mMiscPage;
TimePrefTab* mTimePage;
StorePrefTab* mStorePage;
EditPrefTab* mEditPage;
EmailPrefTab* mEmailPage;
ViewPrefTab* mViewPage;
static KAlarmPrefDlg* mInstance;
StackedScrollGroup* mTabScrollGroup;
bool mShown {false};
bool mValid;
KPageWidgetItem* mMiscPageItem;
KPageWidgetItem* mTimePageItem;
KPageWidgetItem* mStorePageItem;
KPageWidgetItem* mEditPageItem;
KPageWidgetItem* mEmailPageItem;
KPageWidgetItem* mViewPageItem;
bool mShown {false};
bool mValid;
};
#endif // PREFDLG_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