Commit a4565b38 authored by Robin Burchell's avatar Robin Burchell

Merge pull request #1 from rburchell/master

Work at unforking systemsettings from Jolla.
parents 1322126c 3e7899c1
#
# Do NOT Edit the Auto-generated Part!
# Generated by: spectacle version 0.26
# Generated by: spectacle version 0.27
#
Name: nemo-qml-plugin-systemsettings
......@@ -16,16 +16,25 @@ License: BSD
URL: https://github.com/nemomobile/nemo-qml-plugin-systemsettings
Source0: %{name}-%{version}.tar.bz2
Source100: nemo-qml-plugin-systemsettings.yaml
BuildRequires: pkgconfig(QtCore) >= 4.7.0
BuildRequires: pkgconfig(QtDeclarative)
BuildRequires: pkgconfig(qmsystem2)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5SystemInfo)
BuildRequires: pkgconfig(qmsystem2-qt5)
BuildRequires: pkgconfig(profile)
BuildRequires: pkgconfig(QtSystemInfo)
BuildRequires: mce-headers
BuildRequires: pkgconfig(mce)
%description
%{summary}.
%package devel
Summary: System settings C++ library
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
%{summary}.
%prep
%setup -q -n %{name}-%{version}
......@@ -36,7 +45,7 @@ BuildRequires: mce-headers
# >> build pre
# << build pre
%qmake
%qmake5
make %{?jobs:-j%jobs}
......@@ -47,14 +56,27 @@ make %{?jobs:-j%jobs}
rm -rf %{buildroot}
# >> install pre
# << install pre
%qmake_install
%qmake5_install
# >> install post
# << install post
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%{_libdir}/qt4/imports/org/nemomobile/systemsettings/libnemosystemsettings.so
%{_libdir}/qt4/imports/org/nemomobile/systemsettings/qmldir
%{_libdir}/qt5/qml/org/nemomobile/systemsettings/libnemosystemsettings.so
%{_libdir}/qt5/qml/org/nemomobile/systemsettings/qmldir
%{_libdir}/libsystemsettings.so.*
# >> files
# << files
%files devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/systemsettings.pc
%{_includedir}/systemsettings/*
%{_libdir}/libsystemsettings.so
# >> files devel
# << files devel
......@@ -9,15 +9,24 @@ Sources:
- "%{name}-%{version}.tar.bz2"
License: BSD
Configure: none
Builder: qmake
Builder: qmake5
PkgConfigBR:
- QtCore >= 4.7.0
- QtDeclarative
- qmsystem2
- Qt5Qml
- Qt5SystemInfo
- qmsystem2-qt5
- profile
- QtSystemInfo
PkgBR:
- mce-headers
- mce
Files:
- "%{_libdir}/qt4/imports/org/nemomobile/systemsettings/libnemosystemsettings.so"
- "%{_libdir}/qt4/imports/org/nemomobile/systemsettings/qmldir"
- "%{_libdir}/qt5/qml/org/nemomobile/systemsettings/libnemosystemsettings.so"
- "%{_libdir}/qt5/qml/org/nemomobile/systemsettings/qmldir"
- "%{_libdir}/libsystemsettings.so.*"
SubPackages:
- Name: devel
Summary: System settings C++ library
Group: System/Libraries
Description: "%{summary}."
Files:
- "%{_libdir}/pkgconfig/systemsettings.pc"
- "%{_includedir}/systemsettings/*"
- "%{_libdir}/libsystemsettings.so"
......@@ -29,17 +29,21 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include "aboutsettings.h"
#include <QDebug>
#include <QStringList>
#include "aboutsettings.h"
#include <QStorageInfo>
#include <QNetworkInfo>
#include <QDeviceInfo>
AboutSettings::AboutSettings(QObject *parent)
: QObject(parent),
m_sysinfo(new QSystemStorageInfo(this)),
m_netinfo(new QSystemNetworkInfo(this)),
m_devinfo(new QSystemDeviceInfo(this))
m_sysinfo(new QStorageInfo(this)),
m_netinfo(new QNetworkInfo(this)),
m_devinfo(new QDeviceInfo(this))
{
qDebug() << "Drives:" << m_sysinfo->logicalDrives();
qDebug() << "Drives:" << m_sysinfo->allLogicalDrives();
}
AboutSettings::~AboutSettings()
......@@ -58,17 +62,17 @@ qlonglong AboutSettings::availableDiskSpace() const
const QString AboutSettings::bluetoothAddress() const
{
return m_netinfo->macAddress(QSystemNetworkInfo::BluetoothMode);
return m_netinfo->macAddress(QNetworkInfo::BluetoothMode, 0);
}
const QString AboutSettings::wlanMacAddress() const
{
return m_netinfo->macAddress(QSystemNetworkInfo::WlanMode);
return m_netinfo->macAddress(QNetworkInfo::WlanMode, 0);
}
const QString AboutSettings::imei() const
{
return m_devinfo->imei();
return m_devinfo->imei(0);
}
const QString AboutSettings::manufacturer() const
......
......@@ -32,12 +32,11 @@
#ifndef ABOUTSETTINGS_H
#define ABOUTSETTINGS_H
#include <QSystemStorageInfo>
#include <QSystemNetworkInfo>
#include <QSystemDeviceInfo>
QTM_USE_NAMESPACE
#include <QObject>
class QStorageInfo;
class QNetworkInfo;
class QDeviceInfo;
class AboutSettings: public QObject
{
Q_OBJECT
......@@ -64,9 +63,9 @@ public:
const QString model() const;
private:
QSystemStorageInfo *m_sysinfo;
QSystemNetworkInfo *m_netinfo;
QSystemDeviceInfo *m_devinfo;
QStorageInfo *m_sysinfo;
QNetworkInfo *m_netinfo;
QDeviceInfo *m_devinfo;
};
#endif
......@@ -33,6 +33,8 @@
#include <QDir>
#include <QDebug>
#include <QQmlEngine>
#include <qqml.h>
const char * const AlarmToneDir = "/usr/share/sounds/jolla-ringtones/stereo/";
......@@ -40,11 +42,6 @@ const char * const AlarmToneDir = "/usr/share/sounds/jolla-ringtones/stereo/";
AlarmToneModel::AlarmToneModel(QObject *parent)
: QAbstractListModel(parent)
{
QHash<int, QByteArray> roles;
roles[FilenameRole] = "filename";
roles[TitleRole] = "title";
setRoleNames(roles);
QDir ringtoneDir(AlarmToneDir);
QStringList filters;
filters << "*.wav" << "*.mp3" << "*.ogg"; // TODO: need more?
......@@ -55,6 +52,15 @@ AlarmToneModel::~AlarmToneModel()
{
}
QHash<int, QByteArray> AlarmToneModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[FilenameRole] = "filename";
roles[TitleRole] = "title";
return roles;
}
int AlarmToneModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
......@@ -78,3 +84,19 @@ QVariant AlarmToneModel::data(const QModelIndex &index, int role) const
return QVariant();
}
}
QJSValue AlarmToneModel::get(int index) const
{
if (index < 0 || m_fileInfoList.count() <= index) {
return QJSValue();
}
QFileInfo info = m_fileInfoList.at(index);
QJSEngine *const engine = qmlEngine(this);
QJSValue value = engine->newObject();
value.setProperty("filename", engine->toScriptValue(info.absoluteFilePath()));
value.setProperty("title", engine->toScriptValue(info.baseName()));
return value;
}
......@@ -34,11 +34,13 @@
#include <QAbstractListModel>
#include <QFileInfo>
#include <QJSValue>
class AlarmToneModel : public QAbstractListModel
class AlarmToneModel
: public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ rowCount CONSTANT)
public:
enum ApplicationRoles {
FilenameRole = Qt::UserRole + 1,
......@@ -47,14 +49,19 @@ public:
explicit AlarmToneModel(QObject *parent = 0);
virtual ~AlarmToneModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role) const;
Q_INVOKABLE QJSValue get(int index) const;
signals:
void selectedFileChanged();
void currentIndexChanged();
protected:
QHash<int, QByteArray> roleNames() const;
private:
QFileInfoList m_fileInfoList;
};
......
......@@ -80,8 +80,9 @@ bool DateTimeSettings::automaticTimezoneUpdate()
void DateTimeSettings::setAutomaticTimezoneUpdate(bool enable)
{
bool enabled = m_autoTimezone == MeeGo::QmTime::AutoTimeZoneOn;
if (enabled == enable)
if (enabled == enable) {
return;
}
m_time.setAutoTimeZone(enable ? MeeGo::QmTime::AutoTimeZoneOn : MeeGo::QmTime::AutoTimeZoneOff);
}
......@@ -93,8 +94,9 @@ QString DateTimeSettings::timezone() const
void DateTimeSettings::setTimezone(const QString &tz)
{
if (tz == m_timezone)
if (tz == m_timezone) {
return;
}
m_time.setTimezone(tz);
}
......
/*
* Copyright (C) 2013 Jolla Ltd. <pekka.vuorela@jollamobile.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include <QObject>
#include <QSettings>
#include <QProcess>
#include <QDebug>
#include "devicelockiface.h"
static bool runPlugin(QStringList args)
{
QSettings s("/usr/share/lipstick/devicelock/devicelock.conf", QSettings::IniFormat);
QString pluginName = s.value("DeviceLock/pluginName").toString();
if (pluginName.isEmpty()) {
qWarning("DeviceLock: no plugin configuration set in /usr/share/lipstick/devicelock/devicelock.conf");
return false;
}
QProcess p;
p.start(pluginName, args);
if (!p.waitForFinished()) {
qWarning("DeviceLock: plugin did not finish in time");
return false;
}
qDebug() << p.readAllStandardOutput();
qWarning() << p.readAllStandardError();
return p.exitCode() == 0;
}
DeviceLockInterface::DeviceLockInterface(QObject *parent)
: QObject(parent),
m_cacheRefreshNeeded(true)
{
}
DeviceLockInterface::~DeviceLockInterface()
{
}
bool DeviceLockInterface::checkCode(const QString &code)
{
return runPlugin(QStringList() << "--check-code" << code);
}
bool DeviceLockInterface::setCode(const QString &oldCode, const QString &newCode)
{
bool return_value = runPlugin(QStringList() << "--set-code" << oldCode << newCode);
if (return_value) {
m_cacheRefreshNeeded = true;
emit isSetChanged();
}
return return_value;
}
bool DeviceLockInterface::isSet() {
if (m_cacheRefreshNeeded) {
m_codeSet = runPlugin(QStringList() << "--is-set" << "lockcode");
m_cacheRefreshNeeded = false;
}
return m_codeSet;
}
/*
* Copyright (C) 2013 Jolla Ltd. <pekka.vuorela@jollamobile.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef DEVICELOCKINTERFACE_H
#define DEVICELOCKINTERFACE_H
#include <QObject>
#include <QSettings>
#include <QProcess>
#include <QDebug>
class DeviceLockInterface : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isSet READ isSet NOTIFY isSetChanged);
public:
explicit DeviceLockInterface(QObject *parent = 0);
virtual ~DeviceLockInterface();
Q_INVOKABLE bool checkCode(const QString &code);
Q_INVOKABLE bool setCode(const QString &oldCode, const QString &newCode);
Q_INVOKABLE bool isSet();
signals:
void isSetChanged();
private:
bool m_codeSet;
bool m_cacheRefreshNeeded;
};
#endif
......@@ -35,17 +35,33 @@
#include "displaysettings.h"
#include <QDebug>
static const char *MceDisplayBrightness = "/system/osso/dsm/display/display_brightness";
static const char *MceDisplayDimTimeout = "/system/osso/dsm/display/display_dim_timeout";
static const char *MceDisplayBlankTimeout = "/system/osso/dsm/display/display_blank_timeout";
static const char *MceDisplayUseAdaptiveDimming = "/system/osso/dsm/display/use_adaptive_display_dimming";
DisplaySettings::DisplaySettings(QObject *parent)
: QObject(parent)
{
m_mceIface = new ComNokiaMceRequestInterface(MCE_SERVICE, MCE_REQUEST_PATH, QDBusConnection::systemBus(), this);
QDBusPendingReply<QDBusVariant> result = m_mceIface->get_config(QDBusObjectPath("/system/osso/dsm/display/display_brightness"));
QDBusPendingReply<QDBusVariant> result = m_mceIface->get_config(QDBusObjectPath(MceDisplayBrightness));
result.waitForFinished();
m_brightness = result.value().variant().toInt();
result = m_mceIface->get_config(QDBusObjectPath(MceDisplayDimTimeout));
result.waitForFinished();
m_dimTimeout = result.value().variant().toInt();
result = m_mceIface->get_config(QDBusObjectPath(MceDisplayBlankTimeout));
result.waitForFinished();
m_blankTimeout = result.value().variant().toInt();
result = m_mceIface->get_config(QDBusObjectPath(MceDisplayUseAdaptiveDimming));
result.waitForFinished();
m_adaptiveDimming = result.value().variant().toBool();
}
int DisplaySettings::brightness()
int DisplaySettings::brightness() const
{
return m_brightness;
}
......@@ -54,7 +70,7 @@ void DisplaySettings::setBrightness(int value)
{
if (m_brightness != value) {
m_brightness = value;
m_mceIface->set_config(QDBusObjectPath("/system/osso/dsm/display/display_brightness"), QDBusVariant(value));
m_mceIface->set_config(QDBusObjectPath(MceDisplayBrightness), QDBusVariant(value));
emit brightnessChanged();
}
}
......@@ -67,3 +83,44 @@ int DisplaySettings::maximumBrightness()
return result.value().variant().toInt();
}
int DisplaySettings::dimTimeout() const
{
return m_dimTimeout;
}
void DisplaySettings::setDimTimeout(int value)
{
if (m_dimTimeout != value) {
m_dimTimeout = value;
m_mceIface->set_config(QDBusObjectPath(MceDisplayDimTimeout), QDBusVariant(value));
emit dimTimeoutChanged();
}
}
int DisplaySettings::blankTimeout() const
{
return m_blankTimeout;
}
void DisplaySettings::setBlankTimeout(int value)
{
if (m_blankTimeout != value) {
m_blankTimeout = value;
m_mceIface->set_config(QDBusObjectPath(MceDisplayBlankTimeout), QDBusVariant(value));
emit blankTimeoutChanged();
}
}
bool DisplaySettings::adaptiveDimming() const
{
return m_adaptiveDimming;
}
void DisplaySettings::setAdaptiveDimming(bool enabled)
{
if (m_adaptiveDimming != enabled) {
m_adaptiveDimming = enabled;
m_mceIface->set_config(QDBusObjectPath(MceDisplayUseAdaptiveDimming), QDBusVariant(enabled));
emit adaptiveDimmingChanged();
}
}
......@@ -33,7 +33,7 @@
#define DISPLAYSETTINGS_H
#include <QObject>
#include <qdeclarative.h>
#include <QtQml>
class ComNokiaMceRequestInterface;
......@@ -43,21 +43,39 @@ class DisplaySettings: public QObject
Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
Q_PROPERTY(int maximumBrightness READ maximumBrightness CONSTANT)
Q_PROPERTY(int dimTimeout READ dimTimeout WRITE setDimTimeout NOTIFY dimTimeoutChanged)
Q_PROPERTY(int blankTimeout READ blankTimeout WRITE setBlankTimeout NOTIFY blankTimeoutChanged)
Q_PROPERTY(bool adaptiveDimming READ adaptiveDimming WRITE setAdaptiveDimming NOTIFY adaptiveDimmingChanged)
public:
explicit DisplaySettings(QObject *parent = 0);
int brightness();
int brightness() const;
void setBrightness(int);
int maximumBrightness();
int dimTimeout() const;
void setDimTimeout(int t);
int blankTimeout() const;
void setBlankTimeout(int t);
bool adaptiveDimming() const;
void setAdaptiveDimming(bool);
signals:
void brightnessChanged();
void dimTimeoutChanged();
void blankTimeoutChanged();
void adaptiveDimmingChanged();
private:
ComNokiaMceRequestInterface *m_mceIface;
int m_brightness;
int m_dimTimeout;
int m_blankTimeout;
bool m_adaptiveDimming;
};
QML_DECLARE_TYPE(DisplaySettings)
......
......@@ -28,6 +28,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include "languagemodel.h"
#include <QDir>
......@@ -61,8 +62,8 @@ QString localeConfigPath()
}
Language::Language(QString name, QString localeCode, QString region)
: m_name(name), m_localeCode(localeCode), m_region(region)
Language::Language(QString name, QString localeCode, QString region, QString regionLabel)
: m_name(name), m_localeCode(localeCode), m_region(region), m_regionLabel(regionLabel)
{
}
......@@ -81,17 +82,15 @@ QString Language::region() const
return m_region;
}
QString Language::regionLabel() const
{
return m_regionLabel;
}
LanguageModel::LanguageModel(QObject *parent)
: QAbstractListModel(parent),
m_currentIndex(-1)
{
QHash<int, QByteArray> roles;
roles[NameRole] = "name";
roles[LocaleRole] = "locale";
roles[RegionRole] = "region";
setRoleNames(roles);
// get supported languages
QDir languageDirectory(LanguageSupportDirectory);
QFileInfoList fileInfoList = languageDirectory.entryInfoList(QStringList("*.conf"), QDir::Files);
......@@ -102,10 +101,12 @@ LanguageModel::LanguageModel(QObject *parent)
QString name = settings.value("Name").toString();
QString localeCode = settings.value("LocaleCode").toString();
QString region = settings.value("Region").toString();
//% "Region: %1"
QString regionLabel = settings.value("RegionLabel", qtTrId("settings_system-la-region")).toString();
if (name.isEmpty() || localeCode.isEmpty() || region.isEmpty()) {
continue;
}
Language newLanguage(name, localeCode, region);
Language newLanguage(name, localeCode, region, regionLabel);
m_languages.append(newLanguage);
}
......@@ -118,6 +119,16 @@ LanguageModel::~LanguageModel()
{
}
QHash<int, QByteArray> LanguageModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[NameRole] = "name";
roles[LocaleRole] = "locale";
roles[RegionRole] = "region";
roles[RegionLabelRole] = "regionLabel";
return roles;
}
void LanguageModel::readCurrentLocale()
{
......@@ -162,6 +173,8 @@ QVariant LanguageModel::data(const QModelIndex &index, int role) const
return language.localeCode();
case RegionRole:
return language.region();
case RegionLabelRole:
return language.regionLabel();
default:
return QVariant();
}
......@@ -172,6 +185,22 @@ int LanguageModel::currentIndex() const
return m_currentIndex;
}
QString LanguageModel::languageName(int index) const
{
if (index < 0 || index >= m_languages.count()) {
return QString();
}
return m_languages.at(index).name();
}
QString LanguageModel::locale(int index) const
{
if (index < 0 || index >= m_languages.count()) {
return QString();
}
return m_languages.at(index).localeCode();
}
void LanguageModel::setSystemLocale(const QString &localeCode, LocaleUpdateMode updateMode)
{
QFile localeConfig(localeConfigPath());
......@@ -182,7 +211,7 @@ void LanguageModel::setSystemLocale(const QString &localeCode, LocaleUpdateMode
}
localeConfig.write("# Autogenerated by settings\n");
localeConfig.write(QString("LANG=%1\n").arg(localeCode).toAscii());
localeConfig.write(QString("LANG=%1\n").arg(localeCode).toLatin1());
localeConfig.close();
int oldLocale = m_currentIndex;
......
......@@ -37,15 +37,17 @@
class Language {
public:
Language(QString name, QString localeCode, QString region);
Language(QString name, QString localeCode, QString region, QString regionLabel);
QString name() const;
QString localeCode() const;
QString region() const;
QString regionLabel() const;
private:
QString m_name;
QString m_localeCode;
QString m_region;
QString m_regionLabel;
};
class LanguageModel: public QAbstractListModel
......@@ -58,7 +60,8 @@ public:
enum LanguageRoles {
NameRole = Qt::UserRole + 1,
LocaleRole,
RegionRole
RegionRole,
RegionLabelRole
};
enum LocaleUpdateMode {
......@@ -73,11 +76,18 @@ public:
virtual QVariant data(const QModelIndex &index, int role) const;
int currentIndex() const;
Q_INVOKABLE QString languageName(int index) const;
Q_INVOKABLE QString locale(int index) const;
Q_INVOKABLE void setSystemLocale(const QString &localeCode, LocaleUpdateMode updateMode);
signals:
void currentIndexChanged();
protected:
QHash<int, QByteArray> roleNames() const;
private: