diff options
84 files changed, 2625 insertions, 584 deletions
diff --git a/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp b/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp index e473f59..7b29ec9 100644 --- a/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp +++ b/src/bluetoothsettings/bluez/bluetoothdevice_p.cpp @@ -33,6 +33,11 @@ #include "moc_objectmanager_interface.cpp" #include "device1_interface.h" +#ifdef USE_CONNMAN_BLUETOOTH +#include "connman_technology_interface.h" +#include "connmancommon.h" +#endif + QT_BEGIN_NAMESPACE BluetoothDevicePrivate::BluetoothDevicePrivate(BluetoothDevice *parent) : QObject(parent) @@ -49,6 +54,11 @@ BluetoothDevicePrivate::BluetoothDevicePrivate(BluetoothDevice *parent) : QObjec m_manager = new OrgFreedesktopDBusObjectManagerInterface(QStringLiteral("org.bluez"), QStringLiteral("/"), QDBusConnection::systemBus(), this); +#ifdef USE_CONNMAN_BLUETOOTH + m_technology = new NetConnmanTechnologyInterface(QStringLiteral("net.connman"), + QStringLiteral("/net/connman/technology/bluetooth"), + QDBusConnection::systemBus(), this); +#endif QDBusPendingReply<ManagedObjectList> reply = m_manager->GetManagedObjects(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, @@ -69,6 +79,13 @@ bool BluetoothDevicePrivate::powered() const void BluetoothDevicePrivate::setPowered(const bool& aPowered) { + if (!m_localDevice) + return; + +#ifdef USE_CONNMAN_BLUETOOTH + m_technology->SetProperty(PropertyPowered, QDBusVariant(QVariant(aPowered))); +#endif + if (aPowered) { m_localDevice->powerOn(); } @@ -219,9 +236,11 @@ void BluetoothDevicePrivate::getManagedObjectsFinished(QDBusPendingCallWatcher * if (m_powered) { emit q->poweredChanged(); - m_deviceModel->scanDevices(); - m_scanning = true; - emit q->scanningChanged(); + if (!m_scanning) { + m_deviceModel->scanDevices(); + m_scanning = true; + emit q->scanningChanged(); + } } emit q->availabilityChanged(); diff --git a/src/bluetoothsettings/bluez/bluetoothdevice_p.h b/src/bluetoothsettings/bluez/bluetoothdevice_p.h index e037ca3..0e1777e 100644 --- a/src/bluetoothsettings/bluez/bluetoothdevice_p.h +++ b/src/bluetoothsettings/bluez/bluetoothdevice_p.h @@ -49,6 +49,10 @@ class OrgBluezDevice1Interface; class OrgFreedesktopDBusObjectManagerInterface; +#ifdef USE_CONNMAN_BLUETOOTH +class NetConnmanTechnologyInterface; +#endif + QT_BEGIN_NAMESPACE class BluetoothDevicePrivate : public QObject @@ -91,6 +95,10 @@ private: QString m_adapter; DiscoveryModel *m_deviceModel; OrgFreedesktopDBusObjectManagerInterface *m_manager; + +#ifdef USE_CONNMAN_BLUETOOTH + NetConnmanTechnologyInterface *m_technology; +#endif }; QT_END_NAMESPACE diff --git a/src/bluetoothsettings/bluez/bluez.pri b/src/bluetoothsettings/bluez/bluez.pri index b8d39fd..60a3b17 100644 --- a/src/bluetoothsettings/bluez/bluez.pri +++ b/src/bluetoothsettings/bluez/bluez.pri @@ -13,3 +13,10 @@ HEADERS += \ SOURCES += \ $$PWD/bluetoothdevice_p.cpp + +qtHaveModule(networksettings) { + DEFINES += USE_CONNMAN_BLUETOOTH + INCLUDEPATH += $${PWD}/../../networksettings/connman + DBUS_INTERFACES += $${PWD}/../../networksettings/connman/connman_technology.xml + +} diff --git a/src/bluetoothsettings/discoverymodel.cpp b/src/bluetoothsettings/discoverymodel.cpp index 2f70800..31cf972 100644 --- a/src/bluetoothsettings/discoverymodel.cpp +++ b/src/bluetoothsettings/discoverymodel.cpp @@ -163,10 +163,19 @@ DiscoveryModel::DiscoveryModel(QObject *parent) void DiscoveryModel::deviceDiscovered(const QBluetoothDeviceInfo &device) { - beginInsertRows(QModelIndex(), m_items.count(), m_items.count()); - BtDeviceItem *item = new BtDeviceItem(device); - m_items.append(item); - endInsertRows(); + int index; + + // Insert the device to alphabetically sorted location + for (index = 0; index < m_items.count(); index++) + { + if (device.name() < m_items.at(index)->name()) + break; + } + + beginInsertRows(QModelIndex(), index, index); + BtDeviceItem *item = new BtDeviceItem(device); + m_items.insert(index, item); + endInsertRows(); } DiscoveryModel::~DiscoveryModel() @@ -185,6 +194,9 @@ void DiscoveryModel::scanDevices() this, SIGNAL(scanFinished())); } + // Reset previous list, devices are already cached by bluez + clearDeviceList(); + m_discoveryAgent->start(); } @@ -248,4 +260,11 @@ void DiscoveryModel::setConnected(const QString &aAddress, bool connected) emit dataChanged(index(i, 0), index(i, 0), role); } +void DiscoveryModel::clearDeviceList() +{ + beginResetModel(); + m_items.clear(); + endResetModel(); +} + QT_END_NAMESPACE diff --git a/src/bluetoothsettings/discoverymodel.h b/src/bluetoothsettings/discoverymodel.h index ba6e1dd..56f8299 100644 --- a/src/bluetoothsettings/discoverymodel.h +++ b/src/bluetoothsettings/discoverymodel.h @@ -115,6 +115,8 @@ Q_SIGNALS: private Q_SLOTS: void deviceDiscovered(const QBluetoothDeviceInfo &device); private: + void clearDeviceList(); + QList<BtDeviceItem*> m_items; QHash<int, QByteArray> m_roleNames; QBluetoothDeviceDiscoveryAgent *m_discoveryAgent; diff --git a/src/displaysettings/displaysettings.cpp b/src/displaysettings/displaysettings.cpp index 6cadfc2..bf15884 100644 --- a/src/displaysettings/displaysettings.cpp +++ b/src/displaysettings/displaysettings.cpp @@ -73,12 +73,36 @@ int DisplaySettings::physicalScreenSizeInch() const return d->physicalScreenSizeInch(); } +int DisplaySettings::physicalScreenWidthMm() const +{ + Q_D(const DisplaySettings); + return d->physicalScreenWidthMm(); +} + +int DisplaySettings::physicalScreenHeightMm() const +{ + Q_D(const DisplaySettings); + return d->physicalScreenHeightMm(); +} + void DisplaySettings::setPhysicalScreenSizeInch(int inches) { Q_D(DisplaySettings); d->setPhysicalScreenSizeInch(inches); } +void DisplaySettings::setPhysicalScreenWidthMm(int newWidth) +{ + Q_D(DisplaySettings); + d->setPhysicalScreenWidthMm(newWidth); +} + +void DisplaySettings::setPhysicalScreenHeightMm(int newHeight) +{ + Q_D(DisplaySettings); + d->setPhysicalScreenHeightMm(newHeight); +} + bool DisplaySettings::physicalScreenSizeOverride() const { Q_D(const DisplaySettings); diff --git a/src/displaysettings/displaysettings.h b/src/displaysettings/displaysettings.h index fc8782f..835da3f 100644 --- a/src/displaysettings/displaysettings.h +++ b/src/displaysettings/displaysettings.h @@ -41,6 +41,8 @@ class Q_DECL_EXPORT DisplaySettings : public QObject Q_PROPERTY(int displayBrightness READ displayBrightness WRITE setDisplayBrightness NOTIFY displayBrightnessChanged) Q_PROPERTY(int physicalScreenSizeInch READ physicalScreenSizeInch WRITE setPhysicalScreenSizeInch NOTIFY physicalScreenSizeInchChanged) + Q_PROPERTY(int physicalScreenWidthMm READ physicalScreenWidthMm WRITE setPhysicalScreenWidthMm NOTIFY physicalScreenWidthMmChanged) + Q_PROPERTY(int physicalScreenHeightMm READ physicalScreenHeightMm WRITE setPhysicalScreenHeightMm NOTIFY physicalScreenHeightMmChanged) Q_PROPERTY(bool physicalScreenSizeOverride READ physicalScreenSizeOverride WRITE setPhysicalScreenSizeOverride NOTIFY physicalScreenSizeOverrideChanged) public: @@ -49,17 +51,23 @@ public: int displayBrightness(); int physicalScreenSizeInch() const; + int physicalScreenWidthMm() const; + int physicalScreenHeightMm() const; bool physicalScreenSizeOverride() const; public Q_SLOTS: bool setDisplayBrightness(int value); void setPhysicalScreenSizeInch(int inches); void setPhysicalScreenSizeOverride(bool enable); + void setPhysicalScreenWidthMm(int newWidth); + void setPhysicalScreenHeightMm(int newHeight); Q_SIGNALS: void displayBrightnessChanged(int newValue); void physicalScreenSizeInchChanged(int newInches); void physicalScreenSizeOverrideChanged(bool newValue); + void physicalScreenWidthMmChanged(int newValue); + void physicalScreenHeightMmChanged(int newValue); protected: DisplaySettingsPrivate *d_ptr; diff --git a/src/displaysettings/displaysettings_p.cpp b/src/displaysettings/displaysettings_p.cpp index 890d868..e62fca7 100644 --- a/src/displaysettings/displaysettings_p.cpp +++ b/src/displaysettings/displaysettings_p.cpp @@ -103,6 +103,16 @@ int DisplaySettingsPrivate::physicalScreenSizeInch() const return m_physScreenSize->size(); } +int DisplaySettingsPrivate::physicalScreenWidthMm() const +{ + return m_physScreenSize->widthMm(); +} + +int DisplaySettingsPrivate::physicalScreenHeightMm() const +{ + return m_physScreenSize->heightMm(); +} + void DisplaySettingsPrivate::setPhysicalScreenSizeInch(int inches) { Q_Q(DisplaySettings); @@ -112,6 +122,24 @@ void DisplaySettingsPrivate::setPhysicalScreenSizeInch(int inches) } } +void DisplaySettingsPrivate::setPhysicalScreenWidthMm(int newWidth) +{ + Q_Q(DisplaySettings); + if (m_physScreenSize->widthMm() != newWidth) { + m_physScreenSize->setSizeMm(newWidth, m_physScreenSize->heightMm()); + emit q->physicalScreenWidthMmChanged(newWidth); + } +} + +void DisplaySettingsPrivate::setPhysicalScreenHeightMm(int newHeight) +{ + Q_Q(DisplaySettings); + if (m_physScreenSize->heightMm() != newHeight) { + m_physScreenSize->setSizeMm(m_physScreenSize->widthMm(), newHeight); + emit q->physicalScreenHeightMmChanged(newHeight); + } +} + bool DisplaySettingsPrivate::physicalScreenSizeOverride() const { return m_physScreenSize->enabled(); @@ -149,7 +177,8 @@ void PhysicalScreenSize::read(const QString &filename) if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) return; - int physScreenWidth = 154, physScreenHeight = 90; + physScreenWidthMm = 154; + physScreenHeightMm = 90; int found = 0; while (!f.atEnd()) { QByteArray line = f.readLine().trimmed(); @@ -161,13 +190,13 @@ void PhysicalScreenSize::read(const QString &filename) int val = values[2].toInt(&ok); if (ok) { ++found; - physScreenWidth = val; + physScreenWidthMm = val; } } else if (values[1] == QByteArrayLiteral("QT_QPA_EGLFS_PHYSICAL_HEIGHT")) { int val = values[2].toInt(&ok); if (ok) { ++found; - physScreenHeight = val; + physScreenHeightMm = val; } } } @@ -176,7 +205,7 @@ void PhysicalScreenSize::read(const QString &filename) if (found == 2) physScreenSizeEnabled = true; - const qreal diagMM = qSqrt(physScreenWidth * physScreenWidth + physScreenHeight * physScreenHeight); + const qreal diagMM = qSqrt(physScreenWidthMm * physScreenWidthMm + physScreenHeightMm * physScreenHeightMm); physScreenSizeInch = qRound(diagMM / 25.4); } @@ -209,10 +238,8 @@ void PhysicalScreenSize::write(const QString &filename, bool includePhysSize) if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) return; - const qreal diagMM = physScreenSizeInch * 25.4; - // Assume 16:9 aspect ratio - const int physScreenHeight = qRound(diagMM / 1.975); - const int physScreenWidth = qRound(physScreenHeight * 1.777); + const int physScreenHeight = physScreenHeightMm; + const int physScreenWidth = physScreenWidthMm; foreach (const QByteArray &line, lines) f.write(line + QByteArrayLiteral("\n")); @@ -229,6 +256,13 @@ void PhysicalScreenSize::setSize(int inches) physWriteTimer.start(); } +void PhysicalScreenSize::setSizeMm(int width, int height) +{ + physScreenWidthMm = width; + physScreenHeightMm = height; + physWriteTimer.start(); +} + bool PhysicalScreenSize::enabled() const { return physScreenSizeEnabled; diff --git a/src/displaysettings/displaysettings_p.h b/src/displaysettings/displaysettings_p.h index 7e1d9cd..91825e8 100644 --- a/src/displaysettings/displaysettings_p.h +++ b/src/displaysettings/displaysettings_p.h @@ -54,7 +54,10 @@ public: virtual ~PhysicalScreenSize(); void setSize(int inches); + void setSizeMm(int widthMm, int heightMm); int size() const { return physScreenSizeInch; } + int widthMm() const { return physScreenWidthMm; } + int heightMm() const { return physScreenHeightMm; } bool enabled() const; void setEnabled(bool enable); @@ -68,6 +71,8 @@ private: bool physScreenSizeEnabled; int physScreenSizeInch; + int physScreenWidthMm; + int physScreenHeightMm; QTimer physWriteTimer; }; @@ -87,16 +92,22 @@ public: DisplaySettingsPrivate(DisplaySettings* qq); int displayBrightness(); int physicalScreenSizeInch() const; + int physicalScreenWidthMm() const; + int physicalScreenHeightMm() const; bool physicalScreenSizeOverride() const; bool setDisplayBrightness(int value); void setPhysicalScreenSizeInch(int inches); + void setPhysicalScreenWidthMm(int newWidth); + void setPhysicalScreenHeightMm(int newHeight); void setPhysicalScreenSizeOverride(bool enable); private: void initLightDevices(); DisplaySettings *q_ptr; int m_brightness; int m_screenSizeInch; + int m_screenWidthMm; + int m_screenHeightMm; bool m_sizeOverride; QList<LightDevice> m_lightDevices; bool m_lightDevicesInitialized; diff --git a/src/imports/networksettings/plugin.cpp b/src/imports/networksettings/plugin.cpp index ebebf98..419b685 100644 --- a/src/imports/networksettings/plugin.cpp +++ b/src/imports/networksettings/plugin.cpp @@ -32,6 +32,7 @@ #include <qnetworksettingsservice.h> #include <qnetworksettingsuseragent.h> #include <qnetworksettingsservicemodel.h> +#include <qnetworksettingsinterface.h> #include <qnetworksettingsinterfacemodel.h> #include <qqml.h> @@ -122,6 +123,14 @@ */ /*! + \qmlmethod NetworkInterface NetworkSettingsManager::interface(int type, int instance) + + Returns the interface with type \a type and order number of \a instance + + \sa NetworkInterface +*/ + +/*! \qmlmethod NetworkSettingsManager::userAgent.setPassphrase(string passphrase) Sets the \a passphrase for connecting to a Wifi network. @@ -164,6 +173,7 @@ void NetworksettingspluginPlugin::registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtDeviceUtilities.NetworkSettings")); qmlRegisterUncreatableType<QNetworkSettingsService>(uri, 1, 0, "NetworkService", "Cannot be instantiated directly."); + qmlRegisterUncreatableType<QNetworkSettingsInterface>(uri, 1, 0, "NetworkInterface", "Cannot be instantiated directly."); qmlRegisterUncreatableType<QNetworkSettingsIPv4>(uri, 1, 0, "NetworkSettingsIPv4", "Cannot be instantiated directly."); qmlRegisterUncreatableType<QNetworkSettingsIPv6>(uri, 1, 0, "NetworkSettingsIPv6", "Cannot be instantiated directly."); qmlRegisterUncreatableType<QNetworkSettingsProxy>(uri, 1, 0, "NetworkSettingsProxy", "Cannot be instantiated directly."); diff --git a/src/imports/networksettings/plugins.qmltypes b/src/imports/networksettings/plugins.qmltypes index 5022d6f..f2603eb 100644 --- a/src/imports/networksettings/plugins.qmltypes +++ b/src/imports/networksettings/plugins.qmltypes @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2 // 'qmlplugindump -nonrelocatable QtDeviceUtilities.NetworkSettings 1.0' Module { - dependencies: [] + dependencies: ["QtQuick 2.8"] Component { name: "QNetworkSettingsIPv4" prototype: "QObject" @@ -56,6 +56,18 @@ Module { Property { name: "prefixLength"; type: "int" } } Component { + name: "QNetworkSettingsInterface" + prototype: "QObject" + exports: ["QtDeviceUtilities.NetworkSettings/NetworkInterface 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "name"; type: "string"; isReadonly: true } + Property { name: "state"; type: "QNetworkSettingsState::States"; isReadonly: true } + Property { name: "type"; type: "QNetworkSettingsType::Types"; isReadonly: true } + Property { name: "powered"; type: "bool" } + Method { name: "scanServices" } + } + Component { name: "QNetworkSettingsManager" prototype: "QObject" exports: [ @@ -88,6 +100,12 @@ Module { Parameter { name: "name"; type: "string" } Parameter { name: "type"; type: "int" } } + Method { + name: "interface" + type: "QNetworkSettingsInterface*" + Parameter { name: "type"; type: "int" } + Parameter { name: "instance"; type: "int" } + } } Component { name: "QNetworkSettingsProxy" @@ -132,7 +150,6 @@ Module { Property { name: "domains"; type: "QAbstractItemModel"; isReadonly: true; isPointer: true } Property { name: "nameservers"; type: "QAbstractItemModel"; isReadonly: true; isPointer: true } Signal { name: "wirelessChanged" } - Signal { name: "showCrendentialInput" } Method { name: "setAutoConnect" Parameter { name: "autoconnect"; type: "bool" } diff --git a/src/localesettings/localefiltermodel.cpp b/src/localesettings/localefiltermodel.cpp index 186a9c8..997a316 100644 --- a/src/localesettings/localefiltermodel.cpp +++ b/src/localesettings/localefiltermodel.cpp @@ -91,4 +91,13 @@ QVariant LocaleFilterModel::itemFromRow(const int row) const return QVariant(); } +int LocaleFilterModel::indexForCountry(const QString &country) const +{ + QAbstractItemModel *model = this->sourceModel(); + LocaleModel *localModel = qobject_cast<LocaleModel*>(model); + QModelIndex i = localModel->indexForCountry(country); + QModelIndex ret = mapFromSource(i); + return ret.row(); +} + QT_END_NAMESPACE diff --git a/src/localesettings/localefiltermodel.h b/src/localesettings/localefiltermodel.h index 3e768ea..1ddcb9c 100644 --- a/src/localesettings/localefiltermodel.h +++ b/src/localesettings/localefiltermodel.h @@ -45,6 +45,7 @@ public: QString filter() const; void setFilter(const QString& aFilter); Q_INVOKABLE QVariant itemFromRow(const int row) const; + Q_INVOKABLE int indexForCountry(const QString &country) const; Q_SIGNALS: void filterChanged(); private: diff --git a/src/localesettings/localemodel.cpp b/src/localesettings/localemodel.cpp index a5112ed..6925a02 100644 --- a/src/localesettings/localemodel.cpp +++ b/src/localesettings/localemodel.cpp @@ -84,6 +84,8 @@ void LocaleModel::modelReady() beginResetModel(); sort(0); endResetModel(); + + emit ready(); } void LocaleModel::generateModel(LocaleModel* model) @@ -160,4 +162,16 @@ void LocaleModel::sort(int column, Qt::SortOrder order) std::sort(m_items.begin(), m_items.end(), LocaleModel::variantLessThan); } +QModelIndex LocaleModel::indexForCountry(const QString &country) const +{ + for (int i = 0; i < m_items.count(); i++) { + LocaleItem *item = m_items.at(i); + if (item->country() == country || + item->language() == country) { + return index(i); + } + } + return QModelIndex(); +} + QT_END_NAMESPACE diff --git a/src/localesettings/localemodel.h b/src/localesettings/localemodel.h index 2dcbe87..fac0b94 100644 --- a/src/localesettings/localemodel.h +++ b/src/localesettings/localemodel.h @@ -67,6 +67,7 @@ public: QHash<int, QByteArray> roleNames() const; void sort(int column, Qt::SortOrder order=Qt::AscendingOrder); static bool variantLessThan(const LocaleItem* v1, const LocaleItem* v2); + QModelIndex indexForCountry(const QString &country) const; enum Roles { Language = Qt::UserRole + 1, @@ -78,6 +79,7 @@ public: Q_SIGNALS: void addItem(LocaleItem* item); + void ready(); private Q_SLOTS: void addNewItem(QObject* item); diff --git a/src/networksettings/connman/connmancommon.cpp b/src/networksettings/connman/connmancommon.cpp index ae57da8..887af48 100644 --- a/src/networksettings/connman/connmancommon.cpp +++ b/src/networksettings/connman/connmancommon.cpp @@ -55,6 +55,9 @@ const QString &operator>>(const QString &argument, QNetworkSettingsType &obj) else if (argument == AttributeWifi) { obj.setType(QNetworkSettingsType::Wifi); } + else if (argument == AttributeBluetooth) { + obj.setType(QNetworkSettingsType::Bluetooth); + } else { obj.setType(QNetworkSettingsType::Unknown); } diff --git a/src/networksettings/connman/connmancommon.h b/src/networksettings/connman/connmancommon.h index 9c6e53a..442730f 100644 --- a/src/networksettings/connman/connmancommon.h +++ b/src/networksettings/connman/connmancommon.h @@ -42,6 +42,7 @@ #define AttributeWifi QStringLiteral("wifi") #define AttributeEthernet QStringLiteral("ethernet") +#define AttributeBluetooth QStringLiteral("bluetooth") #define AttributeIdle QStringLiteral("idle") #define AttributeFailure QStringLiteral("failure") #define AttributeAssociation QStringLiteral("association") diff --git a/src/networksettings/connman/qnetworksettingsinterface_p.cpp b/src/networksettings/connman/qnetworksettingsinterface_p.cpp index 041dcca..5a64c15 100644 --- a/src/networksettings/connman/qnetworksettingsinterface_p.cpp +++ b/src/networksettings/connman/qnetworksettingsinterface_p.cpp @@ -97,7 +97,10 @@ void QNetworkSettingsInterfacePrivate::setPowered(const bool aPowered) void QNetworkSettingsInterfacePrivate::scan() { - m_technology->Scan(); + if (m_powered) + m_technology->Scan(); + else + qDebug() << "Tried to scan while not powered"; } QT_END_NAMESPACE diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.cpp b/src/networksettings/connman/qnetworksettingsmanager_p.cpp index a136237..b3373ee 100644 --- a/src/networksettings/connman/qnetworksettingsmanager_p.cpp +++ b/src/networksettings/connman/qnetworksettingsmanager_p.cpp @@ -81,12 +81,9 @@ QNetworkSettingsManagerPrivate::QNetworkSettingsManagerPrivate(QNetworkSettingsM void QNetworkSettingsManagerPrivate::requestInput(const QString& service, const QString& type) { + Q_UNUSED(service); Q_UNUSED(type); - foreach (QNetworkSettingsService* servicePtr, m_serviceModel->getModel()) { - if (servicePtr->id() == service) - emit servicePtr->showCrendentialInput(); - } - m_agent->showUserCredentialsInput(); + emit m_agent->showUserCredentialsInput(); } void QNetworkSettingsManagerPrivate::getServicesFinished(QDBusPendingCallWatcher *watcher) diff --git a/src/networksettings/connman/qnetworksettingsuseragent_p.cpp b/src/networksettings/connman/qnetworksettingsuseragent_p.cpp index 595092b..e9e8063 100644 --- a/src/networksettings/connman/qnetworksettingsuseragent_p.cpp +++ b/src/networksettings/connman/qnetworksettingsuseragent_p.cpp @@ -46,8 +46,14 @@ QNetworkSettingsUserAgentPrivate::QNetworkSettingsUserAgentPrivate(QNetworkSetti void QNetworkSettingsUserAgentPrivate::cancel() { // handle method call net.connman.Agent.Cancel + if (!m_pendingReply) + return; + m_pendingReply = false; - QMetaObject::invokeMethod(parent(), "Cancel"); + QDBusMessage errorMessage = m_pendingMessage.createErrorReply( + QStringLiteral("net.connman.Agent.Error.Canceled"), + QStringLiteral("")); + QDBusConnection::systemBus().send(errorMessage); } void QNetworkSettingsUserAgentPrivate::release() @@ -76,8 +82,9 @@ QVariantMap QNetworkSettingsUserAgentPrivate::RequestInput(const QDBusObjectPath Q_UNUSED(path); Q_UNUSED(params); msg.setDelayedReply(true); - m_reply = msg.createReply(); + m_pendingReply = true; + m_pendingMessage = msg; emit q->showUserCredentialsInput(); return QVariantMap(); } @@ -85,11 +92,16 @@ QVariantMap QNetworkSettingsUserAgentPrivate::RequestInput(const QDBusObjectPath void QNetworkSettingsUserAgentPrivate::setPassphrase(const QString& passphrase) { m_passphrase = passphrase; + if (!m_pendingReply) + return; + QVariantMap response; response[PropertyPassphrase] = m_passphrase; - m_reply << response; + + QDBusMessage reply = m_pendingMessage.createReply(); + reply << response; m_pendingReply = false; - QDBusConnection::systemBus().send(m_reply); + QDBusConnection::systemBus().send(reply); } QT_END_NAMESPACE diff --git a/src/networksettings/connman/qnetworksettingsuseragent_p.h b/src/networksettings/connman/qnetworksettingsuseragent_p.h index 6433918..180eea5 100644 --- a/src/networksettings/connman/qnetworksettingsuseragent_p.h +++ b/src/networksettings/connman/qnetworksettingsuseragent_p.h @@ -72,7 +72,7 @@ public Q_SLOTS: // Dbus methods void registerAgent(); private: QNetworkSettingsUserAgent *q_ptr; - QDBusMessage m_reply; + QDBusMessage m_pendingMessage; bool m_pendingReply; QString m_passphrase; }; diff --git a/src/networksettings/qnetworksettingsmanager.cpp b/src/networksettings/qnetworksettingsmanager.cpp index dafc0b1..71aa081 100644 --- a/src/networksettings/qnetworksettingsmanager.cpp +++ b/src/networksettings/qnetworksettingsmanager.cpp @@ -29,6 +29,7 @@ #include "qnetworksettingsmanager.h" #include "qnetworksettingsservice.h" #include "qnetworksettingsservicemodel.h" +#include "qnetworksettingsinterface.h" #include "qnetworksettingsinterfacemodel.h" #include "qnetworksettingsmanager_p.h" #include <QStringListModel> @@ -53,7 +54,7 @@ QNetworkSettingsInterfaceModel *QNetworkSettingsManager::interfaces() return d->interfaceModel(); } -QNetworkSettingsService* QNetworkSettingsManager::service(const QString& name, const int type) +QNetworkSettingsService* QNetworkSettingsManager::service(const QString& name, int type) { Q_D(QNetworkSettingsManager); @@ -62,7 +63,23 @@ QNetworkSettingsService* QNetworkSettingsManager::service(const QString& name, c return service; } } - return NULL; + return nullptr; +} + +QNetworkSettingsInterface* QNetworkSettingsManager::interface(int type, int instance) +{ + Q_D(QNetworkSettingsManager); + int matchingInstance = 0; + + foreach (QNetworkSettingsInterface* interface, d->m_interfaceModel.getModel()) { + if (interface->type() == type) { + if (matchingInstance == instance) { + return interface; + } + matchingInstance++; + } + } + return nullptr; } void QNetworkSettingsManager::setUserAgent(QNetworkSettingsUserAgent *agent) diff --git a/src/networksettings/qnetworksettingsmanager.h b/src/networksettings/qnetworksettingsmanager.h index 7e7cfad..3ce5095 100644 --- a/src/networksettings/qnetworksettingsmanager.h +++ b/src/networksettings/qnetworksettingsmanager.h @@ -38,6 +38,7 @@ QT_FORWARD_DECLARE_CLASS(QNetworkSettingsService) QT_FORWARD_DECLARE_CLASS(QNetworkSettingsServiceModel) QT_FORWARD_DECLARE_CLASS(QNetworkSettingsUserAgent) QT_FORWARD_DECLARE_CLASS(QNetworkSettingsServiceFilter) +QT_FORWARD_DECLARE_CLASS(QNetworkSettingsInterface) QT_FORWARD_DECLARE_CLASS(QNetworkSettingsInterfaceModel) QT_BEGIN_NAMESPACE @@ -57,7 +58,8 @@ public: void setUserAgent(QNetworkSettingsUserAgent *agent); QNetworkSettingsUserAgent* userAgent(); - Q_INVOKABLE QNetworkSettingsService* service(const QString& name, const int type); + Q_INVOKABLE QNetworkSettingsService* service(const QString& name, int type); + Q_INVOKABLE QNetworkSettingsInterface* interface(int type, int instance); Q_SIGNALS: void servicesChanged(); diff --git a/src/networksettings/qnetworksettingsservice.h b/src/networksettings/qnetworksettingsservice.h index 3019b2d..be24a5c 100644 --- a/src/networksettings/qnetworksettingsservice.h +++ b/src/networksettings/qnetworksettingsservice.h @@ -85,7 +85,6 @@ Q_SIGNALS: void domainsChanged(); void nameserversChanged(); void wirelessChanged(); - void showCrendentialInput(); protected: QNetworkSettingsServicePrivate *d_ptr; diff --git a/src/networksettings/qnetworksettingsservicemodel.cpp b/src/networksettings/qnetworksettingsservicemodel.cpp index 9c0b93d..3040dab 100644 --- a/src/networksettings/qnetworksettingsservicemodel.cpp +++ b/src/networksettings/qnetworksettingsservicemodel.cpp @@ -204,7 +204,7 @@ void QNetworkSettingsServiceModel::signalStrengthChanged() */ QNetworkSettingsServiceFilter::QNetworkSettingsServiceFilter(QObject* parent) - :QSortFilterProxyModel(parent) + :QSortFilterProxyModel(parent), m_type(QNetworkSettingsType::Unknown) { connect(this, &QNetworkSettingsServiceFilter::typeChanged, this, &QNetworkSettingsServiceFilter::invalidate); } @@ -244,7 +244,7 @@ bool QNetworkSettingsServiceFilter::filterAcceptsRow( int source_row, const QMod { QObject * obj = qvariant_cast<QObject *>(index.data(Qt::UserRole)); QNetworkSettingsService * service = qobject_cast<QNetworkSettingsService *>(obj); - if (service->type() == m_type) + if (service->type() == m_type || m_type == QNetworkSettingsType::Unknown) return true; } } diff --git a/src/settingsui/bluetooth/Bluetooth.qml b/src/settingsui/bluetooth/Bluetooth.qml index 72b4ae6..4c82904 100644 --- a/src/settingsui/bluetooth/Bluetooth.qml +++ b/src/settingsui/bluetooth/Bluetooth.qml @@ -30,56 +30,81 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.BluetoothSettings 1.0 +import "../common" Item { id: root - property string title: qsTr("Bluetooth Settings") - ColumnLayout { - anchors.margins: 20 - anchors.fill: parent - id: content - spacing: 20 + Row { + id: bluetoothRow + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + spacing: parent.width * 0.025 + + Text { + id: bluetoothSwitchText + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + color: "white" + text: qsTr("Bluetooth") + } + CustomSwitch { + anchors.verticalCenter: parent.verticalCenter + indicatorWidth: root.width * 0.15 + indicatorHeight: root.height * 0.06 - GroupBox { - id: groupBox - width: parent.width - title: qsTr("Bluetooth status") - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop enabled: BtDevice.available + checked: BtDevice.powered + onCheckedChanged: BtDevice.powered = checked + } - RowLayout { - spacing: 10 - Label { - id: off - text: qsTr("Off") - } - Switch { - checked: BtDevice.powered - onCheckedChanged: { - BtDevice.powered = checked - } - } + Text { + id: scanningText + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + color: "white" + text: "Scanning" + font.family: appFont + opacity: (BtDevice.scanning && BtDevice.powered) ? 1.0 : 0.0 + visible: opacity > 0 + Behavior on opacity { + NumberAnimation {duration: 150} + } - Connections { - target: BtDevice - onPoweredChanged: { - if (BtDevice.powered) - BtDevice.scanning = true - } - } + Timer { + id: scanningTimer + interval: 1000 + repeat: true + running: BtDevice.scanning - Label { - text: qsTr("On") + onTriggered: { + if (scanningText.text.indexOf("...") !== -1) + scanningText.text = "Scanning" + else + scanningText.text += "." } } } - Discovery { - id: discovery - visible: BtDevice.powered - Layout.fillWidth: true - Layout.fillHeight: true + + Connections { + target: BtDevice + onPoweredChanged: { + if (BtDevice.powered) + BtDevice.scanning = true + } } } + + Discovery { + id: discovery + anchors.top: bluetoothRow.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.bottomMargin: parent.height * 0.085 + visible: BtDevice.powered + } } diff --git a/src/settingsui/bluetooth/Discovery.qml b/src/settingsui/bluetooth/Discovery.qml index 1b3184a..515d37a 100644 --- a/src/settingsui/bluetooth/Discovery.qml +++ b/src/settingsui/bluetooth/Discovery.qml @@ -30,93 +30,109 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.BluetoothSettings 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: top - GroupBox { - id: groupBox - title: qsTr("Devices") + ListView { + id: mainList anchors.fill: parent + opacity: BtDevice.scanning ? .5 : 1.0 + interactive: !BtDevice.scanning + clip: true + model: BtDevice.deviceModel - ListView { - id: mainList - anchors.fill: parent - opacity: BtDevice.scanning ? .5 : 1.0 - interactive: !BtDevice.scanning - clip: true - model: BtDevice.deviceModel - - function getIcon(deviceType) { - switch (deviceType) { - case BtDeviceItem.Computer: - return "../icons/Laptop_qt_1x.png" - case BtDeviceItem.Headphones: - return "../icons/Headphones_qt_1x.png" - case BtDeviceItem.Microphone: - return "../icons/Microphone_qt_1x.png" - case BtDeviceItem.Mouse: - return "../icons/Mouse_qt_1x.png" - case BtDeviceItem.Keyboard: - return "../icons/Keyboard_qt_1x.png" - default: - return "../icons/Bluetooth_qt_1x.png" - } + function getIcon(deviceType) { + switch (deviceType) { + case BtDeviceItem.Computer: + return "../icons/Laptop_qt_1x.png" + case BtDeviceItem.Headphones: + return "../icons/Headphones_qt_1x.png" + case BtDeviceItem.Microphone: + return "../icons/Microphone_qt_1x.png" + case BtDeviceItem.Mouse: + return "../icons/Mouse_qt_1x.png" + case BtDeviceItem.Keyboard: + return "../icons/Keyboard_qt_1x.png" + default: + return "../icons/Bluetooth_qt_1x.png" } + } - delegate: Item { - id: btDelegate - width: parent.width - height: expanded || connected ? column.height + 10 : bttext.height + 10 - property bool expanded: false; - - MouseArea { - anchors.fill: parent - onClicked: { - if (!connected) - btDelegate.expanded = !btDelegate.expanded + delegate: Item { + id: btDelegate + width: parent.width + height: expanded || connected ? mainList.height * 0.175 + mainList.height * 0.05 : mainList.height * 0.175 + property bool expanded: false + MouseArea { + anchors.fill: parent + onClicked: { + if (!connected){ + btDelegate.expanded = !btDelegate.expanded } } - Image { - id: bticon - anchors.left: parent.left - anchors.top: parent.top - anchors.topMargin: 4 - source: mainList.getIcon(type) - } - Column { - id: column - anchors.left: bticon.right - anchors.leftMargin: 10 - anchors.right: connectButton.left - anchors.rightMargin: 10 - - Label { - id: bttext - text: name - } - Label { - id: details - opacity: btDelegate.expanded || connected ? 1 : 0.0 - text: address - Behavior on opacity { NumberAnimation { duration: 200} } - } + } + Image { + id: bticon + sourceSize.width: parent.width + sourceSize.height: parent.height + height: parent.height * 0.5 + width: height + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + source: mainList.getIcon(type) + } + Column { + anchors.left: bticon.right + anchors.leftMargin: parent.width * 0.025 + anchors.right: connectButton.left + anchors.verticalCenter: parent.verticalCenter + Label { + id: bttext + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + font.pixelSize: mainList.height * 0.06 + text: name + color: connected ? viewSettings.buttonGreenColor : "white" + font.family: appFont + font.styleName: connected ? "SemiBold" : "Regular" } - Button { - id: connectButton - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - visible: (expanded || connected) && !BtDevice.scanning - text: connected ? qsTr("Disconnect") : qsTr("Connect") - onClicked : connected ? BtDevice.requestDisconnect(address) : BtDevice.requestPairing(address); + Label { + id: details + height: btDelegate.height * 0.275 * opacity + opacity: btDelegate.expanded || connected ? 1 : 0.0 + visible: opacity > 0 + text: address + color: connected ? viewSettings.buttonGreenColor : "white" + font.family: appFont + Behavior on opacity { NumberAnimation { duration: 200} } } - Behavior on height { NumberAnimation { duration: 200} } } - focus: true + QtButton { + id: connectButton + height: mainList.height * 0.125 + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + opacity: (expanded || connected) && !BtDevice.scanning ? 1.0 : 0.0 + visible: opacity > 0 + fillColor: connected ? viewSettings.buttonGrayColor : viewSettings.buttonGreenColor + borderColor: "transparent" + text: connected ? qsTr("Disconnect") : qsTr("Connect") + onClicked : connected ? BtDevice.requestDisconnect(address) : BtDevice.requestPairing(address); + Behavior on opacity { NumberAnimation { duration: 200 } } + } + Behavior on height { NumberAnimation { duration: 200} } + + Rectangle { + id: delegateBottom + width: btDelegate.width + color: viewSettings.borderColor + height: 2 + anchors.bottom: btDelegate.bottom + anchors.horizontalCenter: btDelegate.horizontalCenter + } } - } - BusyIndicator { - anchors.centerIn: parent - running: BtDevice.scanning + focus: true } } diff --git a/src/settingsui/common/CustomSwitch.qml b/src/settingsui/common/CustomSwitch.qml new file mode 100644 index 0000000..fa9f9aa --- /dev/null +++ b/src/settingsui/common/CustomSwitch.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 +import QtQuick.Controls 2.1 + +Switch { + id: control + + property alias indicatorWidth: indicatorImg.width + property alias indicatorHeight: indicatorImg.height + + indicator: Image { + id: indicatorImg + width: 200 + height: 75 + sourceSize: Qt.size(width, height) + anchors.horizontalCenter: control.horizontalCenter + y: parent.height / 2 - height / 2 + source: "image://QtButton/10/#848895/transparent" + Text { + id: offText + anchors.left: parent.left + anchors.leftMargin: parent.width * 0.075 + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: parent.height * 0.55 + color: "#3b4155" + text: "OFF" + font.family: appFont + } + Text { + id: onText + anchors.right: parent.right + anchors.rightMargin: parent.width * 0.1 + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: parent.height * 0.55 + color: "#3b4155" + text: "ON" + font.family: appFont + } + + Binding { + target: qtHandle + property: "x" + value: control.checked ? indicatorImg.width - qtHandle.width - indicatorImg.width * 0.025 : indicatorImg.width * 0.025 + when: !mousearea.drag.active + } + + MouseArea { + anchors.fill: parent + onClicked: control.checked = !control.checked + } + + QtButton { + id: qtHandle + anchors.verticalCenter: parent.verticalCenter + width: parent.width * 0.475 + height: parent.height * 0.9 + fillColor: control.checked ? viewSettings.buttonGreenColor : viewSettings.buttonGrayColor + text: control.checked ? "ON" : "OFF" + borderColor: "transparent" + Behavior on x { + NumberAnimation { duration: 50 } + } + + MouseArea { + id: mousearea + anchors.fill: parent + drag.target: qtHandle + drag.axis: Drag.XAxis + drag.minimumX: indicatorImg.width * 0.005 + drag.maximumX: indicatorImg.width - width - indicatorImg.width * 0.005 + + onClicked: control.checked = !control.checked + + onReleased: { + if (qtHandle.x > indicatorImg.width / 5 ) { + control.checked = true + } else { + control.checked = false + } + } + } + } + } +} diff --git a/src/settingsui/common/CustomTableView.qml b/src/settingsui/common/CustomTableView.qml index 6b0505a..2eb42e4 100644 --- a/src/settingsui/common/CustomTableView.qml +++ b/src/settingsui/common/CustomTableView.qml @@ -32,56 +32,46 @@ import QtQuick.Controls 2.0 ColumnLayout { id: root - spacing: 0 + Layout.fillHeight: true Layout.fillWidth: true property var headerTexts: [] property var roleNames: [] property alias model: listView.model + property alias localeIndex: listView.currentIndex signal clicked(int index) - Rectangle { - height: 40 - Layout.fillWidth: true - color: "#80c342" - - Row { - anchors.fill: parent - anchors.leftMargin: 10 - spacing: 10 - - Repeater { - model: root.headerTexts.length - Text { - width: parent.width / root.headerTexts.length - text: root.headerTexts[index] - color: "white" - font.bold: true - anchors.verticalCenter: parent.verticalCenter - } - } - } + Timer { //A workaround to position the listView.. + interval: 250 + running: true + onTriggered: listView.positionViewAtIndex(listView.currentIndex, ListView.Beginning) } + ListView { id: listView Layout.fillHeight: true Layout.fillWidth: true clip: true - Rectangle { - anchors.fill: parent - border.color: "#bdbebf" - border.width: 1 - color: "transparent" + onCurrentIndexChanged: { + if (listView.model) { + positionViewAtIndex(listView.currentIndex, ListView.beginning) + } } - ScrollBar.vertical: ScrollBar {} + ScrollBar.vertical: ScrollBar { + contentItem: Rectangle { + implicitWidth: listView.width * 0.0175 + implicitHeight: listView.height * 0.5 + color: viewSettings.scrollBarColor + } + } - delegate: Rectangle { + delegate: Item { + id: delegateRectangle width: parent.width - height: 30 - color: index % 2 ? "#e3e3e3" : "white" + height: listView.height * 0.1 property var delegateData: modelData Row { @@ -96,9 +86,13 @@ ColumnLayout { width: parent.width / root.roleNames.length text: delegateData[root.roleNames[index]] anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: delegateRectangle.height * 0.5 antialiasing: false smooth: false renderType: listView.moving ? Text.NativeRendering : Text.QtRendering + color: listView.currentIndex == delegateRectangle.index ? viewSettings.buttonGreenColor : "white" + font.family: appFont } } } diff --git a/src/settingsui/display/Display.qml b/src/settingsui/display/Display.qml index 450ac41..ecb1e33 100644 --- a/src/settingsui/display/Display.qml +++ b/src/settingsui/display/Display.qml @@ -30,98 +30,153 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.DisplaySettings 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root - property string title: qsTr("Display Settings") - property int titleWidth: width * 0.382 + anchors.fill: parent - GroupBox { - title: qsTr("Display Settings") - anchors.margins: 20 - anchors.left: parent.left + Column { + spacing: pluginMain.spacing anchors.top: parent.top - anchors.right:parent.right - ColumnLayout { - anchors.fill: parent + Text { + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + text: qsTr("Brightness ") + (brightnessSlider.value / 255 * 100).toFixed(1) + "%" + color: "white" + height: pluginMain.fieldTextHeight + } - RowLayout { - width: parent.width - spacing: 10 + Slider { + id: brightnessSlider + width: root.width + height: pluginMain.buttonHeight + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + from: 0 + to: 255 + onValueChanged: DisplaySettings.setDisplayBrightness(value) - Label { - text: qsTr("Brightness:") - Layout.preferredWidth: root.titleWidth - Layout.alignment: Qt.AlignVCenter - horizontalAlignment: Text.AlignRight - } - Slider { - id: brightnessSlider - value: DisplaySettings.displayBrightness - Layout.alignment: Qt.AlignVCenter - Layout.fillWidth: true - from: 0 - to: 255 + background: Rectangle { + id: sliderBackground + x: brightnessSlider.leftPadding + y: brightnessSlider.topPadding + brightnessSlider.availableHeight / 2 - height / 2 + implicitWidth: root.width + implicitHeight: root.height * 0.01 + width: brightnessSlider.availableWidth + height: implicitHeight + radius: 2 + color: viewSettings.buttonGrayColor + Rectangle { + width: brightnessSlider.visualPosition * parent.width + height: parent.height + color: "white" + radius: 2 } } - Binding { - target: DisplaySettings - property: "displayBrightness" - value: brightnessSlider.position * brightnessSlider.to + handle: Rectangle { + x: brightnessSlider.leftPadding + brightnessSlider.visualPosition * (brightnessSlider.availableWidth - width) + y: brightnessSlider.topPadding + brightnessSlider.availableHeight / 2 - height / 2 + height: sliderBackground.height * 7 + width: height + radius: width * 0.5 + antialiasing: true + color: viewSettings.buttonGreenColor } - GridLayout { - columns: 2 - rows: 3 - rowSpacing: 10 - Label { - text: qsTr("Physical screen size:") - Layout.preferredWidth: root.titleWidth - Layout.alignment: Qt.AlignVCenter - horizontalAlignment: Text.AlignRight - wrapMode: Label.WordWrap + Component.onCompleted: brightnessSlider.value = DisplaySettings.displayBrightness + } + + Text { + verticalAlignment: Text.AlignVCenter + height: pluginMain.fieldTextHeight + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + text: qsTr("Physical screen size") + Layout.preferredWidth: root.width * 0.3 + Layout.alignment: Qt.AlignVCenter + wrapMode: Label.WordWrap + color: "white" + } + + Column { + leftPadding: pluginMain.margin + spacing: pluginMain.spacing + + Row { + spacing: pluginMain.spacing + + Text { + id: widthText + height: pluginMain.buttonHeight + text: qsTr("Width") + color: "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + verticalAlignment: Text.AlignVCenter + } + TextField { + id: widthField + height: pluginMain.buttonHeight + width: root.width * 0.13 + color: "black" + font.pixelSize: pluginMain.valueFontSize + text: DisplaySettings.physicalScreenWidthMm + horizontalAlignment: Text.AlignHCenter + inputMethodHints: Qt.ImhDigitsOnly + background: Rectangle { + border.color: widthField.focus ? viewSettings.buttonGreenColor : "transparent" + border.width: parent.width * 0.05 + } } - RadioButton { - text: qsTr("Default") - checked: !DisplaySettings.physicalScreenSizeOverride + Text { + id: heightText + height: pluginMain.buttonHeight + text: qsTr("Height") + color: "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + verticalAlignment: Text.AlignVCenter } - RadioButton { - id: custom - Layout.column: 1 - Layout.row: 1 - text: qsTr("Custom") - checked: DisplaySettings.physicalScreenSizeOverride - onCheckedChanged: DisplaySettings.physicalScreenSizeOverride = checked + TextField { + id: heightField + width: widthField.width + height: pluginMain.buttonHeight + color: "black" + font.pixelSize: pluginMain.valueFontSize + text: DisplaySettings.physicalScreenHeightMm + horizontalAlignment: Text.AlignHCenter + inputMethodHints: Qt.ImhDigitsOnly + background: Rectangle { + border.color: heightField.focus ? viewSettings.buttonGreenColor : "transparent" + border.width: parent.width * 0.05 + } } - GroupBox { - title: qsTr("Size (in inches): %1").arg(DisplaySettings.physicalScreenSizeInch) - Layout.column: 1 - Layout.row: 2 - Layout.fillWidth: true - visible: custom.checked + } - RowLayout { - spacing: 10 - width: parent.width + Row { + spacing: pluginMain.margin - Label { - text: sizeSlider.from - Layout.alignment: Qt.AlignVCenter - } - Slider { - id: sizeSlider - value: DisplaySettings.physicalScreenSizeInch - Layout.fillWidth: true - stepSize: 1 - from: 4 - to: 60 - onPositionChanged: DisplaySettings.physicalScreenSizeInch = sizeSlider.from + Math.floor(sizeSlider.position * (sizeSlider.to - sizeSlider.from)) - } - Label { - text: sizeSlider.to - Layout.alignment: Qt.AlignVCenter | Qt.AlignRight - } + QtButton { + id: setButton + height: pluginMain.buttonHeight + text: qsTr("SET") + onClicked: { + DisplaySettings.physicalScreenHeightMm = parseInt(heightField.text) + DisplaySettings.physicalScreenWidthMm = parseInt(widthField.text) + } + } + QtButton { + id: resetButton + height: pluginMain.buttonHeight + borderColor: "transparent" + fillColor: viewSettings.buttonGrayColor + text: qsTr("RESET TO DEFAULT") + onClicked: { + DisplaySettings.physicalScreenHeightMm = 90 + DisplaySettings.physicalScreenWidthMm = 154 } } } diff --git a/src/settingsui/locale/Language.qml b/src/settingsui/locale/Language.qml index d4257c3..47a4fdf 100644 --- a/src/settingsui/locale/Language.qml +++ b/src/settingsui/locale/Language.qml @@ -31,59 +31,84 @@ import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.LocaleSettings 1.0 import QtQml 2.2 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root - property string title: qsTr("Language and Region") + // QTBUG-63598: property var currentRegion: Qt.locale(LocaleManager.locale) + property var currentRegion: Qt.locale("en_EN") - GroupBox { - id: groupBox - title: qsTr("Regional Format") - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: 20 - property var currentRegion: Qt.locale(LocaleManager.locale) + Column { + spacing: pluginMain.spacing - ColumnLayout { - width: parent.width + Text { + color: "white" + text: qsTr("Region") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - Component { - id: regionSelect - RegionSelect {} + Row { + leftPadding: pluginMain.margin + spacing: pluginMain.spacing + Text { + color: "white" + text: root.currentRegion.nativeCountryName == "" ? "Default" : root.currentRegion.nativeCountryName + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + verticalAlignment: Text.AlignVCenter + height: parent.height + } + QtButton { + id: regionButton + height: pluginMain.buttonHeight + text: qsTr("CHANGE") + onClicked: settingsLoader.source = "qrc:/locale/RegionSelect.qml" } - 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"); - } - } - ColumnLayout { - spacing: 10 - Layout.fillWidth: true - width: parent.width + } + + Text { + color: "white" + text: qsTr("Format") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } + + Grid { + columns: 2 + leftPadding: pluginMain.margin + spacing: pluginMain.spacing - Label { - text: Date().toLocaleString(groupBox.currentRegion) - } - Label { - text: Number(2343.34).toLocaleString(groupBox.currentRegion) - } - Label { - text: Number(41334.34).toLocaleCurrencyString(groupBox.currentRegion) - } - } + TableKey { + text: qsTr("Region") + } + TableValue { + text: root.currentRegion.nativeCountryName + } + + TableKey { + text: qsTr("Short date:") + } + TableValue { + text: root.currentRegion.dateFormat(1) + } + TableKey { + text: qsTr("Short time:") + } + TableValue { + text: root.currentRegion.timeFormat(1) + } + TableKey { + text: qsTr("Currency:") + } + TableValue { + text: root.currentRegion.currencySymbol(1) + } + TableKey { + text: qsTr("First day of week:") } - Button { - text: qsTr("Change region") - onClicked: stackView.push(regionSelect) + TableValue { + text: root.currentRegion.firstDayOfWeek } } } diff --git a/src/settingsui/locale/RegionSelect.qml b/src/settingsui/locale/RegionSelect.qml index 89042b6..148db0e 100644 --- a/src/settingsui/locale/RegionSelect.qml +++ b/src/settingsui/locale/RegionSelect.qml @@ -31,33 +31,107 @@ import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.LocaleSettings 1.0 import "../common" +import QtGraphicalEffects 1.0 Item { id: root - property string title: qsTr("Select language") + // QTBUG-63598: property var currentRegion: Qt.locale(LocaleManager.locale) + property var currentRegion: Qt.locale("en_EN") - Component.onCompleted: country.text = LocaleFilter.filter + Row { + id: backRow + anchors.top: parent.top + anchors.left: parent.left + width: parent.width * 0.2 + height: parent.height * 0.04 + Image { + id: languageBackIcon + anchors.verticalCenter: parent.verticalCenter + height: parent.height * 0.8 + width: height + fillMode: Image.PreserveAspectFit + source: "../newIcons/back_icon.svg" + + ColorOverlay { + source: languageBackIcon + anchors.fill: languageBackIcon + color: viewSettings.buttonGreenColor + visible: true + } + MouseArea { + anchors.fill: parent + onClicked: settingsLoader.source = "qrc:/locale/Language.qml" + } + } + Text { + anchors.top: parent.top + height: parent.height + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.subTitleFontSize + color: viewSettings.buttonGreenColor + text: "Back" + font.family: appFont + MouseArea { + anchors.fill: parent + onClicked: settingsLoader.source = "qrc:/locale/Language.qml" + } + } + } + + Text { + id: changeLanguageText + anchors.top: backRow.bottom + anchors.topMargin: parent.height * 0.05 + anchors.left: parent.left + font.pixelSize: pluginMain.subTitleFontSize + color: "white" + text: qsTr("Change Language") + font.family: appFont + font.styleName: "Bold" + } + Rectangle { + id: btmLine + anchors.top: changeLanguageText.bottom + anchors.topMargin: parent.height * 0.025 + anchors.left: changeLanguageText.left + width: parent.width * 0.275 + height: parent.height * 0.005 + } ColumnLayout { id: content - anchors.fill: parent - anchors.margins: 20 - spacing: 10 + anchors.top: btmLine.bottom + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.topMargin: parent.height * 0.025 RowLayout { spacing: 10 - - Label { - text: qsTr("Search region: ") - Layout.alignment: Qt.AlignVCenter - } + Layout.fillHeight: false + Layout.preferredHeight: root.height * 0.075 TextField { id: country + Layout.fillHeight: true + Layout.preferredWidth: root.width * 0.5 + font.pixelSize: pluginMain.valueFontSize + color: "white" text: "" + placeholderText: "Search..." + font.family: appFont + font.styleName: "Light" onTextChanged: LocaleFilter.filter = country.text Layout.alignment: Qt.AlignVCenter + background: Rectangle { + color: "transparent" + border.color: viewSettings.borderColor + border.width: 2 + } } } + CustomTableView { + id: localeTableView headerTexts: [qsTr("Language"), qsTr("Country")] roleNames: ["language", "country"] model: LocaleFilter @@ -65,9 +139,22 @@ Item { var val = model.itemFromRow(index); if (val !== "") { LocaleManager.locale = val; - stackView.pop(); + settingsLoader.source = "qrc:/locale/Language.qml" } } } } + Component.onCompleted: { + country.text = LocaleFilter.filter + var n = LocaleFilter.indexForCountry(root.currentRegion.nativeCountryName) + localeTableView.localeIndex = n + } + + Connections { + target: LocaleFilter.sourceModel + onReady: { + var n = LocaleFilter.indexForCountry(root.currentRegion.nativeCountryName) + localeTableView.localeIndex = n + } + } } diff --git a/src/settingsui/locale/TableKey.qml b/src/settingsui/locale/TableKey.qml new file mode 100644 index 0000000..523f0dd --- /dev/null +++ b/src/settingsui/locale/TableKey.qml @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Text { + color: "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont +} diff --git a/src/settingsui/locale/TableValue.qml b/src/settingsui/locale/TableValue.qml new file mode 100644 index 0000000..523f0dd --- /dev/null +++ b/src/settingsui/locale/TableValue.qml @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Text { + color: "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont +} diff --git a/src/settingsui/network/NetworkListView.qml b/src/settingsui/network/NetworkListView.qml new file mode 100644 index 0000000..cbad890 --- /dev/null +++ b/src/settingsui/network/NetworkListView.qml @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQml 2.0 +import QtDeviceUtilities.NetworkSettings 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 +import QtQuick.Controls 2.1 + +ListView { + id: list + clip: true + property var connectingService: null + property bool retryConnectAfterIdle: false + + Component.onCompleted: NetworkSettingsManager.services.type = NetworkSettingsType.Unknown; + model: NetworkSettingsManager.services + + delegate: Item { + id: networkDelegate + width: list.width + height: list.height * 0.15 + Column { + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + width: parent.width * 0.5 + Text { + id: networkName + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + color: connected ? viewSettings.buttonGreenColor : "white" + text: name + } + Row { + id: ipRow + height: networkDelegate.height * 0.275 * opacity + spacing: networkDelegate.width * 0.0075 + Item { + width: pluginMain.margin + height: 1 + } + Text { + id: ipAddressLabel + height: parent.height + anchors.verticalCenter: parent.verticalCenter + text: qsTr("IP Address:") + color: connected ? viewSettings.buttonGreenColor : "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + } + Text { + id: ipAddress + width: root.width * 0.15 + height: parent.height + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + color: connected ? viewSettings.buttonGreenColor : "white" + text: connected ? NetworkSettingsManager.services.itemFromRow(index).ipv4.address + : (NetworkSettingsManager.services.itemFromRow(index).state === NetworkSettingsState.Idle) ? + qsTr("Not connected") : qsTr("Connecting") + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: connected ? "SemiBold" : "Regular" + } + } + } + QtButton { + id: connectButton + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + fillColor: connected ? viewSettings.buttonGrayColor : viewSettings.buttonGreenColor + borderColor: "transparent" + text: connected ? qsTr("DISCONNECT") : qsTr("CONNECT") + height: pluginMain.buttonHeight + onClicked: { + if (connected) { + NetworkSettingsManager.services.itemFromRow(index).disconnectService(); + } else { + list.connectingService = NetworkSettingsManager.services.itemFromRow(index) + if (list.connectingService) { + passphraseEnter.extraInfo = ""; + list.connectingService.connectService(); + list.connectingService.stateChanged.connect(connectingServiceStateChange); + } + } + } + } + Rectangle { + id: delegateBottom + width: networkDelegate.width + color: viewSettings.borderColor + height: 2 + anchors.bottom: networkDelegate.bottom + anchors.horizontalCenter: networkDelegate.horizontalCenter + } + Behavior on height { NumberAnimation { duration: 200} } + + } + + Connections { + target: NetworkSettingsManager.userAgent + onShowUserCredentialsInput : { + passphraseEnter.visible = true; + } + } + + // Popup for entering passphrase + PassphraseEnter { + id: passphraseEnter + parent: root + visible: false + } + + function connectingServiceStateChange() { + if (connectingService !== null) { + if (connectingService.state === NetworkSettingsState.Failure) { + // If authentication failed, request connection again. That will + // initiate new passphrase request. + retryConnectAfterIdle = true + } else if (connectingService.state === NetworkSettingsState.Ready) { + // If connection succeeded, we no longer have service connecting + connectingService = null; + retryConnectAfterIdle = false; + } else if (connectingService.state === NetworkSettingsState.Idle) { + if (retryConnectAfterIdle) { + passphraseEnter.extraInfo = qsTr("Invalid passphrase"); + connectingService.connectService(); + } + retryConnectAfterIdle = false; + } + } + } + + focus: true +} diff --git a/src/settingsui/network/NetworkSettings.qml b/src/settingsui/network/NetworkSettings.qml index bb09954..c357671 100644 --- a/src/settingsui/network/NetworkSettings.qml +++ b/src/settingsui/network/NetworkSettings.qml @@ -28,104 +28,80 @@ ****************************************************************************/ import QtQuick 2.6 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.2 import QtDeviceUtilities.NetworkSettings 1.0 +import "../common" Item { + id: root property string title: qsTr("Network Settings") - GroupBox { - id: networkSelect - anchors.rightMargin: parent.width * 0.618 - anchors.left: parent.left - anchors.leftMargin: 20 - anchors.top: parent.top - anchors.topMargin: 20 + Column { + id: networkSettingsColumn + spacing: pluginMain.spacing + anchors.margins: viewSettings.pageMargin - title: qsTr("Select Connection") - - function stateToStr(serviceState) { - switch (serviceState) { - case NetworkService.Idle: - return qsTr("Idle"); - case NetworkService.Failure: - return qsTr("Failure"); - case NetworkService.Association: - return qsTr("Association"); - case NetworkService.Configuration: - return qsTr("Configuration"); - case NetworkService.Ready: - return qsTr("Ready"); - case NetworkService.Disconnect: - return qsTr("Disconnect"); - case NetworkService.Online: - return qsTr("Online"); - default: - return qsTr("Undefined"); + Row { + spacing: root.width * 0.025 + leftPadding: pluginMain.margin + Text { + text: qsTr("Wi-Fi") + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + color: "white" } - } - ColumnLayout { - width: parent.width - - Repeater { - model: NetworkSettingsManager.interfaces - - RadioButton { - id: btn - enabled: (type != NetworkSettingsType.Wired) || NetworkSettingsManager.services.wiredNetworksAvailable - Layout.fillWidth: true - implicitHeight: 54 - indicator: Item {} - contentItem: Rectangle { - color: checked ? "#80c342" : "white" - border.color: "#bdbebf" - border.width: 1 - anchors.fill: parent - - Column { - height: parent.height * .7 - width: parent.width - spacing: 0 - anchors.verticalCenter: parent.verticalCenter - Label { - width: parent.width - horizontalAlignment: Text.AlignHCenter - text: name - } - Label { - width: parent.width - horizontalAlignment: Text.AlignHCenter - text: ((type == NetworkSettingsType.Wired) && !NetworkSettingsManager.services.wiredNetworksAvailable) ? - qsTr("No networks") : networkSelect.stateToStr(modelData.state) - font.pixelSize: 12 - } - } + CustomSwitch { + id: wifiSwitch + indicatorWidth: root.width * 0.15 + indicatorHeight: root.height * 0.06 + property bool wiFiAvailable: NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0) !== null + enabled: wiFiAvailable && !wifiSwitchTimer.running + onCheckedChanged: { + // Power on/off all WiFi interfaces + for (var i = 0; NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i) !== null; i++) { + NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i).powered = checked + wifiSwitchTimer.start() } - - onCheckedChanged: { - if (checked) { - networkDetails.selectedInterface = modelData - networkDetails.selectedInterface.scanServices() - if (type === NetworkSettingsType.Wired) { - networkDetails.source = "WiredSettings.qml"; - } - else if (type === NetworkSettingsType.Wifi) { - networkDetails.source = "WifiSettings.qml"; - } + } + Component.onCompleted: { + // If any of the WiFi interfaces is powered on, switch is checked + var checkedStatus = false; + for (var i = 0; NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i) !== null; i++) { + if (NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i).powered) { + checkedStatus = true; + break; } } + checked = checkedStatus; + } + + // At least 1s between switching on/off + Timer { + id: wifiSwitchTimer + interval: 1000 + running: false } } } - } - NetworkDetails { - id: networkDetails - anchors.leftMargin: networkSelect.width + 40 - anchors.topMargin: 20 - anchors.rightMargin: 20 - anchors.bottomMargin: 20 - anchors.fill: parent + Text { + text: qsTr("Network list:") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + font.styleName: "SemiBold" + color: "white" + } + + Row { + id: listViewRow + leftPadding: pluginMain.margin + NetworkListView { + id: networkList + width: root.width - listViewRow.leftPadding + height: root.height - listViewRow.y - networkSettingsColumn.anchors.margins + } + } } } diff --git a/src/settingsui/network/PassphraseEnter.qml b/src/settingsui/network/PassphraseEnter.qml new file mode 100644 index 0000000..1881866 --- /dev/null +++ b/src/settingsui/network/PassphraseEnter.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 +import QtDeviceUtilities.NetworkSettings 1.0 + +Rectangle { + id: passphrasePopup + width: root.width + height: root.height + color: viewSettings.backgroundColor + opacity: 0.9 + property string extraInfo: "" + + Rectangle { + id: frame + color: viewSettings.backgroundColor + border.color: viewSettings.borderColor + border.width: 3 + anchors.centerIn: parent + width: passphraseColumn.width * 1.1 + height: passphraseColumn.height * 1.1 + + Column { + id: passphraseColumn + anchors.centerIn: parent + spacing: viewSettings.spacing + + Text { + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + color: "white" + text: qsTr("Enter Passphrase") + } + + Text { + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + color: "red" + text: extraInfo + visible: (extraInfo !== "") + } + + TextField { + id: passField + width: root.width * 0.4 + height: root.height * 0.075 + color: "white" + echoMode: TextInput.Password + background: Rectangle{ + color: "transparent" + border.color: passField.focus ? viewSettings.buttonGreenColor : viewSettings.buttonGrayColor + border.width: passField.focus ? width * 0.01 : 2 + } + } + + Row { + spacing: parent.width * 0.025 + QtButton{ + id: setButton + text: qsTr("SET") + onClicked: { + NetworkSettingsManager.userAgent.setPassphrase(passField.text) + passphrasePopup.visible = false; + } + } + QtButton { + id: cancelButton + text: qsTr("CANCEL") + borderColor: "transparent" + fillColor: viewSettings.buttonGrayColor + onClicked: { + NetworkSettingsManager.userAgent.cancelInput() + passphrasePopup.visible = false; + } + } + } + } + } +} diff --git a/src/settingsui/power/Power.qml b/src/settingsui/power/Power.qml new file mode 100644 index 0000000..1bcc658 --- /dev/null +++ b/src/settingsui/power/Power.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Controls 2.1 +import QtDeviceUtilities.QtButtonImageProvider 1.0 + +Item { + id: root + + Column { + anchors.top: parent.top + spacing: pluginMain.margin + + QtButton { + id: shutdownButton + width: root.width * 0.4 + height: pluginMain.fieldHeight + text: qsTr("SHUTDOWN") + onClicked: shutdownPopup.open(true) + } + QtButton { + id: rebootButton + width: root.width * 0.4 + height: pluginMain.fieldHeight + text: qsTr("REBOOT") + onClicked: shutdownPopup.open(false) + } + } +} diff --git a/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml b/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml new file mode 100644 index 0000000..6fb61f4 --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Image { + id: root + source: "image://QtButton/" + cutSize + "/" + fillColor + "/" + borderColor + sourceSize: Qt.size(width, height) + property string state: "enabled" + property int cutSize: 10 + property color fillColor: viewSettings.buttonGreenColor + property color borderColor: mouseArea.pressed ? viewSettings.buttonActiveColor : viewSettings.buttonGreenColor + property alias text: buttonText.text + signal clicked() + + width: buttonText.contentWidth + cutSize * 4 + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: root.clicked() + } + Text { + id: buttonText + anchors.fill: parent + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: parent.height * 0.65 + font.family: appFont + color: "white" + } +} diff --git a/src/settingsui/qtbuttonimageproviderplugin/plugin.qrc b/src/settingsui/qtbuttonimageproviderplugin/plugin.qrc new file mode 100644 index 0000000..b3b680c --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/plugin.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>QtButton.qml</file> + </qresource> +</RCC> diff --git a/src/settingsui/qtbuttonimageproviderplugin/qmldir b/src/settingsui/qtbuttonimageproviderplugin/qmldir new file mode 100644 index 0000000..5567d74 --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/qmldir @@ -0,0 +1,2 @@ +module QtDeviceUtilities.QtButtonImageProvider +plugin qtbuttonimageproviderplugin diff --git a/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp new file mode 100644 index 0000000..3879d9b --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QQmlExtensionPlugin> +#include <QQmlEngine> +#include <QQuickImageProvider> +#include <QImage> +#include <QPainter> + +class QtButtonImageProvider : public QQuickImageProvider +{ +public: + QtButtonImageProvider() + : QQuickImageProvider(QQuickImageProvider::Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) + { + bool ok = false; + + QStringList params = id.split("/"); + + int cutSize = params.at(0).toInt(&ok); + + if (!ok) + cutSize = 10; + + QColor fillColor; + QColor borderColor; + + if (params.length() > 1) { + fillColor = QColor(params.at(1)); + } + + if (params.length() > 2) + borderColor = QColor(params.at(2)); + + if (!fillColor.isValid()) + fillColor = "#00eb00"; + + if (!borderColor.isValid()) + borderColor ="white"; + + int width = 100; + int height = 50; + + if (size) + *size = QSize(requestedSize.width(), requestedSize.height()); + + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, + requestedSize.height() > 0 ? requestedSize.height() : height); + pixmap.fill(Qt::transparent); + + QPainter painter(&pixmap); + const qreal borderPenWidth = 2; + QPen borderPen(QBrush(borderColor), borderPenWidth); + borderPen.setJoinStyle(Qt::MiterJoin); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(borderPen); + painter.setBrush(fillColor); + + QPainterPath path; + qreal top = borderPenWidth - 1; + qreal left = borderPenWidth - 1; + qreal bottom = pixmap.height() - borderPenWidth; + qreal right = pixmap.width() - borderPenWidth; + path.moveTo(left + cutSize, top); + path.lineTo(right, top); + path.lineTo(right, bottom - cutSize); + path.lineTo(right - cutSize, bottom); + path.lineTo(left, bottom); + path.lineTo(left, top + cutSize); + path.lineTo(left + cutSize, top); + painter.drawPath(path); + + return pixmap; + } +}; + +class ImageProviderExtensionPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + void registerTypes(const char *uri) + { + Q_UNUSED(uri) + Q_ASSERT(uri == QLatin1String("QtDeviceUtilities.QtButtonImageProvider")); + qmlRegisterType(QUrl("qrc:/QtButton.qml"), uri, 1, 0, "QtButton"); + } + + void initializeEngine(QQmlEngine *engine, const char *uri) + { + Q_UNUSED(uri); + QtButtonImageProvider *provider = new QtButtonImageProvider(); + engine->addImageProvider("QtButton", provider); + } +}; + +#include "qtbuttonimageprovider.moc" diff --git a/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.h b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.h new file mode 100644 index 0000000..8fe7cdc --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QTBUTTONIMAGEPROVIDER_H +#define QTBUTTONIMAGEPROVIDER_H + +#include <QQuickImageProvider> +#include <QPixmap> + +class QtButtonImageProvider : public QQuickImageProvider +{ +public: + QtButtonImageProvider(); + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); + + void setCutSize(int size) { m_cutSize = size; } +private: + int m_cutSize; +}; + +#endif // QTBUTTONIMAGEPROVIDER_H diff --git a/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageproviderplugin.pro b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageproviderplugin.pro new file mode 100644 index 0000000..8383a75 --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageproviderplugin.pro @@ -0,0 +1,16 @@ +QT += qml quick +CONFIG += no_cxx_module + +TARGET = qtbuttonimageproviderplugin +TARGETPATH = QtDeviceUtilities/QtButtonImageProvider + +SOURCES += \ + qtbuttonimageprovider.cpp + +HEADERS += \ + qtbuttonimageprovider.h + +RESOURCES += \ + plugin.qrc + +load(qml_plugin) diff --git a/src/settingsui/settingsuiapp.qrc b/src/settingsui/settingsuiapp.qrc index 58687e0..a3e7ca5 100644 --- a/src/settingsui/settingsuiapp.qrc +++ b/src/settingsui/settingsuiapp.qrc @@ -3,5 +3,34 @@ <file>main.qml</file> <file>common/HandwritingModeButton.qml</file> <file>AutoScroller.qml</file> + <file>power/Power.qml</file> + <file>timedate/ManualTime.qml</file> + <file>timedate/CustomComboBox.qml</file> + <file>common/CustomSwitch.qml</file> + <file>network/PassphraseEnter.qml</file> + <file>locale/TableKey.qml</file> + <file>locale/TableValue.qml</file> + <file>display/Display.qml</file> + <file>locale/Language.qml</file> + <file>locale/RegionSelect.qml</file> + <file>network/AddressListEntry.qml</file> + <file>network/ComboBoxEntry.qml</file> + <file>network/EditWiredSettings.qml</file> + <file>network/IpAddressTextField.qml</file> + <file>network/NetworkDetails.qml</file> + <file>network/NetworkListView.qml</file> + <file>network/NetworkSettings.qml</file> + <file>network/WifiSelectorDelegate.qml</file> + <file>network/WifiSettings.qml</file> + <file>network/WifiSignalMonitor.qml</file> + <file>network/WiredSettings.qml</file> + <file>settingsuiplugin/pluginMain.qml</file> + <file>settingsuiplugin/SettingsDelegate.qml</file> + <file>settingsuiplugin/SettingsHeader.qml</file> + <file>settingsuiplugin/SettingsTitleItem.qml</file> + <file>settingsuiplugin/ShutdownPopup.qml</file> + <file>bluetooth/Bluetooth.qml</file> + <file>bluetooth/Discovery.qml</file> + <file>timedate/TimeDate.qml</file> </qresource> </RCC> diff --git a/src/settingsui/settingsuiplugin/SettingsDelegate.qml b/src/settingsui/settingsuiplugin/SettingsDelegate.qml new file mode 100644 index 0000000..91f4ca4 --- /dev/null +++ b/src/settingsui/settingsuiplugin/SettingsDelegate.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +Item { + width: settingsList.width + height: settingsList.height * 0.08 + + property bool isSelected: settingsList.currentIndex == index + + Image { + id: img + sourceSize.width: parent.width + sourceSize.height: parent.height + source: icon + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: parent.width * 0.075 + height: Math.min(parent.width * 0.5, parent.height * 0.6) + width: height + fillMode: Image.PreserveAspectFit + visible: parent.isSelected ? false : true + } + ColorOverlay { + source: img + anchors.fill: img + visible: parent.isSelected ? true : false + color: viewSettings.buttonGreenColor + } + + Text { + text: title + height: parent.height * 0.75 + anchors.right: parent.right + anchors.left: img.right + anchors.leftMargin: parent.width * 0.025 + anchors.verticalCenter: parent.verticalCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: Math.min(parent.width * 0.25, parent.height) + color: parent.isSelected ? viewSettings.buttonGreenColor : "white" + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + font.family: appFont + font.styleName: parent.isSelected ? "Bold" : "Regular" + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + settingsList.currentIndex = index + settingsLoader.source = path + '/' + view + '.qml' + titleItem.title = title + } + } + + Component.onCompleted: pluginMain.init() +} diff --git a/src/settingsui/settingsuiplugin/SettingsHeader.qml b/src/settingsui/settingsuiplugin/SettingsHeader.qml new file mode 100644 index 0000000..9432789 --- /dev/null +++ b/src/settingsui/settingsuiplugin/SettingsHeader.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDeviceUtilities.NetworkSettings 1.0 + +Item { + id: header + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: pluginMain.margin + height: pluginMain.margin * 4 + + signal clicked() + + function refreshIP() { + var networkCount = NetworkSettingsManager.services.sourceModel.rowCount(); + var ipAddress = "Not Found"; + for (var i = 0; i < networkCount; ++i) { + var networkService = NetworkSettingsManager.services.itemFromRow(i); + var tmp = NetworkSettingsManager.services.itemFromRow(i).ipv4.address; + if (tmp !== "" && ipAddress === "Not Found") + ipAddress = tmp; + + if (networkService.type === NetworkSettingsType.Wired && + (networkService.status === NetworkSettingsState.Ready || + networkService.status === NetworkSettingsState.Online)) { + break; + } + } + ipItem.text = qsTr("Device IP: ") + ipAddress; + } + + Image { + id: backButton + anchors.left: parent.left + anchors.top: parent.top + source: "../newIcons/back_icon.svg" + height: parent.height * 0.5 + width: height / sourceSize.height * sourceSize.width + MouseArea { + anchors.fill: parent + anchors.margins: -parent.height * 0.2 + onClicked: header.clicked() + } + } + + Text { + id: settingsText + anchors.left: backButton.right + anchors.verticalCenter: backButton.verticalCenter + font.pixelSize: parent.height * 0.45 + text: qsTr("Settings") + color: "white" + font.family: appFont + font.styleName: "SemiBold" + MouseArea { + anchors.fill: parent + anchors.margins: -parent.height * 0.2 + onClicked: header.clicked() + } + } + + Text { + id: ipItem + width: parent.width * 0.25 + height: parent.height + anchors.verticalCenter: settingsText.verticalCenter + anchors.right: parent.right + anchors.rightMargin: pluginMain.margin + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: parent.height * 0.3 + color: "white" + font.family: appFont + font.styleName: "SemiBold" + text: qsTr("Device IP: ") + + MouseArea { + anchors.fill: parent + onClicked: header.refreshIP() + } + } + + Component.onCompleted: { + var networkCount = NetworkSettingsManager.services.sourceModel.rowCount(); + for (var i = 0; i < networkCount; ++i) { + NetworkSettingsManager.services.itemFromRow(i).ipv4Changed.connect(refreshIP); + } + header.refreshIP() + } +} diff --git a/src/settingsui/settingsuiplugin/SettingsTitleItem.qml b/src/settingsui/settingsuiplugin/SettingsTitleItem.qml new file mode 100644 index 0000000..0ead0c6 --- /dev/null +++ b/src/settingsui/settingsuiplugin/SettingsTitleItem.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Column { + id: page + spacing: pluginMain.spacing + + property alias title: displayText.text + + Text { + id: displayText + font.pixelSize: pluginMain.titleFontSize + color: "white" + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.family: appFont + font.styleName: "Bold" + } + + Rectangle { + id: btmLine + width: page.parent.width * 0.3 + height: 3 + } + + Item { + height: pluginMain.margin + width: 1 + } +} diff --git a/src/settingsui/settingsuiplugin/ShutdownPopup.qml b/src/settingsui/settingsuiplugin/ShutdownPopup.qml new file mode 100644 index 0000000..4ae9480 --- /dev/null +++ b/src/settingsui/settingsuiplugin/ShutdownPopup.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 + +Rectangle { + id: shutdownPopup + width: parent.width + height: parent.height + color: viewSettings.backgroundColor + opacity: 0.9 + + signal accepted() + property bool shutdown: false + + function open(sd) + { + shutdown = sd + if (sd) { + shutDownConfirmText.text = qsTr("Shut down the system?") + shutDownConfirm.text = qsTr("SHUT DOWN") + } + else { + shutDownConfirmText.text = qsTr("Reboot the system?") + shutDownConfirm.text = qsTr("REBOOT") + } + + visible = true; + } + + function close() + { + visible = false; + } + + Rectangle { + id: frame + color: viewSettings.backgroundColor + border.color: viewSettings.borderColor + border.width: 3 + anchors.centerIn: parent + width: parent.width * 0.35 + height: parent.height * 0.4 + + Column { + anchors.centerIn: parent + spacing: viewSettings.pageMargin + + Text { + id: shutDownConfirmText + width: frame.width * 0.75 + height: frame.height * 0.25 + horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + fontSizeMode: Text.Fit + minimumPixelSize: 1 + font.pixelSize: frame.width * 0.3 + color: "white" + font.family: viewSettings.appFont + font.styleName: "SemiBold" + text: "" + } + QtButton { + id: shutDownConfirm + height: frame.height * 0.15 + width: frame.width * 0.45 + anchors.horizontalCenter: parent.horizontalCenter + text: "" + onClicked: shutdownPopup.accepted() + } + QtButton { + height: frame.height * 0.15 + width: frame.width * 0.45 + anchors.horizontalCenter: parent.horizontalCenter + borderColor: "transparent" + fillColor: viewSettings.buttonGrayColor + text: qsTr("CANCEL") + onClicked: shutdownPopup.close() + } + } + } +} diff --git a/src/settingsui/settingsuiplugin/icons.qrc b/src/settingsui/settingsuiplugin/icons.qrc index 88bdeac..91c3a76 100644 --- a/src/settingsui/settingsuiplugin/icons.qrc +++ b/src/settingsui/settingsuiplugin/icons.qrc @@ -30,5 +30,27 @@ <file>icons/Chevron-left_black_6x.png</file> <file>icons/Chevron-left_black.png</file> <file>icons/Power_black_6x.png</file> + <file>newIcons/back_icon.svg</file> + <file>newIcons/bluetooth_icon.svg</file> + <file>newIcons/close_icon.svg</file> + <file>newIcons/date-time_icon.svg</file> + <file>newIcons/detail_icon.svg</file> + <file>newIcons/display_icon.svg</file> + <file>newIcons/grid_icon.svg</file> + <file>newIcons/header_toggle_icon.svg</file> + <file>newIcons/info_icon.svg</file> + <file>newIcons/language_icon.svg</file> + <file>newIcons/mouse_icon.svg</file> + <file>newIcons/mute_icon.svg</file> + <file>newIcons/network_icon.svg</file> + <file>newIcons/pause_icon.svg</file> + <file>newIcons/play_icon.svg</file> + <file>newIcons/power_icon.svg</file> + <file>newIcons/settings_icon.svg</file> + <file>newIcons/settingsmenu_launcher_icon.svg</file> + <file>newIcons/stop_icon.svg</file> + <file>newIcons/touch_icon.svg</file> + <file>newIcons/volume_icon.svg</file> + <file>newIcons/qt_logo_green_rgb.svg</file> </qresource> </RCC> diff --git a/src/settingsui/settingsuiplugin/newIcons/back_icon.svg b/src/settingsui/settingsuiplugin/newIcons/back_icon.svg new file mode 100644 index 0000000..6034bd7 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/back_icon.svg @@ -0,0 +1 @@ +<svg id="back" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>back_icon</title><path d="M26.57,43.5a2.61,2.61,0,0,1-2.1-1.06L10.74,24a2.62,2.62,0,0,1,0-3.12L25.06,1.56a2.62,2.62,0,1,1,4.2,3.12L16.1,22.4,28.67,39.32a2.62,2.62,0,0,1-2.1,4.18Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/bluetooth_icon.svg b/src/settingsui/settingsuiplugin/newIcons/bluetooth_icon.svg new file mode 100644 index 0000000..5dfaa97 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/bluetooth_icon.svg @@ -0,0 +1 @@ +<svg id="bluetooth" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>bluetooth_icon</title><path d="M22.38,43.5a1.79,1.79,0,0,1-1.79-1.79V25.82l-9.08,7.86A1.79,1.79,0,1,1,9.18,31l10.37-9L9.1,13a1.79,1.79,0,0,1,2.34-2.7l9.16,7.92V2.29a1.79,1.79,0,0,1,3-1.35l11.34,9.81a1.79,1.79,0,0,1,0,2.7L25,22l9.88,8.55a1.79,1.79,0,0,1,0,2.7L23.55,43.06A1.79,1.79,0,0,1,22.38,43.5ZM24.17,26V37.81L31,31.9Zm0-19.8V18L31,12.1Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/close_icon.svg b/src/settingsui/settingsuiplugin/newIcons/close_icon.svg new file mode 100644 index 0000000..c98fe51 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/close_icon.svg @@ -0,0 +1 @@ +<svg id="close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>close_icon</title><path d="M25.5,22,42.09,4.78a2.52,2.52,0,1,0-3.64-3.5L22,18.36,5.55,1.27a2.53,2.53,0,0,0-3.64,3.5L18.49,22,1.91,39.22a2.53,2.53,0,0,0,3.64,3.5L22,25.64,38.45,42.73a2.52,2.52,0,1,0,3.64-3.5Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/date-time_icon.svg b/src/settingsui/settingsuiplugin/newIcons/date-time_icon.svg new file mode 100644 index 0000000..2b86128 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/date-time_icon.svg @@ -0,0 +1 @@ +<svg id="date_time" data-name="date time" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>date-time_icon</title><polygon points="9.98 20.74 6.69 20.74 6.69 24.03 9.98 24.03 9.98 20.74 9.98 20.74" style="fill:#fff"/><polygon points="15.68 20.74 12.39 20.74 12.39 24.03 15.68 24.03 15.68 20.74 15.68 20.74" style="fill:#fff"/><polygon points="21.39 20.74 18.09 20.74 18.09 24.03 21.39 24.03 21.39 20.74 21.39 20.74" style="fill:#fff"/><polygon points="9.98 26.03 6.69 26.03 6.69 29.32 9.98 29.32 9.98 26.03 9.98 26.03" style="fill:#fff"/><polygon points="15.68 26.03 12.39 26.03 12.39 29.32 15.68 29.32 15.68 26.03 15.68 26.03" style="fill:#fff"/><polygon points="21.39 26.03 18.09 26.03 18.09 29.32 21.39 29.32 21.39 26.03 21.39 26.03" style="fill:#fff"/><path d="M38.59,21.72V7.28a1.7,1.7,0,0,0-1.7-1.7H32.08V4.45a1.7,1.7,0,1,0-3.4,0V5.58H10.44V4.45a1.7,1.7,0,1,0-3.4,0V5.58H2a1.7,1.7,0,0,0-1.7,1.7V35A1.7,1.7,0,0,0,2,36.69H24.43v0a10.53,10.53,0,1,0,14.16-15ZM3.74,9H7V10.1a1.7,1.7,0,0,0,3.4,0V9H28.68V10.1a1.7,1.7,0,0,0,3.4,0V9h3.11V15.6H3.74Zm0,24.33v-16H35.19v3.08a11,11,0,0,0-2.08-.2,10.43,10.43,0,0,0-6,1.9V20.74h-3.3V24H25A10.53,10.53,0,0,0,22.9,33.3Zm29.37,6.25A8.84,8.84,0,1,1,42,30.71,8.85,8.85,0,0,1,33.11,39.55Z" style="fill:#fff"/><path d="M39.47,30.71a.87.87,0,0,1-.88.88H33.11a.89.89,0,0,1-.88-.88V25.24a.88.88,0,1,1,1.76,0v4.59h4.6A.88.88,0,0,1,39.47,30.71Z" style="fill:#fff"/><path d="M33.2,31.59h-.09a.81.81,0,0,1-.62-.27.84.84,0,0,0,.62.26Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/detail_icon.svg b/src/settingsui/settingsuiplugin/newIcons/detail_icon.svg new file mode 100644 index 0000000..f0dc4ec --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/detail_icon.svg @@ -0,0 +1 @@ +<svg id="detail" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>detail</title><path d="M42.31,5.08H1.69A1.69,1.69,0,0,0,0,6.77V37.23a1.69,1.69,0,0,0,1.69,1.69H42.31A1.69,1.69,0,0,0,44,37.23V6.77A1.69,1.69,0,0,0,42.31,5.08ZM40.61,26.71H24V8.46H40.61Zm-7.16,8.82H24V28.29h9.43Zm-12.57,0H14.59V28.29h6.29Zm0-27.08V26.71H3.38V8.46ZM3.38,28.29h8.07v7.25H3.38ZM35,35.54V28.29h5.59v7.25Z" style="fill:#fff"/><rect x="6.74" y="11" width="12.57" height="1.57" style="fill:#fff"/><rect x="6.74" y="18.86" width="12.57" height="1.57" style="fill:#fff"/><rect x="6.74" y="14.14" width="12.57" height="1.57" style="fill:#fff"/><rect x="6.74" y="22" width="12.57" height="1.57" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/display_icon.svg b/src/settingsui/settingsuiplugin/newIcons/display_icon.svg new file mode 100644 index 0000000..598d2ee --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/display_icon.svg @@ -0,0 +1 @@ +<svg id="display" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>display_icon</title><path d="M42.16,32.5H1.83A1.83,1.83,0,0,1,0,30.67V5A1.83,1.83,0,0,1,1.83,3.17H42.16A1.83,1.83,0,0,1,44,5V30.67a1.83,1.83,0,0,1-1.84,1.83ZM3.67,28.84H40.33v-22H3.67v22Z" style="fill:#fff"/><path d="M28.76,40.83H15.24a1.83,1.83,0,1,1,0-3.67H28.76a1.83,1.83,0,1,1,0,3.67Z" style="fill:#fff"/><path d="M17.34,40.29a1.83,1.83,0,0,1-1.83-1.83V31.05a1.83,1.83,0,1,1,3.67,0v7.41a1.83,1.83,0,0,1-1.83,1.83Z" style="fill:#fff"/><path d="M26.66,40.29a1.83,1.83,0,0,1-1.83-1.83V31.05a1.83,1.83,0,1,1,3.67,0v7.41a1.83,1.83,0,0,1-1.83,1.83Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/grid_icon.svg b/src/settingsui/settingsuiplugin/newIcons/grid_icon.svg new file mode 100644 index 0000000..decd8e2 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/grid_icon.svg @@ -0,0 +1 @@ +<svg id="grid" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>grid_icon</title><path d="M42.31,5.08H1.69A1.69,1.69,0,0,0,0,6.77V37.23a1.69,1.69,0,0,0,1.69,1.69H42.31A1.69,1.69,0,0,0,44,37.23V6.77A1.69,1.69,0,0,0,42.31,5.08ZM40.62,21.26H29.19V8.46H40.62Zm-23.79,0V8.46H27.24v12.8Zm10.41,1.3v13H16.83v-13ZM14.88,8.46v12.8H3.39V8.46ZM3.39,22.56H14.88v13H3.39Zm25.81,13v-13H40.62v13Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/header_toggle_icon.svg b/src/settingsui/settingsuiplugin/newIcons/header_toggle_icon.svg new file mode 100644 index 0000000..06d0b6a --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/header_toggle_icon.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>header_toggle_icon</title><g style="isolation:isolate"><g id="toggle"><g style="opacity:0.35000000000000003;mix-blend-mode:multiply"><polygon points="3.36 15 23.27 33 42.64 15 3.36 15" style="fill:none;stroke:#09102b;stroke-linejoin:round;stroke-width:2px"/></g><polygon points="2.36 13 22.27 31 41.64 13 2.36 13" style="fill:none;stroke:#fff;stroke-linejoin:round;stroke-width:2px"/></g></g></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/info_icon.svg b/src/settingsui/settingsuiplugin/newIcons/info_icon.svg new file mode 100644 index 0000000..64d24c0 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/info_icon.svg @@ -0,0 +1 @@ +<svg id="info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>info_icon</title><path d="M21.86,15.59a2,2,0,0,1-1.33-.48A1.69,1.69,0,0,1,20,13.77a1.68,1.68,0,0,1,.56-1.3A1.91,1.91,0,0,1,21.86,12a1.93,1.93,0,0,1,1.28.46,1.65,1.65,0,0,1,.56,1.35,1.7,1.7,0,0,1-.54,1.34,1.88,1.88,0,0,1-1.29.48m1.83,3.83V30.14a2.39,2.39,0,0,1-.53,1.68,1.76,1.76,0,0,1-1.35.57,1.67,1.67,0,0,1-1.32-.58A2.47,2.47,0,0,1,20,30.14V19.53a2.38,2.38,0,0,1,.51-1.66,1.71,1.71,0,0,1,1.32-.56,1.78,1.78,0,0,1,1.35.56,2.16,2.16,0,0,1,.53,1.55" style="fill:#fff"/><path d="M21.89,43.5A21.5,21.5,0,0,1,6.7,6.8,21.5,21.5,0,0,1,37.11,37.2a21.38,21.38,0,0,1-15.21,6.3m0-39.35A17.85,17.85,0,0,0,9.28,34.62,17.85,17.85,0,1,0,34.52,9.38,17.73,17.73,0,0,0,21.9,4.15" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/language_icon.svg b/src/settingsui/settingsuiplugin/newIcons/language_icon.svg new file mode 100644 index 0000000..f1235c5 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/language_icon.svg @@ -0,0 +1 @@ +<svg id="language" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>language_icon</title><path d="M22,43.5A21.5,21.5,0,1,1,43.5,22,21.52,21.52,0,0,1,22,43.5ZM22,4.12A17.88,17.88,0,1,0,39.88,22,17.9,17.9,0,0,0,22,4.12Z" style="fill:#fff"/><path d="M22,42.6C15.22,42.6,9.7,33.36,9.7,22S15.22,1.41,22,1.41,34.29,10.64,34.29,22,28.78,42.6,22,42.6ZM22,3.22c-5.78,0-10.48,8.43-10.48,18.78S16.22,40.78,22,40.78,32.48,32.36,32.48,22,27.78,3.22,22,3.22Z" style="fill:#fff"/><path d="M22,42.6a.9.9,0,0,1-.91-.91V2.31A.9.9,0,0,1,22,1.41,20.59,20.59,0,0,1,22,42.6ZM22.9,3.24V40.76a18.78,18.78,0,0,0,0-37.53Z" style="fill:#fff"/><path d="M40.41,29.85H3.59a.91.91,0,0,1-.85-.59,20.37,20.37,0,0,1,0-14.52.91.91,0,0,1,.85-.59H40.41a.91.91,0,0,1,.85.59,20.34,20.34,0,0,1,0,14.52.91.91,0,0,1-.85.59ZM4.23,28H39.77a18.45,18.45,0,0,0,0-12.07H4.23A18.49,18.49,0,0,0,4.23,28Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/mouse_icon.svg b/src/settingsui/settingsuiplugin/newIcons/mouse_icon.svg new file mode 100644 index 0000000..5843fe1 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/mouse_icon.svg @@ -0,0 +1 @@ +<svg id="mouse" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 44 44"><defs><clipPath id="clip-path"><polygon points="26.94 20.62 29.12 14.45 30.87 5.33 28.23 5.83 22.8 4.3 18.92 7.24 9.96 3.31 29 -5.98 42.56 8.54 26.94 20.62" style="fill:none"/></clipPath></defs><title>mouse_icon</title><path d="M5,22.1a1.06,1.06,0,0,1,0-1.5l4.23-4.25a1.06,1.06,0,0,1,1.5,0l8.48,8.46h0a1.06,1.06,0,0,1,0,1.5L15,30.56a1.06,1.06,0,0,1-1.5,0L5,22.1Zm5-3.5L7.24,21.35l7,7,2.73-2.74-7-7Z" style="fill:#fff"/><path d="M24.18,5.35a1,1,0,0,1,0,1.36l-4.41,4.41a3.68,3.68,0,0,1,.77.48l4.33-4.44a1,1,0,0,1,1.36,1.36l-4.31,4.42.62.62,4.12-4.23A1,1,0,1,1,28,10.68l-4.15,4.26a6,6,0,0,1,.5.81l4-4a.86.86,0,0,1,1.27,0,1,1,0,0,1,0,1.36L24,18.8,22.73,20,19.5,23.26a2.38,2.38,0,0,1-1.39.66l-6.57-6.56a2.59,2.59,0,0,1,.22-.76l1.38-5a1,1,0,0,1,.26-.44l3.05-3.05a.91.91,0,1,1,1.29,1.29L16.5,10.62l-.22,1.26,6.54-6.54a1,1,0,0,1,1.36,0m1.5-1.5a3.09,3.09,0,0,0-4.36,0l-2.4,2.4a3.07,3.07,0,0,0-4,.34L11.9,9.64A3.12,3.12,0,0,0,11.09,11L9.76,15.89a4.74,4.74,0,0,0-.32,1.19,2.12,2.12,0,0,0,.6,1.79h0l6.56,6.56a2.12,2.12,0,0,0,1.78.6A4.48,4.48,0,0,0,21,24.76l3.23-3.23,1.23-1.23,5.41-5.49a3.09,3.09,0,0,0,0-4.36,3,3,0,0,0-.7-.52,3.08,3.08,0,0,0-1.85-2.51,3.08,3.08,0,0,0-.64-1.31,2.33,2.33,0,0,0-1.14-.53,3.07,3.07,0,0,0-.87-1.74Z" style="fill:#fff"/><g style="clip-path:url(#clip-path)"><path d="M18.34,16.84A9,9,0,0,1,16.4,14c-1.14-2.88,1-6.75,2.41-8.18l4.11-4.11a4.79,4.79,0,0,1,6.63,0l4,4a4.8,4.8,0,0,1,0,6.66l-4.1,4.1c-1.44,1.41-5.3,3.56-8.17,2.42a9,9,0,0,1-2.9-1.95Zm14-10.08L28.4,2.85a3.14,3.14,0,0,0-4.28,0L20,7c-1.32,1.35-2.78,4.51-2,6.37a7.43,7.43,0,0,0,3.92,3.91c1.84.73,5-.73,6.36-2.06l4.1-4.1a3.15,3.15,0,0,0,0-4.32Z" style="fill:#fff"/></g><path d="M37,25.09a1.16,1.16,0,0,1-.51-.12,5.58,5.58,0,0,1-3.22-3.78,7.76,7.76,0,0,1,1.65-6.1c.68-.86,1.4-1.67,2.1-2.44,2.18-2.42,4.06-4.51,3.51-7.11a3.24,3.24,0,0,0-2.21-2.48c-1.87-.62-4.3.1-6.35,1.88a1.16,1.16,0,1,1-1.53-1.76C33.1.82,36.32-.06,39,.84A5.56,5.56,0,0,1,42.76,5c.81,3.76-1.66,6.51-4.05,9.16-.67.75-1.37,1.53-2,2.33a5.5,5.5,0,0,0-1.21,4.14,3.31,3.31,0,0,0,2,2.21A1.17,1.17,0,0,1,37,25.09Z" style="fill:#fff"/><path d="M1.08,35.78h2l1.59,5.57,1.59-5.57h2v7.13H7.13V37.06H7L5.29,42.62H4.08L2.39,37.06H2.24v5.85H1.08Z" style="fill:#fff"/><path d="M9.62,39.38c0-2.38.68-3.71,2.9-3.71s2.89,1.32,2.89,3.71S14.75,43,12.52,43,9.62,41.78,9.62,39.38Zm4.6,0c0-1.77-.32-2.7-1.7-2.7s-1.71.94-1.71,2.7S11.14,42,12.52,42,14.22,41.19,14.22,39.38Z" style="fill:#fff"/><path d="M19.31,42c1,0,1.47-.43,1.47-1.38V35.78h1.17v4.83c0,1.72-.93,2.41-2.63,2.41s-2.61-.7-2.61-2.41V35.78h1.17v4.85C17.86,41.6,18.36,42,19.31,42Z" style="fill:#fff"/><path d="M27.68,36.84s-1.46-.17-2.06-.17c-.87,0-1.32.31-1.32.93s.37.82,1.59,1.15c1.5.42,2,.81,2,2A2.09,2.09,0,0,1,25.54,43a15.19,15.19,0,0,1-2.33-.28l.11-.93s1.41.19,2.14.19,1.29-.4,1.29-1.14-.32-.81-1.41-1.07c-1.54-.4-2.21-.86-2.21-2.1,0-1.44.95-2,2.37-2a15.76,15.76,0,0,1,2.26.25Z" style="fill:#fff"/><path d="M29.18,35.78h4.49v1H30.33v2H33v1H30.33v2.08h3.34v1H29.18Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/mute_icon.svg b/src/settingsui/settingsuiplugin/newIcons/mute_icon.svg new file mode 100644 index 0000000..2ffd61f --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/mute_icon.svg @@ -0,0 +1 @@ +<svg id="mute" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>mute_icon</title><path d="M17.92,40.48A2,2,0,0,1,16.68,40L7.59,32.77H2a2,2,0,0,1-2-2V13.22a2,2,0,0,1,2-2h5.6L16.68,4A2,2,0,0,1,19.9,5.5v33a2,2,0,0,1-2,2ZM4,28.8H8.29a2,2,0,0,1,1.24.44l6.41,5.13V9.64L9.52,14.77a2,2,0,0,1-1.24.44H4V28.8Z" style="fill:#fff"/><path d="M42,32.41a2,2,0,0,1-1.4-.58L23.77,15a2,2,0,0,1,2.81-2.81L43.42,29A2,2,0,0,1,42,32.41Z" style="fill:#fff"/><path d="M25.29,32.52a2,2,0,0,1-1.42-3.37L40.48,12.08a2,2,0,0,1,2.85,2.77L26.71,31.92a2,2,0,0,1-1.42.6Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/network_icon.svg b/src/settingsui/settingsuiplugin/newIcons/network_icon.svg new file mode 100644 index 0000000..6280828 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/network_icon.svg @@ -0,0 +1 @@ +<svg id="network" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>network_icon</title><path d="M8.22,28.71A6.71,6.71,0,1,1,14.93,22a6.72,6.72,0,0,1-6.71,6.71Zm0-10A3.25,3.25,0,1,0,11.47,22a3.25,3.25,0,0,0-3.25-3.25Z" style="fill:#fff"/><path d="M35.78,13.92a6.71,6.71,0,1,1,6.71-6.71,6.72,6.72,0,0,1-6.71,6.71Zm0-10A3.25,3.25,0,1,0,39,7.21,3.25,3.25,0,0,0,35.78,4Z" style="fill:#fff"/><path d="M35.78,43.5a6.71,6.71,0,1,1,6.71-6.71,6.72,6.72,0,0,1-6.71,6.71Zm0-10A3.25,3.25,0,1,0,39,36.79a3.25,3.25,0,0,0-3.25-3.25Z" style="fill:#fff"/><path d="M30.66,35.89a1.73,1.73,0,0,1-.86-.23L12.12,25.46a1.73,1.73,0,0,1,1.73-3L31.52,32.66a1.73,1.73,0,0,1-.87,3.23Z" style="fill:#fff"/><path d="M13,21.77a1.73,1.73,0,0,1-.87-3.23L29.79,8.34a1.73,1.73,0,1,1,1.73,3L13.85,21.54a1.71,1.71,0,0,1-.86.23Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/pause_icon.svg b/src/settingsui/settingsuiplugin/newIcons/pause_icon.svg new file mode 100644 index 0000000..04000f9 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/pause_icon.svg @@ -0,0 +1 @@ +<svg id="pause" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>pause_icon</title><path d="M15.51,43.5H9.76a4.65,4.65,0,0,1-4.64-4.64V5.14A4.65,4.65,0,0,1,9.76.5h5.75a4.65,4.65,0,0,1,4.64,4.64V38.86a4.65,4.65,0,0,1-4.64,4.64ZM9.76,4.55a.6.6,0,0,0-.59.59V38.86a.6.6,0,0,0,.59.59h5.75a.6.6,0,0,0,.59-.59V5.14a.6.6,0,0,0-.59-.59Z" style="fill:#fff"/><path d="M34.24,43.5H28.49a4.65,4.65,0,0,1-4.64-4.64V5.14A4.65,4.65,0,0,1,28.49.5h5.75a4.65,4.65,0,0,1,4.64,4.64V38.86a4.65,4.65,0,0,1-4.64,4.64ZM28.49,4.55a.6.6,0,0,0-.59.59V38.86a.6.6,0,0,0,.59.59h5.75a.6.6,0,0,0,.59-.59V5.14a.6.6,0,0,0-.59-.59Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/play_icon.svg b/src/settingsui/settingsuiplugin/newIcons/play_icon.svg new file mode 100644 index 0000000..ab27771 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/play_icon.svg @@ -0,0 +1 @@ +<svg id="play" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>play_icon</title><path d="M6.58,43.82c-2.4,0-4.08-1.91-4.08-4.65V4.83C2.5,2.09,4.18.18,6.58.18A5.29,5.29,0,0,1,9.22.95L39,18.12A4.56,4.56,0,0,1,41.5,22,4.56,4.56,0,0,1,39,25.88L9.22,43.05a5.28,5.28,0,0,1-2.65.77ZM6.64,4.28a5.24,5.24,0,0,0,0,.55V39.17a1.56,1.56,0,0,0,.08.55,1.74,1.74,0,0,0,.51-.21L36.92,22.33a1.61,1.61,0,0,0,.46-.36c-.06,0-.19-.16-.46-.31L7.18,4.49a1.6,1.6,0,0,0-.54-.22Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/power_icon.svg b/src/settingsui/settingsuiplugin/newIcons/power_icon.svg new file mode 100644 index 0000000..b922c0e --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/power_icon.svg @@ -0,0 +1 @@ +<svg id="power" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>power_icon</title><path d="M22,17.4a1.82,1.82,0,0,1-1.82-1.82V2.3a1.82,1.82,0,0,1,3.65,0V15.57A1.82,1.82,0,0,1,22,17.4Z" style="fill:#fff"/><path d="M22,43.48A19.15,19.15,0,0,1,15.7,6.25,1.82,1.82,0,0,1,16.9,9.7a15.51,15.51,0,1,0,10.19,0,1.82,1.82,0,0,1,1.2-3.45A19.15,19.15,0,0,1,22,43.48Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/qt_logo_green_rgb.svg b/src/settingsui/settingsuiplugin/newIcons/qt_logo_green_rgb.svg new file mode 100644 index 0000000..bdb07d1 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/qt_logo_green_rgb.svg @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 20.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + viewBox="0 0 293.4 216.1" style="enable-background:new 0 0 293.4 216.1;" xml:space="preserve"> +<style type="text/css"> + .st0{fill:#41CD52;} + .st1{fill:#FFFFFF;} +</style> +<g> + <polygon class="st0" points="265.2,0 255,0 40.7,0 40.7,0 0,40.7 0,176.8 0,187.9 0,216.1 28.2,216.1 38.4,216.1 252.7,216.1 + 252.7,216.1 293.4,175.4 293.4,39.3 293.4,28.2 293.4,0 "/> + <path class="st1" d="M109.2,169.2c-19.3,0-32.8-5.2-40.4-15.6c-7.6-10.4-11.4-26.9-11.4-49.3c0-22.5,3.9-39.2,11.6-50.1 + c7.7-10.9,21.2-16.4,40.2-16.4c19.1,0,32.5,5.4,40.1,16.3c7.7,10.8,11.5,27.5,11.5,50.1c0,14.9-1.6,26.9-4.7,36 + c-3.2,9.2-8.3,16.2-15.5,21l15.6,25.1l-19.1,8.9l-16.5-27.1C118.2,168.9,114.4,169.2,109.2,169.2z M85.1,140.3 + c4.2,7.2,12.3,10.9,24.2,10.9s19.9-3.6,24.1-10.7c4.1-7.1,6.2-19.2,6.2-36.1c0-17-2.1-29.3-6.4-37S121,55.9,109.3,55.9 + c-11.6,0-19.6,3.8-24,11.5c-4.3,7.7-6.5,19.9-6.5,36.8C78.8,121,80.9,133.1,85.1,140.3z"/> + <path class="st1" d="M232.4,89.2h-25.6v40.9c0,7.6,0.6,12.6,1.7,15.1s4,3.7,8.5,3.7l15.2-0.6l0.9,16.2c-8.3,1.6-14.6,2.4-19,2.4 + c-10.5,0-17.7-2.4-21.6-7.2c-3.9-4.8-5.9-13.9-5.9-27.3V89.3h-14.1V72h14.2V45.1h20.1V72h25.6V89.2z"/> +</g> +</svg> diff --git a/src/settingsui/settingsuiplugin/newIcons/settings_icon.svg b/src/settingsui/settingsuiplugin/newIcons/settings_icon.svg new file mode 100644 index 0000000..7f5dbde --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/settings_icon.svg @@ -0,0 +1 @@ +<svg id="settings" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>settings_icon</title><path d="M41,17.82H35a14.73,14.73,0,0,0-1.47-3.24l4-4a2.38,2.38,0,0,0,0-3.38L35.83,5.53a2.39,2.39,0,0,0-3.38,0l-4,4a14.34,14.34,0,0,0-3.53-1.43V2.89A2.39,2.39,0,0,0,22.49.5H20.1a2.39,2.39,0,0,0-2.39,2.39V8.14a14,14,0,0,0-3.84,1.61L10.49,6.37a2.4,2.4,0,0,0-3.38,0L5.42,8.06a2.4,2.4,0,0,0,0,3.38l3.44,3.44A14.24,14.24,0,0,0,7.28,19H2.79A2.39,2.39,0,0,0,.39,21.4v2.39a2.39,2.39,0,0,0,2.39,2.38h4.8a14,14,0,0,0,1.93,4L6.27,33.4a2.4,2.4,0,0,0,0,3.38L8,38.47a2.4,2.4,0,0,0,3.38,0L15,34.84a13.89,13.89,0,0,0,3.94,1.27v5A2.4,2.4,0,0,0,21.3,43.5h2.39a2.4,2.4,0,0,0,2.39-2.39V35.5a14,14,0,0,0,3.38-1.72l3.85,3.85a2.4,2.4,0,0,0,3.38,0l1.69-1.69a2.38,2.38,0,0,0,0-3.38l-4.21-4.22A14.15,14.15,0,0,0,35.31,25H41a2.39,2.39,0,0,0,2.39-2.39V20.21A2.4,2.4,0,0,0,41,17.82ZM21.3,31.5A9.5,9.5,0,1,1,30.8,22,9.5,9.5,0,0,1,21.3,31.5Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/settingsmenu_launcher_icon.svg b/src/settingsui/settingsuiplugin/newIcons/settingsmenu_launcher_icon.svg new file mode 100644 index 0000000..479a79f --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/settingsmenu_launcher_icon.svg @@ -0,0 +1 @@ +<svg id="settings_menu_launcher" data-name="settings menu launcher" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>settingsmenu_launcher_icon</title><rect y="1.86" width="44" height="9.43" style="fill:#9d9faa"/><rect y="17.57" width="44" height="9.43" style="fill:#9d9faa"/><rect y="33.29" width="44" height="7.86" style="fill:#9d9faa"/><rect y="1.86" width="44" height="9.43" style="fill:#9ca0aa"/><rect y="17.57" width="44" height="9.43" style="fill:#9ca0aa"/><rect y="33.29" width="44" height="7.86" style="fill:#9ca0aa"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/stop_icon.svg b/src/settingsui/settingsuiplugin/newIcons/stop_icon.svg new file mode 100644 index 0000000..2eeff5f --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/stop_icon.svg @@ -0,0 +1 @@ +<svg id="stop" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>stop_icon</title><path d="M37.66,44H6.34A6.35,6.35,0,0,1,0,37.66V6.34A6.35,6.35,0,0,1,6.34,0H37.66A6.35,6.35,0,0,1,44,6.34V37.66A6.35,6.35,0,0,1,37.66,44ZM6.34,4.14a2.2,2.2,0,0,0-2.2,2.2V37.66a2.2,2.2,0,0,0,2.2,2.2H37.66a2.2,2.2,0,0,0,2.2-2.2V6.34a2.2,2.2,0,0,0-2.2-2.2Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/touch_icon.svg b/src/settingsui/settingsuiplugin/newIcons/touch_icon.svg new file mode 100644 index 0000000..40ce016 --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/touch_icon.svg @@ -0,0 +1 @@ +<svg id="touch" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>touch_icon</title><path d="M10.64,21.23a1.06,1.06,0,0,1,0-1.5l4.23-4.25a1.06,1.06,0,0,1,1.5,0l8.48,8.46h0a1.06,1.06,0,0,1,0,1.5l-4.24,4.25a1.06,1.06,0,0,1-1.5,0l-8.47-8.45Zm5-3.5-2.74,2.74,7,7,2.73-2.74-7-7Z" style="fill:#fff"/><path d="M29.83,4.48a1,1,0,0,1,0,1.36l-4.41,4.41a3.68,3.68,0,0,1,.77.48l.44-.44A1,1,0,0,1,28,11.64l-.42.42.62.62.23-.23a1,1,0,1,1,1.36,1.36l-.25.25a3.68,3.68,0,0,1,.48.76,1,1,0,0,1,1.36,1.36l-1.74,1.74-1.23,1.23-3.23,3.23a2.38,2.38,0,0,1-1.39.66L17.2,16.49a2.52,2.52,0,0,1,.22-.76l1.37-5a1,1,0,0,1,.26-.44l3.05-3.05A.91.91,0,1,1,23.4,8.51L22.15,9.75,21.93,11l6.54-6.54a1,1,0,0,1,1.36,0M31.33,3A3.09,3.09,0,0,0,27,3l-2.4,2.4a3.08,3.08,0,0,0-4,.34L17.55,8.77a3.13,3.13,0,0,0-.81,1.39L15.42,15a4.74,4.74,0,0,0-.32,1.19A2.12,2.12,0,0,0,15.7,18h0l6.57,6.56a2.11,2.11,0,0,0,1.78.6,4.49,4.49,0,0,0,2.61-1.27l3.23-3.23,1.23-1.23,1.74-1.74a3.09,3.09,0,0,0,0-4.36,3,3,0,0,0-.7-.52,3.08,3.08,0,0,0-1.85-2.51A3.09,3.09,0,0,0,29.68,9l1.65-1.65a3.09,3.09,0,0,0,0-4.36Z" style="fill:#fff"/><path d="M6.65,34.69h5.2v1h-2v6.1H8.68v-6.1h-2Z" style="fill:#fff"/><path d="M12.38,38.29c0-2.38.68-3.71,2.9-3.71s2.89,1.32,2.89,3.71-.67,3.64-2.89,3.64S12.38,40.69,12.38,38.29Zm4.6,0c0-1.77-.32-2.7-1.7-2.7s-1.71.94-1.71,2.7.32,2.63,1.71,2.63S17,40.1,17,38.29Z" style="fill:#fff"/><path d="M22.07,40.92c1,0,1.47-.43,1.47-1.38V34.69H24.7v4.83c0,1.72-.93,2.41-2.63,2.41s-2.61-.7-2.61-2.41V34.69h1.17v4.85C20.62,40.5,21.12,40.92,22.07,40.92Z" style="fill:#fff"/><path d="M30.71,41.7a11.23,11.23,0,0,1-2,.23c-2.17,0-2.67-1.24-2.67-3.67s.54-3.68,2.67-3.68a10,10,0,0,1,2,.26l0,.94a13.25,13.25,0,0,0-1.84-.17c-1.31,0-1.63.64-1.63,2.65s.26,2.64,1.66,2.64a13.87,13.87,0,0,0,1.81-.16Z" style="fill:#fff"/><path d="M36.18,38.73H33.1v3.08H31.95V34.69H33.1v3h3.08v-3h1.17v7.13H36.18Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/newIcons/volume_icon.svg b/src/settingsui/settingsuiplugin/newIcons/volume_icon.svg new file mode 100644 index 0000000..12f944e --- /dev/null +++ b/src/settingsui/settingsuiplugin/newIcons/volume_icon.svg @@ -0,0 +1 @@ +<svg id="volume" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44"><title>volume_icon</title><path d="M33.13,40.13a2,2,0,0,1-1.4-3.39,20.87,20.87,0,0,0,0-29.48,2,2,0,1,1,2.81-2.81,24.85,24.85,0,0,1,0,35.09,2,2,0,0,1-1.4.58Z" style="fill:#fff"/><path d="M27.38,34.38A2,2,0,0,1,26,31a12.72,12.72,0,0,0,0-18,2,2,0,0,1,2.81-2.81,16.69,16.69,0,0,1,0,23.59,2,2,0,0,1-1.4.58Z" style="fill:#fff"/><path d="M20.13,40.48A2,2,0,0,1,18.89,40L9.8,32.77H4.19a2,2,0,0,1-2-2V13.22a2,2,0,0,1,2-2h5.6L18.89,4A2,2,0,0,1,22.12,5.5v33a2,2,0,0,1-2,2ZM6.18,28.8h4.32a2,2,0,0,1,1.24.44l6.41,5.13V9.64l-6.42,5.14a2,2,0,0,1-1.24.44H6.18V28.8Z" style="fill:#fff"/></svg>
\ No newline at end of file diff --git a/src/settingsui/settingsuiplugin/plugin.qrc b/src/settingsui/settingsuiplugin/plugin.qrc index 58cb4af..e6d02ea 100644 --- a/src/settingsui/settingsuiplugin/plugin.qrc +++ b/src/settingsui/settingsuiplugin/plugin.qrc @@ -24,5 +24,17 @@ <file>../timedate/TimeDate.qml</file> <file>../timedate/TimezonesView.qml</file> <file>settingsview.xml</file> + <file>../power/Power.qml</file> + <file>../timedate/ManualTime.qml</file> + <file>../timedate/CustomComboBox.qml</file> + <file>../common/CustomSwitch.qml</file> + <file>../network/NetworkListView.qml</file> + <file>../network/PassphraseEnter.qml</file> + <file>../locale/TableKey.qml</file> + <file>../locale/TableValue.qml</file> + <file>SettingsHeader.qml</file> + <file>SettingsDelegate.qml</file> + <file>SettingsTitleItem.qml</file> + <file>ShutdownPopup.qml</file> </qresource> </RCC> diff --git a/src/settingsui/settingsuiplugin/pluginMain.qml b/src/settingsui/settingsuiplugin/pluginMain.qml index 3f15c57..def4c80 100644 --- a/src/settingsui/settingsuiplugin/pluginMain.qml +++ b/src/settingsui/settingsuiplugin/pluginMain.qml @@ -32,135 +32,112 @@ import QtQuick.Controls 2.0 import Qt.labs.settings 1.0 import QtQuick.XmlListModel 2.0 import QtDeviceUtilities.LocalDeviceSettings 1.0 +import QtDeviceUtilities.NetworkSettings 1.0 +import QtGraphicalEffects 1.0 Rectangle { - id: root + id: pluginMain anchors.fill: parent - color: "white" visible: true + color: "#09102b" + opacity: 0.97 + + property bool __initialized: false property var service + property int margin: (pluginMain.width / 3 * 2) * 0.05 + property int spacing: margin * 0.5 + property int titleFontSize: height * 0.04 + property int subTitleFontSize: height * 0.035 + property int valueFontSize: height * 0.025 + property int fieldHeight: height * 0.07 + property int fieldTextHeight: height * 0.05 + property int buttonHeight: height * 0.05 - ToolBar { - id: titlebar - property string title: "" - width: parent.width - height: 40 - z: 2 + property alias model: xmlModel.source - ToolButton { - height: parent.height - width: height - contentItem: Image { - fillMode: Image.PreserveAspectFit - source: "../icons/Chevron-left_black_6x.png" - anchors.fill: parent - anchors.margins: parent.height * .2 + function init() + { + if (!__initialized) { + __initialized = true; + settingsHeader.refreshIP() + settingsList.currentIndex = 0 + if (xmlModel.count >= 1) { + settingsLoader.source = xmlModel.get(0).path + '/' + + xmlModel.get(0).view + '.qml' + titleItem.title = xmlModel.get(0).title + } else { + titleItem.title = qsTr("No settings") } - - visible: stackView.depth > 1 - onClicked: stackView.pop(); - } - Label { - id: titleText - font.pixelSize: 20 - text: stackView.currentItem.title - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - anchors.centerIn: parent } - ToolButton { - height: parent.height - width: height - contentItem: Image { - fillMode: Image.PreserveAspectFit - source: "../icons/Power_black_6x.png" - anchors.fill: parent - anchors.margins: parent.height * .2 - } - anchors.right: parent.right + } - visible: stackView.depth === 1 - onClicked: menu.open(); + signal closed() - Menu { - id: menu - x: parent.width - width + XmlListModel { + id: xmlModel + source: "settingsview.xml" + query: "/xml/settings/item" + XmlRole { name: "title"; query: "title/string()"} + XmlRole { name: "icon"; query: "icon/string()"} + XmlRole { name: "view"; query: "view/string()"} + XmlRole { name: "path"; query: "path/string()"} + } - MenuItem { - text: qsTr("Reboot") - onTriggered: LocalDevice.reboot() - } - MenuItem { - text: qsTr("Shutdown") - onTriggered: LocalDevice.powerOff() - } - } - } + SettingsHeader { + id: settingsHeader + onClicked: pluginMain.closed() } - StackView { - id: stackView - initialItem: mainView - anchors.top: titlebar.bottom - anchors.bottom: parent.bottom + ListView { + id: settingsList + anchors.top: settingsHeader.bottom anchors.left: parent.left - anchors.right: parent.right + anchors.bottom: parent.bottom + width: parent.width / 3 + model: xmlModel - Component { - id: mainView + delegate: SettingsDelegate {} + } + + Rectangle { + id: rightLine + width: 3 + height: parent.height * 0.8 + anchors.left: settingsList.right + anchors.top: settingsHeader.bottom + color: "#9d9faa" + } + + SettingsTitleItem { + id: titleItem + anchors.left: rightLine.right + anchors.right: parent.right + anchors.top: settingsHeader.bottom + anchors.leftMargin: pluginMain.margin * 2 + } - Item { - property string title: qsTr("Device Settings") + Loader { + id: settingsLoader + anchors.top: titleItem.bottom + anchors.left: rightLine.right + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.leftMargin: pluginMain.margin * 2 + anchors.rightMargin: pluginMain.margin * 2 + } - XmlListModel { - id: xmlModel - source: "settingsview.xml" - query: "/xml/settings/item" - XmlRole { name: "title"; query: "title/string()"} - XmlRole { name: "icon"; query: "icon/string()"} - XmlRole { name: "view"; query: "view/string()"} - XmlRole { name: "path"; query: "path/string()"} - } - GridView { - id: grid - anchors.fill: parent - anchors.margins: 40 - cellHeight: 133 + spacing - cellWidth: 117 + spacing - model: xmlModel - property int spacing: 20 - delegate: MouseArea { - width: grid.cellWidth - grid.spacing - height: grid.cellHeight - grid.spacing + ShutdownPopup { + id: shutdownPopup + visible: false - Rectangle { - anchors.fill: parent - color: "#d6d6d6" - radius: 5 - visible: pressed - } - Column { - anchors.fill: parent - anchors.topMargin: 10 - Image { - id: image - source: icon - anchors.horizontalCenter: parent.horizontalCenter - width: grid.cellWidth - fillMode: Image.PreserveAspectFit - } - Label { - text: title - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: grid.cellHeight * .1 - } - } - onClicked: { - var component = Qt.createComponent(path+'/'+view+'.qml'); - stackView.push(component.createObject(stackView)); - } - } - } + onAccepted: { + if (shutdown) { + console.log("Powering off!") + LocalDevice.powerOff() + } + else { + console.log("Rebooting!") + LocalDevice.reboot() } } } diff --git a/src/settingsui/settingsuiplugin/settingsuiplugin.pro b/src/settingsui/settingsuiplugin/settingsuiplugin.pro index 3ff287f..4e2b67d 100644 --- a/src/settingsui/settingsuiplugin/settingsuiplugin.pro +++ b/src/settingsui/settingsuiplugin/settingsuiplugin.pro @@ -26,12 +26,10 @@ DISTFILES += \ qmldir.files = qmldir -unix { - installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - qmldir.path = $$installPath - target.path = $$installPath - INSTALLS += target qmldir -} +installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) +qmldir.path = $$installPath +target.path = $$installPath +INSTALLS += target qmldir RESOURCES += \ icons.qrc \ diff --git a/src/settingsui/settingsuiplugin/settingsview.xml b/src/settingsui/settingsuiplugin/settingsview.xml index 23915db..2749cb8 100644 --- a/src/settingsui/settingsuiplugin/settingsview.xml +++ b/src/settingsui/settingsuiplugin/settingsview.xml @@ -5,31 +5,37 @@ <title>Network</title> <view>NetworkSettings</view> <path>network</path> - <icon>icons/World_qt_6x.png</icon> + <icon>newIcons/network_icon.svg</icon> </item> <item> <title>Display</title> <view>Display</view> <path>display</path> - <icon>icons/Display_qt_6x.png</icon> + <icon>newIcons/display_icon.svg</icon> </item> <item> - <title>Date and Time</title> + <title>Date & Time</title> <view>TimeDate</view> <path>timedate</path> - <icon>icons/Clock_qt_6x.png</icon> + <icon>newIcons/date-time_icon.svg</icon> </item> <item> - <title>Language</title> + <title>Language & Region</title> <view>Language</view> <path>locale</path> - <icon>icons/Flag_qt_6x.png</icon> + <icon>newIcons/language_icon.svg</icon> </item> <item> <title>Bluetooth</title> <view>Bluetooth</view> <path>bluetooth</path> - <icon>icons/Bluetooth_qt_6x.png</icon> + <icon>newIcons/bluetooth_icon.svg</icon> + </item> + <item> + <title>Power</title> + <view>Power</view> + <path>power</path> + <icon>newIcons/power_icon.svg</icon> </item> </settings> </xml> diff --git a/src/settingsui/timedate/CustomComboBox.qml b/src/settingsui/timedate/CustomComboBox.qml new file mode 100644 index 0000000..66c3559 --- /dev/null +++ b/src/settingsui/timedate/CustomComboBox.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import QtGraphicalEffects 1.0 + +ComboBox { + id: comboBox + property int itemsVisible: 5 + indicator: Image { + id: indicatorImage + height: comboBox.height * 0.4 + anchors.right: comboBox.right + anchors.rightMargin: pluginMain.margin + anchors.verticalCenter: comboBox.verticalCenter + fillMode: Image.PreserveAspectFit + rotation: -90 + source: "../newIcons/back_icon.svg" + } + ColorOverlay { + id: indicatorOverlay + source: indicatorImage + anchors.fill: indicatorImage + color: viewSettings.buttonGreenColor + visible: false + rotation: -90 + } + contentItem: Text { + anchors.left: comboBox.left + anchors.leftMargin: pluginMain.margin + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "SemiBold" + color: "white" + elide: Text.ElideRight + text: comboBox.displayText + } + background: Rectangle { + color: "transparent" + border.color: viewSettings.borderColor + border.width: comboBox.visualFocus ? 2 : 1 + } + popup: Popup { + y: comboBox.height -1 + width: comboBox.width + height: comboBox.height * comboBox.itemsVisible + padding: 1 + + contentItem: ListView { + id: listView + clip: true + model: comboBox.popup.visible ? comboBox.delegateModel : null + currentIndex: comboBox.currentIndex + onCurrentIndexChanged: positionViewAtIndex(listView.currentIndex, ListView.beginning) + } + onOpened: { + listView.currentIndex = comboBox.currentIndex + indicatorImage.visible = false + indicatorOverlay.visible = true + } + onClosed: { + indicatorImage.visible = true + indicatorOverlay.visible = false + } + background: Rectangle { + border.color: viewSettings.borderColor + color: viewSettings.backgroundColor + opacity: 0.95 + } + } +} diff --git a/src/settingsui/timedate/ManualTime.qml b/src/settingsui/timedate/ManualTime.qml new file mode 100644 index 0000000..1438565 --- /dev/null +++ b/src/settingsui/timedate/ManualTime.qml @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 +import QtDeviceUtilities.TimeDateSettings 1.0 + +Item { + id: root + property int margin: root.width * 0.05 + property var selectedDate: new Date() + property int firstYear: 2017 + + function zeroPadTime(timeToPad) { + return timeToPad < 10 ? "0" + timeToPad : timeToPad + } + + Column { + spacing: pluginMain.spacing + + Text { + color: "white" + text: qsTr("Set Date") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } + + // Row of date comboboxes + Row { + spacing: pluginMain.spacing + leftPadding: pluginMain.margin + + CustomComboBox { + id: dayBox + width: root.width * 0.15 + height: pluginMain.buttonHeight + displayText: currentIndex + 1 + + model: 31 + itemsVisible: 10 + currentIndex: selectedDate.getDate() - 1 + + delegate: ItemDelegate { + id: dayDelegate + height: dayBox.height + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: dayDelegate.left + anchors.leftMargin: pluginMain.margin + text: modelData + 1 + color: dayBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" + } + } + + onCurrentIndexChanged: selectedDate.setDate(currentIndex + 1) + } + + CustomComboBox { + id: monthBox + width: root.width * 0.35 + height: pluginMain.buttonHeight + model: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] + currentIndex: selectedDate.getMonth() + + itemsVisible: 12 + delegate: ItemDelegate { + id: monthDelegate + height: monthBox.height + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: monthDelegate.left + anchors.leftMargin: pluginMain.margin + color: monthBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + text: modelData + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" + + } + } + onCurrentIndexChanged: selectedDate.setMonth(currentIndex) + } + + CustomComboBox { + id: yearBox + width: root.width * 0.2 + height: pluginMain.buttonHeight + displayText: currentIndex + firstYear + + model: 50 + itemsVisible: 8 + currentIndex: (selectedDate.getFullYear() >= firstYear) ? + selectedDate.getFullYear() - firstYear : 0 + + delegate: ItemDelegate { + id: yearDelegate + height: yearBox.height + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: yearDelegate.left + anchors.leftMargin: pluginMain.margin + text: index + firstYear + color: yearBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" + } + } + onCurrentIndexChanged: selectedDate.setFullYear(currentIndex + firstYear) + } + } // Row of date comboboxes + + Text { + color: "white" + text: qsTr("Set Time") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } + + // Row of time comboboxes + Row { + spacing: pluginMain.spacing + leftPadding: pluginMain.margin + + CustomComboBox { + id: hourBox + width: root.width * 0.15 + height: pluginMain.buttonHeight + displayText: zeroPadTime(currentIndex) + + model: 24 + itemsVisible: 8 + currentIndex: selectedDate.getHours() + + delegate: ItemDelegate { + id: hourDelegate + height: hourBox.height + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: hourDelegate.left + anchors.leftMargin: pluginMain.margin + text: zeroPadTime(parseInt(modelData)) + color: hourBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" + } + } + onCurrentIndexChanged: selectedDate.setHours(currentIndex) + } + CustomComboBox { + id: minuteBox + width: root.width * 0.15 + height: pluginMain.buttonHeight + displayText: zeroPadTime(currentIndex) + + model: 60 + itemsVisible: 8 + currentIndex: selectedDate.getMinutes() + + delegate: ItemDelegate { + id: minuteDelegate + height: minuteBox.height + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: minuteDelegate.left + anchors.leftMargin: pluginMain.margin + text: zeroPadTime(parseInt(modelData)) + color: minuteBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" + } + } + onCurrentIndexChanged: selectedDate.setMinutes(currentIndex) + } + } // Row of time comboboxes + + // Row of set/cancel buttons + Row { + spacing: pluginMain.spacing + + QtButton { + id: dateSetButton + height: pluginMain.buttonHeight + text: qsTr("SET") + + onClicked: { + selectedDate.setSeconds(0); + TimeManager.ntp = false + TimeManager.time = selectedDate; + console.log("Set date to: " + selectedDate) + console.log("TimeManager.time: " + TimeManager.time) + settingsLoader.source = "qrc:/timedate/TimeDate.qml" + } + } + QtButton { + id: dateCancelButton + height: pluginMain.buttonHeight + fillColor: viewSettings.buttonGrayColor + borderColor: "transparent" + text: qsTr("CANCEL") + onClicked: { + settingsLoader.source = "qrc:/timedate/TimeDate.qml" + } + } + } // Row of set/cancel buttons + } // Main column +} diff --git a/src/settingsui/timedate/TimeDate.qml b/src/settingsui/timedate/TimeDate.qml index e269fa5..fccda46 100644 --- a/src/settingsui/timedate/TimeDate.qml +++ b/src/settingsui/timedate/TimeDate.qml @@ -30,92 +30,134 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.TimeDateSettings 1.0 +import QtDeviceUtilities.LocaleSettings 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root - property string title: qsTr("Time and Date settings") + property int margin: root.width * 0.05 - Flickable { - id: flickable - anchors.margins: 20 - anchors.fill: parent - contentHeight: content.height - contentWidth: width - interactive: !clock.handPressed + Column { + spacing: pluginMain.spacing + anchors.top: parent.top - ColumnLayout { - id: content - spacing: 20 - width: parent.width + // Display current date + Text { + color: "white" + text: qsTr("Current date") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - GroupBox { - width: parent.width - title: qsTr("Time Settings") - Layout.fillWidth: true + Text { + id: dateText + leftPadding: pluginMain.margin + color: "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + Timer { + id: dateTimer + interval: 1000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: { + var date = new Date(); + // QTBUG-63598: dateText.text = date.toLocaleString(Qt.locale(LocaleManager.locale), Locale.LongFormat) + dateText.text = date.toLocaleString(Qt.locale("en_EN"), Locale.LongFormat) + } + } + } - ColumnLayout { - spacing: 10 - width: parent.width - Layout.fillWidth: true + // Set date automatically / manually + Text { + color: "white" + text: qsTr("Set Date & Time") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - RadioButton { - id: automatic - text: qsTr("Automatic time set") - checked: TimeManager.ntp - onCheckedChanged: if (checked) updateTimer.restart() + Row { + spacing: pluginMain.spacing + leftPadding: pluginMain.margin + QtButton { + id: automaticButton + height: pluginMain.buttonHeight + text: qsTr("AUTOMATICALLY") + onClicked: TimeManager.ntp = true + } + QtButton { + id: manualButton + height: pluginMain.buttonHeight + fillColor: viewSettings.buttonGrayColor + borderColor: "transparent" + text: qsTr("MANUALLY") + onClicked: { + settingsLoader.source = "qrc:/timedate/ManualTime.qml" + } + } + } - Timer { - id: updateTimer - interval: 300 - onTriggered: calendar.updateDate() - } - } - RadioButton { - id: custom - text: qsTr("Manual") - checked: !TimeManager.ntp - onCheckedChanged: TimeManager.ntp = !checked - } - RowLayout - { - id: layout - spacing: 10 + // Select timezone + Text { + color: "white" + text: qsTr("Time Zone") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - CustomCalendar { - id: calendar - width: height - } - AnalogClock { - id: clock - height: calendar.height - width: height - editMode: !automatic.checked - } - } - Component { - id: zoneselect - TimezonesView { } + Row { + leftPadding: pluginMain.margin + CustomComboBox { + id: timeZoneBox + width: automaticButton.width + manualButton.width + pluginMain.spacing + height: pluginMain.buttonHeight + textRole: "id" + itemsVisible: 7 + model: TimezonesFilter + delegate: ItemDelegate { + id: timeZoneDelegate + height: timeZoneBox.height + width: timeZoneBox.width + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: timeZoneDelegate.left + anchors.leftMargin: pluginMain.margin + text: modelData["id"] + color: timeZoneBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" } } - } - GroupBox { - title: qsTr("Timezone Settings") - Layout.fillWidth: true - width: parent.width - visible: true - RowLayout { - spacing: 10 - Label { - text: TimeManager.timeZone - Layout.alignment: Qt.AlignVCenter + Component.onCompleted: { + var n = TimezonesFilter.indexForTimezone(TimeManager.timeZone) + timeZoneBox.currentIndex = n + } + + Connections { + target: TimezonesFilter.sourceModel + onReady: { + var n = TimezonesFilter.indexForTimezone(TimeManager.timeZone) + timeZoneBox.currentIndex = n } - Button { - text: qsTr("Change") - onClicked : stackView.push(zoneselect) + } + + onCurrentIndexChanged: { + var val = TimezonesFilter.itemFromRow(currentIndex); + if (val && val !== "") { + TimeManager.timeZone = val } } } } + + Component { + id: zoneselect + TimezonesView {} + } } } diff --git a/src/src.pro b/src/src.pro index 123cead..d7ace46 100644 --- a/src/src.pro +++ b/src/src.pro @@ -13,6 +13,7 @@ SUBDIRS += \ displaysettings \ localdevice \ settingsui/settingsuiplugin \ + settingsui/qtbuttonimageproviderplugin \ settingsui \ imports \ doc \ diff --git a/src/timedatesettings/timezonefiltermodel.cpp b/src/timedatesettings/timezonefiltermodel.cpp index 9c2dfb7..b566624 100644 --- a/src/timedatesettings/timezonefiltermodel.cpp +++ b/src/timedatesettings/timezonefiltermodel.cpp @@ -99,4 +99,20 @@ QVariant TimezoneFilterModel::itemFromRow(const int row) const return QVariant(); } +int TimezoneFilterModel::indexForTimezone(const QString &timezone) const +{ + TimezoneModel *model = qobject_cast<TimezoneModel *>(sourceModel()); + QList<TimezoneItem *> data = model->getModel(); + int row = 0; + foreach (TimezoneItem *item, data) { + if (item->id() == timezone) { + QModelIndex mapped = mapFromSource(model->index(row)); + return mapped.row(); + } + row++; + } + + return -1; +} + QT_END_NAMESPACE diff --git a/src/timedatesettings/timezonefiltermodel.h b/src/timedatesettings/timezonefiltermodel.h index 2b4ec2b..ead5eb0 100644 --- a/src/timedatesettings/timezonefiltermodel.h +++ b/src/timedatesettings/timezonefiltermodel.h @@ -55,8 +55,10 @@ public: QString filter() const; void setFilter(const QString& aFilter); Q_INVOKABLE QVariant itemFromRow(const int row) const; + Q_INVOKABLE int indexForTimezone(const QString &timezone) const; Q_SIGNALS: void filterChanged(); + void selectedIndexChanged(); private: QString m_filter; diff --git a/src/timedatesettings/timezonemodel.cpp b/src/timedatesettings/timezonemodel.cpp index bd56814..8983a49 100644 --- a/src/timedatesettings/timezonemodel.cpp +++ b/src/timedatesettings/timezonemodel.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include <QLocale> #include <QFuture> +#include <QFutureWatcher> #include <QThread> #include <QtConcurrent/QtConcurrentRun> #include "timezonemodel.h" @@ -66,7 +67,11 @@ TimezoneModel::TimezoneModel(QObject *parent) m_roleNames.insert(Name, "name"); m_roleNames.insert(Id, "id"); - QFuture<void> t1 = QtConcurrent::run(TimezoneModel::generateModel, this); + + QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this); + QFuture<void> future = QtConcurrent::run(TimezoneModel::generateModel, this); + watcher->setFuture(future); + connect(watcher, SIGNAL(finished()), this, SIGNAL(ready())); } void TimezoneModel::generateModel(TimezoneModel* model) diff --git a/src/timedatesettings/timezonemodel.h b/src/timedatesettings/timezonemodel.h index 14d7a2c..6684472 100644 --- a/src/timedatesettings/timezonemodel.h +++ b/src/timedatesettings/timezonemodel.h @@ -65,6 +65,10 @@ public: int rowCount(const QModelIndex & parent = QModelIndex()) const; QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; QHash<int, QByteArray> roleNames() const; + QList<TimezoneItem *> getModel() const + { + return m_items; + } enum Roles { Name = Qt::UserRole + 1, @@ -74,6 +78,9 @@ public: static void generateModel(TimezoneModel* model); +Q_SIGNALS: + void ready(); + private Q_SLOTS: void addNewItem(QObject* item); |