2 * Copyright (C) 2014-2016 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
19#include <QDBusPendingCall>
20#include <QDBusMessage>
21#include <QDBusConnection>
22#include <QDBusMetaType>
34 // Register the argument needed for UpdateActivationEnvironment below
35 qDBusRegisterMetaType<QMap<QString,QString>>();
37 if(!wizardEnabled()) {
38 m_fsWatcher.addPath(wizardEnabledPath());
40 connect(&m_fsWatcher, &QFileSystemWatcher::fileChanged, this, &System::watcherFileChanged);
43QString System::wizardEnabledPath()
45 // Uses ubuntu-system-settings namespace for historic compatibility reasons
46 return QDir::home().filePath(QStringLiteral(".config/ubuntu-system-settings/wizard-has-run"));
49bool System::wizardEnabled() const
51 return !QFile::exists(wizardEnabledPath());
54void 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();
69void System::watcherFileChanged()
71 Q_EMIT wizardEnabledChanged();
72 m_fsWatcher.removePath(wizardEnabledPath());
75void System::setSessionVariable(const QString &variable, const QString &value)
77 // We need to update both upstart's and DBus's environment
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);
92void 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);
100 // QLocale caches the default locale on startup, and Qt uses that cached
101 // copy when formatting dates. So manually update it here.
102 QLocale::setDefault(QLocale(locale));
104 // Restart bits of the session to pick up new language.
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\""));
115void System::skipUntilFinishedPage()
118 settings.setValue(QStringLiteral("Wizard/SkipUntilFinishedPage"), true);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list