@@ -20,7 +20,6 @@
20#include <QDBusMessage>
20#include <QDBusMessage>
21#include <QDBusConnection>
21#include <QDBusConnection>
22#include <QDBusMetaType>
22#include <QDBusMetaType>
23−#include <QVersionNumber>
24#include <QDir>
23#include <QDir>
25#include <QFile>
24#include <QFile>
26#include <QLocale>
25#include <QLocale>
@@ -44,53 +43,78 @@ System::System()
44QString System::wizardEnabledPath()
43QString System::wizardEnabledPath()
46 // Uses ubuntu-system-settings namespace for historic compatibility reasons
45 // Uses ubuntu-system-settings namespace for historic compatibility reasons
47− return QDir::home().filePath(QStringLiteral(".config/ubuntu-system-settings/wizard-has-run/"));
46+ return QDir::home().filePath(QStringLiteral(".config/ubuntu-system-settings/wizard-has-run"));
49+QString System::currentFrameworkPath()
51+ return QDir::home().filePath(QStringLiteral("/usr/share/click/framework/current"));
55+wizardEnabled and isUpdate logic
57+if wizard-has-run does NOT exists == is new install
58+if wizard-has-run does exists but does NOT match current framework == is update
59+if wizard-has-run does exists but does match current framework == show no wizard
50bool System::wizardEnabled() const
62bool System::wizardEnabled() const
52− return (versionToShow() >= 0);
64+ return !QFile::exists(wizardEnabledPath());
55−signed int System::versionToShow() const
67+QString System::readCurrentFramework()
57− if (!(QFile::exists(wizardEnabledPath()))) {
69+ QFile f(currentFrameworkPath());
58− return 0;
70+ if (!f.open(QFile::ReadOnly | QFile::Text)) return "";
61− QString pathToCheck = QDir(wizardEnabledPath()).filePath(QString::number(CURRENT_VERSION));
75+QString System::readWizardEnabled()
63− if (!(QFile::exists(pathToCheck))) {
77+ QFile f(wizardEnabledPath());
64− return CURRENT_VERSION;
78+ if (!f.open(QFile::ReadOnly | QFile::Text)) return "";
67− return -1;
83+QString System::version() const
85+ return readCurrentFramework();
88+bool System::isUpdate() const
90+ if (!wizardEnabled())
93+ return readCurrentFramework() != readWizardEnabled();
71void System::setWizardEnabled(bool enabled)
96void System::setWizardEnabled(bool enabled)
73− if (wizardEnabled() == enabled)
98+ if (wizardEnabled() == enabled && !isUpdate())
76 if (enabled) {
101 if (enabled) {
77− QDir(wizardEnabledPath()).removeRecursively();
102+ QFile::remove(wizardEnabledPath());
79− QDir(wizardEnabledPath()).mkpath(QStringLiteral("."));
104+ QDir(wizardEnabledPath()).mkpath(QStringLiteral(".."));
105+ if (QFile::exists(wizardEnabledPath()))
106+ QFile::remove(wizardEnabledPath());
107+ QFile::copy(currentFrameworkPath(), wizardEnabledPath());
80 m_fsWatcher.addPath(wizardEnabledPath());
108 m_fsWatcher.addPath(wizardEnabledPath());
81−
109+ Q_EMIT wizardEnabledChanged();
82− // Disable the newest non-first-run wizard, too
110+ Q_EMIT isUpdateChanged();
83− QFile(QDir(wizardEnabledPath()).filePath(QString::number(CURRENT_VERSION))).open(QIODevice::WriteOnly);
86− Q_EMIT wizardEnabledChanged();
87− Q_EMIT versionToShowChanged();
90void System::watcherFileChanged()
114void System::watcherFileChanged()
92 Q_EMIT wizardEnabledChanged();
116 Q_EMIT wizardEnabledChanged();
93− Q_EMIT versionToShowChanged();
117+ Q_EMIT isUpdateChanged();
94 m_fsWatcher.removePath(wizardEnabledPath());
118 m_fsWatcher.removePath(wizardEnabledPath());