From f1d884b6dad5a93d7a3077b6b05d3ec7fcd9a6ea Mon Sep 17 00:00:00 2001 From: Teemu Holappa Date: Thu, 11 Feb 2016 11:50:55 +0200 Subject: Refactored Qml plugins into modules. Separated C++ and Qml interfaces. All the UI's from plugins are moved to the settingsui folder. Change-Id: Id6a6623346b18321357bc42d24121c4d9cdfd098 Reviewed-by: Kimmo Ollila --- .../localesettingsplugin/Language.qml | 111 -------------- .../localesettingsplugin/RegionSelect.qml | 96 ------------ .../localesettingsplugin/icons.qrc | 4 - .../localesettingsplugin/locale.xml | 12 -- .../localesettingsplugin/localefiltermodel.cpp | 96 ------------ .../localesettingsplugin/localefiltermodel.h | 59 -------- .../localesettingsplugin/localemodel.cpp | 167 --------------------- .../localesettingsplugin/localemodel.h | 96 ------------ .../localesettingsplugin/localesettingsplugin.pro | 36 ----- .../localesettingsplugin/plugin.cpp | 75 --------- src/qtdevicesettings/localesettingsplugin/qml.qrc | 6 - src/qtdevicesettings/localesettingsplugin/qmldir | 3 - .../localesettingsplugin/systemlocale.cpp | 57 ------- .../localesettingsplugin/systemlocale.h | 62 -------- .../localesettingsplugin/systemlocale_p.h | 87 ----------- 15 files changed, 967 deletions(-) delete mode 100644 src/qtdevicesettings/localesettingsplugin/Language.qml delete mode 100644 src/qtdevicesettings/localesettingsplugin/RegionSelect.qml delete mode 100644 src/qtdevicesettings/localesettingsplugin/icons.qrc delete mode 100644 src/qtdevicesettings/localesettingsplugin/locale.xml delete mode 100644 src/qtdevicesettings/localesettingsplugin/localefiltermodel.cpp delete mode 100644 src/qtdevicesettings/localesettingsplugin/localefiltermodel.h delete mode 100644 src/qtdevicesettings/localesettingsplugin/localemodel.cpp delete mode 100644 src/qtdevicesettings/localesettingsplugin/localemodel.h delete mode 100644 src/qtdevicesettings/localesettingsplugin/localesettingsplugin.pro delete mode 100644 src/qtdevicesettings/localesettingsplugin/plugin.cpp delete mode 100644 src/qtdevicesettings/localesettingsplugin/qml.qrc delete mode 100644 src/qtdevicesettings/localesettingsplugin/qmldir delete mode 100644 src/qtdevicesettings/localesettingsplugin/systemlocale.cpp delete mode 100644 src/qtdevicesettings/localesettingsplugin/systemlocale.h delete mode 100644 src/qtdevicesettings/localesettingsplugin/systemlocale_p.h (limited to 'src/qtdevicesettings/localesettingsplugin') diff --git a/src/qtdevicesettings/localesettingsplugin/Language.qml b/src/qtdevicesettings/localesettingsplugin/Language.qml deleted file mode 100644 index e630b00..0000000 --- a/src/qtdevicesettings/localesettingsplugin/Language.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles.Flat 1.0 as Flat -import com.theqtcompany.settings.common 1.0 -import com.theqtcompany.settings.locale 1.0 - -Item { - id: root - property string title: qsTr("Language and Region") - - Column { - id: content - anchors.fill: parent - anchors.margins: Math.round(40 * Flat.FlatStyle.scaleFactor) - - GroupBox { - id: groupBox - width: parent.width - title: qsTr("Regional Format") - Layout.fillWidth: true - property var currentRegion: Qt.locale(LocaleManager.locale) - - ColumnLayout { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - width: parent.width - Layout.fillWidth: true - - Component { - id: regionSelect - RegionSelect { } - } - - GroupBox { - width: parent.width - title: { - if (groupBox.currentRegion.name === "C" || groupBox.currentRegion.name === "POSIX") { - return qsTr("Default"); - } - else if (groupBox.currentRegion.name !== "") { - return qsTr("%L1/%L2").arg(groupBox.currentRegion.nativeLanguageName).arg(groupBox.currentRegion.nativeCountryName) - } - else { - return qsTr("Region not set"); - } - } - - flat: true - - ColumnLayout { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - Layout.fillWidth: true - width: parent.width - - TextLabel { - text: Date().toLocaleString(groupBox.currentRegion) - } - - TextLabel { - text: Number(2343.34).toLocaleString(groupBox.currentRegion) - } - - TextLabel { - text: Number(41334.34).toLocaleCurrencyString(groupBox.currentRegion) - } - } - } - - Button { - text: qsTr("Change region") - onClicked: stackView.push(regionSelect) - } - } - } - } -} diff --git a/src/qtdevicesettings/localesettingsplugin/RegionSelect.qml b/src/qtdevicesettings/localesettingsplugin/RegionSelect.qml deleted file mode 100644 index 9247630..0000000 --- a/src/qtdevicesettings/localesettingsplugin/RegionSelect.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles.Flat 1.0 as Flat -import com.theqtcompany.settings.common 1.0 -import com.theqtcompany.settings.locale 1.0 - -Item { - id: root - property string title: qsTr("Select language") - - Component.onCompleted: country.text = LocaleFilter.filter - - Column { - id: content - anchors.fill: parent - anchors.margins: Math.round(20 * Flat.FlatStyle.scaleFactor) - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - - TextLabel { - text: qsTr("Search region: ") - } - - TextField { - id: country - text: "" - onTextChanged: LocaleFilter.filter = country.text - } - } - - TableView { - width: parent.width - height: Math.round(parent.height - 40 * Flat.FlatStyle.scaleFactor) - Layout.fillWidth: true - model: LocaleFilter - headerVisible: true - - TableViewColumn { - role: "language" - title: qsTr("Language") - width: Math.round(parent.width * 0.66) - } - - TableViewColumn { - role: "country" - title: qsTr("Region") - width: Math.round(parent.width * 0.33) - } - - onClicked: { - var val = model.itemFromRow(row); - if (val !== "") { - LocaleManager.locale = val; - stackView.pop(); - } - } - } - } -} diff --git a/src/qtdevicesettings/localesettingsplugin/icons.qrc b/src/qtdevicesettings/localesettingsplugin/icons.qrc deleted file mode 100644 index af8a564..0000000 --- a/src/qtdevicesettings/localesettingsplugin/icons.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/qtdevicesettings/localesettingsplugin/locale.xml b/src/qtdevicesettings/localesettingsplugin/locale.xml deleted file mode 100644 index b722456..0000000 --- a/src/qtdevicesettings/localesettingsplugin/locale.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/qtdevicesettings/localesettingsplugin/localefiltermodel.cpp b/src/qtdevicesettings/localesettingsplugin/localefiltermodel.cpp deleted file mode 100644 index 027caba..0000000 --- a/src/qtdevicesettings/localesettingsplugin/localefiltermodel.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "localemodel.h" -#include "localefiltermodel.h" - -LocaleFilterModel::LocaleFilterModel(QObject* parent) - :QSortFilterProxyModel(parent) -{ - connect(this, &LocaleFilterModel::filterChanged, this, &LocaleFilterModel::invalidate); -} - -LocaleFilterModel::~LocaleFilterModel() -{ - -} - -QString LocaleFilterModel::filter() const -{ - return m_filter; -} - -void LocaleFilterModel::setFilter(const QString& aFilter) -{ - m_filter = aFilter; - emit filterChanged(); -} - -bool LocaleFilterModel::filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const -{ - bool ret = false; - if (this->sourceModel()) - { - QModelIndex index = this->sourceModel()->index( source_row, 0, source_parent ); - if (index.isValid()) - { - QVariant nameRole = index.data(LocaleModel::Country); - if (nameRole.isValid()) - { - QString name = nameRole.toString(); - if (name.contains(m_filter, Qt::CaseInsensitive)) { - ret = true; - } - } - } - } - return ret; -} - -QVariant LocaleFilterModel::itemFromRow(const int row) const -{ - QModelIndex idx = index(row, 0); - QModelIndex mapped = mapToSource(idx); - if (mapped.isValid()) - { - QVariant nameRole = mapped.data(LocaleModel::Code); - if (nameRole.isValid()) - { - return nameRole; - } - } - return QVariant::fromValue(QString("")); -} - diff --git a/src/qtdevicesettings/localesettingsplugin/localefiltermodel.h b/src/qtdevicesettings/localesettingsplugin/localefiltermodel.h deleted file mode 100644 index f4dce1b..0000000 --- a/src/qtdevicesettings/localesettingsplugin/localefiltermodel.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LOCALEFILTERMODEL_H -#define LOCALEFILTERMODEL_H - -#include - -class LocaleFilterModel : public QSortFilterProxyModel -{ - Q_OBJECT - Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) -public: - explicit LocaleFilterModel(QObject* parent); - virtual ~LocaleFilterModel(); - bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const override; - QString filter() const; - void setFilter(const QString& aFilter); - Q_INVOKABLE QVariant itemFromRow(const int row) const; -signals: - void filterChanged(); -private: - QString m_filter; - -}; - -#endif // LOCALEFILTERMODEL_H diff --git a/src/qtdevicesettings/localesettingsplugin/localemodel.cpp b/src/qtdevicesettings/localesettingsplugin/localemodel.cpp deleted file mode 100644 index be24e02..0000000 --- a/src/qtdevicesettings/localesettingsplugin/localemodel.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "localemodel.h" - - -LocaleItem::LocaleItem(const QLocale& locale, QObject *parent) - :QObject(parent) -{ - m_code = locale.name(); - m_country = locale.nativeCountryName(); - if (m_country.isEmpty()) { - m_country = locale.countryToString(locale.country()); - } - - m_language = locale.nativeLanguageName(); - if (m_language.isEmpty()) { - m_language = locale.languageToString(locale.language()); - } -} - -QString LocaleItem::language() const -{ - return m_language; -} - -QString LocaleItem::country() const -{ - return m_country; -} - -QString LocaleItem::code() const -{ - return m_code; -} - -LocaleModel::LocaleModel(QObject *parent) - : QAbstractListModel(parent) -{ - m_roleNames.insert(Qt::UserRole, "modelData"); - m_roleNames.insert(Country, "country"); - m_roleNames.insert(Language, "language"); - m_roleNames.insert(Code, "code"); - - QFutureWatcher *watcher = new QFutureWatcher(this); - QFuture future = QtConcurrent::run(LocaleModel::generateModel, this); - watcher->setFuture(future); - connect(watcher, SIGNAL(finished()), this, SLOT(modelReady())); -} - -void LocaleModel::modelReady() -{ - beginResetModel(); - sort(0); - endResetModel(); -} - -void LocaleModel::generateModel(LocaleModel* model) -{ - QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - - for (const QLocale &locale : allLocales) { - if (locale.name() != "C") { - LocaleItem *l = new LocaleItem(locale); - l->moveToThread(model->thread()); - QMetaObject::invokeMethod(model, "addNewItem", Q_ARG( QObject*, qobject_cast(l))); - } - } - -} - -void LocaleModel::addNewItem(QObject *item) -{ - beginInsertRows(QModelIndex(), m_items.count(), m_items.count()); - LocaleItem* newItem = qobject_cast(item); - if (newItem) - m_items.append(newItem); - endInsertRows(); -} - -LocaleModel::~LocaleModel() -{ - qDeleteAll(m_items); -} - -QHash LocaleModel::roleNames() const -{ - return m_roleNames; -} - -int LocaleModel::rowCount(const QModelIndex & parent) const -{ - Q_UNUSED(parent); - return m_items.count(); -} - -QVariant LocaleModel::data(const QModelIndex & index, int role) const -{ - if (!index.isValid()) return QVariant(); - - LocaleItem *item = m_items[index.row()]; - - switch (role) { - case Country: - return item->country(); - break; - case Language: - return item->language(); - break; - case Code: - return item->code(); - break; - default: - return ""; - } -} - -bool LocaleModel::variantLessThan(const LocaleItem* v1, const LocaleItem* v2) -{ - return v1->language() < v2->language(); -} - -void LocaleModel::sort(int column, Qt::SortOrder order) -{ - Q_UNUSED(column); - Q_UNUSED(order); - qSort(m_items.begin(), m_items.end(), LocaleModel::variantLessThan); -} diff --git a/src/qtdevicesettings/localesettingsplugin/localemodel.h b/src/qtdevicesettings/localesettingsplugin/localemodel.h deleted file mode 100644 index b83286e..0000000 --- a/src/qtdevicesettings/localesettingsplugin/localemodel.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LOCALEMODEL_H -#define LOCALEMODEL_H - -#include -#include -#include -#include - -class LocaleItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString code READ code CONSTANT) - Q_PROPERTY(QString country READ country CONSTANT) - Q_PROPERTY(QString language READ language CONSTANT) -public: - explicit LocaleItem(const QLocale &locale, QObject *parent=0); - QString country() const; - QString language() const; - QString code() const; - -private: - QString m_country; - QString m_language; - QString m_code; -}; - -class LocaleModel : public QAbstractListModel -{ - Q_OBJECT - -public: - explicit LocaleModel(QObject *parent=0); - virtual ~LocaleModel(); - // from QAbstractItemModel - int rowCount(const QModelIndex & parent = QModelIndex()) const; - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - QHash roleNames() const; - Q_INVOKABLE QVariant itemFromRow(const int row) const; - void sort(int column, Qt::SortOrder order=Qt::AscendingOrder); - static bool variantLessThan(const LocaleItem* v1, const LocaleItem* v2); - - enum Roles { - Language = Qt::DisplayPropertyRole, - Country = Qt::UserRole, - Code - }; - - static void generateModel(LocaleModel* model); - -signals: - void addItem(LocaleItem* item); - -private slots: - void addNewItem(QObject* item); - void modelReady(); - -private: - QList m_items; - QHash m_roleNames; -}; -#endif // LOCALEMODEL_H diff --git a/src/qtdevicesettings/localesettingsplugin/localesettingsplugin.pro b/src/qtdevicesettings/localesettingsplugin/localesettingsplugin.pro deleted file mode 100644 index 8ff9157..0000000 --- a/src/qtdevicesettings/localesettingsplugin/localesettingsplugin.pro +++ /dev/null @@ -1,36 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -QT += qml dbus - -uri = com.theqtcompany.settings.locale - -DBUS_INTERFACES = locale.xml - -DESTDIR = imports/Locale -TARGET = localesettingsplugin - -HEADERS = \ - systemlocale.h \ - systemlocale_p.h \ - localemodel.h \ - localefiltermodel.h -SOURCES += plugin.cpp \ - systemlocale.cpp \ - localemodel.cpp \ - localefiltermodel.cpp - -pluginfiles.files += \ - qmldir \ - Language.qml \ - RegionSelect.qml - -installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - -target.path = $$installPath -pluginfiles.path += $$installPath -INSTALLS += target pluginfiles - - -RESOURCES += \ - icons.qrc - diff --git a/src/qtdevicesettings/localesettingsplugin/plugin.cpp b/src/qtdevicesettings/localesettingsplugin/plugin.cpp deleted file mode 100644 index a050615..0000000 --- a/src/qtdevicesettings/localesettingsplugin/plugin.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include "systemlocale.h" -#include "localemodel.h" -#include "localefiltermodel.h" - -template -QObject *instance(QQmlEngine *engine, QJSEngine *) { - T *t = new T(engine); - t->setObjectName(T::staticMetaObject.className()); - return t; -} - -class LanguageSettingsQmlPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri) - { - qmlRegisterSingletonType(uri, 1, 0, "LocaleManager", &instance); - } - - void initializeEngine(QQmlEngine * engine, const char * uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("com.theqtcompany.settings.locale")); - LocaleModel*localeModel = new LocaleModel(engine); - LocaleFilterModel* filter = new LocaleFilterModel(engine); - filter->setSourceModel(localeModel); - engine->rootContext()->setContextProperty("LocaleFilter", filter); - } -}; - -#include "plugin.moc" diff --git a/src/qtdevicesettings/localesettingsplugin/qml.qrc b/src/qtdevicesettings/localesettingsplugin/qml.qrc deleted file mode 100644 index 27fef3d..0000000 --- a/src/qtdevicesettings/localesettingsplugin/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - Language.qml - RegionSelect.qml - - diff --git a/src/qtdevicesettings/localesettingsplugin/qmldir b/src/qtdevicesettings/localesettingsplugin/qmldir deleted file mode 100644 index e915482..0000000 --- a/src/qtdevicesettings/localesettingsplugin/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module com.theqtcompany.settings.locale -Language 1.0 Language.qml -plugin localesettingsplugin diff --git a/src/qtdevicesettings/localesettingsplugin/systemlocale.cpp b/src/qtdevicesettings/localesettingsplugin/systemlocale.cpp deleted file mode 100644 index 21a1105..0000000 --- a/src/qtdevicesettings/localesettingsplugin/systemlocale.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include "systemlocale.h" -#include "systemlocale_p.h" - -SystemLocale::SystemLocale(QObject *parent) - :QObject(parent) - ,d_ptr(new SystemLocalePrivate(this)) -{ -} - -QString SystemLocale::locale() const -{ - Q_D(const SystemLocale); - return d->locale(); -} - -void SystemLocale::setLocale(const QString& aLocale) -{ - Q_D(SystemLocale); - d->setLocale(aLocale); - emit localeChanged(); -} diff --git a/src/qtdevicesettings/localesettingsplugin/systemlocale.h b/src/qtdevicesettings/localesettingsplugin/systemlocale.h deleted file mode 100644 index c02fdd3..0000000 --- a/src/qtdevicesettings/localesettingsplugin/systemlocale.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LOCALE_H -#define LOCALE_H - -#include - -class SystemLocalePrivate; - -class SystemLocale : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString locale READ locale WRITE setLocale NOTIFY localeChanged) -public: - explicit SystemLocale(QObject *parent = 0); - QString locale() const; - void setLocale(const QString& aLocale); -signals: - void localeChanged(); -public slots: - -protected: - SystemLocalePrivate *d_ptr; - - Q_DISABLE_COPY(SystemLocale) - Q_DECLARE_PRIVATE(SystemLocale) -}; - -#endif // LOCALE_H diff --git a/src/qtdevicesettings/localesettingsplugin/systemlocale_p.h b/src/qtdevicesettings/localesettingsplugin/systemlocale_p.h deleted file mode 100644 index 417b958..0000000 --- a/src/qtdevicesettings/localesettingsplugin/systemlocale_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Device Utilities module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LOCALE_P_H -#define LOCALE_P_H - -#include "systemlocale.h" -#include "locale_interface.h" - -class SystemLocalePrivate -{ - Q_DECLARE_PUBLIC(SystemLocale) -public: - SystemLocalePrivate(SystemLocale *qq) - :q_ptr(qq) - { - m_localeInterface = new OrgFreedesktopLocale1Interface(QStringLiteral("org.freedesktop.locale1"), - QStringLiteral("/org/freedesktop/locale1"), - QDBusConnection::systemBus(), qq); - - QStringList locale = m_localeInterface->locale(); - foreach (QString l, locale) { - QStringList nameValue = l.split('='); - if (nameValue.length() == 2) - m_localeCache[nameValue.at(0)] = nameValue.at(1); - } - } - - QString locale() const { - return m_localeCache["LANG"]; - } - - void setLocale(const QString& aLocale) { - m_localeCache["LANG"] = aLocale; - updateLocale(); - } - - void updateLocale() { - QStringList newLocale; - QMap::iterator i; - for (i = m_localeCache.begin(); i != m_localeCache.end(); ++i) { - QString val = i.key() + "=" + i.value(); - newLocale.append(val); - } - m_localeInterface->SetLocale(newLocale, true); - } - - -private: - QMap m_localeCache; - OrgFreedesktopLocale1Interface *m_localeInterface; - SystemLocale *q_ptr; -}; - -#endif // LOCALE_P_H -- cgit v1.2.3