19 #include <QDBusPendingCall> 20 #include <QDBusMessage> 21 #include <QDBusConnection> 22 #include <QDBusMetaType> 35 qDBusRegisterMetaType<QMap<QString,QString>>();
37 if(!wizardEnabled()) {
38 m_fsWatcher.addPath(wizardEnabledPath());
40 connect(&m_fsWatcher, &QFileSystemWatcher::fileChanged,
this, &System::watcherFileChanged);
43 QString System::wizardEnabledPath()
46 return QDir::home().filePath(QStringLiteral(
".config/ubuntu-system-settings/wizard-has-run"));
49 bool System::wizardEnabled()
const 51 return !QFile::exists(wizardEnabledPath());
54 void System::setWizardEnabled(
bool enabled)
56 if (wizardEnabled() == enabled)
60 QFile::remove(wizardEnabledPath());
62 QDir(wizardEnabledPath()).mkpath(QStringLiteral(
".."));
63 QFile(wizardEnabledPath()).open(QIODevice::WriteOnly);
64 m_fsWatcher.addPath(wizardEnabledPath());
65 Q_EMIT wizardEnabledChanged();
69 void System::watcherFileChanged()
71 Q_EMIT wizardEnabledChanged();
72 m_fsWatcher.removePath(wizardEnabledPath());
75 void System::setSessionVariable(
const QString &variable,
const QString &value)
78 QProcess::startDetached(QStringLiteral(
"initctl set-env --global %1=%2").arg(variable, value));
80 QMap<QString,QString> valueMap;
81 valueMap.insert(variable, value);
83 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral(
"org.freedesktop.DBus"),
84 QStringLiteral(
"/org/freedesktop/DBus"),
85 QStringLiteral(
"org.freedesktop.DBus"),
86 QStringLiteral(
"UpdateActivationEnvironment"));
88 msg << QVariant::fromValue(valueMap);
89 QDBusConnection::sessionBus().asyncCall(msg);
92 void System::updateSessionLocale(
const QString &locale)
94 const QString language = locale.split(QStringLiteral(
"."))[0];
96 setSessionVariable(QStringLiteral(
"LANGUAGE"), language);
97 setSessionVariable(QStringLiteral(
"LANG"), locale);
98 setSessionVariable(QStringLiteral(
"LC_ALL"), locale);
102 QLocale::setDefault(QLocale(locale));
105 QProcess::startDetached(QStringLiteral(
"sh -c \"initctl emit indicator-services-end; \ 106 initctl stop scope-registry; \ 107 initctl stop smart-scopes-proxy; \ 108 initctl emit --no-wait indicator-services-start; \ 109 initctl restart --no-wait ubuntu-location-service-trust-stored; \ 110 initctl restart --no-wait maliit-server; \ 111 initctl restart --no-wait indicator-messages; \ 112 initctl restart --no-wait unity8-dash\""));
115 void System::skipUntilFinishedPage()
118 settings.setValue(QStringLiteral(
"Wizard/SkipUntilFinishedPage"),
true);