Commit 057b0a24 authored by David Jarvie's avatar David Jarvie

Store KAlarm version and backend in config file

Forward port 6070c1c18e053412b13a03062a34f7843a2191bf (4.8)
parent cea498d9
......@@ -88,6 +88,7 @@ bool AlarmCalendar::initialiseCalendars()
#ifdef USE_AKONADI
AkonadiModel::instance();
CollectionControlModel::setAskDestinationPolicy(Preferences::askResource());
Preferences::setBackend(Preferences::Akonadi);
#else
AlarmResources::setDebugArea(5951);
AlarmResources::setReservedFile(displayCal);
......@@ -99,7 +100,9 @@ bool AlarmCalendar::initialiseCalendars()
}
resources->setAskDestinationPolicy(Preferences::askResource());
resources->showProgress(true);
Preferences::setBackend(Preferences::Kresources);
#endif
Preferences::self()->writeConfig();
mResourcesCalendar = new AlarmCalendar();
mDisplayCalendar = new AlarmCalendar(displayCal, CalEvent::DISPLAYING);
KACalendar::setProductId(KALARM_NAME, KALARM_VERSION);
......
......@@ -28,7 +28,7 @@
#else
#define VERSION_SUFFIX "-res"
#endif
#define KALARM_VERSION "2.9.0" VERSION_SUFFIX
#define KALARM_VERSION "2.9.1" VERSION_SUFFIX
#define KALARM_NAME "KAlarm"
#define KALARM_DBUS_SERVICE "org.kde.kalarm" // D-Bus service name of KAlarm application
......
......@@ -133,7 +133,7 @@ KAlarmApp::KAlarmApp()
connect(mAlarmTimer, SIGNAL(timeout()), SLOT(checkNextDueAlarm()));
setQuitOnLastWindowClosed(false);
Preferences::self()->readConfig();
Preferences::self(); // read KAlarm configuration
if (!Preferences::noAutoStart())
{
Preferences::setAutoStart(true);
......
......@@ -61,6 +61,14 @@
<label context="@label">KAlarm version</label>
<whatsthis context="@info:whatsthis">KAlarm version which wrote this file.</whatsthis>
</entry>
<entry name="Backend" type="Enum" hidden="true">
<label context="@label">Data storage backend</label>
<whatsthis context="@info:whatsthis">Data storage backend currently used by KAlarm.</whatsthis>
<choices name="Backend">
<choice name="Kresources"><label context="@option">KResources</label></choice>
<choice name="Akonadi"><label context="@option">Akonadi</label></choice>
</choices>
</entry>
<entry name="Base_TimeZone" key="TimeZone" type="String">
<label context="@label">Time zone</label>
<whatsthis context="@info:whatsthis">Select the time zone which &lt;application>KAlarm&lt;/application> should use as its default for displaying and entering dates and times.</whatsthis>
......
......@@ -71,6 +71,8 @@ Preferences* Preferences::mInstance = 0;
bool Preferences::mUsingDefaults = false;
KTimeZone Preferences::mSystemTimeZone;
HolidayRegion* Preferences::mHolidays = 0; // always non-null after Preferences initialisation
QString Preferences::mPreviousVersion;
Preferences::Backend Preferences::mPreviousBackend;
// Change tracking
bool Preferences::mAutoStartChangedByUser = false;
......@@ -86,7 +88,6 @@ Preferences* Preferences::self()
KAMessageBox::setDefaultShouldBeShownContinue(CONFIRM_ALARM_DELETION, default_confirmAlarmDeletion);
mInstance = new Preferences;
mInstance->readConfig();
}
return mInstance;
}
......@@ -97,6 +98,15 @@ Preferences::Preferences()
QObject::connect(this, SIGNAL(base_TimeZoneChanged(QString)), SLOT(timeZoneChange(QString)));
QObject::connect(this, SIGNAL(base_HolidayRegionChanged(QString)), SLOT(holidaysChange(QString)));
QObject::connect(this, SIGNAL(base_WorkTimeChanged(QDateTime,QDateTime,int)), SLOT(workTimeChange(QDateTime,QDateTime,int)));
readConfig();
// Fetch the KAlarm version and backend which wrote the previous config file
mPreviousVersion = version();
mPreviousBackend = backend();
// Update the KAlarm version in the config file, but don't call
// writeConfig() here - leave it to be written only if the config file
// is updated with other data.
setVersion(KALARM_VERSION);
}
void Preferences::setAskAutoStart(bool yes)
......
......@@ -45,6 +45,8 @@ class Preferences : public PreferencesBase
static void setAutoStartChangedByUser(bool c){ mAutoStartChangedByUser = c; }
// Access to settings
static QString previousVersion() { return mPreviousVersion; }
static Backend previousBackend() { return mPreviousBackend; }
static void setAskAutoStart(bool yes);
static KTimeZone timeZone(bool reload = false);
static void setTimeZone(const KTimeZone&);
......@@ -108,6 +110,8 @@ class Preferences : public PreferencesBase
static bool mUsingDefaults;
static KTimeZone mSystemTimeZone;
static KHolidays::HolidayRegion* mHolidays;
static QString mPreviousVersion; // last KAlarm version which wrote the config file
static Backend mPreviousBackend; // backend used by last used version of KAlarm
// All the following members are accessed by the Preferences dialog classes
static int mMessageButtonDelay; // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
......
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