2 * Copyright (C) 2014 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>
33 // Register the argument needed for UpdateActivationEnvironment below
34 qDBusRegisterMetaType<QMap<QString,QString>>();
36 if(!wizardEnabled()) {
37 m_fsWatcher.addPath(wizardEnabledPath());
39 connect(&m_fsWatcher, SIGNAL(fileChanged(const QString &)),
40 this, SLOT(watcherFileChanged()));
43QString System::wizardEnabledPath()
45 // Uses ubuntu-system-settings namespace for historic compatibility reasons
46 return QDir::home().filePath(".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("..");
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("org.freedesktop.DBus",
84 "/org/freedesktop/DBus",
85 "org.freedesktop.DBus",
86 "UpdateActivationEnvironment");
88 msg << QVariant::fromValue(valueMap);
89 QDBusConnection::sessionBus().asyncCall(msg);
92void System::updateSessionLanguage(const QString &locale)
94 const QString language = locale.split(".")[0];
96 setSessionVariable("LANGUAGE", language);
97 setSessionVariable("LANG", locale);
98 setSessionVariable("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("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 maliit-server; \
110 initctl restart --no-wait unity8-dash\"");
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