diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml index d8f175ed17a1bd703b239ed42a79bcc5a76cf6d1..b2b863e28b23d9d0ea377abc399986e28f1fac34 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 0a3cb131620e03274b2950f6198206092396aef6..efafe26bce81876096e5fc0bcdea9698c5cede3a 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 48d5e8b2acd2273e9693e80c1b348abd8446c5e4..9d6f5dfeda0d37550d7e057a9737c42da2fe9704 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 9282c58d8cd6d8128f4827e683cae8f8de42bd2d..b65e749a6beb9d00a9f7ddd96249c88e67c384e7 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 65af1c124cda7eadc91e5299a7998a0294d42ff1..566c814f7f6190bcdd0b16fa5a4203d56a0448ce 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 e472e66e0a44c3b43339706c177eeb5d61995994..2270ff49d9611f953221d95d8ab3de9a18eca447 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 fde08817b243677278f422644e22f5e39da17f55..305e464c8df192a54dafd5bff432e680da761a39 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 64dcfff1d4ad36c62bcccf7e5ccdcb0cdfefb970..9fee75e6426a94f6f1255f849da1aece54446cbf 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 b1f87cec7d0bbb1521afc7fa3a3af9e80ccca4a5..06ec64ceeec7e7695af864874f591f04b8bde3e4 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 9559ea87248b9895f26130a853a80f5a2b5d88ef..623a1026f4b495f478f06f252f7dd8eaeaa07585 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 85cc6681c4adc82756bef68952a07e3bd791d319..62b81807742934fce8d551e9aa4cfafb0a471467 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 6319d72cd712fcc2ac077776ca6c3a4c948d7ef6..503a203e68cfd5af05d38f278993b662cf0804a2 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 32b2d4fb2c5c6dd6200a9a9dd17a33a3983a52ea..b7e6996e819cc3c3c84df0bfd8a86efee81086e6 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 b73a6f3ebcb8bfe07799253dfb9308d54efd33d7..cadea5c763e0bf391b500c9e0d54ee0258708dc1 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 3c1eab1a6a256f4704cc5e1e623286d47fcd49b7..3cf327898cc01ba8ecadea7a2038e2680b123b08 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 fbda88fcc199a8c49577bb71b109f38111663a35..fad8f2d9ab5881a385db1714e87ef7db8a7e6287 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 1b255302a0cc413b097ce297405d6f0fa1f1baca..71cc3196e956208aa56c2e117f5656fed1b66b11 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 c243360cd7bf2cf832fd882a2cf6318a51fb488f..41d4d512296f41702d59f797dd9730a91c7fbbc3 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 0000000000000000000000000000000000000000..5cf71c61394faeb872664c24729bfabf33573f98 --- /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 3a07701c5d2a1afe4f3d0b17ec3d38f6f3363272..b734a4ff1eb8a96439b6f89fe3da1a5c95e39791 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 e33c2d375dcf87d1222756986e32d26241c1e93e..3ae91d35f35e506856c720ad967bfffcaad2dbba 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 803b703f4a9569ed1862c0a506bee52a7c69f586..8e1767dd76b3e6bcd11922ff38877282975bc388 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 7f73028e07498f1a945d568df2415cdad81c7cf0..639197109e36ca62d61613654fd9d51e56026806 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 e2daa17fa450d022c1fa3daf655bb127a33edef5..d2853982eefa75f7578c0b7dfc2c790f1a8dae86 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 8ff0ecbf5ca53abf65e4167a4475c00cc57cffb1..e9ba41860df40b789f0986b5c8f7b50a6e156918 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 0000000000000000000000000000000000000000..27ebfa137f44ae85722653913d47764519b75430 --- /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 719a3c7b5ee4ded30633c009352f0671b1091900..2b70573c4f999d3d5d042d7acdad6733a0b4e61f 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 4effd6eecf3bb054b9e6018cf79307fa3c904869..571ebe12c5fc0b9c9ccdbef177681c344cdfe7b0 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 eab18f7df8ed468c329e754d1162ff9b19d79d30..e6fc49fbb0b472567c25e07bd1e6ea65300f08be 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 0000000000000000000000000000000000000000..aedbfa5a67644bb4f0d797dd10464ccdc63a8af7 --- /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 9a5bcd1edf3c05be453a795b339d7cac51fc9e82..0000000000000000000000000000000000000000 --- 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 4d1885d5ee2422940bfd5023d639fb3930baab8e..0000000000000000000000000000000000000000 --- 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 5077542a56a0798378916f269a0c98abb4fa99a6..43812858a5d09b6729dd127de04238d08a1a80e9 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 0000000000000000000000000000000000000000..3eef2631cb96b8f9c82e50201387c2111762299c --- /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 158c1dd135da11189ab3a613dc3ebbebe7831f7d..0e016ae0bf14792331bd080e067cf1569ed2cf2a 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 6753868c27a14849b37202feacead9f97ec96806..39f76a1e8c2b5bf62d5aa4c74616583764e94415 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 233c4a2ebfda6741d056e3ed265a027c5a319127..f6b53b7229065822e3cb1d983610e743cee3cba1 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 b497230d62eb8d20d327c70836304c9b8e600a2d..23527ccdb6db6b2f089c4072d0318443f5cd14af 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"}