diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2015-08-26 14:15:02 +0300 |
---|---|---|
committer | Dmitry Shachnev <mitya57@gmail.com> | 2015-08-26 13:43:16 +0000 |
commit | cce2a535aa43422118ac241c3dc5be14ee749b73 (patch) | |
tree | bc369bc1e38eb62b4daaecc38aaaa30c1638c422 | |
parent | 8ff2ac6035fb1d01f5c0054ba14afb949410e3a7 (diff) |
Sync QStyleHelper code with the latest code in qtbase dev branch
Change-Id: Ib50a7a9d2732f84edfb8cc926d695db34ed0a791
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/plugins/styles/shared/qstylehelper.cpp | 84 | ||||
-rw-r--r-- | src/plugins/styles/shared/qstylehelper_p.h | 46 |
2 files changed, 83 insertions, 47 deletions
diff --git a/src/plugins/styles/shared/qstylehelper.cpp b/src/plugins/styles/shared/qstylehelper.cpp index 88a1e65..3b647cd 100644 --- a/src/plugins/styles/shared/qstylehelper.cpp +++ b/src/plugins/styles/shared/qstylehelper.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the QtWidgets module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** 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. +** 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 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. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company 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$ ** ****************************************************************************/ @@ -42,11 +34,14 @@ #include <qstyleoption.h> #include <qpainter.h> #include <qpixmapcache.h> -#include <qstringbuilder.h> #include <qmath.h> +#include <qscrollbar.h> +#include <qabstractscrollarea.h> +#include <qwindow.h> #include "qstylecache_p.h" #include "qstylehelper_p.h" +#include <qstringbuilder.h> QT_BEGIN_NAMESPACE @@ -74,6 +69,30 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & return tmp; } +#ifndef QT_NO_ACCESSIBILITY +bool isInstanceOf(QObject *obj, QAccessible::Role role) +{ + bool match = false; + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(obj); + match = iface && iface->role() == role; + return match; +} + +// Searches for an ancestor of a particular accessible role +bool hasAncestor(QObject *obj, QAccessible::Role role) +{ + bool found = false; + QObject *parent = obj ? obj->parent() : 0; + while (parent && !found) { + if (isInstanceOf(parent, role)) + found = true; + parent = parent->parent(); + } + return found; +} +#endif // QT_NO_ACCESSIBILITY + + #ifndef QT_NO_DIAL int calcBigLineSize(int radius) @@ -351,5 +370,22 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec } } + +QColor backgroundColor(const QPalette &pal, const QWidget* widget) +{ + if (qobject_cast<const QScrollBar *>(widget) && widget->parent() && + qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent())) + return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); + return pal.color(QPalette::Base); +} + +QWindow *styleObjectWindow(QObject *so) +{ + if (so) + return so->property("_q_styleObjectWindow").value<QWindow *>(); + + return 0; +} + } QT_END_NAMESPACE diff --git a/src/plugins/styles/shared/qstylehelper_p.h b/src/plugins/styles/shared/qstylehelper_p.h index 8a44f0c..640830e 100644 --- a/src/plugins/styles/shared/qstylehelper_p.h +++ b/src/plugins/styles/shared/qstylehelper_p.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the QtWidgets module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** 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. +** 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 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. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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 +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company 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$ ** ****************************************************************************/ @@ -44,6 +36,7 @@ #include <QtCore/qstring.h> #include <QtGui/qpolygon.h> #include <QtCore/qstringbuilder.h> +#include <QtGui/qaccessible.h> #ifndef QSTYLEHELPER_P_H #define QSTYLEHELPER_P_H @@ -67,6 +60,7 @@ class QPainter; class QPixmap; class QStyleOptionSlider; class QStyleOption; +class QWindow; namespace QStyleHelper { @@ -80,6 +74,12 @@ namespace QStyleHelper void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left = 0, int top = 0, int right = 0, int bottom = 0); +#ifndef QT_NO_ACCESSIBILITY + bool isInstanceOf(QObject *obj, QAccessible::Role role); + bool hasAncestor(QObject *obj, QAccessible::Role role); +#endif + QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0); + QWindow *styleObjectWindow(QObject *so); } |