diff options
38 files changed, 298 insertions, 84 deletions
diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml index d8f175ed..b2b863e2 100644 --- a/examples/quick/controls/text/qml/main.qml +++ b/examples/quick/controls/text/qml/main.qml @@ -319,6 +319,7 @@ ApplicationWindow { anchors.bottom: parent.bottom text: document.text textFormat: Qt.RichText + baseUrl: "qrc:/" Component.onCompleted: forceActiveFocus() } diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 0a3cb131..efafe26b 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype Button diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml index 48d5e8b2..9d6f5dfe 100644 --- a/src/controls/CheckBox.qml +++ b/src/controls/CheckBox.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype CheckBox diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 9282c58d..b65e749a 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ComboBox diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml index 65af1c12..566c814f 100644 --- a/src/controls/MenuBar.qml +++ b/src/controls/MenuBar.qml @@ -42,6 +42,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype MenuBar diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index e472e66e..2270ff49 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ProgressBar diff --git a/src/controls/RadioButton.qml b/src/controls/RadioButton.qml index fde08817..305e464c 100644 --- a/src/controls/RadioButton.qml +++ b/src/controls/RadioButton.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype RadioButton diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 64dcfff1..9fee75e6 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype Slider diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index b1f87cec..06ec64ce 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype SpinBox diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index 9559ea87..623a1026 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Private/StackView.js" as JSArray +import "../private/StackView.js" as JSArray /*! \qmltype StackView diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml index 85cc6681..62b81807 100644 --- a/src/controls/StatusBar.qml +++ b/src/controls/StatusBar.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype StatusBar diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index 6319d72c..503a203e 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype TabView diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 32b2d4fb..b7e6996e 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles" +import QtQuick.Controls.Styles 1.0 /*! \qmltype TextField diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index b73a6f3e..cadea5c7 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ToolBar diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 3c1eab1a..3cf32789 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ToolButton diff --git a/src/controls/controls.pro b/src/controls/controls.pro index fbda88fc..fad8f2d9 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -5,7 +5,7 @@ QT += qml quick gui-private core-private QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf -QML_FILES = \ +OTHER_FILES = \ ApplicationWindow.qml \ Button.qml \ CheckBox.qml \ @@ -37,3 +37,6 @@ include(plugin.pri) CONFIG += no_cxx_module load(qml_plugin) + +RESOURCES += \ + resources.qrc diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index 1b255302..71cc3196 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -98,6 +98,34 @@ void QtQuickControlsPlugin::registerTypes(const char *uri) QLatin1String("Do not create objects of type MenuBase")); qmlRegisterUncreatableType<QQuickStack>(uri, 1, 0, "Stack", QLatin1String("Do not create objects of type Stack")); + + // Controls in resources file + qmlRegisterType(QUrl("qrc:/controls/ApplicationWindow.qml"), uri, 1, 0, "ApplicationWindow"); + qmlRegisterType(QUrl("qrc:/controls/Button.qml"), uri, 1, 0, "Button"); + qmlRegisterType(QUrl("qrc:/controls/CheckBox.qml"), uri, 1, 0, "CheckBox"); + qmlRegisterType(QUrl("qrc:/controls/ComboBox.qml"), uri, 1, 0, "ComboBox"); + qmlRegisterType(QUrl("qrc:/controls/GroupBox.qml"), uri, 1, 0, "GroupBox"); + qmlRegisterType(QUrl("qrc:/controls/Label.qml"), uri, 1, 0, "Label"); + qmlRegisterType(QUrl("qrc:/controls/Menu.qml"), uri, 1, 0, "Menu"); + qmlRegisterType(QUrl("qrc:/controls/MenuBar.qml"), uri, 1, 0, "MenuBar"); + qmlRegisterType(QUrl("qrc:/controls/ProgressBar.qml"), uri, 1, 0, "ProgressBar"); + qmlRegisterType(QUrl("qrc:/controls/RadioButton.qml"), uri, 1, 0, "RadioButton"); + qmlRegisterType(QUrl("qrc:/controls/ScrollView.qml"), uri, 1, 0, "ScrollView"); + qmlRegisterType(QUrl("qrc:/controls/Slider.qml"), uri, 1, 0, "Slider"); + qmlRegisterType(QUrl("qrc:/controls/SpinBox.qml"), uri, 1, 0, "SpinBox"); + qmlRegisterType(QUrl("qrc:/controls/SplitView.qml"), uri, 1, 0, "SplitView"); + qmlRegisterType(QUrl("qrc:/controls/StackView.qml"), uri, 1, 0, "StackView"); + qmlRegisterType(QUrl("qrc:/controls/StackViewDelegate.qml"), uri, 1, 0, "StackViewDelegate"); + qmlRegisterType(QUrl("qrc:/controls/StackViewTransition.qml"), uri, 1, 0, "StackViewTransition"); + qmlRegisterType(QUrl("qrc:/controls/StatusBar.qml"), uri, 1, 0, "StatusBar"); + qmlRegisterType(QUrl("qrc:/controls/Tab.qml"), uri, 1, 0, "Tab"); + qmlRegisterType(QUrl("qrc:/controls/TableView.qml"), uri, 1, 0, "TableView"); + qmlRegisterType(QUrl("qrc:/controls/TableViewColumn.qml"), uri, 1, 0, "TableViewColumn"); + qmlRegisterType(QUrl("qrc:/controls/TextField.qml"), uri, 1, 0, "TextField"); + qmlRegisterType(QUrl("qrc:/controls/TabView.qml"), uri, 1, 0, "TabView"); + qmlRegisterType(QUrl("qrc:/controls/TextArea.qml"), uri, 1, 0, "TextArea"); + qmlRegisterType(QUrl("qrc:/controls/ToolBar.qml"), uri, 1, 0, "ToolBar"); + qmlRegisterType(QUrl("qrc:/controls/ToolButton.qml"), uri, 1, 0, "ToolButton"); } void QtQuickControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) diff --git a/src/controls/qmldir b/src/controls/qmldir index c243360c..41d4d512 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -1,28 +1,2 @@ module QtQuick.Controls plugin qtquickcontrolsplugin -ApplicationWindow 1.0 ApplicationWindow.qml -Button 1.0 Button.qml -CheckBox 1.0 CheckBox.qml -ComboBox 1.0 ComboBox.qml -GroupBox 1.0 GroupBox.qml -Label 1.0 Label.qml -MenuBar 1.0 MenuBar.qml -Menu 1.0 Menu.qml -StackView 1.0 StackView.qml -ProgressBar 1.0 ProgressBar.qml -RadioButton 1.0 RadioButton.qml -ScrollView 1.0 ScrollView.qml -Slider 1.0 Slider.qml -SpinBox 1.0 SpinBox.qml -SplitView 1.0 SplitView.qml -StackViewDelegate 1.0 StackViewDelegate.qml -StackViewTransition 1.0 StackViewTransition.qml -StatusBar 1.0 StatusBar.qml -Tab 1.0 Tab.qml -TabView 1.0 TabView.qml -TableView 1.0 TableView.qml -TableViewColumn 1.0 TableViewColumn.qml -TextArea 1.0 TextArea.qml -TextField 1.0 TextField.qml -ToolBar 1.0 ToolBar.qml -ToolButton 1.0 ToolButton.qml diff --git a/src/controls/resources.qrc b/src/controls/resources.qrc new file mode 100644 index 00000000..5cf71c61 --- /dev/null +++ b/src/controls/resources.qrc @@ -0,0 +1,30 @@ +<RCC> + <qresource prefix="/controls"> + <file>ApplicationWindow.qml</file> + <file>Button.qml</file> + <file>CheckBox.qml</file> + <file>ComboBox.qml</file> + <file>GroupBox.qml</file> + <file>Label.qml</file> + <file>Menu.qml</file> + <file>MenuBar.qml</file> + <file>ProgressBar.qml</file> + <file>RadioButton.qml</file> + <file>ScrollView.qml</file> + <file>Slider.qml</file> + <file>SpinBox.qml</file> + <file>SplitView.qml</file> + <file>StackView.qml</file> + <file>StackViewDelegate.qml</file> + <file>StackViewTransition.qml</file> + <file>StatusBar.qml</file> + <file>Tab.qml</file> + <file>TableView.qml</file> + <file>TableViewColumn.qml</file> + <file>TabView.qml</file> + <file>TextArea.qml</file> + <file>TextField.qml</file> + <file>ToolBar.qml</file> + <file>ToolButton.qml</file> + </qresource> +</RCC> diff --git a/src/private/FocusFrame.qml b/src/private/FocusFrame.qml index 3a07701c..b734a4ff 100644 --- a/src/private/FocusFrame.qml +++ b/src/private/FocusFrame.qml @@ -40,6 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype FocusFrame diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp index e33c2d37..3ae91d35 100644 --- a/src/private/plugin.cpp +++ b/src/private/plugin.cpp @@ -91,6 +91,17 @@ void QtQuickControlsPrivatePlugin::registerTypes(const char *uri) #ifndef QT_NO_WIDGETS qmlRegisterType<QQuickStyleItem>(uri, 1, 0, "StyleItem"); #endif + + qmlRegisterType(QUrl("qrc:/private/AbstractCheckable.qml"), uri, 1, 0, "AbstractCheckable"); + qmlRegisterType(QUrl("qrc:/private/BasicButton.qml"), uri, 1, 0, "BasicButton"); + qmlRegisterType(QUrl("qrc:/private/Control.qml"), uri, 1, 0, "Control"); + qmlRegisterType(QUrl("qrc:/private/FocusFrame.qml"), uri, 1, 0, "FocusFrame"); + qmlRegisterType(QUrl("qrc:/private/ModalPopupBehavior.qml"), uri, 1, 0, "ModalPopupBehavior"); + qmlRegisterType(QUrl("qrc:/private/ScrollBar.qml"), uri, 1, 0, "ScrollBar"); + qmlRegisterType(QUrl("qrc:/private/ScrollViewHelper.qml"), uri, 1, 0, "ScrollViewHelper"); + qmlRegisterType(QUrl("qrc:/private/StackViewSlideDelegate.qml"), uri, 1, 0, "StackViewSlideDelegate"); + qmlRegisterType(QUrl("qrc:/private/Style.qml"), uri, 1, 0, "Style"); + qmlRegisterType(QUrl("qrc:/private/TabBar.qml"), uri, 1, 0, "TabBar"); } QT_END_NAMESPACE diff --git a/src/private/private.pro b/src/private/private.pro index 803b703f..8e1767dd 100644 --- a/src/private/private.pro +++ b/src/private/private.pro @@ -23,7 +23,7 @@ SOURCES += \ $$PWD/qquickabstractstyle.cpp # private qml files -QML_FILES += \ +OTHER_FILES += \ AbstractCheckable.qml \ TabBar.qml \ BasicButton.qml \ @@ -50,3 +50,6 @@ mac { CONFIG += no_cxx_module load(qml_plugin) + +RESOURCES += \ + resources.qrc diff --git a/src/private/qmldir b/src/private/qmldir index 7f73028e..63919710 100644 --- a/src/private/qmldir +++ b/src/private/qmldir @@ -1,12 +1,7 @@ module QtQuick.Controls.Private plugin qtquickcontrolsprivateplugin -AbstractCheckable 1.0 AbstractCheckable.qml -Control 1.0 Control.qml -FocusFrame 1.0 FocusFrame.qml -Margins 1.0 Margins.qml -BasicButton 1.0 BasicButton.qml -ScrollBar 1.0 ScrollBar.qml -ScrollViewHelper 1.0 ScrollViewHelper.qml -Style 1.0 Style.qml -TabBar 1.0 TabBar.qml -StackViewSlideDelegate 1.0 StackViewSlideDelegate.qml +GroupBoxStyle 1.0 qrc:/Base/GroupBoxStyle.qml +SpinBoxStyle 1.0 qrc:/Base/SpinBoxStyle.qml +ToolBarStyle 1.0 qrc:/Base/ToolBarStyle.qml +StatusBarStyle 1.0 qrc:/Base/StatusBarStyle.qml +ToolButtonStyle 1.0 qrc:/Base/ToolButtonStyle.qml diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index e2daa17f..d2853982 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -63,18 +63,24 @@ static QString styleImportName() return QFileInfo(name).fileName(); } -static QString styleImportPath(QQmlEngine *engine, const QString &styleName) +static QString styleImportPath(QQmlEngine *engine, const QString &styleName, bool &fromResources) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); QFileInfo info(path); if (info.isRelative()) { + bool found = false; foreach (const QString &import, engine->importPathList()) { QDir dir(import + QLatin1String("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { + found = true; path = dir.absolutePath(); break; } } + if (!found) { + fromResources = true; + path = "qrc:"; + } } else { path = info.absolutePath(); } @@ -83,23 +89,27 @@ static QString styleImportPath(QQmlEngine *engine, const QString &styleName) QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) { + m_fromResources = false; m_name = styleImportName(); - m_path = styleImportPath(engine, m_name); + m_path = styleImportPath(engine, m_name, m_fromResources); - if (!QFile::exists(styleFilePath())) { + if (!m_fromResources && !QFile::exists(styleFilePath())) { QString unknownStyle = m_name; m_name = defaultStyleName(); - m_path = styleImportPath(engine, m_name); - qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); + m_path = styleImportPath(engine, m_name, m_fromResources); + qWarning() << "WARNING: Cannot find style" << unknownStyle << " locally - fallback:" << styleFilePath(); } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged())); } -QUrl QQuickControlSettings::style() const +QString QQuickControlSettings::style() const { - return QUrl::fromLocalFile(styleFilePath()); + if (m_fromResources) + return styleFilePath(); + else + return QUrl::fromLocalFile(styleFilePath()).toString(); } QString QQuickControlSettings::styleName() const diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h index 8ff0ecbf..e9ba4186 100644 --- a/src/private/qquickcontrolsettings_p.h +++ b/src/private/qquickcontrolsettings_p.h @@ -52,7 +52,7 @@ class QQmlEngine; class QQuickControlSettings : public QObject { Q_OBJECT - Q_PROPERTY(QUrl style READ style NOTIFY styleChanged) + Q_PROPERTY(QString style READ style NOTIFY styleChanged) Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged) Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged) Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT) @@ -60,7 +60,7 @@ class QQuickControlSettings : public QObject public: QQuickControlSettings(QQmlEngine *engine); - QUrl style() const; + QString style() const; QString styleName() const; void setStyleName(const QString &name); @@ -80,6 +80,7 @@ private: QString m_name; QString m_path; + bool m_fromResources; }; QT_END_NAMESPACE diff --git a/src/private/resources.qrc b/src/private/resources.qrc new file mode 100644 index 00000000..27ebfa13 --- /dev/null +++ b/src/private/resources.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/private"> + <file>AbstractCheckable.qml</file> + <file>BasicButton.qml</file> + <file>Control.qml</file> + <file>FocusFrame.qml</file> + <file>ModalPopupBehavior.qml</file> + <file>ScrollBar.qml</file> + <file>ScrollViewHelper.qml</file> + <file>StackView.js</file> + <file>StackViewSlideDelegate.qml</file> + <file>style.js</file> + <file>Style.qml</file> + <file>TabBar.qml</file> + </qresource> +</RCC> diff --git a/src/src.pro b/src/src.pro index 719a3c7b..2b70573c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs -SUBDIRS += controls styles private styles/private - +SUBDIRS += controls styles private SUBDIRS += layouts diff --git a/src/styles/Base/MenuBarStyle.qml b/src/styles/Base/MenuBarStyle.qml index 4effd6ee..571ebe12 100644 --- a/src/styles/Base/MenuBarStyle.qml +++ b/src/styles/Base/MenuBarStyle.qml @@ -40,7 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 -import "../../Private/style.js" as StyleHelpers +import "../private/style.js" as StyleHelpers /*! \qmltype MenuBarStyle diff --git a/src/styles/Base/MenuStyle.qml b/src/styles/Base/MenuStyle.qml index eab18f7d..e6fc49fb 100644 --- a/src/styles/Base/MenuStyle.qml +++ b/src/styles/Base/MenuStyle.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "../../Private/style.js" as StyleHelpers +import "../private/style.js" as StyleHelpers /*! \qmltype MenuStyle diff --git a/src/styles/plugin.cpp b/src/styles/plugin.cpp new file mode 100644 index 00000000..aedbfa5a --- /dev/null +++ b/src/styles/plugin.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQml> + +QT_BEGIN_NAMESPACE + +class QtQuickControlsStylesPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + +public: + void registerTypes(const char *uri); + void initializeEngine(QQmlEngine *engine, const char *uri); +}; + +void QtQuickControlsStylesPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(QUrl("qrc:/Base/ButtonStyle.qml"), uri, 1, 0, "ButtonStyle"); + qmlRegisterType(QUrl("qrc:/Base/CheckBoxStyle.qml"), uri, 1, 0, "CheckBoxStyle"); + qmlRegisterType(QUrl("qrc:/Base/ComboBoxStyle.qml"), uri, 1, 0, "ComboBoxStyle"); + qmlRegisterType(QUrl("qrc:/Base/ProgressBarStyle.qml"), uri, 1, 0, "ProgressBarStyle"); + qmlRegisterType(QUrl("qrc:/Base/RadioButtonStyle.qml"), uri, 1, 0, "RadioButtonStyle"); + qmlRegisterType(QUrl("qrc:/Base/ScrollViewStyle.qml"), uri, 1, 0, "ScrollViewStyle"); + qmlRegisterType(QUrl("qrc:/Base/SliderStyle.qml"), uri, 1, 0, "SliderStyle"); + qmlRegisterType(QUrl("qrc:/Base/TabViewStyle.qml"), uri, 1, 0, "TabViewStyle"); + qmlRegisterType(QUrl("qrc:/Base/TableViewStyle.qml"), uri, 1, 0, "TableViewStyle"); + qmlRegisterType(QUrl("qrc:/Base/TextFieldStyle.qml"), uri, 1, 0, "TextFieldStyle"); +} + +void QtQuickControlsStylesPlugin::initializeEngine(QQmlEngine *engine, const char *uri) +{ + Q_UNUSED(uri) + engine->addPluginPath("qrc:/Base"); +} + +QT_END_NAMESPACE + +#include "plugin.moc" diff --git a/src/styles/private/private.pro b/src/styles/private/private.pro deleted file mode 100644 index 9a5bcd1e..00000000 --- a/src/styles/private/private.pro +++ /dev/null @@ -1,3 +0,0 @@ -TARGETPATH = QtQuick/Controls/Styles/Private - -load(qml_module) diff --git a/src/styles/private/qmldir b/src/styles/private/qmldir deleted file mode 100644 index 4d1885d5..00000000 --- a/src/styles/private/qmldir +++ /dev/null @@ -1,7 +0,0 @@ -module QtQuick.Controls.Styles.Private - -GroupBoxStyle 1.0 ../Base/GroupBoxStyle.qml -SpinBoxStyle 1.0 ../Base/SpinBoxStyle.qml -ToolBarStyle 1.0 ../Base/ToolBarStyle.qml -StatusBarStyle 1.0 ../Base/StatusBarStyle.qml -ToolButtonStyle 1.0 ../Base/ToolButtonStyle.qml diff --git a/src/styles/qmldir b/src/styles/qmldir index 5077542a..43812858 100644 --- a/src/styles/qmldir +++ b/src/styles/qmldir @@ -1,11 +1,2 @@ module QtQuick.Controls.Styles -ButtonStyle 1.0 Base/ButtonStyle.qml -CheckBoxStyle 1.0 Base/CheckBoxStyle.qml -ComboBoxStyle 1.0 Base/ComboBoxStyle.qml -ProgressBarStyle 1.0 Base/ProgressBarStyle.qml -RadioButtonStyle 1.0 Base/RadioButtonStyle.qml -ScrollViewStyle 1.0 Base/ScrollViewStyle.qml -SliderStyle 1.0 Base/SliderStyle.qml -TabViewStyle 1.0 Base/TabViewStyle.qml -TableViewStyle 1.0 Base/TableViewStyle.qml -TextFieldStyle 1.0 Base/TextFieldStyle.qml +plugin qtquickcontrolsstylesplugin diff --git a/src/styles/resources.qrc b/src/styles/resources.qrc new file mode 100644 index 00000000..3eef2631 --- /dev/null +++ b/src/styles/resources.qrc @@ -0,0 +1,61 @@ +<RCC> + <qresource prefix="/Base"> + <file alias="images/arrow-down.png">Base/images/arrow-down.png</file> + <file alias="images/arrow-down@2x.png">Base/images/arrow-down@2x.png</file> + <file alias="images/arrow-left.png">Base/images/arrow-left.png</file> + <file alias="images/arrow-left@2x.png">Base/images/arrow-left@2x.png</file> + <file alias="images/arrow-right.png">Base/images/arrow-right.png</file> + <file alias="images/arrow-right@2x.png">Base/images/arrow-right@2x.png</file> + <file alias="images/arrow-up.png">Base/images/arrow-up.png</file> + <file alias="images/arrow-up@2x.png">Base/images/arrow-up@2x.png</file> + <file alias="images/button_down.png">Base/images/button_down.png</file> + <file alias="images/button.png">Base/images/button.png</file> + <file alias="images/editbox.png">Base/images/editbox.png</file> + <file alias="images/focusframe.png">Base/images/focusframe.png</file> + <file alias="images/groupbox.png">Base/images/groupbox.png</file> + <file alias="images/header.png">Base/images/header.png</file> + <file alias="images/progress-indeterminate.png">Base/images/progress-indeterminate.png</file> + <file alias="images/scrollbar-handle-horizontal.png">Base/images/scrollbar-handle-horizontal.png</file> + <file alias="images/scrollbar-handle-vertical.png">Base/images/scrollbar-handle-vertical.png</file> + <file alias="images/tab_selected.png">Base/images/tab_selected.png</file> + <file alias="images/tab.png">Base/images/tab.png</file> + <file alias="ButtonStyle.qml">Base/ButtonStyle.qml</file> + <file alias="CheckBoxStyle.qml">Base/CheckBoxStyle.qml</file> + <file alias="ComboBoxStyle.qml">Base/ComboBoxStyle.qml</file> + <file alias="FocusFrameStyle.qml">Base/FocusFrameStyle.qml</file> + <file alias="GroupBoxStyle.qml">Base/GroupBoxStyle.qml</file> + <file alias="MenuBarStyle.qml">Base/MenuBarStyle.qml</file> + <file alias="MenuStyle.qml">Base/MenuStyle.qml</file> + <file alias="ProgressBarStyle.qml">Base/ProgressBarStyle.qml</file> + <file alias="RadioButtonStyle.qml">Base/RadioButtonStyle.qml</file> + <file alias="ScrollViewStyle.qml">Base/ScrollViewStyle.qml</file> + <file alias="SliderStyle.qml">Base/SliderStyle.qml</file> + <file alias="SpinBoxStyle.qml">Base/SpinBoxStyle.qml</file> + <file alias="StatusBarStyle.qml">Base/StatusBarStyle.qml</file> + <file alias="TableViewStyle.qml">Base/TableViewStyle.qml</file> + <file alias="TabViewStyle.qml">Base/TabViewStyle.qml</file> + <file alias="TextFieldStyle.qml">Base/TextFieldStyle.qml</file> + <file alias="ToolBarStyle.qml">Base/ToolBarStyle.qml</file> + <file alias="ToolButtonStyle.qml">Base/ToolButtonStyle.qml</file> + </qresource> + <qresource prefix="/Desktop"> + <file alias="ButtonStyle.qml">Desktop/ButtonStyle.qml</file> + <file alias="CheckBoxStyle.qml">Desktop/CheckBoxStyle.qml</file> + <file alias="ComboBoxStyle.qml">Desktop/ComboBoxStyle.qml</file> + <file alias="FocusFrameStyle.qml">Desktop/FocusFrameStyle.qml</file> + <file alias="GroupBoxStyle.qml">Desktop/GroupBoxStyle.qml</file> + <file alias="MenuBarStyle.qml">Desktop/MenuBarStyle.qml</file> + <file alias="MenuStyle.qml">Desktop/MenuStyle.qml</file> + <file alias="ProgressBarStyle.qml">Desktop/ProgressBarStyle.qml</file> + <file alias="RadioButtonStyle.qml">Desktop/RadioButtonStyle.qml</file> + <file alias="ScrollViewStyle.qml">Desktop/ScrollViewStyle.qml</file> + <file alias="SliderStyle.qml">Desktop/SliderStyle.qml</file> + <file alias="SpinBoxStyle.qml">Desktop/SpinBoxStyle.qml</file> + <file alias="StatusBarStyle.qml">Desktop/StatusBarStyle.qml</file> + <file alias="TableViewStyle.qml">Desktop/TableViewStyle.qml</file> + <file alias="TabViewStyle.qml">Desktop/TabViewStyle.qml</file> + <file alias="TextFieldStyle.qml">Desktop/TextFieldStyle.qml</file> + <file alias="ToolBarStyle.qml">Desktop/ToolBarStyle.qml</file> + <file alias="ToolButtonStyle.qml">Desktop/ToolButtonStyle.qml</file> + </qresource> +</RCC> diff --git a/src/styles/styles.pro b/src/styles/styles.pro index 158c1dd1..0e016ae0 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -1,9 +1,12 @@ +TARGET = qtquickcontrolsstylesplugin TARGETPATH = QtQuick/Controls/Styles +QT += qml quick gui-private core-private + QMAKE_DOCS = $$PWD/doc/qtquickcontrolsstyles.qdocconf # Base -QML_FILES = \ +OTHER_FILES = \ Base/ButtonStyle.qml \ Base/CheckBoxStyle.qml \ Base/ComboBoxStyle.qml \ @@ -24,7 +27,7 @@ QML_FILES = \ Base/ToolButtonStyle.qml # Desktop -QML_FILES += \ +OTHER_FILES += \ Desktop/ButtonStyle.qml \ Desktop/CheckBoxStyle.qml \ Desktop/ComboBoxStyle.qml \ @@ -45,7 +48,7 @@ QML_FILES += \ Desktop/ToolButtonStyle.qml # Images -QML_FILES += \ +OTHER_FILES += \ Base/images/button.png \ Base/images/button_down.png \ Base/images/tab.png \ @@ -66,4 +69,11 @@ QML_FILES += \ Base/images/arrow-right.png \ Base/images/arrow-right@2x.png -load(qml_module) +SOURCES += \ + $$PWD/plugin.cpp + +RESOURCES += \ + $$PWD/resources.qrc + +CONFIG += no_cxx_module +load(qml_plugin) diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 6753868c..39f76a1e 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -91,7 +91,7 @@ TestCase { function test_dynamicSize() { - var groupbox = Qt.createQmlObject('import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0 ; GroupBox {style:GroupBoxStyle{}}', container, '') + var groupbox = Qt.createQmlObject('import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0 ; GroupBox {style:GroupBoxStyle{}}', container, '') compare(groupbox.width, 16) compare(groupbox.height, 16) diff --git a/tests/auto/controls/data/tst_styles.qml b/tests/auto/controls/data/tst_styles.qml index 233c4a2e..f6b53b72 100644 --- a/tests/auto/controls/data/tst_styles.qml +++ b/tests/auto/controls/data/tst_styles.qml @@ -62,7 +62,7 @@ Item { function test_createToolButtonStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: ToolButtonStyle {}}' , container, '') } @@ -111,21 +111,21 @@ Item { function test_createSpinBoxStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: SpinBoxStyle {}}' , container, '') } function test_createToolBarStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: ToolBarStyle {}}' , container, '') } function test_createStatusBarStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: StatusBarStyle {}}' , container, '') } @@ -146,7 +146,7 @@ Item { function test_createGroupBoxStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: GroupBoxStyle {}}' , container, '') } diff --git a/tests/manual/testbench/content/Components.qml b/tests/manual/testbench/content/Components.qml index b497230d..23527ccd 100644 --- a/tests/manual/testbench/content/Components.qml +++ b/tests/manual/testbench/content/Components.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 -import QtQuick.Controls.Styles.Private 1.0 +import QtQuick.Controls.Private 1.0 Item { property Component button: Button { text: "Push me"} |