diff options
Diffstat (limited to 'src/plugins')
162 files changed, 3736 insertions, 529 deletions
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp index abbfd445a5..f4460c1be0 100644 --- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp +++ b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp @@ -295,14 +295,10 @@ QString QOfonoDataConnectionManagerInterface::bearer() QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) { - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; + return getProperties().value(property); } -QVariantMap QOfonoDataConnectionManagerInterface::getProperties() +QVariantMap &QOfonoDataConnectionManagerInterface::getProperties() { if (propertiesMap.isEmpty()) { QList<QVariant> argumentList; diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h index 3b97e06dd3..8adb8db19c 100644 --- a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h +++ b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h @@ -160,11 +160,11 @@ public: Q_SIGNALS: void roamingAllowedChanged(bool); private: - QVariantMap getProperties(); + QVariantMap &getProperties(); QVariantMap propertiesMap; QStringList contextList; PathPropertiesList contextListProperties; -private slots: +private Q_SLOTS: void propertyChanged(const QString &, const QDBusVariant &value); }; diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp index 737b175941..1fbe440bb5 100644 --- a/src/plugins/generic/tslib/main.cpp +++ b/src/plugins/generic/tslib/main.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include <QtGui/qgenericplugin.h> -#include "qtslib.h" +#include <QtPlatformSupport/private/qtslib_p.h> QT_BEGIN_NAMESPACE @@ -42,21 +42,16 @@ class QTsLibPlugin : public QGenericPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "tslib.json") public: - QTsLibPlugin(); - QObject* create(const QString &key, const QString &specification); }; -QTsLibPlugin::QTsLibPlugin() - : QGenericPlugin() -{ -} - QObject* QTsLibPlugin::create(const QString &key, - const QString &specification) + const QString &specification) { - if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) + if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) + || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) return new QTsLibMouseHandler(key, specification); + return 0; } diff --git a/src/plugins/generic/tslib/qtslib.cpp b/src/plugins/generic/tslib/qtslib.cpp deleted file mode 100644 index a8f60b69ff..0000000000 --- a/src/plugins/generic/tslib/qtslib.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 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 -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qtslib.h" - - -#include <QSocketNotifier> -#include <QStringList> -#include <QPoint> -#include <qpa/qwindowsysteminterface.h> - -#include <errno.h> -#include <tslib.h> - -#include <qdebug.h> - -QT_BEGIN_NAMESPACE - -QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, - const QString &specification) - : m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false) -{ - qDebug() << "QTsLibMouseHandler" << key << specification; - setObjectName(QLatin1String("TSLib Mouse Handler")); - - QByteArray device = qgetenv("TSLIB_TSDEVICE"); - - if (specification.startsWith("/dev/")) - device = specification.toLocal8Bit(); - - if (device.isEmpty()) - device = QByteArrayLiteral("/dev/input/event1"); - - m_dev = ts_open(device.constData(), 1); - if (!m_dev) { - qErrnoWarning(errno, "ts_open() failed"); - return; - } - - if (ts_config(m_dev)) - perror("Error configuring\n"); - - m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive); - - int fd = ts_fd(m_dev); - if (fd >= 0) { - m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); - } else { - qWarning("Cannot open mouse input device '%s': %s", device.constData(), strerror(errno)); - } -} - - -QTsLibMouseHandler::~QTsLibMouseHandler() -{ - if (m_dev) - ts_close(m_dev); -} - - -static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode) -{ - if (rawMode) - return (ts_read_raw(dev, sample, 1) == 1); - else - return (ts_read(dev, sample, 1) == 1); -} - - -void QTsLibMouseHandler::readMouseData() -{ - ts_sample sample; - - while (get_sample(m_dev, &sample, m_rawMode)) { - bool pressed = sample.pressure; - int x = sample.x; - int y = sample.y; - - // work around missing coordinates on mouse release - if (sample.pressure == 0 && sample.x == 0 && sample.y == 0) { - x = m_x; - y = m_y; - } - - if (!m_rawMode) { - //filtering: ignore movements of 2 pixels or less - int dx = x - m_x; - int dy = y - m_y; - if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed) - continue; - } - QPoint pos(x, y); - - //printf("handleMouseEvent %d %d %d %ld\n", m_x, m_y, pressed, sample.tv.tv_usec); - - QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton); - - m_x = x; - m_y = y; - m_pressed = pressed; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/generic/tslib/qtslib.h b/src/plugins/generic/tslib/qtslib.h deleted file mode 100644 index cd11ca5e2f..0000000000 --- a/src/plugins/generic/tslib/qtslib.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 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 -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTSLIB_H -#define QTSLIB_H - -#include <qobject.h> -//#include <Qt> - -QT_BEGIN_NAMESPACE - -class QSocketNotifier; -struct tsdev; - -class QTsLibMouseHandler : public QObject -{ - Q_OBJECT -public: - QTsLibMouseHandler(const QString &key, const QString &specification); - ~QTsLibMouseHandler(); - -private slots: - void readMouseData(); - -private: - QSocketNotifier * m_notify; - tsdev *m_dev; - int m_x, m_y; - bool m_pressed; - bool m_rawMode; -}; - -QT_END_NAMESPACE - -#endif // QTSLIB_H diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro index bc05efcc32..be6fc4fbea 100644 --- a/src/plugins/generic/tslib/tslib.pro +++ b/src/plugins/generic/tslib/tslib.pro @@ -5,12 +5,9 @@ PLUGIN_EXTENDS = - PLUGIN_CLASS_NAME = QTsLibPlugin load(qt_plugin) -HEADERS = qtslib.h +SOURCES = main.cpp -SOURCES = main.cpp \ - qtslib.cpp - -QT += gui-private +QT += gui-private platformsupport-private LIBS += -lts diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 595892c1d1..62da60ab92 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -155,7 +155,7 @@ namespace QtAndroidInput static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y) { //### TODO: add proper API for Qt 5.2 - static bool rightMouseFromLongPress = qgetenv("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS").toInt(); + static bool rightMouseFromLongPress = qEnvironmentVariableIntValue("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS"); if (!rightMouseFromLongPress) return; m_ignoreMouseEvents = true; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index d1e78dfe5d..df0a8c56cb 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -412,7 +412,7 @@ namespace QtAndroid bool blockEventLoopsWhenSuspended() { - static bool block = qgetenv("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED").toInt(); + static bool block = qEnvironmentVariableIntValue("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED"); return block; } diff --git a/src/plugins/platforms/android/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp index 23182c6e57..36c349f6b4 100644 --- a/src/plugins/platforms/android/androidjnimenu.cpp +++ b/src/plugins/platforms/android/androidjnimenu.cpp @@ -199,7 +199,7 @@ namespace QtAndroidMenu env->DeleteLocalRef(env->CallObjectMethod(menuItem, setEnabledMenuItemMethodID, enabled)); if (!icon.isNull()) { // isNull() only checks the d pointer, not the actual image data. - int sz = qMax(36, qgetenv("QT_ANDROID_APP_ICON_SIZE").toInt()); + int sz = qMax(36, qEnvironmentVariableIntValue("QT_ANDROID_APP_ICON_SIZE")); QImage img = icon.pixmap(QSize(sz,sz), enabled ? QIcon::Normal diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 06303cdd10..2010c19bd4 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -254,7 +254,7 @@ private: AndroidAssetsFileEngineHandler::AndroidAssetsFileEngineHandler() - : m_assetsCache(std::max(5, qgetenv("QT_ANDROID_MAX_ASSETS_CACHE_SIZE").toInt())) + : m_assetsCache(std::max(5, qEnvironmentVariableIntValue("QT_ANDROID_MAX_ASSETS_CACHE_SIZE"))) , m_hasPrepopulatedCache(false) , m_hasTriedPrepopulatingCache(false) { diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 684ae64703..8a07735e5f 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -85,7 +85,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen():QObject(),QPlatformScreen() m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight); // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // is way much faster than 32 - if (qgetenv("QT_ANDROID_RASTER_IMAGE_DEPTH").toInt() == 16) { + if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { m_format = QImage::Format_RGB16; m_depth = 16; } else { diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index f9f2e4a944..b955cff44d 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -440,7 +440,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const { switch (hint) { case StyleNames: - if (qgetenv("QT_USE_ANDROID_NATIVE_STYLE").toInt() + if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE") && m_androidStyleData) { return QStringList("android"); } @@ -448,7 +448,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const case MouseDoubleClickDistance: { - int minimumDistance = qgetenv("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE").toInt(); + int minimumDistance = qEnvironmentVariableIntValue("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE"); int ret = minimumDistance; QAndroidPlatformIntegration *platformIntegration @@ -492,7 +492,7 @@ QString QAndroidPlatformTheme::standardButtonText(int button) const bool QAndroidPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const { if (type == MessageDialog) - return qgetenv("QT_USE_ANDROID_NATIVE_DIALOGS").toInt() == 1; + return qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_DIALOGS") == 1; return false; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 699340795d..0ce5b3b332 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1419,7 +1419,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if (m_sendKeyEvent && m_composingText.isEmpty()) QWindowSystemInterface::handleExtendedKeyEvent(focusWindow, timestamp, QEvent::Type(eventType), keyCode, modifiers, - nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat]); + nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat], false); m_sendKeyEvent = false; m_resendKeyEvent = false; diff --git a/src/plugins/platforms/eglfs/eglfs.pri b/src/plugins/platforms/eglfs/eglfs.pri index 6f463ba7d9..182539d8fe 100644 --- a/src/plugins/platforms/eglfs/eglfs.pri +++ b/src/plugins/platforms/eglfs/eglfs.pri @@ -17,13 +17,15 @@ SOURCES += $$PWD/qeglfsintegration.cpp \ $$PWD/qeglfswindow.cpp \ $$PWD/qeglfsscreen.cpp \ $$PWD/qeglfshooks_stub.cpp \ - $$PWD/qeglfscontext.cpp + $$PWD/qeglfscontext.cpp \ + $$PWD/qeglfsoffscreenwindow.cpp HEADERS += $$PWD/qeglfsintegration.h \ $$PWD/qeglfswindow.h \ $$PWD/qeglfsscreen.h \ $$PWD/qeglfshooks.h \ - $$PWD/qeglfscontext.h + $$PWD/qeglfscontext.h \ + $$PWD/qeglfsoffscreenwindow.h QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 6216fa8575..00778373ae 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -45,7 +45,8 @@ QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config, const QVariant &nativeHandle) - : QEGLPlatformContext(format, share, display, config, nativeHandle) + : QEGLPlatformContext(format, share, display, config, nativeHandle), + m_tempWindow(0) { } @@ -57,17 +58,45 @@ EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface return static_cast<QEGLPbuffer *>(surface)->pbuffer(); } +EGLSurface QEglFSContext::createTemporaryOffscreenSurface() +{ + if (QEglFSHooks::hooks()->supportsPBuffers()) + return QEGLPlatformContext::createTemporaryOffscreenSurface(); + + if (!m_tempWindow) { + m_tempWindow = QEglFSHooks::hooks()->createNativeOffscreenWindow(format()); + if (!m_tempWindow) { + qWarning("QEglFSContext: Failed to create temporary native window"); + return EGL_NO_SURFACE; + } + } + EGLConfig config = q_configFromGLFormat(eglDisplay(), format()); + return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0); +} + +void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface) +{ + if (QEglFSHooks::hooks()->supportsPBuffers()) { + QEGLPlatformContext::destroyTemporaryOffscreenSurface(surface); + } else { + eglDestroySurface(eglDisplay(), surface); + QEglFSHooks::hooks()->destroyNativeWindow(m_tempWindow); + m_tempWindow = 0; + } +} + void QEglFSContext::swapBuffers(QPlatformSurface *surface) { // draw the cursor if (surface->surface()->surfaceClass() == QSurface::Window) { QPlatformWindow *window = static_cast<QPlatformWindow *>(surface); - if (QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(window->screen()->cursor())) + if (QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(window->screen()->cursor())) cursor->paintOnScreen(); } - QEglFSHooks::hooks()->waitForVSync(); + QEglFSHooks::hooks()->waitForVSync(surface); QEGLPlatformContext::swapBuffers(surface); + QEglFSHooks::hooks()->presentBuffer(surface); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h index fcdad5ed22..a656a50e2f 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.h +++ b/src/plugins/platforms/eglfs/qeglfscontext.h @@ -45,7 +45,12 @@ public: QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config, const QVariant &nativeHandle); EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE; + EGLSurface createTemporaryOffscreenSurface() Q_DECL_OVERRIDE; + void destroyTemporaryOffscreenSurface(EGLSurface surface) Q_DECL_OVERRIDE; void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; + +private: + EGLNativeWindowType m_tempWindow; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h index c51af17a56..b2b8d46741 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks.h +++ b/src/plugins/platforms/eglfs/qeglfshooks.h @@ -42,8 +42,9 @@ QT_BEGIN_NAMESPACE -class QEGLPlatformCursor; class QEglFSScreen; +class QEglFSIntegration; +class QPlatformSurface; class QEglFSHooks { @@ -52,6 +53,8 @@ public: virtual void platformInit(); virtual void platformDestroy(); virtual EGLNativeDisplayType platformDisplay() const; + virtual void screenInit(); + virtual void screenDestroy(); virtual QSizeF physicalScreenSize() const; virtual QSize screenSize() const; virtual QDpi logicalDpi() const; @@ -63,15 +66,19 @@ public: virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow, const QSize &size, const QSurfaceFormat &format); + virtual EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format); virtual void destroyNativeWindow(EGLNativeWindowType window); virtual bool hasCapability(QPlatformIntegration::Capability cap) const; - virtual QEGLPlatformCursor *createCursor(QPlatformScreen *screen) const; + virtual QPlatformCursor *createCursor(QPlatformScreen *screen) const; virtual bool filterConfig(EGLDisplay display, EGLConfig config) const; - virtual void waitForVSync() const; + virtual void waitForVSync(QPlatformSurface *surface) const; + virtual void presentBuffer(QPlatformSurface *surface); virtual QByteArray fbDeviceName() const; virtual int framebufferIndex() const; + virtual bool supportsPBuffers() const; + static QEglFSHooks *hooks() { #ifdef EGLFS_PLATFORM_HOOKS diff --git a/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp b/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp index 9e5d624d87..4c430964a3 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp @@ -40,17 +40,185 @@ ****************************************************************************/ #include "qeglfshooks.h" +#include "qeglfsintegration.h" +#include "qeglfsscreen.h" + +#include <QtPlatformSupport/private/qeglplatformcursor_p.h> #include <QtPlatformSupport/private/qdevicediscovery_p.h> #include <QtCore/private/qcore_unix_p.h> #include <QtCore/QScopedPointer> +#include <QtCore/QJsonDocument> +#include <QtCore/QJsonObject> +#include <QtCore/QJsonArray> +#include <QtCore/QLoggingCategory> #include <QtGui/qpa/qplatformwindow.h> +#include <QtGui/qpa/qplatformcursor.h> +#include <QtGui/QPainter> +#include <QtGui/private/qguiapplication_p.h> #include <xf86drm.h> #include <xf86drmMode.h> #include <gbm.h> +#ifndef DRM_CAP_CURSOR_WIDTH +#define DRM_CAP_CURSOR_WIDTH 0x8 +#endif + +#ifndef DRM_CAP_CURSOR_HEIGHT +#define DRM_CAP_CURSOR_HEIGHT 0x9 +#endif + +#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) + QT_USE_NAMESPACE +Q_LOGGING_CATEGORY(qLcEglfsKmsDebug, "qt.qpa.eglfs.kms") + +class QEglFSKmsCursor; +class QEglFSKmsScreen; + +enum OutputConfiguration { + OutputConfigOff, + OutputConfigPreferred, + OutputConfigCurrent, + OutputConfigMode, + OutputConfigModeline +}; + +struct QEglFSKmsOutput { + QString name; + uint32_t connector_id; + uint32_t crtc_id; + QSizeF physical_size; + int mode; // index of selected mode in list below + bool mode_set; + drmModeCrtcPtr saved_crtc; + QList<drmModeModeInfo> modes; +}; + +class QEglFSKmsDevice +{ + Q_DISABLE_COPY(QEglFSKmsDevice) + + QString m_path; + int m_dri_fd; + gbm_device *m_gbm_device; + + quint32 m_crtc_allocator; + quint32 m_connector_allocator; + + int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector); + QEglFSKmsScreen *screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos); + + static void pageFlipHandler(int fd, + unsigned int sequence, + unsigned int tv_sec, + unsigned int tv_usec, + void *user_data); +public: + QEglFSKmsDevice(const QString &path); + + bool open(); + void close(); + + void createScreens(); + + gbm_device *device() const; + int fd() const; + + void handleDrmEvent(); +}; + +class QEglFSKmsScreen : public QEglFSScreen +{ + QEglFSKmsDevice *m_device; + gbm_surface *m_gbm_surface; + + gbm_bo *m_gbm_bo_current; + gbm_bo *m_gbm_bo_next; + + QEglFSKmsOutput m_output; + QPoint m_pos; + QScopedPointer<QEglFSKmsCursor> m_cursor; + + struct FrameBuffer { + FrameBuffer() : fb(0) {} + uint32_t fb; + }; + static void bufferDestroyedHandler(gbm_bo *bo, void *data); + FrameBuffer *framebufferForBufferObject(gbm_bo *bo); + + static QMutex m_waitForFlipMutex; + +public: + QEglFSKmsScreen(QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position); + ~QEglFSKmsScreen(); + + QRect geometry() const Q_DECL_OVERRIDE; + int depth() const Q_DECL_OVERRIDE; + QImage::Format format() const Q_DECL_OVERRIDE; + + QSizeF physicalSize() const Q_DECL_OVERRIDE; + QDpi logicalDpi() const Q_DECL_OVERRIDE; + Qt::ScreenOrientation nativeOrientation() const Q_DECL_OVERRIDE; + Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE; + + QString name() const Q_DECL_OVERRIDE; + + QPlatformCursor *cursor() const Q_DECL_OVERRIDE; + + QEglFSKmsDevice *device() const { return m_device; } + + gbm_surface *surface() const { return m_gbm_surface; } + gbm_surface *createSurface(); + void destroySurface(); + + void waitForFlip(); + void flip(); + void flipFinished(); + + QEglFSKmsOutput &output() { return m_output; } + void restoreMode(); +}; + +QMutex QEglFSKmsScreen::m_waitForFlipMutex; + +class QEglFSKmsCursor : public QPlatformCursor +{ + Q_OBJECT +public: + QEglFSKmsCursor(QEglFSKmsScreen *screen); + ~QEglFSKmsCursor(); + + // input methods + void pointerEvent(const QMouseEvent & event) Q_DECL_OVERRIDE; +#ifndef QT_NO_CURSOR + void changeCursor(QCursor * windowCursor, QWindow * window) Q_DECL_OVERRIDE; +#endif + QPoint pos() const Q_DECL_OVERRIDE; + void setPos(const QPoint &pos) Q_DECL_OVERRIDE; + +private: + void initCursorAtlas(); + + QEglFSKmsScreen *m_screen; + QSize m_cursorSize; + gbm_bo *m_bo; + QPoint m_pos; + QPlatformCursorImage m_cursorImage; + bool m_visible; + + // cursor atlas information + struct CursorAtlas { + CursorAtlas() : cursorsPerRow(0), cursorWidth(0), cursorHeight(0) { } + int cursorsPerRow; + int width, height; // width and height of the atlas + int cursorWidth, cursorHeight; // width and height of cursors inside the atlas + QList<QPoint> hotSpots; + QImage image; + } m_cursorAtlas; +}; + class QEglKmsHooks : public QEglFSHooks { public: @@ -59,111 +227,83 @@ public: void platformInit() Q_DECL_OVERRIDE; void platformDestroy() Q_DECL_OVERRIDE; EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE; - QSizeF physicalScreenSize() const Q_DECL_OVERRIDE; - QSize screenSize() const Q_DECL_OVERRIDE; - int screenDepth() const Q_DECL_OVERRIDE; + void screenInit() Q_DECL_OVERRIDE; QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const Q_DECL_OVERRIDE; EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow, const QSize &size, const QSurfaceFormat &format) Q_DECL_OVERRIDE; + EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format) Q_DECL_OVERRIDE; void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE; bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE; - void waitForVSync() const Q_DECL_OVERRIDE; + QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE; + void waitForVSync(QPlatformSurface *surface) const Q_DECL_OVERRIDE; + void presentBuffer(QPlatformSurface *surface) Q_DECL_OVERRIDE; + bool supportsPBuffers() const Q_DECL_OVERRIDE; - void waitForVSyncImpl(); - bool setup_kms(); - - struct FrameBuffer { - FrameBuffer() : fb(0) {} - uint32_t fb; - }; - FrameBuffer *framebufferForBufferObject(gbm_bo *bo); + bool hwCursor() const; + QMap<QString, QVariantMap> outputSettings() const; private: - // device bits - QByteArray m_device; - int m_dri_fd; - gbm_device *m_gbm_device; + void loadConfig(); - // KMS bits - drmModeConnector *m_drm_connector; - drmModeEncoder *m_drm_encoder; - drmModeModeInfo m_drm_mode; - quint32 m_drm_crtc; + QEglFSKmsDevice *m_device; - // Drawing bits - gbm_surface *m_gbm_surface; + bool m_hwCursor; + bool m_pbuffers; + QString m_devicePath; + QMap<QString, QVariantMap> m_outputSettings; }; static QEglKmsHooks kms_hooks; QEglFSHooks *platformHooks = &kms_hooks; QEglKmsHooks::QEglKmsHooks() - : m_dri_fd(-1) - , m_gbm_device(Q_NULLPTR) - , m_drm_connector(Q_NULLPTR) - , m_drm_encoder(Q_NULLPTR) - , m_drm_crtc(0) - , m_gbm_surface(Q_NULLPTR) -{ - -} + : m_device(Q_NULLPTR) + , m_hwCursor(true) + , m_pbuffers(false) +{} void QEglKmsHooks::platformInit() { - QDeviceDiscovery *d = QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask); - QStringList devices = d->scanConnectedDevices(); - d->deleteLater(); + loadConfig(); - if (devices.isEmpty()) - qFatal("Could not find DRM device!"); + if (!m_devicePath.isEmpty()) { + qCDebug(qLcEglfsKmsDebug) << "Using DRM device" << m_devicePath << "specified in config file"; + } else { - m_device = devices.first().toLocal8Bit(); - m_dri_fd = qt_safe_open(m_device.constData(), O_RDWR | O_CLOEXEC); - if (m_dri_fd == -1) { - qErrnoWarning("Could not open DRM device %s", m_device.constData()); - qFatal("DRM device required, aborting."); - } + QDeviceDiscovery *d = QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask); + QStringList devices = d->scanConnectedDevices(); + qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices; + d->deleteLater(); - if (!setup_kms()) - qFatal("Could not set up KMS on device %s!", m_device.constData()); + if (devices.isEmpty()) + qFatal("Could not find DRM device!"); - m_gbm_device = gbm_create_device(m_dri_fd); - if (!m_gbm_device) - qFatal("Could not initialize gbm on device %s!", m_device.constData()); + m_devicePath = devices.first(); + qCDebug(qLcEglfsKmsDebug) << "Using" << m_devicePath; + } + + m_device = new QEglFSKmsDevice(m_devicePath); + if (!m_device->open()) + qFatal("Could not open device %s - aborting!", qPrintable(m_devicePath)); } void QEglKmsHooks::platformDestroy() { - gbm_device_destroy(m_gbm_device); - m_gbm_device = Q_NULLPTR; - - if (qt_safe_close(m_dri_fd) == -1) - qErrnoWarning("Could not close DRM device %s", m_device.constData()); - - m_dri_fd = -1; + m_device->close(); + delete m_device; + m_device = Q_NULLPTR; } EGLNativeDisplayType QEglKmsHooks::platformDisplay() const { - return static_cast<EGLNativeDisplayType>(m_gbm_device); -} - -QSizeF QEglKmsHooks::physicalScreenSize() const -{ - return QSizeF(m_drm_connector->mmWidth, - m_drm_connector->mmHeight); -} - -QSize QEglKmsHooks::screenSize() const -{ - return QSize(m_drm_mode.hdisplay, - m_drm_mode.vdisplay); + Q_ASSERT(m_device); + return reinterpret_cast<EGLNativeDisplayType>(m_device->device()); } -int QEglKmsHooks::screenDepth() const +void QEglKmsHooks::screenInit() { - return 32; + m_device->createScreens(); } QSurfaceFormat QEglKmsHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const @@ -181,31 +321,35 @@ EGLNativeWindowType QEglKmsHooks::createNativeWindow(QPlatformWindow *platformWi const QSize &size, const QSurfaceFormat &format) { - Q_UNUSED(platformWindow); Q_UNUSED(size); Q_UNUSED(format); - if (m_gbm_surface) { - qWarning("Only single window apps supported!"); + QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(platformWindow->screen()); + if (screen->surface()) { + qWarning("Only single window per screen supported!"); return 0; } - m_gbm_surface = gbm_surface_create(m_gbm_device, - screenSize().width(), - screenSize().height(), - GBM_FORMAT_XRGB8888, - GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); - if (!m_gbm_surface) - qFatal("Could not initialize GBM surface"); + return reinterpret_cast<EGLNativeWindowType>(screen->createSurface()); +} + +EGLNativeWindowType QEglKmsHooks::createNativeOffscreenWindow(const QSurfaceFormat &format) +{ + Q_UNUSED(format); + Q_ASSERT(m_device); - return reinterpret_cast<EGLNativeWindowType>(m_gbm_surface); + qCDebug(qLcEglfsKmsDebug) << "Creating native off screen window"; + gbm_surface *surface = gbm_surface_create(m_device->device(), + 1, 1, + GBM_FORMAT_XRGB8888, + GBM_BO_USE_RENDERING); + + return reinterpret_cast<EGLNativeWindowType>(surface); } void QEglKmsHooks::destroyNativeWindow(EGLNativeWindowType window) { gbm_surface *surface = reinterpret_cast<gbm_surface *>(window); - if (surface == m_gbm_surface) - m_gbm_surface = Q_NULLPTR; gbm_surface_destroy(surface); } @@ -215,16 +359,250 @@ bool QEglKmsHooks::hasCapability(QPlatformIntegration::Capability cap) const case QPlatformIntegration::ThreadedPixmaps: case QPlatformIntegration::OpenGL: case QPlatformIntegration::ThreadedOpenGL: - case QPlatformIntegration::BufferQueueingOpenGL: return true; default: return false; } } -static void gbm_bo_destroyed_callback(gbm_bo *bo, void *data) +QPlatformCursor *QEglKmsHooks::createCursor(QPlatformScreen *screen) const +{ + if (m_hwCursor) + return Q_NULLPTR; + else + return new QEGLPlatformCursor(screen); +} + +void QEglKmsHooks::waitForVSync(QPlatformSurface *surface) const +{ + QWindow *window = static_cast<QWindow *>(surface->surface()); + QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(window->screen()->handle()); + + screen->waitForFlip(); +} + +void QEglKmsHooks::presentBuffer(QPlatformSurface *surface) +{ + QWindow *window = static_cast<QWindow *>(surface->surface()); + QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(window->screen()->handle()); + + screen->flip(); +} + +bool QEglKmsHooks::supportsPBuffers() const +{ + return m_pbuffers; +} + +bool QEglKmsHooks::hwCursor() const +{ + return m_hwCursor; +} + +QMap<QString, QVariantMap> QEglKmsHooks::outputSettings() const +{ + return m_outputSettings; +} + +void QEglKmsHooks::loadConfig() +{ + static QByteArray json = qgetenv("QT_QPA_EGLFS_KMS_CONFIG"); + if (json.isEmpty()) + return; + + qCDebug(qLcEglfsKmsDebug) << "Loading KMS setup from" << json; + + QFile file(QString::fromUtf8(json)); + if (!file.open(QFile::ReadOnly)) { + qCDebug(qLcEglfsKmsDebug) << "Could not open config file" + << json << "for reading"; + return; + } + + QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); + if (!doc.isObject()) { + qCDebug(qLcEglfsKmsDebug) << "Invalid config file" << json + << "- no top-level JSON object"; + return; + } + + QJsonObject object = doc.object(); + + m_hwCursor = object.value("hwcursor").toBool(m_hwCursor); + m_pbuffers = object.value("pbuffers").toBool(m_pbuffers); + m_devicePath = object.value("device").toString(); + + QJsonArray outputs = object.value("outputs").toArray(); + for (int i = 0; i < outputs.size(); i++) { + QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap(); + + if (outputSettings.contains("name")) { + QString name = outputSettings.value("name").toString(); + + if (m_outputSettings.contains(name)) { + qCDebug(qLcEglfsKmsDebug) << "Output" << name << "configured multiple times!"; + } + + m_outputSettings.insert(name, outputSettings); + } + } + + qCDebug(qLcEglfsKmsDebug) << "Configuration:\n" + << "\thwcursor:" << m_hwCursor << "\n" + << "\tpbuffers:" << m_pbuffers << "\n" + << "\toutputs:" << m_outputSettings; +} + +QEglFSKmsCursor::QEglFSKmsCursor(QEglFSKmsScreen *screen) + : m_screen(screen) + , m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below + , m_bo(Q_NULLPTR) + , m_cursorImage(0, 0, 0, 0, 0, 0) + , m_visible(true) { - QEglKmsHooks::FrameBuffer *fb = static_cast<QEglKmsHooks::FrameBuffer *>(data); + uint64_t width, height; + if ((drmGetCap(m_screen->device()->fd(), DRM_CAP_CURSOR_WIDTH, &width) == 0) + && (drmGetCap(m_screen->device()->fd(), DRM_CAP_CURSOR_HEIGHT, &height) == 0)) { + m_cursorSize.setWidth(width); + m_cursorSize.setHeight(height); + } + + m_bo = gbm_bo_create(m_screen->device()->device(), m_cursorSize.width(), m_cursorSize.height(), + GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE); + if (!m_bo) { + qWarning("Could not create buffer for cursor!"); + } else { + initCursorAtlas(); + } + + drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0); +} + +QEglFSKmsCursor::~QEglFSKmsCursor() +{ + drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0, 0); + drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0); + + gbm_bo_destroy(m_bo); + m_bo = Q_NULLPTR; +} + +void QEglFSKmsCursor::pointerEvent(const QMouseEvent &event) +{ + setPos(event.screenPos().toPoint()); +} + +#ifndef QT_NO_CURSOR +void QEglFSKmsCursor::changeCursor(QCursor *windowCursor, QWindow *window) +{ + Q_UNUSED(window); + + if (!m_visible) + return; + + const Qt::CursorShape newShape = windowCursor ? windowCursor->shape() : Qt::ArrowCursor; + if (newShape == Qt::BitmapCursor) { + m_cursorImage.set(windowCursor->pixmap().toImage(), + windowCursor->hotSpot().x(), + windowCursor->hotSpot().y()); + } else { + // Standard cursor, look up in atlas + const int width = m_cursorAtlas.cursorWidth; + const int height = m_cursorAtlas.cursorHeight; + const qreal ws = (qreal)m_cursorAtlas.cursorWidth / m_cursorAtlas.width; + const qreal hs = (qreal)m_cursorAtlas.cursorHeight / m_cursorAtlas.height; + + QRect textureRect(ws * (newShape % m_cursorAtlas.cursorsPerRow) * m_cursorAtlas.width, + hs * (newShape / m_cursorAtlas.cursorsPerRow) * m_cursorAtlas.height, + width, + height); + QPoint hotSpot = m_cursorAtlas.hotSpots[newShape]; + m_cursorImage.set(m_cursorAtlas.image.copy(textureRect), + hotSpot.x(), + hotSpot.y()); + } + + if (m_cursorImage.image()->width() > m_cursorSize.width() || m_cursorImage.image()->height() > m_cursorSize.height()) + qWarning("Cursor larger than %dx%d, cursor will be clipped.", m_cursorSize.width(), m_cursorSize.height()); + + QImage cursorImage(m_cursorSize, QImage::Format_ARGB32); + cursorImage.fill(Qt::transparent); + + QPainter painter; + painter.begin(&cursorImage); + painter.drawImage(0, 0, *m_cursorImage.image()); + painter.end(); + + gbm_bo_write(m_bo, cursorImage.constBits(), cursorImage.byteCount()); + + uint32_t handle = gbm_bo_get_handle(m_bo).u32; + int status = drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, handle, + m_cursorSize.width(), m_cursorSize.height()); + if (status != 0) + qWarning("Could not set cursor: %d", status); +} +#endif // QT_NO_CURSOR + +QPoint QEglFSKmsCursor::pos() const +{ + return m_pos; +} + +void QEglFSKmsCursor::setPos(const QPoint &pos) +{ + QPoint adjustedPos = pos - m_cursorImage.hotspot(); + int ret = drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, adjustedPos.x(), adjustedPos.y()); + if (ret == 0) { + m_pos = pos; + } else { + qWarning("Failed to move cursor: %d", ret); + } +} + +void QEglFSKmsCursor::initCursorAtlas() +{ + static QByteArray json = qgetenv("QT_QPA_EGLFS_CURSOR"); + if (json.isEmpty()) + json = ":/cursor.json"; + + qCDebug(qLcEglfsKmsDebug) << "Initializing cursor atlas from" << json; + + QFile file(QString::fromUtf8(json)); + if (!file.open(QFile::ReadOnly)) { + drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0, 0); + drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0); + m_visible = false; + return; + } + + QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); + QJsonObject object = doc.object(); + + QString atlas = object.value(QLatin1String("image")).toString(); + Q_ASSERT(!atlas.isEmpty()); + + const int cursorsPerRow = object.value(QLatin1String("cursorsPerRow")).toDouble(); + Q_ASSERT(cursorsPerRow); + m_cursorAtlas.cursorsPerRow = cursorsPerRow; + + const QJsonArray hotSpots = object.value(QLatin1String("hotSpots")).toArray(); + Q_ASSERT(hotSpots.count() == Qt::LastCursor + 1); + for (int i = 0; i < hotSpots.count(); i++) { + QPoint hotSpot(hotSpots[i].toArray()[0].toDouble(), hotSpots[i].toArray()[1].toDouble()); + m_cursorAtlas.hotSpots << hotSpot; + } + + QImage image = QImage(atlas).convertToFormat(QImage::Format_ARGB32); + m_cursorAtlas.cursorWidth = image.width() / m_cursorAtlas.cursorsPerRow; + m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow) / cursorsPerRow); + m_cursorAtlas.width = image.width(); + m_cursorAtlas.height = image.height(); + m_cursorAtlas.image = image; +} + +void QEglFSKmsScreen::bufferDestroyedHandler(gbm_bo *bo, void *data) +{ + FrameBuffer *fb = static_cast<FrameBuffer *>(data); if (fb->fb) { gbm_device *device = gbm_bo_get_device(bo); @@ -234,7 +612,7 @@ static void gbm_bo_destroyed_callback(gbm_bo *bo, void *data) delete fb; } -QEglKmsHooks::FrameBuffer *QEglKmsHooks::framebufferForBufferObject(gbm_bo *bo) +QEglFSKmsScreen::FrameBuffer *QEglFSKmsScreen::framebufferForBufferObject(gbm_bo *bo) { { FrameBuffer *fb = static_cast<FrameBuffer *>(gbm_bo_get_user_data(bo)); @@ -249,7 +627,7 @@ QEglKmsHooks::FrameBuffer *QEglKmsHooks::framebufferForBufferObject(gbm_bo *bo) QScopedPointer<FrameBuffer> fb(new FrameBuffer); - int ret = drmModeAddFB(m_dri_fd, width, height, 24, 32, + int ret = drmModeAddFB(m_device->fd(), width, height, 24, 32, stride, handle, &fb->fb); if (ret) { @@ -257,166 +635,542 @@ QEglKmsHooks::FrameBuffer *QEglKmsHooks::framebufferForBufferObject(gbm_bo *bo) return Q_NULLPTR; } - gbm_bo_set_user_data(bo, fb.data(), gbm_bo_destroyed_callback); + gbm_bo_set_user_data(bo, fb.data(), bufferDestroyedHandler); return fb.take(); + } -static void page_flip_handler(int fd, - unsigned int sequence, - unsigned int tv_sec, - unsigned int tv_usec, - void *user_data) +QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position) + : QEglFSScreen(eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(device->device()))) + , m_device(device) + , m_gbm_surface(Q_NULLPTR) + , m_gbm_bo_current(Q_NULLPTR) + , m_gbm_bo_next(Q_NULLPTR) + , m_output(output) + , m_pos(position) + , m_cursor(Q_NULLPTR) { - Q_UNUSED(fd); - Q_UNUSED(sequence); - Q_UNUSED(tv_sec); - Q_UNUSED(tv_usec); +} + +QEglFSKmsScreen::~QEglFSKmsScreen() +{ + restoreMode(); +} + +QRect QEglFSKmsScreen::geometry() const +{ + const int mode = m_output.mode; + return QRect(m_pos.x(), m_pos.y(), + m_output.modes[mode].hdisplay, + m_output.modes[mode].vdisplay); +} + +int QEglFSKmsScreen::depth() const +{ + return 32; +} + +QImage::Format QEglFSKmsScreen::format() const +{ + return QImage::Format_RGB32; +} - // We are no longer flipping - *static_cast<bool *>(user_data) = false; +QSizeF QEglFSKmsScreen::physicalSize() const +{ + return m_output.physical_size; +} + +QDpi QEglFSKmsScreen::logicalDpi() const +{ + QSizeF ps = physicalSize(); + QSize s = geometry().size(); + + if (ps.isValid() && s.isValid()) + return QDpi(25.4 * s.width() / ps.width(), + 25.4 * s.height() / ps.height()); + else + return QDpi(100, 100); +} + +Qt::ScreenOrientation QEglFSKmsScreen::nativeOrientation() const +{ + return Qt::PrimaryOrientation; +} + +Qt::ScreenOrientation QEglFSKmsScreen::orientation() const +{ + return Qt::PrimaryOrientation; +} + +QString QEglFSKmsScreen::name() const +{ + return m_output.name; } -void QEglKmsHooks::waitForVSync() const +QPlatformCursor *QEglFSKmsScreen::cursor() const { - const_cast<QEglKmsHooks*>(this)->waitForVSyncImpl(); + if (kms_hooks.hwCursor()) { + if (m_cursor.isNull()) { + QEglFSKmsScreen *that = const_cast<QEglFSKmsScreen *>(this); + that->m_cursor.reset(new QEglFSKmsCursor(that)); + } + + return m_cursor.data(); + } else { + return QEglFSScreen::cursor(); + } } -void QEglKmsHooks::waitForVSyncImpl() +gbm_surface *QEglFSKmsScreen::createSurface() { if (!m_gbm_surface) { - qWarning("Cannot sync before platform init!"); - return; + qCDebug(qLcEglfsKmsDebug) << "Creating window for screen" << name(); + m_gbm_surface = gbm_surface_create(m_device->device(), + geometry().width(), + geometry().height(), + GBM_FORMAT_XRGB8888, + GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + } + return m_gbm_surface; +} + +void QEglFSKmsScreen::destroySurface() +{ + if (m_gbm_bo_current) { + gbm_bo_destroy(m_gbm_bo_current); + m_gbm_bo_current = Q_NULLPTR; } - if (!gbm_surface_has_free_buffers(m_gbm_surface)) { - qWarning("Out of free GBM buffers!"); + if (m_gbm_bo_next) { + gbm_bo_destroy(m_gbm_bo_next); + m_gbm_bo_next = Q_NULLPTR; + } + + if (m_gbm_surface) { + gbm_surface_destroy(m_gbm_surface); + m_gbm_surface = Q_NULLPTR; + } +} + +void QEglFSKmsScreen::waitForFlip() +{ + // Don't lock the mutex unless we actually need to + if (!m_gbm_bo_next) + return; + + QMutexLocker lock(&m_waitForFlipMutex); + while (m_gbm_bo_next) + m_device->handleDrmEvent(); +} + +void QEglFSKmsScreen::flip() +{ + if (!m_gbm_surface) { + qWarning("Cannot sync before platform init!"); return; } - gbm_bo *front_buffer = gbm_surface_lock_front_buffer(m_gbm_surface); - if (!front_buffer) { + m_gbm_bo_next = gbm_surface_lock_front_buffer(m_gbm_surface); + if (!m_gbm_bo_next) { qWarning("Could not lock GBM surface front buffer!"); return; } - QEglKmsHooks::FrameBuffer *fb = framebufferForBufferObject(front_buffer); + FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next); - int ret = drmModeSetCrtc(m_dri_fd, - m_drm_crtc, - fb->fb, - 0, 0, - &m_drm_connector->connector_id, 1, - &m_drm_mode); - if (ret) { - qErrnoWarning("Could not set DRM mode!"); - return; + if (!m_output.mode_set) { + int ret = drmModeSetCrtc(m_device->fd(), + m_output.crtc_id, + fb->fb, + 0, 0, + &m_output.connector_id, 1, + &m_output.modes[m_output.mode]); + + if (ret) + qErrnoWarning("Could not set DRM mode!"); + else + m_output.mode_set = true; } - bool flipping = true; - ret = drmModePageFlip(m_dri_fd, - m_drm_encoder->crtc_id, - fb->fb, - DRM_MODE_PAGE_FLIP_EVENT, - &flipping); + int ret = drmModePageFlip(m_device->fd(), + m_output.crtc_id, + fb->fb, + DRM_MODE_PAGE_FLIP_EVENT, + this); if (ret) { qErrnoWarning("Could not queue DRM page flip!"); - return; + gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next); + m_gbm_bo_next = Q_NULLPTR; } +} - drmEventContext drmEvent = { - DRM_EVENT_CONTEXT_VERSION, - Q_NULLPTR, // vblank handler - page_flip_handler // page flip handler - }; +void QEglFSKmsScreen::flipFinished() +{ + if (m_gbm_bo_current) + gbm_surface_release_buffer(m_gbm_surface, + m_gbm_bo_current); - fd_set fds; - FD_ZERO(&fds); - FD_SET(m_dri_fd, &fds); + m_gbm_bo_current = m_gbm_bo_next; + m_gbm_bo_next = Q_NULLPTR; +} - time_t start, cur; - time(&start); +void QEglFSKmsScreen::restoreMode() +{ + if (m_output.mode_set && m_output.saved_crtc) { + drmModeSetCrtc(m_device->fd(), + m_output.saved_crtc->crtc_id, + m_output.saved_crtc->buffer_id, + 0, 0, + &m_output.connector_id, 1, + &m_output.saved_crtc->mode); + + drmModeFreeCrtc(m_output.saved_crtc); + m_output.saved_crtc = Q_NULLPTR; + + m_output.mode_set = false; + } +} - while (flipping && (time(&cur) < start + 1)) { - timespec v; - memset(&v, 0, sizeof(v)); - v.tv_sec = start + 1 - cur; +int QEglFSKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector) +{ + for (int i = 0; i < connector->count_encoders; i++) { + drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoders[i]); + if (!encoder) { + qWarning("Failed to get encoder"); + continue; + } + + quint32 possibleCrtcs = encoder->possible_crtcs; + drmModeFreeEncoder(encoder); - ret = qt_safe_select(m_dri_fd + 1, &fds, Q_NULLPTR, Q_NULLPTR, &v); + for (int j = 0; j < resources->count_crtcs; j++) { + bool isPossible = possibleCrtcs & (1 << j); + bool isAvailable = !(m_crtc_allocator & 1 << resources->crtcs[j]); - if (ret == 0) { - // timeout - break; - } else if (ret == -1) { - qErrnoWarning("Error while selecting on DRM fd"); - break; - } else if (drmHandleEvent(m_dri_fd, &drmEvent)) { - qWarning("Could not handle DRM event!"); + if (isPossible && isAvailable) + return j; } } - gbm_surface_release_buffer(m_gbm_surface, front_buffer); + return -1; } -bool QEglKmsHooks::setup_kms() +static const char * const connector_type_names[] = { + "None", + "VGA", + "DVI", + "DVI", + "DVI", + "Composite", + "TV", + "LVDS", + "CTV", + "DIN", + "DP", + "HDMI", + "HDMI", + "TV", + "eDP", +}; + +static QString nameForConnector(const drmModeConnectorPtr connector) { - drmModeRes *resources; - drmModeConnector *connector; - drmModeEncoder *encoder; - quint32 crtc = 0; - int i; + QString connectorName = "UNKNOWN"; - resources = drmModeGetResources(m_dri_fd); - if (!resources) { - qWarning("drmModeGetResources failed"); - return false; - } + if (connector->connector_type < ARRAY_LENGTH(connector_type_names)) + connectorName = connector_type_names[connector->connector_type]; + + connectorName += QString::number(connector->connector_type_id); + + return connectorName; +} + +static bool parseModeline(const QString &s, drmModeModeInfoPtr mode) +{ + char hsync[16]; + char vsync[16]; + float fclock; + + mode->type = DRM_MODE_TYPE_USERDEF; + mode->hskew = 0; + mode->vscan = 0; + mode->vrefresh = 0; + mode->flags = 0; + + if (sscanf(qPrintable(s), "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s", + &fclock, + &mode->hdisplay, + &mode->hsync_start, + &mode->hsync_end, + &mode->htotal, + &mode->vdisplay, + &mode->vsync_start, + &mode->vsync_end, + &mode->vtotal, hsync, vsync) != 11) + return false; + + mode->clock = fclock * 1000; + + if (strcmp(hsync, "+hsync") == 0) + mode->flags |= DRM_MODE_FLAG_PHSYNC; + else if (strcmp(hsync, "-hsync") == 0) + mode->flags |= DRM_MODE_FLAG_NHSYNC; + else + return false; + + if (strcmp(vsync, "+vsync") == 0) + mode->flags |= DRM_MODE_FLAG_PVSYNC; + else if (strcmp(vsync, "-vsync") == 0) + mode->flags |= DRM_MODE_FLAG_NVSYNC; + else + return false; - for (i = 0; i < resources->count_connectors; i++) { - connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]); - if (connector == NULL) - continue; + return true; +} - if (connector->connection == DRM_MODE_CONNECTED && - connector->count_modes > 0) { - break; - } +QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos) +{ + const QString connectorName = nameForConnector(connector); - drmModeFreeConnector(connector); + const int crtc = crtcForConnector(resources, connector); + if (crtc < 0) { + qWarning() << "No usable crtc/encoder pair for connector" << connectorName; + return Q_NULLPTR; + } + + OutputConfiguration configuration; + QSize configurationSize; + drmModeModeInfo configurationModeline; + + const QString mode = kms_hooks.outputSettings().value(connectorName).value("mode", "preferred").toString().toLower(); + if (mode == "off") { + configuration = OutputConfigOff; + } else if (mode == "preferred") { + configuration = OutputConfigPreferred; + } else if (mode == "current") { + configuration = OutputConfigCurrent; + } else if (sscanf(qPrintable(mode), "%dx%d", &configurationSize.rwidth(), &configurationSize.rheight()) == 2) { + configuration = OutputConfigMode; + } else if (parseModeline(mode, &configurationModeline)) { + configuration = OutputConfigModeline; + } else { + qWarning("Invalid mode \"%s\" for output %s", qPrintable(mode), qPrintable(connectorName)); + configuration = OutputConfigPreferred; } - if (i == resources->count_connectors) { - qWarning("No currently active connector found."); - return false; + const uint32_t crtc_id = resources->crtcs[crtc]; + + if (configuration == OutputConfigOff) { + qCDebug(qLcEglfsKmsDebug) << "Turning off output" << connectorName; + drmModeSetCrtc(m_dri_fd, crtc_id, 0, 0, 0, 0, 0, Q_NULLPTR); + return Q_NULLPTR; } - for (i = 0; i < resources->count_encoders; i++) { - encoder = drmModeGetEncoder(m_dri_fd, resources->encoders[i]); + // Get the current mode on the current crtc + drmModeModeInfo crtc_mode; + memset(&crtc_mode, 0, sizeof crtc_mode); + if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) { + drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id); + drmModeFreeEncoder(encoder); - if (encoder == NULL) - continue; + if (!crtc) + return Q_NULLPTR; - if (encoder->encoder_id == connector->encoder_id) - break; + if (crtc->mode_valid) + crtc_mode = crtc->mode; - drmModeFreeEncoder(encoder); + drmModeFreeCrtc(crtc); } - for (int j = 0; j < resources->count_crtcs; j++) { - if ((encoder->possible_crtcs & (1 << j))) { - crtc = resources->crtcs[j]; - break; + QList<drmModeModeInfo> modes; + qCDebug(qLcEglfsKmsDebug) << connectorName << "mode count:" << connector->count_modes; + for (int i = 0; i < connector->count_modes; i++) { + const drmModeModeInfo &mode = connector->modes[i]; + qCDebug(qLcEglfsKmsDebug) << "mode" << i << mode.hdisplay << "x" << mode.vdisplay + << "@" << mode.vrefresh << "hz"; + modes << connector->modes[i]; + } + + int preferred = -1; + int current = -1; + int configured = -1; + int best = -1; + + for (int i = modes.size() - 1; i >= 0; i--) { + const drmModeModeInfo &m = modes.at(i); + + if (configuration == OutputConfigMode && + m.hdisplay == configurationSize.width() && + m.vdisplay == configurationSize.height()) { + configured = i; } + + if (!memcmp(&crtc_mode, &m, sizeof m)) + current = i; + + if (m.type & DRM_MODE_TYPE_PREFERRED) + preferred = i; + + best = i; } - if (crtc == 0) - qFatal("No suitable CRTC available"); + if (configuration == OutputConfigModeline) { + modes << configurationModeline; + configured = modes.size() - 1; + } - m_drm_connector = connector; - m_drm_encoder = encoder; - m_drm_mode = connector->modes[0]; - m_drm_crtc = crtc; + if (current < 0 && crtc_mode.clock != 0) { + modes << crtc_mode; + current = mode.size() - 1; + } - drmModeFreeResources(resources); + if (configuration == OutputConfigCurrent) + configured = current; + + int selected_mode = -1; + + if (configured >= 0) + selected_mode = configured; + else if (preferred >= 0) + selected_mode = preferred; + else if (current >= 0) + selected_mode = current; + else if (best >= 0) + selected_mode = best; + + if (selected_mode < 0) { + qWarning() << "No modes available for output" << connectorName; + return Q_NULLPTR; + } else { + int width = modes[selected_mode].hdisplay; + int height = modes[selected_mode].vdisplay; + int refresh = modes[selected_mode].vrefresh; + qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height + << "@" << refresh << "hz for output" << connectorName; + } + + QEglFSKmsOutput output = { + connectorName, + connector->connector_id, + crtc_id, + QSizeF(connector->mmWidth, connector->mmHeight), + selected_mode, + false, + drmModeGetCrtc(m_dri_fd, crtc_id), + modes + }; + + m_crtc_allocator |= (1 << output.crtc_id); + m_connector_allocator |= (1 << output.connector_id); + + return new QEglFSKmsScreen(this, output, pos); +} + +void QEglFSKmsDevice::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) +{ + Q_UNUSED(fd); + Q_UNUSED(sequence); + Q_UNUSED(tv_sec); + Q_UNUSED(tv_usec); + + QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(user_data); + screen->flipFinished(); +} + +QEglFSKmsDevice::QEglFSKmsDevice(const QString &path) + : m_path(path) + , m_dri_fd(-1) + , m_gbm_device(Q_NULLPTR) + , m_crtc_allocator(0) + , m_connector_allocator(0) +{ +} + +bool QEglFSKmsDevice::open() +{ + Q_ASSERT(m_dri_fd == -1); + Q_ASSERT(m_gbm_device == Q_NULLPTR); + + qCDebug(qLcEglfsKmsDebug) << "Opening device" << m_path; + m_dri_fd = qt_safe_open(m_path.toLocal8Bit().constData(), O_RDWR | O_CLOEXEC); + if (m_dri_fd == -1) { + qErrnoWarning("Could not open DRM device %s", qPrintable(m_path)); + return false; + } + + qCDebug(qLcEglfsKmsDebug) << "Creating GBM device for file descriptor" << m_dri_fd + << "obtained from" << m_path; + m_gbm_device = gbm_create_device(m_dri_fd); + if (!m_gbm_device) { + qErrnoWarning("Could not create GBM device"); + qt_safe_close(m_dri_fd); + m_dri_fd = -1; + return false; + } return true; } + +void QEglFSKmsDevice::close() +{ + if (m_gbm_device) { + gbm_device_destroy(m_gbm_device); + m_gbm_device = Q_NULLPTR; + } + + if (m_dri_fd != -1) { + qt_safe_close(m_dri_fd); + m_dri_fd = -1; + } +} + +void QEglFSKmsDevice::createScreens() +{ + drmModeResPtr resources = drmModeGetResources(m_dri_fd); + if (!resources) { + qWarning("drmModeGetResources failed"); + return; + } + + QPoint pos(0, 0); + QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration()); + + for (int i = 0; i < resources->count_connectors; i++) { + drmModeConnectorPtr connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]); + if (!connector) + continue; + + QEglFSKmsScreen *screen = screenForConnector(resources, connector, pos); + if (screen) { + integration->addScreen(screen); + pos.rx() += screen->geometry().width(); + } + + drmModeFreeConnector(connector); + } + + drmModeFreeResources(resources); +} + +gbm_device *QEglFSKmsDevice::device() const +{ + return m_gbm_device; +} + +int QEglFSKmsDevice::fd() const +{ + return m_dri_fd; +} + +void QEglFSKmsDevice::handleDrmEvent() +{ + drmEventContext drmEvent = { + DRM_EVENT_CONTEXT_VERSION, + Q_NULLPTR, // vblank handler + pageFlipHandler // page flip handler + }; + + drmHandleEvent(m_dri_fd, &drmEvent); +} + +#include "qeglfshooks_kms.moc" diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index 26d77a2abb..1b042a0743 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -32,9 +32,13 @@ ****************************************************************************/ #include "qeglfshooks.h" +#include "qeglfsintegration.h" +#include "qeglfsscreen.h" + #include <QtPlatformSupport/private/qeglplatformcursor_p.h> #include <QtPlatformSupport/private/qeglconvenience_p.h> #include <QtCore/QRegularExpression> +#include <QtGui/private/qguiapplication_p.h> #if defined(Q_OS_LINUX) #include <fcntl.h> @@ -96,6 +100,18 @@ EGLNativeDisplayType QEglFSHooks::platformDisplay() const return EGL_DEFAULT_DISPLAY; } +void QEglFSHooks::screenInit() +{ + QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration()); + integration->addScreen(new QEglFSScreen(integration->display())); +} + +void QEglFSHooks::screenDestroy() +{ + while (!qApp->screens().isEmpty()) + delete qApp->screens().last()->handle(); +} + QSizeF QEglFSHooks::physicalScreenSize() const { return q_physicalScreenSizeFromFb(framebuffer, screenSize()); @@ -139,7 +155,7 @@ QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) { QSurfaceFormat format = inputFormat; - static const bool force888 = qgetenv("QT_QPA_EGLFS_FORCE888").toInt(); + static const bool force888 = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCE888"); if (force888) { format.setRedBufferSize(8); format.setGreenBufferSize(8); @@ -164,6 +180,12 @@ EGLNativeWindowType QEglFSHooks::createNativeWindow(QPlatformWindow *platformWin return 0; } +EGLNativeWindowType QEglFSHooks::createNativeOffscreenWindow(const QSurfaceFormat &format) +{ + Q_UNUSED(format); + return 0; +} + void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window) { Q_UNUSED(window); @@ -175,15 +197,17 @@ bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const return false; } -QEGLPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const +QPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const { return new QEGLPlatformCursor(screen); } -void QEglFSHooks::waitForVSync() const +void QEglFSHooks::waitForVSync(QPlatformSurface *surface) const { + Q_UNUSED(surface); + #if defined(FBIO_WAITFORVSYNC) - static const bool forceSync = qgetenv("QT_QPA_EGLFS_FORCEVSYNC").toInt(); + static const bool forceSync = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCEVSYNC"); if (forceSync && framebuffer != -1) { int arg = 0; if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1) @@ -192,6 +216,16 @@ void QEglFSHooks::waitForVSync() const #endif } +void QEglFSHooks::presentBuffer(QPlatformSurface *surface) +{ + Q_UNUSED(surface); +} + +bool QEglFSHooks::supportsPBuffers() const +{ + return true; +} + #ifndef EGLFS_PLATFORM_HOOKS QEglFSHooks stubHooks; #endif diff --git a/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp b/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp index b16857297c..c026546ced 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp @@ -265,7 +265,7 @@ QSize QEglFSX11Hooks::screenSize() const m_screenSize = QSize(env.at(0).toInt(), env.at(1).toInt()); } else { m_screenSize = QSize(640, 480); - qDebug("EGLFS_X11_SIZE not set, falling back to 640x480"); + qWarning("EGLFS_X11_SIZE not set, falling back to 640x480"); } } return m_screenSize; @@ -313,7 +313,7 @@ EGLNativeWindowType QEglFSX11Hooks::createNativeWindow(QPlatformWindow *platform xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window, m_atoms[Atoms::WM_PROTOCOLS], XCB_ATOM_ATOM, 32, 1, &m_atoms[Atoms::WM_DELETE_WINDOW]); - if (qgetenv("EGLFS_X11_FULLSCREEN").toInt()) { + if (qEnvironmentVariableIntValue("EGLFS_X11_FULLSCREEN")) { // Go fullscreen. The QScreen and QWindow size is controlled by EGLFS_X11_SIZE regardless, // this is just the native window. xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window, diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2a4eae3fe2..ffae64d31c 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -36,6 +36,7 @@ #include "qeglfswindow.h" #include "qeglfshooks.h" #include "qeglfscontext.h" +#include "qeglfsoffscreenwindow.h" #include <QtGui/private/qguiapplication_p.h> @@ -62,16 +63,11 @@ QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() { - mDisableInputHandlers = qgetenv("QT_QPA_EGLFS_DISABLE_INPUT").toInt(); + mDisableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT"); initResources(); } -QEglFSIntegration::~QEglFSIntegration() -{ - QEglFSHooks::hooks()->platformDestroy(); -} - bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const { // We assume that devices will have more and not less capabilities @@ -81,6 +77,11 @@ bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) cons return QEGLPlatformIntegration::hasCapability(cap); } +void QEglFSIntegration::addScreen(QPlatformScreen *screen) +{ + screenAdded(screen); +} + void QEglFSIntegration::initialize() { QEglFSHooks::hooks()->platformInit(); @@ -89,16 +90,20 @@ void QEglFSIntegration::initialize() if (!mDisableInputHandlers) createInputHandlers(); + + QEglFSHooks::hooks()->screenInit(); } -EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const +void QEglFSIntegration::destroy() { - return QEglFSHooks::hooks()->platformDisplay(); + QEglFSHooks::hooks()->screenDestroy(); + QEGLPlatformIntegration::destroy(); + QEglFSHooks::hooks()->platformDestroy(); } -QEGLPlatformScreen *QEglFSIntegration::createScreen() const +EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const { - return new QEglFSScreen(display()); + return QEglFSHooks::hooks()->platformDisplay(); } QEGLPlatformWindow *QEglFSIntegration::createWindow(QWindow *window) const @@ -115,9 +120,9 @@ QEGLPlatformContext *QEglFSIntegration::createContext(const QSurfaceFormat &form QSurfaceFormat adjustedFormat = QEglFSHooks::hooks()->surfaceFormatFor(format); if (!nativeHandle || nativeHandle->isNull()) { EGLConfig config = QEglFSIntegration::chooseConfig(display, adjustedFormat); - ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant()); + ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant()); } else { - ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle); + ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle); } *nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), display)); return ctx; @@ -127,18 +132,13 @@ QPlatformOffscreenSurface *QEglFSIntegration::createOffscreenSurface(EGLDisplay const QSurfaceFormat &format, QOffscreenSurface *surface) const { - return new QEGLPbuffer(display, QEglFSHooks::hooks()->surfaceFormatFor(format), surface); -} + QSurfaceFormat fmt = QEglFSHooks::hooks()->surfaceFormatFor(format); + if (QEglFSHooks::hooks()->supportsPBuffers()) + return new QEGLPbuffer(display, fmt, surface); + else + return new QEglFSOffscreenWindow(display, fmt, surface); -QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const -{ - switch (hint) - { - case QPlatformIntegration::ShowIsFullScreen: - return screen()->compositingWindow() == 0; - default: - return QPlatformIntegration::styleHint(hint); - } + // Never return null. Multiple QWindows are not supported by this plugin. } EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format) diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h index d612a270f2..86038910ca 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -44,17 +44,17 @@ class QEglFSIntegration : public QEGLPlatformIntegration { public: QEglFSIntegration(); - ~QEglFSIntegration(); + + void addScreen(QPlatformScreen *screen); void initialize() Q_DECL_OVERRIDE; + void destroy() Q_DECL_OVERRIDE; bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE; - QVariant styleHint(QPlatformIntegration::StyleHint hint) const Q_DECL_OVERRIDE; static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format); protected: - QEGLPlatformScreen *createScreen() const Q_DECL_OVERRIDE; QEGLPlatformWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE; QEGLPlatformContext *createContext(const QSurfaceFormat &format, QPlatformOpenGLContext *shareContext, diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp new file mode 100644 index 0000000000..0e8e3957d0 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qeglfsoffscreenwindow.h" +#include "qeglfshooks.h" +#include <QtGui/QOffscreenSurface> +#include <QtPlatformSupport/private/qeglconvenience_p.h> + +QT_BEGIN_NAMESPACE + +/* + In some cases pbuffers are not available. Triggering QtGui's built-in + fallback for a hidden QWindow is not suitable for eglfs since this would be + treated as an attempt to create multiple top-level, native windows. + + Therefore this class is provided as an alternative to QEGLPbuffer. + + This class requires the hooks to implement createNativeOffscreenWindow(). +*/ + +QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface) + : QPlatformOffscreenSurface(offscreenSurface) + , m_format(format) + , m_display(display) + , m_surface(EGL_NO_SURFACE) + , m_window(0) +{ + m_window = QEglFSHooks::hooks()->createNativeOffscreenWindow(format); + if (!m_window) { + qWarning("QEglFSOffscreenWindow: Failed to create native window"); + return; + } + EGLConfig config = q_configFromGLFormat(m_display, m_format); + m_surface = eglCreateWindowSurface(m_display, config, m_window, 0); + if (m_surface != EGL_NO_SURFACE) + m_format = q_glFormatFromConfig(m_display, config); +} + +QEglFSOffscreenWindow::~QEglFSOffscreenWindow() +{ + if (m_surface != EGL_NO_SURFACE) + eglDestroySurface(m_display, m_surface); + if (m_window) + QEglFSHooks::hooks()->destroyNativeWindow(m_window); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h new file mode 100644 index 0000000000..8bd4089c34 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLFSOFFSCREENWINDOW_H +#define QEGLFSOFFSCREENWINDOW_H + +#include <EGL/egl.h> +#include <qpa/qplatformoffscreensurface.h> + +QT_BEGIN_NAMESPACE + +class QEglFSOffscreenWindow : public QPlatformOffscreenSurface +{ +public: + QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface); + ~QEglFSOffscreenWindow(); + + QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; } + bool isValid() const Q_DECL_OVERRIDE { return m_surface != EGL_NO_SURFACE; } + +private: + QSurfaceFormat m_format; + EGLDisplay m_display; + EGLSurface m_surface; + EGLNativeWindowType m_window; +}; + +QT_END_NAMESPACE + +#endif // QEGLFSOFFSCREENWINDOW_H diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index cd68540581..60f7347ba5 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -34,7 +34,7 @@ #include "qeglfsscreen.h" #include "qeglfswindow.h" #include "qeglfshooks.h" -#include <QtPlatformSupport/private/qeglplatformcursor_p.h> +#include <QtGui/qpa/qplatformcursor.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h index 132646d7a6..c5ab3b52f5 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.h +++ b/src/plugins/platforms/eglfs/qeglfsscreen.h @@ -42,7 +42,6 @@ QT_BEGIN_NAMESPACE -class QEGLPlatformCursor; class QEglFSWindow; class QOpenGLContext; @@ -78,7 +77,7 @@ private: friend class QEglFSWindow; EGLSurface m_surface; - QEGLPlatformCursor *m_cursor; + QPlatformCursor *m_cursor; QEGLPlatformWindow *m_rootWindow; QOpenGLContext *m_rootContext; }; diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index f5839e086d..59c2014d66 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -116,7 +116,7 @@ void QEglFSWindow::destroy() { QEglFSScreen *screen = this->screen(); if (m_flags.testFlag(HasNativeWindow)) { - QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->cursor()); + QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(screen->cursor()); if (cursor) cursor->resetResources(); @@ -147,8 +147,9 @@ void QEglFSWindow::invalidateSurface() void QEglFSWindow::resetSurface() { - EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display(); - m_window = QEglFSHooks::hooks()->createNativeWindow(this, QEglFSHooks::hooks()->screenSize(), m_format); + QEglFSScreen *nativeScreen = static_cast<QEglFSScreen *>(screen()); + EGLDisplay display = nativeScreen->display(); + m_window = QEglFSHooks::hooks()->createNativeWindow(this, nativeScreen->geometry().size(), m_format); m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL); if (m_surface == EGL_NO_SURFACE) { EGLint error = eglGetError(); diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm index 63b6827ad3..3dff271d00 100644 --- a/src/plugins/platforms/ios/quiaccessibilityelement.mm +++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm @@ -193,4 +193,33 @@ action->doAction(QAccessibleActionInterface::decreaseAction()); } +- (BOOL) accessibilityScroll : (UIAccessibilityScrollDirection) direction +{ + QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid); + QAccessibleActionInterface *action = iface->actionInterface(); + if (!action) + return NO; + switch (direction) { + case UIAccessibilityScrollDirectionRight: + action->doAction(QAccessibleActionInterface::scrollRightAction()); + return YES; + case UIAccessibilityScrollDirectionLeft: + action->doAction(QAccessibleActionInterface::scrollLeftAction()); + return YES; + case UIAccessibilityScrollDirectionUp: + action->doAction(QAccessibleActionInterface::scrollUpAction()); + return YES; + case UIAccessibilityScrollDirectionDown: + action->doAction(QAccessibleActionInterface::scrollDownAction()); + return YES; + case UIAccessibilityScrollDirectionNext: + action->doAction(QAccessibleActionInterface::nextPageAction()); + return YES; + case UIAccessibilityScrollDirectionPrevious: + action->doAction(QAccessibleActionInterface::previousPageAction()); + return YES; + } + return NO; +} + @end diff --git a/src/plugins/platforms/kms/qkmsscreen.cpp b/src/plugins/platforms/kms/qkmsscreen.cpp index ddcdd10928..84c1eba448 100644 --- a/src/plugins/platforms/kms/qkmsscreen.cpp +++ b/src/plugins/platforms/kms/qkmsscreen.cpp @@ -216,7 +216,7 @@ void QKmsScreen::performPageFlip() // Initialize cursor - static int hideCursor = qgetenv("QT_QPA_KMS_HIDECURSOR").toInt(); + static int hideCursor = qEnvironmentVariableIntValue("QT_QPA_KMS_HIDECURSOR"); if (!hideCursor) { QCursor cursor(Qt::ArrowCursor); m_cursor->changeCursor(&cursor, 0); diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 252f842df4..6bd9d8c96d 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -66,7 +66,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters) , m_options(parseOptions(parameters)) { if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable) - && qgetenv(debugBackingStoreEnvironmentVariable).toInt() > 0) { + && qEnvironmentVariableIntValue(debugBackingStoreEnvironmentVariable) > 0) { m_options |= DebugBackingStore | EnableFonts; } diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index 09736304e1..7133d01e87 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -164,7 +164,7 @@ EGLenum QQnxGLContext::checkEGLError(const char *msg) return error; } -void QQnxGLContext::initialize() +void QQnxGLContext::initializeContext() { qGLContextDebug() << Q_FUNC_INFO; @@ -182,7 +182,7 @@ void QQnxGLContext::initialize() } } -void QQnxGLContext::shutdown() +void QQnxGLContext::shutdownContext() { qGLContextDebug() << Q_FUNC_INFO; diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h index 090c7ed49d..a91a89901f 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.h +++ b/src/plugins/platforms/qnx/qqnxglcontext.h @@ -53,8 +53,8 @@ public: static EGLenum checkEGLError(const char *msg); - static void initialize(); - static void shutdown(); + static void initializeContext(); + static void shutdownContext(); void requestSurfaceChange(); diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 34b79b61da..6a3cd902af 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -182,7 +182,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) #if !defined(QT_NO_OPENGL) // Initialize global OpenGL resources - QQnxGLContext::initialize(); + QQnxGLContext::initializeContext(); #endif // Create/start event thread @@ -306,7 +306,7 @@ QQnxIntegration::~QQnxIntegration() #if !defined(QT_NO_OPENGL) // Cleanup global OpenGL resources - QQnxGLContext::shutdown(); + QQnxGLContext::shutdownContext(); #endif #if defined(QQNX_PPS) diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index f3f93e7f64..04a6611cc4 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -305,7 +305,7 @@ static int defaultDepth() if (defaultDepth == 0) { // check if display depth was specified in environment variable; // use default value if no valid value found - defaultDepth = qgetenv("QQNX_DISPLAY_DEPTH").toInt(); + defaultDepth = qEnvironmentVariableIntValue("QQNX_DISPLAY_DEPTH"); if (defaultDepth != 16 && defaultDepth != 32) defaultDepth = 32; } @@ -679,7 +679,7 @@ void QQnxScreen::adjustOrientation() return; bool ok = false; - const int rotation = qgetenv("ORIENTATION").toInt(&ok); + const int rotation = qEnvironmentVariableIntValue("ORIENTATION", &ok); if (ok) setRotation(rotation); @@ -858,7 +858,7 @@ void QQnxScreen::setRootWindow(QQnxWindow *window) { // Optionally disable the screen power save bool ok = false; - const int disablePowerSave = qgetenv("QQNX_DISABLE_POWER_SAVE").toInt(&ok); + const int disablePowerSave = qEnvironmentVariableIntValue("QQNX_DISABLE_POWER_SAVE", &ok); if (ok && disablePowerSave) { const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE; int result = screen_set_window_property_iv(window->nativeHandle(), SCREEN_PROPERTY_IDLE_MODE, &mode); diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h index 351bf2555c..f7f5e022c3 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.h +++ b/src/plugins/platforms/windows/accessible/iaccessible2.h @@ -39,24 +39,7 @@ #include "qwindowsmsaaaccessible.h" #include "comutils.h" -#include "Accessible2.h" -#include "AccessibleAction.h" -#include "AccessibleApplication.h" -#include "AccessibleComponent.h" -#include "AccessibleEditableText.h" -#include "AccessibleHyperlink.h" -#include "AccessibleHypertext.h" -#include "AccessibleImage.h" -#include "AccessibleRelation.h" -#include "AccessibleTable.h" -#include "AccessibleTable2.h" -#include "AccessibleTableCell.h" -#include "AccessibleText.h" -#include "AccessibleValue.h" - -#include "AccessibleEventID.h" -#include "AccessibleRole.h" -#include "AccessibleStates.h" +#include "ia2_api_all.h" #include <servprov.h> diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h index a78d821b1d..c522cf281e 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h @@ -42,7 +42,7 @@ #include <QtGui/qaccessible.h> #ifndef Q_CC_MINGW # include <oleacc.h> -# include "Accessible2.h" // IAccessible2 inherits from IAccessible +# include "ia2_api_all.h" // IAccessible2 inherits from IAccessible #else // MinGW # include <basetyps.h> diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index d8ccb8cd56..e6f30f2c35 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -1181,19 +1181,13 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo return QImage(); } - QImage indexed(mask->width(), mask->height(), QImage::Format_Indexed8); + QImage alphaMap(mask->width(), mask->height(), QImage::Format_Alpha8); - // ### This part is kinda pointless, but we'll crash later if we don't because some - // code paths expects there to be colortables for index8-bit... - QVector<QRgb> colors(256); - for (int i=0; i<256; ++i) - colors[i] = qRgba(0, 0, 0, i); - indexed.setColorTable(colors); // Copy data... Cannot use QPainter here as GDI has messed up the // Alpha channel of the ni.image pixels... for (int y=0; y<mask->height(); ++y) { - uchar *dest = indexed.scanLine(y); + uchar *dest = alphaMap.scanLine(y); if (mask->image().format() == QImage::Format_RGB16) { const qint16 *src = (qint16 *) ((const QImage &) mask->image()).scanLine(y); for (int x=0; x<mask->width(); ++x) @@ -1215,7 +1209,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo DeleteObject(font); } - return indexed; + return alphaMap; } #define SPI_GETFONTSMOOTHINGCONTRAST 0x200C diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 648f68bb19..f8747a741e 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -485,15 +485,11 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub { QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform()); - QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); - QVector<QRgb> colors(256); - for (int i=0; i<256; ++i) - colors[i] = qRgba(0, 0, 0, i); - indexed.setColorTable(colors); + QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8); for (int y=0; y<im.height(); ++y) { uint *src = (uint*) im.scanLine(y); - uchar *dst = indexed.scanLine(y); + uchar *dst = alphaMap.scanLine(y); for (int x=0; x<im.width(); ++x) { *dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.); ++dst; @@ -501,7 +497,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub } } - return indexed; + return alphaMap; } bool QWindowsFontEngineDirectWrite::supportsSubPixelPositions() const diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index bc8e9347dc..42f4e66d6c 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -343,10 +343,11 @@ static bool setData(const QByteArray &data, STGMEDIUM *pmedium) return true; } -static QByteArray getData(int cf, IDataObject *pDataObj) +static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1) { QByteArray data; FORMATETC formatetc = setCf(cf); + formatetc.lindex = lindex; STGMEDIUM s; if (pDataObj->GetData(&formatetc, &s) == S_OK) { DWORD * val = (DWORD*)GlobalLock(s.hGlobal); @@ -791,7 +792,6 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD { if (mimeType == QLatin1String("text/uri-list")) { if (canGetData(CF_HDROP, pDataObj)) { - QByteArray texturi; QList<QVariant> urls; QByteArray data = getData(CF_HDROP, pDataObj); @@ -1340,21 +1340,34 @@ static bool isCustomMimeType(const QString &mimeType) return mimeType.startsWith(QLatin1String(x_qt_windows_mime), Qt::CaseInsensitive); } -static QString customMimeType(const QString &mimeType) +static QString customMimeType(const QString &mimeType, int *lindex = 0) { int len = sizeof(x_qt_windows_mime) - 1; - int n = mimeType.lastIndexOf(QLatin1Char('\"'))-len; - return mimeType.mid(len, n); + int n = mimeType.lastIndexOf(QLatin1Char('\"')) - len; + QString ret = mimeType.mid(len, n); + + const int beginPos = mimeType.indexOf(QLatin1String(";index=")); + if (beginPos > -1) { + const int endPos = mimeType.indexOf(QLatin1Char(';'), beginPos + 1); + const int indexStartPos = beginPos + 7; + if (lindex) + *lindex = mimeType.midRef(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt(); + } else { + if (lindex) + *lindex = -1; + } + return ret; } bool QLastResortMimes::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { if (isCustomMimeType(mimeType)) { + // MSDN documentation for QueryGetData says only -1 is supported, so ignore lindex here. QString clipFormat = customMimeType(mimeType); int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16())); return canGetData(cf, pDataObj); } else if (formats.keys(mimeType).isEmpty()) { - // if it is not in there then register it an see if we can get it + // if it is not in there then register it and see if we can get it int cf = QWindowsMime::registerMimeType(mimeType); return canGetData(cf, pDataObj); } else { @@ -1370,9 +1383,10 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p if (canConvertToMime(mimeType, pDataObj)) { QByteArray data; if (isCustomMimeType(mimeType)) { - QString clipFormat = customMimeType(mimeType); + int lindex; + QString clipFormat = customMimeType(mimeType, &lindex); int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16())); - data = getData(cf, pDataObj); + data = getData(cf, pDataObj, lindex); } else if (formats.keys(mimeType).isEmpty()) { int cf = QWindowsMime::registerMimeType(mimeType); data = getData(cf, pDataObj); @@ -1452,6 +1466,7 @@ QWindowsMime * QWindowsMimeConverter::converterToMime(const QString &mimeType, I QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) const { + qCDebug(lcQpaMime) << "QWindowsMime::allMimesForFormats()"; ensureInitialized(); QStringList formats; LPENUMFORMATETC FAR fmtenum; @@ -1461,10 +1476,9 @@ QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) con FORMATETC fmtetc; while (S_OK == fmtenum->Next(1, &fmtetc, 0)) { #if defined(QMIME_DEBUG) - qDebug("QWindowsMime::allMimesForFormats()"); wchar_t buf[256] = {0}; GetClipboardFormatName(fmtetc.cfFormat, buf, 255); - qDebug("CF = %d : %s", fmtetc.cfFormat, QString::fromWCharArray(buf)); + qDebug("CF = %d : %s", fmtetc.cfFormat, qPrintable(QString::fromWCharArray(buf))); #endif for (int i= m_mimes.size() - 1; i >= 0; --i) { QString format = m_mimes.at(i)->mimeForFormat(fmtetc); @@ -1478,7 +1492,7 @@ QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) con } fmtenum->Release(); } - qCDebug(lcQpaMime) << __FUNCTION__ << pDataObj << formats; + qCDebug(lcQpaMime) << pDataObj << formats; return formats; } diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index f64b47960a..339a658c3e 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -170,7 +170,7 @@ QWinRTTheme::QWinRTTheme() bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const { static bool useNativeDialogs = qEnvironmentVariableIsSet("QT_USE_WINRT_NATIVE_DIALOGS") - ? qgetenv("QT_USE_WINRT_NATIVE_DIALOGS").toInt() : true; + ? qEnvironmentVariableIntValue("QT_USE_WINRT_NATIVE_DIALOGS") : true; if (type == FileDialog || type == MessageDialog) return useNativeDialogs; diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8bdedba8ac..def6e2ce9a 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -320,7 +320,7 @@ QDpi QXcbScreen::logicalDpi() const qreal QXcbScreen::devicePixelRatio() const { - static int override_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt(); + static int override_dpr = qEnvironmentVariableIntValue("QT_DEVICE_PIXEL_RATIO"); static bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"; if (override_dpr > 0) return override_dpr; diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index d1cbff59c1..587063b100 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -3,5 +3,6 @@ TEMPLATE = subdirs SUBDIRS *= sqldrivers !winrt:qtHaveModule(network): SUBDIRS += bearer qtHaveModule(gui): SUBDIRS *= imageformats platforms platforminputcontexts platformthemes generic +qtHaveModule(widgets): SUBDIRS *= styles !winrt:!wince*:qtHaveModule(widgets):SUBDIRS += printsupport diff --git a/src/plugins/styles/bb10style/bb10lightstyle.qrc b/src/plugins/styles/bb10style/bb10lightstyle.qrc new file mode 100644 index 0000000000..0777e009bb --- /dev/null +++ b/src/plugins/styles/bb10style/bb10lightstyle.qrc @@ -0,0 +1,54 @@ +<RCC> + <qresource prefix="/"> + <file>light/button/core_button_disabled.png</file> + <file>light/button/core_button_inactive.png</file> + <file>light/button/core_button_pressed.png</file> + <file>light/checkbox/core_checkbox_checked.png</file> + <file>light/checkbox/core_checkbox_disabled.png</file> + <file>light/checkbox/core_checkbox_disabledchecked.png</file> + <file>light/checkbox/core_checkbox_enabled.png</file> + <file>light/checkbox/core_checkbox_pressed.png</file> + <file>light/checkbox/core_checkbox_pressedchecked.png</file> + <file>light/radiobutton/core_radiobutton_checked.png</file> + <file>light/radiobutton/core_radiobutton_disabled.png</file> + <file>light/radiobutton/core_radiobutton_disabledchecked.png</file> + <file>light/radiobutton/core_radiobutton_enabled.png</file> + <file>light/radiobutton/core_radiobutton_pressed.png</file> + <file>light/slider/core_slider_active.png</file> + <file>light/slider/core_slider_disabled.png</file> + <file>light/slider/core_slider_handle.png</file> + <file>light/slider/core_slider_handle_disabled.png</file> + <file>light/slider/core_slider_handle_pressed.png</file> + <file>light/slider/core_slider_inactive.png</file> + <file>light/slider/core_slider_vactive.png</file> + <file>light/slider/core_slider_vdisabled.png</file> + <file>light/slider/core_slider_vinactive.png</file> + <file>light/slider/core_slider_black.png</file> + <file>light/slider/core_slider_enabled.png</file> + <file>light/slider/core_slider_vblack.png</file> + <file>light/slider/core_slider_venabled.png</file> + <file>light/button/core_button_active.png</file> + <file>light/lineedit/core_textinput_bg.png</file> + <file>light/lineedit/core_textinput_bg_disabled.png</file> + <file>light/lineedit/core_textinput_bg_focused.png</file> + <file>light/progressbar/core_progressindicator_bg.png</file> + <file>light/progressbar/core_progressindicator_complete.png</file> + <file>light/progressbar/core_progressindicator_fill.png</file> + <file>light/progressbar/core_progressindicator_vbg.png</file> + <file>light/progressbar/core_progressindicator_vcomplete.png</file> + <file>light/progressbar/core_progressindicator_vfill.png</file> + <file>light/combobox/core_dropdown_button.png</file> + <file>light/combobox/core_dropdown_button_arrowdown.png</file> + <file>light/combobox/core_dropdown_button_arrowdown_pressed.png</file> + <file>light/combobox/core_dropdown_button_arrowup.png</file> + <file>light/combobox/core_dropdown_button_disabled.png</file> + <file>light/combobox/core_dropdown_button_pressed.png</file> + <file>light/combobox/core_dropdown_checkmark.png</file> + <file>light/combobox/core_dropdown_divider.png</file> + <file>light/combobox/core_dropdown_menu.png</file> + <file>light/combobox/core_dropdown_menuup.png</file> + <file>light/combobox/core_listitem_active.png</file> + <file>light/listitem/core_listitem_active.png</file> + <file>light/listitem/core_listitem_divider.png</file> + </qresource> +</RCC> diff --git a/src/plugins/styles/bb10style/bb10style.pro b/src/plugins/styles/bb10style/bb10style.pro new file mode 100644 index 0000000000..ad35df6de7 --- /dev/null +++ b/src/plugins/styles/bb10style/bb10style.pro @@ -0,0 +1,28 @@ +TARGET = bb10styleplugin + +PLUGIN_TYPE = styles +PLUGIN_CLASS_NAME = BlackBerry10StylePlugin +load(qt_plugin) + +INCLUDEPATH += $$PWD + +QT += widgets + +HEADERS += \ + qpixmapstyle.h \ + qbb10brightstyle.h \ + qbb10darkstyle.h \ + qbb10styleplugin.h + +SOURCES += \ + qpixmapstyle.cpp \ + qbb10brightstyle.cpp \ + qbb10darkstyle.cpp \ + qbb10styleplugin.cpp + +RESOURCES += \ + qbb10brightstyle.qrc \ + qbb10darkstyle.qrc + +OTHER_FILES += qbb10styleplugin.json + diff --git a/src/plugins/styles/bb10style/bright/button/core_button_disabled.png b/src/plugins/styles/bb10style/bright/button/core_button_disabled.png Binary files differnew file mode 100644 index 0000000000..578a2383b8 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/button/core_button_disabled.png diff --git a/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png b/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png Binary files differnew file mode 100644 index 0000000000..7cd998af46 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png diff --git a/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png b/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png Binary files differnew file mode 100644 index 0000000000..ff0850f616 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png diff --git a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png Binary files differnew file mode 100755 index 0000000000..7769f15e44 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png diff --git a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png Binary files differnew file mode 100755 index 0000000000..59b5bfa7c2 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png Binary files differnew file mode 100644 index 0000000000..c59f60633c --- /dev/null +++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png Binary files differnew file mode 100644 index 0000000000..49d9cfdf94 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png Binary files differnew file mode 100644 index 0000000000..35751553e1 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png Binary files differnew file mode 100644 index 0000000000..2a0c56b503 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png Binary files differnew file mode 100755 index 0000000000..f1c2ee3bed --- /dev/null +++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png Binary files differnew file mode 100644 index 0000000000..d58df47cbf --- /dev/null +++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png Binary files differnew file mode 100644 index 0000000000..1aa844309f --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png Binary files differnew file mode 100644 index 0000000000..9ac049fb3d --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png Binary files differnew file mode 100644 index 0000000000..d11af56b71 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png Binary files differnew file mode 100644 index 0000000000..d10779d8d7 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png Binary files differnew file mode 100644 index 0000000000..f9e1c9465b --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png Binary files differnew file mode 100644 index 0000000000..27a321e387 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png Binary files differnew file mode 100644 index 0000000000..a8270aed56 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png Binary files differnew file mode 100644 index 0000000000..0198293ad6 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png Binary files differnew file mode 100644 index 0000000000..47e7b2d4b6 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png Binary files differnew file mode 100644 index 0000000000..2bde84e71d --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png diff --git a/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png b/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png Binary files differnew file mode 100644 index 0000000000..4935d13c05 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png Binary files differnew file mode 100755 index 0000000000..07b8ea21bf --- /dev/null +++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png Binary files differnew file mode 100644 index 0000000000..ab1083e9fa --- /dev/null +++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png Binary files differnew file mode 100755 index 0000000000..55f8aee066 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png Binary files differnew file mode 100755 index 0000000000..34daccc27e --- /dev/null +++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png Binary files differnew file mode 100755 index 0000000000..7a1e22321d --- /dev/null +++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png Binary files differnew file mode 100755 index 0000000000..3ff930dea7 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png Binary files differnew file mode 100644 index 0000000000..87974668ff --- /dev/null +++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png Binary files differnew file mode 100644 index 0000000000..8ff257dad3 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png Binary files differnew file mode 100644 index 0000000000..66cf8cac8f --- /dev/null +++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png Binary files differnew file mode 100644 index 0000000000..f18e0abafb --- /dev/null +++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png Binary files differnew file mode 100644 index 0000000000..94e388a7aa --- /dev/null +++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png Binary files differnew file mode 100644 index 0000000000..5dc5e52d88 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png Binary files differnew file mode 100644 index 0000000000..077aa79c65 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png Binary files differnew file mode 100644 index 0000000000..439499040a --- /dev/null +++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png Binary files differnew file mode 100755 index 0000000000..cb4c6a8136 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png Binary files differnew file mode 100755 index 0000000000..88fd1344d2 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png Binary files differnew file mode 100755 index 0000000000..79154e0568 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png Binary files differnew file mode 100644 index 0000000000..169a4e1656 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_active.png b/src/plugins/styles/bb10style/bright/slider/core_slider_active.png Binary files differnew file mode 100644 index 0000000000..c23c0ebc26 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_active.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png b/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png Binary files differnew file mode 100644 index 0000000000..6b7224d702 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png Binary files differnew file mode 100644 index 0000000000..9de7567e68 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png Binary files differnew file mode 100644 index 0000000000..ad5c35076c --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png Binary files differnew file mode 100644 index 0000000000..076e272794 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png Binary files differnew file mode 100644 index 0000000000..5989fcaaeb --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png Binary files differnew file mode 100755 index 0000000000..8cb79118b9 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png b/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png Binary files differnew file mode 100644 index 0000000000..8836534923 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png Binary files differnew file mode 100644 index 0000000000..03062326f2 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png Binary files differnew file mode 100644 index 0000000000..b0d94d7127 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png Binary files differnew file mode 100644 index 0000000000..ce99b1a3ac --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png b/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png Binary files differnew file mode 100644 index 0000000000..910b6627d4 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png b/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png Binary files differnew file mode 100644 index 0000000000..18a9819af8 --- /dev/null +++ b/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png diff --git a/src/plugins/styles/bb10style/dark/button/core_button_disabled.png b/src/plugins/styles/bb10style/dark/button/core_button_disabled.png Binary files differnew file mode 100644 index 0000000000..79245dbf11 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/button/core_button_disabled.png diff --git a/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png b/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png Binary files differnew file mode 100644 index 0000000000..5eb86b70f3 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png diff --git a/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png b/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png Binary files differnew file mode 100644 index 0000000000..7b1a6ce40b --- /dev/null +++ b/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png diff --git a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png Binary files differnew file mode 100755 index 0000000000..97842e1ac4 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png diff --git a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png Binary files differnew file mode 100755 index 0000000000..c149b64a26 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png Binary files differnew file mode 100644 index 0000000000..5a8af33094 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png Binary files differnew file mode 100644 index 0000000000..74a24522fa --- /dev/null +++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png Binary files differnew file mode 100644 index 0000000000..1e953221b6 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png Binary files differnew file mode 100644 index 0000000000..5e51e7f39b --- /dev/null +++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png Binary files differnew file mode 100755 index 0000000000..507a77b3ea --- /dev/null +++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png Binary files differnew file mode 100644 index 0000000000..7fa85428a0 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png Binary files differnew file mode 100644 index 0000000000..a68d93acb5 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png Binary files differnew file mode 100644 index 0000000000..4c1d085360 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png Binary files differnew file mode 100644 index 0000000000..1ee578e07c --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png Binary files differnew file mode 100644 index 0000000000..3239ef4bd6 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png Binary files differnew file mode 100644 index 0000000000..af6793b87c --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png Binary files differnew file mode 100644 index 0000000000..df6d402554 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png Binary files differnew file mode 100644 index 0000000000..578c80aa5f --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png Binary files differnew file mode 100644 index 0000000000..43b1025d36 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png Binary files differnew file mode 100644 index 0000000000..1f52362050 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png Binary files differnew file mode 100644 index 0000000000..62c7a2e558 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png diff --git a/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png b/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png Binary files differnew file mode 100644 index 0000000000..1df4a7aad9 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png Binary files differnew file mode 100755 index 0000000000..07b8ea21bf --- /dev/null +++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png Binary files differnew file mode 100644 index 0000000000..6bcaf91f87 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png Binary files differnew file mode 100755 index 0000000000..9b115897e8 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png Binary files differnew file mode 100755 index 0000000000..52aa4e4aa2 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png Binary files differnew file mode 100755 index 0000000000..39e3a8a4f5 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png Binary files differnew file mode 100755 index 0000000000..95fcafb437 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png Binary files differnew file mode 100644 index 0000000000..e849c8f179 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png Binary files differnew file mode 100644 index 0000000000..e8fd3b0173 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png Binary files differnew file mode 100644 index 0000000000..1433f3ec33 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png Binary files differnew file mode 100644 index 0000000000..d750e4671c --- /dev/null +++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png Binary files differnew file mode 100644 index 0000000000..2c3c0a5e6c --- /dev/null +++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png Binary files differnew file mode 100644 index 0000000000..1721586ac5 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png Binary files differnew file mode 100644 index 0000000000..e646c9174b --- /dev/null +++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png Binary files differnew file mode 100644 index 0000000000..93b3118e8d --- /dev/null +++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png Binary files differnew file mode 100755 index 0000000000..fd61937d65 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png Binary files differnew file mode 100755 index 0000000000..58a1a57b4c --- /dev/null +++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png Binary files differnew file mode 100755 index 0000000000..384f60758a --- /dev/null +++ b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png Binary files differnew file mode 100644 index 0000000000..2542f2acaf --- /dev/null +++ b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_active.png b/src/plugins/styles/bb10style/dark/slider/core_slider_active.png Binary files differnew file mode 100644 index 0000000000..6bdb413ced --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_active.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png b/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png Binary files differnew file mode 100644 index 0000000000..eea5b3d78e --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png Binary files differnew file mode 100644 index 0000000000..6a233315e4 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png Binary files differnew file mode 100644 index 0000000000..2b297e5ca2 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png Binary files differnew file mode 100644 index 0000000000..fbd37e5584 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png Binary files differnew file mode 100644 index 0000000000..49cb6a42a7 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png Binary files differnew file mode 100755 index 0000000000..803c374015 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png b/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png Binary files differnew file mode 100644 index 0000000000..08a1aecb6c --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png Binary files differnew file mode 100644 index 0000000000..c8e467d9e6 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png Binary files differnew file mode 100644 index 0000000000..ff160cbb1d --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png Binary files differnew file mode 100644 index 0000000000..27d348122b --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png b/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png Binary files differnew file mode 100644 index 0000000000..ff8a74a19f --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png b/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png Binary files differnew file mode 100644 index 0000000000..b2b19a5460 --- /dev/null +++ b/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png diff --git a/src/plugins/styles/bb10style/qbb10brightstyle.cpp b/src/plugins/styles/bb10style/qbb10brightstyle.cpp new file mode 100644 index 0000000000..8e6da406ea --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10brightstyle.cpp @@ -0,0 +1,352 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbb10brightstyle.h" + +#include <QApplication> +#include <QFont> +#include <QStyleOption> +#include <QProgressBar> +#include <QComboBox> +#include <QAbstractItemView> +#include <QPainter> + +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<QProgressBar*>(widget)) + pb->setTextVisible(false); + + if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) { + QAbstractItemView *list = cb->view(); + QPalette p = list->palette(); + p.setBrush(QPalette::HighlightedText, p.brush(QPalette::Text)); + list->setPalette(p); + } + + if (qobject_cast<QAbstractItemView*>(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<const QStyleOptionButton*>(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 --git a/src/plugins/styles/bb10style/qbb10brightstyle.h b/src/plugins/styles/bb10style/qbb10brightstyle.h new file mode 100644 index 0000000000..4a63b1dc48 --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10brightstyle.h @@ -0,0 +1,70 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBB10BRIGHTSTYLE_H +#define QBB10BRIGHTSTYLE_H + +#include "qpixmapstyle.h" + +QT_BEGIN_NAMESPACE + +class QBB10BrightStyle : public QPixmapStyle +{ + Q_OBJECT + +public: + QBB10BrightStyle(); + ~QBB10BrightStyle(); + + void polish(QApplication *application); + void polish(QWidget *widget); + + QPalette standardPalette() const; + + void drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; +}; + +QT_END_NAMESPACE + +#endif // QBB10BRIGHTSTYLE_H diff --git a/src/plugins/styles/bb10style/qbb10brightstyle.qrc b/src/plugins/styles/bb10style/qbb10brightstyle.qrc new file mode 100644 index 0000000000..2172536fa3 --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10brightstyle.qrc @@ -0,0 +1,57 @@ +<RCC> + <qresource prefix="/"> + <file>bright/button/core_button_disabled.png</file> + <file>bright/button/core_button_disabled_selected.png</file> + <file>bright/button/core_button_inactive.png</file> + <file>bright/button/core_button_enabled_selected.png</file> + <file>bright/button/core_button_pressed.png</file> + <file>bright/checkbox/core_checkbox_checked.png</file> + <file>bright/checkbox/core_checkbox_disabled.png</file> + <file>bright/checkbox/core_checkbox_disabled_checked.png</file> + <file>bright/checkbox/core_checkbox_enabled.png</file> + <file>bright/checkbox/core_checkbox_pressed.png</file> + <file>bright/checkbox/core_checkbox_pressed_checked.png</file> + <file>bright/combobox/core_dropdown_button.png</file> + <file>bright/combobox/core_dropdown_button_arrowdown.png</file> + <file>bright/combobox/core_dropdown_button_arrowdown_pressed.png</file> + <file>bright/combobox/core_dropdown_button_arrowup.png</file> + <file>bright/combobox/core_dropdown_button_disabled.png</file> + <file>bright/combobox/core_dropdown_button_pressed.png</file> + <file>bright/combobox/core_dropdown_checkmark.png</file> + <file>bright/combobox/core_dropdown_divider.png</file> + <file>bright/combobox/core_dropdown_menu.png</file> + <file>bright/combobox/core_dropdown_menuup.png</file> + <file>bright/combobox/core_listitem_active.png</file> + <file>bright/lineedit/core_textinput_bg.png</file> + <file>bright/lineedit/core_textinput_bg_disabled.png</file> + <file>bright/lineedit/core_textinput_bg_highlight.png</file> + <file>bright/listitem/core_listitem_active.png</file> + <file>bright/listitem/core_listitem_divider.png</file> + <file>bright/progressbar/core_progressindicator_bg.png</file> + <file>bright/progressbar/core_progressindicator_complete.png</file> + <file>bright/progressbar/core_progressindicator_fill.png</file> + <file>bright/progressbar/core_progressindicator_vbg.png</file> + <file>bright/progressbar/core_progressindicator_vcomplete.png</file> + <file>bright/progressbar/core_progressindicator_vfill.png</file> + <file>bright/radiobutton/core_radiobutton_checked.png</file> + <file>bright/radiobutton/core_radiobutton_disabled.png</file> + <file>bright/radiobutton/core_radiobutton_disabled_checked.png</file> + <file>bright/radiobutton/core_radiobutton_inactive.png</file> + <file>bright/radiobutton/core_radiobutton_pressed.png</file> + <file>bright/scrollbar/core_scrollbar.png</file> + <file>bright/scrollbar/core_scrollbar_v.png</file> + <file>bright/slider/core_slider_active.png</file> + <file>bright/slider/core_slider_cache.png</file> + <file>bright/slider/core_slider_disabled.png</file> + <file>bright/slider/core_slider_enabled.png</file> + <file>bright/slider/core_slider_handle.png</file> + <file>bright/slider/core_slider_handle_disabled.png</file> + <file>bright/slider/core_slider_handle_pressed.png</file> + <file>bright/slider/core_slider_inactive.png</file> + <file>bright/slider/core_slider_vactive.png</file> + <file>bright/slider/core_slider_vcache.png</file> + <file>bright/slider/core_slider_vdisabled.png</file> + <file>bright/slider/core_slider_venabled.png</file> + <file>bright/slider/core_slider_vinactive.png</file> + </qresource> +</RCC> diff --git a/src/plugins/styles/bb10style/qbb10darkstyle.cpp b/src/plugins/styles/bb10style/qbb10darkstyle.cpp new file mode 100644 index 0000000000..85bf4a7917 --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10darkstyle.cpp @@ -0,0 +1,357 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbb10darkstyle.h" + +#include <QApplication> +#include <QFont> +#include <QStyleOption> +#include <QProgressBar> +#include <QComboBox> +#include <QAbstractItemView> +#include <QPainter> +#include <QLineEdit> +#include <QTextEdit> + +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<QProgressBar*>(widget)) + pb->setTextVisible(false); + + if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) { + QAbstractItemView *list = cb->view(); + QPalette p = list->palette(); + p.setBrush(QPalette::HighlightedText, p.brush(QPalette::Text)); + list->setPalette(p); + } + + if (qobject_cast<QLineEdit*>(widget) || qobject_cast<QTextEdit*>(widget)) { + QPalette p = widget->palette(); + p.setBrush(QPalette::Text, QColor(38, 38, 38)); + widget->setPalette(p); + } + + if (qobject_cast<QAbstractItemView*>(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<const QStyleOptionButton*>(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 --git a/src/plugins/styles/bb10style/qbb10darkstyle.h b/src/plugins/styles/bb10style/qbb10darkstyle.h new file mode 100644 index 0000000000..1be7b0540c --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10darkstyle.h @@ -0,0 +1,70 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBB10DARKSTYLE_H +#define QBB10DARKSTYLE_H + +#include "qpixmapstyle.h" + +QT_BEGIN_NAMESPACE + +class QBB10DarkStyle : public QPixmapStyle +{ + Q_OBJECT + +public: + QBB10DarkStyle(); + ~QBB10DarkStyle(); + + void polish(QApplication *application); + void polish(QWidget *widget); + + QPalette standardPalette() const; + + void drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; +}; + +QT_END_NAMESPACE + +#endif // QBB10DARKSTYLE_H diff --git a/src/plugins/styles/bb10style/qbb10darkstyle.qrc b/src/plugins/styles/bb10style/qbb10darkstyle.qrc new file mode 100644 index 0000000000..31a5236207 --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10darkstyle.qrc @@ -0,0 +1,57 @@ +<RCC> + <qresource prefix="/"> + <file>dark/button/core_button_disabled.png</file> + <file>dark/button/core_button_disabled_selected.png</file> + <file>dark/button/core_button_inactive.png</file> + <file>dark/button/core_button_enabled_selected.png</file> + <file>dark/button/core_button_pressed.png</file> + <file>dark/checkbox/core_checkbox_checked.png</file> + <file>dark/checkbox/core_checkbox_disabled.png</file> + <file>dark/checkbox/core_checkbox_disabled_checked.png</file> + <file>dark/checkbox/core_checkbox_enabled.png</file> + <file>dark/checkbox/core_checkbox_pressed.png</file> + <file>dark/checkbox/core_checkbox_pressed_checked.png</file> + <file>dark/combobox/core_dropdown_button.png</file> + <file>dark/combobox/core_dropdown_button_arrowdown.png</file> + <file>dark/combobox/core_dropdown_button_arrowdown_pressed.png</file> + <file>dark/combobox/core_dropdown_button_arrowup.png</file> + <file>dark/combobox/core_dropdown_button_disabled.png</file> + <file>dark/combobox/core_dropdown_button_pressed.png</file> + <file>dark/combobox/core_dropdown_checkmark.png</file> + <file>dark/combobox/core_dropdown_divider.png</file> + <file>dark/combobox/core_dropdown_menu.png</file> + <file>dark/combobox/core_dropdown_menuup.png</file> + <file>dark/combobox/core_listitem_active.png</file> + <file>dark/lineedit/core_textinput_bg.png</file> + <file>dark/lineedit/core_textinput_bg_disabled.png</file> + <file>dark/lineedit/core_textinput_bg_highlight.png</file> + <file>dark/listitem/core_listitem_active.png</file> + <file>dark/listitem/core_listitem_divider.png</file> + <file>dark/progressbar/core_progressindicator_bg.png</file> + <file>dark/progressbar/core_progressindicator_complete.png</file> + <file>dark/progressbar/core_progressindicator_fill.png</file> + <file>dark/progressbar/core_progressindicator_vbg.png</file> + <file>dark/progressbar/core_progressindicator_vcomplete.png</file> + <file>dark/progressbar/core_progressindicator_vfill.png</file> + <file>dark/radiobutton/core_radiobutton_checked.png</file> + <file>dark/radiobutton/core_radiobutton_disabled.png</file> + <file>dark/radiobutton/core_radiobutton_disabled_checked.png</file> + <file>dark/radiobutton/core_radiobutton_inactive.png</file> + <file>dark/radiobutton/core_radiobutton_pressed.png</file> + <file>dark/scrollbar/core_scrollbar.png</file> + <file>dark/scrollbar/core_scrollbar_v.png</file> + <file>dark/slider/core_slider_active.png</file> + <file>dark/slider/core_slider_cache.png</file> + <file>dark/slider/core_slider_disabled.png</file> + <file>dark/slider/core_slider_enabled.png</file> + <file>dark/slider/core_slider_handle.png</file> + <file>dark/slider/core_slider_handle_disabled.png</file> + <file>dark/slider/core_slider_handle_pressed.png</file> + <file>dark/slider/core_slider_inactive.png</file> + <file>dark/slider/core_slider_vactive.png</file> + <file>dark/slider/core_slider_vcache.png</file> + <file>dark/slider/core_slider_vdisabled.png</file> + <file>dark/slider/core_slider_venabled.png</file> + <file>dark/slider/core_slider_vinactive.png</file> + </qresource> +</RCC> diff --git a/src/plugins/styles/bb10style/qbb10styleplugin.cpp b/src/plugins/styles/bb10style/qbb10styleplugin.cpp new file mode 100644 index 0000000000..eba5e868a2 --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10styleplugin.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "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; +} + +QStringList QBB10StylePlugin::keys() const +{ + return QStringList() << QLatin1String("bb10bright") << QLatin1String("bb10dark"); +} + +QT_END_NAMESPACE + +#include "moc_qbb10styleplugin.cpp" diff --git a/src/plugins/styles/bb10style/qbb10styleplugin.h b/src/plugins/styles/bb10style/qbb10styleplugin.h new file mode 100644 index 0000000000..2bc08d441c --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10styleplugin.h @@ -0,0 +1,64 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBB10STYLEPLUGIN_H +#define QBB10STYLEPLUGIN_H + +#include <QStylePlugin> + +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); + QStringList keys() const; +}; + +QT_END_NAMESPACE + +#endif // QBB10STYLEPLUGIN_H diff --git a/src/plugins/styles/bb10style/qbb10styleplugin.json b/src/plugins/styles/bb10style/qbb10styleplugin.json new file mode 100644 index 0000000000..8f79b706c3 --- /dev/null +++ b/src/plugins/styles/bb10style/qbb10styleplugin.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "bb10bright", "bb10dark" ] +} diff --git a/src/plugins/styles/bb10style/qpixmapstyle.cpp b/src/plugins/styles/bb10style/qpixmapstyle.cpp new file mode 100644 index 0000000000..e80a1d991c --- /dev/null +++ b/src/plugins/styles/bb10style/qpixmapstyle.cpp @@ -0,0 +1,994 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qpixmapstyle.h" + +#include <QDebug> +#include <QTextEdit> +#include <QStringBuilder> +#include <QPainter> +#include <QPixmapCache> +#include <QStyleOption> +#include <QString> +#include <QProgressBar> +#include <QSlider> +#include <QEvent> +#include <QComboBox> +#include <QAbstractItemView> +#include <QListView> +#include <QTreeView> +#include <QStyledItemDelegate> +#include <QAbstractScrollArea> +#include <QScrollBar> + +#include <qscroller.h> + +QT_BEGIN_NAMESPACE + +QPixmapStyle::QPixmapStyle() : + QCommonStyle() +{ +} + +QPixmapStyle::~QPixmapStyle() +{ +} + +void QPixmapStyle::polish(QApplication *application) +{ + QCommonStyle::polish(application); +#if defined(Q_WS_WIN) + QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); +#endif +} + +void QPixmapStyle::polish(QPalette &palette) +{ + palette = proxy()->standardPalette(); +} + +void QPixmapStyle::polish(QWidget *widget) +{ + // Don't fill the interior of the QTextEdit + if (qobject_cast<QTextEdit*>(widget)) { + QPalette p = widget->palette(); + p.setBrush(QPalette::Base, Qt::NoBrush); + widget->setPalette(p); + } + + if (QProgressBar *pb = qobject_cast<QProgressBar*>(widget)) { + // Center the text in the progress bar + pb->setAlignment(Qt::AlignCenter); + // Change the font size if needed, as it's used to compute the minimum size + QFont font = pb->font(); + font.setPixelSize(m_descriptors.value(PB_HBackground).size.height()/2); + pb->setFont(font); + } + + if (qobject_cast<QSlider*>(widget)) + widget->installEventFilter(this); + + if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) { + widget->installEventFilter(this); + // NOTE: This will break if the private API of QComboBox changes drastically + // Make sure the popup is created so we can change the frame style + QAbstractItemView *list = cb->view(); + list->setProperty("_pixmap_combobox_list", true); + list->setItemDelegate(new QStyledItemDelegate(list)); + QPalette p = list->palette(); + p.setBrush(QPalette::Active, QPalette::Base, QBrush(Qt::transparent) ); + p.setBrush(QPalette::Active, QPalette::AlternateBase, QBrush(Qt::transparent) ); + p.setBrush(QPalette::Inactive, QPalette::Base, QBrush(Qt::transparent) ); + p.setBrush(QPalette::Inactive, QPalette::AlternateBase, QBrush(Qt::transparent) ); + p.setBrush(QPalette::Disabled, QPalette::Base, QBrush(Qt::transparent) ); + p.setBrush(QPalette::Disabled, QPalette::AlternateBase, QBrush(Qt::transparent) ); + list->setPalette(p); + + QFrame *frame = qobject_cast<QFrame*>(list->parent()); + if (frame) { + const Descriptor &desc = m_descriptors.value(DD_PopupDown); + const Pixmap &pix = m_pixmaps.value(DD_ItemSeparator); + frame->setContentsMargins(pix.margins.left(), desc.margins.top(), + pix.margins.right(), desc.margins.bottom()); + frame->setAttribute(Qt::WA_TranslucentBackground); +#ifdef Q_WS_WIN + // FramelessWindowHint is needed on windows to make + // WA_TranslucentBackground work properly + frame->setWindowFlags(widget->windowFlags() | Qt::FramelessWindowHint); +#endif + } + } + + if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) + widget->installEventFilter(this); + + if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) { + scrollArea->viewport()->setAutoFillBackground(false); + if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(scrollArea)) { + view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + } + QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); + } + + if (qobject_cast<QScrollBar*>(widget)) + widget->setAttribute(Qt::WA_OpaquePaintEvent, false); + + QCommonStyle::polish(widget); +} + +void QPixmapStyle::unpolish(QWidget *widget) +{ + if (qobject_cast<QSlider*>(widget) || + qobject_cast<QComboBox*>(widget)) { + widget->removeEventFilter(this); + } + + if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) + widget->removeEventFilter(this); + + if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) + QScroller::ungrabGesture(scrollArea->viewport()); + + QCommonStyle::unpolish(widget); +} + +void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + switch (element) { + case PE_FrameFocusRect: //disable focus rectangle + break; + case PE_PanelButtonBevel: + case PE_PanelButtonCommand: + drawPushButton(option, painter, widget); + break; + case PE_PanelLineEdit: + case PE_FrameLineEdit: + drawLineEdit(option, painter, widget); + break; + case PE_Frame: + case PE_FrameDefaultButton: + if (qobject_cast<const QTextEdit*>(widget)) + drawTextEdit(option, painter, widget); + break; + case PE_IndicatorCheckBox: + drawCheckBox(option, painter, widget); + break; + case PE_IndicatorRadioButton: + drawRadioButton(option, painter, widget); + break; + case PE_PanelItemViewItem: + if (qobject_cast<const QListView*>(widget)) + drawPanelItemViewItem(option, painter, widget); + else + QCommonStyle::drawPrimitive(element, option, painter, widget); + break; + default: + QCommonStyle::drawPrimitive(element, option, painter, widget); + } +} + +void QPixmapStyle::drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + switch (element) { + case CE_ProgressBarGroove: + drawProgressBarBackground(option, painter, widget); + break; + case CE_ProgressBarLabel: + drawProgressBarLabel(option, painter, widget); + break; + case CE_ProgressBarContents: + drawProgressBarFill(option, painter, widget); + break; + case CE_ShapedFrame: + // NOTE: This will break if the private API of QComboBox changes drastically + if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) { + const Descriptor &desc = m_descriptors.value(DD_PopupDown); + const Pixmap &pix = m_pixmaps.value(DD_ItemSeparator); + QRect rect = option->rect; + rect.adjust(-pix.margins.left(), -desc.margins.top(), + pix.margins.right(), desc.margins.bottom()); + bool up = widget->property("_pixmapstyle_combobox_up").toBool(); + drawCachedPixmap(up ? DD_PopupUp : DD_PopupDown, rect, painter); + } + else { + QCommonStyle::drawControl(element, option, painter, widget); + } + break; + default: + QCommonStyle::drawControl(element, option, painter, widget); + } +} + +void QPixmapStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const +{ + switch (cc) { + case CC_Slider: + drawSlider(option, painter, widget); + break; + case CC_ComboBox: + drawComboBox(option, painter, widget); + break; + case CC_ScrollBar: + drawScrollBar(option, painter, widget); + break; + default: + QCommonStyle::drawComplexControl(cc, option, painter, widget); + } +} + +QSize QPixmapStyle::sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const +{ + switch (type) { + case CT_PushButton: + return pushButtonSizeFromContents(option, contentsSize, widget); + case CT_LineEdit: + return lineEditSizeFromContents(option, contentsSize, widget); + case CT_ProgressBar: + return progressBarSizeFromContents(option, contentsSize, widget); + case CT_Slider: + return sliderSizeFromContents(option, contentsSize, widget); + case CT_ComboBox: + return comboBoxSizeFromContents(option, contentsSize, widget); + case CT_ItemViewItem: + return itemViewSizeFromContents(option, contentsSize, widget); + default: ; + } + + return QCommonStyle::sizeFromContents(type, option, contentsSize, widget); +} + +QRect QPixmapStyle::subElementRect(SubElement element, const QStyleOption *option, + const QWidget *widget) const +{ + switch (element) { + case SE_LineEditContents: + { + QRect rect = QCommonStyle::subElementRect(element, option, widget); + const Descriptor &desc = m_descriptors.value(LE_Enabled); + rect.adjust(desc.margins.left(), desc.margins.top(), + -desc.margins.right(), -desc.margins.bottom()); + rect = visualRect(option->direction, option->rect, rect); + return rect; + } + default: ; + } + + return QCommonStyle::subElementRect(element, option, widget); +} + +QRect QPixmapStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option, + SubControl sc, const QWidget *widget) const +{ + switch (cc) { + case CC_ComboBox: + return comboBoxSubControlRect(option, sc, widget); + case CC_ScrollBar: + return scrollBarSubControlRect(option, sc, widget); + default: ; + } + + return QCommonStyle::subControlRect(cc, option, sc, widget); +} + +int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, + const QWidget *widget) const +{ + switch (metric) { + case PM_ButtonShiftHorizontal: + case PM_ButtonShiftVertical: + return 0; + case PM_DefaultFrameWidth: + if (qobject_cast<const QTextEdit*>(widget)) { + const Descriptor &desc = m_descriptors.value(LE_Enabled); + return qMax(qMax(desc.margins.left(), desc.margins.right()), + qMax(desc.margins.top(), desc.margins.bottom())); + } + return 0; + case PM_IndicatorWidth: + return m_pixmaps.value(CB_Enabled).pixmap.width(); + case PM_IndicatorHeight: + return m_pixmaps.value(CB_Enabled).pixmap.height(); + case PM_CheckBoxLabelSpacing: + { + const Pixmap &pix = m_pixmaps.value(CB_Enabled); + return qMax(qMax(pix.margins.left(), pix.margins.right()), + qMax(pix.margins.top(), pix.margins.bottom())); + } + case PM_ExclusiveIndicatorWidth: + return m_pixmaps.value(RB_Enabled).pixmap.width(); + case PM_ExclusiveIndicatorHeight: + return m_pixmaps.value(RB_Enabled).pixmap.height(); + case PM_RadioButtonLabelSpacing: + { + const Pixmap &pix = m_pixmaps.value(RB_Enabled); + return qMax(qMax(pix.margins.left(), pix.margins.right()), + qMax(pix.margins.top(), pix.margins.bottom())); + } + case PM_SliderThickness: + if (const QStyleOptionSlider *slider = + qstyleoption_cast<const QStyleOptionSlider*>(option)) { + const Descriptor desc = m_descriptors.value(slider->orientation == Qt::Horizontal + ? SG_HEnabled : SG_VEnabled); + return slider->orientation == Qt::Horizontal + ? desc.size.height() : desc.size.width(); + } + break; + case PM_SliderControlThickness: + if (const QStyleOptionSlider *slider = + qstyleoption_cast<const QStyleOptionSlider*>(option)) { + const Pixmap pix = m_pixmaps.value(slider->orientation == Qt::Horizontal + ? SH_HEnabled : SH_VEnabled); + return slider->orientation == Qt::Horizontal + ? pix.pixmap.height() : pix.pixmap.width(); + } + break; + case PM_SliderLength: + if (const QStyleOptionSlider *slider = + qstyleoption_cast<const QStyleOptionSlider*>(option)) { + const Pixmap pix = m_pixmaps.value(slider->orientation == Qt::Horizontal + ? SH_HEnabled : SH_VEnabled); + return slider->orientation == Qt::Horizontal + ? pix.pixmap.width() : pix.pixmap.height(); + } + break; + case PM_ScrollBarExtent: + if (const QStyleOptionSlider *slider = + qstyleoption_cast<const QStyleOptionSlider*>(option)) { + const Descriptor desc = m_descriptors.value(slider->orientation == Qt::Horizontal + ? SB_Horizontal : SB_Vertical); + return slider->orientation == Qt::Horizontal + ? desc.size.height() : desc.size.width(); + } + break; + case PM_ScrollBarSliderMin: + return 0; + default: ; + } + + return QCommonStyle::pixelMetric(metric, option, widget); +} + +int QPixmapStyle::styleHint(StyleHint hint, const QStyleOption *option, + const QWidget *widget, QStyleHintReturn *returnData) const +{ + switch (hint) { + case SH_EtchDisabledText: + return false; + case SH_ComboBox_Popup: + return false; + default: ; + } + + return QCommonStyle::styleHint(hint, option, widget, returnData); +} + +QStyle::SubControl QPixmapStyle::hitTestComplexControl(QStyle::ComplexControl control, + const QStyleOptionComplex *option, + const QPoint &pos, + const QWidget *widget) const +{ + const SubControl sc = QCommonStyle::hitTestComplexControl(control, option, pos, widget); + if (control == CC_ScrollBar) { + if (sc == SC_ScrollBarAddLine) + return SC_ScrollBarAddPage; + else if (sc == SC_ScrollBarSubLine) + return SC_ScrollBarSubPage; + } + + return sc; +} + +bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) +{ + if (QSlider *slider = qobject_cast<QSlider*>(watched)) { + switch (event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + slider->update(); + break; + default: ; + } + } + + if (QComboBox *comboBox = qobject_cast<QComboBox*>(watched)) { + switch (event->type()) { + case QEvent::MouseButtonPress: + event->ignore(); + comboBox->setProperty("_pixmapstyle_combobox_pressed", true); + comboBox->repaint(); + return true; + case QEvent::MouseButtonRelease: + comboBox->setProperty("_pixmapstyle_combobox_pressed", false); + comboBox->repaint(); + if ( comboBox->view() ) { + if ( comboBox->view()->isVisible() || (!comboBox->isEnabled())) + comboBox->hidePopup(); + else + comboBox->showPopup(); + } + break; + default: ; + } + } + + if (qstrcmp(watched->metaObject()->className(),"QComboBoxPrivateContainer") == 0) { + if (event->type() == QEvent::Show) { + QWidget *widget = qobject_cast<QWidget*>(watched); + int yPopup = widget->geometry().top(); + int yCombo = widget->parentWidget()->mapToGlobal(QPoint(0, 0)).y(); + QRect geom = widget->geometry(); + const Descriptor &desc = m_descriptors.value(DD_ButtonEnabled); + const bool up = yPopup < yCombo; + geom.moveTop(geom.top() + (up ? desc.margins.top() : -desc.margins.bottom())); + widget->setGeometry(geom); + widget->setProperty("_pixmapstyle_combobox_up", up); + widget->parentWidget()->setProperty("_pixmapstyle_combobox_up", up); + } + } + + return QCommonStyle::eventFilter(watched, event); +} + +void QPixmapStyle::addDescriptor(QPixmapStyle::ControlDescriptor control, const QString &fileName, + QMargins margins, QTileRules tileRules) +{ + Descriptor desc; + + QImage image(fileName); + if (image.isNull()) + return; + + desc.fileName = fileName; + desc.margins = margins; + desc.tileRules = tileRules; + desc.size = image.size(); + + m_descriptors[control] = desc; +} + +void QPixmapStyle::copyDescriptor(QPixmapStyle::ControlDescriptor source, + QPixmapStyle::ControlDescriptor dest) +{ + m_descriptors[dest] = m_descriptors.value(source); +} + +void QPixmapStyle::drawCachedPixmap(QPixmapStyle::ControlDescriptor control, const QRect &rect, + QPainter *p) const +{ + if (!m_descriptors.contains(control)) + return; + const Descriptor &desc = m_descriptors.value(control); + const QPixmap pix = getCachedPixmap(control, desc, rect.size()); + Q_ASSERT(!pix.isNull()); + p->drawPixmap(rect, pix); +} + +void QPixmapStyle::addPixmap(ControlPixmap control, const QString &fileName, + QMargins margins) +{ + Pixmap pix; + + QPixmap image(fileName); + if (image.isNull()) + return; + + pix.pixmap = image; + pix.margins = margins; + + m_pixmaps[control] = pix; +} + +void QPixmapStyle::copyPixmap(QPixmapStyle::ControlPixmap source, QPixmapStyle::ControlPixmap dest) +{ + m_pixmaps[dest] = m_pixmaps.value(source); +} + +void QPixmapStyle::drawPushButton(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + const bool checked = option->state & State_On; + const bool pressed = option->state & State_Sunken; + const bool enabled = option->state & State_Enabled; + + ControlDescriptor control = PB_Enabled; + if (enabled) + control = pressed ? PB_Pressed : (checked ? PB_Checked : PB_Enabled); + else + control = checked ? PB_PressedDisabled : PB_Disabled; + drawCachedPixmap(control, option->rect, painter); +} + +void QPixmapStyle::drawLineEdit(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + // Don't draw for the line edit inside a combobox + if (widget && qobject_cast<const QComboBox*>(widget->parentWidget())) + return; + + const bool enabled = option->state & State_Enabled; + const bool focused = option->state & State_HasFocus; + ControlDescriptor control = enabled ? (focused ? LE_Focused : LE_Enabled) : LE_Disabled; + drawCachedPixmap(control, option->rect, painter); +} + +void QPixmapStyle::drawTextEdit(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + const bool enabled = option->state & State_Enabled; + const bool focused = option->state & State_HasFocus; + ControlDescriptor control = enabled ? (focused ? TE_Focused : TE_Enabled) : TE_Disabled; + drawCachedPixmap(control, option->rect, painter); +} + +void QPixmapStyle::drawCheckBox(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option); + + const bool down = button->state & State_Sunken; + const bool enabled = button->state & State_Enabled; + const bool on = button->state & State_On; + + ControlPixmap control; + if (enabled) + control = on ? (down ? CB_PressedChecked : CB_Checked) : (down ? CB_Pressed : CB_Enabled); + else + control = on ? CB_DisabledChecked : CB_Disabled; + painter->drawPixmap(button->rect, m_pixmaps.value(control).pixmap); +} + +void QPixmapStyle::drawRadioButton(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option); + + const bool down = button->state & State_Sunken; + const bool enabled = button->state & State_Enabled; + const bool on = button->state & State_On; + + ControlPixmap control; + if (enabled) + control = on ? RB_Checked : (down ? RB_Pressed : RB_Enabled); + else + control = on ? RB_DisabledChecked : RB_Disabled; + painter->drawPixmap(button->rect, m_pixmaps.value(control).pixmap); +} + +void QPixmapStyle::drawPanelItemViewItem(const QStyleOption *option, QPainter *painter, + const QWidget *widget) const +{ + ControlPixmap cp = ID_Separator; + ControlDescriptor cd = ID_Selected; + + if (widget && widget->property("_pixmap_combobox_list").toBool()) { + cp = DD_ItemSeparator; + cd = DD_ItemSelected; + } + + QPixmap pix = m_pixmaps.value(cp).pixmap; + QRect rect = option->rect; + rect.setBottom(rect.top() + pix.height()-1); + painter->drawPixmap(rect, pix); + if (option->state & QStyle::State_Selected) { + rect = option->rect; + rect.setTop(rect.top() + pix.height()); + drawCachedPixmap(cd, rect, painter); + } +} + +void QPixmapStyle::drawProgressBarBackground(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + bool vertical = false; + if (const QStyleOptionProgressBarV2 *pb2 = + qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { + vertical = (pb2->orientation == Qt::Vertical); + } + drawCachedPixmap(vertical ? PB_VBackground : PB_HBackground, option->rect, painter); +} + +void QPixmapStyle::drawProgressBarLabel(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + if (const QStyleOptionProgressBar *pb = + qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { + bool vertical = false; + if (const QStyleOptionProgressBarV2 *pb2 = + qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { + vertical = (pb2->orientation == Qt::Vertical); + } + if (!vertical) { + QPalette::ColorRole textRole = QPalette::ButtonText; + proxy()->drawItemText(painter, pb->rect, + Qt::AlignCenter | Qt::TextSingleLine, pb->palette, + pb->state & State_Enabled, pb->text, textRole); + } + } +} + +void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, + QPainter *painter, const QWidget *) const +{ + const QStyleOptionProgressBar *pbar = + qstyleoption_cast<const QStyleOptionProgressBar*>(option); + bool vertical = false; + bool flip = pbar->direction == Qt::RightToLeft; + if (const QStyleOptionProgressBarV2 *pb2 = + qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { + vertical = (pb2->orientation == Qt::Vertical); + flip = flip ^ pb2->invertedAppearance; + } + + if (pbar->progress == pbar->maximum) { + drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter); + + } else { + if (pbar->progress == 0) + return; + const int maximum = pbar->maximum; + const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum; + const int progress = pbar->progress*ratio; + + QRect optRect = option->rect; + if (vertical) { + if (flip) + optRect.setBottom(optRect.top()+progress-1); + else + optRect.setTop(optRect.bottom()-progress+1); + } else { + if (flip) + optRect.setLeft(optRect.right()-progress+1); + else + optRect.setRight(optRect.left()+progress-1); + } + + drawCachedPixmap(vertical ? PB_VContent : PB_HContent, optRect, painter); + } +} + +void QPixmapStyle::drawSlider(const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const +{ + const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option); + if (!slider) + return; + + const bool enabled = option->state & State_Enabled; + const bool pressed = option->state & State_Sunken; + const Qt::Orientation orient = slider->orientation; + + const QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); + if (option->subControls & SC_SliderGroove) { + QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + if (groove.isValid()) { + // Draw the background + ControlDescriptor control; + if (orient == Qt::Horizontal) + control = enabled ? SG_HEnabled : SG_HDisabled; + else + control = enabled ? SG_VEnabled : SG_VDisabled; + drawCachedPixmap(control, groove, painter); + + // Draw the active part + if (orient == Qt::Horizontal) { + control = enabled ? (pressed ? SG_HActivePressed : SG_HActiveEnabled ) + : SG_HActiveDisabled; + } else { + control = enabled ? (pressed ? SG_VActivePressed : SG_VActiveEnabled ) + : SG_VActiveDisabled; + } + const Descriptor &desc = m_descriptors.value(control); + const QPixmap pix = getCachedPixmap(control, desc, groove.size()); + if (!pix.isNull()) { + groove.setRight(orient == Qt::Horizontal + ? handle.center().x() : handle.center().y()); + painter->drawPixmap(groove, pix, groove); + } + } + } + if (option->subControls & SC_SliderHandle) { + if (handle.isValid()) { + ControlPixmap pix; + if (orient == Qt::Horizontal) + pix = enabled ? (pressed ? SH_HPressed : SH_HEnabled) : SH_HDisabled; + else + pix = enabled ? (pressed ? SH_VPressed : SH_VEnabled) : SH_VDisabled; + painter->drawPixmap(handle, m_pixmaps.value(pix).pixmap); + } + } +} + +void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const +{ + const bool enabled = option->state & State_Enabled; + const bool pressed = widget->property("_pixmapstyle_combobox_pressed").toBool(); + const bool opened = option->state & State_On; + + ControlDescriptor control = + enabled ? (pressed ? DD_ButtonPressed : DD_ButtonEnabled) : DD_ButtonDisabled; + drawCachedPixmap(control, option->rect, painter); + + ControlPixmap cp = enabled ? (opened ? DD_ArrowOpen + : (pressed ? DD_ArrowPressed : DD_ArrowEnabled)) + : DD_ArrowDisabled; + Pixmap pix = m_pixmaps.value(cp); + QRect rect = comboBoxSubControlRect(option, SC_ComboBoxArrow, widget); + painter->drawPixmap(rect, pix.pixmap); +} + +void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const +{ + if (const QStyleOptionSlider *slider = + qstyleoption_cast<const QStyleOptionSlider*>(option)) { + // Do not draw the scrollbar + if (slider->minimum == slider->maximum) + return; + + QRect rect = scrollBarSubControlRect(option, SC_ScrollBarSlider, widget); + ControlDescriptor control = slider->orientation == Qt::Horizontal + ? SB_Horizontal : SB_Vertical; + drawCachedPixmap(control, rect, painter); + } +} + +QSize QPixmapStyle::pushButtonSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, + const QWidget *widget) const +{ + const Descriptor &desc = m_descriptors.value(PB_Enabled); + const int bm = proxy()->pixelMetric(PM_ButtonMargin, option, widget); + + int w = contentsSize.width(); + int h = contentsSize.height(); + w += desc.margins.left() + desc.margins.right() + bm; + h += desc.margins.top() + desc.margins.bottom() + bm; + + return computeSize(desc, w, h); +} + +QSize QPixmapStyle::lineEditSizeFromContents(const QStyleOption *, + const QSize &contentsSize, const QWidget *) const +{ + const Descriptor &desc = m_descriptors.value(LE_Enabled); + const int border = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth); + + int w = contentsSize.width() + border + desc.margins.left() + desc.margins.right(); + int h = contentsSize.height() + border + desc.margins.top() + desc.margins.bottom(); + + return computeSize(desc, w, h); +} + +QSize QPixmapStyle::progressBarSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, + const QWidget *widget) const +{ + bool vertical = false; + if (const QStyleOptionProgressBarV2 *pb2 = + qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { + vertical = (pb2->orientation == Qt::Vertical); + } + QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget); + if (vertical) { + const Descriptor desc = m_descriptors.value(PB_VBackground); + return QSize(desc.size.height(), result.height()); + } else { + const Descriptor desc = m_descriptors.value(PB_HBackground); + return QSize(result.width(), desc.size.height()); + } +} + +QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, + const QWidget *widget) const +{ + const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option); + if (!slider) + return QSize(); + + QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget); + + const Descriptor desc = m_descriptors.value(slider->orientation == Qt::Horizontal + ? SG_HEnabled : SG_VEnabled); + + if (slider->orientation == Qt::Horizontal) + return QSize(result.width(), desc.size.height()); + else + return QSize(desc.size.width(), result.height()); +} + +QSize QPixmapStyle::comboBoxSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, + const QWidget *widget) const +{ + const Descriptor &desc = m_descriptors.value(DD_ButtonEnabled); + + QSize result = QCommonStyle::sizeFromContents(CT_ComboBox, option, contentsSize, widget); + return computeSize(desc, result.width(), result.height()); +} + +QSize QPixmapStyle::itemViewSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, + const QWidget *widget) const +{ + QSize size = QCommonStyle::sizeFromContents(CT_ItemViewItem, option, contentsSize, widget); + + ControlPixmap cp = ID_Separator; + ControlDescriptor cd = ID_Selected; + if (widget && widget->property("_pixmap_combobox_list").toBool()) { + cp = DD_ItemSeparator; + cd = DD_ItemSelected; + } + + const Descriptor &desc = m_descriptors.value(cd); + const Pixmap &pix = m_pixmaps.value(cp); + size.setHeight(qMax(size.height(), + desc.size.height() + pix.pixmap.height())); + return size; +} + +QRect QPixmapStyle::comboBoxSubControlRect(const QStyleOptionComplex *option, + QStyle::SubControl sc, const QWidget *) const +{ + QRect r = option->rect; // Default size + const Pixmap &pix = m_pixmaps.value(DD_ArrowEnabled); + const Descriptor &desc = m_descriptors.value(DD_ButtonEnabled); + + switch (sc) { + case SC_ComboBoxArrow: + r.setRect(r.right() - pix.margins.right() - pix.pixmap.width(), + r.top() + pix.margins.top(), + pix.pixmap.width(), pix.pixmap.height()); + break; + case SC_ComboBoxEditField: + r.adjust(desc.margins.left(), desc.margins.right(), + -desc.margins.right(), -desc.margins.bottom()); + r.setRight(r.right() - pix.margins.right() - pix.margins.left() - pix.pixmap.width()); + break; + default: + break; + } + + r = visualRect(option->direction, option->rect, r); + return r; +} + +QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option, + QStyle::SubControl sc, const QWidget *) const +{ + if (const QStyleOptionSlider *slider = + qstyleoption_cast<const QStyleOptionSlider*>(option)) { + int length = (slider->orientation == Qt::Horizontal) + ? slider->rect.width() : slider->rect.height(); + int page = length * slider->pageStep + / (slider->maximum - slider->minimum + slider->pageStep); + int pos = length * slider->sliderValue + / (slider->maximum - slider->minimum + slider->pageStep); + pos = qMin(pos+page, length) - page; + + QRect rect = slider->rect; + + if (slider->orientation == Qt::Horizontal) { + switch (sc) { + case SC_ScrollBarAddPage: + rect.setLeft(pos+page); + return rect; + case SC_ScrollBarSubPage: + rect.setRight(pos); + return rect; + case SC_ScrollBarGroove: + return rect; + case SC_ScrollBarSlider: + rect.setLeft(pos); + rect.setRight(pos+page); + return rect; + default: ; + } + } else { + switch (sc) { + case SC_ScrollBarAddPage: + rect.setTop(pos+page); + return rect; + case SC_ScrollBarSubPage: + rect.setBottom(pos); + return rect; + case SC_ScrollBarGroove: + return rect; + case SC_ScrollBarSlider: + rect.setTop(pos); + rect.setBottom(pos+page); + return rect; + default: ; + } + } + } + return QRect(); +} + +static QPixmap scale(int w, int h, const QPixmap &pixmap, const QPixmapStyle::Descriptor &desc) +{ + QPixmap result(w, h); + { + const QColor transparent(0, 0, 0, 0); + result.fill( transparent ); + QPainter p( &result ); + const QMargins margins = desc.margins; + qDrawBorderPixmap(&p, result.rect(), margins, pixmap, + pixmap.rect(), margins, desc.tileRules); + } + return result; +} + +QPixmap QPixmapStyle::getCachedPixmap(ControlDescriptor control, const Descriptor &desc, + const QSize &size) const +{ + const QString sizeString = QString::number(size.width()) % QLatin1Char('*') + % QString::number(size.height()); + const QString key = QLatin1String(metaObject()->className()) % QString::number(control) + % QLatin1Char('@') % sizeString; + + QPixmap result; + + if (!QPixmapCache::find( key, &result)) { + QPixmap source(desc.fileName); + result = scale(size.width(), size.height(), source, desc); + QPixmapCache::insert(key, result); + } + return result; +} + +QSize QPixmapStyle::computeSize(const QPixmapStyle::Descriptor &desc, int width, int height) const +{ + if (desc.tileRules.horizontal != Qt::RepeatTile) + width = qMax(width, desc.size.width()); + if (desc.tileRules.vertical != Qt::RepeatTile) + height = qMax(height, desc.size.height()); + return QSize(width, height); +} + +QT_END_NAMESPACE diff --git a/src/plugins/styles/bb10style/qpixmapstyle.h b/src/plugins/styles/bb10style/qpixmapstyle.h new file mode 100644 index 0000000000..d4a223aab8 --- /dev/null +++ b/src/plugins/styles/bb10style/qpixmapstyle.h @@ -0,0 +1,236 @@ +/*************************************************************************** +** +** Copyright (C) 2014 BlackBerry Limited. All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPIXMAPSTYLE_H +#define QPIXMAPSTYLE_H + +#include <QCommonStyle> +#include <QString> +#include <QPixmap> +#include <QMargins> +#include <QTileRules> +#include <QHash> +#include <QPainter> + +QT_BEGIN_NAMESPACE + +class QPixmapStyle : public QCommonStyle +{ + Q_OBJECT + +public: + struct Descriptor { + QString fileName; + QSize size; + QMargins margins; + QTileRules tileRules; + }; + + enum ControlDescriptor { + BG_Background=0, + LE_Enabled, // QLineEdit + LE_Disabled, + LE_Focused, + PB_Enabled, // QPushButton + PB_Pressed, + PB_PressedDisabled, + PB_Checked, + PB_Disabled, + TE_Enabled, // QTextEdit + TE_Disabled, + TE_Focused, + PB_HBackground, // Horizontal QProgressBar + PB_HContent, + PB_HComplete, + PB_VBackground, // Vertical QProgressBar + PB_VContent, + PB_VComplete, + SG_HEnabled, // Horizontal QSlider groove + SG_HDisabled, + SG_HActiveEnabled, + SG_HActivePressed, + SG_HActiveDisabled, + SG_VEnabled, // Vertical QSlider groove + SG_VDisabled, + SG_VActiveEnabled, + SG_VActivePressed, + SG_VActiveDisabled, + DD_ButtonEnabled, // QComboBox (DropDown) + DD_ButtonDisabled, + DD_ButtonPressed, + DD_PopupDown, + DD_PopupUp, + DD_ItemSelected, + ID_Selected, // QStyledItemDelegate + SB_Horizontal, // QScrollBar + SB_Vertical + }; + + struct Pixmap { + QPixmap pixmap; + QMargins margins; + }; + enum ControlPixmap { + CB_Enabled, // QCheckBox + CB_Checked, + CB_Pressed, + CB_PressedChecked, + CB_Disabled, + CB_DisabledChecked, + RB_Enabled, // QRadioButton + RB_Checked, + RB_Pressed, + RB_Disabled, + RB_DisabledChecked, + SH_HEnabled, // Horizontal QSlider handle + SH_HDisabled, + SH_HPressed, + SH_VEnabled, // Vertical QSlider handle + SH_VDisabled, + SH_VPressed, + DD_ArrowEnabled, // QComboBox (DropDown) arrow + DD_ArrowDisabled, + DD_ArrowPressed, + DD_ArrowOpen, + DD_ItemSeparator, + ID_Separator // QStyledItemDelegate separator + }; + +public: + QPixmapStyle(); + ~QPixmapStyle(); + + void polish(QApplication *application); + void polish(QPalette &palette); + void polish(QWidget *widget); + void unpolish(QWidget *widget); + + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const; + void drawControl(ControlElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const; + void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget=0) const; + + QSize sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget = 0) const; + QRect subElementRect(SubElement element, const QStyleOption *option, + const QWidget *widget = 0) const; + QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, + SubControl sc, const QWidget *widget = 0) const; + + int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, + const QWidget *widget = 0) const; + int styleHint(StyleHint hint, const QStyleOption *option, + const QWidget *widget, QStyleHintReturn *returnData) const; + SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, + const QPoint &pos, const QWidget *widget) const; + + bool eventFilter(QObject *watched, QEvent *event); + +protected: + void addDescriptor(ControlDescriptor control, const QString &fileName, + QMargins margins = QMargins(), + QTileRules tileRules = QTileRules(Qt::RepeatTile, Qt::RepeatTile)); + void copyDescriptor(ControlDescriptor source, ControlDescriptor dest); + void drawCachedPixmap(ControlDescriptor control, const QRect &rect, QPainter *p) const; + + void addPixmap(ControlPixmap control, const QString &fileName, + QMargins margins = QMargins()); + void copyPixmap(ControlPixmap source, ControlPixmap dest); + + void drawPushButton(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawLineEdit(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawTextEdit(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawCheckBox(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawRadioButton(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawPanelItemViewItem(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawProgressBarBackground(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawProgressBarLabel(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawProgressBarFill(const QStyleOption *option, + QPainter *painter, const QWidget *widget) const; + void drawSlider(const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const; + void drawComboBox(const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const; + void drawScrollBar(const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const; + + QSize pushButtonSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const; + QSize lineEditSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const; + QSize progressBarSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const; + QSize sliderSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const; + QSize comboBoxSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const; + QSize itemViewSizeFromContents(const QStyleOption *option, + const QSize &contentsSize, const QWidget *widget) const; + + QRect comboBoxSubControlRect(const QStyleOptionComplex *option, + SubControl sc, const QWidget *widget) const; + QRect scrollBarSubControlRect(const QStyleOptionComplex *option, + SubControl sc, const QWidget *widget) const; + +private: + QPixmap getCachedPixmap(ControlDescriptor control, + const Descriptor &desc, const QSize &size) const; + + QSize computeSize(const Descriptor &desc, int width, int height) const; + +private: + QHash<ControlDescriptor, Descriptor> m_descriptors; + QHash<ControlPixmap, Pixmap> m_pixmaps; +}; + +QT_END_NAMESPACE + +#endif // QPIXMAPSTYLE_H diff --git a/src/plugins/styles/styles.pro b/src/plugins/styles/styles.pro new file mode 100644 index 0000000000..88b3f90e0c --- /dev/null +++ b/src/plugins/styles/styles.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +blackberry:SUBDIRS += bb10style |