diff options
47 files changed, 329 insertions, 113 deletions
diff --git a/examples/ApplicationTemplate/ApplicationTemplate.pro b/examples/ApplicationTemplate/ApplicationTemplate.pro index d623dff9..f877756d 100644 --- a/examples/ApplicationTemplate/ApplicationTemplate.pro +++ b/examples/ApplicationTemplate/ApplicationTemplate.pro @@ -1,7 +1,6 @@ -QT += widgets qml quick +QT += qml quick widgets CONFIG += console TARGET = application - SOURCES += \ main.cpp diff --git a/examples/examples.pro b/examples/examples.pro index e3c3a203..0be155cd 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,10 +1,13 @@ TEMPLATE = subdirs SUBDIRS += \ - ApplicationTemplate \ gallery \ splitview \ stackview \ tableview \ - text \ touch + +qtHaveModule(widgets) { + SUBDIRS += text \ + ApplicationTemplate +} diff --git a/examples/text/text.pro b/examples/text/text.pro index 8b36231a..3b5b1046 100644 --- a/examples/text/text.pro +++ b/examples/text/text.pro @@ -1,6 +1,9 @@ -QT += widgets qml quick +QT += qml quick CONFIG += console TARGET = text +qtHaveModule(widgets) { + QT += widgets +} include(src/src.pri) diff --git a/qtquickcontrols.pro b/qtquickcontrols.pro index a4ca1464..bc5ed5e8 100644 --- a/qtquickcontrols.pro +++ b/qtquickcontrols.pro @@ -1,5 +1,3 @@ -requires(qtHaveModule(widgets)) - load(qt_parts) # We need accessibility diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 5249d21f..2b5df56a 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype Button @@ -87,5 +86,5 @@ BasicButton { Accessible.name: text - style: Qt.createComponent(Settings.THEME_PATH + "/ButtonStyle.qml", button) + style: Qt.createComponent(Settings.theme() + "/ButtonStyle.qml", button) } diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml index 7f03573e..8b3ce5ea 100644 --- a/src/controls/CheckBox.qml +++ b/src/controls/CheckBox.qml @@ -42,8 +42,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings - /*! \qmltype CheckBox \inqmlmodule QtQuick.Controls 1.0 @@ -130,7 +128,7 @@ AbstractCheckable { */ property bool __ignoreChecked: false - style: Qt.createComponent(Settings.THEME_PATH + "/CheckBoxStyle.qml", checkBox) + style: Qt.createComponent(Settings.theme() + "/CheckBoxStyle.qml", checkBox) activeFocusOnTab: true diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 53ff46e3..f1b3978d 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype ComboBox @@ -91,7 +90,7 @@ Control { /*! \internal */ property alias __containsMouse: mouseArea.containsMouse - style: Qt.createComponent(Settings.THEME_PATH + "/ComboBoxStyle.qml", comboBox) + style: Qt.createComponent(Settings.theme() + "/ComboBoxStyle.qml", comboBox) activeFocusOnTab: true diff --git a/src/controls/GroupBox.qml b/src/controls/GroupBox.qml index d67dc216..6aa94e09 100644 --- a/src/controls/GroupBox.qml +++ b/src/controls/GroupBox.qml @@ -40,8 +40,8 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 +import QtQuick.Controls.Private 1.0 import QtQuick.Controls.Styles 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype GroupBox @@ -138,7 +138,7 @@ Item { property real contentHeight: content.childrenRect.height /*! \internal */ - property Component style: Qt.createComponent(Settings.THEME_PATH + "/GroupBoxStyle.qml", groupbox) + property Component style: Qt.createComponent(Settings.theme() + "/GroupBoxStyle.qml", groupbox) /*! \internal */ default property alias data: content.data diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml index 1df73356..a65f76e3 100644 --- a/src/controls/Menu.qml +++ b/src/controls/Menu.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 -import "Styles/Settings.js" as Settings +import QtQuick.Controls.Private 1.0 /*! \qmltype Menu @@ -129,7 +129,7 @@ MenuPrivate { property Component __selfComponent: null /*! \internal */ - property Component style: Qt.createComponent(Settings.THEME_PATH + "/MenuStyle.qml", root) + property Component style: Qt.createComponent(Settings.theme() + "/MenuStyle.qml", root) /*! \internal */ property var __menuBar: null diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml index 43ff1562..226e304e 100644 --- a/src/controls/MenuBar.qml +++ b/src/controls/MenuBar.qml @@ -42,7 +42,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype MenuBar @@ -74,7 +73,7 @@ MenuBarPrivate { id: root /*! \internal */ - property Component style: Qt.createComponent(Settings.THEME_PATH + "/MenuBarStyle.qml", root) + property Component style: Qt.createComponent(Settings.theme() + "/MenuBarStyle.qml", root) /*! \internal */ __contentItem: Loader { diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index 340d5777..b379bb8b 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype ProgressBar @@ -97,7 +96,7 @@ Control { property int orientation: Qt.Horizontal /*! \internal */ - style: Qt.createComponent(Settings.THEME_PATH + "/ProgressBarStyle.qml", progressbar) + style: Qt.createComponent(Settings.theme() + "/ProgressBarStyle.qml", progressbar) /*! \internal */ property bool __initialized: false diff --git a/src/controls/RadioButton.qml b/src/controls/RadioButton.qml index 87f57257..e3173934 100644 --- a/src/controls/RadioButton.qml +++ b/src/controls/RadioButton.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype RadioButton @@ -87,7 +86,7 @@ AbstractCheckable { \codeline Qt.createComponent("path/to/style.qml", radioButtonId); */ - style: Qt.createComponent(Settings.THEME_PATH + "/RadioButtonStyle.qml", radioButton) + style: Qt.createComponent(Settings.theme() + "/RadioButtonStyle.qml", radioButton) __cycleStatesHandler: function() { checked = !checked; } } diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index a218b546..3ce2054a 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -42,7 +42,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 import QtQuick.Controls.Styles 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype ScrollView @@ -140,7 +139,7 @@ FocusScope { /*! \internal */ property alias verticalScrollBar: scroller.verticalScrollBar /*! \internal */ - property Component style: Qt.createComponent(Settings.THEME_PATH + "/ScrollViewStyle.qml", root) + property Component style: Qt.createComponent(Settings.theme() + "/ScrollViewStyle.qml", root) /* \internal */ property Style __style: styleLoader.item diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 0493d934..3cc51119 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype Slider @@ -181,7 +180,7 @@ Control { return Math.round(v); } - style: Qt.createComponent(Settings.THEME_PATH + "/SliderStyle.qml", slider) + style: Qt.createComponent(Settings.theme() + "/SliderStyle.qml", slider) Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0 Keys.onLeftPressed: value -= (maximumValue - minimumValue)/10.0 diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 3eb16b58..ebcf82e6 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype SpinBox @@ -131,7 +130,7 @@ Control { */ property bool activeFocusOnPress: true - style: Qt.createComponent(Settings.THEME_PATH + "/SpinBoxStyle.qml", spinbox) + style: Qt.createComponent(Settings.theme() + "/SpinBoxStyle.qml", spinbox) /*! \internal */ function __increment() { diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml index 02ac5ab8..cd905179 100644 --- a/src/controls/StatusBar.qml +++ b/src/controls/StatusBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype StatusBar @@ -72,7 +71,7 @@ Item { Accessible.role: Accessible.StatusBar implicitWidth: parent ? parent.width : loader.item ? loader.item.implicitHeight : 0 implicitHeight: loader.item ? loader.item.implicitHeight : 0 - property Component style: Qt.createComponent(Settings.THEME_PATH + "/StatusBarStyle.qml", statusbar) + property Component style: Qt.createComponent(Settings.theme() + "/StatusBarStyle.qml", statusbar) Loader { id: loader anchors.fill: parent diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index 88336eee..1ff28392 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype TabView @@ -126,7 +125,7 @@ FocusScope { property var __tabs: new Array() /*! \internal */ - property Component style: Qt.createComponent(Settings.THEME_PATH + "/TabViewStyle.qml", root) + property Component style: Qt.createComponent(Settings.theme() + "/TabViewStyle.qml", root) /*! \internal */ property var __styleItem: loader.item diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 1dc5602c..22e7e052 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype TableView @@ -225,7 +224,7 @@ ScrollView { signal activated - style: Qt.createComponent(Settings.THEME_PATH + "/TableViewStyle.qml", root) + style: Qt.createComponent(Settings.theme() + "/TableViewStyle.qml", root) Accessible.role: Accessible.Table diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 9ec60fd5..7ce75ee9 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -42,7 +42,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 import "Styles" -import "Styles/Settings.js" as Settings /*! \qmltype TextField @@ -530,7 +529,7 @@ Control { /*! \internal */ property alias __contentWidth: textInput.contentWidth - style: Qt.createComponent(Settings.THEME_PATH + "/TextFieldStyle.qml", textInput) + style: Qt.createComponent(Settings.theme() + "/TextFieldStyle.qml", textInput) activeFocusOnTab: true diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index ffbf16e1..74c6433a 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype ToolBar @@ -75,7 +74,7 @@ Item { Accessible.role: Accessible.ToolBar implicitWidth: loader.item ? loader.item.implicitWidth : 0 implicitHeight: loader.item ? loader.item.implicitHeight : 0 - property Component style: Qt.createComponent(Settings.THEME_PATH + "/ToolBarStyle.qml", toolbar) + property Component style: Qt.createComponent(Settings.theme() + "/ToolBarStyle.qml", toolbar) Loader { id: loader anchors.fill: parent diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 445ab96b..3116e76e 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles/Settings.js" as Settings /*! \qmltype ToolButton @@ -78,5 +77,5 @@ BasicButton { Accessible.name: text - style: Qt.createComponent(Settings.THEME_PATH + "/ToolButtonStyle.qml", button) + style: Qt.createComponent(Settings.theme() + "/ToolButtonStyle.qml", button) } diff --git a/src/controls/controls.pro b/src/controls/controls.pro index a57e9991..369329e1 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -1,7 +1,7 @@ TARGET = plugin TARGETPATH = QtQuick/Controls -QT += qml quick widgets gui-private core-private +QT += qml quick gui-private core-private QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h index dd26b1d6..cd1d785e 100644 --- a/src/layouts/qquickgridlayoutengine_p.h +++ b/src/layouts/qquickgridlayoutengine_p.h @@ -56,7 +56,6 @@ #include "qgridlayoutengine_p.h" #include "qquickitem.h" #include "qquicklayout_p.h" -#include <QtWidgets/qsizepolicy.h> #include "qdebug.h" QT_BEGIN_NAMESPACE diff --git a/src/private/Control.qml b/src/private/Control.qml index 06bcdce6..624b14f1 100644 --- a/src/private/Control.qml +++ b/src/private/Control.qml @@ -76,6 +76,7 @@ FocusScope { Loader { id: styleLoader sourceComponent: style + property Item control: root onStatusChanged: { if (status === Loader.Error) console.error("Failed to load Style for", root) diff --git a/src/private/FocusFrame.qml b/src/private/FocusFrame.qml index 08f4b04a..52c11438 100644 --- a/src/private/FocusFrame.qml +++ b/src/private/FocusFrame.qml @@ -42,17 +42,26 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 /*! - \qmltype FocusFrame - \internal - \inqmlmodule QtQuick.Controls.Private 1.0 + \qmltype FocusFrame + \internal + \inqmlmodule QtQuick.Controls.Private 1.0 */ -StyleItem { - z: 2 - anchors.fill: parent - property int focusMargin: -3 +Item { + id: root + activeFocusOnTab: false + Accessible.role: Accessible.StatusBar + anchors.topMargin: focusMargin anchors.leftMargin: focusMargin anchors.rightMargin: focusMargin anchors.bottomMargin: focusMargin - elementType: "focusframe" + + property int focusMargin: loader.item ? loader.item.margin : -3 + + Loader { + id: loader + z: 2 + anchors.fill: parent + sourceComponent: Qt.createComponent( "../" + Settings.theme() + "/FocusFrameStyle.qml", root) + } } diff --git a/src/private/ScrollBar.qml b/src/private/ScrollBar.qml index d11fcef6..e5a29387 100644 --- a/src/private/ScrollBar.qml +++ b/src/private/ScrollBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "../Styles/Settings.js" as Settings /*! \qmltype ScrollBar @@ -56,7 +55,7 @@ Item { property alias maximumValue: slider.maximumValue property alias value: slider.value - property Component style: Qt.createComponent("../" + Settings.THEME_PATH + "/ScrollBarStyle.qml", scrollbar) + property Component style: Qt.createComponent("../" + Settings.theme() + "/ScrollBarStyle.qml", scrollbar) property alias styleItem: loader.item activeFocusOnTab: false diff --git a/src/private/ScrollViewHelper.qml b/src/private/ScrollViewHelper.qml index ec0194c2..3e3b4f96 100644 --- a/src/private/ScrollViewHelper.qml +++ b/src/private/ScrollViewHelper.qml @@ -99,16 +99,15 @@ Item { } } - StyleItem { - // This is the filled corner between scrollbars + Loader { id: cornerFill - elementType: "scrollareacorner" - width: visible ? vscrollbar.width : 0 + sourceComponent: __style.corner anchors.right: parent.right - height: visible ? hscrollbar.height : 0 anchors.bottom: parent.bottom anchors.bottomMargin: frameMargin anchors.rightMargin: frameMargin + width: visible ? vscrollbar.width : 0 + height: visible ? hscrollbar.height : 0 visible: hscrollbar.visible && !hscrollbar.isTransient && vscrollbar.visible && !vscrollbar.isTransient } diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp index 17b2b09b..34486de1 100644 --- a/src/private/plugin.cpp +++ b/src/private/plugin.cpp @@ -43,6 +43,11 @@ #include "qquickwheelarea_p.h" #include "qquickstyleitem_p.h" #include "qquicktooltip_p.h" +#include "qquickcontrolsettings_p.h" + +#ifndef QT_NO_WIDGETS +#include "qquickstyleitem_p.h" +#endif #include <qqml.h> #include <qqmlextensionplugin.h> @@ -56,6 +61,13 @@ static QObject *registerTooltipModule(QQmlEngine *engine, QJSEngine *jsEngine) return new QQuickTooltip(); } +static QObject *registerSettingsModule(QQmlEngine *engine, QJSEngine *jsEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(jsEngine); + return new QQuickControlSettings(); +} + class QtQuickControlsPrivatePlugin : public QQmlExtensionPlugin { Q_OBJECT @@ -69,8 +81,11 @@ void QtQuickControlsPrivatePlugin::registerTypes(const char *uri) { qmlRegisterType<QQuickRangeModel>(uri, 1, 0, "RangeModel"); qmlRegisterType<QQuickWheelArea>(uri, 1, 0, "WheelArea"); - qmlRegisterType<QQuickStyleItem>(uri, 1, 0, "StyleItem"); qmlRegisterSingletonType<QQuickTooltip>(uri, 1, 0, "Tooltip", registerTooltipModule); + qmlRegisterSingletonType<QQuickControlSettings>(uri, 1, 0, "Settings", registerSettingsModule); +#ifndef QT_NO_WIDGETS + qmlRegisterType<QQuickStyleItem>(uri, 1, 0, "StyleItem"); +#endif } QT_END_NAMESPACE diff --git a/src/private/private.pro b/src/private/private.pro index 09d9bacf..8c77dd45 100644 --- a/src/private/private.pro +++ b/src/private/private.pro @@ -1,20 +1,20 @@ TARGET = privateplugin TARGETPATH = QtQuick/Controls/Private -QT += qml quick widgets gui-private core-private +QT += qml quick gui-private core-private HEADERS += \ $$PWD/qquicktooltip_p.h \ $$PWD/qquickrangemodel_p.h \ $$PWD/qquickrangemodel_p_p.h \ - $$PWD/qquickwheelarea_p.h \ - $$PWD/qquickstyleitem_p.h + $$PWD/qquickcontrolsettings_p.h \ + $$PWD/qquickwheelarea_p.h SOURCES += \ $$PWD/plugin.cpp \ $$PWD/qquicktooltip.cpp \ - $$PWD/qquickstyleitem.cpp \ $$PWD/qquickrangemodel.cpp \ + $$PWD/qquickcontrolsettings.cpp \ $$PWD/qquickwheelarea.cpp # private qml files @@ -30,6 +30,13 @@ QML_FILES += \ ScrollBar.qml \ FocusFrame.qml + +qtHaveModule(widgets) { + QT += widgets + HEADERS += $$PWD/qquickstyleitem_p.h + SOURCES += $$PWD/qquickstyleitem.cpp +} + mac { LIBS += -framework Carbon } diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp new file mode 100644 index 00000000..3b3744fc --- /dev/null +++ b/src/private/qquickcontrolsettings.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 "qquickcontrolsettings_p.h" +#include <qquickitem.h> +#include <qcoreapplication.h> + +QT_BEGIN_NAMESPACE + +QQuickControlSettings::QQuickControlSettings(QObject *parent) + : QObject(parent) +{ +} + +QString QQuickControlSettings::theme() +{ + static QString currentTheme; + if (currentTheme.isEmpty()) { + currentTheme = QLatin1String("Styles"); +#ifndef QT_NO_WIDGETS + // Only enable QStyle support when we are using QApplication + if (QCoreApplication::instance()->inherits("QApplication")) + currentTheme = QLatin1String("Styles/Desktop"); +#endif + } + return currentTheme; +} + +QT_END_NAMESPACE diff --git a/src/styles/Settings.js b/src/private/qquickcontrolsettings_p.h index 683e4363..ea2811be 100644 --- a/src/styles/Settings.js +++ b/src/private/qquickcontrolsettings_p.h @@ -38,5 +38,24 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -.pragma library -var THEME_PATH = "Styles/Desktop" + +#ifndef QQUICKCONTROLSETTINGS_P_H +#define QQUICKCONTROLSETTINGS_P_H + +#include <QtCore/qobject.h> + +QT_BEGIN_NAMESPACE + +class QQuickControlSettings : public QObject +{ + Q_OBJECT + +public: + QQuickControlSettings(QObject *parent = 0); + + Q_INVOKABLE QString theme(); +}; + +QT_END_NAMESPACE + +#endif // QQUICKCONTROLSETTINGS_P_H diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp index 7c38794d..4a673579 100644 --- a/src/private/qquickstyleitem.cpp +++ b/src/private/qquickstyleitem.cpp @@ -132,17 +132,6 @@ QQuickStyleItem::QQuickStyleItem(QQuickItem *parent) m_contentHeight(0) { - // Check on QApplication, allowing for "qmlplugindump" to query our interfaces. - QCoreApplication *coreApp = QCoreApplication::instance(); - Q_ASSERT(coreApp); - if (!qobject_cast<QApplication *>(coreApp)) { - if (QCoreApplication::applicationFilePath().contains(QLatin1String("qmlplugindump"), Qt::CaseInsensitive)) - return; - qWarning("\nError: No widget style available. \n\nQt Quick Controls" - "currently depend on the widget module to function. \n" - "Use QApplication when creating standalone executables.\n\n"); - exit(-1); - } m_font = qApp->font(); setFlag(QQuickItem::ItemHasContents, true); setSmooth(false); diff --git a/src/private/qquicktooltip.cpp b/src/private/qquicktooltip.cpp index cc694b88..e76fa3ad 100644 --- a/src/private/qquicktooltip.cpp +++ b/src/private/qquicktooltip.cpp @@ -40,11 +40,13 @@ ****************************************************************************/ #include "qquicktooltip_p.h" - -#include <qtooltip.h> #include <qquickwindow.h> #include <qquickitem.h> +#ifndef QT_NO_WIDGETS +#include <qtooltip.h> +#endif + QT_BEGIN_NAMESPACE QQuickTooltip::QQuickTooltip(QObject *parent) @@ -57,13 +59,20 @@ void QQuickTooltip::showText(QQuickItem *item, const QPointF &pos, const QString { if (!item || !item->window()) return; - +#ifndef QT_NO_WIDGETS QToolTip::showText(item->window()->mapToGlobal(item->mapToScene(pos).toPoint()), str); +#else + Q_UNUSED(item); + Q_UNUSED(pos); + Q_UNUSED(str); +#endif } void QQuickTooltip::hideText() { +#ifndef QT_NO_WIDGETS QToolTip::hideText(); +#endif } QT_END_NAMESPACE diff --git a/src/styles/Desktop/FocusFrameStyle.qml b/src/styles/Desktop/FocusFrameStyle.qml new file mode 100644 index 00000000..420a0ab5 --- /dev/null +++ b/src/styles/Desktop/FocusFrameStyle.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Private 1.0 + +/*! + \qmltype FocusFrameStyle + \internal + \inqmlmodule QtQuick.Controls.Styles 1.0 +*/ +StyleItem { + property int margin: -3 + anchors.fill: parent + elementType: "focusframe" +} + + diff --git a/src/styles/Desktop/ScrollViewStyle.qml b/src/styles/Desktop/ScrollViewStyle.qml index 375579f8..a8c35c14 100644 --- a/src/styles/Desktop/ScrollViewStyle.qml +++ b/src/styles/Desktop/ScrollViewStyle.qml @@ -58,4 +58,5 @@ Style { visible: frameVisible } + property Component corner: StyleItem { elementType: "scrollareacorner" } } diff --git a/src/styles/FocusFrameStyle.qml b/src/styles/FocusFrameStyle.qml new file mode 100644 index 00000000..6fd50e9a --- /dev/null +++ b/src/styles/FocusFrameStyle.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Private 1.0 + +/*! + \qmltype FocusFrameStyle + \internal + \inqmlmodule QtQuick.Controls.Styles 1.0 +*/ +Item { + property int margin: -3 +} diff --git a/src/styles/ScrollViewStyle.qml b/src/styles/ScrollViewStyle.qml index 9edb5028..b64fe16f 100644 --- a/src/styles/ScrollViewStyle.qml +++ b/src/styles/ScrollViewStyle.qml @@ -45,17 +45,10 @@ import QtQuick.Controls.Styles 1.0 Style { id: root - property bool frameOnlyAroundContents: __styleitem.styleHint("frameOnlyAroundContents") - property int scrollBarSpacing: __styleitem.pixelMetric("scrollbarspacing") - property int defaultFrameWidth: __styleitem.pixelMetric("defaultframewidth") - - property StyleItem __styleitem: StyleItem { elementType: "frame" } - - property Component frame: StyleItem { - id: styleitem - elementType: "frame" - sunken: true - visible: control.frameVisible - } + property bool frameOnlyAroundContents: false + property int scrollBarSpacing: 4 + property int defaultFrameWidth: 1 + property Component frame: Rectangle { visible: frameVisible } + property Component corner: Rectangle { color: "red" } } diff --git a/src/styles/SliderStyle.qml b/src/styles/SliderStyle.qml index b54c2ba9..bebe9e90 100644 --- a/src/styles/SliderStyle.qml +++ b/src/styles/SliderStyle.qml @@ -83,8 +83,9 @@ Style { property Component panel: Item { id: root - implicitWidth: backgroundControl.implicitWidth - implicitHeight: backgroundControl.implicitHeight + property bool horizontal : control.orientation === Qt.Horizontal + implicitWidth: horizontal ? backgroundControl.implicitWidth : backgroundControl.implicitHeight + implicitHeight: horizontal ? backgroundControl.implicitHeight : backgroundControl.implicitWidth property Control __cref: control diff --git a/src/styles/SpinBoxStyle.qml b/src/styles/SpinBoxStyle.qml index 890e7344..1da81309 100644 --- a/src/styles/SpinBoxStyle.qml +++ b/src/styles/SpinBoxStyle.qml @@ -55,10 +55,14 @@ Style { property int rightMargin: 12 property int bottomMargin: 0 - property color foregroundColor: syspal.text - property color backgroundColor: syspal.base - property color selectionColor: syspal.highlight - property color selectedTextColor: syspal.highlightedText + property color foregroundColor: __syspal.text + property color backgroundColor: __syspal.base + property color selectionColor: __syspal.highlight + property color selectedTextColor: __syspal.highlightedText + + property var __syspal: SystemPalette { + colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled + } property Component upControl: Rectangle { anchors.centerIn: parent @@ -101,7 +105,7 @@ Style { property Component panel: Item { id: styleitem - implicitWidth: 100 + implicitWidth: control.__contentWidth + 26 implicitHeight: 21 property color foregroundColor: spinboxStyle.foregroundColor @@ -122,11 +126,6 @@ Style { property SpinBox cref: control - SystemPalette { - id: syspal - colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled - } - Loader { id: backgroundLoader anchors.fill: parent diff --git a/src/styles/qmldir b/src/styles/qmldir index 8b4b9c2c..494f745f 100644 --- a/src/styles/qmldir +++ b/src/styles/qmldir @@ -2,6 +2,7 @@ module QtQuick.Controls.Styles ButtonStyle 1.0 ButtonStyle.qml CheckBoxStyle 1.0 CheckBoxStyle.qml ComboBoxStyle 1.0 ComboBoxStyle.qml +FocusFrameStyle 1.0 FocusFrameStyle.qml GroupBoxStyle 1.0 GroupBoxStyle.qml ProgressBarStyle 1.0 ProgressBarStyle.qml RadioButtonStyle 1.0 RadioButtonStyle.qml diff --git a/src/styles/styles.pro b/src/styles/styles.pro index 06bf83cb..402a8db7 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -4,13 +4,13 @@ QML_FILES = \ ButtonStyle.qml \ CheckBoxStyle.qml \ ComboBoxStyle.qml \ + FocusFrameStyle.qml \ GroupBoxStyle.qml \ MenuBarStyle.qml \ MenuStyle.qml \ ProgressBarStyle.qml \ RadioButtonStyle.qml \ ScrollBarStyle.qml \ - Settings.js \ ScrollViewStyle.qml\ SliderStyle.qml \ SpinBoxStyle.qml \ @@ -27,6 +27,7 @@ QML_FILES += \ Desktop/ButtonStyle.qml \ Desktop/CheckBoxStyle.qml \ Desktop/ComboBoxStyle.qml \ + Desktop/FocusFrameStyle.qml \ Desktop/GroupBoxStyle.qml \ Desktop/MenuBarStyle.qml \ Desktop/MenuStyle.qml \ diff --git a/tests/auto/activeFocusOnTab/activeFocusOnTab.pro b/tests/auto/activeFocusOnTab/activeFocusOnTab.pro index 1a32e0e6..7ca9e7e1 100644 --- a/tests/auto/activeFocusOnTab/activeFocusOnTab.pro +++ b/tests/auto/activeFocusOnTab/activeFocusOnTab.pro @@ -8,5 +8,6 @@ include (../shared/util.pri) TESTDATA = data/* -QT += widgets core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private v8-private qml-private quick-private testlib +qtHaveModule(widgets) { QT += widgets } DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/applicationwindow/applicationwindow.pro b/tests/auto/applicationwindow/applicationwindow.pro index 1e4dcf9e..0a66bf5b 100644 --- a/tests/auto/applicationwindow/applicationwindow.pro +++ b/tests/auto/applicationwindow/applicationwindow.pro @@ -4,7 +4,7 @@ SOURCES += tst_applicationwindow.cpp macx:CONFIG -= app_bundle -QT += widgets core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private v8-private testlib include (../shared/util.pri) diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro index 3286e9eb..949991a9 100644 --- a/tests/auto/controls/controls.pro +++ b/tests/auto/controls/controls.pro @@ -3,7 +3,7 @@ TARGET = tst_controls IMPORTPATH = $$OUT_PWD/../testplugin -QT += widgets +qtHaveModule(widgets) { QT += widgets } CONFIG += qmltestcase console diff --git a/tests/auto/testplugin/QtQuickControlsTests/qmldir b/tests/auto/testplugin/QtQuickControlsTests/qmldir index 10c6cbab..e5e0015e 100644 --- a/tests/auto/testplugin/QtQuickControlsTests/qmldir +++ b/tests/auto/testplugin/QtQuickControlsTests/qmldir @@ -1,2 +1,2 @@ -module QtQuickControlsTests + module QtQuickControlsTests plugin testplugin diff --git a/tests/auto/testplugin/testplugin.pro b/tests/auto/testplugin/testplugin.pro index d656517f..d25d3a9f 100644 --- a/tests/auto/testplugin/testplugin.pro +++ b/tests/auto/testplugin/testplugin.pro @@ -3,7 +3,9 @@ CONFIG += plugin TARGET = testplugin TARGETPATH = QtQuickControlsTests -QT += qml quick widgets +QT += qml quick +qtHaveModule(widgets) { QT += widgets } + QMLDIR = $$PWD/$$TARGETPATH/qmldir diff --git a/tests/shared/qt_quick_controls_quicktest.h b/tests/shared/qt_quick_controls_quicktest.h index 0e1873af..8bcd0d47 100644 --- a/tests/shared/qt_quick_controls_quicktest.h +++ b/tests/shared/qt_quick_controls_quicktest.h @@ -43,7 +43,12 @@ #define QT_QUICK_CONTROLS_QUICKTEST_H #include <QtQuickTest/quicktestglobal.h> + +#ifndef QT_NO_WIDGETS #include <QtWidgets/QApplication> +#else +#include <QtGui/QGuiApplication> +#endif QT_BEGIN_NAMESPACE @@ -53,12 +58,18 @@ QT_BEGIN_NAMESPACE #define QT_QUICK_CONTROLS_TEST_MAIN_VAR 0 #endif +#ifndef QT_NO_WIDGETS +#define Application QApplication +#else +#define Application QGuiApplication +#endif + #define QT_QUICK_CONTROLS_TEST_MAIN(name) \ int main(int argc, char **argv) \ { \ - QApplication* app = 0; \ + Application* app = 0; \ if (!QCoreApplication::instance()) \ - app = new QApplication(argc, argv); \ + app = new Application(argc, argv); \ int i = quick_test_main(argc, argv, #name, QT_QUICK_CONTROLS_TEST_MAIN_VAR); \ delete app; \ return i; \ @@ -66,4 +77,4 @@ QT_BEGIN_NAMESPACE QT_END_NAMESPACE -#endif +#endif // QT_QUICK_CONTROLS_QUICKTEST_H |