diff -Nru qtstyleplugins-src-5.0.0/debian/changelog qtstyleplugins-src-5.0.0+git23.g335dbec/debian/changelog --- qtstyleplugins-src-5.0.0/debian/changelog 2015-11-30 14:39:04.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/debian/changelog 2019-11-18 04:55:54.000000000 +0000 @@ -1,14 +1,69 @@ -qtstyleplugins-src (5.0.0-1build3) xenial; urgency=medium +qtstyleplugins-src (5.0.0+git23.g335dbec-2build5~16.04.sav0) xenial; urgency=medium - * Rebuild against Qt 5.5.1. + * Backport to Xenial + * Build against ppa:savoury1/build-tools for debhelper 11.1.6 (qttools needs + debhelper >= 10.9.2) and ninja-build 1.9.0 (required for qtwebkit build) - -- Timo Jyrinki Mon, 30 Nov 2015 16:29:40 +0200 + -- Rob Savoury Sun, 17 Nov 2019 20:55:54 -0800 -qtstyleplugins-src (5.0.0-1build1) wily; urgency=medium +qtstyleplugins-src (5.0.0+git23.g335dbec-2build5) bionic; urgency=medium - * No-change rebuild against Qt 5.4.2. + * No-change rebuild against qtbase-abi-5-9-5. - -- Timo Jyrinki Mon, 15 Jun 2015 21:03:40 +0300 + -- Simon Quigley Sat, 14 Apr 2018 22:00:49 -0500 + +qtstyleplugins-src (5.0.0+git23.g335dbec-2build4) bionic; urgency=medium + + * No-change rebuild against qtbase-abi-5-9-4. + + -- Simon Quigley Tue, 27 Feb 2018 09:50:06 -0600 + +qtstyleplugins-src (5.0.0+git23.g335dbec-2build3) bionic; urgency=medium + + * No-change rebuild for new Qt. + + -- Simon Quigley Thu, 21 Dec 2017 15:58:46 -0600 + +qtstyleplugins-src (5.0.0+git23.g335dbec-2build2) bionic; urgency=medium + + * No-change rebuild against qtbase5-private-dev. + + -- Simon Quigley Fri, 03 Nov 2017 17:27:21 -0500 + +qtstyleplugins-src (5.0.0+git23.g335dbec-2build1) artful; urgency=medium + + * No change rebuild against Qt 5.9. + + -- Dmitry Shachnev Sun, 13 Aug 2017 21:16:36 +0300 + +qtstyleplugins-src (5.0.0+git23.g335dbec-2) unstable; urgency=medium + + * Limit the libmtdev-dev build dependency to Linux architectures, as it is + needed only there. + * Bump Standards-Version to 4.0.0, no changes required. + + -- Pino Toscano Sun, 25 Jun 2017 19:44:50 +0200 + +qtstyleplugins-src (5.0.0+git23.g335dbec-1) unstable; urgency=medium + + * New upstream snapshot, compatible with Qt 5.8+. + + -- Dmitry Shachnev Sat, 17 Jun 2017 21:16:16 +0300 + +qtstyleplugins-src (5.0.0+git16.g7aa4764-1) unstable; urgency=medium + + * New upstream snapshot. + - Includes the GTK+ 2 style, moved from qtbase (closes: #843257). + - Drop upstream_Cleanlooks-style-Fix-floating-point-exception.patch. + * Build-depend on libegl1-mesa-dev, libgtk2.0-dev, libmtdev-dev and + libx11-dev, for the GTK+ 2 style and platformtheme. + * Update the package description to mention the GTK+ platform theme. + * Break/Replace all versions of libqt5libqgtk2. + * Update debian/copyright. + * Use HTTPS in Vcs-Git and Vcs-Browser fields. + * Bump Standards-Version to 3.9.8, no changes needed. + + -- Dmitry Shachnev Sun, 11 Dec 2016 20:01:02 +0300 qtstyleplugins-src (5.0.0-1) unstable; urgency=low diff -Nru qtstyleplugins-src-5.0.0/debian/control qtstyleplugins-src-5.0.0+git23.g335dbec/debian/control --- qtstyleplugins-src-5.0.0/debian/control 2015-11-30 14:29:40.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/debian/control 2017-06-25 17:43:45.000000000 +0000 @@ -1,8 +1,7 @@ Source: qtstyleplugins-src Section: libs Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Debian Qt/KDE Maintainers +Maintainer: Debian Qt/KDE Maintainers Uploaders: Fathi Boudra , Modestas Vainius , Sune Vuorela , @@ -12,18 +11,24 @@ Timo Jyrinki , Dmitry Shachnev Build-Depends: debhelper (>= 9), + libegl1-mesa-dev, + libgtk2.0-dev, + libmtdev-dev [linux-any], + libx11-dev, pkg-kde-tools, qtbase5-private-dev, -Standards-Version: 3.9.6 +Standards-Version: 4.0.0 Homepage: http://qt-project.org/ -Vcs-Git: git://anonscm.debian.org/pkg-kde/qt/qtstyleplugins.git -Vcs-Browser: http://anonscm.debian.org/cgit/pkg-kde/qt/qtstyleplugins.git +Vcs-Git: https://anonscm.debian.org/git/pkg-kde/qt/qtstyleplugins.git +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-kde/qt/qtstyleplugins.git Package: qt5-style-plugins Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends} +Breaks: libqt5libqgtk2 (<< 5.7) +Replaces: libqt5libqgtk2 (<< 5.7) Description: Qt 5 extra widget styles Qt is a cross-platform C++ application framework. Qt's primary feature is its rich set of widgets that provide standard GUI functionality. @@ -32,3 +37,8 @@ - Cleanlooks - Motif - Plastique + - GTK+ 2 + . + It also provides the GTK+ 2 platformtheme, which you would likely want + to use if you want the GTK+ 2 style. Export QT_QPA_PLATFORMTHEME=gtk2 to + enable it for all Qt applications. diff -Nru qtstyleplugins-src-5.0.0/debian/copyright qtstyleplugins-src-5.0.0+git23.g335dbec/debian/copyright --- qtstyleplugins-src-5.0.0/debian/copyright 2014-12-29 13:22:02.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/debian/copyright 2017-06-25 17:39:07.000000000 +0000 @@ -2,30 +2,31 @@ Upstream-Name: qtstyleplugins-src Files: * -Copyright: 2012 Digia Plc and/or its subsidiary(-ies) -License: LGPL-2.1 with Digia Qt LGPL Exception 1.1 or GPL-3 +Copyright: 2012-2015 The Qt Company Ltd. +License: LGPL-2.1 with Qt-1.1 exception or GPL-3 + +Files: src/plugins/styles/bb10style/* +Copyright: 2014 BlackBerry Limited. +License: LGPL-2.1 with Qt-1.1 exception or GPL-3 Files: debian/* Copyright: 2014 Pino Toscano License: LGPL-2.1 -License: LGPL-2.1 with Digia Qt LGPL Exception 1.1 - GNU Lesser General Public License version 2.1: - 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. +License: LGPL-2.1 with Qt-1.1 exception + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1 + as published by the Free Software Foundation. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. . - On Debian systems, the complete text of the GNU Lesser General Public License - can be found in `/usr/share/common-licenses/LGPL-2.1`. + On Debian systems, the complete text of the GNU Lesser General Public + License version 2.1 can be found in /usr/share/common-licenses/LGPL-2.1. . - Digia Qt LGPL Exception version 1.1: + The Qt Company LGPL Exception version 1.1: As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute @@ -48,25 +49,27 @@ modified version of the Library. License: GPL-3 - 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. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License version 3 as + published by the Free Software Foundation. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. . - On Debian systems, the complete text of the license can be found in - `/usr/share/common-licenses/GPL-3`. + On Debian systems, the complete text of the GNU General Public License + version 3 can be found in /usr/share/common-licenses/GPL-3. License: LGPL-2.1 - 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. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1 + as published by the Free Software Foundation. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. . - On Debian systems, the complete text of the LGPL-2.1 license can be found in - `/usr/share/common-licenses/LGPL-2.1`, + On Debian systems, the complete text of the GNU Lesser General Public + License version 2.1 can be found in /usr/share/common-licenses/LGPL-2.1. diff -Nru qtstyleplugins-src-5.0.0/debian/patches/series qtstyleplugins-src-5.0.0+git23.g335dbec/debian/patches/series --- qtstyleplugins-src-5.0.0/debian/patches/series 2014-12-29 13:31:48.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -upstream_Cleanlooks-style-Fix-floating-point-exception.patch diff -Nru qtstyleplugins-src-5.0.0/debian/patches/upstream_Cleanlooks-style-Fix-floating-point-exception.patch qtstyleplugins-src-5.0.0+git23.g335dbec/debian/patches/upstream_Cleanlooks-style-Fix-floating-point-exception.patch --- qtstyleplugins-src-5.0.0/debian/patches/upstream_Cleanlooks-style-Fix-floating-point-exception.patch 2014-12-29 13:31:40.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/debian/patches/upstream_Cleanlooks-style-Fix-floating-point-exception.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -From 8ff2ac6035fb1d01f5c0054ba14afb949410e3a7 Mon Sep 17 00:00:00 2001 -From: Alexandre Rostovtsev -Date: Wed, 4 Jun 2014 20:27:53 -0400 -Subject: [PATCH] Cleanlooks style: Fix floating point exception - -In QCleanlooksStyle::drawControl, if indeterminate == true and -rect.width() == 4, we will end up with slideWidth of zero, and -take a mod by zero when calculating the value of step. - -Identical code in Qt4 Cleanlooks causes a crash in Quassel 0.10; -see https://bugs.gentoo.org/show_bug.cgi?id=507124 - -Instead, calculate slideWidth based on max(width, minWidth) where -minWidth was already set as 4, ensuring that slideWidth >= 2. - -Change-Id: Id3e39437665be326358f68c48eaf1249b6880c4a -Reviewed-by: Giuseppe D'Angelo -Reviewed-by: J-P Nurmi ---- - src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp b/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp -index 8d89e39..1e82ed7 100644 ---- a/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp -+++ b/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp -@@ -1749,7 +1749,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o - progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3); - } - } else { -- int slideWidth = ((rect.width() - 4) * 2) / 3; -+ int slideWidth = (qMax(rect.width() - 4, minWidth) * 2) / 3; - int step = ((animateStep * slideWidth) / progressAnimationFps) % slideWidth; - if ((((animateStep * slideWidth) / progressAnimationFps) % (2 * slideWidth)) >= slideWidth) - step = slideWidth - step; --- -2.1.4 - diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/gtk2.json qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/gtk2.json --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/gtk2.json 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/gtk2.json 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,3 @@ +{ + "Keys": [ "gtk2" ] +} diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/gtk2.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/gtk2.pro --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/gtk2.pro 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/gtk2.pro 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,25 @@ +TARGET = qgtk2 + +QT += core-private gui-private +greaterThan(QT_MAJOR_VERSION, 5)|greaterThan(QT_MINOR_VERSION, 7): \ + QT += theme_support-private +else: \ + QT += platformsupport-private + +CONFIG += X11 +CONFIG += link_pkgconfig +PKGCONFIG += gtk+-2.0 + +HEADERS += \ + qgtk2dialoghelpers.h \ + qgtk2theme.h + +SOURCES += \ + main.cpp \ + qgtk2dialoghelpers.cpp \ + qgtk2theme.cpp \ + +PLUGIN_TYPE = platformthemes +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QGtk2ThemePlugin +load(qt_plugin) diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/main.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/main.cpp --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/main.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/main.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgtk2theme.h" + +QT_BEGIN_NAMESPACE + +class QGtk2ThemePlugin : public QPlatformThemePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "gtk2.json") + +public: + QPlatformTheme *create(const QString &key, const QStringList ¶ms) Q_DECL_OVERRIDE; +}; + +QPlatformTheme *QGtk2ThemePlugin::create(const QString &key, const QStringList ¶ms) +{ + Q_UNUSED(params); + if (!key.compare(QLatin1String(QGtk2Theme::name), Qt::CaseInsensitive)) + return new QGtk2Theme; + + return 0; +} + +QT_END_NAMESPACE + +#include "main.moc" diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,624 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgtk2dialoghelpers.h" + +#include +#include +#include +#include +#include + +#include +#include + +#undef signals +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QGtk2Dialog : public QWindow +{ + Q_OBJECT + +public: + QGtk2Dialog(GtkWidget *gtkWidget); + ~QGtk2Dialog(); + + GtkDialog *gtkDialog() const; + + void exec(); + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent); + void hide(); + +Q_SIGNALS: + void accept(); + void reject(); + +protected: + static void onResponse(QGtk2Dialog *dialog, int response); + +private slots: + void onParentWindowDestroyed(); + +private: + GtkWidget *gtkWidget; +}; + +QGtk2Dialog::QGtk2Dialog(GtkWidget *gtkWidget) : gtkWidget(gtkWidget) +{ + g_signal_connect_swapped(G_OBJECT(gtkWidget), "response", G_CALLBACK(onResponse), this); + g_signal_connect(G_OBJECT(gtkWidget), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); +} + +QGtk2Dialog::~QGtk2Dialog() +{ + gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); + gtk_widget_destroy(gtkWidget); +} + +GtkDialog *QGtk2Dialog::gtkDialog() const +{ + return GTK_DIALOG(gtkWidget); +} + +void QGtk2Dialog::exec() +{ + if (modality() == Qt::ApplicationModal) { + // block input to the whole app, including other GTK dialogs + gtk_dialog_run(gtkDialog()); + } else { + // block input to the window, allow input to other GTK dialogs + QEventLoop loop; + connect(this, SIGNAL(accept()), &loop, SLOT(quit())); + connect(this, SIGNAL(reject()), &loop, SLOT(quit())); + loop.exec(); + } +} + +bool QGtk2Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +{ + if (parent) { + connect(parent, &QWindow::destroyed, this, &QGtk2Dialog::onParentWindowDestroyed, + Qt::UniqueConnection); + } + setParent(parent); + setFlags(flags); + setModality(modality); + + gtk_widget_realize(gtkWidget); // creates X window + + if (parent) { + XSetTransientForHint(gdk_x11_drawable_get_xdisplay(gtkWidget->window), + gdk_x11_drawable_get_xid(gtkWidget->window), + parent->winId()); + } + + if (modality != Qt::NonModal) { + gdk_window_set_modal_hint(gtkWidget->window, true); + QGuiApplicationPrivate::showModalWindow(this); + } + + gtk_widget_show(gtkWidget); + gdk_window_focus(gtkWidget->window, 0); + return true; +} + +void QGtk2Dialog::hide() +{ + QGuiApplicationPrivate::hideModalWindow(this); + gtk_widget_hide(gtkWidget); +} + +void QGtk2Dialog::onResponse(QGtk2Dialog *dialog, int response) +{ + if (response == GTK_RESPONSE_OK) + emit dialog->accept(); + else + emit dialog->reject(); +} + +void QGtk2Dialog::onParentWindowDestroyed() +{ + // The QGtk2*DialogHelper classes own this object. Make sure the parent doesn't delete it. + setParent(0); +} + +QGtk2ColorDialogHelper::QGtk2ColorDialogHelper() +{ + d.reset(new QGtk2Dialog(gtk_color_selection_dialog_new(""))); + connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); + connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); + + GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(d->gtkDialog())); + g_signal_connect_swapped(gtkColorSelection, "color-changed", G_CALLBACK(onColorChanged), this); +} + +QGtk2ColorDialogHelper::~QGtk2ColorDialogHelper() +{ +} + +bool QGtk2ColorDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +{ + applyOptions(); + return d->show(flags, modality, parent); +} + +void QGtk2ColorDialogHelper::exec() +{ + d->exec(); +} + +void QGtk2ColorDialogHelper::hide() +{ + d->hide(); +} + +void QGtk2ColorDialogHelper::setCurrentColor(const QColor &color) +{ + GtkDialog *gtkDialog = d->gtkDialog(); + GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(gtkDialog)); + GdkColor gdkColor; + gdkColor.red = color.red() << 8; + gdkColor.green = color.green() << 8; + gdkColor.blue = color.blue() << 8; + gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(gtkColorSelection), &gdkColor); + if (color.alpha() < 255) { + gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(gtkColorSelection), true); + gtk_color_selection_set_current_alpha(GTK_COLOR_SELECTION(gtkColorSelection), color.alpha() << 8); + } +} + +QColor QGtk2ColorDialogHelper::currentColor() const +{ + GtkDialog *gtkDialog = d->gtkDialog(); + GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(gtkDialog)); + GdkColor gdkColor; + gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(gtkColorSelection), &gdkColor); + guint16 alpha = gtk_color_selection_get_current_alpha(GTK_COLOR_SELECTION(gtkColorSelection)); + return QColor(gdkColor.red >> 8, gdkColor.green >> 8, gdkColor.blue >> 8, alpha >> 8); +} + +void QGtk2ColorDialogHelper::onAccepted() +{ + emit accept(); + emit colorSelected(currentColor()); +} + +void QGtk2ColorDialogHelper::onColorChanged(QGtk2ColorDialogHelper *dialog) +{ + emit dialog->currentColorChanged(dialog->currentColor()); +} + +void QGtk2ColorDialogHelper::applyOptions() +{ + GtkDialog *gtkDialog = d->gtkDialog(); + gtk_window_set_title(GTK_WINDOW(gtkDialog), options()->windowTitle().toUtf8()); + + GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(gtkDialog)); + gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(gtkColorSelection), options()->testOption(QColorDialogOptions::ShowAlphaChannel)); + + GtkWidget *okButton = 0; + GtkWidget *cancelButton = 0; + GtkWidget *helpButton = 0; + g_object_get(G_OBJECT(gtkDialog), "ok-button", &okButton, "cancel-button", &cancelButton, "help-button", &helpButton, NULL); + if (okButton) + g_object_set(G_OBJECT(okButton), "visible", !options()->testOption(QColorDialogOptions::NoButtons), NULL); + if (cancelButton) + g_object_set(G_OBJECT(cancelButton), "visible", !options()->testOption(QColorDialogOptions::NoButtons), NULL); + if (helpButton) + gtk_widget_hide(helpButton); +} + +QGtk2FileDialogHelper::QGtk2FileDialogHelper() +{ + d.reset(new QGtk2Dialog(gtk_file_chooser_dialog_new("", 0, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, NULL))); + connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); + connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); + + g_signal_connect(GTK_FILE_CHOOSER(d->gtkDialog()), "selection-changed", G_CALLBACK(onSelectionChanged), this); + g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "current-folder-changed", G_CALLBACK(onCurrentFolderChanged), this); +} + +QGtk2FileDialogHelper::~QGtk2FileDialogHelper() +{ +} + +bool QGtk2FileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +{ + _dir.clear(); + _selection.clear(); + + applyOptions(); + return d->show(flags, modality, parent); +} + +void QGtk2FileDialogHelper::exec() +{ + d->exec(); +} + +void QGtk2FileDialogHelper::hide() +{ + // After GtkFileChooserDialog has been hidden, gtk_file_chooser_get_current_folder() + // & gtk_file_chooser_get_filenames() will return bogus values -> cache the actual + // values before hiding the dialog + _dir = directory(); + _selection = selectedFiles(); + + d->hide(); +} + +bool QGtk2FileDialogHelper::defaultNameFilterDisables() const +{ + return false; +} + +void QGtk2FileDialogHelper::setDirectory(const QUrl &directory) +{ + GtkDialog *gtkDialog = d->gtkDialog(); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), directory.toLocalFile().toUtf8()); +} + +QUrl QGtk2FileDialogHelper::directory() const +{ + // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_current_folder() + // returns a bogus value -> return the cached value before hiding + if (!_dir.isEmpty()) + return _dir; + + QString ret; + GtkDialog *gtkDialog = d->gtkDialog(); + gchar *folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(gtkDialog)); + if (folder) { + ret = QString::fromUtf8(folder); + g_free(folder); + } + return QUrl::fromLocalFile(ret); +} + +void QGtk2FileDialogHelper::selectFile(const QUrl &filename) +{ + GtkDialog *gtkDialog = d->gtkDialog(); + if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { + QFileInfo fi(filename.toLocalFile()); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), fi.path().toUtf8()); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), fi.fileName().toUtf8()); + } else { + gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), filename.toLocalFile().toUtf8()); + } +} + +QList QGtk2FileDialogHelper::selectedFiles() const +{ + // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_filenames() + // returns a bogus value -> return the cached value before hiding + if (!_selection.isEmpty()) + return _selection; + + QList selection; + GtkDialog *gtkDialog = d->gtkDialog(); + GSList *filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(gtkDialog)); + for (GSList *it = filenames; it; it = it->next) + selection += QUrl::fromLocalFile(QString::fromUtf8((const char*)it->data)); + g_slist_free(filenames); + return selection; +} + +void QGtk2FileDialogHelper::setFilter() +{ + applyOptions(); +} + +void QGtk2FileDialogHelper::selectNameFilter(const QString &filter) +{ + GtkFileFilter *gtkFilter = _filters.value(filter); + if (gtkFilter) { + GtkDialog *gtkDialog = d->gtkDialog(); + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter); + } +} + +QString QGtk2FileDialogHelper::selectedNameFilter() const +{ + GtkDialog *gtkDialog = d->gtkDialog(); + GtkFileFilter *gtkFilter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(gtkDialog)); + return _filterNames.value(gtkFilter); +} + +void QGtk2FileDialogHelper::onAccepted() +{ + emit accept(); + + QString filter = selectedNameFilter(); + if (filter.isEmpty()) + emit filterSelected(filter); + + QList files = selectedFiles(); + emit filesSelected(files); + if (files.count() == 1) + emit fileSelected(files.first()); +} + +void QGtk2FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk2FileDialogHelper *helper) +{ + QString selection; + gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtkDialog)); + if (filename) { + selection = QString::fromUtf8(filename); + g_free(filename); + } + emit helper->currentChanged(QUrl::fromLocalFile(selection)); +} + +void QGtk2FileDialogHelper::onCurrentFolderChanged(QGtk2FileDialogHelper *dialog) +{ + emit dialog->directoryEntered(dialog->directory()); +} + +static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer &options) +{ + switch (options->fileMode()) { + case QFileDialogOptions::AnyFile: + case QFileDialogOptions::ExistingFile: + case QFileDialogOptions::ExistingFiles: + if (options->acceptMode() == QFileDialogOptions::AcceptOpen) + return GTK_FILE_CHOOSER_ACTION_OPEN; + else + return GTK_FILE_CHOOSER_ACTION_SAVE; + case QFileDialogOptions::Directory: + case QFileDialogOptions::DirectoryOnly: + default: + if (options->acceptMode() == QFileDialogOptions::AcceptOpen) + return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + else + return GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + } +} + +void QGtk2FileDialogHelper::applyOptions() +{ + GtkDialog *gtkDialog = d->gtkDialog(); + const QSharedPointer &opts = options(); + + gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); + gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true); + + const GtkFileChooserAction action = gtkFileChooserAction(opts); + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action); + + const bool selectMultiple = opts->fileMode() == QFileDialogOptions::ExistingFiles; + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(gtkDialog), selectMultiple); + + const bool confirmOverwrite = !opts->testOption(QFileDialogOptions::DontConfirmOverwrite); + gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(gtkDialog), confirmOverwrite); + + const QStringList nameFilters = opts->nameFilters(); + if (!nameFilters.isEmpty()) + setNameFilters(nameFilters); + + if (opts->initialDirectory().isLocalFile()) + setDirectory(opts->initialDirectory()); + + foreach (const QUrl &filename, opts->initiallySelectedFiles()) + selectFile(filename); + + const QString initialNameFilter = opts->initiallySelectedNameFilter(); + if (!initialNameFilter.isEmpty()) + selectNameFilter(initialNameFilter); + +#if GTK_CHECK_VERSION(2, 20, 0) + GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK); + if (acceptButton) { + if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept)) + gtk_button_set_label(GTK_BUTTON(acceptButton), opts->labelText(QFileDialogOptions::Accept).toUtf8()); + else if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) + gtk_button_set_label(GTK_BUTTON(acceptButton), GTK_STOCK_OPEN); + else + gtk_button_set_label(GTK_BUTTON(acceptButton), GTK_STOCK_SAVE); + } + + GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL); + if (rejectButton) { + if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject)) + gtk_button_set_label(GTK_BUTTON(rejectButton), opts->labelText(QFileDialogOptions::Reject).toUtf8()); + else + gtk_button_set_label(GTK_BUTTON(rejectButton), GTK_STOCK_CANCEL); + } +#endif +} + +void QGtk2FileDialogHelper::setNameFilters(const QStringList &filters) +{ + GtkDialog *gtkDialog = d->gtkDialog(); + foreach (GtkFileFilter *filter, _filters) + gtk_file_chooser_remove_filter(GTK_FILE_CHOOSER(gtkDialog), filter); + + _filters.clear(); + _filterNames.clear(); + + foreach (const QString &filter, filters) { + GtkFileFilter *gtkFilter = gtk_file_filter_new(); + const QString name = filter.left(filter.indexOf(QLatin1Char('('))); + const QStringList extensions = cleanFilterList(filter); + + gtk_file_filter_set_name(gtkFilter, name.isEmpty() ? extensions.join(QStringLiteral(", ")).toUtf8() : name.toUtf8()); + foreach (const QString &ext, extensions) + gtk_file_filter_add_pattern(gtkFilter, ext.toUtf8()); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter); + + _filters.insert(filter, gtkFilter); + _filterNames.insert(gtkFilter, filter); + } +} + +QGtk2FontDialogHelper::QGtk2FontDialogHelper() +{ + d.reset(new QGtk2Dialog(gtk_font_selection_dialog_new(""))); + connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); + connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); +} + +QGtk2FontDialogHelper::~QGtk2FontDialogHelper() +{ +} + +bool QGtk2FontDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +{ + applyOptions(); + return d->show(flags, modality, parent); +} + +void QGtk2FontDialogHelper::exec() +{ + d->exec(); +} + +void QGtk2FontDialogHelper::hide() +{ + d->hide(); +} + +static QString qt_fontToString(const QFont &font) +{ + PangoFontDescription *desc = pango_font_description_new(); + pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE); + pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8()); + + int weight = font.weight(); + if (weight >= QFont::Black) + pango_font_description_set_weight(desc, PANGO_WEIGHT_HEAVY); + else if (weight >= QFont::ExtraBold) + pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRABOLD); + else if (weight >= QFont::Bold) + pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD); + else if (weight >= QFont::DemiBold) + pango_font_description_set_weight(desc, PANGO_WEIGHT_SEMIBOLD); + else if (weight >= QFont::Medium) + pango_font_description_set_weight(desc, PANGO_WEIGHT_MEDIUM); + else if (weight >= QFont::Normal) + pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL); + else if (weight >= QFont::Light) + pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT); + else if (weight >= QFont::ExtraLight) + pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRALIGHT); + else + pango_font_description_set_weight(desc, PANGO_WEIGHT_THIN); + + int style = font.style(); + if (style == QFont::StyleItalic) + pango_font_description_set_style(desc, PANGO_STYLE_ITALIC); + else if (style == QFont::StyleOblique) + pango_font_description_set_style(desc, PANGO_STYLE_OBLIQUE); + else + pango_font_description_set_style(desc, PANGO_STYLE_NORMAL); + + char *str = pango_font_description_to_string(desc); + QString name = QString::fromUtf8(str); + pango_font_description_free(desc); + g_free(str); + return name; +} + +static QFont qt_fontFromString(const QString &name) +{ + QFont font; + PangoFontDescription *desc = pango_font_description_from_string(name.toUtf8()); + font.setPointSizeF(static_cast(pango_font_description_get_size(desc)) / PANGO_SCALE); + + QString family = QString::fromUtf8(pango_font_description_get_family(desc)); + if (!family.isEmpty()) + font.setFamily(family); + + const int weight = pango_font_description_get_weight(desc); + font.setWeight(QPlatformFontDatabase::weightFromInteger(weight)); + + PangoStyle style = pango_font_description_get_style(desc); + if (style == PANGO_STYLE_ITALIC) + font.setStyle(QFont::StyleItalic); + else if (style == PANGO_STYLE_OBLIQUE) + font.setStyle(QFont::StyleOblique); + else + font.setStyle(QFont::StyleNormal); + + pango_font_description_free(desc); + return font; +} + +void QGtk2FontDialogHelper::setCurrentFont(const QFont &font) +{ + GtkFontSelectionDialog *gtkDialog = GTK_FONT_SELECTION_DIALOG(d->gtkDialog()); + gtk_font_selection_dialog_set_font_name(gtkDialog, qt_fontToString(font).toUtf8()); +} + +QFont QGtk2FontDialogHelper::currentFont() const +{ + GtkFontSelectionDialog *gtkDialog = GTK_FONT_SELECTION_DIALOG(d->gtkDialog()); + gchar *name = gtk_font_selection_dialog_get_font_name(gtkDialog); + QFont font = qt_fontFromString(QString::fromUtf8(name)); + g_free(name); + return font; +} + +void QGtk2FontDialogHelper::onAccepted() +{ + emit currentFontChanged(currentFont()); + emit accept(); + emit fontSelected(currentFont()); +} + +void QGtk2FontDialogHelper::applyOptions() +{ + GtkDialog *gtkDialog = d->gtkDialog(); + const QSharedPointer &opts = options(); + + gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); + + GtkWidget *okButton = gtk_font_selection_dialog_get_ok_button(GTK_FONT_SELECTION_DIALOG(gtkDialog)); + GtkWidget *cancelButton = gtk_font_selection_dialog_get_cancel_button(GTK_FONT_SELECTION_DIALOG(gtkDialog)); + if (okButton) + gtk_widget_set_visible(okButton, !options()->testOption(QFontDialogOptions::NoButtons)); + if (cancelButton) + gtk_widget_set_visible(cancelButton, !options()->testOption(QFontDialogOptions::NoButtons)); +} + +QT_END_NAMESPACE + +#include "qgtk2dialoghelpers.moc" diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTK2DIALOGHELPERS_P_H +#define QGTK2DIALOGHELPERS_P_H + +#include +#include +#include +#include +#include +#include + +typedef struct _GtkDialog GtkDialog; +typedef struct _GtkFileFilter GtkFileFilter; + +QT_BEGIN_NAMESPACE + +class QGtk2Dialog; +class QColor; + +class QGtk2ColorDialogHelper : public QPlatformColorDialogHelper +{ + Q_OBJECT + +public: + QGtk2ColorDialogHelper(); + ~QGtk2ColorDialogHelper(); + + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; + void exec() Q_DECL_OVERRIDE; + void hide() Q_DECL_OVERRIDE; + + void setCurrentColor(const QColor &color) Q_DECL_OVERRIDE; + QColor currentColor() const Q_DECL_OVERRIDE; + +private Q_SLOTS: + void onAccepted(); + +private: + static void onColorChanged(QGtk2ColorDialogHelper *helper); + void applyOptions(); + + QScopedPointer d; +}; + +class QGtk2FileDialogHelper : public QPlatformFileDialogHelper +{ + Q_OBJECT + +public: + QGtk2FileDialogHelper(); + ~QGtk2FileDialogHelper(); + + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; + void exec() Q_DECL_OVERRIDE; + void hide() Q_DECL_OVERRIDE; + + bool defaultNameFilterDisables() const Q_DECL_OVERRIDE; + void setDirectory(const QUrl &directory) Q_DECL_OVERRIDE; + QUrl directory() const Q_DECL_OVERRIDE; + void selectFile(const QUrl &filename) Q_DECL_OVERRIDE; + QList selectedFiles() const Q_DECL_OVERRIDE; + void setFilter() Q_DECL_OVERRIDE; + void selectNameFilter(const QString &filter) Q_DECL_OVERRIDE; + QString selectedNameFilter() const Q_DECL_OVERRIDE; + +private Q_SLOTS: + void onAccepted(); + +private: + static void onSelectionChanged(GtkDialog *dialog, QGtk2FileDialogHelper *helper); + static void onCurrentFolderChanged(QGtk2FileDialogHelper *helper); + void applyOptions(); + void setNameFilters(const QStringList &filters); + + QUrl _dir; + QList _selection; + QHash _filters; + QHash _filterNames; + QScopedPointer d; +}; + +class QGtk2FontDialogHelper : public QPlatformFontDialogHelper +{ + Q_OBJECT + +public: + QGtk2FontDialogHelper(); + ~QGtk2FontDialogHelper(); + + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; + void exec() Q_DECL_OVERRIDE; + void hide() Q_DECL_OVERRIDE; + + void setCurrentFont(const QFont &font) Q_DECL_OVERRIDE; + QFont currentFont() const Q_DECL_OVERRIDE; + +private Q_SLOTS: + void onAccepted(); + +private: + void applyOptions(); + + QScopedPointer d; +}; + +QT_END_NAMESPACE + +#endif // QGTK2DIALOGHELPERS_P_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2theme.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2theme.cpp --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2theme.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2theme.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgtk2theme.h" +#include "qgtk2dialoghelpers.h" +#include + +#undef signals +#include + +#include + +QT_BEGIN_NAMESPACE + +const char *QGtk2Theme::name = "gtk2"; + +static QString gtkSetting(const gchar *propertyName) +{ + GtkSettings *settings = gtk_settings_get_default(); + gchararray value; + g_object_get(settings, propertyName, &value, NULL); + QString str = QString::fromUtf8(value); + g_free(value); + return str; +} + +QGtk2Theme::QGtk2Theme() +{ + // gtk_init will reset the Xlib error handler, and that causes + // Qt applications to quit on X errors. Therefore, we need to manually restore it. + int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL); + + gtk_init(0, 0); + + XSetErrorHandler(oldErrorHandler); +} + +QVariant QGtk2Theme::themeHint(QPlatformTheme::ThemeHint hint) const +{ + switch (hint) { + case QPlatformTheme::SystemIconThemeName: + return QVariant(gtkSetting("gtk-icon-theme-name")); + case QPlatformTheme::SystemIconFallbackThemeName: + return QVariant(gtkSetting("gtk-fallback-icon-theme")); + case QPlatformTheme::StyleNames: + return QVariant(QStringList(QStringLiteral("gtk2"))); + default: + return QGnomeTheme::themeHint(hint); + } +} + +QString QGtk2Theme::gtkFontName() const +{ + QString cfgFontName = gtkSetting("gtk-font-name"); + if (!cfgFontName.isEmpty()) + return cfgFontName; + return QGnomeTheme::gtkFontName(); +} + +bool QGtk2Theme::usePlatformNativeDialog(DialogType type) const +{ + switch (type) { + case ColorDialog: + return true; + case FileDialog: + return true; + case FontDialog: + return true; + default: + return false; + } +} + +QPlatformDialogHelper *QGtk2Theme::createPlatformDialogHelper(DialogType type) const +{ + switch (type) { + case ColorDialog: + return new QGtk2ColorDialogHelper; + case FileDialog: + return new QGtk2FileDialogHelper; + case FontDialog: + return new QGtk2FontDialogHelper; + default: + return 0; + } +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2theme.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2theme.h --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/gtk2/qgtk2theme.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/gtk2/qgtk2theme.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTK2THEME_H +#define QGTK2THEME_H + +#include + +QT_BEGIN_NAMESPACE + +class QGtk2Theme : public QGnomeTheme +{ +public: + QGtk2Theme(); + + virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; + virtual QString gtkFontName() const Q_DECL_OVERRIDE; + + bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE; + QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE; + + static const char *name; +}; + +QT_END_NAMESPACE + +#endif // QGTK2THEME_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/platformthemes/platformthemes.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/platformthemes.pro --- qtstyleplugins-src-5.0.0/src/plugins/platformthemes/platformthemes.pro 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/platformthemes/platformthemes.pro 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +packagesExist(gtk+-2.0) { + SUBDIRS += gtk2 +} diff -Nru qtstyleplugins-src-5.0.0/src/plugins/plugins.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/plugins.pro --- qtstyleplugins-src-5.0.0/src/plugins/plugins.pro 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/plugins.pro 2017-03-11 09:23:02.000000000 +0000 @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = styles +SUBDIRS = platformthemes styles diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bb10lightstyle.qrc qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bb10lightstyle.qrc --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bb10lightstyle.qrc 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bb10lightstyle.qrc 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,54 @@ + + + light/button/core_button_disabled.png + light/button/core_button_inactive.png + light/button/core_button_pressed.png + light/checkbox/core_checkbox_checked.png + light/checkbox/core_checkbox_disabled.png + light/checkbox/core_checkbox_disabledchecked.png + light/checkbox/core_checkbox_enabled.png + light/checkbox/core_checkbox_pressed.png + light/checkbox/core_checkbox_pressedchecked.png + light/radiobutton/core_radiobutton_checked.png + light/radiobutton/core_radiobutton_disabled.png + light/radiobutton/core_radiobutton_disabledchecked.png + light/radiobutton/core_radiobutton_enabled.png + light/radiobutton/core_radiobutton_pressed.png + light/slider/core_slider_active.png + light/slider/core_slider_disabled.png + light/slider/core_slider_handle.png + light/slider/core_slider_handle_disabled.png + light/slider/core_slider_handle_pressed.png + light/slider/core_slider_inactive.png + light/slider/core_slider_vactive.png + light/slider/core_slider_vdisabled.png + light/slider/core_slider_vinactive.png + light/slider/core_slider_black.png + light/slider/core_slider_enabled.png + light/slider/core_slider_vblack.png + light/slider/core_slider_venabled.png + light/button/core_button_active.png + light/lineedit/core_textinput_bg.png + light/lineedit/core_textinput_bg_disabled.png + light/lineedit/core_textinput_bg_focused.png + light/progressbar/core_progressindicator_bg.png + light/progressbar/core_progressindicator_complete.png + light/progressbar/core_progressindicator_fill.png + light/progressbar/core_progressindicator_vbg.png + light/progressbar/core_progressindicator_vcomplete.png + light/progressbar/core_progressindicator_vfill.png + light/combobox/core_dropdown_button.png + light/combobox/core_dropdown_button_arrowdown.png + light/combobox/core_dropdown_button_arrowdown_pressed.png + light/combobox/core_dropdown_button_arrowup.png + light/combobox/core_dropdown_button_disabled.png + light/combobox/core_dropdown_button_pressed.png + light/combobox/core_dropdown_checkmark.png + light/combobox/core_dropdown_divider.png + light/combobox/core_dropdown_menu.png + light/combobox/core_dropdown_menuup.png + light/combobox/core_listitem_active.png + light/listitem/core_listitem_active.png + light/listitem/core_listitem_divider.png + + diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bb10style.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bb10style.pro --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bb10style.pro 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bb10style.pro 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,26 @@ +TARGET = bb10styleplugin + +PLUGIN_TYPE = styles +PLUGIN_CLASS_NAME = QBB10StylePlugin +load(qt_plugin) + +INCLUDEPATH += $$PWD + +QT += widgets-private + +HEADERS += \ + qbb10brightstyle.h \ + qbb10darkstyle.h \ + qbb10styleplugin.h + +SOURCES += \ + qbb10brightstyle.cpp \ + qbb10darkstyle.cpp \ + qbb10styleplugin.cpp + +RESOURCES += \ + qbb10brightstyle.qrc \ + qbb10darkstyle.qrc + +OTHER_FILES += qbb10styleplugin.json + Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/button/core_button_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/button/core_button_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/button/core_button_inactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/button/core_button_inactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/button/core_button_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/button/core_button_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_active.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_active.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/button/core_button_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/button/core_button_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/button/core_button_inactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/button/core_button_inactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/button/core_button_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/button/core_button_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_active.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_active.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png differ Binary files /tmp/tmpYMDMUp/aMAAuJHAuH/qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png and /tmp/tmpYMDMUp/rzRlAFu2Ec/qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png differ diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10brightstyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10brightstyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10brightstyle.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10brightstyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,344 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbb10brightstyle.h" + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QBB10BrightStyle::QBB10BrightStyle() : + QPixmapStyle() +{ + addDescriptor(PB_Enabled, + QLatin1String("://bright/button/core_button_inactive.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_Checked, + QLatin1String("://bright/button/core_button_enabled_selected.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_Pressed, + QLatin1String("://bright/button/core_button_pressed.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_Disabled, + QLatin1String("://bright/button/core_button_disabled.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_PressedDisabled, + QLatin1String("://bright/button/core_button_disabled_selected.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + + addDescriptor(LE_Enabled, + QLatin1String("://bright/lineedit/core_textinput_bg.png"), + QMargins(8, 8, 8, 8)); + addDescriptor(LE_Disabled, + QLatin1String("://bright/lineedit/core_textinput_bg_disabled.png"), + QMargins(8, 8, 8, 8)); + addDescriptor(LE_Focused, + QLatin1String("://bright/lineedit/core_textinput_bg_highlight.png"), + QMargins(8, 8, 8, 8)); + + copyDescriptor(LE_Enabled, TE_Enabled); + copyDescriptor(LE_Disabled, TE_Disabled); + copyDescriptor(LE_Focused, TE_Focused); + + addPixmap(CB_Enabled, + QLatin1String("://bright/checkbox/core_checkbox_enabled.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_Checked, + QLatin1String("://bright/checkbox/core_checkbox_checked.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_Pressed, + QLatin1String("://bright/checkbox/core_checkbox_pressed.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_PressedChecked, + QLatin1String("://bright/checkbox/core_checkbox_pressed_checked.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_Disabled, + QLatin1String("://bright/checkbox/core_checkbox_disabled.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_DisabledChecked, + QLatin1String("://bright/checkbox/core_checkbox_disabled_checked.png"), + QMargins(16, 16, 16, 16)); + + addPixmap(RB_Enabled, + QLatin1String("://bright/radiobutton/core_radiobutton_inactive.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_Checked, + QLatin1String("://bright/radiobutton/core_radiobutton_checked.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_Pressed, + QLatin1String("://bright/radiobutton/core_radiobutton_pressed.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_Disabled, + QLatin1String("://bright/radiobutton/core_radiobutton_disabled.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_DisabledChecked, + QLatin1String("://bright/radiobutton/core_radiobutton_disabled_checked.png"), + QMargins(16, 16, 16, 16)); + + addDescriptor(PB_HBackground, + QLatin1String("://bright/progressbar/core_progressindicator_bg.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_HContent, + QLatin1String("://bright/progressbar/core_progressindicator_fill.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_HComplete, + QLatin1String("://bright/progressbar/core_progressindicator_complete.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_VBackground, + QLatin1String("://bright/progressbar/core_progressindicator_vbg.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(PB_VContent, + QLatin1String("://bright/progressbar/core_progressindicator_vfill.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(PB_VComplete, + QLatin1String("://bright/progressbar/core_progressindicator_vcomplete.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + + addDescriptor(SG_HEnabled, + QLatin1String("://bright/slider/core_slider_enabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HDisabled, + QLatin1String("://bright/slider/core_slider_disabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HActiveEnabled, + QLatin1String("://bright/slider/core_slider_inactive.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HActivePressed, + QLatin1String("://bright/slider/core_slider_active.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HActiveDisabled, + QLatin1String("://bright/slider/core_slider_cache.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_VEnabled, + QLatin1String("://bright/slider/core_slider_venabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VDisabled, + QLatin1String("://bright/slider/core_slider_vdisabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VActiveEnabled, + QLatin1String("://bright/slider/core_slider_vinactive.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VActivePressed, + QLatin1String("://bright/slider/core_slider_vactive.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VActiveDisabled, + QLatin1String("://bright/slider/core_slider_vcache.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + + addPixmap(SH_HEnabled, + QLatin1String("://bright/slider/core_slider_handle.png")); + addPixmap(SH_HDisabled, + QLatin1String("://bright/slider/core_slider_handle_disabled.png")); + addPixmap(SH_HPressed, + QLatin1String("://bright/slider/core_slider_handle_pressed.png")); + addPixmap(SH_VEnabled, + QLatin1String("://bright/slider/core_slider_handle.png")); + addPixmap(SH_VDisabled, + QLatin1String("://bright/slider/core_slider_handle_disabled.png")); + addPixmap(SH_VPressed, + QLatin1String("://bright/slider/core_slider_handle_pressed.png")); + + addDescriptor(DD_ButtonEnabled, + QLatin1String("://bright/combobox/core_dropdown_button.png"), + QMargins(14, 14, 14, 14), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(DD_ButtonDisabled, + QLatin1String("://bright/combobox/core_dropdown_button_disabled.png"), + QMargins(14, 14, 14, 14), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(DD_ButtonPressed, + QLatin1String("://bright/combobox/core_dropdown_button_pressed.png"), + QMargins(14, 14, 14, 14), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(DD_ItemSelected, + QLatin1String("://bright/combobox/core_listitem_active.png")); + + addPixmap(DD_ArrowEnabled, + QLatin1String("://bright/combobox/core_dropdown_button_arrowdown.png"), + QMargins(35, 39, 35, 39)); + copyPixmap(DD_ArrowEnabled, DD_ArrowDisabled); + addPixmap(DD_ArrowPressed, + QLatin1String("://bright/combobox/core_dropdown_button_arrowdown_pressed.png"), + QMargins(35, 39, 35, 39)); + addPixmap(DD_ArrowOpen, + QLatin1String("://bright/combobox/core_dropdown_button_arrowup.png"), + QMargins(35, 39, 35, 39)); + addDescriptor(DD_PopupDown, + QLatin1String("://bright/combobox/core_dropdown_menu.png"), + QMargins(12, 12, 12, 12), + QTileRules(Qt::StretchTile, Qt::StretchTile)); + addDescriptor(DD_PopupUp, + QLatin1String("://bright/combobox/core_dropdown_menuup.png"), + QMargins(12, 12, 12, 12), + QTileRules(Qt::StretchTile, Qt::StretchTile)); + addPixmap(DD_ItemSeparator, + QLatin1String("://bright/combobox/core_dropdown_divider.png"), + QMargins(5, 0, 5, 0)); + + addDescriptor(ID_Selected, + QLatin1String("://bright/listitem/core_listitem_active.png")); + addPixmap(ID_Separator, + QLatin1String("://bright/listitem/core_listitem_divider.png")); + + addDescriptor(SB_Horizontal, + QLatin1String("://bright/scrollbar/core_scrollbar.png"), + QMargins(7, 8, 7, 8), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SB_Vertical, + QLatin1String("://bright/scrollbar/core_scrollbar_v.png"), + QMargins(8, 7, 8, 7), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); +} + +QBB10BrightStyle::~QBB10BrightStyle() +{ +} + +void QBB10BrightStyle::polish(QApplication *application) +{ + QPixmapStyle::polish(application); +} + +void QBB10BrightStyle::polish(QWidget *widget) +{ + // Hide the text by default + if (QProgressBar *pb = qobject_cast(widget)) + pb->setTextVisible(false); + + if (QComboBox *cb = qobject_cast(widget)) { + QAbstractItemView *list = cb->view(); + QPalette p = list->palette(); + p.setBrush(QPalette::HighlightedText, p.brush(QPalette::Text)); + list->setPalette(p); + } + + if (qobject_cast(widget)) { + QPalette p = widget->palette(); + p.setBrush(QPalette::Disabled, QPalette::HighlightedText, p.brush(QPalette::Text)); + widget->setPalette(p); + } + + QPixmapStyle::polish(widget); +} + +QPalette QBB10BrightStyle::standardPalette() const +{ + QPalette p; + + QColor color = QColor(38, 38, 38); + p.setBrush(QPalette::ButtonText, color); + p.setBrush(QPalette::WindowText, color); + p.setBrush(QPalette::Text, color); + + color.setAlpha(179); + p.setBrush(QPalette::Disabled, QPalette::ButtonText, color); + p.setBrush(QPalette::Disabled, QPalette::WindowText, color); + p.setBrush(QPalette::Disabled, QPalette::Text, color); + + p.setColor(QPalette::Window, QColor(248, 248, 248)); + + p.setBrush(QPalette::Highlight, QColor(0, 168, 223)); + p.setBrush(QPalette::HighlightedText, QColor(250, 250,250)); + + return p; +} + +void QBB10BrightStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + switch (element) { + case CE_PushButtonLabel: + { + const bool on = option->state & State_On || option->state & State_Sunken; + const QStyleOptionButton *button = qstyleoption_cast(option); + QStyleOptionButton newOpt = *button; + if (on) + newOpt.palette.setBrush(QPalette::ButtonText, QColor(250, 250, 250)); + QPixmapStyle::drawControl(CE_PushButtonLabel, &newOpt, painter, widget); + break; + } + case CE_ProgressBarLabel: + // Don't draw the progress bar label + break; + default: + QPixmapStyle::drawControl(element, option, painter, widget); + } +} + +void QBB10BrightStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + QPixmapStyle::drawPrimitive(element, option, painter, widget); + + if (element == PE_PanelItemViewItem) { + // Draw the checkbox for current item + if (widget->property("_pixmap_combobox_list").toBool() + && option->state & QStyle::State_Selected) { + QPixmap pix(QLatin1String("://bright/combobox/core_dropdown_checkmark.png")); + QRect rect = option->rect; + const int margin = rect.height() / 2; + QPoint pos(rect.right() - margin - pix.width() / 2, + rect.top() + margin - pix.height() / 2); + painter->drawPixmap(pos, pix); + } + } +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10brightstyle.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10brightstyle.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10brightstyle.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10brightstyle.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,62 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBB10BRIGHTSTYLE_H +#define QBB10BRIGHTSTYLE_H + +#include + +QT_BEGIN_NAMESPACE + +class QBB10BrightStyle : public QPixmapStyle +{ + Q_OBJECT + +public: + QBB10BrightStyle(); + ~QBB10BrightStyle(); + + void polish(QApplication *application) Q_DECL_OVERRIDE; + void polish(QWidget *widget) Q_DECL_OVERRIDE; + + QPalette standardPalette() const Q_DECL_OVERRIDE; + + void drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif // QBB10BRIGHTSTYLE_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10brightstyle.qrc qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10brightstyle.qrc --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10brightstyle.qrc 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10brightstyle.qrc 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,57 @@ + + + bright/button/core_button_disabled.png + bright/button/core_button_disabled_selected.png + bright/button/core_button_inactive.png + bright/button/core_button_enabled_selected.png + bright/button/core_button_pressed.png + bright/checkbox/core_checkbox_checked.png + bright/checkbox/core_checkbox_disabled.png + bright/checkbox/core_checkbox_disabled_checked.png + bright/checkbox/core_checkbox_enabled.png + bright/checkbox/core_checkbox_pressed.png + bright/checkbox/core_checkbox_pressed_checked.png + bright/combobox/core_dropdown_button.png + bright/combobox/core_dropdown_button_arrowdown.png + bright/combobox/core_dropdown_button_arrowdown_pressed.png + bright/combobox/core_dropdown_button_arrowup.png + bright/combobox/core_dropdown_button_disabled.png + bright/combobox/core_dropdown_button_pressed.png + bright/combobox/core_dropdown_checkmark.png + bright/combobox/core_dropdown_divider.png + bright/combobox/core_dropdown_menu.png + bright/combobox/core_dropdown_menuup.png + bright/combobox/core_listitem_active.png + bright/lineedit/core_textinput_bg.png + bright/lineedit/core_textinput_bg_disabled.png + bright/lineedit/core_textinput_bg_highlight.png + bright/listitem/core_listitem_active.png + bright/listitem/core_listitem_divider.png + bright/progressbar/core_progressindicator_bg.png + bright/progressbar/core_progressindicator_complete.png + bright/progressbar/core_progressindicator_fill.png + bright/progressbar/core_progressindicator_vbg.png + bright/progressbar/core_progressindicator_vcomplete.png + bright/progressbar/core_progressindicator_vfill.png + bright/radiobutton/core_radiobutton_checked.png + bright/radiobutton/core_radiobutton_disabled.png + bright/radiobutton/core_radiobutton_disabled_checked.png + bright/radiobutton/core_radiobutton_inactive.png + bright/radiobutton/core_radiobutton_pressed.png + bright/scrollbar/core_scrollbar.png + bright/scrollbar/core_scrollbar_v.png + bright/slider/core_slider_active.png + bright/slider/core_slider_cache.png + bright/slider/core_slider_disabled.png + bright/slider/core_slider_enabled.png + bright/slider/core_slider_handle.png + bright/slider/core_slider_handle_disabled.png + bright/slider/core_slider_handle_pressed.png + bright/slider/core_slider_inactive.png + bright/slider/core_slider_vactive.png + bright/slider/core_slider_vcache.png + bright/slider/core_slider_vdisabled.png + bright/slider/core_slider_venabled.png + bright/slider/core_slider_vinactive.png + + diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10darkstyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10darkstyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10darkstyle.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10darkstyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,349 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbb10darkstyle.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QBB10DarkStyle::QBB10DarkStyle() : + QPixmapStyle() +{ + addDescriptor(PB_Enabled, + QLatin1String("://dark/button/core_button_inactive.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_Checked, + QLatin1String("://dark/button/core_button_enabled_selected.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_Pressed, + QLatin1String("://dark/button/core_button_pressed.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_Disabled, + QLatin1String("://dark/button/core_button_disabled.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_PressedDisabled, + QLatin1String("://dark/button/core_button_disabled_selected.png"), + QMargins(13, 13, 13, 13), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + + addDescriptor(LE_Enabled, + QLatin1String("://dark/lineedit/core_textinput_bg.png"), + QMargins(8, 8, 8, 8)); + addDescriptor(LE_Disabled, + QLatin1String("://dark/lineedit/core_textinput_bg_disabled.png"), + QMargins(8, 8, 8, 8)); + addDescriptor(LE_Focused, + QLatin1String("://dark/lineedit/core_textinput_bg_highlight.png"), + QMargins(8, 8, 8, 8)); + + copyDescriptor(LE_Enabled, TE_Enabled); + copyDescriptor(LE_Disabled, TE_Disabled); + copyDescriptor(LE_Focused, TE_Focused); + + addPixmap(CB_Enabled, + QLatin1String("://dark/checkbox/core_checkbox_enabled.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_Checked, + QLatin1String("://dark/checkbox/core_checkbox_checked.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_Pressed, + QLatin1String("://dark/checkbox/core_checkbox_pressed.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_PressedChecked, + QLatin1String("://dark/checkbox/core_checkbox_pressed_checked.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_Disabled, + QLatin1String("://dark/checkbox/core_checkbox_disabled.png"), + QMargins(16, 16, 16, 16)); + addPixmap(CB_DisabledChecked, + QLatin1String("://dark/checkbox/core_checkbox_disabled_checked.png"), + QMargins(16, 16, 16, 16)); + + addPixmap(RB_Enabled, + QLatin1String("://dark/radiobutton/core_radiobutton_inactive.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_Checked, + QLatin1String("://dark/radiobutton/core_radiobutton_checked.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_Pressed, + QLatin1String("://dark/radiobutton/core_radiobutton_pressed.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_Disabled, + QLatin1String("://dark/radiobutton/core_radiobutton_disabled.png"), + QMargins(16, 16, 16, 16)); + addPixmap(RB_DisabledChecked, + QLatin1String("://dark/radiobutton/core_radiobutton_disabled_checked.png"), + QMargins(16, 16, 16, 16)); + + addDescriptor(PB_HBackground, + QLatin1String("://dark/progressbar/core_progressindicator_bg.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_HContent, + QLatin1String("://dark/progressbar/core_progressindicator_fill.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_HComplete, + QLatin1String("://dark/progressbar/core_progressindicator_complete.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(PB_VBackground, + QLatin1String("://dark/progressbar/core_progressindicator_vbg.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(PB_VContent, + QLatin1String("://dark/progressbar/core_progressindicator_vfill.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(PB_VComplete, + QLatin1String("://dark/progressbar/core_progressindicator_vcomplete.png"), + QMargins(10, 10, 10, 10), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + + addDescriptor(SG_HEnabled, + QLatin1String("://dark/slider/core_slider_enabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HDisabled, + QLatin1String("://dark/slider/core_slider_disabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HActiveEnabled, + QLatin1String("://dark/slider/core_slider_inactive.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HActivePressed, + QLatin1String("://dark/slider/core_slider_active.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_HActiveDisabled, + QLatin1String("://dark/slider/core_slider_cache.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SG_VEnabled, + QLatin1String("://dark/slider/core_slider_venabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VDisabled, + QLatin1String("://dark/slider/core_slider_vdisabled.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VActiveEnabled, + QLatin1String("://dark/slider/core_slider_vinactive.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VActivePressed, + QLatin1String("://dark/slider/core_slider_vactive.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + addDescriptor(SG_VActiveDisabled, + QLatin1String("://dark/slider/core_slider_vcache.png"), + QMargins(50, 50, 50, 50), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); + + addPixmap(SH_HEnabled, + QLatin1String("://dark/slider/core_slider_handle.png")); + addPixmap(SH_HDisabled, + QLatin1String("://dark/slider/core_slider_handle_disabled.png")); + addPixmap(SH_HPressed, + QLatin1String("://dark/slider/core_slider_handle_pressed.png")); + addPixmap(SH_VEnabled, + QLatin1String("://dark/slider/core_slider_handle.png")); + addPixmap(SH_VDisabled, + QLatin1String("://dark/slider/core_slider_handle_disabled.png")); + addPixmap(SH_VPressed, + QLatin1String("://dark/slider/core_slider_handle_pressed.png")); + + addDescriptor(DD_ButtonEnabled, + QLatin1String("://dark/combobox/core_dropdown_button.png"), + QMargins(14, 14, 14, 14), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(DD_ButtonDisabled, + QLatin1String("://dark/combobox/core_dropdown_button_disabled.png"), + QMargins(14, 14, 14, 14), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(DD_ButtonPressed, + QLatin1String("://dark/combobox/core_dropdown_button_pressed.png"), + QMargins(14, 14, 14, 14), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(DD_ItemSelected, + QLatin1String("://dark/combobox/core_listitem_active.png")); + addPixmap(DD_ArrowEnabled, + QLatin1String("://dark/combobox/core_dropdown_button_arrowdown.png"), + QMargins(35, 39, 35, 39)); + copyPixmap(DD_ArrowEnabled, DD_ArrowDisabled); + addPixmap(DD_ArrowPressed, + QLatin1String("://dark/combobox/core_dropdown_button_arrowdown_pressed.png"), + QMargins(35, 39, 35, 39)); + addPixmap(DD_ArrowOpen, + QLatin1String("://dark/combobox/core_dropdown_button_arrowup.png"), + QMargins(35, 39, 35, 39)); + addDescriptor(DD_PopupDown, + QLatin1String("://dark/combobox/core_dropdown_menu.png"), + QMargins(12, 12, 12, 12), QTileRules(Qt::StretchTile, Qt::StretchTile)); + addDescriptor(DD_PopupUp, + QLatin1String("://dark/combobox/core_dropdown_menuup.png"), + QMargins(12, 12, 12, 12), QTileRules(Qt::StretchTile, Qt::StretchTile)); + addPixmap(DD_ItemSeparator, + QLatin1String("://dark/combobox/core_dropdown_divider.png"), + QMargins(5, 0, 5, 0)); + + addDescriptor(ID_Selected, + QLatin1String("://dark/listitem/core_listitem_active.png")); + addPixmap(ID_Separator, + QLatin1String("://dark/listitem/core_listitem_divider.png")); + + addDescriptor(SB_Horizontal, + QLatin1String("://dark/scrollbar/core_scrollbar.png"), + QMargins(7, 8, 7, 8), + QTileRules(Qt::RepeatTile, Qt::StretchTile)); + addDescriptor(SB_Vertical, + QLatin1String("://dark/scrollbar/core_scrollbar_v.png"), + QMargins(8, 7, 8, 7), + QTileRules(Qt::StretchTile, Qt::RepeatTile)); +} + +QBB10DarkStyle::~QBB10DarkStyle() +{ +} + +void QBB10DarkStyle::polish(QApplication *application) +{ + QPixmapStyle::polish(application); +} + +void QBB10DarkStyle::polish(QWidget *widget) +{ + // Hide the text by default + if (QProgressBar *pb = qobject_cast(widget)) + pb->setTextVisible(false); + + if (QComboBox *cb = qobject_cast(widget)) { + QAbstractItemView *list = cb->view(); + QPalette p = list->palette(); + p.setBrush(QPalette::HighlightedText, p.brush(QPalette::Text)); + list->setPalette(p); + } + + if (qobject_cast(widget) || qobject_cast(widget)) { + QPalette p = widget->palette(); + p.setBrush(QPalette::Text, QColor(38, 38, 38)); + widget->setPalette(p); + } + + if (qobject_cast(widget)) { + QPalette p = widget->palette(); + p.setBrush(QPalette::Disabled, QPalette::HighlightedText, p.brush(QPalette::Text)); + widget->setPalette(p); + } + + QPixmapStyle::polish(widget); +} + +QPalette QBB10DarkStyle::standardPalette() const +{ + QPalette p; + + QColor color = QColor(250, 250, 250); + p.setBrush(QPalette::ButtonText, color); + p.setBrush(QPalette::WindowText, color); + p.setBrush(QPalette::Text, color); + + color.setAlpha(179); + p.setBrush(QPalette::Disabled, QPalette::ButtonText, color); + p.setBrush(QPalette::Disabled, QPalette::WindowText, color); + p.setBrush(QPalette::Disabled, QPalette::Text, color); + + p.setColor(QPalette::Window, QColor(18, 18, 18)); + + p.setBrush(QPalette::Highlight, QColor(0, 168, 223)); + p.setBrush(QPalette::HighlightedText, QColor(250, 250,250)); + + return p; +} + +void QBB10DarkStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + switch (element) { + case CE_PushButtonLabel: + { + const bool on = option->state & State_On || option->state & State_Sunken; + const QStyleOptionButton *button = qstyleoption_cast(option); + QStyleOptionButton newOpt = *button; + if (on) + newOpt.palette.setBrush(QPalette::ButtonText, QColor(38, 38, 38)); + QPixmapStyle::drawControl(CE_PushButtonLabel, &newOpt, painter, widget); + break; + } + case CE_ProgressBarLabel: + // Don't draw the progress bar label + break; + default: + QPixmapStyle::drawControl(element, option, painter, widget); + } +} + +void QBB10DarkStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + QPixmapStyle::drawPrimitive(element, option, painter, widget); + + if (element == PE_PanelItemViewItem) { + // Draw the checkbox for current item + if (widget->property("_pixmap_combobox_list").toBool() + && option->state & QStyle::State_Selected) { + QPixmap pix(QLatin1String("://dark/combobox/core_dropdown_checkmark.png")); + QRect rect = option->rect; + const int margin = rect.height() / 2; + QPoint pos(rect.right() - margin - pix.width() / 2, + rect.top() + margin - pix.height() / 2); + painter->drawPixmap(pos, pix); + } + } +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10darkstyle.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10darkstyle.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10darkstyle.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10darkstyle.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,62 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBB10DARKSTYLE_H +#define QBB10DARKSTYLE_H + +#include + +QT_BEGIN_NAMESPACE + +class QBB10DarkStyle : public QPixmapStyle +{ + Q_OBJECT + +public: + QBB10DarkStyle(); + ~QBB10DarkStyle(); + + void polish(QApplication *application) Q_DECL_OVERRIDE; + void polish(QWidget *widget) Q_DECL_OVERRIDE; + + QPalette standardPalette() const Q_DECL_OVERRIDE; + + void drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif // QBB10DARKSTYLE_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10darkstyle.qrc qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10darkstyle.qrc --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10darkstyle.qrc 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10darkstyle.qrc 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,57 @@ + + + dark/button/core_button_disabled.png + dark/button/core_button_disabled_selected.png + dark/button/core_button_inactive.png + dark/button/core_button_enabled_selected.png + dark/button/core_button_pressed.png + dark/checkbox/core_checkbox_checked.png + dark/checkbox/core_checkbox_disabled.png + dark/checkbox/core_checkbox_disabled_checked.png + dark/checkbox/core_checkbox_enabled.png + dark/checkbox/core_checkbox_pressed.png + dark/checkbox/core_checkbox_pressed_checked.png + dark/combobox/core_dropdown_button.png + dark/combobox/core_dropdown_button_arrowdown.png + dark/combobox/core_dropdown_button_arrowdown_pressed.png + dark/combobox/core_dropdown_button_arrowup.png + dark/combobox/core_dropdown_button_disabled.png + dark/combobox/core_dropdown_button_pressed.png + dark/combobox/core_dropdown_checkmark.png + dark/combobox/core_dropdown_divider.png + dark/combobox/core_dropdown_menu.png + dark/combobox/core_dropdown_menuup.png + dark/combobox/core_listitem_active.png + dark/lineedit/core_textinput_bg.png + dark/lineedit/core_textinput_bg_disabled.png + dark/lineedit/core_textinput_bg_highlight.png + dark/listitem/core_listitem_active.png + dark/listitem/core_listitem_divider.png + dark/progressbar/core_progressindicator_bg.png + dark/progressbar/core_progressindicator_complete.png + dark/progressbar/core_progressindicator_fill.png + dark/progressbar/core_progressindicator_vbg.png + dark/progressbar/core_progressindicator_vcomplete.png + dark/progressbar/core_progressindicator_vfill.png + dark/radiobutton/core_radiobutton_checked.png + dark/radiobutton/core_radiobutton_disabled.png + dark/radiobutton/core_radiobutton_disabled_checked.png + dark/radiobutton/core_radiobutton_inactive.png + dark/radiobutton/core_radiobutton_pressed.png + dark/scrollbar/core_scrollbar.png + dark/scrollbar/core_scrollbar_v.png + dark/slider/core_slider_active.png + dark/slider/core_slider_cache.png + dark/slider/core_slider_disabled.png + dark/slider/core_slider_enabled.png + dark/slider/core_slider_handle.png + dark/slider/core_slider_handle_disabled.png + dark/slider/core_slider_handle_pressed.png + dark/slider/core_slider_inactive.png + dark/slider/core_slider_vactive.png + dark/slider/core_slider_vcache.png + dark/slider/core_slider_vdisabled.png + dark/slider/core_slider_venabled.png + dark/slider/core_slider_vinactive.png + + diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10styleplugin.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10styleplugin.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10styleplugin.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10styleplugin.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,61 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbb10styleplugin.h" +#include "qbb10darkstyle.h" +#include "qbb10brightstyle.h" + +QT_BEGIN_NAMESPACE + +QBB10StylePlugin::QBB10StylePlugin() +{ +} + +QBB10StylePlugin::~QBB10StylePlugin() +{ +} + +QStyle *QBB10StylePlugin::create(const QString &key) +{ + const QString keyLower(key.toLower()); + if (keyLower == QLatin1String("bb10bright")) + return new QBB10BrightStyle; + else if (keyLower == QLatin1String("bb10dark")) + return new QBB10DarkStyle; + + return 0; +} + +QT_END_NAMESPACE + +#include "moc_qbb10styleplugin.cpp" diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10styleplugin.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10styleplugin.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10styleplugin.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10styleplugin.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,55 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBB10STYLEPLUGIN_H +#define QBB10STYLEPLUGIN_H + +#include + +QT_BEGIN_NAMESPACE + +class QBB10StylePlugin : public QStylePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "qbb10styleplugin.json") + +public: + QBB10StylePlugin(); + ~QBB10StylePlugin(); + + QStyle *create(const QString &key) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif // QBB10STYLEPLUGIN_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10styleplugin.json qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10styleplugin.json --- qtstyleplugins-src-5.0.0/src/plugins/styles/bb10style/qbb10styleplugin.json 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/bb10style/qbb10styleplugin.json 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,3 @@ +{ + "Keys": [ "bb10bright", "bb10dark" ] +} diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/cleanlooks/cleanlooks.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/cleanlooks/cleanlooks.pro --- qtstyleplugins-src-5.0.0/src/plugins/styles/cleanlooks/cleanlooks.pro 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/cleanlooks/cleanlooks.pro 2017-03-11 09:23:02.000000000 +0000 @@ -1,5 +1,6 @@ TARGET = qcleanlooksstyle PLUGIN_TYPE = styles +PLUGIN_CLASS_NAME = QCleanlooksStylePlugin load(qt_plugin) QT = core gui widgets diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -609,7 +609,6 @@ QCleanlooksStyle::QCleanlooksStyle() : QProxyStyle(QStyleFactory::create(QLatin1String("Windows"))), animateStep(0), animateTimer(0) { setObjectName(QLatin1String("CleanLooks")); - startTime.start(); } /*! @@ -1591,9 +1590,7 @@ case CE_DockWidgetTitle: painter->save(); if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast(option)) { - const QStyleOptionDockWidgetV2 *v2 - = qstyleoption_cast(dwOpt); - bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; + bool verticalTitleBar = dwOpt->verticalTitleBar; QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget); if (verticalTitleBar) { @@ -1711,16 +1708,10 @@ painter->save(); if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { QRect rect = bar->rect; - bool vertical = false; - bool inverted = false; + bool vertical = (bar->orientation == Qt::Vertical); + bool inverted = bar->invertedAppearance; bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); - // Get extra style options if version 2 - if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast(option)) { - vertical = (bar2->orientation == Qt::Vertical); - inverted = bar2->invertedAppearance; - } - // If the orientation is vertical, we use a transform to rotate // the progress bar 90 degrees clockwise. This way we can use the // same rendering code for both orientations. @@ -1749,7 +1740,7 @@ progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3); } } else { - int slideWidth = ((rect.width() - 4) * 2) / 3; + int slideWidth = (qMax(rect.width() - 4, minWidth) * 2) / 3; int step = ((animateStep * slideWidth) / progressAnimationFps) % slideWidth; if ((((animateStep * slideWidth) / progressAnimationFps) % (2 * slideWidth)) >= slideWidth) step = slideWidth - step; @@ -2333,7 +2324,7 @@ #endif // QT_NO_TABBAR default: - QProxyStyle::drawControl(element,option,painter,widget); + QCommonStyle::drawControl(element,option,painter,widget); break; } } @@ -3337,11 +3328,11 @@ if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); - bool flat = groupBox->features & QStyleOptionFrameV2::Flat; + bool flat = groupBox->features & QStyleOptionFrame::Flat; if (!flat) { if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { - QStyleOptionFrameV2 frame; + QStyleOptionFrame frame; frame.QStyleOption::operator=(*groupBox); frame.features = groupBox->features; frame.lineWidth = groupBox->lineWidth; @@ -3953,17 +3944,26 @@ /*! \reimp */ -void QCleanlooksStyle::timerEvent(QTimerEvent *event) +bool QCleanlooksStyle::event(QEvent *event) { + switch (event->type()) { + case QEvent::Timer: { #ifndef QT_NO_PROGRESSBAR - if (event->timerId() == animateTimer) { - Q_ASSERT(progressAnimationFps> 0); - animateStep = startTime.elapsed() / (1000 / progressAnimationFps); - foreach (QProgressBar *bar, animatedProgressBars) - bar->update(); - } + QTimerEvent *timerEvent = reinterpret_cast(event); + if (timerEvent->timerId() == animateTimer) { + Q_ASSERT(progressAnimationFps > 0); + animateStep = startTime.elapsed() / (1000 / progressAnimationFps); + foreach (QProgressBar *bar, animatedProgressBars) + bar->update(); + } #endif // QT_NO_PROGRESSBAR - event->ignore(); + event->ignore(); + } + default: + break; + } + + return QProxyStyle::event(event); } /*! @@ -4006,6 +4006,8 @@ animatedProgressBars << bar; if (!animateTimer) { Q_ASSERT(progressAnimationFps > 0); + animateStep = 0; + startTime.start(); animateTimer = o->startTimer(1000 / progressAnimationFps); } } @@ -4013,10 +4015,12 @@ void QCleanlooksStyle::stopProgressAnimation(QObject *o, QProgressBar *bar) { - animatedProgressBars.removeAll(bar); - if (animatedProgressBars.isEmpty() && animateTimer) { - o->killTimer(animateTimer); - animateTimer = 0; + if (!animatedProgressBars.isEmpty()) { + animatedProgressBars.removeOne(bar); + if (animatedProgressBars.isEmpty() && animateTimer) { + o->killTimer(animateTimer); + animateTimer = 0; + } } } @@ -4129,7 +4133,7 @@ int topMargin = 0; int topHeight = 0; int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); - bool flat = groupBox->features & QStyleOptionFrameV2::Flat; + bool flat = groupBox->features & QStyleOptionFrame::Flat; if (!groupBox->text.isEmpty()) { topHeight = groupBox->fontMetrics.height(); if (verticalAlignment & Qt::AlignVCenter) @@ -4422,9 +4426,9 @@ r.adjust(0, 1, 0, -1); break; case SE_DockWidgetTitleBarText: { - const QStyleOptionDockWidgetV2 *v2 - = qstyleoption_cast(opt); - bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; + const QStyleOptionDockWidget *dwOpt + = qstyleoption_cast(opt); + bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar; if (verticalTitleBar) { r.adjust(0, 0, 0, -4); } else { diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/cleanlooks/qcleanlooksstyle.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/cleanlooks/qcleanlooksstyle.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/cleanlooks/qcleanlooksstyle.h 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/cleanlooks/qcleanlooksstyle.h 2017-03-11 09:23:02.000000000 +0000 @@ -59,46 +59,46 @@ QCleanlooksStyle(); ~QCleanlooksStyle(); - QPalette standardPalette () const; + QPalette standardPalette () const Q_DECL_OVERRIDE; void drawPrimitive(PrimitiveElement elem, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0) const; + QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE; void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter, - const QWidget *widget) const; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; + const QWidget *widget) const Q_DECL_OVERRIDE; + int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE; void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const; + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const Q_DECL_OVERRIDE; QSize sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const; + const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE; SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, - const QPoint &pt, const QWidget *w = 0) const; + const QPoint &pt, const QWidget *w = 0) const Q_DECL_OVERRIDE; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget) const; + SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, - const QStyleOption *opt) const; + const QStyleOption *opt) const Q_DECL_OVERRIDE; int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const; - QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const; + QStyleHintReturn *returnData = 0) const Q_DECL_OVERRIDE; + QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE; QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; void drawItemPixmap(QPainter *painter, const QRect &rect, - int alignment, const QPixmap &pixmap) const; + int alignment, const QPixmap &pixmap) const Q_DECL_OVERRIDE; void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, - const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const; - void polish(QWidget *widget); - void polish(QApplication *app); - void polish(QPalette &pal); - void unpolish(QWidget *widget); - void unpolish(QApplication *app); + const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const Q_DECL_OVERRIDE; + void polish(QWidget *widget) Q_DECL_OVERRIDE; + void polish(QApplication *app) Q_DECL_OVERRIDE; + void polish(QPalette &pal) Q_DECL_OVERRIDE; + void unpolish(QWidget *widget) Q_DECL_OVERRIDE; + void unpolish(QApplication *app) Q_DECL_OVERRIDE; protected: - void timerEvent(QTimerEvent *); - bool eventFilter(QObject *o, QEvent *e); + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; void startProgressAnimation(QObject *o, QProgressBar *bar); void stopProgressAnimation(QObject *o, QProgressBar *bar); diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/gtk2.json qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/gtk2.json --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/gtk2.json 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/gtk2.json 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,3 @@ +{ + "Keys": [ "gtk2" ] +} diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/gtk2.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/gtk2.pro --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/gtk2.pro 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/gtk2.pro 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,17 @@ +TARGET = qgtk2style +PLUGIN_TYPE = styles +PLUGIN_CLASS_NAME = QGtk2StylePlugin +load(qt_plugin) + +QT = core-private gui-private widgets-private + +CONFIG += link_pkgconfig +PKGCONFIG += gtk+-2.0 x11 + +HEADERS += qgtk2painter_p.h qgtkglobal_p.h qgtkpainter_p.h qgtkstyle_p.h qgtkstyle_p_p.h +SOURCES += qgtk2painter.cpp qgtkpainter.cpp qgtkstyle.cpp qgtkstyle_p.cpp plugin.cpp +DEFINES += QT_NO_ANIMATION + +include(../shared/shared.pri) + +OTHER_FILES += gtk2.json diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/plugin.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/plugin.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/plugin.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/plugin.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgtkstyle_p.h" + +QT_BEGIN_NAMESPACE + +class QGtk2StylePlugin : public QStylePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "gtk2.json") + +public: + QStyle *create(const QString &key); +}; + +QStyle *QGtk2StylePlugin::create(const QString &key) +{ + if (key == "gtk2") + return new QGtkStyle; + return 0; +} + +QT_END_NAMESPACE + +#include "plugin.moc" diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtk2painter.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtk2painter.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtk2painter.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtk2painter.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,614 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgtk2painter_p.h" + +#include + +// This class is primarily a wrapper around the gtk painter functions +// and takes care of converting all such calls into cached Qt pixmaps. + +#include "qgtkstyle_p_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// To recover alpha we apply the gtk painting function two times to +// white, and black window backgrounds. This can be used to +// recover the premultiplied alpha channel +QPixmap QGtk2Painter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const +{ + const int bytecount = rect.width() * rect.height() * 4; + for (int index = 0; index < bytecount ; index += 4) { + uchar val = bdata[index + GTK_BLUE]; + if (m_alpha) { + int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE], + bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]); + alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255; + bdata[index + QT_ALPHA] = alphaval; + } + bdata[index + QT_RED] = bdata[index + GTK_RED]; + bdata[index + QT_GREEN] = bdata[index + GTK_GREEN]; + bdata[index + QT_BLUE] = val; + } + QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ? + QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); + + if (m_hflipped || m_vflipped) { + return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped)); + } else { + // on raster graphicssystem we need to do a copy here, because + // we intend to deallocate the qimage bits shortly after... + return QPixmap::fromImage(converted.copy()); + } +} + +// This macro is responsible for painting any GtkStyle painting function onto a QPixmap +#define DRAW_TO_CACHE(draw_func) \ + if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \ + return; \ + QRect pixmapRect(0, 0, rect.width(), rect.height()); \ + { \ + GdkPixmap *pixmap = gdk_pixmap_new((GdkDrawable*)(m_window->window), \ + rect.width(), rect.height(), -1); \ + if (!pixmap) \ + return; \ + style = gtk_style_attach (style, m_window->window); \ + gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, \ + true, 0, 0, rect.width(), rect.height()); \ + draw_func; \ + GdkPixbuf *imgb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \ + rect.width(), rect.height()); \ + if (!imgb) \ + return; \ + imgb = gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \ + rect.width(), rect.height()); \ + uchar* bdata = (uchar*)gdk_pixbuf_get_pixels(imgb); \ + if (m_alpha) { \ + gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, \ + rect.width(), rect.height()); \ + draw_func; \ + GdkPixbuf *imgw = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \ + rect.width(), rect.height()); \ + if (!imgw) \ + return; \ + imgw = gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0,\ + rect.width(), rect.height()); \ + uchar* wdata = (uchar*)gdk_pixbuf_get_pixels(imgw); \ + cache = renderTheme(bdata, wdata, rect); \ + g_object_unref(imgw); \ + } else { \ + cache = renderTheme(bdata, 0, rect); \ + } \ + gdk_drawable_unref(pixmap); \ + g_object_unref(imgb); \ + } + +QGtk2Painter::QGtk2Painter() : QGtkPainter(), m_window(QGtkStylePrivate::gtkWidget("GtkWindow")) +{ +} + +// Note currently painted without alpha for performance reasons +void QGtk2Painter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part, + const QRect &paintRect, GtkStateType state, + GtkShadowType shadow, GtkPositionType gap_side, + gint x, gint width, + GtkStyle *style) +{ + if (!paintRect.isValid()) + return; + + QPixmap cache; + QRect rect = paintRect; + + // To avoid exhausting cache on large tabframes we cheat a bit by + // tiling the center part. + + const int maxHeight = 256; + const int border = 16; + if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM)) + rect.setHeight(2 * border + 1); + + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + % HexString(gap_side) + % HexString(width) + % HexString(x); + + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_box_gap (style, + pixmap, + state, + shadow, + NULL, + gtkWidget, + (const gchar*)part, + 0, 0, + rect.width(), + rect.height(), + gap_side, + x, + width)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + if (rect.size() != paintRect.size()) { + // We assume we can stretch the middle tab part + // Note: the side effect of this is that pinstripe patterns will get fuzzy + const QSize size = cache.size(); + // top part + m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(), + paintRect.width(), border), cache, + QRect(0, 0, size.width(), border)); + + // tiled center part + QPixmap tilePart(cache.width(), 1); + QPainter scanLinePainter(&tilePart); + scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1)); + scanLinePainter.end(); + m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border, + paintRect.width(), paintRect.height() - 2*border), tilePart); + + // bottom part + m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border, + paintRect.width(), border), cache, + QRect(0, size.height() - border, size.width(), border)); + } else + m_painter->drawPixmap(paintRect.topLeft(), cache); +} + +void QGtk2Painter::paintBox(GtkWidget *gtkWidget, const gchar* part, + const QRect &paintRect, GtkStateType state, + GtkShadowType shadow, GtkStyle *style, + const QString &pmKey) +{ + if (!paintRect.isValid()) + return; + + QPixmap cache; + QRect rect = paintRect; + + // To avoid exhausting cache on large tabframes we cheat a bit by + // tiling the center part. + + const int maxHeight = 256; + const int maxArea = 256*512; + const int border = 32; + if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea)) + rect.setHeight(2 * border + 1); + + QString pixmapName = uniqueName(QLS(part), state, shadow, + rect.size(), gtkWidget) % pmKey; + + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_box (style, + pixmap, + state, + shadow, + NULL, + gtkWidget, + part, + 0, 0, + rect.width(), + rect.height())); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + if (rect.size() != paintRect.size()) { + // We assume we can stretch the middle tab part + // Note: the side effect of this is that pinstripe patterns will get fuzzy + const QSize size = cache.size(); + // top part + m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(), + paintRect.width(), border), cache, + QRect(0, 0, size.width(), border)); + + // tiled center part + QPixmap tilePart(cache.width(), 1); + QPainter scanLinePainter(&tilePart); + scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1)); + scanLinePainter.end(); + m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border, + paintRect.width(), paintRect.height() - 2*border), tilePart); + + // bottom part + m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border, + paintRect.width(), border), cache, + QRect(0, size.height() - border, size.width(), border)); + } else + m_painter->drawPixmap(paintRect.topLeft(), cache); +} + +void QGtk2Painter::paintHline(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, + GtkStyle *style, int x1, int x2, int y, + const QString &pmKey) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) + % HexString(x1) + % HexString(x2) + % HexString(y) + % pmKey; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_hline (style, + pixmap, + state, + NULL, + gtkWidget, + part, + x1, x2, y)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + +void QGtk2Painter::paintVline(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, + GtkStyle *style, int y1, int y2, int x, + const QString &pmKey) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) + % HexString(y1) + % HexString(y2) + % HexString(x) + % pmKey; + + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_vline (style, + pixmap, + state, + NULL, + gtkWidget, + part, + y1, y2, + x)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + m_painter->drawPixmap(rect.topLeft(), cache); +} + + +void QGtk2Painter::paintExpander(GtkWidget *gtkWidget, + const gchar* part, const QRect &rect, + GtkStateType state, GtkExpanderStyle expander_state, + GtkStyle *style, const QString &pmKey) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) + % HexString(expander_state) + % pmKey; + + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_expander (style, pixmap, + state, NULL, + gtkWidget, part, + rect.width()/2, + rect.height()/2, + expander_state)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + +void QGtk2Painter::paintFocus(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, + GtkStyle *style, const QString &pmKey) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_focus (style, pixmap, state, NULL, + gtkWidget, + part, + 0, 0, + rect.width(), + rect.height())); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + + +void QGtk2Painter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, + GtkShadowType shadow, GdkWindowEdge edge, + GtkStyle *style, const QString &pmKey) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_resize_grip (style, pixmap, state, + NULL, gtkWidget, + part, edge, 0, 0, + rect.width(), + rect.height())); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + + +void QGtk2Painter::paintArrow(GtkWidget *gtkWidget, const gchar* part, + const QRect &arrowrect, GtkArrowType arrow_type, + GtkStateType state, GtkShadowType shadow, + gboolean fill, GtkStyle *style, const QString &pmKey) +{ + QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect; + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) + % HexString(arrow_type) + % pmKey; + + GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()}; + int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0; + int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_arrow (style, pixmap, state, shadow, + >kCliprect, + gtkWidget, + part, + arrow_type, fill, + xOffset, yOffset, + arrowrect.width(), + arrowrect.height())) + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + + +void QGtk2Painter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, + GtkOrientation orientation, GtkStyle *style) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) + % HexString(orientation); + + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_handle (style, + pixmap, + state, + shadow, + NULL, + gtkWidget, + part, 0, 0, + rect.width(), + rect.height(), + orientation)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + m_painter->drawPixmap(rect.topLeft(), cache); +} + + +void QGtk2Painter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, + GtkStyle *style, GtkOrientation orientation, + const QString &pmKey) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_slider (style, + pixmap, + state, + shadow, + NULL, + gtkWidget, + part, + 0, 0, + rect.width(), + rect.height(), + orientation)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + m_painter->drawPixmap(rect.topLeft(), cache); +} + + +void QGtk2Painter::paintShadow(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, + GtkShadowType shadow, GtkStyle *style, + const QString &pmKey) + +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_shadow(style, pixmap, state, shadow, NULL, + gtkWidget, part, 0, 0, rect.width(), rect.height())); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + m_painter->drawPixmap(rect.topLeft(), cache); +} + +void QGtk2Painter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, + GtkShadowType shadow, GtkStyle *style, + const QString &pmKey) +{ + if (!rect.isValid()) + return; + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_flat_box (style, + pixmap, + state, + shadow, + NULL, + gtkWidget, + part, 0, 0, + rect.width(), + rect.height())); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + m_painter->drawPixmap(rect.topLeft(), cache); +} + +void QGtk2Painter::paintExtention(GtkWidget *gtkWidget, + const gchar *part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, + GtkPositionType gap_pos, GtkStyle *style) +{ + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + % HexString(gap_pos); + + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_extension (style, pixmap, state, shadow, + NULL, gtkWidget, + (const gchar*)part, 0, 0, + rect.width(), + rect.height(), + gap_pos)); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + +void QGtk2Painter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect, + GtkStateType state, GtkShadowType shadow, + GtkStyle *style, const QString &detail) + +{ + QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect; + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(detail, state, shadow, rect.size()); + GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()}; + int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0; + int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_option(style, pixmap, + state, shadow, + >kCliprect, + gtkWidget, + detail.toLatin1(), + xOffset, yOffset, + radiorect.width(), + radiorect.height())); + + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + +void QGtk2Painter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect, + GtkStateType state, GtkShadowType shadow, + GtkStyle *style, const QString &detail) + +{ + QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect; + if (!rect.isValid()) + return; + + QPixmap cache; + QString pixmapName = uniqueName(detail, state, shadow, rect.size()); + GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()}; + int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0; + int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0; + if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + DRAW_TO_CACHE(gtk_paint_check (style, + pixmap, + state, + shadow, + >kCliprect, + gtkWidget, + detail.toLatin1(), + xOffset, yOffset, + checkrect.width(), + checkrect.height())); + if (m_usePixmapCache) + QPixmapCache::insert(pixmapName, cache); + } + + m_painter->drawPixmap(rect.topLeft(), cache); +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtk2painter_p.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtk2painter_p.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtk2painter_p.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtk2painter_p.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTK2PAINTER_P_H +#define QGTK2PAINTER_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 + +#include "qgtkpainter_p.h" + +QT_BEGIN_NAMESPACE + +class QGtk2Painter : public QGtkPainter +{ +public: + QGtk2Painter(); + + void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x, + gint width, GtkStyle *style) Q_DECL_OVERRIDE; + void paintBox(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, + const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style, + int x1, int x2, int y, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style, + int y1, int y2, int x, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, + GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style, + const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow, + gboolean fill, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) Q_DECL_OVERRIDE; + void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE; + void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) Q_DECL_OVERRIDE; + void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GtkPositionType gap_pos, GtkStyle *style) Q_DECL_OVERRIDE; + void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) Q_DECL_OVERRIDE; + void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) Q_DECL_OVERRIDE; + +private: + QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const; + + GtkWidget *m_window; +}; + +QT_END_NAMESPACE + +#endif // QGTK2PAINTER_P_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkglobal_p.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkglobal_p.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkglobal_p.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkglobal_p.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTKGLOBAL_P_H +#define QGTKGLOBAL_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 + +#undef signals // Collides with GTK symbols +#include + +typedef unsigned long XID; + +#undef GTK_OBJECT_FLAGS +#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags) + +#define QLS(x) QLatin1String(x) + +QT_BEGIN_NAMESPACE + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +# define QT_RED 3 +# define QT_GREEN 2 +# define QT_BLUE 1 +# define QT_ALPHA 0 +#else +# define QT_RED 0 +# define QT_GREEN 1 +# define QT_BLUE 2 +# define QT_ALPHA 3 +#endif +# define GTK_RED 2 +# define GTK_GREEN 1 +# define GTK_BLUE 0 +# define GTK_ALPHA 3 + +QT_END_NAMESPACE + +#endif // QGTKGLOBAL_P_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkpainter.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkpainter.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkpainter.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkpainter.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgtkpainter_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QGtkPainter::QGtkPainter() +{ + reset(0); +} + +QGtkPainter::~QGtkPainter() +{ +} + +void QGtkPainter::reset(QPainter *painter) +{ + m_painter = painter; + m_alpha = true; + m_hflipped = false; + m_vflipped = false; + m_usePixmapCache = true; + m_cliprect = QRect(); +} + +QString QGtkPainter::uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, + const QSize &size, GtkWidget *widget) +{ + // Note the widget arg should ideally use the widget path, though would compromise performance + QString tmp = key + % HexString(state) + % HexString(shadow) + % HexString(size.width()) + % HexString(size.height()) + % HexString(quint64(widget)); + return tmp; +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkpainter_p.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkpainter_p.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkpainter_p.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkpainter_p.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTKPAINTER_H +#define QGTKPAINTER_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 + +#include "qgtkglobal_p.h" +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QGtkPainter +{ +public: + QGtkPainter(); + virtual ~QGtkPainter(); + + void reset(QPainter *painter = 0); + + void setAlphaSupport(bool value) { m_alpha = value; } + void setClipRect(const QRect &rect) { m_cliprect = rect; } + void setFlipHorizontal(bool value) { m_hflipped = value; } + void setFlipVertical(bool value) { m_vflipped = value; } + void setUsePixmapCache(bool value) { m_usePixmapCache = value; } + + virtual void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x, + gint width, GtkStyle *style) = 0; + virtual void paintBox(GtkWidget *gtkWidget, const gchar* part, + const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, + const QString &pmKey = QString()) = 0; + virtual void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style, + int x1, int x2, int y, const QString &pmKey = QString()) = 0; + virtual void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style, + int y1, int y2, int x, const QString &pmKey = QString()) = 0; + virtual void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, + GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) = 0; + virtual void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style, + const QString &pmKey = QString()) = 0; + virtual void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) = 0; + virtual void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow, + gboolean fill, GtkStyle *style, const QString &pmKey = QString()) = 0; + virtual void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, + GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) = 0; + virtual void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) = 0; + virtual void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GtkStyle *style, const QString &pmKey = QString()) = 0; + virtual void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) = 0; + virtual void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, + GtkPositionType gap_pos, GtkStyle *style) = 0; + virtual void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0; + virtual void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0; + +protected: + static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0); + + QPainter *m_painter; + bool m_alpha; + bool m_hflipped; + bool m_vflipped; + bool m_usePixmapCache; + QRect m_cliprect; +}; + +QT_END_NAMESPACE + +#endif // QGTKPAINTER_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,4217 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qgtkstyle_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#undef signals // Collides with GTK stymbols +#include "qgtkpainter_p.h" +#include +#include "qgtkstyle_p_p.h" + +QT_BEGIN_NAMESPACE + +static GtkStateType qt_gtk_state(const QStyleOption *option) +{ + GtkStateType state = GTK_STATE_NORMAL; + if (!(option->state & QStyle::State_Enabled)) + state = GTK_STATE_INSENSITIVE; + else if (option->state & QStyle::State_MouseOver) + state = GTK_STATE_PRELIGHT; + + return state; +} + +static QPixmap qt_gtk_get_icon(const char* iconName, GtkIconSize size = GTK_ICON_SIZE_BUTTON) +{ + GtkStyle *style = QGtkStylePrivate::gtkStyle(); + GtkIconSet* iconSet = gtk_icon_factory_lookup_default (iconName); + GdkPixbuf* icon = gtk_icon_set_render_icon(iconSet, + style, + GTK_TEXT_DIR_LTR, + GTK_STATE_NORMAL, + size, + NULL, + "button"); + uchar* data = (uchar*)gdk_pixbuf_get_pixels(icon); + int width = gdk_pixbuf_get_width(icon); + int height = gdk_pixbuf_get_height(icon); + QImage converted(width, height, QImage::Format_ARGB32); + uchar* tdata = (uchar*)converted.bits(); + + for ( int index = 0 ; index < height * width*4 ; index +=4 ) { + //int index = y * rowstride + x; + tdata[index + QT_RED] = data[index + GTK_RED]; + tdata[index + QT_GREEN] = data[index + GTK_GREEN]; + tdata[index + QT_BLUE] = data[index + GTK_BLUE]; + tdata[index + QT_ALPHA] = data[index + GTK_ALPHA]; + } + + g_object_unref(icon); + + // should we free iconset? + return QPixmap::fromImage(converted); +} + +static void qt_gtk_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken) +{ + QColor dark; + dark.setHsv(option->palette.button().color().hue(), + qMin(255, (int)(option->palette.button().color().saturation()*1.9)), + qMin(255, (int)(option->palette.button().color().value()*0.7))); + + QColor highlight = option->palette.highlight().color(); + + bool active = (option->titleBarState & QStyle::State_Active); + QColor titleBarHighlight(255, 255, 255, 60); + + if (sunken) + painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().darker(120)); + else if (hover) + painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20)); + + QColor mdiButtonGradientStartColor; + QColor mdiButtonGradientStopColor; + + mdiButtonGradientStartColor = QColor(0, 0, 0, 40); + mdiButtonGradientStopColor = QColor(255, 255, 255, 60); + + if (sunken) + titleBarHighlight = highlight.darker(130); + + QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom()); + gradient.setColorAt(0, mdiButtonGradientStartColor); + gradient.setColorAt(1, mdiButtonGradientStopColor); + QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110)); + + painter->setPen(QPen(mdiButtonBorderColor, 1)); + const QLine lines[4] = { + QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), + QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), + QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), + QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(tmp.left() + 1, tmp.top() + 1), + QPoint(tmp.right() - 1, tmp.top() + 1), + QPoint(tmp.left() + 1, tmp.bottom() - 1), + QPoint(tmp.right() - 1, tmp.bottom() - 1) + }; + painter->drawPoints(points, 4); + + painter->setPen(titleBarHighlight); + painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1); + painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2); + + painter->setPen(QPen(gradient, 1)); + painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2); + painter->drawPoint(tmp.right() , tmp.top() + 1); + + painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1); + painter->drawPoint(tmp.left() + 1, tmp.bottom()); + painter->drawPoint(tmp.right() - 1, tmp.bottom()); + painter->drawPoint(tmp.right() , tmp.bottom() - 1); +} + +static const char * const dock_widget_close_xpm[] = + { + "11 13 5 1", + " c None", + ". c #D5CFCB", + "+ c #6C6A67", + "@ c #6C6A67", + "$ c #B5B0AC", + " ", + " @@@@@@@@@ ", + "@+ +@", + "@ +@ @+ @", + "@ @@@ @@@ @", + "@ @@@@@ @", + "@ @@@ @", + "@ @@@@@ @", + "@ @@@ @@@ @", + "@ +@ @+ @", + "@+ +@", + " @@@@@@@@@ ", + " " + }; + +static const char * const dock_widget_restore_xpm[] = + { + "11 13 5 1", + " c None", + ". c #D5CFCB", + "+ c #6C6A67", + "@ c #6C6A67", + "# c #6C6A67", + " ", + " @@@@@@@@@ ", + "@+ +@", + "@ #@@@# @", + "@ @ @ @", + "@ #@@@# @ @", + "@ @ @ @ @", + "@ @ @@@ @", + "@ @ @ @", + "@ #@@@@ @", + "@+ +@", + " @@@@@@@@@ ", + " " + }; + +static const char * const qt_titlebar_context_help[] = { + "10 10 3 1", + " c None", + "# c #000000", + "+ c #444444", + " +####+ ", + " ### ### ", + " ## ## ", + " +##+ ", + " +## ", + " ## ", + " ## ", + " ", + " ## ", + " ## "}; + +static const char * const qt_scrollbar_button_arrow_up[] = { + "7 4 2 1", + " c None", + "* c #BFBFBF", + " * ", + " *** ", + " ***** ", + "*******"}; + +static const char * const qt_scrollbar_button_arrow_down[] = { + "7 4 2 1", + " c None", + "* c #BFBFBF", + "*******", + " ***** ", + " *** ", + " * "}; + +static const int groupBoxBottomMargin = 2; // space below the groupbox +static const int groupBoxTitleMargin = 6; // space between contents and title +static const int groupBoxTopMargin = 2; + +static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50) +{ + const int maxFactor = 100; + QColor tmp = colorA; + tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor); + tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor); + tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor); + return tmp; +} + +static GdkColor fromQColor(const QColor &color) +{ + GdkColor retval; + retval.pixel = 0; + retval.red = color.red() * 255; + retval.green = color.green() * 255; + retval.blue = color.blue() * 255; + return retval; +} + +/*! + \class QGtkStyle + \brief The QGtkStyle class provides a widget style rendered by GTK+ + \since 4.5 + + \internal + \inmodule QtWidgets + + The QGtkStyle style provides a look and feel that integrates well + into GTK-based desktop environments such as the XFCe and GNOME. + + It does this by making use of the GTK+ theme engine, ensuring + that Qt applications look and feel native on these platforms. + + Note: The style requires GTK+ version 2.18 or later. + The Qt3-based "Qt" GTK+ theme engine will not work with QGtkStyle. + + \sa QWindowsXPStyle, QMacStyle, QWindowsStyle, QFusionStyle +*/ + +/*! + Constructs a QGtkStyle object. +*/ +QGtkStyle::QGtkStyle() + : QCommonStyle(*new QGtkStylePrivate) +{ + Q_D(QGtkStyle); + d->init(); +} + +/*! + \internal + + Constructs a QGtkStyle object. +*/ +QGtkStyle::QGtkStyle(QGtkStylePrivate &dd) + : QCommonStyle(dd) +{ + Q_D(QGtkStyle); + d->init(); +} + + +/*! + Destroys the QGtkStyle object. +*/ +QGtkStyle::~QGtkStyle() +{ +} + +/*! + \reimp +*/ +QPalette QGtkStyle::standardPalette() const +{ + Q_D(const QGtkStyle); + + QPalette palette = QCommonStyle::standardPalette(); + if (d->isThemeAvailable()) { + GtkStyle *style = d->gtkStyle(); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + GtkWidget *gtkEntry = d->getTextColorWidget(); + GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg, gdkaSbg, gdkaSfg; + QColor bg, base, text, fg, highlight, highlightText, inactiveHighlight, inactiveHighlightedTExt; + gdkBg = style->bg[GTK_STATE_NORMAL]; + gdkForeground = gtk_widget_get_style(gtkButton)->fg[GTK_STATE_NORMAL]; + + // Our base and selected color is primarily used for text + // so we assume a gtkEntry will have the most correct value + GtkStyle *gtkEntryStyle = gtk_widget_get_style(gtkEntry); + gdkBase = gtkEntryStyle->base[GTK_STATE_NORMAL]; + gdkText = gtkEntryStyle->text[GTK_STATE_NORMAL]; + gdkSbg = gtkEntryStyle->base[GTK_STATE_SELECTED]; + gdkSfg = gtkEntryStyle->text[GTK_STATE_SELECTED]; + + // The ACTIVE base color is really used for inactive windows + gdkaSbg = gtkEntryStyle->base[GTK_STATE_ACTIVE]; + gdkaSfg = gtkEntryStyle->text[GTK_STATE_ACTIVE]; + + bg = QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); + text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + fg = QColor(gdkForeground.red>>8, gdkForeground.green>>8, gdkForeground.blue>>8); + base = QColor(gdkBase.red>>8, gdkBase.green>>8, gdkBase.blue>>8); + highlight = QColor(gdkSbg.red>>8, gdkSbg.green>>8, gdkSbg.blue>>8); + highlightText = QColor(gdkSfg.red>>8, gdkSfg.green>>8, gdkSfg.blue>>8); + inactiveHighlight = QColor(gdkaSbg.red>>8, gdkaSbg.green>>8, gdkaSbg.blue>>8); + inactiveHighlightedTExt = QColor(gdkaSfg.red>>8, gdkaSfg.green>>8, gdkaSfg.blue>>8); + + palette.setColor(QPalette::HighlightedText, highlightText); + + + palette.setColor(QPalette::Light, bg.lighter(125)); + palette.setColor(QPalette::Shadow, bg.darker(130)); + palette.setColor(QPalette::Dark, bg.darker(120)); + palette.setColor(QPalette::Text, text); + palette.setColor(QPalette::WindowText, fg); + palette.setColor(QPalette::ButtonText, fg); + palette.setColor(QPalette::Base, base); + + QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); + GdkColor *gtkAltBase = NULL; + gtk_widget_style_get(gtkTreeView, "odd-row-color", >kAltBase, NULL); + if (gtkAltBase) { + alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8); + gdk_color_free(gtkAltBase); + } + palette.setColor(QPalette::AlternateBase, alternateRowColor); + + palette.setColor(QPalette::Window, bg); + palette.setColor(QPalette::Button, bg); + palette.setColor(QPalette::Background, bg); + QColor disabled((fg.red() + bg.red()) / 2, + (fg.green() + bg.green())/ 2, + (fg.blue() + bg.blue()) / 2); + palette.setColor(QPalette::Disabled, QPalette::Text, disabled); + palette.setColor(QPalette::Disabled, QPalette::WindowText, disabled); + palette.setColor(QPalette::Disabled, QPalette::Foreground, disabled); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabled); + palette.setColor(QPalette::Highlight, highlight); + // calculate disabled colors by removing saturation + highlight.setHsv(highlight.hue(), 0, highlight.value(), highlight.alpha()); + highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha()); + palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText); + + palette.setColor(QPalette::Inactive, QPalette::HighlightedText, inactiveHighlightedTExt); + palette.setColor(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); + + style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", + gtk_window_get_type()); + if (style) { + gdkText = style->fg[GTK_STATE_NORMAL]; + text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + palette.setColor(QPalette::ToolTipText, text); + } + } + return palette; +} + +/*! + \reimp +*/ +void QGtkStyle::polish(QPalette &palette) +{ + Q_D(QGtkStyle); + + if (!d->isThemeAvailable()) + QCommonStyle::polish(palette); + else + palette = palette.resolve(standardPalette()); +} + +/*! + \reimp +*/ +void QGtkStyle::polish(QApplication *app) +{ + Q_D(QGtkStyle); + + QCommonStyle::polish(app); + // Custom fonts and palettes with QtConfig are intentionally + // not supported as these should be entirely determined by + // current Gtk settings + if (app->desktopSettingsAware() && d->isThemeAvailable()) { + QApplicationPrivate::setSystemPalette(standardPalette()); + QApplicationPrivate::setSystemFont(d->getThemeFont()); + d->applyCustomPaletteHash(); + if (!d->isKDE4Session()) + qApp->installEventFilter(&d->filter); + } +} + +/*! + \reimp +*/ +void QGtkStyle::unpolish(QApplication *app) +{ + Q_D(QGtkStyle); + + QCommonStyle::unpolish(app); + QPixmapCache::clear(); + + if (app->desktopSettingsAware() && d->isThemeAvailable() && !d->isKDE4Session()) + qApp->removeEventFilter(&d->filter); +} + +/*! + \reimp +*/ + +void QGtkStyle::polish(QWidget *widget) +{ + Q_D(QGtkStyle); + + QCommonStyle::polish(widget); + if (!d->isThemeAvailable()) + return; + if (qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget)) + widget->setAttribute(Qt::WA_Hover); +#ifndef QT_NO_TREEVIEW + else if (QTreeView *tree = qobject_cast (widget)) + tree->viewport()->setAttribute(Qt::WA_Hover); +#endif +} + +/*! + \reimp +*/ +void QGtkStyle::unpolish(QWidget *widget) +{ + QCommonStyle::unpolish(widget); +} + +/*! + \reimp +*/ +int QGtkStyle::pixelMetric(PixelMetric metric, + const QStyleOption *option, + const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) + return QCommonStyle::pixelMetric(metric, option, widget); + + switch (metric) { + case PM_DefaultFrameWidth: + if (qobject_cast(widget)) { + if (GtkStyle *style = + gtk_rc_get_style_by_paths(gtk_settings_get_default(), + "*.GtkScrolledWindow", + "*.GtkScrolledWindow", + gtk_window_get_type())) + return qMax(style->xthickness, style->ythickness); + } + return 2; + + case PM_MenuButtonIndicator: + return 20; + + case PM_TabBarBaseOverlap: + return 1; + + case PM_ToolBarSeparatorExtent: + return 11; + + case PM_ToolBarFrameWidth: + return 1; + + case PM_ToolBarItemSpacing: + return 0; + + case PM_ButtonShiftHorizontal: { + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + guint horizontal_shift; + gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL); + return horizontal_shift; + } + + case PM_ButtonShiftVertical: { + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + guint vertical_shift; + gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL); + return vertical_shift; + } + + case PM_MenuBarPanelWidth: + return 0; + + case PM_MenuPanelWidth: { + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); + guint horizontal_padding = 0; + // horizontal-padding is used by Maemo to get thicker borders + if (!gtk_check_version(2, 10, 0)) + gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL); + int padding = qMax(gtk_widget_get_style(gtkMenu)->xthickness, horizontal_padding); + return padding; + } + + case PM_ButtonIconSize: { + int retVal = 24; + GtkSettings *settings = gtk_settings_get_default(); + gchararray icon_sizes; + g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL); + QStringList values = QString(QLS(icon_sizes)).split(QLatin1Char(':')); + g_free(icon_sizes); + QChar splitChar(QLatin1Char(',')); + foreach (const QString &value, values) { + if (value.startsWith(QLS("gtk-button="))) { + QString iconSize = value.right(value.size() - 11); + + if (iconSize.contains(splitChar)) + retVal = iconSize.split(splitChar)[0].toInt(); + break; + } + } + return retVal; + } + + case PM_MenuVMargin: + + case PM_MenuHMargin: + return 0; + + case PM_DockWidgetTitleMargin: + return 0; + + case PM_DockWidgetTitleBarButtonMargin: + return 5; + + case PM_TabBarTabVSpace: + return 12; + + case PM_TabBarTabHSpace: + return 14; + + case PM_TabBarTabShiftVertical: + return 2; + + case PM_ToolBarHandleExtent: + return 9; + + case PM_SplitterWidth: + return 6; + + case PM_SliderThickness: + case PM_SliderControlThickness: { + GtkWidget *gtkScale = d->gtkWidget("GtkHScale"); + gint val; + gtk_widget_style_get(gtkScale, "slider-width", &val, NULL); + if (metric == PM_SliderControlThickness) + return val + 2*gtk_widget_get_style(gtkScale)->ythickness; + return val; + } + + case PM_ScrollBarExtent: { + gint sliderLength; + gint trough_border; + GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar"); + gtk_widget_style_get(hScrollbar, + "trough-border", &trough_border, + "slider-width", &sliderLength, + NULL); + return sliderLength + trough_border*2; + } + + case PM_ScrollBarSliderMin: + return 34; + + case PM_SliderLength: + gint val; + gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL); + return val; + + case PM_ExclusiveIndicatorWidth: + case PM_ExclusiveIndicatorHeight: + case PM_IndicatorWidth: + case PM_IndicatorHeight: { + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); + gint size, spacing; + gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL); + return size + 2 * spacing; + } + + case PM_MenuBarVMargin: { + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); + return qMax(0, gtk_widget_get_style(gtkMenubar)->ythickness); + } + case PM_ScrollView_ScrollBarSpacing: + { + gint spacing = 3; + GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow"); + Q_ASSERT(gtkScrollWindow); + gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL); + return spacing; + } + case PM_SubMenuOverlap: { + gint offset = 0; + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); + gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL); + return offset; + } + case PM_ToolTipLabelFrameWidth: + return 2; + case PM_ButtonDefaultIndicator: + return 0; + case PM_ListViewIconSize: + return 24; + case PM_DialogButtonsSeparator: + return 6; + case PM_TitleBarHeight: + return 24; + case PM_SpinBoxFrameWidth: + return 3; + case PM_MenuBarItemSpacing: + return 6; + case PM_MenuBarHMargin: + return 0; + case PM_ToolBarItemMargin: + return 1; + case PM_SmallIconSize: + return 16; + case PM_MaximumDragDistance: + return -1; + case PM_TabCloseIndicatorWidth: + case PM_TabCloseIndicatorHeight: + return 20; + default: + return QCommonStyle::pixelMetric(metric, option, widget); + } +} + +/*! + \reimp +*/ +int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, + + QStyleHintReturn *returnData = 0) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) + return QCommonStyle::styleHint(hint, option, widget, returnData); + + switch (hint) { + case SH_ItemView_ChangeHighlightOnFocus: + return true; + case SH_ScrollBar_MiddleClickAbsolutePosition: + return true; + case SH_Menu_AllowActiveAndDisabled: + return false; + case SH_MainWindow_SpaceBelowMenuBar: + return false; + case SH_MenuBar_MouseTracking: + return true; + case SH_Menu_MouseTracking: + return true; + case SH_TitleBar_AutoRaise: + return true; + case SH_TitleBar_NoBorder: + return true; + case SH_ItemView_ShowDecorationSelected: + return true; + case SH_Table_GridLineColor: + if (option) + return option->palette.background().color().darker(120).rgb(); + break; + case SH_WindowFrame_Mask: + if (QStyleHintReturnMask *mask = qstyleoption_cast(returnData)) { + //left rounded corner + mask->region = option->rect; + mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1); + mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1); + mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1); + mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2); + + //right rounded corner + mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1); + mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1); + mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1); + mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2); + } + return QCommonStyle::styleHint(hint, option, widget, returnData); + case SH_MessageBox_TextInteractionFlags: + return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; + case SH_MessageBox_CenterButtons: + return false; +#ifndef QT_NO_WIZARD + case SH_WizardStyle: + return QWizard::ClassicStyle; +#endif + case SH_ItemView_ArrowKeysNavigateIntoChildren: + return false; + case SH_DialogButtonLayout: { + int ret = QDialogButtonBox::GnomeLayout; + gboolean alternateOrder = 0; + GtkSettings *settings = gtk_settings_get_default(); + g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL); + + if (alternateOrder) + ret = QDialogButtonBox::WinLayout; + + return ret; + } + break; + + case SH_ToolButtonStyle: + { + if (d->isKDE4Session()) + return QCommonStyle::styleHint(hint, option, widget, returnData); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); + GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; + g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL); + switch (toolbar_style) { + case GTK_TOOLBAR_TEXT: + return Qt::ToolButtonTextOnly; + case GTK_TOOLBAR_BOTH: + return Qt::ToolButtonTextUnderIcon; + case GTK_TOOLBAR_BOTH_HORIZ: + return Qt::ToolButtonTextBesideIcon; + case GTK_TOOLBAR_ICONS: + default: + return Qt::ToolButtonIconOnly; + } + } + break; + case SH_SpinControls_DisableOnBounds: + return int(true); + + case SH_DitherDisabledText: + return int(false); + + case SH_ComboBox_Popup: { + GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox"); + gboolean appears_as_list; + gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL); + return appears_as_list ? 0 : 1; + } + + case SH_MenuBar_AltKeyNavigation: + return int(false); + + case SH_EtchDisabledText: + return int(false); + + case SH_Menu_SubMenuPopupDelay: { + gint delay = 225; + GtkSettings *settings = gtk_settings_get_default(); + g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL); + return delay; + } + + case SH_ScrollView_FrameOnlyAroundContents: { + gboolean scrollbars_within_bevel = false; + if (widget && widget->isWindow()) + scrollbars_within_bevel = true; + else if (!gtk_check_version(2, 12, 0)) { + GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow"); + gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL); + } + return !scrollbars_within_bevel; + } + + case SH_DialogButtonBox_ButtonsHaveIcons: { + gboolean buttonsHaveIcons = true; + GtkSettings *settings = gtk_settings_get_default(); + g_object_get(settings, "gtk-button-images", &buttonsHaveIcons, NULL); + return buttonsHaveIcons; + } + + case SH_UnderlineShortcut: { + gboolean underlineShortcut = true; + if (!gtk_check_version(2, 12, 0)) { + GtkSettings *settings = gtk_settings_get_default(); + g_object_get(settings, "gtk-enable-mnemonics", &underlineShortcut, NULL); + } + return underlineShortcut; + } + + default: + break; + } + return QCommonStyle::styleHint(hint, option, widget, returnData); +} + +/*! + \reimp +*/ +void QGtkStyle::drawPrimitive(PrimitiveElement element, + const QStyleOption *option, + QPainter *painter, + const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) { + QCommonStyle::drawPrimitive(element, option, painter, widget); + return; + } + + GtkStyle* style = d->gtkStyle(); + QGtkPainter* gtkPainter = d->gtkPainter(painter); + + switch (element) { + case PE_Frame: { + if (widget && widget->inherits("QComboBoxPrivateContainer")){ + QStyleOption copy = *option; + copy.state |= State_Raised; + proxy()->drawPrimitive(PE_PanelMenu, ©, painter, widget); + break; + } + // Drawing the entire itemview frame is very expensive, especially on the native X11 engine + // Instead we cheat a bit and draw a border image without the center part, hence only scaling + // thin rectangular images + const int pmSize = 64; + const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); + const QString pmKey = QLatin1String("windowframe") % HexString(option->state); + + QPixmap pixmap; + QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize)); + + // Only draw through style once + if (!QPixmapCache::find(pmKey, pixmap)) { + pixmap = QPixmap(pmSize, pmSize); + pixmap.fill(Qt::transparent); + QPainter pmPainter(&pixmap); + gtkPainter->reset(&pmPainter); + gtkPainter->setUsePixmapCache(false); // Don't cache twice + + GtkShadowType shadow_type = GTK_SHADOW_NONE; + if (option->state & State_Sunken) + shadow_type = GTK_SHADOW_IN; + else if (option->state & State_Raised) + shadow_type = GTK_SHADOW_OUT; + + GtkStyle *style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), + "*.GtkScrolledWindow", "*.GtkScrolledWindow", gtk_window_get_type()); + if (style) + gtkPainter->paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect, + option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, + shadow_type, style); + QPixmapCache::insert(pmKey, pixmap); + gtkPainter->reset(painter); + } + + QRect rect = option->rect; + const int rw = rect.width() - border; + const int rh = rect.height() - border; + const int pw = pmRect.width() - border; + const int ph = pmRect.height() - border; + + // Sidelines + painter->drawPixmap(rect.adjusted(border, 0, -border, -rh), pixmap, pmRect.adjusted(border, 0, -border,-ph)); + painter->drawPixmap(rect.adjusted(border, rh, -border, 0), pixmap, pmRect.adjusted(border, ph,-border,0)); + painter->drawPixmap(rect.adjusted(0, border, -rw, -border), pixmap, pmRect.adjusted(0, border, -pw, -border)); + painter->drawPixmap(rect.adjusted(rw, border, 0, -border), pixmap, pmRect.adjusted(pw, border, 0, -border)); + + // Corners + painter->drawPixmap(rect.adjusted(0, 0, -rw, -rh), pixmap, pmRect.adjusted(0, 0, -pw,-ph)); + painter->drawPixmap(rect.adjusted(rw, 0, 0, -rh), pixmap, pmRect.adjusted(pw, 0, 0,-ph)); + painter->drawPixmap(rect.adjusted(0, rh, -rw, 0), pixmap, pmRect.adjusted(0, ph, -pw,0)); + painter->drawPixmap(rect.adjusted(rw, rh, 0, 0), pixmap, pmRect.adjusted(pw, ph, 0,0)); + } + break; + case PE_FrameWindow: + painter->save(); + { + QRect rect= option->rect; + painter->setPen(QPen(option->palette.dark().color().darker(150), 0)); + painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + painter->setPen(QPen(option->palette.light(), 0)); + painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), + QPoint(rect.left() + 1, rect.bottom() - 1)); + painter->setPen(QPen(option->palette.background().color().darker(120), 0)); + painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), + QPoint(rect.right() - 2, rect.bottom() - 1)); + painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), + QPoint(rect.right() - 1, rect.bottom() - 1)); + } + painter->restore(); + break; + + case PE_PanelTipLabel: { + GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed + style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", + gtk_window_get_type()); + gtkPainter->paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style); + } + break; + + case PE_PanelStatusBar: { + if (widget && widget->testAttribute(Qt::WA_SetPalette) && + option->palette.resolve() & (1 << QPalette::Window)) { + // Respect custom palette + painter->fillRect(option->rect, option->palette.window()); + break; + } + GtkShadowType shadow_type; + GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame"); + gtk_widget_style_get(gtk_widget_get_parent(gtkStatusbarFrame), "shadow-type", &shadow_type, NULL); + gtkPainter->paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL, + shadow_type, gtk_widget_get_style(gtkStatusbarFrame)); + } + break; + + case PE_IndicatorHeaderArrow: + if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { + GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton"); + GtkStateType state = qt_gtk_state(option); + style = gtk_widget_get_style(gtkTreeHeader); + GtkArrowType type = GTK_ARROW_UP; + // This sorting indicator inversion is intentional, and follows the GNOME HIG. + // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable + if (header->sortIndicator & QStyleOptionHeader::SortUp) + type = GTK_ARROW_UP; + else if (header->sortIndicator & QStyleOptionHeader::SortDown) + type = GTK_ARROW_DOWN; + + gtkPainter->paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state, + GTK_SHADOW_NONE, false, style); + } + break; + + case PE_FrameDefaultButton: // fall through + case PE_FrameFocusRect: { + QRect frameRect = option->rect.adjusted(1, 1, -2, -2); // ### this mess should move to subcontrolrect + if (qobject_cast(widget)) { + // Don't draw anything + } else if (qobject_cast(widget)) { + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); + style = gtk_widget_get_style(gtkNotebook); + gtkPainter->paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style); + } else { + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); + gtkPainter->paintFocus(gtkRadioButton, "radiobutton", frameRect, GTK_STATE_ACTIVE, style); + } + } + break; + + case PE_IndicatorBranch: + if (option->state & State_Children) { + QRect rect = option->rect; + rect = QRect(0, 0, 12, 12); + rect.moveCenter(option->rect.center()); + rect.translate(2, 0); + GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED; + GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED; + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); + + GtkStateType state = GTK_STATE_NORMAL; + if (!(option->state & State_Enabled)) + state = GTK_STATE_INSENSITIVE; + else if (option->state & State_MouseOver) + state = GTK_STATE_PRELIGHT; + + gtkPainter->paintExpander(gtkTreeView, "treeview", rect, state, + option->state & State_Open ? openState : closedState , gtk_widget_get_style(gtkTreeView)); + } + break; + + case PE_PanelItemViewRow: + // This primitive is only used to draw selection behind selected expander arrows. + // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate + // The reason for this is that a lot of code that relies on custom item delegates will look odd having + // a gradient on the branch but a flat shaded color on the item itself. + QCommonStyle::drawPrimitive(element, option, painter, widget); + if (!(option->state & State_Selected)) { + break; + } else { + if (const QAbstractItemView *view = qobject_cast(widget)) { + if (!qobject_cast(view->itemDelegate())) + break; + } + } // fall through + + case PE_PanelItemViewItem: + if (const QStyleOptionViewItem *vopt = qstyleoption_cast(option)) { + uint resolve_mask = vopt->palette.resolve(); + if (vopt->backgroundBrush.style() != Qt::NoBrush + || (resolve_mask & (1 << QPalette::Base))) + { + QPointF oldBO = painter->brushOrigin(); + painter->setBrushOrigin(vopt->rect.topLeft()); + painter->fillRect(vopt->rect, vopt->backgroundBrush); + painter->setBrushOrigin(oldBO); + if (!(option->state & State_Selected)) + break; + } + if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) { + const char *detail = "cell_even_ruled"; + if (vopt && vopt->features & QStyleOptionViewItem::Alternate) + detail = "cell_odd_ruled"; + bool isActive = option->state & State_Active; + QString key; + if (isActive ) { + // Required for active/non-active window appearance + key = QLS("a"); + QGtkStylePrivate::gtkWidgetSetFocus(gtkTreeView, true); + } + bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled)); + gtkPainter->paintFlatBox(gtkTreeView, detail, option->rect, + option->state & State_Selected ? GTK_STATE_SELECTED : + isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, + GTK_SHADOW_OUT, gtk_widget_get_style(gtkTreeView), key); + if (isActive ) + QGtkStylePrivate::gtkWidgetSetFocus(gtkTreeView, false); + } + } + break; + case PE_IndicatorToolBarSeparator: + { + const int margin = 6; + GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem"); + if (option->state & State_Horizontal) { + const int offset = option->rect.width()/2; + QRect rect = option->rect.adjusted(offset, margin, 0, -margin); + painter->setPen(QPen(option->palette.background().color().darker(110))); + gtkPainter->paintVline(gtkSeparator, "vseparator", + rect, GTK_STATE_NORMAL, gtk_widget_get_style(gtkSeparator), + 0, rect.height(), 0); + } else { //Draw vertical separator + const int offset = option->rect.height()/2; + QRect rect = option->rect.adjusted(margin, offset, -margin, 0); + painter->setPen(QPen(option->palette.background().color().darker(110))); + gtkPainter->paintHline(gtkSeparator, "hseparator", + rect, GTK_STATE_NORMAL, gtk_widget_get_style(gtkSeparator), + 0, rect.width(), 0); + } + } + break; + + case PE_IndicatorToolBarHandle: { + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); + GtkShadowType shadow_type; + gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); + //Note when the toolbar is horizontal, the handle is vertical + painter->setClipRect(option->rect); + gtkPainter->paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1), + GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ? + GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, gtk_widget_get_style(gtkToolbar)); + } + break; + + case PE_IndicatorArrowUp: + case PE_IndicatorArrowDown: + case PE_IndicatorArrowLeft: + case PE_IndicatorArrowRight: { + + + GtkArrowType type = GTK_ARROW_UP; + + switch (element) { + + case PE_IndicatorArrowDown: + type = GTK_ARROW_DOWN; + break; + + case PE_IndicatorArrowLeft: + type = GTK_ARROW_LEFT; + break; + + case PE_IndicatorArrowRight: + type = GTK_ARROW_RIGHT; + break; + + default: + break; + } + int size = qMin(option->rect.height(), option->rect.width()); + int border = (size > 9) ? (size/4) : 0; //Allow small arrows to have exact dimensions + int bsx = 0, bsy = 0; + if (option->state & State_Sunken) { + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); + } + QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy); + GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT; + GtkStateType state = qt_gtk_state(option); + + QColor arrowColor = option->palette.buttonText().color(); + GtkWidget *gtkArrow = d->gtkWidget("GtkArrow"); + GdkColor color = fromQColor(arrowColor); + gtk_widget_modify_fg (gtkArrow, state, &color); + gtkPainter->paintArrow(gtkArrow, "button", arrowRect, + type, state, shadow, false, gtk_widget_get_style(gtkArrow), + QString::number(arrowColor.rgba(), 16)); + // Passing NULL will revert the color change + gtk_widget_modify_fg (gtkArrow, state, NULL); + } + break; + + case PE_FrameGroupBox: + // Do nothing here, the GNOME groupboxes are flat + break; + + case PE_PanelMenu: { + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); + gtkPainter->setAlphaSupport(false); // Note, alpha disabled for performance reasons + gtkPainter->paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtk_widget_get_style(gtkMenu), QString()); + } + break; + + case PE_FrameMenu: + //This is actually done by PE_Widget due to a clipping issue + //Otherwise Menu items will not be able to span the entire menu width + + // This is only used by floating tool bars + if (qobject_cast(widget)) { + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); + gtkPainter->paintBox(gtkMenubar, "toolbar", option->rect, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, style); + gtkPainter->paintBox(gtkMenubar, "menu", option->rect, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, style); + } + break; + + case PE_FrameLineEdit: { + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); + + + gboolean interior_focus; + gint focus_line_width; + QRect rect = option->rect; + gtk_widget_style_get(gtkEntry, + "interior-focus", &interior_focus, + "focus-line-width", &focus_line_width, NULL); + + // See https://bugzilla.mozilla.org/show_bug.cgi?id=405421 for info about this hack + g_object_set_data(G_OBJECT(gtkEntry), "transparent-bg-hint", GINT_TO_POINTER(true)); + + if (!interior_focus && option->state & State_HasFocus) + rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width); + + if (option->state & State_HasFocus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, true); + gtkPainter->paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ? + GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, + GTK_SHADOW_IN, gtk_widget_get_style(gtkEntry), + option->state & State_HasFocus ? QLS("focus") : QString()); + if (!interior_focus && option->state & State_HasFocus) + gtkPainter->paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ? + GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, + GTK_SHADOW_IN, gtk_widget_get_style(gtkEntry), QLS("GtkEntryShadowIn")); + + if (option->state & State_HasFocus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, false); + } + break; + + case PE_PanelLineEdit: + if (const QStyleOptionFrame *panel = qstyleoption_cast(option)) { + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); + if (panel->lineWidth > 0) + proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget); + uint resolve_mask = option->palette.resolve(); + GtkStyle *gtkEntryStyle = gtk_widget_get_style(gtkEntry); + QRect textRect = option->rect.adjusted(gtkEntryStyle->xthickness, gtkEntryStyle->ythickness, + -gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness); + + if (widget && widget->testAttribute(Qt::WA_SetPalette) && + resolve_mask & (1 << QPalette::Base)) // Palette overridden by user + painter->fillRect(textRect, option->palette.base()); + else + gtkPainter->paintFlatBox(gtkEntry, "entry_bg", textRect, + option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntryStyle); + } + break; + + case PE_FrameTabWidget: + if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast(option)) { + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); + style = gtk_widget_get_style(gtkNotebook); + gtkPainter->setAlphaSupport(false); + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook + bool reverse = (option->direction == Qt::RightToLeft); + gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + + GtkPositionType frameType = GTK_POS_TOP; + QTabBar::Shape shape = frame->shape; + int gapStart = 0; + int gapSize = 0; + if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) { + frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM; + gapStart = frame->selectedTabRect.left(); + gapSize = frame->selectedTabRect.width(); + } else { + frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT; + gapStart = frame->selectedTabRect.y(); + gapSize = frame->selectedTabRect.height(); + } + gtkPainter->paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType, + gapStart, gapSize, style); + } + break; + + case PE_PanelButtonCommand: + case PE_PanelButtonTool: { + bool isDefault = false; + bool isTool = (element == PE_PanelButtonTool); + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) + isDefault = btn->features & QStyleOptionButton::DefaultButton; + + // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on + if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise)) + break; + // don't draw a frame for dock widget buttons, unless we are hovering + if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver)) + break; + + GtkStateType state = qt_gtk_state(option); + if (option->state & State_On || option->state & State_Sunken) + state = GTK_STATE_ACTIVE; + GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton"); + gint focusWidth, focusPad; + gboolean interiorFocus = false; + gtk_widget_style_get (gtkButton, + "focus-line-width", &focusWidth, + "focus-padding", &focusPad, + "interior-focus", &interiorFocus, NULL); + + style = gtk_widget_get_style(gtkButton); + + QRect buttonRect = option->rect; + + QString key; + if (isDefault) { + key += QLS("def"); + gtk_widget_set_can_default(gtkButton, true); + gtk_window_set_default((GtkWindow*)gtk_widget_get_toplevel(gtkButton), gtkButton); + gtkPainter->paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN, + style, isDefault ? QLS("d") : QString()); + } + + bool hasFocus = option->state & State_HasFocus; + + if (hasFocus) { + key += QLS("def"); + QGtkStylePrivate::gtkWidgetSetFocus(gtkButton, true); + } + + if (!interiorFocus) + buttonRect = buttonRect.adjusted(focusWidth, focusWidth, -focusWidth, -focusWidth); + + GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? + GTK_SHADOW_IN : GTK_SHADOW_OUT; + + gtkPainter->paintBox(gtkButton, "button", buttonRect, state, shadow, + style, key); + if (isDefault) + gtk_window_set_default((GtkWindow*)gtk_widget_get_toplevel(gtkButton), 0); + if (hasFocus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkButton, false); + } + break; + + case PE_IndicatorRadioButton: { + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = qt_gtk_state(option); + + if (option->state & State_Sunken) + state = GTK_STATE_ACTIVE; + + if (option->state & State_NoChange) + shadow = GTK_SHADOW_ETCHED_IN; + else if (option->state & State_On) + shadow = GTK_SHADOW_IN; + else + shadow = GTK_SHADOW_OUT; + + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); + gint spacing; + gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL); + QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); + gtkPainter->setClipRect(option->rect); + // ### Note: Ubuntulooks breaks when the proper widget is passed + // Murrine engine requires a widget not to get RGBA check - warnings + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); + QString key(QLS("radiobutton")); + if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag + key += QLatin1Char('f'); + QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, true); + } + gtkPainter->paintOption(gtkCheckButton , buttonRect, state, shadow, gtk_widget_get_style(gtkRadioButton), key); + if (option->state & State_HasFocus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, false); + } + break; + + case PE_IndicatorCheckBox: { + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = qt_gtk_state(option); + + if (option->state & State_Sunken) + state = GTK_STATE_ACTIVE; + + if (option->state & State_NoChange) + shadow = GTK_SHADOW_ETCHED_IN; + else if (option->state & State_On) + shadow = GTK_SHADOW_IN; + else + shadow = GTK_SHADOW_OUT; + + int spacing; + + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); + QString key(QLS("checkbutton")); + if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag + key += QLatin1Char('f'); + QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, true); + } + + // Some styles such as aero-clone assume they can paint in the spacing area + gtkPainter->setClipRect(option->rect); + + gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL); + + QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); + + gtkPainter->paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtk_widget_get_style(gtkCheckButton), + key); + if (option->state & State_HasFocus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, false); + + } + break; + +#ifndef QT_NO_TABBAR + + case PE_FrameTabBarBase: + if (const QStyleOptionTabBarBase *tbb + = qstyleoption_cast(option)) { + QRect tabRect = tbb->rect; + painter->save(); + painter->setPen(QPen(option->palette.dark().color().dark(110), 0)); + switch (tbb->shape) { + + case QTabBar::RoundedNorth: + painter->drawLine(tabRect.topLeft(), tabRect.topRight()); + break; + + case QTabBar::RoundedWest: + painter->drawLine(tabRect.left(), tabRect.top(), tabRect.left(), tabRect.bottom()); + break; + + case QTabBar::RoundedSouth: + painter->drawLine(tbb->rect.left(), tbb->rect.bottom(), + tabRect.right(), tabRect.bottom()); + break; + + case QTabBar::RoundedEast: + painter->drawLine(tabRect.topRight(), tabRect.bottomRight()); + break; + + case QTabBar::TriangularNorth: + case QTabBar::TriangularEast: + case QTabBar::TriangularWest: + case QTabBar::TriangularSouth: + painter->restore(); + QCommonStyle::drawPrimitive(element, option, painter, widget); + return; + } + + painter->restore(); + } + return; + +#endif // QT_NO_TABBAR + + case PE_Widget: + break; + + default: + QCommonStyle::drawPrimitive(element, option, painter, widget); + } +} + +/*! + \reimp +*/ +void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, + + QPainter *painter, const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) { + QCommonStyle::drawComplexControl(control, option, painter, widget); + return; + } + + GtkStyle* style = d->gtkStyle(); + QGtkPainter* gtkPainter = d->gtkPainter(painter); + QColor button = option->palette.button().color(); + QColor dark; + QColor grooveColor; + QColor darkOutline; + dark.setHsv(button.hue(), + qMin(255, (int)(button.saturation()*1.9)), + qMin(255, (int)(button.value()*0.7))); + grooveColor.setHsv(button.hue(), + qMin(255, (int)(button.saturation()*2.6)), + qMin(255, (int)(button.value()*0.9))); + darkOutline.setHsv(button.hue(), + qMin(255, (int)(button.saturation()*3.0)), + qMin(255, (int)(button.value()*0.6))); + + QColor alphaCornerColor; + + if (widget) + alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline); + else + alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline); + + switch (control) { + + case CC_TitleBar: + painter->save(); + if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast(option)) { + // Since this is drawn by metacity and not Gtk we + // have to do custom drawing + + GdkColor gdkBg = style->bg[GTK_STATE_SELECTED]; + QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); + + const int buttonMargin = 5; + bool active = (titleBar->titleBarState & State_Active); + QRect fullRect = titleBar->rect; + QPalette palette = option->palette; + QColor highlight = bgColor; + + QColor titleBarFrameBorder(active ? highlight.darker(180): dark.darker(110)); + QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120)); + QColor textColor(active ? 0xffffff : 0xff000000); + QColor textAlphaColor(active ? 0xffffff : 0xff000000 ); + + { + // Fill title bar gradient + QColor titlebarColor = QColor(active ? highlight: palette.background().color()); + QLinearGradient gradient(option->rect.center().x(), option->rect.top(), + option->rect.center().x(), option->rect.bottom()); + + gradient.setColorAt(0, titlebarColor.lighter(114)); + gradient.setColorAt(0.5, titlebarColor.lighter(102)); + gradient.setColorAt(0.51, titlebarColor.darker(104)); + gradient.setColorAt(1, titlebarColor); + painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient); + + // Frame and rounded corners + painter->setPen(titleBarFrameBorder); + + // top outline + painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); + painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); + const QPoint points[5] = { + QPoint(fullRect.left() + 4, fullRect.top() + 1), + QPoint(fullRect.left() + 3, fullRect.top() + 1), + QPoint(fullRect.left() + 2, fullRect.top() + 2), + QPoint(fullRect.left() + 1, fullRect.top() + 3), + QPoint(fullRect.left() + 1, fullRect.top() + 4) + }; + painter->drawPoints(points, 5); + + painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); + const QPoint points2[5] = { + QPoint(fullRect.right() - 3, fullRect.top() + 1), + QPoint(fullRect.right() - 4, fullRect.top() + 1), + QPoint(fullRect.right() - 2, fullRect.top() + 2), + QPoint(fullRect.right() - 1, fullRect.top() + 3), + QPoint(fullRect.right() - 1, fullRect.top() + 4) + }; + painter->drawPoints(points2, 5); + + // draw bottomline + painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom()); + + // top highlight + painter->setPen(titleBarHighlight); + painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1); + } + // draw title + QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); + QFont font = painter->font(); + font.setBold(true); + painter->setFont(font); + painter->setPen(active? (titleBar->palette.text().color().lighter(120)) : + titleBar->palette.text().color() ); + // Note workspace also does elliding but it does not use the correct font + QString title = QFontMetrics(font).elidedText(titleBar->text, Qt::ElideRight, textRect.width() - 14); + painter->drawText(textRect.adjusted(1, 1, 1, 1), title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); + painter->setPen(Qt::white); + if (active) + painter->drawText(textRect, title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); + // min button + if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && + !(titleBar->titleBarState& Qt::WindowMinimized)) { + QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); + if (minButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); + qt_gtk_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); + QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin); + painter->setPen(textColor); + painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3, + minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3); + painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4, + minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4); + painter->setPen(textAlphaColor); + painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3, + minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4); + painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3, + minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4); + } + } + // max button + if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && + !(titleBar->titleBarState & Qt::WindowMaximized)) { + QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); + if (maxButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); + qt_gtk_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); + + QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); + + painter->setPen(textColor); + painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); + painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, + maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); + painter->setPen(textAlphaColor); + const QPoint points[4] = { + maxButtonIconRect.topLeft(), + maxButtonIconRect.topRight(), + maxButtonIconRect.bottomLeft(), + maxButtonIconRect.bottomRight() + }; + painter->drawPoints(points, 4); + } + } + + // close button + if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { + QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); + if (closeButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); + qt_gtk_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); + QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); + painter->setPen(textAlphaColor); + const QLine lines[4] = { + QLine(closeIconRect.left() + 1, closeIconRect.top(), + closeIconRect.right(), closeIconRect.bottom() - 1), + QLine(closeIconRect.left(), closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom()), + QLine(closeIconRect.right() - 1, closeIconRect.top(), + closeIconRect.left(), closeIconRect.bottom() - 1), + QLine(closeIconRect.right(), closeIconRect.top() + 1, + closeIconRect.left() + 1, closeIconRect.bottom()) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + closeIconRect.topLeft(), + closeIconRect.topRight(), + closeIconRect.bottomLeft(), + closeIconRect.bottomRight() + }; + painter->drawPoints(points, 4); + + painter->setPen(textColor); + painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom() - 1); + painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1, + closeIconRect.right() - 1, closeIconRect.top() + 1); + } + } + + // normalize button + if ((titleBar->subControls & SC_TitleBarNormalButton) && + (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && + (titleBar->titleBarState & Qt::WindowMinimized)) || + ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && + (titleBar->titleBarState & Qt::WindowMaximized)))) { + QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); + if (normalButtonRect.isValid()) { + + bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken); + QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); + qt_gtk_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken); + + QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0); + painter->setPen(textColor); + painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1)); + painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, + frontWindowRect.right() - 1, frontWindowRect.top() + 1); + painter->setPen(textAlphaColor); + const QPoint points[4] = { + frontWindowRect.topLeft(), + frontWindowRect.topRight(), + frontWindowRect.bottomLeft(), + frontWindowRect.bottomRight() + }; + painter->drawPoints(points, 4); + + QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); + QRegion clipRegion = backWindowRect; + clipRegion -= frontWindowRect; + painter->save(); + painter->setClipRegion(clipRegion); + painter->setPen(textColor); + painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1)); + painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, + backWindowRect.right() - 1, backWindowRect.top() + 1); + painter->setPen(textAlphaColor); + const QPoint points2[4] = { + backWindowRect.topLeft(), + backWindowRect.topRight(), + backWindowRect.bottomLeft(), + backWindowRect.bottomRight() + }; + painter->drawPoints(points2, 4); + painter->restore(); + } + } + + // context help button + if (titleBar->subControls & SC_TitleBarContextHelpButton + && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) { + QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); + if (contextHelpButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); + qt_gtk_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); + + QColor blend; + QImage image(qt_titlebar_context_help); + QColor alpha = textColor; + alpha.setAlpha(128); + image.setColor(1, textColor.rgba()); + image.setColor(2, alpha.rgba()); + painter->setRenderHint(QPainter::SmoothPixmapTransform); + painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image); + } + } + + // shade button + if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { + QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); + if (shadeButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); + qt_gtk_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken); + QImage image(qt_scrollbar_button_arrow_up); + image.setColor(1, textColor.rgba()); + painter->drawImage(shadeButtonRect.adjusted(5, 7, -5, -7), image); + } + } + + // unshade button + if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { + QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); + if (unshadeButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); + qt_gtk_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken); + QImage image(qt_scrollbar_button_arrow_down); + image.setColor(1, textColor.rgba()); + painter->drawImage(unshadeButtonRect.adjusted(5, 7, -5, -7), image); + } + } + + if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { + QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); + if (iconRect.isValid()) { + if (!titleBar->icon.isNull()) { + titleBar->icon.paint(painter, iconRect); + } else { + QStyleOption tool(0); + tool.palette = titleBar->palette; + QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16); + tool.rect = iconRect; + painter->save(); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); + painter->restore(); + } + } + } + } + painter->restore(); + break; + +#ifndef QT_NO_GROUPBOX + + case CC_GroupBox: + painter->save(); + + if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { + QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); + QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); + // Draw title + + if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { + // Draw prelight background + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); + + if (option->state & State_MouseOver) { + QRect bgRect = textRect | checkBoxRect; + gtkPainter->paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2), + GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtk_widget_get_style(gtkCheckButton)); + } + + if (!groupBox->text.isEmpty()) { + int alignment = int(groupBox->textAlignment); + if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) + alignment |= Qt::TextHideMnemonic; + QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored + int labelState = GTK_STATE_INSENSITIVE; + + if (option->state & State_Enabled) + labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; + + GdkColor gdkText = gtk_widget_get_style(gtkCheckButton)->fg[labelState]; + textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + painter->setPen(textColor); + QFont font = painter->font(); + font.setBold(true); + painter->setFont(font); + painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text); + + if (option->state & State_HasFocus) + gtkPainter->paintFocus(gtkCheckButton, "checkbutton", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style); + } + } + + if (groupBox->subControls & SC_GroupBoxCheckBox) { + QStyleOptionButton box; + box.QStyleOption::operator=(*groupBox); + box.rect = checkBoxRect; + proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); + } + } + + painter->restore(); + break; +#endif // QT_NO_GROUPBOX + +#ifndef QT_NO_COMBOBOX + + case CC_ComboBox: + // See: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBox + // and http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBoxEntry + if (const QStyleOptionComboBox *comboBox = qstyleoption_cast(option)) { + bool sunken = comboBox->state & State_On; // play dead, if combobox has no items + BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable)); + gtkPainter->reset(p); + gtkPainter->setUsePixmapCache(false); // cached externally + + bool isEnabled = (comboBox->state & State_Enabled); + bool focus = isEnabled && (comboBox->state & State_HasFocus); + GtkStateType state = qt_gtk_state(option); + int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget); + QStyleOptionComboBox comboBoxCopy = *comboBox; + comboBoxCopy.rect = option->rect; + + bool reverse = (option->direction == Qt::RightToLeft); + QRect rect = option->rect; + QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, + SC_ComboBoxArrow, widget); + + GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? + GTK_SHADOW_IN : GTK_SHADOW_OUT; + const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox"); + + // We use the gtk widget to position arrows and separators for us + GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); + GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()}; + gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + gtk_widget_size_allocate(gtkCombo, &geometry); + + QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); + GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath); + gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + if (gtkToggleButton && (appears_as_list || comboBox->editable)) { + if (focus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, true); + // Draw the combo box as a line edit with a button next to it + if (comboBox->editable || appears_as_list) { + GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state; + QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame"); + GtkWidget *gtkEntry = d->gtkWidget(entryPath); + gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + QRect frameRect = option->rect; + + if (reverse) + frameRect.setLeft(arrowButtonRect.right()); + else + frameRect.setRight(arrowButtonRect.left()); + + // Fill the line edit background + // We could have used flat_box with "entry_bg" but that is probably not worth the overhead + uint resolve_mask = option->palette.resolve(); + GtkStyle *gtkEntryStyle = gtk_widget_get_style(gtkEntry); + QRect contentRect = frameRect.adjusted(gtkEntryStyle->xthickness, gtkEntryStyle->ythickness, + -gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness); + // Required for inner blue highlight with clearlooks + if (focus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, true); + + if (widget && widget->testAttribute(Qt::WA_SetPalette) && + resolve_mask & (1 << QPalette::Base)) // Palette overridden by user + p->fillRect(contentRect, option->palette.base().color()); + else { + gtkPainter->paintFlatBox(gtkEntry, "entry_bg", contentRect, + option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, + GTK_SHADOW_NONE, gtkEntryStyle, entryPath.toString() + QString::number(focus)); + } + + gtkPainter->paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, + GTK_SHADOW_IN, gtkEntryStyle, entryPath.toString() + + QString::number(focus) + QString::number(comboBox->editable) + + QString::number(option->direction)); + if (focus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, false); + } + + GtkStateType buttonState = GTK_STATE_NORMAL; + + if (!(option->state & State_Enabled)) + buttonState = GTK_STATE_INSENSITIVE; + else if (option->state & State_Sunken || option->state & State_On) + buttonState = GTK_STATE_ACTIVE; + else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow) + buttonState = GTK_STATE_PRELIGHT; + + Q_ASSERT(gtkToggleButton); + gtkPainter->paintBox(gtkToggleButton, "button", arrowButtonRect, buttonState, + shadow, gtk_widget_get_style(gtkToggleButton), buttonPath.toString() + + QString::number(focus) + QString::number(option->direction)); + if (focus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, false); + } else { + // Draw combo box as a button + QRect buttonRect = option->rect; + GtkStyle *gtkToggleButtonStyle = gtk_widget_get_style(gtkToggleButton); + + if (focus) // Clearlooks actually check the widget for the default state + QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, true); + gtkPainter->paintBox(gtkToggleButton, "button", + buttonRect, state, + shadow, gtkToggleButtonStyle, + buttonPath.toString() + QString::number(focus)); + if (focus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, false); + + + // Draw the separator between label and arrows + QHashableLatin1Literal vSeparatorPath = comboBox->editable + ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator"); + + if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) { + GtkAllocation allocation; + gtk_widget_get_allocation(gtkVSeparator, &allocation); + QRect vLineRect(allocation.x, allocation.y, allocation.width, allocation.height); + + gtkPainter->paintVline(gtkVSeparator, "vseparator", + vLineRect, state, gtk_widget_get_style(gtkVSeparator), + 0, vLineRect.height(), 0, vSeparatorPath.toString()); + + + gint interiorFocus = true; + gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL); + int xt = interiorFocus ? gtkToggleButtonStyle->xthickness : 0; + int yt = interiorFocus ? gtkToggleButtonStyle->ythickness : 0; + if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) + gtkPainter->paintFocus(gtkToggleButton, "button", + option->rect.adjusted(xt, yt, -xt, -yt), + option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, + gtkToggleButtonStyle); + } + } + + if (comboBox->subControls & SC_ComboBoxArrow) { + if (!isEnabled) + state = GTK_STATE_INSENSITIVE; + else if (sunken) + state = GTK_STATE_ACTIVE; + else if (option->state & State_MouseOver) + state = GTK_STATE_PRELIGHT; + else + state = GTK_STATE_NORMAL; + + QHashableLatin1Literal arrowPath(""); + if (comboBox->editable) { + if (appears_as_list) + arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow"); + else + arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow"); + } else { + if (appears_as_list) + arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow"); + else + arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"); + } + + GtkWidget *gtkArrow = d->gtkWidget(arrowPath); + gfloat scale = 0.7; + gint minSize = 15; + QRect arrowWidgetRect; + + if (gtkArrow && !gtk_check_version(2, 12, 0)) { + gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL); + gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL); + } + if (gtkArrow) { + GtkAllocation allocation; + gtk_widget_get_allocation(gtkArrow, &allocation); + arrowWidgetRect = QRect(allocation.x, allocation.y, allocation.width, allocation.height); + style = gtk_widget_get_style(gtkArrow); + } + + // Note that for some reason the arrow-size is not properly respected with Hildon + // Hence we enforce the minimum "arrow-size" ourselves + int arrowSize = qMax(qMin(rect.height() - gtk_widget_get_style(gtkCombo)->ythickness * 2, minSize), + qMin(arrowWidgetRect.width(), arrowWidgetRect.height())); + QRect arrowRect(0, 0, static_cast(arrowSize * scale), static_cast(arrowSize * scale)); + + arrowRect.moveCenter(arrowWidgetRect.center()); + + if (sunken) { + int xoff, yoff; + const QHashableLatin1Literal toggleButtonPath = comboBox->editable + ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); + + GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath); + gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL); + gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL); + arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff); + } + + // Some styles such as Nimbus paint outside the arrowRect + // hence we have provide the whole widget as the cliprect + if (gtkArrow) { + gtkPainter->setClipRect(option->rect); + gtkPainter->paintArrow(gtkArrow, "arrow", arrowRect, + GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, true, + style, arrowPath.toString() + QString::number(option->direction)); + } + } + END_STYLE_PIXMAPCACHE; + } + break; +#endif // QT_NO_COMBOBOX +#ifndef QT_NO_TOOLBUTTON + + case CC_ToolButton: + if (const QStyleOptionToolButton *toolbutton + = qstyleoption_cast(option)) { + QRect button, menuarea; + button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget); + menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); + State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver); + + if (bflags & State_AutoRaise) + if (!(bflags & State_MouseOver)) + bflags &= ~State_Raised; + + State mflags = bflags; + + if (toolbutton->state & State_Sunken) { + if (toolbutton->activeSubControls & SC_ToolButton) + bflags |= State_Sunken; + if (toolbutton->activeSubControls & SC_ToolButtonMenu) + mflags |= State_Sunken; + } else if (toolbutton->state & State_MouseOver) { + if (toolbutton->activeSubControls & SC_ToolButton) + bflags |= State_MouseOver; + if (toolbutton->activeSubControls & SC_ToolButtonMenu) + mflags |= State_MouseOver; + } + + QStyleOption tool(0); + + tool.palette = toolbutton->palette; + + if (toolbutton->subControls & SC_ToolButton) { + if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) { + tool.rect = button; + tool.state = bflags; + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); + } + } + + bool drawMenuArrow = toolbutton->features & QStyleOptionToolButton::HasMenu && + !(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup); + int popupArrowSize = drawMenuArrow ? 7 : 0; + + if (toolbutton->state & State_HasFocus) { + QStyleOptionFocusRect fr; + fr.QStyleOption::operator=(*toolbutton); + fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget); + fr.rect.adjust(1, 1, -1, -1); + proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); + } + + QStyleOptionToolButton label = *toolbutton; + label.state = bflags; + GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton"); + QPalette pal = toolbutton->palette; + if (option->state & State_Enabled && + option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) { + GdkColor gdkText = gtk_widget_get_style(gtkButton)->fg[GTK_STATE_PRELIGHT]; + QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + pal.setBrush(QPalette::All, QPalette::ButtonText, textColor); + label.palette = pal; + } + label.rect = button.adjusted(style->xthickness, style->ythickness, + -style->xthickness - popupArrowSize, -style->ythickness); + proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget); + + if (toolbutton->subControls & SC_ToolButtonMenu) { + tool.rect = menuarea; + tool.state = mflags; + if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise)) + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget); + + proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); + + } else if (drawMenuArrow) { + QRect ir = toolbutton->rect; + QStyleOptionToolButton newBtn = *toolbutton; + newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); + } + } + break; + +#endif // QT_NO_TOOLBUTTON +#ifndef QT_NO_SCROLLBAR + + case CC_ScrollBar: + if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { + GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar"); + GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar"); + + // Fill background in case the scrollbar is partially transparent + painter->fillRect(option->rect, option->palette.background()); + + QRect rect = scrollBar->rect; + QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); + QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); + QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); + QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); + bool horizontal = scrollBar->orientation == Qt::Horizontal; + GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar; + style = gtk_widget_get_style(scrollbarWidget); + gboolean trough_under_steppers = true; + gboolean trough_side_details = false; + gboolean activate_slider = false; + gboolean stepper_size = 14; + gint trough_border = 1; + if (!gtk_check_version(2, 10, 0)) { + gtk_widget_style_get((GtkWidget*)(scrollbarWidget), + "trough-border", &trough_border, + "trough-side-details", &trough_side_details, + "trough-under-steppers", &trough_under_steppers, + "activate-slider", &activate_slider, + "stepper-size", &stepper_size, NULL); + } + if (trough_under_steppers) { + scrollBarAddLine.adjust(trough_border, trough_border, -trough_border, -trough_border); + scrollBarSubLine.adjust(trough_border, trough_border, -trough_border, -trough_border); + scrollBarSlider.adjust(horizontal ? -trough_border : 0, horizontal ? 0 : -trough_border, + horizontal ? trough_border : 0, horizontal ? 0 : trough_border); + } + + // Some styles check the position of scrollbars in order to determine + // if lines should be painted when the scrollbar is in max or min positions. + int maximum = 2; + int fakePos = 0; + bool reverse = (option->direction == Qt::RightToLeft); + if (scrollBar->minimum == scrollBar->maximum) + maximum = 0; + if (scrollBar->sliderPosition == scrollBar->maximum) + fakePos = maximum; + else if (scrollBar->sliderPosition > scrollBar->minimum) + fakePos = maximum - 1; + + + GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar); + GtkAdjustment *adjustment = 0; + + adjustment = gtk_range_get_adjustment(range); + if (adjustment) { + gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0); + } else { + adjustment = (GtkAdjustment*)gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0); + gtk_range_set_adjustment(range, adjustment); + } + + if (scrollBar->subControls & SC_ScrollBarGroove) { + GtkStateType state = GTK_STATE_ACTIVE; + + if (!(option->state & State_Enabled)) + state = GTK_STATE_INSENSITIVE; + + if (trough_under_steppers) + grooveRect = option->rect; + + gtkPainter->paintBox(scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style); + } + + //paint slider + if (scrollBar->subControls & SC_ScrollBarSlider) { + GtkStateType state = GTK_STATE_NORMAL; + + if (!(option->state & State_Enabled)) + state = GTK_STATE_INSENSITIVE; + else if (activate_slider && + option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSlider)) + state = GTK_STATE_ACTIVE; + else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider)) + state = GTK_STATE_PRELIGHT; + + GtkShadowType shadow = GTK_SHADOW_OUT; + + if (trough_under_steppers) { + if (!horizontal) + scrollBarSlider.adjust(trough_border, 0, -trough_border, 0); + else + scrollBarSlider.adjust(0, trough_border, 0, -trough_border); + } + + gtkPainter->paintSlider(scrollbarWidget, "slider", scrollBarSlider, state, shadow, style, + horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum)); + } + + if (scrollBar->subControls & SC_ScrollBarAddLine) { + GtkAllocation vAllocation; + vAllocation.y = scrollBarAddLine.top(); + vAllocation.height = scrollBarAddLine.height() - rect.height() + 6; + gtk_widget_set_allocation(gtkVScrollBar, &vAllocation); + + GtkAllocation hAllocation; + hAllocation.x = scrollBarAddLine.right(); + hAllocation.width = scrollBarAddLine.width() - rect.width(); + gtk_widget_set_allocation(gtkHScrollBar, &hAllocation); + + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = GTK_STATE_NORMAL; + + if (!(option->state & State_Enabled) || (fakePos == maximum)) + state = GTK_STATE_INSENSITIVE; + else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) { + state = GTK_STATE_ACTIVE; + shadow = GTK_SHADOW_IN; + + } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) + state = GTK_STATE_PRELIGHT; + + gtkPainter->paintBox(scrollbarWidget, + horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine, + state, shadow, style, QLS("add")); + + gtkPainter->paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4), + horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) : + GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, false, style); + } + + if (scrollBar->subControls & SC_ScrollBarSubLine) { + GtkAllocation vAllocation; + vAllocation.y = 0; + vAllocation.height = scrollBarSubLine.height(); + gtk_widget_set_allocation(gtkVScrollBar, &vAllocation); + + GtkAllocation hAllocation; + hAllocation.x = 0; + hAllocation.width = scrollBarSubLine.width(); + gtk_widget_set_allocation(gtkHScrollBar, &hAllocation); + + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = GTK_STATE_NORMAL; + + if (!(option->state & State_Enabled) || (fakePos == 0)) + state = GTK_STATE_INSENSITIVE; + else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) { + shadow = GTK_SHADOW_IN; + state = GTK_STATE_ACTIVE; + + } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) + state = GTK_STATE_PRELIGHT; + + gtkPainter->paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine, + state, shadow, style, QLS("sub")); + + gtkPainter->paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4), + horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) : + GTK_ARROW_UP, state, GTK_SHADOW_NONE, false, style); + } + } + break; + +#endif //QT_NO_SCROLLBAR +#ifndef QT_NO_SPINBOX + + case CC_SpinBox: + if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { + + GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons + ? d->gtkWidget("GtkEntry") + : d->gtkWidget("GtkSpinButton"); + bool isEnabled = (spinBox->state & State_Enabled); + bool hover = isEnabled && (spinBox->state & State_MouseOver); + bool sunken = (spinBox->state & State_Sunken); + bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp); + bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown); + bool reverse = (spinBox->direction == Qt::RightToLeft); + + QRect editArea = option->rect; + QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); + QRect upRect, downRect, buttonRect; + if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { + upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); + downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); + + //### Move this to subControlRect + upRect.setTop(option->rect.top()); + + if (reverse) + upRect.setLeft(option->rect.left()); + else + upRect.setRight(option->rect.right()); + + downRect.setBottom(option->rect.bottom()); + + if (reverse) + downRect.setLeft(option->rect.left()); + else + downRect.setRight(option->rect.right()); + + buttonRect = upRect | downRect; + + if (reverse) + editArea.setLeft(upRect.right()); + else + editArea.setRight(upRect.left()); + } + if (spinBox->frame) { + GtkStateType state = qt_gtk_state(option); + + if (!(option->state & State_Enabled)) + state = GTK_STATE_INSENSITIVE; + else if (option->state & State_HasFocus) + state = GTK_STATE_NORMAL; + else if (state == GTK_STATE_PRELIGHT) + state = GTK_STATE_NORMAL; + + style = gtk_widget_get_style(gtkSpinButton); + + + QString key; + + if (option->state & State_HasFocus) { + key += QLatin1Char('f'); + QGtkStylePrivate::gtkWidgetSetFocus(gtkSpinButton, true); + } + + uint resolve_mask = option->palette.resolve(); + + if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user + painter->fillRect(editRect, option->palette.base().color()); + else + gtkPainter->paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness, + -style->xthickness, -style->ythickness), + option->state & State_Enabled ? + GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key); + + gtkPainter->paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtk_widget_get_style(gtkSpinButton), key); + if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { + gtkPainter->paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key); + + upRect.setSize(downRect.size()); + if (!(option->state & State_Enabled)) + gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); + else if (upIsActive && sunken) + gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); + else if (upIsActive && hover) + gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); + else + gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); + + if (!(option->state & State_Enabled)) + gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); + else if (downIsActive && sunken) + gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); + else if (downIsActive && hover) + gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); + else + gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); + + if (option->state & State_HasFocus) + QGtkStylePrivate::gtkWidgetSetFocus(gtkSpinButton, false); + } + } + + if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { + int centerX = upRect.center().x(); + int centerY = upRect.center().y(); + // plus/minus + + if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) { + painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY); + painter->drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2); + + } else { + painter->drawLine(centerX - 2, centerY, centerX + 2, centerY); + painter->drawLine(centerX, centerY - 2, centerX, centerY + 2); + } + centerX = downRect.center().x(); + centerY = downRect.center().y(); + + if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) { + painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY); + } else { + painter->drawLine(centerX - 2, centerY, centerX + 2, centerY); + } + + } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) { + int size = d->getSpinboxArrowSize(); + int w = size / 2 - 1; + w -= w % 2 - 1; // force odd + int h = (w + 1)/2; + QRect arrowRect(0, 0, w, h); + arrowRect.moveCenter(upRect.center()); + // arrows + GtkStateType state = GTK_STATE_NORMAL; + + if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) + state = GTK_STATE_INSENSITIVE; + + gtkPainter->paintArrow(gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state, + GTK_SHADOW_NONE, false, style); + + arrowRect.moveCenter(downRect.center()); + + state = GTK_STATE_NORMAL; + if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) + state = GTK_STATE_INSENSITIVE; + + gtkPainter->paintArrow(gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state, + GTK_SHADOW_NONE, false, style); + } + } + break; + +#endif // QT_NO_SPINBOX + +#ifndef QT_NO_SLIDER + + case CC_Slider: + if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { + GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale"); + GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale"); + + QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); + + bool horizontal = slider->orientation == Qt::Horizontal; + bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; + bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; + + QBrush oldBrush = painter->brush(); + QPen oldPen = painter->pen(); + + QColor shadowAlpha(Qt::black); + shadowAlpha.setAlpha(10); + QColor highlightAlpha(Qt::white); + highlightAlpha.setAlpha(80); + + gtk_widget_set_direction(hScaleWidget, slider->upsideDown ? + GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget; + style = gtk_widget_get_style(scaleWidget); + + if ((option->subControls & SC_SliderGroove) && groove.isValid()) { + + GtkRange *range = (GtkRange*)scaleWidget; + GtkAdjustment *adjustment = 0; + adjustment = gtk_range_get_adjustment(range); + if (adjustment) { + gtk_adjustment_configure(adjustment, + slider->sliderPosition, + slider->minimum, + slider->maximum, + slider->singleStep, + slider->singleStep, + slider->pageStep); + } else { + adjustment = (GtkAdjustment*)gtk_adjustment_new(slider->sliderPosition, + slider->minimum, + slider->maximum, + slider->singleStep, + slider->singleStep, + slider->pageStep); + gtk_range_set_adjustment(range, adjustment); + } + + int outerSize; + gtk_range_set_inverted(range, !horizontal); + gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL); + outerSize++; + + GtkStateType state = qt_gtk_state(option); + int focusFrameMargin = 2; + QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin, + -focusFrameMargin, -outerSize - focusFrameMargin); + + gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs + if (!gtk_check_version(2, 10, 0)) + gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL); + + if (!trough_side_details) { + gtkPainter->paintBox(scaleWidget, "trough", grooveRect, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); + } else { + QRect upperGroove = grooveRect; + QRect lowerGroove = grooveRect; + + if (horizontal) { + if (slider->upsideDown) { + lowerGroove.setLeft(handle.center().x()); + upperGroove.setRight(handle.center().x()); + } else { + upperGroove.setLeft(handle.center().x()); + lowerGroove.setRight(handle.center().x()); + } + } else { + if (!slider->upsideDown) { + lowerGroove.setBottom(handle.center().y()); + upperGroove.setTop(handle.center().y()); + } else { + upperGroove.setBottom(handle.center().y()); + lowerGroove.setTop(handle.center().y()); + } + } + + gtkPainter->paintBox(scaleWidget, "trough-upper", upperGroove, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); + gtkPainter->paintBox(scaleWidget, "trough-lower", lowerGroove, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); + } + } + + if (option->subControls & SC_SliderTickmarks) { + painter->setPen(darkOutline); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int interval = slider->tickInterval; + + if (interval <= 0) { + interval = slider->singleStep; + + if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, + available) + - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, + 0, available) < 3) + interval = slider->pageStep; + } + + if (interval <= 0) + interval = 1; + + int v = slider->minimum; + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); + while (v <= slider->maximum + 1) { + if (v == slider->maximum + 1 && interval == 1) + break; + const int v_ = qMin(v, slider->maximum); + int pos = sliderPositionFromValue(slider->minimum, slider->maximum, + v_, (horizontal + ? slider->rect.width() + : slider->rect.height()) - len, + slider->upsideDown) + len / 2; + int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0); + if (horizontal) { + if (ticksAbove) + painter->drawLine(pos, slider->rect.top() + extra, + pos, slider->rect.top() + tickSize); + if (ticksBelow) + painter->drawLine(pos, slider->rect.bottom() - extra, + pos, slider->rect.bottom() - tickSize); + + } else { + if (ticksAbove) + painter->drawLine(slider->rect.left() + extra, pos, + slider->rect.left() + tickSize, pos); + if (ticksBelow) + painter->drawLine(slider->rect.right() - extra, pos, + slider->rect.right() - tickSize, pos); + } + + // In the case where maximum is max int + int nextInterval = v + interval; + if (nextInterval < v) + break; + v = nextInterval; + } + } + + // Draw slider handle + if (option->subControls & SC_SliderHandle) { + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = GTK_STATE_NORMAL; + + if (!(option->state & State_Enabled)) + state = GTK_STATE_INSENSITIVE; + else if (option->state & State_MouseOver && option->activeSubControls & SC_SliderHandle) + state = GTK_STATE_PRELIGHT; + + bool horizontal = option->state & State_Horizontal; + + if (slider->state & State_HasFocus) { + QStyleOptionFocusRect fropt; + fropt.QStyleOption::operator=(*slider); + fropt.rect = slider->rect.adjusted(-1, -1 ,1, 1); + + if (horizontal) { + fropt.rect.setTop(handle.top() - 3); + fropt.rect.setBottom(handle.bottom() + 4); + + } else { + fropt.rect.setLeft(handle.left() - 3); + fropt.rect.setRight(handle.right() + 3); + } + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + } + gtkPainter->paintSlider(scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style, + horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL); + } + painter->setBrush(oldBrush); + painter->setPen(oldPen); + } + break; + case CC_Dial: + if (const QStyleOptionSlider *dial = qstyleoption_cast(option)) + QStyleHelper::drawDial(dial, painter); + break; + +#endif // QT_NO_SLIDER + + default: + QCommonStyle::drawComplexControl(control, option, painter, widget); + + break; + } +} + + +/*! + \reimp +*/ +void QGtkStyle::drawControl(ControlElement element, + const QStyleOption *option, + QPainter *painter, + const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) { + QCommonStyle::drawControl(element, option, painter, widget); + return; + } + + GtkStyle* style = d->gtkStyle(); + QGtkPainter* gtkPainter = d->gtkPainter(painter); + + switch (element) { + case CE_ProgressBarLabel: + if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); + if (!gtkProgressBar) + return; + + QRect leftRect; + QRect rect = bar->rect; + GtkStyle *gtkProgressBarStyle = gtk_widget_get_style(gtkProgressBar); + GdkColor gdkText = gtkProgressBarStyle->fg[GTK_STATE_NORMAL]; + QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + gdkText = gtkProgressBarStyle->fg[GTK_STATE_PRELIGHT]; + QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + + painter->save(); + bool vertical = (bar->orientation == Qt::Vertical); + bool inverted = bar->invertedAppearance; + if (vertical) + rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height + const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / + qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) + leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); + if (vertical) + leftRect.translate(rect.width() - progressIndicatorPos, 0); + + bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) || + ((bar->direction == Qt::LeftToRight) && inverted))); + + QRegion rightRect = rect; + rightRect = rightRect.subtracted(leftRect); + painter->setClipRegion(rightRect); + painter->setPen(flip ? alternateTextColor : textColor); + painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); + if (!leftRect.isNull()) { + painter->setPen(flip ? textColor : alternateTextColor); + painter->setClipRect(leftRect); + painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); + } + painter->restore(); + } + break; + case CE_PushButtonLabel: + if (const QStyleOptionButton *button = qstyleoption_cast(option)) { + QRect ir = button->rect; + uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; + QPoint buttonShift; + + if (option->state & State_Sunken) + buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); + + if (proxy()->styleHint(SH_UnderlineShortcut, button, widget)) + tf |= Qt::TextShowMnemonic; + else + tf |= Qt::TextHideMnemonic; + + if (!button->icon.isNull()) { + //Center both icon and text + QPoint point; + + QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + if (mode == QIcon::Normal && button->state & State_HasFocus) + mode = QIcon::Active; + + QIcon::State state = QIcon::Off; + + if (button->state & State_On) + state = QIcon::On; + + QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); + int w = pixmap.width(); + int h = pixmap.height(); + + if (!button->text.isEmpty()) + w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 4; + + point = QPoint(ir.x() + ir.width() / 2 - w / 2, + ir.y() + ir.height() / 2 - h / 2); + + if (button->direction == Qt::RightToLeft) + point.rx() += pixmap.width(); + + painter->drawPixmap(visualPos(button->direction, button->rect, point + buttonShift), pixmap); + + if (button->direction == Qt::RightToLeft) + ir.translate(-point.x() - 2, 0); + else + ir.translate(point.x() + pixmap.width() + 2, 0); + + // left-align text if there is + if (!button->text.isEmpty()) + tf |= Qt::AlignLeft; + + } else { + tf |= Qt::AlignHCenter; + } + + ir.translate(buttonShift); + + if (button->features & QStyleOptionButton::HasMenu) + ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); + + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + QPalette pal = button->palette; + int labelState = GTK_STATE_INSENSITIVE; + if (option->state & State_Enabled) + labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ? + GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; + + GdkColor gdkText = gtk_widget_get_style(gtkButton)->fg[labelState]; + QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + pal.setBrush(QPalette::ButtonText, textColor); + proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled), + button->text, QPalette::ButtonText); + } + break; + + case CE_RadioButton: // Fall through + case CE_CheckBox: + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { + bool isRadio = (element == CE_RadioButton); + + // Draw prelight background + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); + + if (option->state & State_MouseOver) { + gtkPainter->paintFlatBox(gtkRadioButton, "checkbutton", option->rect, + GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtk_widget_get_style(gtkRadioButton)); + } + + QStyleOptionButton subopt = *btn; + subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator + : SE_CheckBoxIndicator, btn, widget); + proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, + &subopt, painter, widget); + subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents + : SE_CheckBoxContents, btn, widget); + // Get label text color + QPalette pal = subopt.palette; + int labelState = GTK_STATE_INSENSITIVE; + if (option->state & State_Enabled) + labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; + + GdkColor gdkText = gtk_widget_get_style(gtkRadioButton)->fg[labelState]; + QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + pal.setBrush(QPalette::WindowText, textColor); + subopt.palette = pal; + proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); + + if (btn->state & State_HasFocus) { + QStyleOptionFocusRect fropt; + fropt.QStyleOption::operator=(*btn); + fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect + : SE_CheckBoxFocusRect, btn, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + } + } + break; + +#ifndef QT_NO_COMBOBOX + + case CE_ComboBoxLabel: + if (const QStyleOptionComboBox *cb = qstyleoption_cast(option)) { + QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); + bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget); + painter->save(); + painter->setClipRect(editRect); + + if (!cb->currentIcon.isNull()) { + QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal + : QIcon::Disabled; + QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); + QRect iconRect(editRect); + iconRect.setWidth(cb->iconSize.width() + 4); + + iconRect = alignedRect(cb->direction, + Qt::AlignLeft | Qt::AlignVCenter, + iconRect.size(), editRect); + + if (cb->editable) + painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); + + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); + + if (cb->direction == Qt::RightToLeft) + editRect.translate(-4 - cb->iconSize.width(), 0); + else + editRect.translate(cb->iconSize.width() + 4, 0); + } + + if (!cb->currentText.isEmpty() && !cb->editable) { + GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox"); + QPalette pal = cb->palette; + int labelState = GTK_STATE_INSENSITIVE; + + if (option->state & State_Enabled) + labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; + + GdkColor gdkText = gtk_widget_get_style(gtkCombo)->fg[labelState]; + + QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + + pal.setBrush(QPalette::ButtonText, textColor); + + proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), + visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), + pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText); + } + + painter->restore(); + } + break; + +#endif // QT_NO_COMBOBOX + + case CE_DockWidgetTitle: + painter->save(); + if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast(option)) { + bool verticalTitleBar = dwOpt->verticalTitleBar; + + QRect rect = dwOpt->rect; + QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget).adjusted(-2, 0, -2, 0); + QRect r = rect.adjusted(0, 0, -1, -1); + if (verticalTitleBar) + r.adjust(0, 0, 0, -1); + + if (verticalTitleBar) { + QRect r = rect; + r.setSize(r.size().transposed()); + + titleRect = QRect(r.left() + rect.bottom() + - titleRect.bottom(), + r.top() + titleRect.left() - rect.left(), + titleRect.height(), titleRect.width()); + + painter->translate(r.left(), r.top() + r.width()); + painter->rotate(-90); + painter->translate(-r.left(), -r.top()); + + rect = r; + } + + if (!dwOpt->title.isEmpty()) { + QString titleText + = painter->fontMetrics().elidedText(dwOpt->title, + Qt::ElideRight, titleRect.width()); + proxy()->drawItemText(painter, + titleRect, + Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, + dwOpt->state & State_Enabled, titleText, + QPalette::WindowText); + } + } + painter->restore(); + break; + + + + case CE_HeaderSection: + painter->save(); + + // Draws the header in tables. + if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { + Q_UNUSED(header); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); + // Get the middle column + GtkTreeViewColumn *column = gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1); + Q_ASSERT(column); + + GtkWidget *gtkTreeHeader = column->button; + GtkStateType state = qt_gtk_state(option); + GtkShadowType shadow = GTK_SHADOW_OUT; + + if (option->state & State_Sunken) + shadow = GTK_SHADOW_IN; + + gtkPainter->paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, gtk_widget_get_style(gtkTreeHeader)); + } + + painter->restore(); + break; + +#ifndef QT_NO_SIZEGRIP + + case CE_SizeGrip: { + GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame"); + GtkStyle *gtkStatusbarStyle = gtk_widget_get_style(gtkStatusbar); + QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbarStyle->xthickness, -gtkStatusbarStyle->ythickness); + gtkPainter->paintResizeGrip(gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL, + GTK_SHADOW_OUT, option->direction == Qt::RightToLeft ? + GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST, + gtkStatusbarStyle); + } + break; + +#endif // QT_NO_SIZEGRIP + + case CE_MenuBarEmptyArea: { + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); + GdkColor gdkBg = gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency + painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); + if (widget) { // See CE_MenuBarItem + QRect menuBarRect = widget->rect(); + QPixmap pixmap(menuBarRect.size()); + pixmap.fill(Qt::transparent); + QPainter pmPainter(&pixmap); + gtkPainter->reset(&pmPainter); + GtkShadowType shadow_type; + gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL); + gtkPainter->paintBox(gtkMenubar, "menubar", menuBarRect, + GTK_STATE_NORMAL, shadow_type, gtk_widget_get_style(gtkMenubar)); + pmPainter.end(); + painter->drawPixmap(option->rect, pixmap, option->rect); + gtkPainter->reset(painter); + } + } + break; + + case CE_MenuBarItem: + painter->save(); + + if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(option)) { + GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem"); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); + + style = gtk_widget_get_style(gtkMenubarItem); + + if (widget) { + // Since Qt does not currently allow filling the entire background + // we use a hack for this by making a complete menubar each time and + // paint with the correct offset inside it. Pixmap caching should resolve + // most of the performance penalty. + QRect menuBarRect = widget->rect(); + QPixmap pixmap(menuBarRect.size()); + pixmap.fill(Qt::transparent); + QPainter pmPainter(&pixmap); + gtkPainter->reset(&pmPainter); + GtkShadowType shadow_type; + gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL); + GdkColor gdkBg = gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency + painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); + gtkPainter->paintBox(gtkMenubar, "menubar", menuBarRect, + GTK_STATE_NORMAL, shadow_type, gtk_widget_get_style(gtkMenubar)); + pmPainter.end(); + painter->drawPixmap(option->rect, pixmap, option->rect); + gtkPainter->reset(painter); + } + + QStyleOptionMenuItem item = *mbi; + bool act = mbi->state & State_Selected && mbi->state & State_Sunken; + bool dis = !(mbi->state & State_Enabled); + item.rect = mbi->rect; + GdkColor gdkText = style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL]; + GdkColor gdkHText = style->fg[GTK_STATE_PRELIGHT]; + QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8); + item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor); + item.palette.setBrush(QPalette::Text, normalTextColor); + item.palette.setBrush(QPalette::ButtonText, normalTextColor); + QCommonStyle::drawControl(element, &item, painter, widget); + + if (act) { + GtkShadowType shadowType = GTK_SHADOW_NONE; + gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL); + gtkPainter->paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3), + GTK_STATE_PRELIGHT, shadowType, style); + //draw text + QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; + uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; + + if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) + alignment |= Qt::TextHideMnemonic; + + proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole); + } + } + painter->restore(); + break; + + case CE_Splitter: { + GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed + gtkPainter->paintHandle(gtkWindow, "splitter", option->rect, qt_gtk_state(option), GTK_SHADOW_NONE, + !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, + style); + } + break; + +#ifndef QT_NO_TOOLBAR + + case CE_ToolBar: + if (const QStyleOptionToolBar *toolbar = qstyleoption_cast(option)) { + // Reserve the beveled appearance only for mainwindow toolbars + if (!(widget && qobject_cast (widget->parentWidget()))) + break; + + QRect rect = option->rect; + // There is a 1 pixel gap between toolbar lines in some styles (i.e Human) + if (toolbar->positionWithinLine != QStyleOptionToolBar::End) + rect.adjust(0, 0, 1, 0); + + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); + GtkShadowType shadow_type = GTK_SHADOW_NONE; + gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); + gtkPainter->paintBox(gtkToolbar, "toolbar", rect, + GTK_STATE_NORMAL, shadow_type, gtk_widget_get_style(gtkToolbar)); + } + break; + +#endif // QT_NO_TOOLBAR + + case CE_MenuItem: + painter->save(); + + // Draws one item in a popup menu. + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { + const int windowsItemHMargin = 3; // menu item hor text margin + const int windowsItemVMargin = 26; // menu item ver text margin + GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") : + d->gtkWidget("GtkMenu.GtkMenuItem"); + + style = gtk_widget_get_style(gtkMenuItem); + QColor shadow = option->palette.dark().color(); + + if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); + painter->setPen(shadow.lighter(106)); + gboolean wide_separators = 0; + gint separator_height = 0; + guint horizontal_padding = 3; + QRect separatorRect = option->rect; + if (!gtk_check_version(2, 10, 0)) { + gtk_widget_style_get(gtkMenuSeparator, + "wide-separators", &wide_separators, + "separator-height", &separator_height, + "horizontal-padding", &horizontal_padding, + NULL); + } + GtkStyle *gtkMenuSeparatorStyle = gtk_widget_get_style(gtkMenuSeparator); + separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparatorStyle->ythickness); + separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparatorStyle->xthickness)); + separatorRect.moveCenter(option->rect.center()); + if (wide_separators) + gtkPainter->paintBox(gtkMenuSeparator, "hseparator", + separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparatorStyle); + else + gtkPainter->paintHline(gtkMenuSeparator, "hseparator", + separatorRect, GTK_STATE_NORMAL, gtkMenuSeparatorStyle, + 0, option->rect.right() - 1, 1); + painter->restore(); + break; + } + + bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; + + if (selected) { + QRect rect = option->rect; +#ifndef QT_NO_COMBOBOX + if (qobject_cast(widget)) + rect = option->rect; +#endif + gtkPainter->paintBox(gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style); + } + + bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; + bool checked = menuItem->checked; + bool enabled = menuItem->state & State_Enabled; + bool ignoreCheckMark = false; + + gint checkSize; + gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL); + + int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize)); + +#ifndef QT_NO_COMBOBOX + + if (qobject_cast(widget) || + (option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool())) + ignoreCheckMark = true; // Ignore the checkmarks provided by the QComboMenuDelegate + +#endif + if (!ignoreCheckMark) { + // Check + QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize); + checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); + + if (checkable && menuItem->icon.isNull()) { + // Some themes such as aero-clone draw slightly outside the paint rect + int spacing = 1; // ### Consider using gtkCheckBox : "indicator-spacing" instead + + if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) { + // Radio button + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = qt_gtk_state(option); + + if (selected) + state = GTK_STATE_PRELIGHT; + if (checked) + shadow = GTK_SHADOW_IN; + + gtkPainter->setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing)); + gtkPainter->paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow, + style, QLS("option")); + gtkPainter->setClipRect(QRect()); + + } else { + // Check box + if (menuItem->icon.isNull()) { + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = qt_gtk_state(option); + + if (selected) + state = GTK_STATE_PRELIGHT; + if (checked) + shadow = GTK_SHADOW_IN; + + gtkPainter->setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing)); + gtkPainter->paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow, + style, QLS("check")); + gtkPainter->setClipRect(QRect()); + } + } + } + + } else { + // Ignore checkmark + if (menuItem->icon.isNull()) + checkcol = 0; + else + checkcol = menuItem->maxIconWidth; + } + + bool dis = !(menuItem->state & State_Enabled); + bool act = menuItem->state & State_Selected; + const QStyleOption *opt = option; + const QStyleOptionMenuItem *menuitem = menuItem; + QPainter *p = painter; + QRect vCheckRect = visualRect(opt->direction, menuitem->rect, + QRect(menuitem->rect.x() + 3, menuitem->rect.y(), + checkcol, menuitem->rect.height())); + + if (!menuItem->icon.isNull()) { + QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; + + if (act && !dis) + mode = QIcon::Active; + + QPixmap pixmap; + int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); + QSize iconSize(smallIconSize, smallIconSize); + +#ifndef QT_NO_COMBOBOX + if (const QComboBox *combo = qobject_cast(widget)) + iconSize = combo->iconSize(); + +#endif // QT_NO_COMBOBOX + if (checked) + pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); + else + pixmap = menuItem->icon.pixmap(iconSize, mode); + + const int pixw = pixmap.width() / pixmap.devicePixelRatio(); + const int pixh = pixmap.height() / pixmap.devicePixelRatio(); + QRect pmr(0, 0, pixw, pixh); + pmr.moveCenter(vCheckRect.center() - QPoint(0, 1)); + painter->setPen(menuItem->palette.text().color()); + if (!ignoreCheckMark && checkable && checked) { + QStyleOption opt = *option; + + if (act) { + QColor activeColor = mergedColors(option->palette.background().color(), + option->palette.highlight().color()); + opt.palette.setBrush(QPalette::Button, activeColor); + } + opt.state |= State_Sunken; + opt.rect = vCheckRect; + proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); + } + painter->drawPixmap(pmr.topLeft(), pixmap); + } + + GdkColor gdkText = style->fg[GTK_STATE_NORMAL]; + GdkColor gdkDText = style->fg[GTK_STATE_INSENSITIVE]; + GdkColor gdkHText = style->fg[GTK_STATE_PRELIGHT]; + uint resolve_mask = option->palette.resolve(); + QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8); + if (resolve_mask & (1 << QPalette::ButtonText)) { + textColor = option->palette.buttonText().color(); + disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color(); + } + + QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8); + if (resolve_mask & (1 << QPalette::HighlightedText)) { + highlightedTextColor = option->palette.highlightedText().color(); + } + + if (selected) + painter->setPen(highlightedTextColor); + else + painter->setPen(textColor); + + int x, y, w, h; + menuitem->rect.getRect(&x, &y, &w, &h); + int tab = menuitem->tabWidth; + int xm = QGtkStylePrivate::menuItemFrame + checkcol + windowsItemHMargin; + int xpos = menuitem->rect.x() + xm + 1; + QRect textRect(xpos, y + windowsItemVMargin, w - xm - QGtkStylePrivate::menuRightBorder - tab + 1, h - 2 * windowsItemVMargin); + QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); + QString s = menuitem->text; + + if (!s.isEmpty()) { // Draw text + p->save(); + int t = s.indexOf(QLatin1Char('\t')); + int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; + + if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) + text_flags |= Qt::TextHideMnemonic; + + // Draw shortcut right aligned + text_flags |= Qt::AlignRight; + + if (t >= 0) { + int rightMargin = 12; // Hardcode for now + QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, + QRect(textRect.topRight(), QPoint(menuitem->rect.right() - rightMargin, textRect.bottom()))); + + if (dis) + p->setPen(disabledTextColor); + p->drawText(vShortcutRect, text_flags , s.mid(t + 1)); + s = s.left(t); + } + + text_flags &= ~Qt::AlignRight; + text_flags |= Qt::AlignLeft; + QFont font = menuitem->font; + if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) + font.setBold(true); + p->setFont(font); + + if (dis) + p->setPen(disabledTextColor); + p->drawText(vTextRect, text_flags, s.left(t)); + p->restore(); + } + + // Arrow + if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow + + QFontMetrics fm(menuitem->font); + int arrow_size = fm.ascent() + fm.descent() - 2 * style->ythickness; + gfloat arrow_scaling = 0.8; + int extra = 0; + if (!gtk_check_version(2, 16, 0)) { + // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c) + // though the current documentation states otherwise + gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL); + // in versions < 2.16 ythickness was previously subtracted from the arrow_size + extra = 2 * style->ythickness; + } + + int horizontal_padding; + gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL); + + const int dim = static_cast(arrow_size * arrow_scaling) + extra; + int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim; + QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, + QRect(xpos, menuItem->rect.top() + + menuItem->rect.height() / 2 - dim / 2, dim, dim)); + GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE; + GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN; + gtkPainter->paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, option->direction == Qt::RightToLeft ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state, + shadowType, false, style); + } + } + painter->restore(); + break; + + case CE_PushButton: + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); + QStyleOptionButton subopt = *btn; + subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); + gint interiorFocus = true; + gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL); + GtkStyle *gtkButtonStyle = gtk_widget_get_style(gtkButton); + int xt = interiorFocus ? gtkButtonStyle->xthickness : 0; + int yt = interiorFocus ? gtkButtonStyle->ythickness : 0; + + if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus) + // The normal button focus rect does not work well for flat buttons in Clearlooks + proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget); + else if (btn->state & State_HasFocus) + gtkPainter->paintFocus(gtkButton, "button", + option->rect.adjusted(xt, yt, -xt, -yt), + btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, + gtkButtonStyle); + + proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget); + } + break; + +#ifndef QT_NO_TABBAR + + case CE_TabBarTabShape: + if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); + style = gtk_widget_get_style(gtkNotebook); + + QRect rect = option->rect; + GtkShadowType shadow = GTK_SHADOW_OUT; + GtkStateType state = GTK_STATE_ACTIVE; + if (tab->state & State_Selected) + state = GTK_STATE_NORMAL; + + bool selected = (tab->state & State_Selected); + bool first = false, last = false; + if (widget) { + // This is most accurate and avoids resizing tabs while moving + first = tab->rect.left() == widget->rect().left(); + last = tab->rect.right() == widget->rect().right(); + } else if (option->direction == Qt::RightToLeft) { + bool tmp = first; + first = last; + last = tmp; + } + int topIndent = 3; + int bottomIndent = 1; + int tabOverlap = 1; + painter->save(); + + switch (tab->shape) { + case QTabBar::RoundedNorth: + if (!selected) + rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent); + gtkPainter->paintExtention(gtkNotebook, "tab", rect, + state, shadow, GTK_POS_BOTTOM, style); + break; + + case QTabBar::RoundedSouth: + if (!selected) + rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent); + gtkPainter->paintExtention(gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0), + state, shadow, GTK_POS_TOP, style); + break; + + case QTabBar::RoundedWest: + if (!selected) + rect.adjust(topIndent, 0, -bottomIndent, 0); + gtkPainter->paintExtention(gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style); + break; + + case QTabBar::RoundedEast: + if (!selected) + rect.adjust(bottomIndent, 0, -topIndent, 0); + gtkPainter->paintExtention(gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style); + break; + + default: + QCommonStyle::drawControl(element, option, painter, widget); + break; + } + + painter->restore(); + } + + break; + +#endif //QT_NO_TABBAR + + case CE_ProgressBarGroove: + if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { + Q_UNUSED(bar); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); + GtkStateType state = qt_gtk_state(option); + gtkPainter->paintBox(gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtk_widget_get_style(gtkProgressBar)); + } + + break; + + case CE_ProgressBarContents: + if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { + GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE; + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); + style = gtk_widget_get_style(gtkProgressBar); + gtkPainter->paintBox(gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style); + int xt = style->xthickness; + int yt = style->ythickness; + QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt); + bool vertical = (bar->orientation == Qt::Vertical); + bool inverted = bar->invertedAppearance; + bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); + + // If the orientation is vertical, we use a transform to rotate + // the progress bar 90 degrees clockwise. This way we can use the + // same rendering code for both orientations. + if (vertical) { + rect.translate(xt, -yt * 2); + rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height + QTransform m = QTransform::fromTranslate(rect.height(), 0); + m.rotate(90.0); + painter->setTransform(m); + } + + int maxWidth = rect.width(); + int minWidth = 4; + + qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // Workaround for bug in QProgressBar + double vc6_workaround = ((progress - qint64(bar->minimum)) / double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth; + int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth; + int width = indeterminate ? maxWidth : progressBarWidth; + bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; + + if (inverted) + reverse = !reverse; + + int maximum = 2; + int fakePos = 0; + if (bar->minimum == bar->maximum) + maximum = 0; + if (bar->progress == bar->maximum) + fakePos = maximum; + else if (bar->progress > bar->minimum) + fakePos = maximum - 1; + + QRect progressBar; + + if (!indeterminate) { + if (!reverse) + progressBar.setRect(rect.left(), rect.top(), width, rect.height()); + else + progressBar.setRect(rect.right() - width, rect.top(), width, rect.height()); +#ifndef QT_NO_ANIMATION + d->stopAnimation(option->styleObject); +#endif + } else { + int slideWidth = ((rect.width() - 4) * 2) / 3; + int step = 0; +#ifndef QT_NO_ANIMATION + Q_D(const QGtkStyle); + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(option->styleObject))) + step = animation->progressStep(slideWidth); + else + d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject)); +#endif + progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height()); + } + + QString key = QString(QLS("%0")).arg(fakePos); + if (inverted) { + key += QLatin1String("inv"); + gtkPainter->setFlipHorizontal(true); + } + gtkPainter->paintBox(gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key); + } + + break; + + default: + QCommonStyle::drawControl(element, option, painter, widget); + } +} + +/*! + \reimp +*/ +QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, + SubControl subControl, const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget); + if (!d->isThemeAvailable()) + return QCommonStyle::subControlRect(control, option, subControl, widget); + + switch (control) { + case CC_ScrollBar: + break; + case CC_Slider: + if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + switch (subControl) { + case SC_SliderHandle: { + if (slider->orientation == Qt::Horizontal) { + rect.setHeight(proxy()->pixelMetric(PM_SliderThickness)); + rect.setWidth(proxy()->pixelMetric(PM_SliderLength)); + int centerY = slider->rect.center().y() - rect.height() / 2; + if (slider->tickPosition & QSlider::TicksAbove) + centerY += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + centerY -= tickSize; + rect.moveTop(centerY); + } else { + rect.setWidth(proxy()->pixelMetric(PM_SliderThickness)); + rect.setHeight(proxy()->pixelMetric(PM_SliderLength)); + int centerX = slider->rect.center().x() - rect.width() / 2; + if (slider->tickPosition & QSlider::TicksAbove) + centerX += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + centerX -= tickSize; + rect.moveLeft(centerX); + } + } + break; + case SC_SliderGroove: { + QPoint grooveCenter = slider->rect.center(); + if (slider->orientation == Qt::Horizontal) { + rect.setHeight(7); + if (slider->tickPosition & QSlider::TicksAbove) + grooveCenter.ry() += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + grooveCenter.ry() -= tickSize; + } else { + rect.setWidth(7); + if (slider->tickPosition & QSlider::TicksAbove) + grooveCenter.rx() += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + grooveCenter.rx() -= tickSize; + } + rect.moveCenter(grooveCenter); + break; + } + default: + break; + } + } + break; + +#ifndef QT_NO_GROUPBOX + + case CC_GroupBox: + if (const QStyleOptionGroupBox * groupBox = qstyleoption_cast(option)) { + rect = option->rect.adjusted(0, groupBoxTopMargin, 0, -groupBoxBottomMargin); + int topMargin = 0; + int topHeight = 0; + topHeight = 10; + QRect frameRect = rect; + frameRect.setTop(topMargin); + + if (subControl == SC_GroupBoxFrame) + return rect; + else if (subControl == SC_GroupBoxContents) { + int margin = 0; + int leftMarginExtension = 8; + return frameRect.adjusted(leftMarginExtension + margin, margin + topHeight + groupBoxTitleMargin, -margin, -margin); + } + + QFontMetrics fontMetrics = option->fontMetrics; + if (qobject_cast(widget)) { + //Prepare metrics for a bold font + QFont font = widget->font(); + font.setBold(true); + fontMetrics = QFontMetrics(font); + } else if (QStyleHelper::isInstanceOf(groupBox->styleObject, QAccessible::Grouping)) { + QVariant var = groupBox->styleObject->property("font"); + if (var.isValid() && var.canConvert()) { + QFont font = var.value(); + font.setBold(true); + fontMetrics = QFontMetrics(font); + } + } + + QSize textRect = fontMetrics.boundingRect(groupBox->text).size() + QSize(4, 4); + int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); + int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); + + if (subControl == SC_GroupBoxCheckBox) { + rect.setWidth(indicatorWidth); + rect.setHeight(indicatorHeight); + rect.moveTop((textRect.height() - indicatorHeight) / 2); + + } else if (subControl == SC_GroupBoxLabel) { + if (groupBox->subControls & SC_GroupBoxCheckBox) + rect.adjust(indicatorWidth + 4, 0, 0, 0); + rect.setSize(textRect); + } + rect = visualRect(option->direction, option->rect, rect); + } + + return rect; + +#endif +#ifndef QT_NO_SPINBOX + + case CC_SpinBox: + if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { + GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton"); + int center = spinbox->rect.height() / 2; + GtkStyle *gtkSpinButtonStyle = gtk_widget_get_style(gtkSpinButton); + int xt = spinbox->frame ? gtkSpinButtonStyle->xthickness : 0; + int yt = spinbox->frame ? gtkSpinButtonStyle->ythickness : 0; + int y = yt; + + QSize bs; + bs.setHeight(qMax(8, spinbox->rect.height()/2 - y)); + bs.setWidth(d->getSpinboxArrowSize()); + int x, lx, rx; + x = spinbox->rect.width() - y - bs.width() + 2; + lx = xt; + rx = x - xt; + + switch (subControl) { + + case SC_SpinBoxUp: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + return QRect(); + rect = QRect(x, xt, bs.width(), center - yt); + break; + + case SC_SpinBoxDown: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + return QRect(); + rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - yt + 1); + break; + + case SC_SpinBoxEditField: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + rect = QRect(lx, yt, spinbox->rect.width() - 2*xt, spinbox->rect.height() - 2*yt); + else + rect = QRect(lx, yt, rx - qMax(xt - 1, 0), spinbox->rect.height() - 2*yt); + break; + + case SC_SpinBoxFrame: + rect = spinbox->rect; + + default: + break; + } + + rect = visualRect(spinbox->direction, spinbox->rect, rect); + } + + break; + +#endif // Qt_NO_SPINBOX +#ifndef QT_NO_COMBOBOX + + case CC_TitleBar: + if (const QStyleOptionTitleBar *tb = qstyleoption_cast(option)) { + SubControl sc = subControl; + QRect &ret = rect; + const int indent = 3; + const int controlTopMargin = 3; + const int controlBottomMargin = 3; + const int controlWidthMargin = 2; + const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ; + const int delta = controlHeight + controlWidthMargin; + int offset = 0; + + bool isMinimized = tb->titleBarState & Qt::WindowMinimized; + bool isMaximized = tb->titleBarState & Qt::WindowMaximized; + + switch (sc) { + case SC_TitleBarLabel: + if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) { + ret = tb->rect; + if (tb->titleBarFlags & Qt::WindowSystemMenuHint) + ret.adjust(delta, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) + ret.adjust(0, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) + ret.adjust(0, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowShadeButtonHint) + ret.adjust(0, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) + ret.adjust(0, 0, -delta, 0); + } + break; + case SC_TitleBarContextHelpButton: + if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) + offset += delta; + case SC_TitleBarMinButton: + if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarMinButton) + break; + case SC_TitleBarNormalButton: + if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) + offset += delta; + else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarNormalButton) + break; + case SC_TitleBarMaxButton: + if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarMaxButton) + break; + case SC_TitleBarShadeButton: + if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarShadeButton) + break; + case SC_TitleBarUnshadeButton: + if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarUnshadeButton) + break; + case SC_TitleBarCloseButton: + if (tb->titleBarFlags & Qt::WindowSystemMenuHint) + offset += delta; + else if (sc == SC_TitleBarCloseButton) + break; + ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin, + controlHeight, controlHeight); + break; + case SC_TitleBarSysMenu: + if (tb->titleBarFlags & Qt::WindowSystemMenuHint) { + ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin, + controlHeight, controlHeight); + } + break; + default: + break; + } + ret = visualRect(tb->direction, tb->rect, ret); + } + break; + case CC_ComboBox: + if (const QStyleOptionComboBox *box = qstyleoption_cast(option)) { + // We employ the gtk widget to position arrows and separators for us + GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry") + : d->gtkWidget("GtkComboBox"); + gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())}; + gtk_widget_size_allocate(gtkCombo, &geometry); + int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget); + QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton"); + if (!box->editable) { + if (appears_as_list) + arrowPath = "GtkComboBox.GtkToggleButton"; + else + arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"; + } + + GtkWidget *arrowWidget = d->gtkWidget(arrowPath); + if (!arrowWidget) + return QCommonStyle::subControlRect(control, option, subControl, widget); + + GtkAllocation allocation; + gtk_widget_get_allocation(arrowWidget, &allocation); + QRect buttonRect(option->rect.left() + allocation.x, + option->rect.top() + allocation.y, + allocation.width, allocation.height); + + switch (subControl) { + + case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos + rect = buttonRect; + break; + + case SC_ComboBoxEditField: { + rect = visualRect(option->direction, option->rect, rect); + int xMargin = box->editable ? 1 : 4, yMargin = 2; + GtkStyle *gtkComboStyle = gtk_widget_get_style(gtkCombo); + rect.setRect(option->rect.left() + gtkComboStyle->xthickness + xMargin, + option->rect.top() + gtkComboStyle->ythickness + yMargin, + option->rect.width() - buttonRect.width() - 2*(gtkComboStyle->xthickness + xMargin), + option->rect.height() - 2*(gtkComboStyle->ythickness + yMargin)); + rect = visualRect(option->direction, option->rect, rect); + break; + } + + default: + break; + } + } + + break; +#endif // QT_NO_COMBOBOX + + default: + break; + } + + return rect; +} + +/*! + \reimp +*/ +QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &size, const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + QSize newSize = QCommonStyle::sizeFromContents(type, option, size, widget); + if (!d->isThemeAvailable()) + return newSize; + + switch (type) { + case CT_GroupBox: + // Since we use a bold font we have to recalculate base width + if (const QGroupBox *gb = qobject_cast(widget)) { + QFont font = gb->font(); + font.setBold(true); + QFontMetrics metrics(font); + int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' ')); + if (gb->isCheckable()) { + baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget); + baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget); + } + newSize.setWidth(qMax(baseWidth, newSize.width())); + } + newSize += QSize(4, 1 + groupBoxBottomMargin + groupBoxTopMargin + groupBoxTitleMargin); // Add some space below the groupbox + break; + case CT_ToolButton: + if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast(option)) { + GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton"); + GtkStyle *gtkButtonStyle = gtk_widget_get_style(gtkButton); + newSize = size + QSize(2 * gtkButtonStyle->xthickness, 2 + 2 * gtkButtonStyle->ythickness); + if (widget && qobject_cast(widget->parentWidget())) { + QSize minSize(0, 25); + if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly) + minSize = toolbutton->iconSize + QSize(12, 12); + newSize = newSize.expandedTo(minSize); + } + + if (toolbutton->features & QStyleOptionToolButton::HasMenu) + newSize += QSize(6, 0); + } + break; + case CT_SpinBox: + // QSpinBox does some nasty things that depends on CT_LineEdit + newSize = newSize + QSize(0, -gtk_widget_get_style(d->gtkWidget("GtkSpinButton"))->ythickness * 2); + break; + case CT_RadioButton: + case CT_CheckBox: + newSize += QSize(0, 1); + break; + case CT_PushButton: + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { + if (!btn->icon.isNull() && btn->iconSize.height() > 16) + newSize -= QSize(0, 2); // From cleanlooksstyle + newSize += QSize(0, 1); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + gint focusPadding, focusWidth; + gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL); + gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL); + newSize = size; + GtkStyle *gtkButtonStyle = gtk_widget_get_style(gtkButton); + newSize += QSize(2*gtkButtonStyle->xthickness + 4, 2*gtkButtonStyle->ythickness); + newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding)); + + GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox"); + gint minWidth = 85, minHeight = 0; + gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth, + "child-min-height", &minHeight, NULL); + if (!btn->text.isEmpty() && newSize.width() < minWidth) + newSize.setWidth(minWidth); + if (newSize.height() < minHeight) + newSize.setHeight(minHeight); + } + break; + case CT_Slider: { + GtkWidget *gtkSlider = d->gtkWidget("GtkHScale"); + GtkStyle *gtkSliderStyle = gtk_widget_get_style(gtkSlider); + newSize = size + QSize(2*gtkSliderStyle->xthickness, 2*gtkSliderStyle->ythickness); } + break; + case CT_LineEdit: { + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); + GtkStyle *gtkEntryStyle = gtk_widget_get_style(gtkEntry); + newSize = size + QSize(2*gtkEntryStyle->xthickness, 2 + 2*gtkEntryStyle->ythickness); } + break; + case CT_ItemViewItem: + newSize += QSize(0, 2); + break; + case CT_ComboBox: + if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) { + GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox"); + QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget); + GtkStyle *gtkComboStyle = gtk_widget_get_style(gtkCombo); + newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkComboStyle->xthickness, 4 + 2*gtkComboStyle->ythickness); + + if (!(widget && qobject_cast(widget->parentWidget()))) + newSize += QSize(0, 2); + } + break; + case CT_TabBarTab: + if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { + if (!tab->icon.isNull()) + newSize += QSize(6, 0); + } + newSize += QSize(1, 1); + break; + case CT_MenuBarItem: + newSize += QSize(QGtkStylePrivate::menuItemHMargin * 4, QGtkStylePrivate::menuItemVMargin * 2 + 2); + break; + case CT_SizeGrip: + newSize += QSize(4, 4); + break; + case CT_MdiControls: + if (const QStyleOptionComplex *styleOpt = qstyleoption_cast(option)) { + int width = 0; + if (styleOpt->subControls & SC_MdiMinButton) + width += 19 + 1; + if (styleOpt->subControls & SC_MdiNormalButton) + width += 19 + 1; + if (styleOpt->subControls & SC_MdiCloseButton) + width += 19 + 1; + newSize = QSize(width, 19); + } else { + newSize = QSize(60, 19); + } + break; + case CT_MenuItem: + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { + int w = newSize.width(); + int maxpmw = menuItem->maxIconWidth; + int tabSpacing = 20; + if (menuItem->text.contains(QLatin1Char('\t'))) + w += tabSpacing; + else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) + w += 2 * QGtkStylePrivate::menuArrowHMargin; + else if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) { + // adjust the font and add the difference in size. + // it would be better if the font could be adjusted in the initStyleOption qmenu func!! + QFontMetrics fm(menuItem->font); + QFont fontBold = menuItem->font; + fontBold.setBold(true); + QFontMetrics fmBold(fontBold); + w += fmBold.width(menuItem->text) - fm.width(menuItem->text); + } + + int checkcol = qMax(maxpmw, QGtkStylePrivate::menuCheckMarkWidth); // Windows always shows a check column + w += checkcol; + w += int(QGtkStylePrivate::menuRightBorder) + 10; + + newSize.setWidth(w); + + int textMargin = 8; + if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); + GtkRequisition sizeReq = {0, 0}; + gtk_widget_size_request(gtkMenuSeparator, &sizeReq); + newSize = QSize(newSize.width(), sizeReq.height); + break; + } + + GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem"); + GtkStyle* style = gtk_widget_get_style(gtkMenuItem); + + // Note we get the perfect height for the default font since we + // set a fake text label on the gtkMenuItem + // But if custom fonts are used on the widget we need a minimum size + GtkRequisition sizeReq = {0, 0}; + gtk_widget_size_request(gtkMenuItem, &sizeReq); + newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); + newSize += QSize(textMargin + style->xthickness - 1, 0); + + gint checkSize; + gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); + newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); + } + break; + default: + break; + } + + return newSize; +} + + +/*! \reimp */ +QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, + const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) + return QCommonStyle::standardPixmap(sp, option, widget); + + QPixmap pixmap; + switch (sp) { + + case SP_TitleBarNormalButton: { + QImage restoreButton(dock_widget_restore_xpm); + QColor alphaCorner = restoreButton.color(2); + alphaCorner.setAlpha(80); + restoreButton.setColor(2, alphaCorner.rgba()); + alphaCorner.setAlpha(180); + restoreButton.setColor(4, alphaCorner.rgba()); + return QPixmap::fromImage(restoreButton); + } + break; + + case SP_TitleBarCloseButton: // Fall through + case SP_DockWidgetCloseButton: { + + QImage closeButton(dock_widget_close_xpm); + QColor alphaCorner = closeButton.color(2); + alphaCorner.setAlpha(80); + closeButton.setColor(2, alphaCorner.rgba()); + return QPixmap::fromImage(closeButton); + } + break; + + case SP_DialogDiscardButton: + return qt_gtk_get_icon(GTK_STOCK_DELETE); + case SP_DialogOkButton: + return qt_gtk_get_icon(GTK_STOCK_OK); + case SP_DialogCancelButton: + return qt_gtk_get_icon(GTK_STOCK_CANCEL); + case SP_DialogYesButton: + return qt_gtk_get_icon(GTK_STOCK_YES); + case SP_DialogNoButton: + return qt_gtk_get_icon(GTK_STOCK_NO); + case SP_DialogOpenButton: + return qt_gtk_get_icon(GTK_STOCK_OPEN); + case SP_DialogCloseButton: + return qt_gtk_get_icon(GTK_STOCK_CLOSE); + case SP_DialogApplyButton: + return qt_gtk_get_icon(GTK_STOCK_APPLY); + case SP_DialogSaveButton: + return qt_gtk_get_icon(GTK_STOCK_SAVE); + case SP_MessageBoxWarning: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); + case SP_MessageBoxQuestion: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); + case SP_MessageBoxInformation: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); + case SP_MessageBoxCritical: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); + default: + return QCommonStyle::standardPixmap(sp, option, widget); + } + return pixmap; +} + +/*! + \reimp +*/ +QIcon QGtkStyle::standardIcon(StandardPixmap standardIcon, + const QStyleOption *option, + const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + if (!d->isThemeAvailable()) + return QCommonStyle::standardIcon(standardIcon, option, widget); + switch (standardIcon) { + case SP_DialogDiscardButton: + return qt_gtk_get_icon(GTK_STOCK_DELETE); + case SP_DialogOkButton: + return qt_gtk_get_icon(GTK_STOCK_OK); + case SP_DialogCancelButton: + return qt_gtk_get_icon(GTK_STOCK_CANCEL); + case SP_DialogYesButton: + return qt_gtk_get_icon(GTK_STOCK_YES); + case SP_DialogNoButton: + return qt_gtk_get_icon(GTK_STOCK_NO); + case SP_DialogOpenButton: + return qt_gtk_get_icon(GTK_STOCK_OPEN); + case SP_DialogCloseButton: + return qt_gtk_get_icon(GTK_STOCK_CLOSE); + case SP_DialogApplyButton: + return qt_gtk_get_icon(GTK_STOCK_APPLY); + case SP_DialogSaveButton: + return qt_gtk_get_icon(GTK_STOCK_SAVE); + case SP_MessageBoxWarning: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); + case SP_MessageBoxQuestion: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); + case SP_MessageBoxInformation: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); + case SP_MessageBoxCritical: + return qt_gtk_get_icon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); + default: + return QCommonStyle::standardIcon(standardIcon, option, widget); + } +} + + +/*! \reimp */ +QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const +{ + Q_D(const QGtkStyle); + + QRect r = QCommonStyle::subElementRect(element, option, widget); + if (!d->isThemeAvailable()) + return r; + + switch (element) { + case SE_PushButtonFocusRect: + r.adjust(0, 1, 0, -1); + break; + case SE_DockWidgetTitleBarText: { + const QStyleOptionDockWidget *dwOpt + = qstyleoption_cast(option); + bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar; + if (verticalTitleBar) { + r.adjust(0, 0, 0, -4); + } else { + if (option->direction == Qt::LeftToRight) + r.adjust(4, 0, 0, 0); + else + r.adjust(0, 0, -4, 0); + } + + break; + } + case SE_ProgressBarLabel: + case SE_ProgressBarContents: + case SE_ProgressBarGroove: + return option->rect; + case SE_PushButtonContents: + if (!gtk_check_version(2, 10, 0)) { + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); + GtkBorder *border = 0; + gtk_widget_style_get(gtkButton, "inner-border", &border, NULL); + if (border) { + r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom); + gtk_border_free(border); + } else { + r = option->rect.adjusted(1, 1, -1, -1); + } + r = visualRect(option->direction, option->rect, r); + } + break; + default: + break; + } + + return r; +} + +/*! + \reimp +*/ +QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const +{ + return QCommonStyle::itemPixmapRect(r, flags, pixmap); +} + +/*! + \reimp +*/ +void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect, + int alignment, const QPixmap &pixmap) const +{ + QCommonStyle::drawItemPixmap(painter, rect, alignment, pixmap); +} + +/*! + \reimp +*/ +QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, + const QPoint &pt, const QWidget *w) const +{ + return QCommonStyle::hitTestComplexControl(cc, opt, pt, w); +} + +/*! + \reimp +*/ +QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, + const QStyleOption *opt) const +{ + return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt); +} + +/*! + \reimp +*/ +void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, + bool enabled, const QString& text, QPalette::ColorRole textRole) const +{ + return QCommonStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole); +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle_p.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle_p.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle_p.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle_p.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,601 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgtkstyle_p_p.h" + +// This file is responsible for resolving all GTK functions we use +// dynamically. This is done to avoid link-time dependency on GTK +// as well as crashes occurring due to usage of the GTK_QT engines +// +// Additionally we create a map of common GTK widgets that we can pass +// to the GTK theme engine as many engines resort to querying the +// actual widget pointers for details that are not covered by the +// state flags + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "qgtk2painter_p.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// X11 Includes: + +// the following is necessary to work around breakage in many versions +// of XFree86's Xlib.h still in use +// ### which versions? +#if defined(_XLIB_H_) // crude hack, but... +#error "cannot include before this file" +#endif +#define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback +#define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback +#define XSetIMValues qt_XSetIMValues +#include +#undef XRegisterIMInstantiateCallback +#undef XUnregisterIMInstantiateCallback +#undef XSetIMValues + +QT_BEGIN_NAMESPACE + +Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler) + +Ptr_ubuntu_gtk_set_use_overlay_scrollbar QGtkStylePrivate::ubuntu_gtk_set_use_overlay_scrollbar = 0; + +typedef int (*x11ErrorHandler)(Display*, XErrorEvent*); + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QGtkStylePrivate*); + +QT_BEGIN_NAMESPACE + +static void gtkStyleSetCallback(GtkWidget*) +{ + qRegisterMetaType(); + + // We have to let this function return and complete the event + // loop to ensure that all gtk widgets have been styled before + // updating + QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection); +} + +static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer) +{ + GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; + g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL); + QWidgetList widgets = QApplication::allWidgets(); + for (int i = 0; i < widgets.size(); ++i) { + QWidget *widget = widgets.at(i); + if (qobject_cast(widget)) { + QEvent event(QEvent::StyleChange); + QApplication::sendEvent(widget, &event); + } + } +} + +static QHashableLatin1Literal classPath(GtkWidget *widget) +{ + char *class_path; + gtk_widget_path (widget, NULL, &class_path, NULL); + + char *copy = class_path; + if (strncmp(copy, "GtkWindow.", 10) == 0) + copy += 10; + if (strncmp(copy, "GtkFixed.", 9) == 0) + copy += 9; + + copy = strdup(copy); + + g_free(class_path); + + return QHashableLatin1Literal::fromData(copy); +} + + + +bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e) +{ + if (e->type() == QEvent::ApplicationPaletteChange) { + // Only do this the first time since this will also + // generate applicationPaletteChange events + //if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) { + // stylePrivate->applyCustomPaletteHash(); + //} + } + return QObject::eventFilter(obj, e); +} + +QList QGtkStylePrivate::instances; +QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0; + +QGtkStylePrivate::QGtkStylePrivate() + : QCommonStylePrivate() + , filter(this) +{ + instances.append(this); + animationFps = 60; +} + +QGtkStylePrivate::~QGtkStylePrivate() +{ + instances.removeOne(this); +} + +void QGtkStylePrivate::init() +{ + initGtkWidgets(); +} + +QGtkPainter* QGtkStylePrivate::gtkPainter(QPainter *painter) +{ + // TODO: choose between gtk2 and gtk3 + static QGtk2Painter instance; + instance.reset(painter); + return &instance; +} + +GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path) +{ + GtkWidget *widget = gtkWidgetMap()->value(path); + if (!widget) { + // Theme might have rearranged widget internals + widget = gtkWidgetMap()->value(path); + } + return widget; +} + +GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path) +{ + if (GtkWidget *w = gtkWidgetMap()->value(path)) + return gtk_widget_get_style(w); + return 0; +} + +void QGtkStylePrivate::gtkWidgetSetFocus(GtkWidget *widget, bool focus) +{ + GdkEvent *event = gdk_event_new(GDK_FOCUS_CHANGE); + event->focus_change.type = GDK_FOCUS_CHANGE; + event->focus_change.in = focus; + gtk_widget_send_focus_change(widget, event); + gdk_event_free(event); +} + +/* \internal + * Initializes a number of gtk menu widgets. + * The widgets are cached. + */ +void QGtkStylePrivate::initGtkMenu() const +{ + // Create menubar + GtkWidget *gtkMenuBar = gtk_menu_bar_new(); + setupGtkWidget(gtkMenuBar); + + GtkWidget *gtkMenuBarItem = gtk_menu_item_new_with_label("X"); + gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem); + gtk_widget_realize(gtkMenuBarItem); + + // Create menu + GtkWidget *gtkMenu = gtk_menu_new(); + gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu); + gtk_widget_realize(gtkMenu); + + GtkWidget *gtkMenuItem = gtk_menu_item_new_with_label("X"); + gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem); + gtk_widget_realize(gtkMenuItem); + + GtkWidget *gtkCheckMenuItem = gtk_check_menu_item_new_with_label("X"); + gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem); + gtk_widget_realize(gtkCheckMenuItem); + + GtkWidget *gtkMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator); + + addAllSubWidgets(gtkMenuBar); + addAllSubWidgets(gtkMenu); +} + + +void QGtkStylePrivate::initGtkTreeview() const +{ + GtkWidget *gtkTreeView = gtk_tree_view_new(); + gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new()); + gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new()); + gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new()); + addWidget(gtkTreeView); +} + + +/* \internal + * Initializes a number of gtk widgets that we can later on use to determine some of our styles. + * The widgets are cached. + */ +void QGtkStylePrivate::initGtkWidgets() const +{ + // From gtkmain.c + uid_t ruid = getuid (); + uid_t rgid = getgid (); + uid_t euid = geteuid (); + uid_t egid = getegid (); + if (ruid != euid || rgid != egid) { + qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this " + "therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', " + "\'kdesudo\' or a similar tool.\n\n" + "See http://www.gtk.org/setuid.html for more information.\n"); + return; + } + + // Gtk will set the Qt error handler so we have to reset it afterwards + x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0); + gtk_init (NULL, NULL); + XSetErrorHandler(qt_x_errhandler); + + ubuntu_gtk_set_use_overlay_scrollbar = (Ptr_ubuntu_gtk_set_use_overlay_scrollbar)QLibrary::resolve(QLS("gtk-x11-2.0"), "ubuntu_gtk_set_use_overlay_scrollbar"); + if (ubuntu_gtk_set_use_overlay_scrollbar) + ubuntu_gtk_set_use_overlay_scrollbar(false); + + // make a window + GtkWidget* gtkWindow = gtk_window_new(GTK_WINDOW_POPUP); + gtk_widget_realize(gtkWindow); + QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow")); + removeWidgetFromMap(widgetPath); + gtkWidgetMap()->insert(widgetPath, gtkWindow); + + + // Make all other widgets. respect the text direction + if (qApp->layoutDirection() == Qt::RightToLeft) + gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); + + if (!gtkWidgetMap()->contains("GtkButton")) { + GtkWidget *gtkButton = gtk_button_new(); + addWidget(gtkButton); + g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0); + addWidget(GTK_WIDGET(gtk_tool_button_new(NULL, "Qt"))); + addWidget(GTK_WIDGET(gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE))); + addWidget(GTK_WIDGET(gtk_hbutton_box_new())); + addWidget(GTK_WIDGET(gtk_check_button_new())); + addWidget(GTK_WIDGET(gtk_radio_button_new(NULL))); + addWidget(GTK_WIDGET(gtk_combo_box_new())); + addWidget(GTK_WIDGET(gtk_combo_box_entry_new())); + GtkWidget *entry = gtk_entry_new(); + // gtk-im-context-none is supported in gtk+ since 2.19.5 + // and also exists in gtk3 + // http://git.gnome.org/browse/gtk+/tree/gtk/gtkimmulticontext.c?id=2.19.5#n33 + // reason that we don't use gtk-im-context-simple here is, + // gtk-im-context-none has less overhead, and 2.19.5 is + // relatively old. and even for older gtk+, it will fallback + // to gtk-im-context-simple if gtk-im-context-none doesn't + // exists. + g_object_set(entry, "im-module", "gtk-im-context-none", NULL); + addWidget(entry); + addWidget(gtk_frame_new(NULL)); + addWidget(gtk_expander_new("")); + addWidget(gtk_statusbar_new()); + addWidget(gtk_hscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(1, 0, 1, 0, 0, 0)))); + addWidget(gtk_hscrollbar_new(NULL)); + addWidget(gtk_scrolled_window_new(NULL, NULL)); + + initGtkMenu(); + addWidget(gtk_notebook_new()); + addWidget(gtk_progress_bar_new()); + addWidget(gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3)); + GtkWidget *toolbar = gtk_toolbar_new(); + g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar); + gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1); + addWidget(toolbar); + initGtkTreeview(); + addWidget(gtk_vscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(1, 0, 1, 0, 0, 0)))); + addWidget(gtk_vscrollbar_new(NULL)); + } + else // Rebuild map + { + // When styles change subwidgets can get rearranged + // as with the combo box. We need to update the widget map + // to reflect this; + QHash oldMap = *gtkWidgetMap(); + gtkWidgetMap()->clear(); + QHashIterator it(oldMap); + while (it.hasNext()) { + it.next(); + if (!strchr(it.key().data(), '.')) { + addAllSubWidgets(it.value()); + } + free(const_cast(it.key().data())); + } + } +} + +/*! \internal + * destroys all previously buffered widgets. + */ +void QGtkStylePrivate::cleanupGtkWidgets() +{ + if (!widgetMap) + return; + if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children + gtk_widget_destroy(widgetMap->value("GtkWindow")); + for (QHash::const_iterator it = widgetMap->constBegin(); + it != widgetMap->constEnd(); ++it) + free(const_cast(it.key().data())); +} + +QString QGtkStylePrivate::getThemeName() +{ + QString themeName; + // Read the theme name from GtkSettings + GtkSettings *settings = gtk_settings_get_default(); + gchararray value; + g_object_get(settings, "gtk-theme-name", &value, NULL); + themeName = QString::fromUtf8(value); + g_free(value); + return themeName; +} + +// Get size of the arrow controls in a GtkSpinButton +int QGtkStylePrivate::getSpinboxArrowSize() const +{ + const int MIN_ARROW_WIDTH = 6; + GtkWidget *spinButton = gtkWidget("GtkSpinButton"); + GtkStyle *style = gtk_widget_get_style(spinButton); + gint size = pango_font_description_get_size (style->font_desc); + gint arrow_size; + arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness; + arrow_size += arrow_size%2 + 1; + return arrow_size; +} + + +bool QGtkStylePrivate::isKDE4Session() +{ + static int version = -1; + if (version == -1) + version = qgetenv("KDE_SESSION_VERSION").toInt(); + return (version == 4); +} + +void QGtkStylePrivate::applyCustomPaletteHash() +{ + QPalette menuPal = gtkWidgetPalette("GtkMenu"); + GdkColor gdkBg = gtk_widget_get_style(gtkWidget("GtkMenu"))->bg[GTK_STATE_NORMAL]; + QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); + menuPal.setBrush(QPalette::Base, bgColor); + menuPal.setBrush(QPalette::Window, bgColor); + qApp->setPalette(menuPal, "QMenu"); + + QPalette toolbarPal = gtkWidgetPalette("GtkToolbar"); + qApp->setPalette(toolbarPal, "QToolBar"); + + QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar"); + qApp->setPalette(menuBarPal, "QMenuBar"); +} + +/*! \internal + * Returns the gtk Widget that should be used to determine text foreground and background colors. +*/ +GtkWidget* QGtkStylePrivate::getTextColorWidget() const +{ + return gtkWidget("GtkEntry"); +} + +void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget) +{ + if (GTK_IS_WIDGET(widget)) { + GtkWidget *protoLayout = gtkWidgetMap()->value("GtkContainer"); + if (!protoLayout) { + protoLayout = gtk_fixed_new(); + gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout); + QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkContainer")); + gtkWidgetMap()->insert(widgetPath, protoLayout); + } + Q_ASSERT(protoLayout); + + if (!gtk_widget_get_parent(widget) && !gtk_widget_is_toplevel(widget)) + gtk_container_add((GtkContainer*)(protoLayout), widget); + gtk_widget_realize(widget); + } +} + +void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path) +{ + WidgetMap *map = gtkWidgetMap(); + WidgetMap::iterator it = map->find(path); + if (it != map->end()) { + char* keyData = const_cast(it.key().data()); + map->erase(it); + free(keyData); + } +} + +void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget) +{ + if (GTK_IS_WIDGET(widget)) { + gtk_widget_realize(widget); + QHashableLatin1Literal widgetPath = classPath(widget); + + removeWidgetFromMap(widgetPath); + gtkWidgetMap()->insert(widgetPath, widget); +#ifdef DUMP_GTK_WIDGET_TREE + qWarning("Inserted Gtk Widget: %s", widgetPath.data()); +#endif + } + } + +void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v) +{ + Q_UNUSED(v); + addWidgetToMap(widget); + if (G_TYPE_CHECK_INSTANCE_TYPE ((widget), gtk_container_get_type())) + gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL); +} + +// Updates window/windowtext palette based on the indicated gtk widget +QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal >kWidgetName) const +{ + GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName); + Q_ASSERT(gtkWidget); + QPalette pal = QApplication::palette(); + GdkColor gdkBg = gtk_widget_get_style(gtkWidget)->bg[GTK_STATE_NORMAL]; + GdkColor gdkText = gtk_widget_get_style(gtkWidget)->fg[GTK_STATE_NORMAL]; + GdkColor gdkDisabledText = gtk_widget_get_style(gtkWidget)->fg[GTK_STATE_INSENSITIVE]; + QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); + QColor textColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); + QColor disabledTextColor(gdkDisabledText.red>>8, gdkDisabledText.green>>8, gdkDisabledText.blue>>8); + pal.setBrush(QPalette::Window, bgColor); + pal.setBrush(QPalette::Button, bgColor); + pal.setBrush(QPalette::All, QPalette::WindowText, textColor); + pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor); + pal.setBrush(QPalette::All, QPalette::ButtonText, textColor); + pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor); + return pal; +} + + +void QGtkStyleUpdateScheduler::updateTheme() +{ + static QString oldTheme(QLS("qt_not_set")); + QPixmapCache::clear(); + + QFont font = QGtkStylePrivate::getThemeFont(); + if (QApplication::font() != font) + qApp->setFont(font); + + if (oldTheme != QGtkStylePrivate::getThemeName()) { + oldTheme = QGtkStylePrivate::getThemeName(); + QPalette newPalette = qApp->style()->standardPalette(); + QApplicationPrivate::setSystemPalette(newPalette); + QApplication::setPalette(newPalette); + if (!QGtkStylePrivate::instances.isEmpty()) { + QGtkStylePrivate::instances.last()->initGtkWidgets(); + QGtkStylePrivate::instances.last()->applyCustomPaletteHash(); + } + QList widgets = QApplication::allWidgets(); + // Notify all widgets that size metrics might have changed + foreach (QWidget *widget, widgets) { + QEvent e(QEvent::StyleChange); + QApplication::sendEvent(widget, &e); + } + } + QIconLoader::instance()->updateSystemTheme(); +} + +void QGtkStylePrivate::addWidget(GtkWidget *widget) +{ + if (widget) { + setupGtkWidget(widget); + addAllSubWidgets(widget); + } +} + + +// Fetch the application font from the pango font description +// contained in the theme. +QFont QGtkStylePrivate::getThemeFont() +{ + QFont font; + GtkStyle *style = gtkStyle(); + if (style && qApp->desktopSettingsAware()) + { + PangoFontDescription *gtk_font = style->font_desc; + font.setPointSizeF((float)(pango_font_description_get_size(gtk_font))/PANGO_SCALE); + + QString family = QString::fromLatin1(pango_font_description_get_family(gtk_font)); + if (!family.isEmpty()) + font.setFamily(family); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) + const int weight = pango_font_description_get_weight(gtk_font); + font.setWeight(QPlatformFontDatabase::weightFromInteger(weight)); +#else + int weight = pango_font_description_get_weight(gtk_font); + if (weight >= PANGO_WEIGHT_HEAVY) + font.setWeight(QFont::Black); + else if (weight >= PANGO_WEIGHT_BOLD) + font.setWeight(QFont::Bold); + else if (weight >= PANGO_WEIGHT_SEMIBOLD) + font.setWeight(QFont::DemiBold); + else if (weight >= PANGO_WEIGHT_NORMAL) + font.setWeight(QFont::Normal); + else + font.setWeight(QFont::Light); +#endif + + PangoStyle fontstyle = pango_font_description_get_style(gtk_font); + if (fontstyle == PANGO_STYLE_ITALIC) + font.setStyle(QFont::StyleItalic); + else if (fontstyle == PANGO_STYLE_OBLIQUE) + font.setStyle(QFont::StyleOblique); + else + font.setStyle(QFont::StyleNormal); + } + return font; +} + +bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) +{ + return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0; +} + +// copied from qHash.cpp +uint qHash(const QHashableLatin1Literal &key) +{ + int n = key.size(); + const uchar *p = reinterpret_cast(key.data()); + uint h = 0; + uint g; + + while (n--) { + h = (h << 4) + *p++; + if ((g = (h & 0xf0000000)) != 0) + h ^= g >> 23; + h &= ~g; + } + return h; +} + +QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle_p.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle_p.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle_p.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle_p.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTKSTYLE_P_H +#define QGTKSTYLE_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 +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QPainterPath; +class QGtkStylePrivate; + +class QGtkStyle : public QCommonStyle +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QGtkStyle) + +public: + QGtkStyle(); + QGtkStyle(QGtkStylePrivate &dd); + + ~QGtkStyle(); + + QPalette standardPalette() const Q_DECL_OVERRIDE; + + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; + void drawControl(ControlElement control, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; + void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; + void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, + const QPixmap &pixmap) const Q_DECL_OVERRIDE; + void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, + bool enabled, const QString& text, QPalette::ColorRole textRole) const Q_DECL_OVERRIDE; + + int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, + const QWidget *widget = 0) const Q_DECL_OVERRIDE; + int styleHint(StyleHint hint, const QStyleOption *option, + const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE; + + QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, + const QPoint &pt, const QWidget *w) const Q_DECL_OVERRIDE; + + QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, + SubControl subControl, const QWidget *widget) const Q_DECL_OVERRIDE; + QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const Q_DECL_OVERRIDE; + QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE; + + + QSize sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, + const QWidget *widget = 0) const Q_DECL_OVERRIDE; + QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option, + const QWidget *widget) const Q_DECL_OVERRIDE; + QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, + const QStyleOption *opt) const Q_DECL_OVERRIDE; + + void polish(QWidget *widget) Q_DECL_OVERRIDE; + void polish(QApplication *app) Q_DECL_OVERRIDE; + void polish(QPalette &palette) Q_DECL_OVERRIDE; + + void unpolish(QWidget *widget) Q_DECL_OVERRIDE; + void unpolish(QApplication *app) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif //QGTKSTYLE_P_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle_p_p.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle_p_p.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/gtk2/qgtkstyle_p_p.h 1970-01-01 00:00:00.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/gtk2/qgtkstyle_p_p.h 2017-03-11 09:23:02.000000000 +0000 @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $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 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 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGTKSTYLE_P_P_H +#define QGTKSTYLE_P_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 + +#include +#include +#include + +#include + +#include "qgtkstyle_p.h" +#include +#include "qgtkglobal_p.h" + +QT_BEGIN_NAMESPACE + +class QHashableLatin1Literal +{ +public: + int size() const { return m_size; } + const char *data() const { return m_data; } + +#ifdef __SUNPRO_CC + QHashableLatin1Literal(const char* str) + : m_size(strlen(str)), m_data(str) {} +#else + template + QHashableLatin1Literal(const char (&str)[N]) + : m_size(N - 1), m_data(str) {} +#endif + + QHashableLatin1Literal(const QHashableLatin1Literal &other) + : m_size(other.m_size), m_data(other.m_data) + {} + + QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other) + { + if (this == &other) + return *this; + *const_cast(&m_size) = other.m_size; + *const_cast(&m_data) = const_cast(other.m_data); + return *this; + } + + QString toString() const { return QString::fromLatin1(m_data, m_size); } + + static QHashableLatin1Literal fromData(const char *str) + { + return QHashableLatin1Literal(str, qstrlen(str)); + } + +private: + QHashableLatin1Literal(const char *str, int length) + : m_size(length), m_data(str) + {} + + const int m_size; + const char *m_data; +}; + +bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2); +inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); } +uint qHash(const QHashableLatin1Literal &key); + +typedef void (*Ptr_ubuntu_gtk_set_use_overlay_scrollbar) (gboolean); + +class QGtkPainter; +class QGtkStylePrivate; + +class QGtkStyleFilter : public QObject +{ +public: + QGtkStyleFilter(QGtkStylePrivate* sp) + : stylePrivate(sp) + {} +private: + QGtkStylePrivate* stylePrivate; + bool eventFilter(QObject *obj, QEvent *e) Q_DECL_OVERRIDE; +}; + +typedef enum { + GNOME_ICON_LOOKUP_FLAGS_NONE = 0, + GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0, + GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1, + GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2 +} GnomeIconLookupFlags; + +typedef enum { + GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0, + GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0 +} GnomeIconLookupResultFlags; + +struct GnomeThumbnailFactory; + +class QGtkStylePrivate : public QCommonStylePrivate +{ + Q_DECLARE_PUBLIC(QGtkStyle) +public: + QGtkStylePrivate(); + ~QGtkStylePrivate(); + + QGtkStyleFilter filter; + + static QGtkPainter* gtkPainter(QPainter *painter = 0); + static GtkWidget* gtkWidget(const QHashableLatin1Literal &path); + static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow")); + static void gtkWidgetSetFocus(GtkWidget *widget, bool focus); + + virtual void initGtkMenu() const; + virtual void initGtkTreeview() const; + virtual void initGtkWidgets() const; + + static void cleanupGtkWidgets(); + + static bool isKDE4Session(); + void applyCustomPaletteHash(); + static QFont getThemeFont(); + static bool isThemeAvailable() { return gtkStyle() != 0; } + + static QString getThemeName(); + virtual int getSpinboxArrowSize() const; + + virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal >kWidgetName) const; + + static Ptr_ubuntu_gtk_set_use_overlay_scrollbar ubuntu_gtk_set_use_overlay_scrollbar; + +protected: + typedef QHash WidgetMap; + + static inline void destroyWidgetMap() + { + cleanupGtkWidgets(); + delete widgetMap; + widgetMap = 0; + } + + static inline WidgetMap *gtkWidgetMap() + { + if (!widgetMap) { + widgetMap = new WidgetMap(); + qAddPostRoutine(destroyWidgetMap); + } + return widgetMap; + } + + static QStringList extract_filter(const QString &rawFilter); + + virtual GtkWidget* getTextColorWidget() const; + static void setupGtkWidget(GtkWidget* widget); + static void addWidgetToMap(GtkWidget* widget); + static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0); + static void addWidget(GtkWidget *widget); + static void removeWidgetFromMap(const QHashableLatin1Literal &path); + + virtual void init(); + + enum { + menuItemFrame = 2, // menu item frame width + menuItemHMargin = 3, // menu item hor text margin + menuArrowHMargin = 6, // menu arrow horizontal margin + menuItemVMargin = 2, // menu item ver text margin + menuRightBorder = 15, // right border on menus + menuCheckMarkWidth = 12 // checkmarks width on menus + }; + +private: + static QList instances; + static WidgetMap *widgetMap; + friend class QGtkStyleUpdateScheduler; +}; + +// Helper to ensure that we have polished all our gtk widgets +// before updating our own palettes +class QGtkStyleUpdateScheduler : public QObject +{ + Q_OBJECT +public slots: + void updateTheme(); +}; + +QT_END_NAMESPACE + +#endif // QGTKSTYLE_P_P_H diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/motif/motif.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/motif.pro --- qtstyleplugins-src-5.0.0/src/plugins/styles/motif/motif.pro 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/motif.pro 2017-03-11 09:23:02.000000000 +0000 @@ -1,5 +1,6 @@ TARGET = qmotifstyle PLUGIN_TYPE = styles +PLUGIN_CLASS_NAME = QMotifStylePlugin load(qt_plugin) QT = core gui widgets diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qcdestyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qcdestyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qcdestyle.cpp 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qcdestyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -100,6 +100,7 @@ QCDEStyle::QCDEStyle(bool useHighlightCols) : QMotifStyle(useHighlightCols) { + spinboxHCoeff = 10; } /*! diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qcdestyle.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qcdestyle.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qcdestyle.h 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qcdestyle.h 2017-03-11 09:23:02.000000000 +0000 @@ -57,14 +57,14 @@ virtual ~QCDEStyle(); int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const; + const QWidget *w = 0) const Q_DECL_OVERRIDE; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const; - QPalette standardPalette() const; + const QWidget *w = 0) const Q_DECL_OVERRIDE; + QPalette standardPalette() const Q_DECL_OVERRIDE; QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; }; QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qmotifstyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qmotifstyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qmotifstyle.cpp 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qmotifstyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -111,9 +111,9 @@ text color. */ QMotifStyle::QMotifStyle(bool useHighlightCols) : QCommonStyle(), focus(0), - highlightCols(useHighlightCols), animationFps(25), animateTimer(0), animateStep(0) + highlightCols(useHighlightCols), animationFps(25), animateTimer(0), animateStep(0), + spinboxHCoeff(6) { - startTime.start(); } /*! @@ -135,26 +135,22 @@ #ifndef QT_NO_PROGRESSBAR switch (e->type()) { case QEvent::StyleChange: + case QEvent::Paint: case QEvent::Show: if (QProgressBar *bar = qobject_cast(o)) { - bars << bar; - if (bars.size() == 1) { - Q_ASSERT(animationFps> 0); - animateTimer = startTimer(1000 / animationFps); - } + // Animation by timer for progress bars that have their min and + // max values the same + if (bar->minimum() == bar->maximum()) + startProgressAnimation(bar); + else + stopProgressAnimation(bar); } break; case QEvent::Destroy: case QEvent::Hide: // reinterpret_cast because there is no type info when getting // the destroy event. We know that it is a QProgressBar. - if (QProgressBar *bar = reinterpret_cast(o)) { - bars.removeAll(bar); - if (bars.isEmpty() && animateTimer) { - killTimer(animateTimer); - animateTimer = 0; - } - } + stopProgressAnimation(reinterpret_cast(o)); default: break; } @@ -162,6 +158,30 @@ return QStyle::eventFilter(o, e); } +void QMotifStyle::startProgressAnimation(QProgressBar *bar) +{ + if (!bars.contains(bar)) { + bars << bar; + if (bars.size() == 1) { + Q_ASSERT(animationFps > 0); + animateStep = 0; + startTime.start(); + animateTimer = startTimer(1000 / animationFps); + } + } +} + +void QMotifStyle::stopProgressAnimation(QProgressBar *bar) +{ + if (!bars.isEmpty()) { + bars.removeOne(bar); + if (bars.isEmpty() && animateTimer) { + killTimer(animateTimer); + animateTimer = 0; + } + } +} + /*! \reimp */ @@ -270,7 +290,7 @@ #ifndef QT_NO_PROGRESSBAR if (qobject_cast(widget)) { widget->removeEventFilter(this); - bars.removeAll(static_cast(widget)); + bars.removeOne(static_cast(widget)); } #endif } @@ -744,9 +764,8 @@ case PE_IndicatorProgressChunk: { - bool vertical = false; - if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast(opt)) - vertical = (pb2->orientation == Qt::Vertical); + const QStyleOptionProgressBar *pb = qstyleoption_cast(opt); + bool vertical = pb && (pb->orientation == Qt::Vertical); if (!vertical) { p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(), opt->palette.brush(QPalette::Highlight)); @@ -995,14 +1014,9 @@ if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { QTransform oldMatrix = p->transform(); QRect rect = pb->rect; - bool vertical = false; - bool invert = false; - bool bottomToTop = false; - if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast(opt)) { - vertical = (pb2->orientation == Qt::Vertical); - invert = pb2->invertedAppearance; - bottomToTop = pb2->bottomToTop; - } + bool vertical = (pb->orientation == Qt::Vertical); + bool invert = pb->invertedAppearance; + bool bottomToTop = pb->bottomToTop; if (vertical) { QTransform m; rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height @@ -1259,15 +1273,8 @@ case CE_ProgressBarContents: if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { QRect rect = pb->rect; - bool vertical = false; - bool inverted = false; - - // Get extra style options if version 2 - const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast(opt); - if (pb2) { - vertical = (pb2->orientation == Qt::Vertical); - inverted = pb2->invertedAppearance; - } + bool vertical = (pb->orientation == Qt::Vertical); + bool inverted = pb->invertedAppearance; QTransform m; if (vertical) { @@ -1915,6 +1922,14 @@ } break; +#ifndef QT_NO_SPINBOX + case CT_SpinBox: + if (const QStyleOptionSpinBox *vopt = qstyleoption_cast(opt)) { + if (vopt->frame) + sz.rheight() += spinboxHCoeff * proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget); + } + break; +#endif default: sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qmotifstyle.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qmotifstyle.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/motif/qmotifstyle.h 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/motif/qmotifstyle.h 2017-03-11 09:23:02.000000000 +0000 @@ -65,47 +65,49 @@ void setUseHighlightColors(bool); bool useHighlightColors() const; - void polish(QPalette&); - void polish(QWidget*); - void unpolish(QWidget*); - void polish(QApplication*); - void unpolish(QApplication*); + void polish(QPalette&) Q_DECL_OVERRIDE; + void polish(QWidget*) Q_DECL_OVERRIDE; + void unpolish(QWidget*) Q_DECL_OVERRIDE; + void polish(QApplication*) Q_DECL_OVERRIDE; + void unpolish(QApplication*) Q_DECL_OVERRIDE; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const; + const QWidget *w = 0) const Q_DECL_OVERRIDE; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const; + const QWidget *w = 0) const Q_DECL_OVERRIDE; void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = 0) const; + const QWidget *w = 0) const Q_DECL_OVERRIDE; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget = 0) const; + SubControl sc, const QWidget *widget = 0) const Q_DECL_OVERRIDE; int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = 0) const; + const QSize &contentsSize, const QWidget *widget = 0) const Q_DECL_OVERRIDE; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const; + QRect subElementRect(SubElement r, const QStyleOption *opt,const QWidget *widget = 0) const Q_DECL_OVERRIDE; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const; + QStyleHintReturn *returnData = 0) const Q_DECL_OVERRIDE; - bool event(QEvent *); - QPalette standardPalette() const; + bool event(QEvent *) Q_DECL_OVERRIDE; + QPalette standardPalette() const Q_DECL_OVERRIDE; QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; protected: QPointer focus; - void timerEvent(QTimerEvent *event); - bool eventFilter(QObject *o, QEvent *e); + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; + void startProgressAnimation(QProgressBar *bar); + void stopProgressAnimation(QProgressBar *bar); private: bool highlightCols; @@ -114,6 +116,9 @@ int animateTimer; QTime startTime; int animateStep; + +protected: + int spinboxHCoeff; }; QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/plastique/plastique.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/plastique/plastique.pro --- qtstyleplugins-src-5.0.0/src/plugins/styles/plastique/plastique.pro 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/plastique/plastique.pro 2017-03-11 09:23:02.000000000 +0000 @@ -1,5 +1,6 @@ TARGET = qplastiquestyle PLUGIN_TYPE = styles +PLUGIN_CLASS_NAME = QPlastiqueStylePlugin load(qt_plugin) QT = core core-private gui gui-private widgets diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/plastique/qplastiquestyle.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/plastique/qplastiquestyle.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/plastique/qplastiquestyle.cpp 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/plastique/qplastiquestyle.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -1298,15 +1298,15 @@ #ifndef QT_NO_GROUPBOX case PE_FrameGroupBox: if (const QStyleOptionFrame *frame = qstyleoption_cast(option)) { - QStyleOptionFrameV2 frameV2(*frame); - if (frameV2.features & QStyleOptionFrameV2::Flat) { + if (frame->features & QStyleOptionFrame::Flat) { QPen oldPen = painter->pen(); painter->setPen(borderColor); - painter->drawLine(frameV2.rect.topLeft(), frameV2.rect.topRight()); + painter->drawLine(frame->rect.topLeft(), frame->rect.topRight()); painter->setPen(oldPen); } else { - frameV2.state &= ~(State_Sunken | State_HasFocus); - proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget); + QStyleOptionFrame frame2(*frame); + frame2.state &= ~(State_Sunken | State_HasFocus); + proxy()->drawPrimitive(PE_Frame, &frame2, painter, widget); } } break; @@ -2436,15 +2436,9 @@ painter->setFont(font); painter->setPen(bar->palette.text().color()); - bool vertical = false; - bool inverted = false; - bool bottomToTop = false; - // Get extra style options if version 2 - if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast(option)) { - vertical = (bar2->orientation == Qt::Vertical); - inverted = bar2->invertedAppearance; - bottomToTop = bar2->bottomToTop; - } + bool vertical = (bar->orientation == Qt::Vertical); + bool inverted = bar->invertedAppearance; + bool bottomToTop = bar->bottomToTop; if (vertical) { rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height @@ -2499,20 +2493,14 @@ case CE_ProgressBarContents: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { QRect rect = bar->rect; - bool vertical = false; - bool inverted = false; + bool vertical = (bar->orientation == Qt::Vertical); + bool inverted = bar->invertedAppearance; bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); if (!indeterminate && bar->progress == -1) break; painter->save(); - // Get extra style options if version 2 - if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast(option)) { - vertical = (bar2->orientation == Qt::Vertical); - inverted = bar2->invertedAppearance; - } - // If the orientation is vertical, we use a transform to rotate // the progress bar 90 degrees clockwise. This way we can use the // same rendering code for both orientations. @@ -3114,9 +3102,7 @@ if (const QStyleOptionDockWidget *dockWidget = qstyleoption_cast(option)) { painter->save(); - const QStyleOptionDockWidgetV2 *v2 - = qstyleoption_cast(dockWidget); - bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; + bool verticalTitleBar = dockWidget->verticalTitleBar; // Find text width and title rect int textWidth = option->fontMetrics.width(dockWidget->title); @@ -3615,7 +3601,7 @@ // we need the label to be drawn using ButtonText where it // would usually use Text. painter->setPen(QPen(comboBox->palette.buttonText(), 0)); - QProxyStyle::drawControl(element, option, painter, widget); + QCommonStyle::drawControl(element, option, painter, widget); } else if (!comboBox->currentIcon.isNull()) { { QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); @@ -3648,7 +3634,7 @@ break; #endif default: - QProxyStyle::drawControl(element, option, painter, widget); + QCommonStyle::drawControl(element, option, painter, widget); break; } } @@ -4877,7 +4863,6 @@ #ifndef QT_NO_SPINBOX case CT_SpinBox: // Make sure the size is odd - newSize.setHeight(sizeFromContents(CT_LineEdit, option, size, widget).height()); newSize.rheight() -= ((1 - newSize.rheight()) & 1); break; #endif @@ -5672,7 +5657,7 @@ #ifndef QT_NO_PROGRESSBAR if (AnimateBusyProgressBar && qobject_cast(widget)) { widget->removeEventFilter(this); - bars.removeAll(static_cast(widget)); + bars.removeOne(static_cast(widget)); } #endif @@ -5794,25 +5779,21 @@ { #ifndef QT_NO_PROGRESSBAR switch (event->type()) { + case QEvent::StyleChange: + case QEvent::Paint: case QEvent::Show: if (QProgressBar *bar = qobject_cast(watched)) { - bars.append(bar); - if (bars.size() == 1) { - Q_ASSERT(ProgressBarFps > 0); - timer.start(); - progressBarAnimateTimer = startTimer(1000 / ProgressBarFps); - } + // Animation by timer for progress bars that have their min and + // max values the same + if (bar->minimum() == bar->maximum()) + startProgressAnimation(bar); + else + stopProgressAnimation(bar); } break; case QEvent::Destroy: case QEvent::Hide: - if (!bars.isEmpty()) { - bars.removeAll(reinterpret_cast(watched)); - if (bars.isEmpty()) { - killTimer(progressBarAnimateTimer); - progressBarAnimateTimer = 0; - } - } + stopProgressAnimation(reinterpret_cast(watched)); break; #if defined QPlastique_MaskButtons case QEvent::Resize: @@ -5843,19 +5824,52 @@ /*! \reimp */ -void QPlastiqueStyle::timerEvent(QTimerEvent *event) +bool QPlastiqueStyle::event(QEvent *event) { + switch (event->type()) { + case QEvent::Timer: { #ifndef QT_NO_PROGRESSBAR - if (event->timerId() == progressBarAnimateTimer) { - Q_ASSERT(ProgressBarFps > 0); - animateStep = timer.elapsed() / (1000 / ProgressBarFps); - foreach (QProgressBar *bar, bars) { - if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0)) - bar->update(); + QTimerEvent *timerEvent = reinterpret_cast(event); + if (timerEvent->timerId() == progressBarAnimateTimer) { + Q_ASSERT(ProgressBarFps > 0); + animateStep = timer.elapsed() / (1000 / ProgressBarFps); + foreach (QProgressBar *bar, bars) { + if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0)) + bar->update(); + } } - } #endif // QT_NO_PROGRESSBAR - event->ignore(); + event->ignore(); + } + default: + break; + } + + return QProxyStyle::event(event); +} + +void QPlastiqueStyle::startProgressAnimation(QProgressBar *bar) +{ + if (!bars.contains(bar)) { + bars << bar; + if (bars.size() == 1) { + Q_ASSERT(ProgressBarFps > 0); + animateStep = 0; + timer.start(); + progressBarAnimateTimer = startTimer(1000 / ProgressBarFps); + } + } +} + +void QPlastiqueStyle::stopProgressAnimation(QProgressBar *bar) +{ + if (!bars.isEmpty()) { + bars.removeOne(bar); + if (bars.isEmpty() && progressBarAnimateTimer) { + killTimer(progressBarAnimateTimer); + progressBarAnimateTimer = 0; + } + } } QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/plastique/qplastiquestyle.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/plastique/qplastiquestyle.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/plastique/qplastiquestyle.h 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/plastique/qplastiquestyle.h 2017-03-11 09:23:02.000000000 +0000 @@ -60,47 +60,49 @@ ~QPlastiqueStyle(); void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0) const; + QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE; void drawControl(ControlElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const; + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const; + QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE; QSize sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const; + const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE; - QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const; + QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget) const; + SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE; int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const; + QStyleHintReturn *returnData = 0) const Q_DECL_OVERRIDE; SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, - const QPoint &pos, const QWidget *widget = 0) const; + const QPoint &pos, const QWidget *widget = 0) const Q_DECL_OVERRIDE; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; + int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; - void polish(QWidget *widget); - void polish(QApplication *app); - void polish(QPalette &pal); - void unpolish(QWidget *widget); - void unpolish(QApplication *app); + void polish(QWidget *widget) Q_DECL_OVERRIDE; + void polish(QApplication *app) Q_DECL_OVERRIDE; + void polish(QPalette &pal) Q_DECL_OVERRIDE; + void unpolish(QWidget *widget) Q_DECL_OVERRIDE; + void unpolish(QApplication *app) Q_DECL_OVERRIDE; - QPalette standardPalette() const; + QPalette standardPalette() const Q_DECL_OVERRIDE; QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option = 0, - const QWidget *widget = 0) const; + const QWidget *widget = 0) const Q_DECL_OVERRIDE; protected: - bool eventFilter(QObject *watched, QEvent *event); - void timerEvent(QTimerEvent *event); + bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; + void startProgressAnimation(QProgressBar *bar); + void stopProgressAnimation(QProgressBar *bar); private: int animateStep; diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/shared/qstylehelper.cpp qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/shared/qstylehelper.cpp --- qtstyleplugins-src-5.0.0/src/plugins/styles/shared/qstylehelper.cpp 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/shared/qstylehelper.cpp 2017-03-11 09:23:02.000000000 +0000 @@ -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 #include #include -#include #include +#include +#include +#include #include "qstylecache_p.h" #include "qstylehelper_p.h" +#include QT_BEGIN_NAMESPACE @@ -74,6 +69,30 @@ 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 @@ } } + +QColor backgroundColor(const QPalette &pal, const QWidget* widget) +{ + if (qobject_cast(widget) && widget->parent() && + qobject_cast(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(); + + return 0; +} + } QT_END_NAMESPACE diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/shared/qstylehelper_p.h qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/shared/qstylehelper_p.h --- qtstyleplugins-src-5.0.0/src/plugins/styles/shared/qstylehelper_p.h 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/shared/qstylehelper_p.h 2017-03-11 09:23:02.000000000 +0000 @@ -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 #include #include +#include #ifndef QSTYLEHELPER_P_H #define QSTYLEHELPER_P_H @@ -67,6 +60,7 @@ class QPixmap; class QStyleOptionSlider; class QStyleOption; +class QWindow; namespace QStyleHelper { @@ -80,6 +74,12 @@ 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); } diff -Nru qtstyleplugins-src-5.0.0/src/plugins/styles/styles.pro qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/styles.pro --- qtstyleplugins-src-5.0.0/src/plugins/styles/styles.pro 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/src/plugins/styles/styles.pro 2017-03-11 09:23:02.000000000 +0000 @@ -3,3 +3,12 @@ cleanlooks \ motif \ plastique + +greaterThan(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 6) { + # only 5.7 or later + SUBDIRS += bb10style +} + +packagesExist(gtk+-2.0 x11) { + SUBDIRS += gtk2 +} diff -Nru qtstyleplugins-src-5.0.0/sync.profile qtstyleplugins-src-5.0.0+git23.g335dbec/sync.profile --- qtstyleplugins-src-5.0.0/sync.profile 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/sync.profile 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -# Module dependencies. -# Every module that is required to build this module should have one entry. -# Each of the module version specifiers can take one of the following values: -# - A specific Git revision. -# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) -# -%dependencies = ( - "qtbase" => "refs/heads/stable", -); diff -Nru qtstyleplugins-src-5.0.0/.tag qtstyleplugins-src-5.0.0+git23.g335dbec/.tag --- qtstyleplugins-src-5.0.0/.tag 2013-02-13 12:16:55.000000000 +0000 +++ qtstyleplugins-src-5.0.0+git23.g335dbec/.tag 2017-03-11 09:23:02.000000000 +0000 @@ -1 +1 @@ -7bd6205398b2d89b3ac083b2f6f00b197f40057a +335dbece103e2cbf6c7cf819ab6672c2956b17b3