diff options
19 files changed, 261 insertions, 12 deletions
diff --git a/src/settingsui/bluetooth/CustomSwitch.qml b/src/settingsui/bluetooth/CustomSwitch.qml index 9c7c180..adb7031 100644 --- a/src/settingsui/bluetooth/CustomSwitch.qml +++ b/src/settingsui/bluetooth/CustomSwitch.qml @@ -27,7 +27,7 @@ ** ****************************************************************************/ import QtQuick 2.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 import QtQuick.Controls 2.1 Switch { diff --git a/src/settingsui/bluetooth/Discovery.qml b/src/settingsui/bluetooth/Discovery.qml index bde88aa..2d6a88c 100644 --- a/src/settingsui/bluetooth/Discovery.qml +++ b/src/settingsui/bluetooth/Discovery.qml @@ -30,7 +30,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.BluetoothSettings 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: top diff --git a/src/settingsui/display/Display.qml b/src/settingsui/display/Display.qml index 4bdf9a2..bb0e36a 100644 --- a/src/settingsui/display/Display.qml +++ b/src/settingsui/display/Display.qml @@ -30,7 +30,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.DisplaySettings 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root diff --git a/src/settingsui/locale/Language.qml b/src/settingsui/locale/Language.qml index 7904a72..79c72e7 100644 --- a/src/settingsui/locale/Language.qml +++ b/src/settingsui/locale/Language.qml @@ -31,7 +31,7 @@ import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.LocaleSettings 1.0 import QtQml 2.2 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root diff --git a/src/settingsui/locale/RegionSelect.qml b/src/settingsui/locale/RegionSelect.qml index ca8debe..0423a45 100644 --- a/src/settingsui/locale/RegionSelect.qml +++ b/src/settingsui/locale/RegionSelect.qml @@ -32,7 +32,7 @@ import QtQuick.Controls 2.0 import QtDeviceUtilities.LocaleSettings 1.0 import "../common" import QtGraphicalEffects 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root diff --git a/src/settingsui/network/NetworkListView.qml b/src/settingsui/network/NetworkListView.qml index c42d7e1..7ea12b5 100644 --- a/src/settingsui/network/NetworkListView.qml +++ b/src/settingsui/network/NetworkListView.qml @@ -29,7 +29,7 @@ import QtQuick 2.0 import QtQml 2.0 import QtDeviceUtilities.NetworkSettings 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 import QtQuick.Controls 2.1 ListView { diff --git a/src/settingsui/network/NetworkSettings.qml b/src/settingsui/network/NetworkSettings.qml index 0becc55..8c7cf21 100644 --- a/src/settingsui/network/NetworkSettings.qml +++ b/src/settingsui/network/NetworkSettings.qml @@ -30,7 +30,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 import QtDeviceUtilities.NetworkSettings 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { NetworkListView { diff --git a/src/settingsui/network/PassphraseEnter.qml b/src/settingsui/network/PassphraseEnter.qml index 2936afa..6be0b20 100644 --- a/src/settingsui/network/PassphraseEnter.qml +++ b/src/settingsui/network/PassphraseEnter.qml @@ -29,7 +29,7 @@ import QtQuick 2.0 import QtGraphicalEffects 1.0 import QtQuick.Controls 2.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 import QtDeviceUtilities.NetworkSettings 1.0 Item { diff --git a/src/settingsui/power/Power.qml b/src/settingsui/power/Power.qml index 4d924a5..3502ca6 100644 --- a/src/settingsui/power/Power.qml +++ b/src/settingsui/power/Power.qml @@ -28,7 +28,7 @@ ****************************************************************************/ import QtQuick 2.0 import QtQuick.Controls 2.1 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root diff --git a/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml b/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml new file mode 100644 index 0000000..9501aa1 --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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: "white" + property color borderColor: "black" + property alias text: buttonText.text + signal clicked() + + width: buttonText.contentWidth + cutSize * 4 + + 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..c69b053 --- /dev/null +++ b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** 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); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(borderColor); + painter.setBrush(fillColor); + + QPainterPath path; + path.moveTo(cutSize,0); + path.lineTo(pixmap.width(), 0); + path.lineTo(pixmap.width(), pixmap.height()-cutSize); + path.lineTo(pixmap.width()-cutSize, pixmap.height()); + path.lineTo(0, pixmap.height()); + path.lineTo(0, cutSize); + path.lineTo(cutSize, 0); + path.closeSubpath(); + 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/settingsuiplugin/pluginMain.qml b/src/settingsui/settingsuiplugin/pluginMain.qml index 1014cdb..a080e53 100644 --- a/src/settingsui/settingsuiplugin/pluginMain.qml +++ b/src/settingsui/settingsuiplugin/pluginMain.qml @@ -34,7 +34,7 @@ import QtQuick.XmlListModel 2.0 import QtDeviceUtilities.LocalDeviceSettings 1.0 import QtDeviceUtilities.NetworkSettings 1.0 import QtGraphicalEffects 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Rectangle { id: pluginMain diff --git a/src/settingsui/timedate/ManualTime.qml b/src/settingsui/timedate/ManualTime.qml index b2b3f48..564edc7 100644 --- a/src/settingsui/timedate/ManualTime.qml +++ b/src/settingsui/timedate/ManualTime.qml @@ -28,7 +28,7 @@ ****************************************************************************/ import QtQuick 2.0 import QtQuick.Controls 2.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 import QtDeviceUtilities.TimeDateSettings 1.0 Item { diff --git a/src/settingsui/timedate/TimeDate.qml b/src/settingsui/timedate/TimeDate.qml index 7a27047..b38ed54 100644 --- a/src/settingsui/timedate/TimeDate.qml +++ b/src/settingsui/timedate/TimeDate.qml @@ -31,7 +31,7 @@ import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.TimeDateSettings 1.0 import QtDeviceUtilities.LocaleSettings 1.0 -import QtDemoLauncher.QtButtonImageProvider 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root diff --git a/src/src.pro b/src/src.pro index 27a9700..de260b9 100644 --- a/src/src.pro +++ b/src/src.pro @@ -10,6 +10,7 @@ SUBDIRS += \ timedatesettings \ localdevice \ settingsui/settingsuiplugin \ + settingsui/qtbuttonimageproviderplugin \ settingsui \ imports \ doc \ |