diff options
Diffstat (limited to 'src/controls')
-rw-r--r-- | src/controls/controls.pri | 2 | ||||
-rw-r--r-- | src/controls/qquickcolorimageprovider.cpp | 80 | ||||
-rw-r--r-- | src/controls/qquickcolorimageprovider_p.h | 68 | ||||
-rw-r--r-- | src/controls/qquickpaddedrectangle_p.h | 4 | ||||
-rw-r--r-- | src/controls/qquickproxytheme_p.h | 30 | ||||
-rw-r--r-- | src/controls/qquickstyle.cpp | 21 | ||||
-rw-r--r-- | src/controls/qquickstyle_p.h | 4 | ||||
-rw-r--r-- | src/controls/qquickstyleselector.cpp | 2 |
8 files changed, 182 insertions, 29 deletions
diff --git a/src/controls/controls.pri b/src/controls/controls.pri index 005ee839..7aa9447f 100644 --- a/src/controls/controls.pri +++ b/src/controls/controls.pri @@ -1,4 +1,5 @@ HEADERS += \ + $$PWD/qquickcolorimageprovider_p.h \ $$PWD/qquickproxytheme_p.h \ $$PWD/qquickstyle_p.h \ $$PWD/qquickstyleselector_p.h \ @@ -6,6 +7,7 @@ HEADERS += \ $$PWD/qquickpaddedrectangle_p.h SOURCES += \ + $$PWD/qquickcolorimageprovider.cpp \ $$PWD/qquickproxytheme.cpp \ $$PWD/qquickstyle.cpp \ $$PWD/qquickstyleselector.cpp \ diff --git a/src/controls/qquickcolorimageprovider.cpp b/src/controls/qquickcolorimageprovider.cpp new file mode 100644 index 00000000..582b73ed --- /dev/null +++ b/src/controls/qquickcolorimageprovider.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickcolorimageprovider_p.h" + +#include <QtCore/qdebug.h> +#include <QtGui/qpainter.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qscreen.h> +#include <QtGui/qicon.h> + +QT_BEGIN_NAMESPACE + +QQuickColorImageProvider::QQuickColorImageProvider(const QString &path) + : QQuickImageProvider(Image), m_path(path) +{ +} + +QImage QQuickColorImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) +{ + Q_UNUSED(requestedSize); + + int sep = id.indexOf(QLatin1Char('/')); + QString name = id.left(sep); + QString color = id.mid(sep + 1); + qreal dpr = qApp->primaryScreen()->devicePixelRatio(); + QString file = qt_findAtNxFile(m_path + QLatin1Char('/') + name + QStringLiteral(".png"), dpr); + + QImage image(file); + if (image.isNull()) { + qWarning() << "QQuickColorImageProvider: unknown id:" << id; + return QImage(); + } + + if (size) + *size = image.size(); + + if (!color.isEmpty()) { + QPainter painter(&image); + painter.setCompositionMode(QPainter::CompositionMode_SourceIn); + painter.fillRect(image.rect(), QColor(color)); + } + + return image; +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickcolorimageprovider_p.h b/src/controls/qquickcolorimageprovider_p.h new file mode 100644 index 00000000..6f55f75f --- /dev/null +++ b/src/controls/qquickcolorimageprovider_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKCOLORIMAGEPROVIDER_P_H +#define QQUICKCOLORIMAGEPROVIDER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/qquickimageprovider.h> + +QT_BEGIN_NAMESPACE + +class QQuickColorImageProvider : public QQuickImageProvider +{ +public: + QQuickColorImageProvider(const QString &path); + + QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; + +private: + QString m_path; +}; + +QT_END_NAMESPACE + +#endif // QQUICKOCOLORIMAGEPROVIDER_P_H diff --git a/src/controls/qquickpaddedrectangle_p.h b/src/controls/qquickpaddedrectangle_p.h index 5c0a8919..690448d6 100644 --- a/src/controls/qquickpaddedrectangle_p.h +++ b/src/controls/qquickpaddedrectangle_p.h @@ -62,7 +62,7 @@ class QQuickPaddedRectangle : public QQuickRectangle Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL) public: - QQuickPaddedRectangle(QQuickItem *parent = Q_NULLPTR); + QQuickPaddedRectangle(QQuickItem *parent = nullptr); qreal padding() const; void setPadding(qreal padding); @@ -92,7 +92,7 @@ Q_SIGNALS: void bottomPaddingChanged(); protected: - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private: void setTopPadding(qreal padding, bool has); diff --git a/src/controls/qquickproxytheme_p.h b/src/controls/qquickproxytheme_p.h index 47f931b5..6d7040e5 100644 --- a/src/controls/qquickproxytheme_p.h +++ b/src/controls/qquickproxytheme_p.h @@ -61,33 +61,33 @@ public: QPlatformTheme* theme() const; - QPlatformMenuItem* createPlatformMenuItem() const Q_DECL_OVERRIDE; - QPlatformMenu* createPlatformMenu() const Q_DECL_OVERRIDE; - QPlatformMenuBar* createPlatformMenuBar() const Q_DECL_OVERRIDE; - void showPlatformMenuBar() Q_DECL_OVERRIDE; + QPlatformMenuItem* createPlatformMenuItem() const override; + QPlatformMenu* createPlatformMenu() const override; + QPlatformMenuBar* createPlatformMenuBar() const override; + void showPlatformMenuBar() override; - bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE; - QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE; + bool usePlatformNativeDialog(DialogType type) const override; + QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override; #ifndef QT_NO_SYSTEMTRAYICON - QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE; + QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const override; #endif - const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE; + const QPalette *palette(Palette type = SystemPalette) const override; - const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE; + const QFont *font(Font type = SystemFont) const override; - QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; + QVariant themeHint(ThemeHint hint) const override; - QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const Q_DECL_OVERRIDE; + QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, - QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE; + QPlatformTheme::IconOptions iconOptions = 0) const override; - QIconEngine *createIconEngine(const QString &iconName) const Q_DECL_OVERRIDE; + QIconEngine *createIconEngine(const QString &iconName) const override; - QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const Q_DECL_OVERRIDE; + QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const override; - QString standardButtonText(int button) const Q_DECL_OVERRIDE; + QString standardButtonText(int button) const override; private: QPlatformTheme *m_theme; diff --git a/src/controls/qquickstyle.cpp b/src/controls/qquickstyle.cpp index 0ca6558e..320148c3 100644 --- a/src/controls/qquickstyle.cpp +++ b/src/controls/qquickstyle.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE static QQuickStyle *attachedStyle(const QMetaObject *type, QObject *object, bool create = false) { if (!object) - return Q_NULLPTR; + return nullptr; int idx = -1; return qobject_cast<QQuickStyle *>(qmlAttachedPropertiesObject(&idx, object, type, create)); } @@ -55,7 +55,7 @@ static QQuickStyle *attachedStyle(const QMetaObject *type, QObject *object, bool static QQuickStyle *findParentStyle(const QMetaObject *type, QObject *parent) { if (!parent) - return Q_NULLPTR; + return nullptr; QQuickStyle *style = attachedStyle(type, parent); if (style) @@ -97,7 +97,7 @@ static QQuickStyle *findParentStyle(const QMetaObject *type, QObject *parent) return style; } - return Q_NULLPTR; + return nullptr; } static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *object) @@ -109,7 +109,8 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob if (QQuickWindow *window = qobject_cast<QQuickWindow *>(object)) { item = window->contentItem(); - foreach (QObject *child, window->children()) { + const auto windowChildren = window->children(); + for (QObject *child : windowChildren) { QQuickWindow *childWindow = qobject_cast<QQuickWindow *>(child); if (childWindow) { QQuickStyle *style = attachedStyle(type, childWindow); @@ -127,7 +128,8 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob } if (item) { - foreach (QQuickItem *child, item->childItems()) { + const auto childItems = item->childItems(); + for (QQuickItem *child : childItems) { QQuickStyle *style = attachedStyle(type, child); if (style) children += style; @@ -135,7 +137,8 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob children += findChildStyles(type, child); } - foreach (QObject *child, item->children()) { + const auto itemChildren = item->children(); + for (QObject *child : itemChildren) { if (!qobject_cast<QQuickItem *>(child)) { QQuickStyle *style = attachedStyle(type, child); if (style) @@ -162,7 +165,7 @@ QQuickStyle::~QQuickStyle() if (item) QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Parent); - setParentStyle(Q_NULLPTR); + setParentStyle(nullptr); } QSharedPointer<QSettings> QQuickStyle::settings(const QString &group) @@ -214,8 +217,8 @@ void QQuickStyle::init() if (parentStyle) setParentStyle(parentStyle); - QList<QQuickStyle *> children = findChildStyles(metaObject(), parent); - foreach (QQuickStyle *child, children) + const QList<QQuickStyle *> children = findChildStyles(metaObject(), parent); + for (QQuickStyle *child : children) child->setParentStyle(this); } diff --git a/src/controls/qquickstyle_p.h b/src/controls/qquickstyle_p.h index 02ee667a..36a2320c 100644 --- a/src/controls/qquickstyle_p.h +++ b/src/controls/qquickstyle_p.h @@ -64,7 +64,7 @@ class QQuickStyle : public QObject, public QQuickItemChangeListener Q_OBJECT public: - explicit QQuickStyle(QObject *parent = Q_NULLPTR); + explicit QQuickStyle(QObject *parent = nullptr); ~QQuickStyle(); static QSharedPointer<QSettings> settings(const QString &group = QString()); @@ -79,7 +79,7 @@ protected: virtual void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent); - void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE; + void itemParentChanged(QQuickItem *item, QQuickItem *parent) override; private: QList<QQuickStyle *> m_childStyles; diff --git a/src/controls/qquickstyleselector.cpp b/src/controls/qquickstyleselector.cpp index 49b2aa17..b169ade2 100644 --- a/src/controls/qquickstyleselector.cpp +++ b/src/controls/qquickstyleselector.cpp @@ -113,7 +113,7 @@ static QString selectionHelper(const QString &path, const QString &fileName, con */ Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/'))); - foreach (const QString &s, selectors) { + for (const QString &s : selectors) { QString prospectiveBase = path + s + QLatin1Char('/'); QStringList remainingSelectors = selectors; remainingSelectors.removeAll(s); |