diff options
Diffstat (limited to 'src/private')
-rw-r--r-- | src/private/Control.qml | 1 | ||||
-rw-r--r-- | src/private/FocusFrame.qml | 25 | ||||
-rw-r--r-- | src/private/ScrollBar.qml | 3 | ||||
-rw-r--r-- | src/private/ScrollViewHelper.qml | 9 | ||||
-rw-r--r-- | src/private/plugin.cpp | 17 | ||||
-rw-r--r-- | src/private/private.pro | 15 | ||||
-rw-r--r-- | src/private/qquickcontrolsettings.cpp | 67 | ||||
-rw-r--r-- | src/private/qquickcontrolsettings_p.h | 61 | ||||
-rw-r--r-- | src/private/qquickstyleitem.cpp | 11 | ||||
-rw-r--r-- | src/private/qquicktooltip.cpp | 15 |
10 files changed, 190 insertions, 34 deletions
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/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h new file mode 100644 index 00000000..ea2811be --- /dev/null +++ b/src/private/qquickcontrolsettings_p.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#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 |