diff options
Diffstat (limited to 'src/plugins')
260 files changed, 640 insertions, 5593 deletions
diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index a1434fc2ea..61e6f46ebc 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -7,7 +7,6 @@ TEMPLATE = subdirs #win32:SUBDIRS += nla win32:SUBDIRS += generic -blackberry:SUBDIRS += blackberry win32:!wince:!winrt: SUBDIRS += nativewifi mac:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan mac:SUBDIRS += generic diff --git a/src/plugins/bearer/blackberry/blackberry.json b/src/plugins/bearer/blackberry/blackberry.json deleted file mode 100644 index 233f05cf53..0000000000 --- a/src/plugins/bearer/blackberry/blackberry.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "blackberry" ] -} diff --git a/src/plugins/bearer/blackberry/blackberry.pro b/src/plugins/bearer/blackberry/blackberry.pro deleted file mode 100644 index c75de3aaad..0000000000 --- a/src/plugins/bearer/blackberry/blackberry.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = qbbbearer - -PLUGIN_TYPE = bearer -PLUGIN_CLASS_NAME = QBBEnginePlugin -load(qt_plugin) - -QT = core-private network-private - -# Uncomment this to enable debugging output for the plugin -#DEFINES += QBBENGINE_DEBUG - -HEADERS += qbbengine.h \ - ../qnetworksession_impl.h \ - ../qbearerengine_impl.h - -SOURCES += qbbengine.cpp \ - ../qnetworksession_impl.cpp \ - main.cpp - -OTHER_FILES += blackberry.json diff --git a/src/plugins/bearer/blackberry/qbbengine.cpp b/src/plugins/bearer/blackberry/qbbengine.cpp deleted file mode 100644 index 5483c48eaa..0000000000 --- a/src/plugins/bearer/blackberry/qbbengine.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbbengine.h" -#include "../qnetworksession_impl.h" - -#include <QDebug> -#include <QThreadStorage> -#include <QStringList> -#include <QTimer> - -#include <bps/netstatus.h> - -#ifndef QT_NO_BEARERMANAGEMENT - -#ifdef QBBENGINE_DEBUG -#define qBearerDebug qDebug -#else -#define qBearerDebug QT_NO_QDEBUG_MACRO -#endif - -struct NetstatusInterfaceListCleanupHelper -{ - static inline void cleanup(netstatus_interface_list_t *list) - { - netstatus_free_interfaces(list); - } -}; - -struct NetstatusInterfaceCleanupHelper -{ - static inline void cleanup(char *interface) - { - bps_free(interface); - } -}; - -struct EngineInstanceHolder -{ - EngineInstanceHolder(QBBEngine *engine) : - instance(engine) {} - - QBBEngine *instance; -}; - -Q_GLOBAL_STATIC(QThreadStorage<EngineInstanceHolder *>, instanceStorage); - -static QNetworkConfiguration::BearerType -interfaceType(netstatus_interface_type_t type) -{ - switch (type) { - case NETSTATUS_INTERFACE_TYPE_USB: - case NETSTATUS_INTERFACE_TYPE_WIRED: - return QNetworkConfiguration::BearerEthernet; - - case NETSTATUS_INTERFACE_TYPE_WIFI: - return QNetworkConfiguration::BearerWLAN; - - case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN: - return QNetworkConfiguration::BearerBluetooth; - - case NETSTATUS_INTERFACE_TYPE_CELLULAR: - // The exact bearer type is determined in QNetworkConfiguration - // at the time this info is queried, because opposed to the - // information here the type might change quickly. - return QNetworkConfiguration::Bearer2G; - - case NETSTATUS_INTERFACE_TYPE_VPN: - case NETSTATUS_INTERFACE_TYPE_BB: - case NETSTATUS_INTERFACE_TYPE_UNKNOWN: - break; - } - - return QNetworkConfiguration::BearerUnknown; -} - -static QString idForName(const QString &name) -{ - return QStringLiteral("bps:") + name; -} - -QT_BEGIN_NAMESPACE - - -QBBEngine::QBBEngine(QObject *parent) : - QBearerEngineImpl(parent), - pollingRequired(false), - initialized(false) -{ -} - -QBBEngine::~QBBEngine() -{ -} - - -QString QBBEngine::getInterfaceFromId(const QString &id) -{ - const QMutexLocker locker(&mutex); - - return configurationInterface.value(id); -} - -bool QBBEngine::hasIdentifier(const QString &id) -{ - const QMutexLocker locker(&mutex); - - return configurationInterface.contains(id); -} - -void QBBEngine::connectToId(const QString &id) -{ - Q_EMIT connectionError(id, OperationNotSupported); -} - -void QBBEngine::disconnectFromId(const QString &id) -{ - Q_EMIT connectionError(id, OperationNotSupported); -} - -void QBBEngine::initialize() -{ - if (initialized) { - qWarning("called, but instance already initialized."); - return; - } - - instanceStorage()->setLocalData(new EngineInstanceHolder(this)); - - if (netstatus_request_events(0) != BPS_SUCCESS) { - qWarning("cannot register for network events. Polling enabled."); - - const QMutexLocker locker(&pollingMutex); - pollingRequired = true; - } else { - QAbstractEventDispatcher::instance()->installEventFilter(this); - } - - doRequestUpdate(); -} - -void QBBEngine::requestUpdate() -{ - doRequestUpdate(); -} - -void QBBEngine::doRequestUpdate() -{ - qBearerDebug("entered method"); - - netstatus_interface_list_t interfaceList; - - if ((netstatus_get_interfaces(&interfaceList)) != BPS_SUCCESS) { - qBearerDebug("cannot retrieve interface list"); - return; - } - - const QScopedPointer<netstatus_interface_list_t, - NetstatusInterfaceListCleanupHelper> holder(&interfaceList); - - QSet<QString> currentConfigurations; - - for (int i = 0; i < interfaceList.num_interfaces; i++) { - const char *interface = interfaceList.interfaces[i]; - - qBearerDebug() << "discovered interface" << interface; - - updateConfiguration(interface); - - currentConfigurations << idForName(QString::fromLatin1(interface)); - } - - QMutexLocker locker(&mutex); - - const QStringList keys = accessPointConfigurations.uniqueKeys(); - - locker.unlock(); - - Q_FOREACH (const QString &id, keys) { - if (!currentConfigurations.contains(id)) - removeConfiguration(id); - } - - Q_EMIT updateCompleted(); -} - -QNetworkSession::State QBBEngine::sessionStateForId(const QString &id) -{ - const QMutexLocker locker(&mutex); - - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); - - if (!ptr || !ptr->isValid) - return QNetworkSession::Invalid; - - if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) - return QNetworkSession::Connected; - else if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) - return QNetworkSession::Disconnected; - else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) - return QNetworkSession::NotAvailable; - else if ((ptr->state & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined) - return QNetworkSession::NotAvailable; - - return QNetworkSession::Invalid; -} - -QNetworkConfigurationManager::Capabilities QBBEngine::capabilities() const -{ - return QNetworkConfigurationManager::ForcedRoaming; -} - -QNetworkSessionPrivate *QBBEngine::createSessionBackend() -{ - return new QNetworkSessionPrivateImpl; -} - -QNetworkConfigurationPrivatePointer QBBEngine::defaultConfiguration() -{ - char *interface = 0; - - if (netstatus_get_default_interface(&interface) != BPS_SUCCESS) - return QNetworkConfigurationPrivatePointer(); - - if (!interface) - return QNetworkConfigurationPrivatePointer(); - - const QScopedPointer<char, NetstatusInterfaceCleanupHelper> holder(interface); - - const QString id = idForName(QString::fromLatin1(interface)); - - const QMutexLocker locker(&mutex); - - if (accessPointConfigurations.contains(id)) { - qBearerDebug() << "found default interface:" << id; - - return accessPointConfigurations.value(id); - } - - return QNetworkConfigurationPrivatePointer(); -} - -bool QBBEngine::requiresPolling() const -{ - const QMutexLocker locker(&pollingMutex); - - return pollingRequired; -} - -bool QBBEngine::nativeEventFilter(const QByteArray &eventType, void *message, long *result) -{ - Q_UNUSED(eventType); - Q_UNUSED(result); - - bps_event_t * const event = static_cast<bps_event_t *>(message); - - Q_ASSERT(event); - - if (bps_event_get_domain(event) == netstatus_get_domain()) { - qBearerDebug("got update request."); - doRequestUpdate(); - } - - return false; -} - -void QBBEngine::updateConfiguration(const char *interface) -{ - netstatus_interface_details_t *details = 0; - - if (netstatus_get_interface_details(interface, &details) != BPS_SUCCESS) { - qBearerDebug() << "cannot retrieve details for interface" << interface; - - return; - } - - const QString name = QString::fromLatin1(netstatus_interface_get_name(details)); - const QString id = idForName(name); - - - const netstatus_interface_type_t type = netstatus_interface_get_type(details); - const netstatus_ip_status_t ipStatus = netstatus_interface_get_ip_status(details); - - netstatus_free_interface_details(&details); - - QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined; - - if (ipStatus == NETSTATUS_IP_STATUS_OK) - state |= QNetworkConfiguration::Active; - - QMutexLocker locker(&mutex); - - if (accessPointConfigurations.contains(id)) { - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); - - bool changed = false; - - QMutexLocker ptrLocker(&ptr->mutex); - - if (!ptr->isValid) { - ptr->isValid = true; - changed = true; - } - - if (ptr->name != name) { - ptr->name = name; - changed = true; - } - - if (ptr->id != id) { - ptr->id = id; - changed = true; - } - - if (ptr->state != state) { - ptr->state = state; - changed = true; - } - - const netstatus_ip_status_t oldIpStatus = ptr->oldIpStatus; - ptr->oldIpStatus = ipStatus; - - ptrLocker.unlock(); - - locker.unlock(); - - if (changed) { - qBearerDebug() << "configuration changed:" << interface; - - Q_EMIT configurationChanged(ptr); - } else { - // maybe Wifi has changed but gateway not yet ready etc. - qBearerDebug("configuration has not changed."); - if (oldIpStatus != ipStatus) { // if IP status changed - if (ipStatus != NETSTATUS_IP_STATUS_OK - && ipStatus != NETSTATUS_IP_STATUS_ERROR_NOT_UP - && ipStatus != NETSTATUS_IP_STATUS_ERROR_NOT_CONFIGURED) { - // work around race condition in netstatus API by just checking - // again in 300 ms - QTimer::singleShot(300, this, SLOT(doRequestUpdate())); - } - } - } - - return; - } - - QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); - - ptr->name = name; - ptr->isValid = true; - ptr->id = id; - ptr->state = state; - ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->bearerType = interfaceType(type); - - accessPointConfigurations.insert(id, ptr); - configurationInterface.insert(id, name); - - locker.unlock(); - - qBearerDebug() << "configuration added:" << interface; - - Q_EMIT configurationAdded(ptr); -} - -void QBBEngine::removeConfiguration(const QString &id) -{ - QMutexLocker locker(&mutex); - - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.take(id); - - configurationInterface.remove(ptr->id); - - locker.unlock(); - - Q_EMIT configurationRemoved(ptr); -} - -QT_END_NAMESPACE - -#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/blackberry/qbbengine.h b/src/plugins/bearer/blackberry/qbbengine.h deleted file mode 100644 index 08790797ea..0000000000 --- a/src/plugins/bearer/blackberry/qbbengine.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBBENGINE_H -#define QBBENGINE_H - -#include "../qbearerengine_impl.h" - -#include <QAbstractEventDispatcher> -#include <QAbstractNativeEventFilter> - -#ifndef QT_NO_BEARERMANAGEMENT - -struct bps_event_t; - -QT_BEGIN_NAMESPACE - -class QNetworkConfigurationPrivate; -class QNetworkSessionPrivate; - -class QBBEngine : public QBearerEngineImpl, public QAbstractNativeEventFilter -{ - Q_OBJECT - -public: - explicit QBBEngine(QObject *parent = 0); - ~QBBEngine(); - - QString getInterfaceFromId(const QString &id) Q_DECL_OVERRIDE; - bool hasIdentifier(const QString &id) Q_DECL_OVERRIDE; - - void connectToId(const QString &id) Q_DECL_OVERRIDE; - void disconnectFromId(const QString &id) Q_DECL_OVERRIDE; - - Q_INVOKABLE void initialize() Q_DECL_OVERRIDE; - Q_INVOKABLE void requestUpdate() Q_DECL_OVERRIDE; - - QNetworkSession::State sessionStateForId(const QString &id) Q_DECL_OVERRIDE; - - QNetworkConfigurationManager::Capabilities capabilities() const Q_DECL_OVERRIDE; - - QNetworkSessionPrivate *createSessionBackend() Q_DECL_OVERRIDE; - - QNetworkConfigurationPrivatePointer defaultConfiguration() Q_DECL_OVERRIDE; - - bool requiresPolling() const Q_DECL_OVERRIDE; - - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - -protected: - void updateConfiguration(const char *interface); - void removeConfiguration(const QString &id); - -private Q_SLOTS: - void doRequestUpdate(); - -private: - QHash<QString, QString> configurationInterface; - - mutable QMutex pollingMutex; - - bool pollingRequired; - bool initialized; -}; - - -QT_END_NAMESPACE - -#endif // QT_NO_BEARERMANAGEMENT - -#endif // QBBENGINE_H diff --git a/src/plugins/generic/evdevtablet/main.cpp b/src/plugins/generic/evdevtablet/main.cpp index 62524e8f33..3a9fd4f1dd 100644 --- a/src/plugins/generic/evdevtablet/main.cpp +++ b/src/plugins/generic/evdevtablet/main.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include <QtGui/qgenericplugin.h> -#include <QtPlatformSupport/private/qevdevtablet_p.h> +#include <QtPlatformSupport/private/qevdevtabletmanager_p.h> QT_BEGIN_NAMESPACE @@ -44,7 +44,6 @@ class QEvdevTabletPlugin : public QGenericPlugin public: QEvdevTabletPlugin(); - QStringList keys() const; QObject* create(const QString &key, const QString &specification) Q_DECL_OVERRIDE; }; @@ -52,16 +51,11 @@ QEvdevTabletPlugin::QEvdevTabletPlugin() { } -QStringList QEvdevTabletPlugin::keys() const -{ - return QStringList() << "EvdevTablet"; -} - -QObject *QEvdevTabletPlugin::create(const QString &key, +QObject* QEvdevTabletPlugin::create(const QString &key, const QString &spec) { if (!key.compare(QLatin1String("EvdevTablet"), Qt::CaseInsensitive)) - return new QEvdevTabletHandlerThread(spec); + return new QEvdevTabletManager(key, spec); return 0; } diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp index 2b42889cb1..2598bc5caf 100644 --- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp +++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp @@ -36,6 +36,7 @@ #include <QRect> #include <QWindow> #include <QGuiApplication> +#include <QTouchDevice> #include <qpa/qwindowsysteminterface.h> diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index a952123576..0148d36a6c 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -397,6 +397,7 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal bool retval = reply.value(); qCDebug(qtQpaInputMethods) << "filterEventFinished return" << code << sym << state << retval; if (!retval) { +#ifndef QT_NO_CONTEXTMENU if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu && window != NULL) { const QPoint globalPos = window->screen()->handle()->cursor()->pos(); @@ -404,6 +405,7 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers); } +#endif // QT_NO_CONTEXTMENU QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, code, sym, state, string, isAutoRepeat); diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index f500d6e413..2bc3b0dc7d 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -487,7 +487,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para // Obtain a handle to the main library (the library that contains the main() function). // This library should already be loaded, and calling dlopen() will just return a reference to it. m_mainLibraryHnd = dlopen(m_applicationParams.first().data(), 0); - if (m_mainLibraryHnd == nullptr) { + if (Q_UNLIKELY(!m_mainLibraryHnd)) { qCritical() << "dlopen failed:" << dlerror(); return false; } @@ -497,7 +497,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para m_main = (Main)dlsym(RTLD_DEFAULT, "main"); } - if (!m_main) { + if (Q_UNLIKELY(!m_main)) { qCritical() << "dlsym failed:" << dlerror() << endl << "Could not find main method"; return false; diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 0eddb26959..2e4c3d71ab 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -339,7 +339,7 @@ QAndroidInputContext::QAndroidInputContext() : QPlatformInputContext(), m_composingTextStart(-1), m_blockUpdateSelection(false), m_batchEditNestingLevel(0), m_focusObject(0) { jclass clazz = QJNIEnvironmentPrivate::findClass(QtNativeInputConnectionClassName); - if (clazz == NULL) { + if (Q_UNLIKELY(!clazz)) { qCritical() << "Native registration unable to find class '" << QtNativeInputConnectionClassName << '\''; @@ -347,7 +347,7 @@ QAndroidInputContext::QAndroidInputContext() } QJNIEnvironmentPrivate env; - if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0) { + if (Q_UNLIKELY(env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0)) { qCritical() << "RegisterNatives failed for '" << QtNativeInputConnectionClassName << '\''; @@ -355,7 +355,7 @@ QAndroidInputContext::QAndroidInputContext() } clazz = QJNIEnvironmentPrivate::findClass(QtExtractedTextClassName); - if (clazz == NULL) { + if (Q_UNLIKELY(!clazz)) { qCritical() << "Native registration unable to find class '" << QtExtractedTextClassName << '\''; @@ -364,43 +364,43 @@ QAndroidInputContext::QAndroidInputContext() m_extractedTextClass = static_cast<jclass>(env->NewGlobalRef(clazz)); m_classConstructorMethodID = env->GetMethodID(m_extractedTextClass, "<init>", "()V"); - if (m_classConstructorMethodID == NULL) { + if (Q_UNLIKELY(!m_classConstructorMethodID)) { qCritical() << "GetMethodID failed"; return; } m_partialEndOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialEndOffset", "I"); - if (m_partialEndOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_partialEndOffsetFieldID)) { qCritical() << "Can't find field partialEndOffset"; return; } m_partialStartOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialStartOffset", "I"); - if (m_partialStartOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_partialStartOffsetFieldID)) { qCritical() << "Can't find field partialStartOffset"; return; } m_selectionEndFieldID = env->GetFieldID(m_extractedTextClass, "selectionEnd", "I"); - if (m_selectionEndFieldID == NULL) { + if (Q_UNLIKELY(!m_selectionEndFieldID)) { qCritical() << "Can't find field selectionEnd"; return; } m_selectionStartFieldID = env->GetFieldID(m_extractedTextClass, "selectionStart", "I"); - if (m_selectionStartFieldID == NULL) { + if (Q_UNLIKELY(!m_selectionStartFieldID)) { qCritical() << "Can't find field selectionStart"; return; } m_startOffsetFieldID = env->GetFieldID(m_extractedTextClass, "startOffset", "I"); - if (m_startOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_startOffsetFieldID)) { qCritical() << "Can't find field startOffset"; return; } m_textFieldID = env->GetFieldID(m_extractedTextClass, "text", "Ljava/lang/String;"); - if (m_textFieldID == NULL) { + if (Q_UNLIKELY(!m_textFieldID)) { qCritical() << "Can't find field text"; return; } diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp index a8bbec9400..835ca8a10a 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp @@ -47,7 +47,7 @@ void QAndroidPlatformFontDatabase::populateFontDatabase() QString fontpath = fontDir(); QDir dir(fontpath); - if (!dir.exists()) { + if (Q_UNLIKELY(!dir.exists())) { qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?", qPrintable(fontpath)); } diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 2a127f5c3c..23d242a95f 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -120,14 +120,14 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidPlatformNativeInterface = new QAndroidPlatformNativeInterface(); m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (m_eglDisplay == EGL_NO_DISPLAY) + if (Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY)) qFatal("Could not open egl display"); EGLint major, minor; - if (!eglInitialize(m_eglDisplay, &major, &minor)) + if (Q_UNLIKELY(!eglInitialize(m_eglDisplay, &major, &minor))) qFatal("Could not initialize egl display"); - if (!eglBindAPI(EGL_OPENGL_ES_API)) + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) qFatal("Could not bind GL_ES API"); m_primaryScreen = new QAndroidPlatformScreen(); diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp index 57d3bfaf22..85f51d7d29 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp @@ -175,7 +175,7 @@ void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config) m_androidSurfaceObject = QJNIObjectPrivate(); m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL); m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat()); - if (m_eglSurface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE)) { EGLint error = eglGetError(); eglTerminate(m_eglDisplay); qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 5531910555..94e132fc9a 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -204,12 +204,12 @@ QJsonObject AndroidStyle::loadStyleData() QJsonParseError error; QJsonDocument document = QJsonDocument::fromJson(f.readAll(), &error); - if (document.isNull()) { + if (Q_UNLIKELY(document.isNull())) { qCritical() << error.errorString(); return QJsonObject(); } - if (!document.isObject()) { + if (Q_UNLIKELY(!document.isObject())) { qCritical() << "Style.json does not contain a valid style."; return QJsonObject(); } @@ -219,7 +219,7 @@ QJsonObject AndroidStyle::loadStyleData() static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette) { double pixelDensity = QHighDpiScaling::isActive() ? QtAndroid::pixelDensity() : 1.0; - std::shared_ptr<AndroidStyle> style(new AndroidStyle); + std::shared_ptr<AndroidStyle> style = std::make_shared<AndroidStyle>(); style->m_styleData = AndroidStyle::loadStyleData(); if (style->m_styleData.isEmpty()) return std::shared_ptr<AndroidStyle>(); diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index ba0e6b001a..fec1da334f 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -84,7 +84,7 @@ contains(QT_CONFIG, opengl.*) { RESOURCES += qcocoaresources.qrc -LIBS += -framework Cocoa -framework Carbon -framework IOKit -lcups +LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups QT += core-private gui-private platformsupport-private diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm index 43ff715161..4ec2b4ffc4 100644 --- a/src/plugins/platforms/cocoa/main.mm +++ b/src/plugins/platforms/cocoa/main.mm @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <qpa/qplatformintegrationplugin.h> #include <qpa/qplatformthemeplugin.h> diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.h b/src/plugins/platforms/cocoa/qcocoaaccessibility.h index 228643ab26..2d1aa41a9a 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.h +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.h @@ -33,7 +33,7 @@ #ifndef QCOCOAACCESIBILITY_H #define QCOCOAACCESIBILITY_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtGui> #include <qpa/qplatformaccessibility.h> diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 723c341e59..e8d69e9dbb 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -336,6 +336,7 @@ bool hasValueAttribute(QAccessibleInterface *interface) Q_ASSERT(interface); const QAccessible::Role qtrole = interface->role(); if (qtrole == QAccessible::EditableText + || qtrole == QAccessible::StaticText || interface->valueInterface() || interface->state().checkable) { return true; @@ -347,6 +348,9 @@ bool hasValueAttribute(QAccessibleInterface *interface) id getValueAttribute(QAccessibleInterface *interface) { const QAccessible::Role qtrole = interface->role(); + if (qtrole == QAccessible::StaticText) { + return QCFString::toNSString(interface->text(QAccessible::Name)); + } if (qtrole == QAccessible::EditableText) { if (QAccessibleTextInterface *textInterface = interface->textInterface()) { // VoiceOver will read out the entire text string at once when returning diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index b55393c7dc..5b2ee1c284 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -292,6 +292,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of QSize qtSize = iface->rect().size(); return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())]; } else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) { + if (iface->role() == QAccessible::StaticText) + return nil; return QCFString::toNSString(iface->text(QAccessible::Name)); } else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) { return QCFString::toNSString(iface->text(QAccessible::Description)); diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm index d9919f1120..7d0018a595 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm @@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent() { - if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) + if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) // In a plugin we cannot chain sendEvent hooks: a second plugin could // store the implementation of the first, which during the program flow // can be unloaded. @@ -207,7 +207,7 @@ void qt_redirectNSApplicationSendEvent() void qt_resetNSApplicationSendEvent() { - if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) + if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) return; diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h index abaaba91a5..a0eb8cc6fd 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h @@ -79,7 +79,7 @@ // -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include <qglobal.h> #include <private/qcore_mac_p.h> diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index 5a199de4a5..839b536863 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -34,7 +34,7 @@ #ifndef QBACKINGSTORE_COCOA_H #define QBACKINGSTORE_COCOA_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoawindow.h" #include "qnsview.h" diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index 8843e009a2..ddc2938855 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -31,13 +31,13 @@ ** ****************************************************************************/ -#include "qcocoacolordialoghelper.h" - #ifndef QT_NO_COLORDIALOG #include <QtCore/qdebug.h> #include <QtCore/qtimer.h> +#include <qpa/qplatformtheme.h> +#include "qcocoacolordialoghelper.h" #include "qcocoahelpers.h" #import <AppKit/AppKit.h> @@ -52,7 +52,7 @@ static NSButton *macCreateButton(const char *text, NSView *superview) [button setButtonType:NSMomentaryLightButton]; [button setBezelStyle:NSRoundedBezelStyle]; [button setTitle:(NSString*)(CFStringRef)QCFString( - qt_mac_removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; + QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; [[button cell] setFont:[NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; [superview addSubview:button]; diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index d104939f0c..58be5414f1 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -34,7 +34,7 @@ #ifndef QWINDOWSCURSOR_H #define QWINDOWSCURSOR_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtCore> #include <qpa/qplatformcursor.h> diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h index c1eeb34679..51de5dd5ed 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.h +++ b/src/plugins/platforms/cocoa/qcocoadrag.h @@ -34,7 +34,7 @@ #ifndef QCOCOADRAG_H #define QCOCOADRAG_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtGui> #include <qpa/qplatformdrag.h> #include <private/qsimpledrag_p.h> diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 1865624d57..117eba1b2a 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -80,7 +80,7 @@ #include <qdebug.h> #undef slots -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <Carbon/Carbon.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 9dc013ba4d..0bfb105a5d 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -31,6 +31,8 @@ ** ****************************************************************************/ +#include <qpa/qplatformtheme.h> + #include "qcocoafiledialoghelper.h" #ifndef QT_NO_FILEDIALOG @@ -180,7 +182,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate); static QString strippedText(QString s) { s.remove( QString::fromLatin1("...") ); - return qt_mac_removeMnemonics(s).trimmed(); + return QPlatformTheme::removeMnemonics(s).trimmed(); } - (NSString *)strip:(const QString &)label diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index d1802fe4f9..c1c871f02b 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -31,17 +31,17 @@ ** ****************************************************************************/ -#include "qcocoafontdialoghelper.h" - #ifndef QT_NO_FONTDIALOG #include <QtCore/qtimer.h> #include <QtGui/qfontdatabase.h> +#include <qpa/qplatformtheme.h> #include <private/qfont_p.h> #include <private/qfontengine_p.h> #include <private/qfontengine_coretext_p.h> +#include "qcocoafontdialoghelper.h" #include "qcocoahelpers.h" #import <AppKit/AppKit.h> @@ -72,7 +72,7 @@ static NSButton *macCreateButton(const char *text, NSView *superview) [button setButtonType:NSMomentaryLightButton]; [button setBezelStyle:NSRoundedBezelStyle]; [button setTitle:(NSString*)(CFStringRef)QCFString( - qt_mac_removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; + QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; [[button cell] setFont:[NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; [superview addSubview:button]; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index fa6db018a7..cac53b14f9 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -40,7 +40,7 @@ #include <QtGui/QWindow> #undef slots -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 0f9b8b900d..d43c8e5ee9 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -39,7 +39,7 @@ #include <QtPlatformSupport/private/cglconvenience_p.h> #include <QtPlatformHeaders/qcocoanativecontext.h> -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index b86a17ca12..a75316acba 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -90,7 +90,6 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions); // Misc void qt_mac_transformProccessToForegroundApplication(); -QString qt_mac_removeMnemonics(const QString &original); CGColorSpaceRef qt_mac_genericColorSpace(); CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget); CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice); diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index f51c21ee9b..cfb7e911cc 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -31,6 +31,8 @@ ** ****************************************************************************/ +#include <qpa/qplatformtheme.h> + #include "qcocoahelpers.h" @@ -46,6 +48,8 @@ #include <algorithm> +#include <Carbon/Carbon.h> + QT_BEGIN_NAMESPACE // @@ -439,88 +443,49 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions) // Misc // -// Changes the process type for this process to kProcessTransformToForegroundApplication, +// Sets the activation policy for this process to NSApplicationActivationPolicyRegular, // unless either LSUIElement or LSBackgroundOnly is set in the Info.plist. void qt_mac_transformProccessToForegroundApplication() { - ProcessSerialNumber psn; - if (GetCurrentProcess(&psn) == noErr) { - bool forceTransform = true; - CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), - CFSTR("LSUIElement")); + bool forceTransform = true; + CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), + CFSTR("LSUIElement")); + if (value) { + CFTypeID valueType = CFGetTypeID(value); + // Officially it's supposed to be a string, a boolean makes sense, so we'll check. + // A number less so, but OK. + if (valueType == CFStringGetTypeID()) + forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); + else if (valueType == CFBooleanGetTypeID()) + forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value)); + else if (valueType == CFNumberGetTypeID()) { + int valueAsInt; + CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt); + forceTransform = !valueAsInt; + } + } + + if (forceTransform) { + value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), + CFSTR("LSBackgroundOnly")); if (value) { CFTypeID valueType = CFGetTypeID(value); - // Officially it's supposed to be a string, a boolean makes sense, so we'll check. - // A number less so, but OK. - if (valueType == CFStringGetTypeID()) - forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); - else if (valueType == CFBooleanGetTypeID()) + if (valueType == CFBooleanGetTypeID()) forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value)); + else if (valueType == CFStringGetTypeID()) + forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); else if (valueType == CFNumberGetTypeID()) { int valueAsInt; CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt); forceTransform = !valueAsInt; } } - - if (forceTransform) { - value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), - CFSTR("LSBackgroundOnly")); - if (value) { - CFTypeID valueType = CFGetTypeID(value); - if (valueType == CFBooleanGetTypeID()) - forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value)); - else if (valueType == CFStringGetTypeID()) - forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt()); - else if (valueType == CFNumberGetTypeID()) { - int valueAsInt; - CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt); - forceTransform = !valueAsInt; - } - } - } - - if (forceTransform) { - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - } } -} -QString qt_mac_removeMnemonics(const QString &original) -{ - QString returnText(original.size(), 0); - int finalDest = 0; - int currPos = 0; - int l = original.length(); - while (l) { - if (original.at(currPos) == QLatin1Char('&') - && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { - ++currPos; - --l; - if (l == 0) - break; - } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && - original.at(currPos + 1) == QLatin1Char('&') && - original.at(currPos + 2) != QLatin1Char('&') && - original.at(currPos + 3) == QLatin1Char(')')) { - /* remove mnemonics its format is "\s*(&X)" */ - int n = 0; - while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) - ++n; - finalDest -= n; - currPos += 4; - l -= 4; - continue; - } - returnText[finalDest] = original.at(currPos); - ++currPos; - ++finalDest; - --l; + if (forceTransform) { + [[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular]; } - returnText.truncate(finalDest); - return returnText; } - static CGColorSpaceRef m_genericColorSpace = 0; static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash; static bool m_postRoutineRegistered = false; @@ -774,7 +739,7 @@ bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret) QString qt_mac_removeAmpersandEscapes(QString s) { - return qt_mac_removeMnemonics(s).trimmed(); + return QPlatformTheme::removeMnemonics(s).trimmed(); } /*! \internal diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index e7e21c356a..c7875af83e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -34,7 +34,7 @@ #ifndef QPLATFORMINTEGRATION_COCOA_H #define QPLATFORMINTEGRATION_COCOA_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoacursor.h" #include "qcocoawindow.h" diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 6bec6b191d..e469ec5c74 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -317,7 +317,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) // ### For AA_MacPluginApplication we don't want to load the menu nib. // Qt 4 also does not set the application delegate, so that behavior // is matched here. - if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { + if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { // Set app delegate, link to the current delegate (if any) QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate]; @@ -344,7 +344,7 @@ QCocoaIntegration::~QCocoaIntegration() qt_resetNSApplicationSendEvent(); QMacAutoReleasePool pool; - if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { + if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { // remove the apple event handlers installed by QCocoaApplicationDelegate QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate]; [delegate removeAppleEventHandlers]; diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h index 11bbdc5426..9e79d634ab 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.h +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h @@ -36,7 +36,7 @@ #include <qcocoahelpers.h> -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <Carbon/Carbon.h> #include <QtCore/QList> diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 1a516f874b..d404438db6 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoamenubar.h" #include "qcocoawindow.h" diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 0f551bcd7d..968d1a2a4d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -31,6 +31,8 @@ ** ****************************************************************************/ +#include <qpa/qplatformtheme.h> + #include "qcocoamenuitem.h" #include "qcocoamenu.h" @@ -318,7 +320,7 @@ NSMenuItem *QCocoaMenuItem::sync() if (accel.count() > 1) text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")"); - QString finalString = qt_mac_removeMnemonics(text); + QString finalString = QPlatformTheme::removeMnemonics(text); bool useAttributedTitle = false; // Cocoa Font and title if (m_font.resolve()) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h index bdc943f78a..a3eea8bc15 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.h +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h @@ -45,7 +45,7 @@ // We mean it. // -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include <QtCore/private/qcore_mac_p.h> @interface QT_MANGLE_NAMESPACE(QCocoaMenuLoader) : NSResponder diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 41ea1fa49c..d2d3a7d562 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -60,7 +60,7 @@ #include <QtPlatformHeaders/qcocoawindowfunctions.h> -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaservices.mm b/src/plugins/platforms/cocoa/qcocoaservices.mm index 6f3f6c4e1d..75fc32f338 100644 --- a/src/plugins/platforms/cocoa/qcocoaservices.mm +++ b/src/plugins/platforms/cocoa/qcocoaservices.mm @@ -33,8 +33,6 @@ #include "qcocoaservices.h" -#include "qt_mac_p.h" - #include <AppKit/NSWorkspace.h> #include <Foundation/NSURL.h> @@ -47,7 +45,7 @@ bool QCocoaServices::openUrl(const QUrl &url) const QString scheme = url.scheme(); if (scheme.isEmpty()) return openDocument(url); - return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QCFString::toNSString(url.toString(QUrl::FullyEncoded))]]; + return [[NSWorkspace sharedWorkspace] openURL:url.toNSURL()]; } bool QCocoaServices::openDocument(const QUrl &url) @@ -55,7 +53,7 @@ bool QCocoaServices::openDocument(const QUrl &url) if (!url.isValid()) return false; - return [[NSWorkspace sharedWorkspace] openFile:QCFString::toNSString(url.toLocalFile())]; + return [[NSWorkspace sharedWorkspace] openFile:url.toLocalFile().toNSString()]; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 4b73d0af08..51e96cac89 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include "qcocoatheme.h" #include "messages.h" @@ -55,6 +55,8 @@ #include <qpa/qplatformintegration.h> #include <qpa/qplatformnativeinterface.h> +#include <Carbon/Carbon.h> + QT_BEGIN_NAMESPACE const char *QCocoaTheme::name = "cocoa"; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 05e6cf3c9e..e830be212a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -34,7 +34,7 @@ #ifndef QCOCOAWINDOW_H #define QCOCOAWINDOW_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <qpa/qplatformwindow.h> #include <QRect> diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5a59a842c6..18abaddfd7 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -47,8 +47,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformscreen.h> -#include <Cocoa/Cocoa.h> -#include <Carbon/Carbon.h> +#include <AppKit/AppKit.h> #include <QDebug> @@ -685,7 +684,16 @@ void QCocoaWindow::setVisible(bool visible) cocoaEventDispatcherPrivate->beginModalSession(window()); m_hasModalSession = true; } else if ([m_nsWindow canBecomeKeyWindow]) { - [m_nsWindow makeKeyAndOrderFront:nil]; + QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher()); + QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0; + if (cocoaEventDispatcher) + cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); + + if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) + [m_nsWindow makeKeyAndOrderFront:nil]; + else + [m_nsWindow orderFront:nil]; + foreach (QCocoaWindow *childWindow, m_childWindows) childWindow->show(true); } else { @@ -1341,6 +1349,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) } } else { // Child windows have no NSWindow, link the NSViews instead. + if ([m_contentView superview]) + [m_contentView removeFromSuperview]; + [m_parentCocoaWindow->m_contentView addSubview : m_contentView]; QRect rect = windowGeometry(); // Prevent setting a (0,0) window size; causes opengl context diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index 0d1f195f48..8b290866c6 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -39,7 +39,7 @@ #undef slots -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h index b2773a2b9f..fd540e7c34 100644 --- a/src/plugins/platforms/cocoa/qmacdefines_mac.h +++ b/src/plugins/platforms/cocoa/qmacdefines_mac.h @@ -92,7 +92,7 @@ typedef signed long OSStatus; # define old_slots slots # undef slots # endif -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> # ifdef old_slots # undef slots # define slots diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h index e4eec41295..0af0505a47 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h +++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h @@ -47,7 +47,7 @@ #include <QtCore/qglobal.h> -#import <Cocoa/Cocoa.h> +#import <AppKit/AppKit.h> #include <qpa/qwindowsysteminterface.h> #include <qhash.h> diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 50b456cab7..a3541829c6 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -34,7 +34,7 @@ #ifndef QNSVIEW_H #define QNSVIEW_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <QtCore/QPointer> #include <QtGui/QImage> diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 3faa292ae0..528e6f120f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -33,7 +33,6 @@ #include <QtCore/qglobal.h> -#include <Carbon/Carbon.h> #include <dlfcn.h> #include "qnsview.h" diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 1f15da5b3b..d44b02549d 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -31,8 +31,6 @@ ** ****************************************************************************/ -#include <Carbon/Carbon.h> - #include "qnsview.h" #include "qcocoahelpers.h" #include "qcocoaaccessibility.h" diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index b8d344aa0e..794059bc68 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -34,7 +34,7 @@ #ifndef QNSWINDOWDELEGATE_H #define QNSWINDOWDELEGATE_H -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include "qcocoawindow.h" diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index 576e0f9729..9bfc0f7ba1 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -48,7 +48,7 @@ #include "qmacdefines_mac.h" #ifdef __OBJC__ -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <objc/runtime.h> #endif @@ -63,30 +63,10 @@ #include "QtGui/qpainter.h" -#include <Carbon/Carbon.h> - QT_BEGIN_NAMESPACE class QWidget; class QDragMoveEvent; -/* Event masks */ -// internal Qt types - -enum { - //AE types - typeAEClipboardChanged = 1, - //types - typeQWidget = 1, /* QWidget * */ - //params - kEventParamQWidget = 'qwid', /* typeQWidget */ - //events - kEventQtRequestContext = 13, - kEventQtRequestMenubarUpdate = 14, - kEventQtRequestShowSheet = 17, - kEventQtRequestActivate = 18, - kEventQtRequestWindowChange = 20 -}; - // Simple class to manage short-lived regions class QMacSmartQuickDrawRegion { @@ -103,8 +83,6 @@ public: } }; -QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp - class Q_WIDGETS_EXPORT QMacWindowChangeEvent { private: @@ -173,10 +151,6 @@ extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt) # undef check #endif -QFont qfontForThemeFont(ThemeFontID themeID); - -QColor qcolorForThemeTextColor(ThemeTextColor themeColor); - struct QMacDndAnswerRecord { QRect rect; Qt::KeyboardModifiers modifiers; diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp index 154023fb11..418c2e3745 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp @@ -51,7 +51,7 @@ public: HRESULT hr = QWindowsDirect2DContext::instance()->d2dDevice()->CreateDeviceContext( D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &deviceContext); - if (FAILED(hr)) + if (Q_UNLIKELY(FAILED(hr))) qFatal("%s: Couldn't create Direct2D Device Context: %#x", __FUNCTION__, hr); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp index d1814fb85d..789f2fa86f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp @@ -77,7 +77,7 @@ void QEglFSKmsIntegration::platformInit() qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices; d->deleteLater(); - if (devices.isEmpty()) + if (Q_UNLIKELY(devices.isEmpty())) qFatal("Could not find DRM device!"); m_devicePath = devices.first(); @@ -85,7 +85,7 @@ void QEglFSKmsIntegration::platformInit() } m_device = new QEglFSKmsDevice(this, m_devicePath); - if (!m_device->open()) + if (Q_UNLIKELY(!m_device->open())) qFatal("Could not open device %s - aborting!", qPrintable(m_devicePath)); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index f7450708ab..03cfea72b8 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -53,20 +53,20 @@ QEglFSKmsEglDeviceIntegration::QEglFSKmsEglDeviceIntegration() void QEglFSKmsEglDeviceIntegration::platformInit() { - if (!query_egl_device()) + if (Q_UNLIKELY(!query_egl_device())) qFatal("Could not set up EGL device!"); const char *deviceName = m_funcs->query_device_string(m_egl_device, EGL_DRM_DEVICE_FILE_EXT); - if (!deviceName) + if (Q_UNLIKELY(!deviceName)) qFatal("Failed to query device name from EGLDevice"); qCDebug(qLcEglfsKmsDebug, "Opening %s", deviceName); m_dri_fd = drmOpen(deviceName, Q_NULLPTR); - if (m_dri_fd < 0) + if (Q_UNLIKELY(m_dri_fd < 0)) qFatal("Could not open DRM device"); - if (!setup_kms()) + if (Q_UNLIKELY(!setup_kms())) qFatal("Could not set up KMS on device %s!", m_device.constData()); qCDebug(qLcEglfsKmsDebug, "DRM/KMS initialized"); @@ -101,14 +101,14 @@ EGLDisplay QEglFSKmsEglDeviceIntegration::createDisplay(EGLNativeDisplayType nat display = eglGetDisplay(nativeDisplay); } - if (display == EGL_NO_DISPLAY) + if (Q_UNLIKELY(display == EGL_NO_DISPLAY)) qFatal("Could not get EGL display"); EGLint major, minor; - if (!eglInitialize(display, &major, &minor)) + if (Q_UNLIKELY(!eglInitialize(display, &major, &minor))) qFatal("Could not initialize egl display"); - if (!eglBindAPI(EGL_OPENGL_ES_API)) + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) qFatal("Failed to bind EGL_OPENGL_ES_API\n"); return display; @@ -267,8 +267,8 @@ QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const QEglJetsonTK1Window *eglWindow = new QEglJetsonTK1Window(window, this); m_funcs->initialize(eglWindow->screen()->display()); - if (!(m_funcs->has_egl_output_base && m_funcs->has_egl_output_drm && m_funcs->has_egl_stream - && m_funcs->has_egl_stream_producer_eglsurface && m_funcs->has_egl_stream_consumer_egloutput)) + if (Q_UNLIKELY(!(m_funcs->has_egl_output_base && m_funcs->has_egl_output_drm && m_funcs->has_egl_stream && + m_funcs->has_egl_stream_producer_eglsurface && m_funcs->has_egl_stream_consumer_egloutput))) qFatal("Required extensions missing!"); return eglWindow; @@ -310,7 +310,7 @@ void QEglFSKmsEglDeviceIntegration::waitForVSync(QPlatformSurface *) const -1, 0, 0, &m_drm_connector->connector_id, 1, const_cast<const drmModeModeInfoPtr>(&m_drm_mode)); - if (ret) + if (Q_UNLIKELY(ret)) qFatal("drmModeSetCrtc failed"); } } @@ -379,7 +379,7 @@ bool QEglFSKmsEglDeviceIntegration::setup_kms() } } - if (crtc == 0) + if (Q_UNLIKELY(crtc == 0)) qFatal("No suitable CRTC available"); m_drm_connector = connector; @@ -399,7 +399,7 @@ bool QEglFSKmsEglDeviceIntegration::setup_kms() bool QEglFSKmsEglDeviceIntegration::query_egl_device() { m_funcs = new QEGLStreamConvenience; - if (!m_funcs->has_egl_device_base) + if (Q_UNLIKELY(!m_funcs->has_egl_device_base)) qFatal("EGL_EXT_device_base missing"); EGLint num_devices = 0; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 4d29b96608..ef586622e2 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -172,7 +172,7 @@ void QEglFSX11Integration::sendConnectionEvent(xcb_atom_t a) void QEglFSX11Integration::platformInit() { m_display = XOpenDisplay(0); - if (!m_display) + if (Q_UNLIKELY(!m_display)) qFatal("Could not open display"); XSetEventQueueOwner(DISPLAY, XCBOwnsEventQueue); diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/qeglfscursor.cpp index eea130a754..bfb69d3e8f 100644 --- a/src/plugins/platforms/eglfs/qeglfscursor.cpp +++ b/src/plugins/platforms/eglfs/qeglfscursor.cpp @@ -38,6 +38,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLShaderProgram> +#include <QtCore/QFile> #include <QtCore/QJsonDocument> #include <QtCore/QJsonArray> #include <QtCore/QJsonObject> diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp index 8af48a893b..d64cc457f3 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp @@ -155,7 +155,7 @@ void QEGLDeviceIntegration::platformInit() framebuffer = qt_safe_open(fbDev, O_RDONLY); - if (framebuffer == -1) { + if (Q_UNLIKELY(framebuffer == -1)) { qWarning("EGLFS: Failed to open %s", fbDev.constData()); qFatal("EGLFS: Can't continue without a display"); } diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2086ce56e2..001dd76803 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -118,11 +118,11 @@ void QEglFSIntegration::initialize() qt_egl_device_integration()->platformInit(); m_display = qt_egl_device_integration()->createDisplay(nativeDisplay()); - if (m_display == EGL_NO_DISPLAY) + if (Q_UNLIKELY(m_display == EGL_NO_DISPLAY)) qFatal("Could not open egl display"); EGLint major, minor; - if (!eglInitialize(m_display, &major, &minor)) + if (Q_UNLIKELY(!eglInitialize(m_display, &major, &minor))) qFatal("Could not initialize egl display"); m_inputContext = QPlatformInputContextFactory::create(); diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 8301be8c17..b29981bc98 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -102,17 +102,15 @@ void QEglFSWindow::create() QEglFSScreen *screen = this->screen(); QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); if (screen->primarySurface() != EGL_NO_SURFACE) { - if (isRaster() && compositor->targetWindow()) { - m_format = compositor->targetWindow()->format(); - return; - } - + if (Q_UNLIKELY(!isRaster() || !compositor->targetWindow())) { #if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK) - // We can have either a single OpenGL window or multiple raster windows. - // Other combinations cannot work. - qFatal("EGLFS: OpenGL windows cannot be mixed with others."); + // We can have either a single OpenGL window or multiple raster windows. + // Other combinations cannot work. + qFatal("EGLFS: OpenGL windows cannot be mixed with others."); #endif - + return; + } + m_format = compositor->targetWindow()->format(); return; } @@ -122,7 +120,7 @@ void QEglFSWindow::create() resetSurface(); - if (m_surface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_surface == EGL_NO_SURFACE)) { EGLint error = eglGetError(); eglTerminate(screen->display()); qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); @@ -135,7 +133,7 @@ void QEglFSWindow::create() context->setShareContext(qt_gl_global_share_context()); context->setFormat(m_format); context->setScreen(window()->screen()); - if (!context->create()) + if (Q_UNLIKELY(!context->create())) qFatal("EGLFS: Failed to create compositing context"); compositor->setTarget(context, window()); } diff --git a/src/plugins/platforms/haiku/qhaikuwindow.cpp b/src/plugins/platforms/haiku/qhaikuwindow.cpp index 9622d12111..1576e7c04e 100644 --- a/src/plugins/platforms/haiku/qhaikuwindow.cpp +++ b/src/plugins/platforms/haiku/qhaikuwindow.cpp @@ -127,7 +127,7 @@ QHaikuWindow::QHaikuWindow(QWindow *window) m_window = haikuWindow; - if (!m_window) + if (Q_UNLIKELY(!m_window)) qFatal("QHaikuWindow: failed to create window"); setGeometry(rect); diff --git a/src/plugins/platforms/ios/ios.pro b/src/plugins/platforms/ios/ios.pro index bf7849b740..236234628d 100644 --- a/src/plugins/platforms/ios/ios.pro +++ b/src/plugins/platforms/ios/ios.pro @@ -30,7 +30,8 @@ OBJECTIVE_SOURCES = \ qiostextresponder.mm \ qiosmenu.mm \ qiosfileengineassetslibrary.mm \ - qiosfiledialog.mm + qiosfiledialog.mm \ + qiosmessagedialog.mm HEADERS = \ qiosintegration.h \ @@ -54,7 +55,8 @@ HEADERS = \ qiosmenu.h \ qiosfileenginefactory.h \ qiosfileengineassetslibrary.h \ - qiosfiledialog.h + qiosfiledialog.h \ + qiosmessagedialog.h OTHER_FILES = \ quiview_textinput.mm \ diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index 0e9f176487..e1c6071c38 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -129,7 +129,7 @@ namespace // Which we verify, just in case struct rlimit stackLimit = {0, 0}; - if (getrlimit(RLIMIT_STACK, &stackLimit) == 0 && stackSize > stackLimit.rlim_cur) + if (Q_UNLIKELY(getrlimit(RLIMIT_STACK, &stackLimit) == 0 && stackSize > stackLimit.rlim_cur)) qFatal("Unexpectedly exceeded stack limit"); return stackSize; @@ -250,7 +250,7 @@ static void __attribute__((noinline, noreturn)) user_main_trampoline() unsigned int bufferSize = [arg lengthOfBytesUsingEncoding:cStringEncoding] + 1; argv[i] = reinterpret_cast<char *>(malloc(bufferSize)); - if (![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding]) + if (Q_UNLIKELY(![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding])) qFatal("Could not convert argv[%d] to C string", i); } diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 0e3da8dce8..72c9286f86 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -70,7 +70,7 @@ QIOSIntegration::QIOSIntegration() , m_accessibility(0) , m_debugWindowManagement(false) { - if (![UIApplication sharedApplication]) { + if (Q_UNLIKELY(![UIApplication sharedApplication])) { qFatal("Error: You are creating QApplication before calling UIApplicationMain.\n" \ "If you are writing a native iOS application, and only want to use Qt for\n" \ "parts of the application, a good place to create QApplication is from within\n" \ diff --git a/src/plugins/platforms/ios/qiosmenu.h b/src/plugins/platforms/ios/qiosmenu.h index ec23b55507..3beb58b503 100644 --- a/src/plugins/platforms/ios/qiosmenu.h +++ b/src/plugins/platforms/ios/qiosmenu.h @@ -74,9 +74,6 @@ public: bool m_separator; QIOSMenu *m_menu; QKeySequence m_shortcut; - -private: - QString removeMnemonics(const QString &original); }; typedef QList<QIOSMenuItem *> QIOSMenuItemList; diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index 7aea3729fd..f68321fb3b 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -33,6 +33,7 @@ #include <qglobal.h> #include <qguiapplication.h> +#include <qpa/qplatformtheme.h> #include "qiosglobal.h" #include "qiosmenu.h" @@ -254,7 +255,7 @@ quintptr QIOSMenuItem::tag() const void QIOSMenuItem::setText(const QString &text) { - m_text = removeMnemonics(text); + m_text = QPlatformTheme::removeMnemonics(text); } void QIOSMenuItem::setMenu(QPlatformMenu *menu) @@ -287,41 +288,6 @@ void QIOSMenuItem::setEnabled(bool enabled) m_enabled = enabled; } -QString QIOSMenuItem::removeMnemonics(const QString &original) -{ - // Copied from qcocoahelpers - QString returnText(original.size(), 0); - int finalDest = 0; - int currPos = 0; - int l = original.length(); - while (l) { - if (original.at(currPos) == QLatin1Char('&') - && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { - ++currPos; - --l; - if (l == 0) - break; - } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && - original.at(currPos + 1) == QLatin1Char('&') && - original.at(currPos + 2) != QLatin1Char('&') && - original.at(currPos + 3) == QLatin1Char(')')) { - /* remove mnemonics its format is "\s*(&X)" */ - int n = 0; - while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) - ++n; - finalDest -= n; - currPos += 4; - l -= 4; - continue; - } - returnText[finalDest] = original.at(currPos); - ++currPos; - ++finalDest; - --l; - } - returnText.truncate(finalDest); - return returnText; -} QIOSMenu::QIOSMenu() : QPlatformMenu() diff --git a/src/plugins/bearer/blackberry/main.cpp b/src/plugins/platforms/ios/qiosmessagedialog.h index ddeaefa75c..a9bd42324e 100644 --- a/src/plugins/bearer/blackberry/main.cpp +++ b/src/plugins/platforms/ios/qiosmessagedialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 Research In Motion +** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. @@ -31,33 +31,35 @@ ** ****************************************************************************/ -#include "qbbengine.h" +#ifndef QIOSMESSAGEDIALOG_H +#define QIOSMESSAGEDIALOG_H -#include <QtNetwork/private/qbearerplugin_p.h> - -#ifndef QT_NO_BEARERMANAGEMENT +#include <QtCore/qeventloop.h> +#include <qpa/qplatformdialoghelper.h> QT_BEGIN_NAMESPACE -class QBBEnginePlugin : public QBearerEnginePlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "blackberry.json") +Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertController); +Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertAction); +class QIOSMessageDialog : public QPlatformMessageDialogHelper +{ public: - QBearerEngine *create(const QString &key) const; -}; + QIOSMessageDialog(); + ~QIOSMessageDialog(); -QBearerEngine *QBBEnginePlugin::create(const QString &key) const -{ - if (key == QLatin1String("blackberry")) - return new QBBEngine; + void exec() Q_DECL_OVERRIDE; + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) Q_DECL_OVERRIDE; + void hide() Q_DECL_OVERRIDE; - return 0; -} +private: + QEventLoop m_eventLoop; + UIAlertController *m_alertController; + QString messageTextPlain(); + UIAlertAction *createAction(StandardButton button); +}; QT_END_NAMESPACE -#include "main.moc" +#endif // QIOSMESSAGEDIALOG_H -#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm new file mode 100644 index 0000000000..39f7d4b1cd --- /dev/null +++ b/src/plugins/platforms/ios/qiosmessagedialog.mm @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#import <UIKit/UIKit.h> + +#include <QtGui/qwindow.h> +#include <QtGui/private/qguiapplication_p.h> +#include <qpa/qplatformtheme.h> + +#include "qiosglobal.h" +#include "quiview.h" +#include "qiosmessagedialog.h" + +QIOSMessageDialog::QIOSMessageDialog() + : m_alertController(Q_NULLPTR) +{ +} + +QIOSMessageDialog::~QIOSMessageDialog() +{ + hide(); +} + +inline QString QIOSMessageDialog::messageTextPlain() +{ + // Concatenate text fragments, and remove HTML tags + const QSharedPointer<QMessageDialogOptions> &opt = options(); + const QString &lineShift = QStringLiteral("\n\n"); + const QString &informativeText = opt->informativeText(); + const QString &detailedText = opt->detailedText(); + + QString text = opt->text(); + if (!informativeText.isEmpty()) + text += lineShift + informativeText; + if (!detailedText.isEmpty()) + text += lineShift + detailedText; + + text.replace(QLatin1String("<p>"), QStringLiteral("\n"), Qt::CaseInsensitive); + text.remove(QRegularExpression(QStringLiteral("<[^>]*>"))); + + return text; +} + +inline UIAlertAction *QIOSMessageDialog::createAction(StandardButton button) +{ + const StandardButton labelButton = button == NoButton ? Ok : button; + const QString &standardLabel = QGuiApplicationPrivate::platformTheme()->standardButtonText(labelButton); + const QString &label = QPlatformTheme::removeMnemonics(standardLabel); + + UIAlertActionStyle style = UIAlertActionStyleDefault; + if (button == Cancel) + style = UIAlertActionStyleCancel; + else if (button == Discard) + style = UIAlertActionStyleDestructive; + + return [UIAlertAction actionWithTitle:label.toNSString() style:style handler:^(UIAlertAction *) { + hide(); + if (button == NoButton) + emit reject(); + else + emit clicked(button, buttonRole(button)); + }]; +} + +void QIOSMessageDialog::exec() +{ + m_eventLoop.exec(QEventLoop::DialogExec); +} + +bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) +{ + Q_UNUSED(windowFlags); + if (m_alertController // Ensure that the dialog is not showing already + || !options() // Some message dialogs don't have options (QErrorMessage) + || windowModality != Qt::ApplicationModal // We can only do app modal dialogs + || QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) // API limitation + return false; + + m_alertController = [[UIAlertController + alertControllerWithTitle:options()->windowTitle().toNSString() + message:messageTextPlain().toNSString() + preferredStyle:UIAlertControllerStyleAlert] retain]; + + if (StandardButtons buttons = options()->standardButtons()) { + for (int i = FirstButton; i < LastButton; i<<=1) { + if (i & buttons) + [m_alertController addAction:createAction(StandardButton(i))]; + } + } else { + // We need at least one button to allow the user close the dialog + [m_alertController addAction:createAction(NoButton)]; + } + + UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window : [UIApplication sharedApplication].keyWindow; + [window.rootViewController presentViewController:m_alertController animated:YES completion:nil]; + return true; +} + +void QIOSMessageDialog::hide() +{ + m_eventLoop.exit(); + [m_alertController dismissViewControllerAnimated:YES completion:nil]; + [m_alertController release]; + m_alertController = Q_NULLPTR; +} diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index bc40069670..dccacb2c0e 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -47,6 +47,7 @@ #include "qiosmenu.h" #include "qiosfiledialog.h" +#include "qiosmessagedialog.h" QT_BEGIN_NAMESPACE @@ -85,6 +86,7 @@ bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const { switch (type) { case FileDialog: + case MessageDialog: return true; default: return false; @@ -97,6 +99,9 @@ QPlatformDialogHelper *QIOSTheme::createPlatformDialogHelper(QPlatformTheme::Dia case FileDialog: return new QIOSFileDialog(); break; + case MessageDialog: + return new QIOSMessageDialog(); + break; default: return 0; } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 91708c0a47..45f66db75d 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -34,6 +34,7 @@ #include "qlinuxfbscreen.h" #include <QtPlatformSupport/private/qfbcursor_p.h> #include <QtPlatformSupport/private/qfbwindow_p.h> +#include <QtCore/QFile> #include <QtCore/QRegularExpression> #include <QtGui/QPainter> diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp index 59062338cb..093a1c689c 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp @@ -74,19 +74,19 @@ QMinimalEglScreen::QMinimalEglScreen(EGLNativeDisplayType display) EGLint major, minor; - if (!eglBindAPI(EGL_OPENGL_ES_API)) { + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) { qWarning("Could not bind GL_ES API\n"); qFatal("EGL error"); } m_dpy = eglGetDisplay(display); - if (m_dpy == EGL_NO_DISPLAY) { + if (Q_UNLIKELY(m_dpy == EGL_NO_DISPLAY)) { qWarning("Could not open egl display\n"); qFatal("EGL error"); } qWarning("Opened display %p\n", m_dpy); - if (!eglInitialize(m_dpy, &major, &minor)) { + if (Q_UNLIKELY(!eglInitialize(m_dpy, &major, &minor))) { qWarning("Could not initialize egl display\n"); qFatal("EGL error"); } @@ -135,9 +135,9 @@ void QMinimalEglScreen::createAndSetPlatformContext() EGLNativeWindowType eglWindow = 0; #ifdef Q_OPENKODE - if (kdInitializeNV() == KD_ENOTINITIALIZED) { + if (Q_UNLIKELY(kdInitializeNV() == KD_ENOTINITIALIZED)) qFatal("Did not manage to initialize openkode"); - } + KDWindow *window = kdCreateWindow(m_dpy,config,0); kdRealizeWindow(window,&eglWindow); @@ -148,7 +148,7 @@ void QMinimalEglScreen::createAndSetPlatformContext() #endif m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL); - if (m_surface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_surface == EGL_NO_SURFACE)) { qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); eglTerminate(m_dpy); qFatal("EGL error"); diff --git a/src/plugins/platforms/mirclient/qmirclientclipboard.cpp b/src/plugins/platforms/mirclient/qmirclientclipboard.cpp index aa2ddf2103..4494847b54 100644 --- a/src/plugins/platforms/mirclient/qmirclientclipboard.cpp +++ b/src/plugins/platforms/mirclient/qmirclientclipboard.cpp @@ -100,7 +100,7 @@ void QMirClientClipboard::onDBusClipboardGetContentsFinished(QDBusPendingCallWat Q_ASSERT(call == mPendingGetContentsCall.data()); QDBusPendingReply<QByteArray> reply = *call; - if (reply.isError()) { + if (Q_UNLIKELY(reply.isError())) { qCritical("QMirClientClipboard - Failed to get system clipboard contents via D-Bus. %s, %s", qPrintable(reply.error().name()), qPrintable(reply.error().message())); // TODO: Might try again later a number of times... @@ -114,7 +114,7 @@ void QMirClientClipboard::onDBusClipboardGetContentsFinished(QDBusPendingCallWat void QMirClientClipboard::onDBusClipboardSetContentsFinished(QDBusPendingCallWatcher *call) { QDBusPendingReply<void> reply = *call; - if (reply.isError()) { + if (Q_UNLIKELY(reply.isError())) { qCritical("QMirClientClipboard - Failed to set the system clipboard contents via D-Bus. %s, %s", qPrintable(reply.error().name()), qPrintable(reply.error().message())); // TODO: Might try again later a number of times... @@ -148,9 +148,8 @@ void QMirClientClipboard::setupDBus() "com.canonical.QtMir.Clipboard", "ContentsChanged", this, SLOT(updateMimeData(QByteArray))); - if (!ok) { + if (Q_UNLIKELY(!ok)) qCritical("QMirClientClipboard - Failed to connect to ContentsChanged signal form the D-Bus system clipboard."); - } mDBusClipboard = new QDBusInterface("com.canonical.QtMir", "/com/canonical/QtMir/Clipboard", diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp index bfba5051e5..bbd7f5ee75 100644 --- a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp +++ b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp @@ -39,6 +39,7 @@ #include "qmirclientwindow.h" #include "qmirclientlogging.h" #include <QtPlatformSupport/private/qeglconvenience_p.h> +#include <QtGui/private/qopenglcontext_p.h> #if !defined(QT_NO_DEBUG) static void printOpenGLESConfig() { @@ -103,6 +104,15 @@ bool QMirClientOpenGLContext::makeCurrent(QPlatformSurface* surface) ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE); printOpenGLESConfig(); #endif + + // When running on the emulator, shaders will be compiled using a thin wrapper around the desktop drivers. + // These wrappers might not support the precision qualifiers, so set the workaround flag to true. + const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); + if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) { + QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); + ctx_d->workaround_missingPrecisionQualifiers = true; + } + return true; } diff --git a/src/plugins/platforms/mirclient/qmirclientintegration.cpp b/src/plugins/platforms/mirclient/qmirclientintegration.cpp index a234f4eac6..87d2002c56 100644 --- a/src/plugins/platforms/mirclient/qmirclientintegration.cpp +++ b/src/plugins/platforms/mirclient/qmirclientintegration.cpp @@ -95,7 +95,7 @@ QMirClientClientIntegration::QMirClientClientIntegration() // Create new application instance mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions); - if (mInstance == nullptr) + if (Q_UNLIKELY(!mInstance)) qFatal("QMirClientClientIntegration: connection to Mir server failed. Check that a Mir server is\n" "running, and the correct socket is being used and is accessible. The shell may have\n" "rejected the incoming connection, so check its log file"); diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index eb704f2dfa..dfaaa43c1d 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -143,7 +143,7 @@ static Window createDummyWindow(QOffscreenX11Info *x11, XVisualInfo *visualInfo) static Window createDummyWindow(QOffscreenX11Info *x11, GLXFBConfig config) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(x11->display(), config); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); Window window = createDummyWindow(x11, visualInfo); XFree(visualInfo); @@ -177,7 +177,7 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL d->window = createDummyWindow(x11, config); } else { XVisualInfo *visualInfo = qglx_findVisualInfo(x11->display(), 0, &d->format); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); d->context = glXCreateContext(x11->display(), visualInfo, d->shareContext, true); if (!d->context && d->shareContext) { diff --git a/src/plugins/platforms/openwfd/qopenwfdport.cpp b/src/plugins/platforms/openwfd/qopenwfdport.cpp index 8da1e9bd34..c1646fbdf9 100644 --- a/src/plugins/platforms/openwfd/qopenwfdport.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdport.cpp @@ -96,9 +96,8 @@ void QOpenWFDPort::attach() mPhysicalSize = QSizeF(physicalWFDSize[0],physicalWFDSize[1]); WFDint numAvailablePipelines = wfdGetPortAttribi(mDevice->handle(),mPort,WFD_PORT_PIPELINE_ID_COUNT); - if (!numAvailablePipelines) { + if (Q_UNLIKELY(!numAvailablePipelines)) qFatal("Not possible to make screen that is not possible to create WFPort with no pipline"); - } WFDint pipeIds[numAvailablePipelines]; wfdGetPortAttribiv(mDevice->handle(),mPort,WFD_PORT_BINDABLE_PIPELINE_IDS,numAvailablePipelines,pipeIds); @@ -109,9 +108,9 @@ void QOpenWFDPort::attach() mDevice-> addToUsedPipelineSet(mPipelineId,this); mPipeline = wfdCreatePipeline(mDevice->handle(),mPipelineId,WFD_NONE); - if (mPipeline == WFD_INVALID_HANDLE) { + if (Q_UNLIKELY(mPipeline == WFD_INVALID_HANDLE)) qFatal("Failed to create pipeline for port %p", this); - } + break; } } diff --git a/src/plugins/platforms/qnx/qblackberrytheme.cpp b/src/plugins/platforms/qnx/qblackberrytheme.cpp deleted file mode 100644 index f75e8f3766..0000000000 --- a/src/plugins/platforms/qnx/qblackberrytheme.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qblackberrytheme.h" - -#include "qqnxfiledialoghelper.h" -#include "qqnxsystemsettings.h" -#include "qqnxintegration.h" - -QT_BEGIN_NAMESPACE - -QBlackberryTheme::QBlackberryTheme(const QQnxIntegration *integration) : m_integration(integration) -{ - // Set the dark theme as default palette - QColor color = QColor(211, 211, 211); - m_defaultPalette.setBrush(QPalette::ButtonText, color); - m_defaultPalette.setBrush(QPalette::WindowText, color); - m_defaultPalette.setBrush(QPalette::Text, color); - - color.setAlpha(179); - m_defaultPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, color); - m_defaultPalette.setBrush(QPalette::Disabled, QPalette::WindowText, color); - m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Text, color); - - color.setRgb(18, 18, 18); - m_defaultPalette.setColor(QPalette::Window, color); - m_defaultPalette.setColor(QPalette::Base, color); - m_defaultPalette.setColor(QPalette::AlternateBase, QColor(50, 50, 50)); - m_defaultPalette.setColor(QPalette::Button, color); - - m_defaultPalette.setBrush(QPalette::Highlight, QColor(0, 168, 223)); - m_defaultPalette.setBrush(QPalette::HighlightedText, QColor(250, 250,250)); -} - -QBlackberryTheme::~QBlackberryTheme() -{ - qDeleteAll(m_fonts); -} - -bool QBlackberryTheme::usePlatformNativeDialog(DialogType type) const -{ - if (type == QPlatformTheme::FileDialog) - return true; -#if !defined(QT_NO_COLORDIALOG) - if (type == QPlatformTheme::ColorDialog) - return false; -#endif -#if !defined(QT_NO_FONTDIALOG) - if (type == QPlatformTheme::FontDialog) - return false; -#endif - return false; -} - -QPlatformDialogHelper *QBlackberryTheme::createPlatformDialogHelper(DialogType type) const -{ - switch (type) { - case QPlatformTheme::FileDialog: - return new QQnxFileDialogHelper(m_integration); -#if !defined(QT_NO_COLORDIALOG) - case QPlatformTheme::ColorDialog: -#endif -#if !defined(QT_NO_FONTDIALOG) - case QPlatformTheme::FontDialog: -#endif - default: - return 0; - } -} - -const QFont *QBlackberryTheme::font(Font type) const -{ - QPlatformFontDatabase *fontDatabase = m_integration->fontDatabase(); - - if (fontDatabase && m_fonts.isEmpty()) - m_fonts = qt_qnx_createRoleFonts(fontDatabase); - return m_fonts.value(type, 0); -} - -const QPalette *QBlackberryTheme::palette(Palette type) const -{ - // Return the default palette - if (type == SystemPalette) - return &m_defaultPalette; - - return QPlatformTheme::palette(type); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qblackberrytheme.h b/src/plugins/platforms/qnx/qblackberrytheme.h deleted file mode 100644 index bcef4e5ef4..0000000000 --- a/src/plugins/platforms/qnx/qblackberrytheme.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBLACKBERRYTHEME_H -#define QBLACKBERRYTHEME_H - -#include <qpa/qplatformtheme.h> - -#include <QtGui/qfont.h> - -#include <QtCore/qhash.h> -#include <QtCore/qstring.h> - -#include <QtGui/QPalette> - -QT_BEGIN_NAMESPACE - -class QQnxIntegration; - -class QBlackberryTheme : public QPlatformTheme -{ -public: - explicit QBlackberryTheme(const QQnxIntegration *); - ~QBlackberryTheme(); - - static QString name() { return QStringLiteral("blackberry"); } - - bool usePlatformNativeDialog(DialogType type) const; - QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; - - const QFont *font(Font type = SystemFont) const; - - const QPalette *palette(Palette type = SystemPalette) const; - -private: - mutable QHash<QPlatformTheme::Font, QFont*> m_fonts; - const QQnxIntegration *m_integration; - QPalette m_defaultPalette; -}; - -QT_END_NAMESPACE - -#endif // QBLACKBERRYTHEME_H diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index 95a8e44cb8..5a0f4f5c98 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -5,10 +5,9 @@ QT += platformsupport-private core-private gui-private # Uncomment this to build with support for IMF once it becomes available in the BBNDK #CONFIG += qqnx_imf -!blackberry:CONFIG += qqnx_screeneventthread +CONFIG += qqnx_screeneventthread # Uncomment these to enable debugging output for various aspects of the plugin -#DEFINES += QQNXBPSEVENTFILTER_DEBUG #DEFINES += QQNXBUFFER_DEBUG #DEFINES += QQNXBUTTON_DEBUG #DEFINES += QQNXCLIPBOARD_DEBUG @@ -86,52 +85,20 @@ contains(QT_CONFIG, opengles2) { LIBS += -lEGL } -CONFIG(blackberry) { - SOURCES += qqnxnavigatorbps.cpp \ - qqnxeventdispatcher_blackberry.cpp \ - qqnxbpseventfilter.cpp \ - qqnxvirtualkeyboardbps.cpp \ - qblackberrytheme.cpp \ - qqnxsystemsettings.cpp - - HEADERS += qqnxnavigatorbps.h \ - qqnxeventdispatcher_blackberry.h \ - qqnxbpseventfilter.h \ - qqnxvirtualkeyboardbps.h \ - qblackberrytheme.h \ - qqnxsystemsettings.h \ - qqnxfiledialoghelper.h - - LIBS += -lbps -} - -CONFIG(blackberry) { - SOURCES += qqnxfiledialoghelper_bb10.cpp \ - qqnxfilepicker.cpp \ - qqnxnavigatorcover.cpp - - HEADERS += qqnxfilepicker.h \ - qqnxnavigatorcover.h -} - CONFIG(qqnx_pps) { DEFINES += QQNX_PPS SOURCES += qqnxclipboard.cpp \ - qqnxbuttoneventnotifier.cpp + qqnxbuttoneventnotifier.cpp \ + qqnxnavigatorpps.cpp \ + qqnxnavigatoreventnotifier.cpp \ + qqnxvirtualkeyboardpps.cpp HEADERS += qqnxclipboard.h \ - qqnxbuttoneventnotifier.h - - !blackberry { - SOURCES += qqnxnavigatorpps.cpp \ - qqnxnavigatoreventnotifier.cpp \ - qqnxvirtualkeyboardpps.cpp - - HEADERS += qqnxnavigatorpps.h \ - qqnxnavigatoreventnotifier.h \ - qqnxvirtualkeyboardpps.h - } + qqnxbuttoneventnotifier.h \ + qqnxnavigatorpps.h \ + qqnxnavigatoreventnotifier.h \ + qqnxvirtualkeyboardpps.h LIBS += -lpps !contains(DEFINES, QT_NO_CLIPBOARD): LIBS += -lclipboard diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp deleted file mode 100644 index 66843283b6..0000000000 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxbpseventfilter.h" -#include "qqnxnavigatoreventhandler.h" -#include "qqnxscreen.h" -#include "qqnxscreeneventhandler.h" -#include "qqnxvirtualkeyboardbps.h" -#include "qqnxfiledialoghelper.h" - -#include <QCoreApplication> -#include <QAbstractEventDispatcher> -#include <QDebug> - -#include <bps/event.h> -#include <bps/navigator.h> -#include <bps/screen.h> - -#if defined(QQNXBPSEVENTFILTER_DEBUG) -#define qBpsEventFilterDebug qDebug -#else -#define qBpsEventFilterDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -static QQnxBpsEventFilter *s_instance = 0; - -QQnxBpsEventFilter::QQnxBpsEventFilter(QQnxNavigatorEventHandler *navigatorEventHandler, - QQnxScreenEventHandler *screenEventHandler, - QQnxVirtualKeyboardBps *virtualKeyboard, QObject *parent) - : QObject(parent) - , m_navigatorEventHandler(navigatorEventHandler) - , m_screenEventHandler(screenEventHandler) - , m_virtualKeyboard(virtualKeyboard) -{ - Q_ASSERT(s_instance == 0); - - s_instance = this; -} - -QQnxBpsEventFilter::~QQnxBpsEventFilter() -{ - Q_ASSERT(s_instance == this); - - s_instance = 0; -} - -void QQnxBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *dispatcher) -{ - qBpsEventFilterDebug() << "dispatcher=" << dispatcher; - - if (navigator_request_events(NAVIGATOR_EXTENDED_DATA) != BPS_SUCCESS) - qWarning("QQNX: failed to register for navigator events"); - - dispatcher->installNativeEventFilter(this); -} - -void QQnxBpsEventFilter::registerForScreenEvents(QQnxScreen *screen) -{ - if (!m_screenEventHandler) { - qWarning("QQNX: trying to register for screen events, but no handler provided."); - return; - } - - int attached; - if (screen_get_display_property_iv(screen->nativeDisplay(), SCREEN_PROPERTY_ATTACHED, &attached) != BPS_SUCCESS) { - qWarning() << "QQNX: unable to query display attachment"; - return; - } - - if (!attached) { - qBpsEventFilterDebug() << "skipping event registration for non-attached screen"; - return; - } - - if (screen_request_events(screen->nativeContext()) != BPS_SUCCESS) - qWarning("QQNX: failed to register for screen events on screen %p", screen->nativeContext()); -} - -void QQnxBpsEventFilter::unregisterForScreenEvents(QQnxScreen *screen) -{ - if (!m_screenEventHandler) { - qWarning("QQNX: trying to unregister for screen events, but no handler provided."); - return; - } - - if (screen_stop_events(screen->nativeContext()) != BPS_SUCCESS) - qWarning("QQNX: failed to unregister for screen events on screen %p", screen->nativeContext()); -} - -bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) -{ - Q_UNUSED(eventType); - Q_UNUSED(result); - bps_event_t *event = static_cast<bps_event_t *>(message); - const int eventDomain = bps_event_get_domain(event); - qBpsEventFilterDebug() << "event=" << event << "domain=" << eventDomain; - - if (eventDomain == screen_get_domain()) { - if (!m_screenEventHandler) { - qWarning("QQNX: registered for screen events, but no handler provided."); - return false; - } - - screen_event_t screenEvent = screen_event_get_event(event); - return m_screenEventHandler->handleEvent(screenEvent); - } - - if (eventDomain == navigator_get_domain()) - return handleNavigatorEvent(event); - - if (m_virtualKeyboard->handleEvent(event)) - return true; - - return false; -} - -bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event) -{ - switch (bps_event_get_code(event)) { - case NAVIGATOR_ORIENTATION_CHECK: { - const int angle = navigator_event_get_orientation_angle(event); - qBpsEventFilterDebug() << "ORIENTATION CHECK event. angle=" << angle; - - const bool result = m_navigatorEventHandler->handleOrientationCheck(angle); - qBpsEventFilterDebug() << "ORIENTATION CHECK event. result=" << result; - - // reply to navigator whether orientation is acceptable - navigator_orientation_check_response(event, result); - break; - } - - case NAVIGATOR_ORIENTATION: { - const int angle = navigator_event_get_orientation_angle(event); - qBpsEventFilterDebug() << "ORIENTATION event. angle=" << angle; - m_navigatorEventHandler->handleOrientationChange(angle); - - navigator_done_orientation(event); - break; - } - - case NAVIGATOR_SWIPE_DOWN: - qBpsEventFilterDebug("SWIPE DOWN event"); - m_navigatorEventHandler->handleSwipeDown(); - break; - - case NAVIGATOR_EXIT: - qBpsEventFilterDebug("EXIT event"); - m_navigatorEventHandler->handleExit(); - break; - - case NAVIGATOR_WINDOW_STATE: { - qBpsEventFilterDebug("WINDOW STATE event"); - const navigator_window_state_t state = navigator_event_get_window_state(event); - const QByteArray id(navigator_event_get_groupid(event)); - - switch (state) { - case NAVIGATOR_WINDOW_FULLSCREEN: - m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowFullScreen); - break; - case NAVIGATOR_WINDOW_THUMBNAIL: - m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowMinimized); - break; - case NAVIGATOR_WINDOW_INVISIBLE: - break; - } - - break; - } - - case NAVIGATOR_WINDOW_ACTIVE: { - qBpsEventFilterDebug("WINDOW ACTIVE event"); - const QByteArray id(navigator_event_get_groupid(event)); - m_navigatorEventHandler->handleWindowGroupActivated(id); - break; - } - - case NAVIGATOR_WINDOW_INACTIVE: { - qBpsEventFilterDebug("WINDOW INACTIVE event"); - const QByteArray id(navigator_event_get_groupid(event)); - m_navigatorEventHandler->handleWindowGroupDeactivated(id); - break; - } - - case NAVIGATOR_LOW_MEMORY: - qWarning() << "QGuiApplication based process" << QCoreApplication::applicationPid() - << "received \"NAVIGATOR_LOW_MEMORY\" event"; - return false; - - default: - qBpsEventFilterDebug() << "Unhandled navigator event. code=" << bps_event_get_code(event); - return false; - } - - return true; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.h b/src/plugins/platforms/qnx/qqnxbpseventfilter.h deleted file mode 100644 index f1d67848e8..0000000000 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXBPSEVENTFILTER_H -#define QQNXBPSEVENTFILTER_H - -#include <QObject> -#include <QHash> -#include <QAbstractNativeEventFilter> - -#include <bps/dialog.h> - -struct bps_event_t; - -QT_BEGIN_NAMESPACE - -class QAbstractEventDispatcher; -class QQnxNavigatorEventHandler; -class QQnxFileDialogHelper; -class QQnxScreen; -class QQnxScreenEventHandler; -class QQnxVirtualKeyboardBps; - -class QQnxBpsEventFilter : public QObject, public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - QQnxBpsEventFilter(QQnxNavigatorEventHandler *navigatorEventHandler, - QQnxScreenEventHandler *screenEventHandler, - QQnxVirtualKeyboardBps *virtualKeyboard, QObject *parent = 0); - ~QQnxBpsEventFilter(); - - void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher); - - void registerForScreenEvents(QQnxScreen *screen); - void unregisterForScreenEvents(QQnxScreen *screen); - -private: - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - - bool handleNavigatorEvent(bps_event_t *event); - -private: - QQnxNavigatorEventHandler *m_navigatorEventHandler; - QQnxScreenEventHandler *m_screenEventHandler; - QQnxVirtualKeyboardBps *m_virtualKeyboard; - QHash<dialog_instance_t, QQnxFileDialogHelper*> m_dialogMapper; -}; - -QT_END_NAMESPACE - -#endif // QQNXBPSEVENTFILTER_H diff --git a/src/plugins/platforms/qnx/qqnxbuffer.cpp b/src/plugins/platforms/qnx/qqnxbuffer.cpp index 7ee6664676..5d838ac189 100644 --- a/src/plugins/platforms/qnx/qqnxbuffer.cpp +++ b/src/plugins/platforms/qnx/qqnxbuffer.cpp @@ -76,7 +76,7 @@ QQnxBuffer::QQnxBuffer(screen_buffer_t buffer) screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr), "Failed to query buffer pointer"); - if (dataPtr == 0) + if (Q_UNLIKELY(!dataPtr)) qFatal("QQNX: buffer pointer is NULL, errno=%d", errno); // Get format of buffer @@ -131,13 +131,13 @@ void QQnxBuffer::invalidateInCache() qBufferDebug(); // Verify native buffer exists - if (m_buffer == 0) + if (Q_UNLIKELY(!m_buffer)) qFatal("QQNX: can't invalidate cache for null buffer"); // Evict buffer's data from cache errno = 0; int result = msync(m_image.bits(), m_image.height() * m_image.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY); - if (result != 0) + if (Q_UNLIKELY(result != 0)) qFatal("QQNX: failed to invalidate cache, errno=%d", errno); } diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp index 614bfc381f..ec30e79ab5 100644 --- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp @@ -82,7 +82,7 @@ void QQnxButtonEventNotifier::start() errno = 0; m_fd = qt_safe_open(ppsPath, O_RDONLY); if (m_fd == -1) { -#if defined(Q_OS_BLACKBERRY) || defined (QQNXBUTTON_DEBUG) +#if defined (QQNXBUTTON_DEBUG) qWarning("QQNX: failed to open buttons pps, errno=%d", errno); #endif return; diff --git a/src/plugins/platforms/qnx/qqnxeglwindow.cpp b/src/plugins/platforms/qnx/qqnxeglwindow.cpp index 00eaf2bf03..5f80b39fe6 100644 --- a/src/plugins/platforms/qnx/qqnxeglwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxeglwindow.cpp @@ -59,7 +59,7 @@ QQnxEglWindow::QQnxEglWindow(QWindow *window, screen_context_t context, bool nee // Set window usage const int val = SCREEN_USAGE_OPENGL_ES2; const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); - if (result != 0) + if (Q_UNLIKELY(result != 0)) qFatal("QQnxEglWindow: failed to set window alpha usage, errno=%d", errno); m_requestedBufferSize = shouldMakeFullScreen() ? screen()->geometry().size() : window->geometry().size(); @@ -106,7 +106,7 @@ void QQnxEglWindow::destroyEGLSurface() // Destroy EGL surface if it exists if (m_eglSurface != EGL_NO_SURFACE) { EGLBoolean eglResult = eglDestroySurface(platformOpenGLContext()->getEglDisplay(), m_eglSurface); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to destroy EGL surface, err=%d", eglGetError()); } @@ -118,12 +118,12 @@ void QQnxEglWindow::swapEGLBuffers() qEglWindowDebug(); // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Post EGL surface to window eglResult = eglSwapBuffers(m_platformOpenGLContext->getEglDisplay(), m_eglSurface); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to swap EGL buffers, err=%d", eglGetError()); windowPosted(); @@ -178,15 +178,15 @@ int QQnxEglWindow::pixelFormat() const const QSurfaceFormat format = m_platformOpenGLContext->format(); // Extract size of color channels from window format const int redSize = format.redBufferSize(); - if (redSize == -1) + if (Q_UNLIKELY(redSize == -1)) qFatal("QQnxWindow: red size not defined"); const int greenSize = format.greenBufferSize(); - if (greenSize == -1) + if (Q_UNLIKELY(greenSize == -1)) qFatal("QQnxWindow: green size not defined"); const int blueSize = format.blueBufferSize(); - if (blueSize == -1) + if (Q_UNLIKELY(blueSize == -1)) qFatal("QQnxWindow: blue size not defined"); // select matching native format diff --git a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp b/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp deleted file mode 100644 index 30596fe08f..0000000000 --- a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxeventdispatcher_blackberry.h" - -#include <qpa/qwindowsysteminterface.h> -#include <private/qguiapplication_p.h> - -QT_BEGIN_NAMESPACE - - -QQnxEventDispatcherBlackberry::QQnxEventDispatcherBlackberry(QObject *parent) - : QEventDispatcherBlackberry(parent) -{ -} - -QQnxEventDispatcherBlackberry::~QQnxEventDispatcherBlackberry() -{ -} - -bool QQnxEventDispatcherBlackberry::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - const bool didSendEvents = QEventDispatcherBlackberry::processEvents(flags); - return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents; -} - -bool QQnxEventDispatcherBlackberry::hasPendingEvents() -{ - return QEventDispatcherBlackberry::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued(); -} - -void QQnxEventDispatcherBlackberry::flush() -{ - if (qApp) - qApp->sendPostedEvents(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h b/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h deleted file mode 100644 index 036bf126ab..0000000000 --- a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXEVENTDISPATCHER_BLACKBERRY_H -#define QQNXEVENTDISPATCHER_BLACKBERRY_H - -#include <qglobal.h> -#include <private/qeventdispatcher_blackberry_p.h> - -QT_BEGIN_NAMESPACE - -class QQnxEventDispatcherBlackberry : public QEventDispatcherBlackberry -{ - Q_OBJECT - -public: - explicit QQnxEventDispatcherBlackberry(QObject *parent = 0); - ~QQnxEventDispatcherBlackberry(); - - bool processEvents(QEventLoop::ProcessEventsFlags flags); - bool hasPendingEvents(); - - void flush(); -}; - -QT_END_NAMESPACE - -#endif // QQNXEVENTDISPATCHER_BLACKBERRY_H diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h b/src/plugins/platforms/qnx/qqnxfiledialoghelper.h deleted file mode 100644 index 76cceafcfe..0000000000 --- a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXFILEDIALOGHELPER_H -#define QQNXFILEDIALOGHELPER_H - -#include <qpa/qplatformdialoghelper.h> - - -QT_BEGIN_NAMESPACE - -class QQnxIntegration; - -class QQnxFilePicker; - -class QQnxFileDialogHelper : public QPlatformFileDialogHelper -{ - Q_OBJECT -public: - explicit QQnxFileDialogHelper(const QQnxIntegration *); - ~QQnxFileDialogHelper(); - - void exec(); - - bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent); - void hide(); - - bool defaultNameFilterDisables() const; - void setDirectory(const QUrl &directory) Q_DECL_OVERRIDE; - QUrl directory() const Q_DECL_OVERRIDE; - void selectFile(const QUrl &fileName) Q_DECL_OVERRIDE; - QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE; - void setFilter(); - void selectNameFilter(const QString &filter); - QString selectedNameFilter() const; - - QQnxFilePicker *nativeDialog() const { return m_dialog; } - -Q_SIGNALS: - void dialogClosed(); - -private Q_SLOTS: - void emitSignals(); - -private: - void setNameFilter(const QString &filter); - void setNameFilters(const QStringList &filters); - - const QQnxIntegration *m_integration; - QQnxFilePicker *m_dialog; - QFileDialogOptions::AcceptMode m_acceptMode; - QString m_selectedFilter; -}; - -QT_END_NAMESPACE - -#endif // QQNXFILEDIALOGHELPER_H diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp b/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp deleted file mode 100644 index 3bc84686e0..0000000000 --- a/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxfiledialoghelper.h" - -#include "qqnxfilepicker.h" -#include "qqnxbpseventfilter.h" -#include "qqnxscreen.h" -#include "qqnxintegration.h" - -#include <QDebug> -#include <QEventLoop> -#include <QScreen> -#include <QTimer> -#include <QWindow> - -#ifdef QQNXFILEDIALOGHELPER_DEBUG -#define qFileDialogHelperDebug qDebug -#else -#define qFileDialogHelperDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -QQnxFileDialogHelper::QQnxFileDialogHelper(const QQnxIntegration *integration) - : QPlatformFileDialogHelper(), - m_integration(integration), - m_dialog(new QQnxFilePicker), - m_acceptMode(QFileDialogOptions::AcceptOpen), - m_selectedFilter() -{ - connect(m_dialog, &QQnxFilePicker::closed, this, &QQnxFileDialogHelper::emitSignals); -} - -QQnxFileDialogHelper::~QQnxFileDialogHelper() -{ - delete m_dialog; -} - -void QQnxFileDialogHelper::exec() -{ - qFileDialogHelperDebug(); - - // Clear any previous results - m_dialog->setDirectories(QStringList()); - - QEventLoop loop; - connect(m_dialog, SIGNAL(closed()), &loop, SLOT(quit())); - loop.exec(); -} - -bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) -{ - Q_UNUSED(flags); - Q_UNUSED(parent); - Q_UNUSED(modality); - - qFileDialogHelperDebug(); - - // Create dialog - const QSharedPointer<QFileDialogOptions> &opts = options(); - if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) { - // Select one or many files? - const QQnxFilePicker::Mode mode = (opts->fileMode() == QFileDialogOptions::ExistingFiles) - ? QQnxFilePicker::PickerMultiple : QQnxFilePicker::Picker; - - m_dialog->setMode(mode); - - // Set the actual list of extensions - if (!opts->nameFilters().isEmpty()) - setNameFilters(opts->nameFilters()); - else - setNameFilter(tr("All files (*.*)")); - } else { - const QQnxFilePicker::Mode mode = (opts->initiallySelectedFiles().count() >= 2) - ? QQnxFilePicker::SaverMultiple : QQnxFilePicker::Saver; - - m_dialog->setMode(mode); - - if (!opts->initiallySelectedFiles().isEmpty()) { - QStringList files; - Q_FOREACH ( const QUrl &url, opts->initiallySelectedFiles() ) - files.append(url.toLocalFile()); - m_dialog->setDefaultSaveFileNames(files); - } - } - - // Cache the accept mode so we know which functions to use to get the results back - m_acceptMode = opts->acceptMode(); - m_dialog->setTitle(opts->windowTitle()); - m_dialog->open(); - - return true; -} - -void QQnxFileDialogHelper::hide() -{ - qFileDialogHelperDebug(); - m_dialog->close(); -} - -bool QQnxFileDialogHelper::defaultNameFilterDisables() const -{ - qFileDialogHelperDebug(); - return false; -} - -void QQnxFileDialogHelper::setDirectory(const QUrl &directory) -{ - m_dialog->addDirectory(directory.toLocalFile()); -} - -QUrl QQnxFileDialogHelper::directory() const -{ - qFileDialogHelperDebug(); - if (!m_dialog->directories().isEmpty()) - return QUrl::fromLocalFile(m_dialog->directories().first()); - - return QUrl(); -} - -void QQnxFileDialogHelper::selectFile(const QUrl &fileName) -{ - m_dialog->addDefaultSaveFileName(fileName.toLocalFile()); -} - -QList<QUrl> QQnxFileDialogHelper::selectedFiles() const -{ - qFileDialogHelperDebug(); - QList<QUrl> urls; - QStringList files = m_dialog->selectedFiles(); - Q_FOREACH (const QString &file, files) - urls.append(QUrl::fromLocalFile(file)); - return urls; -} - -void QQnxFileDialogHelper::setFilter() -{ - // No native api to support setting a filter from QDir::Filters - qFileDialogHelperDebug(); -} - -void QQnxFileDialogHelper::selectNameFilter(const QString &filter) -{ - qFileDialogHelperDebug() << "filter =" << filter; - setNameFilter(filter); -} - -QString QQnxFileDialogHelper::selectedNameFilter() const -{ - // For now there is no way for the user to change the selected filter - // so this just reflects what the developer has set programmatically. - qFileDialogHelperDebug(); - return m_selectedFilter; -} - -void QQnxFileDialogHelper::emitSignals() -{ - if (m_dialog->selectedFiles().isEmpty()) - Q_EMIT reject(); - else - Q_EMIT accept(); -} - -void QQnxFileDialogHelper::setNameFilter(const QString &filter) -{ - qFileDialogHelperDebug() << "filter =" << filter; - - setNameFilters(QPlatformFileDialogHelper::cleanFilterList(filter)); -} - -void QQnxFileDialogHelper::setNameFilters(const QStringList &filters) -{ - qFileDialogHelperDebug() << "filters =" << filters; - - Q_ASSERT(!filters.isEmpty()); - - m_dialog->setFilters(filters); - m_selectedFilter = filters.first(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.cpp b/src/plugins/platforms/qnx/qqnxfilepicker.cpp deleted file mode 100644 index ca8d731e66..0000000000 --- a/src/plugins/platforms/qnx/qqnxfilepicker.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxfilepicker.h" - -#include <QAbstractEventDispatcher> -#include <QCoreApplication> -#include <QDebug> -#include <QJsonDocument> -#include <QJsonObject> -#include <QJsonArray> -#include <QJsonParseError> -#include <QMimeDatabase> -#include <QUrl> -#include <private/qppsobject_p.h> - -#include <bps/navigator.h> -#include <bps/navigator_invoke.h> - -#include <errno.h> - -#ifdef QQNXFILEPICKER_DEBUG -#define qFilePickerDebug qDebug -#else -#define qFilePickerDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -static const char s_filePickerTarget[] = "sys.filepicker.target"; - -QQnxFilePicker::QQnxFilePicker(QObject *parent) - : QObject(parent) - , m_invocationHandle(0) - , m_mode(QQnxFilePicker::Picker) - , m_title(tr("Pick a file")) -{ - QCoreApplication::eventDispatcher()->installNativeEventFilter(this); -} - -QQnxFilePicker::~QQnxFilePicker() -{ - cleanup(); - - QCoreApplication::eventDispatcher()->removeNativeEventFilter(this); -} - -void QQnxFilePicker::open() -{ - if (m_invocationHandle) - return; - - // Clear any previous results - m_selectedFiles.clear(); - - int errorCode = BPS_SUCCESS; - - errorCode = navigator_invoke_invocation_create(&m_invocationHandle); - if (errorCode != BPS_SUCCESS) { - qWarning() << "QQnxFilePicker: unable to create invocation:" << strerror(errno); - return; - } - - errorCode = navigator_invoke_invocation_set_target(m_invocationHandle, s_filePickerTarget); - - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set target:" << strerror(errno); - return; - } - - errorCode = navigator_invoke_invocation_set_action(m_invocationHandle, "bb.action.OPEN"); - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set action:" << strerror(errno); - return; - } - - errorCode = navigator_invoke_invocation_set_type(m_invocationHandle, "application/vnd.blackberry.file_picker"); - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set mime type:" << strerror(errno); - return; - } - - QVariantMap map; - map[QStringLiteral("Type")] = filePickerType(); - map[QStringLiteral("Mode")] = modeToString(m_mode); - map[QStringLiteral("Title")] = m_title; - map[QStringLiteral("ViewMode")] = QStringLiteral("Default"); - map[QStringLiteral("SortBy")] = QStringLiteral("Default"); - map[QStringLiteral("SortOrder")] = QStringLiteral("Default"); - map[QStringLiteral("ImageCrop")] = false; - map[QStringLiteral("AllowOverwrite")] = false; - - if (!m_defaultSaveFileNames.isEmpty()) - map[QStringLiteral("DefaultFileNames")] = m_defaultSaveFileNames.join(QLatin1Char(',')); - if (!m_filters.isEmpty()) - map[QStringLiteral("Filter")] = m_filters.join(QLatin1Char(';')); - - QByteArray ppsData; - ppsData = QPpsObject::encode(map); - - errorCode = navigator_invoke_invocation_set_data(m_invocationHandle, ppsData.constData(), ppsData.size()); - if (errorCode != BPS_SUCCESS) { - cleanup(); - qWarning() << "QQnxFilePicker: unable to set data:" << strerror(errno); - return; - } - - navigator_invoke_invocation_send(m_invocationHandle); -} - -void QQnxFilePicker::close() -{ - navigator_card_close_child(); - cleanup(); -} - -bool QQnxFilePicker::nativeEventFilter(const QByteArray&, void *message, long*) -{ - bps_event_t * const event = static_cast<bps_event_t*>(message); - if (!event) - return false; - - if (bps_event_get_code(event) == NAVIGATOR_INVOKE_TARGET_RESULT) { - const char *id = navigator_event_get_id(event); - const char *err = navigator_event_get_err(event); - qFilePickerDebug("received invocation response: id=%s err=%s", id, err); - } else if (bps_event_get_code(event) == NAVIGATOR_CHILD_CARD_CLOSED) { - const char *data = navigator_event_get_card_closed_data(event); - qFilePickerDebug("received data: data='%s'", data); - handleFilePickerResponse(data); - } - - return false; // do not drop the event -} - -void QQnxFilePicker::setMode(QQnxFilePicker::Mode mode) -{ - m_mode = mode; -} - -void QQnxFilePicker::setDefaultSaveFileNames(const QStringList &fileNames) -{ - m_defaultSaveFileNames = fileNames; -} - -void QQnxFilePicker::addDefaultSaveFileName(const QString &fileName) -{ - m_defaultSaveFileNames.append(fileName); -} - -void QQnxFilePicker::setDirectories(const QStringList &directories) -{ - m_directories = directories; -} - -void QQnxFilePicker::addDirectory(const QString &directory) -{ - m_directories.append(directory); -} - -void QQnxFilePicker::setFilters(const QStringList &filters) -{ - m_filters = filters; -} - -void QQnxFilePicker::setTitle(const QString &title) -{ - m_title = title; -} - -QQnxFilePicker::Mode QQnxFilePicker::mode() const -{ - return m_mode; -} - -QStringList QQnxFilePicker::defaultSaveFileNames() const -{ - return m_defaultSaveFileNames; -} - -QStringList QQnxFilePicker::directories() const -{ - return m_directories; -} - -QStringList QQnxFilePicker::filters() const -{ - return m_filters; -} - -QStringList QQnxFilePicker::selectedFiles() const -{ - return m_selectedFiles; -} - -QString QQnxFilePicker::title() const -{ - return m_title; -} - -void QQnxFilePicker::cleanup() -{ - if (m_invocationHandle) { - navigator_invoke_invocation_destroy(m_invocationHandle); - m_invocationHandle = 0; - } -} - -void QQnxFilePicker::handleFilePickerResponse(const char *data) -{ - QJsonParseError jsonError; - QJsonDocument document = QJsonDocument::fromJson(data, &jsonError); - - if (jsonError.error != QJsonParseError::NoError) { - qFilePickerDebug() << "Error parsing FilePicker response: " - << jsonError.errorString(); - Q_EMIT closed(); - cleanup(); - return; - } - - // The response is a list of Json objects. - const QVariantList array = document.array().toVariantList(); - - foreach (const QVariant &variant, array) { - const QJsonObject object = QJsonObject::fromVariantMap(variant.toMap()); - const QUrl url(object.value(QStringLiteral("uri")).toString()); - const QString localFile = url.toLocalFile(); // strip "file://" - - if (!localFile.isEmpty()) - m_selectedFiles << localFile; - - qFilePickerDebug() << "FilePicker uri response:" << localFile; - } - - Q_EMIT closed(); - cleanup(); -} - -QString QQnxFilePicker::filePickerType() const -{ - bool images = false; - bool video = false; - bool music = false; - QMimeDatabase mimeDb; - for (int i = 0; i < m_filters.count(); i++) { - QList<QMimeType> mimeTypes = mimeDb.mimeTypesForFileName(m_filters.at(i)); - if (mimeTypes.isEmpty()) - return QStringLiteral("Other"); - - if (mimeTypes.first().name().startsWith(QLatin1String("image"))) - images = true; - else if (mimeTypes.first().name().startsWith(QLatin1String("audio"))) - music = true; - else if (mimeTypes.first().name().startsWith(QLatin1String("video"))) - video = true; - else - return QStringLiteral("Other"); - } - - if (!video && !music) - return QStringLiteral("Picture"); - - if (!images && !music) - return QStringLiteral("Video"); - - if (!images && !video) - return QStringLiteral("Music"); - - return QStringLiteral("Other"); -} - -QString QQnxFilePicker::modeToString(QQnxFilePicker::Mode mode) const -{ - switch (mode) { - case Picker: - return QStringLiteral("Picker"); - case Saver: - return QStringLiteral("Saver"); - case PickerMultiple: - return QStringLiteral("PickerMultiple"); - case SaverMultiple: - return QStringLiteral("SaverMultiple"); - } - - return QStringLiteral("Picker"); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.h b/src/plugins/platforms/qnx/qqnxfilepicker.h deleted file mode 100644 index 7e4f9010cc..0000000000 --- a/src/plugins/platforms/qnx/qqnxfilepicker.h +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXFILEPICKER_H -#define QQNXFILEPICKER_H - -#include <QAbstractNativeEventFilter> -#include <QObject> -#include <QStringList> - -QT_BEGIN_NAMESPACE - -struct navigator_invoke_invocation_t; - -class QQnxFilePicker : public QObject, public QAbstractNativeEventFilter -{ - Q_OBJECT - -public: - explicit QQnxFilePicker(QObject *parent = 0); - ~QQnxFilePicker(); - - enum Mode { - Picker, - Saver, - PickerMultiple, - SaverMultiple - }; - - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - - void setMode(Mode mode); - void setDefaultSaveFileNames(const QStringList &fileNames); - void addDefaultSaveFileName(const QString &fileName); - void setDirectories(const QStringList &directories); - void addDirectory(const QString &directory); - void setFilters(const QStringList &filters); - void setTitle(const QString &title); - - Mode mode() const; - - QStringList defaultSaveFileNames() const; - QStringList directories() const; - QStringList filters() const; - QStringList selectedFiles() const; - - QString title() const; - -Q_SIGNALS: - void closed(); - -public Q_SLOTS: - void open(); - void close(); - -private: - void cleanup(); - void handleFilePickerResponse(const char *data); - QString filePickerType() const; - - QString modeToString(Mode mode) const; - - navigator_invoke_invocation_t *m_invocationHandle; - - Mode m_mode; - - QStringList m_defaultSaveFileNames; - QStringList m_directories; - QStringList m_filters; - QStringList m_selectedFiles; - - QString m_title; -}; - -QT_END_NAMESPACE - -#endif // QQNXFILEPICKER_H diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index 5ef8d72926..20930af524 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -61,7 +61,7 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Get colour channel sizes from window format @@ -113,7 +113,7 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) // Select EGL config based on requested window format m_eglConfig = q_configFromGLFormat(ms_eglDisplay, format); - if (m_eglConfig == 0) + if (Q_UNLIKELY(m_eglConfig == 0)) qFatal("QQnxGLContext: failed to find EGL config"); QQnxGLContext *glShareContext = static_cast<QQnxGLContext*>(m_glContext->shareHandle()); @@ -121,7 +121,7 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) m_eglContext = eglCreateContext(ms_eglDisplay, m_eglConfig, m_eglShareContext, contextAttrs(format)); - if (m_eglContext == EGL_NO_CONTEXT) { + if (Q_UNLIKELY(m_eglContext == EGL_NO_CONTEXT)) { checkEGLError("eglCreateContext"); qFatal("QQnxGLContext: failed to create EGL context, err=%d", eglGetError()); } @@ -170,13 +170,13 @@ void QQnxGLContext::initializeContext() // Initialize connection to EGL ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (ms_eglDisplay == EGL_NO_DISPLAY) { + if (Q_UNLIKELY(ms_eglDisplay == EGL_NO_DISPLAY)) { checkEGLError("eglGetDisplay"); qFatal("QQnxGLContext: failed to obtain EGL display"); } EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0); - if (eglResult != EGL_TRUE) { + if (Q_UNLIKELY(eglResult != EGL_TRUE)) { checkEGLError("eglInitialize"); qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError()); } @@ -198,7 +198,7 @@ bool QQnxGLContext::makeCurrent(QPlatformSurface *surface) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQnxGLContext: failed to set EGL API, err=%d", eglGetError()); QQnxEglWindow *platformWindow = dynamic_cast<QQnxEglWindow*>(surface); @@ -227,12 +227,12 @@ void QQnxGLContext::doneCurrent() // set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // clear curent EGL context and unbind EGL surface eglResult = eglMakeCurrent(ms_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to clear current EGL context, err=%d", eglGetError()); } @@ -252,7 +252,7 @@ QFunctionPointer QQnxGLContext::getProcAddress(const QByteArray &procName) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) + if (Q_UNLIKELY(eglResult != EGL_TRUE)) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); // Lookup EGL extension function pointer diff --git a/src/plugins/platforms/qnx/qqnxglobal.cpp b/src/plugins/platforms/qnx/qqnxglobal.cpp index 01e7675839..4d2599746e 100644 --- a/src/plugins/platforms/qnx/qqnxglobal.cpp +++ b/src/plugins/platforms/qnx/qqnxglobal.cpp @@ -44,8 +44,8 @@ void qScreenCheckError(int rc, const char *funcInfo, const char *message, bool c rc = screen_flush_context(QQnxIntegration::screenContext(), 0); } - if (rc) { - if (critical) + if (Q_UNLIKELY(rc)) { + if (Q_UNLIKELY(critical)) qCritical("%s - Screen: %s - Error: %s (%i)", funcInfo, message, strerror(errno), errno); else qWarning("%s - Screen: %s - Error: %s (%i)", funcInfo, message, strerror(errno), errno); diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp index 3af481b991..5aa8b9bfee 100644 --- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp +++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp @@ -530,29 +530,28 @@ static bool imfAvailable() if ( p_imf_client_init == 0 ) { void *handle = dlopen("libinput_client.so.1", 0); - if ( handle ) { - p_imf_client_init = (int32_t (*)()) dlsym(handle, "imf_client_init"); - p_imf_client_disconnect = (void (*)()) dlsym(handle, "imf_client_disconnect"); - p_ictrl_open_session = (const input_session_t *(*)(connection_interface_t *))dlsym(handle, "ictrl_open_session"); - p_ictrl_close_session = (void (*)(input_session_t *))dlsym(handle, "ictrl_close_session"); - p_ictrl_dispatch_event = (int32_t (*)(event_t *))dlsym(handle, "ictrl_dispatch_event"); - p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service"); - p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions"); - } else { + if (Q_UNLIKELY(!handle)) { qCritical("libinput_client.so.1 is not present - IMF services are disabled."); s_imfDisabled = true; return false; } - - if ( p_imf_client_init && p_ictrl_open_session && p_ictrl_dispatch_event ) { - s_imfReady = true; - } else { + p_imf_client_init = (int32_t (*)()) dlsym(handle, "imf_client_init"); + p_imf_client_disconnect = (void (*)()) dlsym(handle, "imf_client_disconnect"); + p_ictrl_open_session = (const input_session_t *(*)(connection_interface_t *))dlsym(handle, "ictrl_open_session"); + p_ictrl_close_session = (void (*)(input_session_t *))dlsym(handle, "ictrl_close_session"); + p_ictrl_dispatch_event = (int32_t (*)(event_t *))dlsym(handle, "ictrl_dispatch_event"); + p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service"); + p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions"); + + if (Q_UNLIKELY(!p_imf_client_init || !p_ictrl_open_session || !p_ictrl_dispatch_event)) { p_ictrl_open_session = 0; p_ictrl_dispatch_event = 0; s_imfDisabled = true; qCritical("libinput_client.so.1 did not contain the correct symbols, library mismatch? IMF services are disabled."); return false; } + + s_imfReady = true; } return s_imfReady; @@ -581,7 +580,7 @@ QQnxInputContext::QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVir Q_ASSERT(sInputContextInstance == 0); sInputContextInstance = this; - if (p_imf_client_init() != 0) { + if (Q_UNLIKELY(p_imf_client_init() != 0)) { s_imfInitFailed = true; qCritical("imf_client_init failed - IMF services will be unavailable"); } diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 6548c82310..0616ac626f 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -52,12 +52,7 @@ #include "qqnxeglwindow.h" #endif -#if defined(Q_OS_BLACKBERRY) -#include "qqnxbpseventfilter.h" -#include "qqnxnavigatorbps.h" -#include "qblackberrytheme.h" -#include "qqnxvirtualkeyboardbps.h" -#elif defined(QQNX_PPS) +#if defined(QQNX_PPS) #include "qqnxnavigatorpps.h" #include "qqnxnavigatoreventnotifier.h" #include "qqnxvirtualkeyboardpps.h" @@ -75,12 +70,7 @@ #endif #include "private/qgenericunixfontdatabase_p.h" - -#if defined(Q_OS_BLACKBERRY) -#include "qqnxeventdispatcher_blackberry.h" -#else #include "private/qgenericunixeventdispatcher_p.h" -#endif #include <qpa/qplatformwindow.h> #include <qpa/qwindowsysteminterface.h> @@ -120,16 +110,10 @@ static inline QQnxIntegration::Options parseOptions(const QStringList ¶mList options |= QQnxIntegration::AlwaysFlushScreenContext; } -// On Blackberry the first window is treated as a root window -#ifdef Q_OS_BLACKBERRY - if (!paramList.contains(QLatin1String("no-rootwindow"))) { - options |= QQnxIntegration::RootWindow; - } -#else if (paramList.contains(QLatin1String("rootwindow"))) { options |= QQnxIntegration::RootWindow; } -#endif + return options; } @@ -147,12 +131,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) #endif , m_services(0) , m_fontDatabase(new QGenericUnixFontDatabase()) -#if defined(Q_OS_BLACKBERRY) - , m_eventDispatcher(new QQnxEventDispatcherBlackberry()) - , m_bpsEventFilter(0) -#else , m_eventDispatcher(createUnixEventDispatcher()) -#endif , m_nativeInterface(new QQnxNativeInterface(this)) , m_screenEventHandler(new QQnxScreenEventHandler(this)) #if !defined(QT_NO_CLIPBOARD) @@ -169,8 +148,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) Q_SCREEN_CRITICALERROR(screen_create_context(&ms_screenContext, SCREEN_APPLICATION_CONTEXT), "Failed to create screen context"); - // Not on BlackBerry, it has specialized event dispatcher which also handles navigator events -#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) +#if defined(QQNX_PPS) // Create/start navigator event notifier m_navigatorEventNotifier = new QQnxNavigatorEventNotifier(m_navigatorEventHandler); @@ -190,8 +168,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) m_screenEventThread->start(); #endif - // Not on BlackBerry, it has specialized event dispatcher which also handles virtual keyboard events -#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) +#if defined(QQNX_PPS) // Create/start the keyboard class. m_virtualKeyboard = new QQnxVirtualKeyboardPps(); @@ -200,9 +177,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection); #endif -#if defined(Q_OS_BLACKBERRY) - m_navigator = new QQnxNavigatorBps(); -#elif defined(QQNX_PPS) +#if defined(QQNX_PPS) m_navigator = new QQnxNavigatorPps(); #endif @@ -210,34 +185,8 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) if (m_navigator) m_services = new QQnxServices(m_navigator); -#if defined(Q_OS_BLACKBERRY) - QQnxVirtualKeyboardBps* virtualKeyboardBps = new QQnxVirtualKeyboardBps; - -#if defined(QQNX_SCREENEVENTTHREAD) - m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, 0, virtualKeyboardBps); -#else - m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, m_screenEventHandler, virtualKeyboardBps); -#endif - - m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher); - - m_virtualKeyboard = virtualKeyboardBps; -#endif - - // Create displays for all possible screens (which may not be attached). We have to do this - // *after* the call to m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher). The - // reason for this is that we have to be registered for NAVIGATOR events before we create the - // QQnxScreen objects, and hence the QQnxRootWindow's. It is when the NAVIGATOR service sees - // the window creation that it starts sending us messages which results in a race if we - // create the displays first. createDisplays(); -#if !defined(QQNX_SCREENEVENTTHREAD) && defined(Q_OS_BLACKBERRY) - // Register for screen domain events with bps - Q_FOREACH (QQnxScreen *screen, m_screens) - m_bpsEventFilter->registerForScreenEvents(screen); -#endif - if (m_virtualKeyboard) { // TODO check if we need to do this for all screens or only the primary one QObject::connect(m_virtualKeyboard, SIGNAL(heightChanged(int)), @@ -275,7 +224,7 @@ QQnxIntegration::~QQnxIntegration() #endif // Stop/destroy navigator event notifier -#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) +#if defined(QQNX_PPS) delete m_navigatorEventNotifier; #endif delete m_navigatorEventHandler; @@ -283,13 +232,6 @@ QQnxIntegration::~QQnxIntegration() #if defined(QQNX_SCREENEVENTTHREAD) // Stop/destroy screen event thread delete m_screenEventThread; -#elif defined(Q_OS_BLACKBERRY) - Q_FOREACH (QQnxScreen *screen, m_screens) - m_bpsEventFilter->unregisterForScreenEvents(screen); -#endif - -#if defined(Q_OS_BLACKBERRY) - delete m_bpsEventFilter; #endif // In case the event-dispatcher was never transferred to QCoreApplication @@ -450,21 +392,6 @@ QPlatformServices * QQnxIntegration::services() const return m_services; } -#if defined(Q_OS_BLACKBERRY) -QStringList QQnxIntegration::themeNames() const -{ - return QStringList(QBlackberryTheme::name()); -} - -QPlatformTheme *QQnxIntegration::createPlatformTheme(const QString &name) const -{ - qIntegrationDebug() << "name =" << name; - if (name == QBlackberryTheme::name()) - return new QBlackberryTheme(this); - return 0; -} -#endif - QWindow *QQnxIntegration::window(screen_window_t qnxWindow) { qIntegrationDebug(); @@ -498,7 +425,7 @@ void QQnxIntegration::createDisplays() &displayCount); Q_SCREEN_CRITICALERROR(result, "Failed to query display count"); - if (displayCount < 1) { + if (Q_UNLIKELY(displayCount < 1)) { // Never happens, even if there's no display, libscreen returns 1 qFatal("QQnxIntegration: displayCount=%d", displayCount); } @@ -601,7 +528,7 @@ QQnxIntegration::Options QQnxIntegration::ms_options = 0; bool QQnxIntegration::supportsNavigatorEvents() const { - // If QQNX_PPS or Q_OS_BLACKBERRY is defined then we have navigator + // If QQNX_PPS is defined then we have navigator return m_navigator != 0; } diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 04250cdba0..3a4a1380ab 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -42,7 +42,6 @@ QT_BEGIN_NAMESPACE -class QQnxBpsEventFilter; #if defined(QQNX_SCREENEVENTTHREAD) class QQnxScreenEventThread; #endif @@ -117,12 +116,6 @@ public: QPlatformServices *services() const; -#if defined(Q_OS_BLACKBERRY) - QStringList themeNames() const; - QPlatformTheme *createPlatformTheme(const QString &name) const; - QQnxBpsEventFilter *bpsEventFilter() const { return m_bpsEventFilter; } -#endif - static QWindow *window(screen_window_t qnxWindow); QQnxScreen *screenForNative(screen_display_t qnxScreen) const; @@ -156,9 +149,6 @@ private: QQnxServices *m_services; QPlatformFontDatabase *m_fontDatabase; mutable QAbstractEventDispatcher *m_eventDispatcher; -#if defined(Q_OS_BLACKBERRY) - QQnxBpsEventFilter *m_bpsEventFilter; -#endif QQnxNativeInterface *m_nativeInterface; QList<QQnxScreen*> m_screens; QQnxScreenEventHandler *m_screenEventHandler; diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp index 549e0209bf..8c22f7cea0 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp @@ -85,11 +85,6 @@ void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q void *QQnxNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { -#ifdef Q_OS_BLACKBERRY - if (resource == "navigatorEventHandler") - return m_integration->navigatorEventHandler(); -#endif - return 0; } diff --git a/src/plugins/platforms/qnx/qqnxnavigatorbps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorbps.cpp deleted file mode 100644 index 0d730d6f57..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorbps.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxnavigatorbps.h" - -#include <QDebug> - -#include <bps/navigator.h> - -QT_BEGIN_NAMESPACE - -QQnxNavigatorBps::QQnxNavigatorBps(QObject *parent) - : QQnxAbstractNavigator(parent) -{ - bps_initialize(); -} - -QQnxNavigatorBps::~QQnxNavigatorBps() -{ - bps_shutdown(); -} - -bool QQnxNavigatorBps::requestInvokeUrl(const QByteArray &encodedUrl) -{ - char *error = 0; - - int ret = navigator_invoke(encodedUrl, &error); - if (error) { - qWarning() << "error=" << error; - bps_free(error); - } - - return (ret == BPS_SUCCESS); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxnavigatorbps.h b/src/plugins/platforms/qnx/qqnxnavigatorbps.h deleted file mode 100644 index b006695de6..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorbps.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXNAVIGATORBPS_H -#define QQNXNAVIGATORBPS_H - -#include "qqnxabstractnavigator.h" - -QT_BEGIN_NAMESPACE - -class QQnxNavigatorBps : public QQnxAbstractNavigator -{ - Q_OBJECT -public: - explicit QQnxNavigatorBps(QObject *parent = 0); - ~QQnxNavigatorBps(); - -protected: - bool requestInvokeUrl(const QByteArray &encodedUrl); -}; - -QT_END_NAMESPACE - -#endif // QQNXNAVIGATORBPS_H diff --git a/src/plugins/platforms/qnx/qqnxnavigatorcover.cpp b/src/plugins/platforms/qnx/qqnxnavigatorcover.cpp deleted file mode 100644 index 6d30677b30..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorcover.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxnavigatorcover.h" - -QQnxNavigatorCover::QQnxNavigatorCover() -{ - navigator_window_cover_attribute_create(&m_coverAttribute); -} - -QQnxNavigatorCover::~QQnxNavigatorCover() -{ - if (m_coverAttribute) - navigator_window_cover_attribute_destroy(m_coverAttribute); - - navigator_window_cover_reset(); -} - -void QQnxNavigatorCover::updateCover() -{ - if (m_coverAttribute) { - navigator_window_cover_attribute_set_transition(m_coverAttribute, - NAVIGATOR_WINDOW_COVER_TRANSITION_NONE); - navigator_window_cover_attribute_set_alternate_window(m_coverAttribute); - navigator_window_cover_update(m_coverAttribute); - } -} diff --git a/src/plugins/platforms/qnx/qqnxnavigatorcover.h b/src/plugins/platforms/qnx/qqnxnavigatorcover.h deleted file mode 100644 index 5e9ed9f7bd..0000000000 --- a/src/plugins/platforms/qnx/qqnxnavigatorcover.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXNAVIGATORCOVER_H -#define QQNXNAVIGATORCOVER_H - -#include "qqnxabstractcover.h" -#include <bps/navigator.h> - -class QQnxNavigatorCover : public QQnxAbstractCover -{ -public: - QQnxNavigatorCover(); - ~QQnxNavigatorCover(); - - void updateCover(); - -private: - navigator_window_cover_attribute_t *m_coverAttribute; -}; - -#endif // QQNXNAVIGATORCOVER_H diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp index 6199eb8e11..8098c9970e 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp @@ -102,7 +102,7 @@ void QQnxNavigatorEventNotifier::parsePPS(const QByteArray &ppsData, QByteArray QList<QByteArray> lines = ppsData.split('\n'); // validate pps object - if (lines.size() == 0 || lines.at(0) != "@control") + if (Q_UNLIKELY(lines.empty() || lines.at(0) != "@control")) qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); // parse pps object attributes and extract values @@ -160,7 +160,7 @@ void QQnxNavigatorEventNotifier::replyPPS(const QByteArray &res, const QByteArra // send pps message to navigator errno = 0; int bytes = write(m_fd, ppsData.constData(), ppsData.size()); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to write navigator pps, errno=%d", errno); } @@ -198,7 +198,7 @@ void QQnxNavigatorEventNotifier::readData() // attempt to read pps data errno = 0; int bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to read navigator pps, errno=%d", errno); // check if pps data was received diff --git a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp index b139471669..ca8e2bd3ab 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp @@ -100,7 +100,7 @@ bool QQnxNavigatorPps::sendPpsMessage(const QByteArray &message, const QByteArra // send pps message to navigator errno = 0; int bytes = qt_safe_write(m_fd, ppsMessage.constData(), ppsMessage.size()); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to write navigator pps, errno=%d", errno); // allocate buffer for pps data @@ -110,7 +110,7 @@ bool QQnxNavigatorPps::sendPpsMessage(const QByteArray &message, const QByteArra do { errno = 0; bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1); - if (bytes == -1) + if (Q_UNLIKELY(bytes == -1)) qFatal("QQNX: failed to read navigator pps, errno=%d", errno); } while (bytes == 0); @@ -125,7 +125,7 @@ bool QQnxNavigatorPps::sendPpsMessage(const QByteArray &message, const QByteArra parsePPS(ppsData, responseFields); if (responseFields.contains("res") && responseFields.value("res") == message) { - if (responseFields.contains("err")) { + if (Q_UNLIKELY(responseFields.contains("err"))) { qCritical() << "navigator responded with error: " << responseFields.value("err"); return false; } @@ -142,7 +142,7 @@ void QQnxNavigatorPps::parsePPS(const QByteArray &ppsData, QHash<QByteArray, QBy QList<QByteArray> lines = ppsData.split('\n'); // validate pps object - if (lines.size() == 0 || lines.at(0) != "@control") + if (Q_UNLIKELY(lines.empty() || lines.at(0) != "@control")) qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); // parse pps object attributes and extract values diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index 933fce0e33..771986d763 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -61,7 +61,7 @@ QQnxRasterWindow::QQnxRasterWindow(QWindow *window, screen_context_t context, bo const int val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE; const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); - if (result != 0) + if (Q_UNLIKELY(result != 0)) qFatal("QQnxRasterWindow: failed to set window alpha usage, errno=%d", errno); } diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index c4125ef177..7eaf50318c 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -584,10 +584,6 @@ void QQnxScreen::addWindow(QQnxWindow *window) else m_childWindows.push_back(window); updateHierarchy(); - } else { -#if defined(Q_OS_BLACKBERRY) - m_coverWindow = window; -#endif } } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 6c9532c428..781c6f28af 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -254,13 +254,8 @@ void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event) "Failed to query event cap"); int sequenceId = 0; -#if defined(Q_OS_BLACKBERRY) - Q_SCREEN_CHECKERROR( - screen_get_event_property_iv(event, SCREEN_PROPERTY_SEQUENCE_ID, &sequenceId), - "Failed to query event seqId"); -#endif - bool inject = true; + Q_FOREACH (QQnxScreenEventFilter *filter, m_eventFilters) { if (filter->handleKeyboardEvent(flags, sym, modifiers, scan, cap, sequenceId)) { inject = false; @@ -584,12 +579,12 @@ void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t event) errno = 0; screen_window_t window = 0; - if (screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) + if (Q_UNLIKELY(screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0)) qFatal("QQnx: failed to query window property, errno=%d", errno); errno = 0; int property; - if (screen_get_event_property_iv(event, SCREEN_PROPERTY_NAME, &property) != 0) + if (Q_UNLIKELY(screen_get_event_property_iv(event, SCREEN_PROPERTY_NAME, &property) != 0)) qFatal("QQnx: failed to query window property, errno=%d", errno); switch (property) { @@ -606,7 +601,7 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi { errno = 0; int focus = 0; - if (window && screen_get_window_property_iv(window, SCREEN_PROPERTY_KEYBOARD_FOCUS, &focus) != 0) + if (Q_UNLIKELY(window && screen_get_window_property_iv(window, SCREEN_PROPERTY_KEYBOARD_FOCUS, &focus) != 0)) qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno); QWindow *focusWindow = QQnxIntegration::window(window); diff --git a/src/plugins/platforms/qnx/qqnxsystemsettings.cpp b/src/plugins/platforms/qnx/qqnxsystemsettings.cpp deleted file mode 100644 index 243630ec85..0000000000 --- a/src/plugins/platforms/qnx/qqnxsystemsettings.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxsystemsettings.h" - -#include <QFont> -#include <qpa/qplatformfontdatabase.h> - -QT_BEGIN_NAMESPACE - -QHash<QPlatformTheme::Font, QFont *> qt_qnx_createRoleFonts(QPlatformFontDatabase *fontDatabase) -{ - // See http://docs.blackberry.com/en/developers/deliverables/41577/typography.jsp - // which recommends using - // - small font size of 6 points - // - normal font size of 8 points - // - 11 points for titles (not covered by the theme system). - QFont baseFont = fontDatabase->defaultFont(); - baseFont.setPointSize(8); - - QHash<QPlatformTheme::Font, QFont *> fonts; - fonts.insert(QPlatformTheme::SystemFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::PushButtonFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ListViewFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ListBoxFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::TitleBarFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::MenuFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ComboMenuItemFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::HeaderViewFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::TipLabelFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::LabelFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ToolButtonFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::MenuItemFont, new QFont(baseFont)); - fonts.insert(QPlatformTheme::ComboLineEditFont, new QFont(baseFont)); - - QFont smallFont(baseFont); - smallFont.setPointSize(6); - fonts.insert(QPlatformTheme::SmallFont, new QFont(smallFont)); - fonts.insert(QPlatformTheme::MiniFont, new QFont(smallFont)); - - return fonts; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxsystemsettings.h b/src/plugins/platforms/qnx/qqnxsystemsettings.h deleted file mode 100644 index 6a99d5a70c..0000000000 --- a/src/plugins/platforms/qnx/qqnxsystemsettings.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXSYSTEMSETTINGS_H -#define QQNXSYSTEMSETTINGS_H - -#include <QtCore/qhash.h> -#include <qpa/qplatformtheme.h> - -QT_BEGIN_NAMESPACE - -class QPlatformFontDatabase; - -QHash<QPlatformTheme::Font, QFont *> qt_qnx_createRoleFonts(QPlatformFontDatabase *fontDatabase); - -QT_END_NAMESPACE - -#endif // QQNXSYSTEMSETTINGS_H diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp deleted file mode 100644 index b55ae842ed..0000000000 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqnxvirtualkeyboardbps.h" - -#include <QDebug> - -#include <bps/event.h> -#include <bps/locale.h> -#include <bps/virtualkeyboard.h> -#if defined(Q_OS_BLACKBERRY) -#include <bbndk.h> -#endif - -#if defined(QQNXVIRTUALKEYBOARD_DEBUG) -#define qVirtualKeyboardDebug qDebug -#else -#define qVirtualKeyboardDebug QT_NO_QDEBUG_MACRO -#endif - -QT_BEGIN_NAMESPACE - -QQnxVirtualKeyboardBps::QQnxVirtualKeyboardBps(QObject *parent) - : QQnxAbstractVirtualKeyboard(parent) -{ - if (locale_request_events(0) != BPS_SUCCESS) - qWarning("QQNX: Failed to register for locale events"); - - if (virtualkeyboard_request_events(0) != BPS_SUCCESS) - qWarning("QQNX: Failed to register for virtual keyboard events"); - - int height = 0; - if (virtualkeyboard_get_height(&height) != BPS_SUCCESS) - qWarning("QQNX: Failed to get virtual keyboard height"); - - setHeight(height); -} - -bool QQnxVirtualKeyboardBps::handleEvent(bps_event_t *event) -{ - const int eventDomain = bps_event_get_domain(event); - if (eventDomain == locale_get_domain()) - return handleLocaleEvent(event); - - if (eventDomain == virtualkeyboard_get_domain()) - return handleVirtualKeyboardEvent(event); - - return false; -} - -bool QQnxVirtualKeyboardBps::showKeyboard() -{ - qVirtualKeyboardDebug() << "current visibility=" << isVisible(); - - // They keyboard's mode is global between applications, we have to set it each time - if ( !isVisible() ) - applyKeyboardOptions(); - - virtualkeyboard_show(); - return true; -} - -bool QQnxVirtualKeyboardBps::hideKeyboard() -{ - qVirtualKeyboardDebug() << "current visibility=" << isVisible(); - virtualkeyboard_hide(); - return true; -} - -void QQnxVirtualKeyboardBps::applyKeyboardOptions() -{ - virtualkeyboard_layout_t layout = keyboardLayout(); - virtualkeyboard_enter_t enter = enterKey(); - - qVirtualKeyboardDebug() << "mode=" << keyboardMode() << "enterKey=" << enterKeyType(); - - virtualkeyboard_change_options(layout, enter); -} - -virtualkeyboard_layout_t QQnxVirtualKeyboardBps::keyboardLayout() const -{ - switch (keyboardMode()) { - case Url: - return VIRTUALKEYBOARD_LAYOUT_URL; - case Email: - return VIRTUALKEYBOARD_LAYOUT_EMAIL; - case Web: - return VIRTUALKEYBOARD_LAYOUT_WEB; - case NumPunc: - return VIRTUALKEYBOARD_LAYOUT_NUM_PUNC; - case Number: - return VIRTUALKEYBOARD_LAYOUT_NUMBER; - case Symbol: - return VIRTUALKEYBOARD_LAYOUT_SYMBOL; - case Phone: - return VIRTUALKEYBOARD_LAYOUT_PHONE; - case Pin: - return VIRTUALKEYBOARD_LAYOUT_PIN; - case Password: - return VIRTUALKEYBOARD_LAYOUT_PASSWORD; -#if defined(Q_OS_BLACKBERRY) -#if BBNDK_VERSION_AT_LEAST(10, 2, 1) - case Alphanumeric: - return VIRTUALKEYBOARD_LAYOUT_ALPHANUMERIC; -#endif -#endif - case Default: // fall through - default: - return VIRTUALKEYBOARD_LAYOUT_DEFAULT; - } - - return VIRTUALKEYBOARD_LAYOUT_DEFAULT; -} - -virtualkeyboard_enter_t QQnxVirtualKeyboardBps::enterKey() const -{ - switch (enterKeyType()) { - case Connect: - return VIRTUALKEYBOARD_ENTER_CONNECT; - case Done: - return VIRTUALKEYBOARD_ENTER_DONE; - case Go: - return VIRTUALKEYBOARD_ENTER_GO; - case Join: - return VIRTUALKEYBOARD_ENTER_JOIN; - case Next: - return VIRTUALKEYBOARD_ENTER_NEXT; - case Search: - return VIRTUALKEYBOARD_ENTER_SEARCH; - case Send: - return VIRTUALKEYBOARD_ENTER_SEND; - case Submit: - return VIRTUALKEYBOARD_ENTER_SUBMIT; - case Default: // fall through - default: - return VIRTUALKEYBOARD_ENTER_DEFAULT; - } - - return VIRTUALKEYBOARD_ENTER_DEFAULT; -} - -bool QQnxVirtualKeyboardBps::handleLocaleEvent(bps_event_t *event) -{ - if (bps_event_get_code(event) == LOCALE_INFO) { - const QString language = QString::fromLatin1(locale_event_get_language(event)); - const QString country = QString::fromLatin1(locale_event_get_country(event)); - const QLocale newLocale(language + QLatin1Char('_') + country); - - qVirtualKeyboardDebug() << "current locale" << locale() << "new locale=" << newLocale; - setLocale(newLocale); - return true; - } - - qVirtualKeyboardDebug() << "Unhandled locale event. code=" << bps_event_get_code(event); - - return false; -} - -bool QQnxVirtualKeyboardBps::handleVirtualKeyboardEvent(bps_event_t *event) -{ - switch (bps_event_get_code(event)) { - case VIRTUALKEYBOARD_EVENT_VISIBLE: - qVirtualKeyboardDebug() << "EVENT VISIBLE: current visibility=" << isVisible(); - setVisible(true); - break; - - case VIRTUALKEYBOARD_EVENT_HIDDEN: - qVirtualKeyboardDebug() << "EVENT HIDDEN: current visibility=" << isVisible(); - setVisible(false); - break; - - case VIRTUALKEYBOARD_EVENT_INFO: { - const int newHeight = virtualkeyboard_event_get_height(event); - qVirtualKeyboardDebug() << "EVENT INFO: current height=" << height() << "new height=" << newHeight; - setHeight(newHeight); - break; - } - - default: - qVirtualKeyboardDebug() << "Unhandled virtual keyboard event. code=" << bps_event_get_code(event); - return false; - } - - return true; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h deleted file mode 100644 index a720c5d894..0000000000 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQNXVIRTUALKEYBOARDBPS_H -#define QQNXVIRTUALKEYBOARDBPS_H - -#include "qqnxabstractvirtualkeyboard.h" -#include <bps/virtualkeyboard.h> - -struct bps_event_t; - -QT_BEGIN_NAMESPACE - -class QQnxVirtualKeyboardBps : public QQnxAbstractVirtualKeyboard -{ - Q_OBJECT -public: - explicit QQnxVirtualKeyboardBps(QObject *parent = 0); - - bool handleEvent(bps_event_t *event); - - bool showKeyboard(); - bool hideKeyboard(); - -protected: - void applyKeyboardOptions(); - -private: - bool handleLocaleEvent(bps_event_t *event); - bool handleVirtualKeyboardEvent(bps_event_t *event); - - virtualkeyboard_layout_t keyboardLayout() const; - virtualkeyboard_enter_t enterKey() const; -}; - -QT_END_NAMESPACE - -#endif // QQNXVIRTUALKEYBOARDBPS_H diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp index d5a9a49ac6..880a914c84 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -127,7 +127,7 @@ bool QQnxVirtualKeyboardPps::connect() } m_buffer = new char[ms_bufferSize]; - if (!m_buffer) { + if (Q_UNLIKELY(!m_buffer)) { qCritical("QQnxVirtualKeyboard: Unable to allocate buffer of %d bytes. " "Size is unavailable.", ms_bufferSize); return false; @@ -170,7 +170,7 @@ void QQnxVirtualKeyboardPps::ppsDataReady() return; // nread is the real space necessary, not the amount read. - if (static_cast<size_t>(nread) > ms_bufferSize - 1) { + if (Q_UNLIKELY(static_cast<size_t>(nread) > ms_bufferSize - 1)) { qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1); connect(); // reconnect return; @@ -184,7 +184,7 @@ void QQnxVirtualKeyboardPps::ppsDataReady() #endif const char *value; - if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) { + if (Q_UNLIKELY(pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK)) { qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]"); return; } @@ -214,11 +214,11 @@ void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage() { int newHeight = 0; - if (pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK) { + if (Q_UNLIKELY(pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK)) { qCritical("QQnxVirtualKeyboard: Keyboard PPS dat object not found"); return; } - if (pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK) { + if (Q_UNLIKELY(pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK)) { qCritical("QQnxVirtualKeyboard: Keyboard PPS size field not found"); return; } diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 4dc1248bd1..47888178c4 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -47,12 +47,6 @@ #include <QtCore/QDebug> -#if defined(Q_OS_BLACKBERRY) -#include "qqnxnavigatorcover.h" -#include <sys/pps.h> -#include <bps/navigator.h> -#endif - #include <errno.h> #if defined(QQNXWINDOW_DEBUG) @@ -378,7 +372,7 @@ void QQnxWindow::setBufferSize(const QSize &size) screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount), "Failed to query render buffer count"); - if (bufferCount != MAX_BUFFER_COUNT) { + if (Q_UNLIKELY(bufferCount != MAX_BUFFER_COUNT)) { qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d.", MAX_BUFFER_COUNT, bufferCount); } @@ -456,10 +450,10 @@ void QQnxWindow::removeFromParent() qWindowDebug() << "window =" << window(); // Remove from old Hierarchy position if (m_parentWindow) { - if (m_parentWindow->m_childWindows.removeAll(this)) - m_parentWindow = 0; - else + if (Q_UNLIKELY(!m_parentWindow->m_childWindows.removeAll(this))) qFatal("QQnxWindow: Window Hierarchy broken; window has parent, but parent hasn't got child."); + else + m_parentWindow = 0; } else if (m_screen) { m_screen->removeWindow(this); } @@ -633,23 +627,7 @@ QQnxWindow *QQnxWindow::findWindow(screen_window_t windowHandle) void QQnxWindow::minimize() { -#if defined(Q_OS_BLACKBERRY) - qWindowDebug(); - - pps_encoder_t encoder; - - pps_encoder_initialize(&encoder, false); - pps_encoder_add_string(&encoder, "msg", "minimizeWindow"); - - if (navigator_raw_write(pps_encoder_buffer(&encoder), - pps_encoder_length(&encoder)) != BPS_SUCCESS) { - qWindowDebug() << "navigator_raw_write failed:" << strerror(errno); - } - - pps_encoder_cleanup(&encoder); -#else qWarning("Qt::WindowMinimized is not supported by this OS version"); -#endif } void QQnxWindow::setRotation(int rotation) @@ -686,18 +664,8 @@ void QQnxWindow::initWindow() QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window()->screen()->handle()); setScreen(platformScreen); - if (window()->type() == Qt::CoverWindow) { -#if defined(Q_OS_BLACKBERRY) - if (platformScreen->rootWindow()) { - screen_set_window_property_pv(m_screen->rootWindow()->nativeHandle(), - SCREEN_PROPERTY_ALTERNATE_WINDOW, (void**)&m_window); - m_cover.reset(new QQnxNavigatorCover); - } else { - qWarning("No root window for cover window"); - } -#endif + if (window()->type() == Qt::CoverWindow) m_exposed = false; - } // Add window to plugin's window mapper QQnxIntegration::addWindow(m_window, window()); diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index f2f6402889..217444d129 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -188,7 +188,7 @@ void QWindowsUser32DLL::init() // MinGW (g++ 3.4.5) accepts only C casts. setLayeredWindowAttributes = (SetLayeredWindowAttributes)(library.resolve("SetLayeredWindowAttributes")); updateLayeredWindow = (UpdateLayeredWindow)(library.resolve("UpdateLayeredWindow")); - if (!setLayeredWindowAttributes || !updateLayeredWindow) + if (Q_UNLIKELY(!setLayeredWindowAttributes || !updateLayeredWindow)) qFatal("This version of Windows is not supported (User32.dll is missing the symbols 'SetLayeredWindowAttributes', 'UpdateLayeredWindow')."); updateLayeredWindowIndirect = (UpdateLayeredWindowIndirect)(library.resolve("UpdateLayeredWindowIndirect")); diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 021058fa33..c68f05b5bb 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -230,8 +230,6 @@ private: }; typedef QMap<Qt::DropAction, CursorEntry> ActionCursorMap; - typedef ActionCursorMap::Iterator ActionCursorMapIt; - typedef ActionCursorMap::ConstIterator ActionCursorMapConstIt; const Mode m_mode; QWindowsDrag *m_drag; @@ -312,7 +310,7 @@ void QWindowsOleDropSource::createCursors() if (cursorPixmap.isNull() && platformCursor) cursorPixmap = static_cast<QWindowsCursor *>(platformCursor)->dragDefaultCursor(action); const qint64 cacheKey = cursorPixmap.cacheKey(); - const ActionCursorMapIt it = m_cursors.find(action); + const auto it = m_cursors.find(action); if (it != m_cursors.end() && it.value().cacheKey == cacheKey) continue; if (cursorPixmap.isNull()) { @@ -393,7 +391,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { HRESULT hr = S_OK; do { - if (fEscapePressed) { + if (fEscapePressed || QWindowsDrag::isCanceled()) { hr = ResultFromScode(DRAGDROP_S_CANCEL); break; } @@ -441,7 +439,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) m_drag->updateAction(action); const qint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey(); - ActionCursorMapConstIt it = m_cursors.constFind(action); + auto it = m_cursors.constFind(action); // If a custom drag cursor is set, check its cache key to detect changes. if (it == m_cursors.constEnd() || (currentCacheKey && currentCacheKey != it.value().cacheKey)) { createCursors(); @@ -673,6 +671,8 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, \ingroup qt-lighthouse-win */ +bool QWindowsDrag::m_canceled = false; + QWindowsDrag::QWindowsDrag() : m_dropDataObject(0), m_cachedDropTargetHelper(0) { @@ -714,6 +714,7 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) Qt::DropAction dragResult = Qt::IgnoreAction; DWORD resultEffect; + QWindowsDrag::m_canceled = false; QWindowsOleDropSource *windowDropSource = new QWindowsOleDropSource(this); windowDropSource->createCursors(); QWindowsOleDataObject *dropDataObject = new QWindowsOleDataObject(dropData); diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index 890ad6c142..ebe949a6af 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -90,6 +90,8 @@ public: Qt::DropAction drag(QDrag *drag) Q_DECL_OVERRIDE; static QWindowsDrag *instance(); + void cancelDrag() Q_DECL_OVERRIDE { QWindowsDrag::m_canceled = true; } + static bool isCanceled() { return QWindowsDrag::m_canceled; } IDataObject *dropDataObject() const { return m_dropDataObject; } void setDropDataObject(IDataObject *dataObject) { m_dropDataObject = dataObject; } @@ -99,6 +101,8 @@ public: IDropTargetHelper* dropHelper(); private: + static bool m_canceled; + QWindowsDropMimeData m_dropData; IDataObject *m_dropDataObject; diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 8a2fbe1f6d..8d1bbc75a6 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -44,6 +44,7 @@ #include <QtCore/qmath.h> #include <QtCore/QDebug> +#include <QtCore/QFile> #include <QtCore/QtEndian> #include <QtCore/QThreadStorage> #include <QtCore/private/qsystemlibrary_p.h> @@ -1062,7 +1063,7 @@ QSharedPointer<QWindowsFontEngineData> sharedFontData() { FontEngineThreadLocalData *data = fontEngineThreadLocalData(); if (!data->hasLocalData()) - data->setLocalData(QSharedPointer<QWindowsFontEngineData>(new QWindowsFontEngineData)); + data->setLocalData(QSharedPointer<QWindowsFontEngineData>::create()); return data->localData(); } #else // !QT_NO_THREAD @@ -1072,7 +1073,7 @@ QWindowsFontEngineDataPtr sharedFontData() { QWindowsFontEngineDataPtr *data = fontEngineData(); if (data->isNull()) - *data = QWindowsFontEngineDataPtr(new QWindowsFontEngineData); + *data = QWindowsFontEngineDataPtr::create(); return *data; } #endif // QT_NO_THREAD @@ -1605,7 +1606,7 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request) lf.lfPitchAndFamily = DEFAULT_PITCH | hint; QString fam = request.family; - if (fam.size() >= LF_FACESIZE) { + if (Q_UNLIKELY(fam.size() >= LF_FACESIZE)) { qCritical("%s: Family name '%s' is too long.", __FUNCTION__, qPrintable(fam)); fam.truncate(LF_FACESIZE - 1); } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 16cc2afef6..361e7f4445 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -145,10 +145,8 @@ static FontKeys &fontKeys() static const FontKey *findFontKey(const QString &name, int *indexIn = Q_NULLPTR) { - typedef FontKeys::ConstIterator ConstIt; - const FontKeys &keys = fontKeys(); - for (ConstIt it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) { + for (auto it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) { const int index = it->fontNames.indexOf(name); if (index >= 0) { if (indexIn) diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 30417f7cee..41fa8c015d 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -54,6 +54,7 @@ #include <QtGui/private/qpaintengine_raster_p.h> #include <QtCore/QtEndian> +#include <QtCore/QFile> #include <QtCore/qmath.h> #include <QtCore/QThreadStorage> #include <QtCore/private/qsystemlibrary_p.h> @@ -196,7 +197,7 @@ void QWindowsFontEngine::getCMap() designToDevice = QFixed((int)otm->otmEMSquare)/QFixed::fromReal(fontDef.pixelSize); unitsPerEm = otm->otmEMSquare; x_height = (int)otm->otmsXHeight; - loadKerningPairs(QFixed((int)otm->otmEMSquare)/int(otm->otmTextMetrics.tmHeight)); + loadKerningPairs(designToDevice); _faceId.filename = QFile::encodeName(QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName))); lineWidth = otm->otmsUnderscoreSize; fsType = otm->otmfsType; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 55e6d55e5b..5f22ca1887 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -61,6 +61,7 @@ #if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER) # include "qwindowssessionmanager.h" #endif +#include <QtGui/qtouchdevice.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/qpa/qplatforminputcontextfactory_p.h> @@ -220,11 +221,13 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL if (tabletAbsoluteRange >= 0) m_context.setTabletAbsoluteRange(tabletAbsoluteRange); if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication. - m_context.setProcessDpiAwareness(dpiAwareness); + if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { + m_context.setProcessDpiAwareness(dpiAwareness); + qCDebug(lcQpaWindows) + << __FUNCTION__ << "DpiAwareness=" << dpiAwareness; + } dpiAwarenessSet = true; } - qCDebug(lcQpaWindows) - << __FUNCTION__ << "DpiAwareness=" << dpiAwareness; m_context.initTouch(m_options); } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index e26010b5c4..80f3d3e2b8 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -41,6 +41,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> +#include <QtGui/QTouchDevice> #include <QtGui/QWindow> #include <QtGui/QCursor> diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.cpp b/src/plugins/platforms/windows/qwindowsnativeimage.cpp index 66e64e64b4..56e18e20d7 100644 --- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeimage.cpp @@ -96,7 +96,7 @@ static inline HBITMAP createDIB(HDC hdc, int width, int height, void *bits = 0; HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi), DIB_RGB_COLORS, &bits, 0, 0); - if (!bitmap || !bits) + if (Q_UNLIKELY(!bitmap || !bits)) qFatal("%s: CreateDIBSection failed.", __FUNCTION__); *bitsIn = (uchar*)bits; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index b27811df9e..d5aae9746d 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -391,6 +391,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const int currentDevice = m_devices.at(m_currentDevice).currentDevice; const int currentPointer = m_devices.at(m_currentDevice).currentPointerType; + const qint64 uniqueId = m_devices.at(m_currentDevice).uniqueId; // The tablet can be used in 2 different modes, depending on it settings: // 1) Absolute (pen) mode: @@ -407,7 +408,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const QRect virtualDesktopArea = QGuiApplication::primaryScreen()->virtualGeometry(); qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount - << "target:" << QGuiApplicationPrivate::tabletPressTarget; + << "target:" << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); @@ -420,7 +421,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() QPointF globalPosF = m_oldGlobalPosF; m_oldGlobalPosF = m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea); - QWindow *target = QGuiApplicationPrivate::tabletPressTarget; // Pass to window that grabbed it. + QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; // Pass to window that grabbed it. QPoint globalPos = globalPosF.toPoint(); // Get Mouse Position and compare to tablet info @@ -484,7 +485,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() static_cast<Qt::MouseButtons>(packet.pkButtons), pressureNew, tiltX, tiltY, tangentialPressure, rotation, z, - m_devices.at(m_currentDevice).uniqueId, + uniqueId, keyboardModifiers); } return true; diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp index 3fd0278360..1008e1c5e8 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp @@ -55,7 +55,7 @@ struct WinRTEGLDisplay { WinRTEGLDisplay() { eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (eglDisplay == EGL_NO_DISPLAY) + if (Q_UNLIKELY(eglDisplay == EGL_NO_DISPLAY)) qCritical("Failed to initialize EGL display: 0x%x", eglGetError()); } ~WinRTEGLDisplay() { @@ -114,10 +114,10 @@ void QWinRTEGLContext::initialize() EGL_NONE, }; g->eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes); - if (g->eglDisplay == EGL_NO_DISPLAY) + if (Q_UNLIKELY(g->eglDisplay == EGL_NO_DISPLAY)) qCritical("Failed to initialize EGL display: 0x%x", eglGetError()); - if (!eglInitialize(g->eglDisplay, nullptr, nullptr)) + if (Q_UNLIKELY(!eglInitialize(g->eglDisplay, nullptr, nullptr))) qCritical("Failed to initialize EGL: 0x%x", eglGetError()); d->eglConfig = q_configFromGLFormat(g->eglDisplay, d->format); diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index bec94c1e51..8a53047d1e 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -180,7 +180,7 @@ QWinRTWindow::~QWinRTWindow() EGLBoolean value = eglDestroySurface(d->display, d->surface); d->surface = EGL_NO_SURFACE; - if (value == EGL_FALSE) + if (Q_UNLIKELY(value == EGL_FALSE)) qCritical("Failed to destroy EGL window surface: 0x%x", eglGetError()); } @@ -321,7 +321,7 @@ void QWinRTWindow::createEglSurface(EGLDisplay display, EGLConfig config) d->surface = eglCreateWindowSurface(display, config, reinterpret_cast<EGLNativeWindowType>(winId()), nullptr); - if (d->surface == EGL_NO_SURFACE) + if (Q_UNLIKELY(d->surface == EGL_NO_SURFACE)) qCritical("Failed to create EGL window surface: 0x%x", eglGetError()); return S_OK; }); diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 37f01d4eed..e1fb63fbc4 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -99,7 +99,7 @@ static Window createDummyWindow(Display *dpy, XVisualInfo *visualInfo, int scree static Window createDummyWindow(Display *dpy, GLXFBConfig config, int screenNumber, Window rootWin) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(dpy, config); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); Window window = createDummyWindow(dpy, visualInfo, screenNumber, rootWin); XFree(visualInfo); @@ -301,7 +301,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) // Note that m_format gets updated with the used surface format visualInfo = qglx_findVisualInfo(m_display, screen->screenNumber(), &m_format); - if (!visualInfo) + if (Q_UNLIKELY(!visualInfo)) qFatal("Could not initialize GLX"); m_context = glXCreateContext(m_display, visualInfo, m_shareContext, true); if (!m_context && m_shareContext) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 50d49ca798..ff39b24e93 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -521,7 +521,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreenNumber); #endif //XCB_USE_XLIB - if (!m_connection || xcb_connection_has_error(m_connection)) + if (Q_UNLIKELY(!m_connection || xcb_connection_has_error(m_connection))) qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData()); @@ -553,7 +553,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeXFixes(); initializeScreens(); - if (m_screens.isEmpty()) + if (Q_UNLIKELY(m_screens.isEmpty())) qFatal("QXcbConnection: no screens available"); initializeXRender(); diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 2e088d3ca5..0bfefc962e 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1511,11 +1511,13 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, QWindow *window = targetWindow->window(); if (!filtered) { +#ifndef QT_NO_CONTEXTMENU if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu) { const QPoint globalPos = window->screen()->handle()->cursor()->pos(); const QPoint pos = window->mapFromGlobal(globalPos); QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers); } +#endif // QT_NO_CONTEXTMENU QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, code, sym, state, string, isAutoRepeat); } diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 0e99d58679..db7d837e01 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -182,8 +182,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe updateRefreshRate(crtc->mode); free(crtc); } - } else { - updateGeometry(output ? output->timestamp : 0); } if (m_geometry.isEmpty()) { diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 6023ee6b29..3e01a90402 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -395,7 +395,7 @@ void QXcbWindow::create() if (!visualInfo) visualInfo = static_cast<XVisualInfo *>(createVisual()); - if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) + if (Q_UNLIKELY(!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface)) qFatal("Could not initialize OpenGL"); if (!visualInfo && window()->surfaceType() == QSurface::RasterGLSurface) { @@ -1096,6 +1096,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) } setWmWindowType(wmWindowTypes, flags); + setNetWmStateWindowFlags(flags); setMotifWindowFlags(flags); setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput); @@ -1331,6 +1332,15 @@ void QXcbWindow::updateNetWmStateBeforeMap() setNetWmStates(states); } +void QXcbWindow::setNetWmStateWindowFlags(Qt::WindowFlags flags) +{ + changeNetWmState(flags & Qt::WindowStaysOnTopHint, + atom(QXcbAtom::_NET_WM_STATE_ABOVE), + atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); + changeNetWmState(flags & Qt::WindowStaysOnBottomHint, + atom(QXcbAtom::_NET_WM_STATE_BELOW)); +} + void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) { xcb_window_t wid = m_window; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 43e66a774d..c42c98c205 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -184,6 +184,7 @@ protected: void setNetWmStates(NetWmStates); void setMotifWindowFlags(Qt::WindowFlags flags); + void setNetWmStateWindowFlags(Qt::WindowFlags flags); void updateMotifWmHintsBeforeMap(); void updateNetWmStateBeforeMap(); diff --git a/src/plugins/platformthemes/gtk2/gtk2.json b/src/plugins/platformthemes/gtk2/gtk2.json deleted file mode 100644 index 86dd8e58fa..0000000000 --- a/src/plugins/platformthemes/gtk2/gtk2.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "gtk2" ] -} diff --git a/src/plugins/platformthemes/gtk2/gtk2.pro b/src/plugins/platformthemes/gtk2/gtk2.pro deleted file mode 100644 index 73c156f82b..0000000000 --- a/src/plugins/platformthemes/gtk2/gtk2.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = qgtk2 - -PLUGIN_TYPE = platformthemes -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QGtk2ThemePlugin -load(qt_plugin) - -QT += core-private gui-private platformsupport-private - -CONFIG += X11 -QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTK2 -LIBS += $$QT_LIBS_QGTK2 - -HEADERS += \ - qgtk2dialoghelpers.h \ - qgtk2theme.h - -SOURCES += \ - main.cpp \ - qgtk2dialoghelpers.cpp \ - qgtk2theme.cpp \ diff --git a/src/plugins/platformthemes/gtk3/gtk3.json b/src/plugins/platformthemes/gtk3/gtk3.json new file mode 100644 index 0000000000..3887248353 --- /dev/null +++ b/src/plugins/platformthemes/gtk3/gtk3.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "gtk3" ] +} diff --git a/src/plugins/platformthemes/gtk3/gtk3.pro b/src/plugins/platformthemes/gtk3/gtk3.pro new file mode 100644 index 0000000000..cd19e73ed8 --- /dev/null +++ b/src/plugins/platformthemes/gtk3/gtk3.pro @@ -0,0 +1,21 @@ +TARGET = qgtk3 + +PLUGIN_TYPE = platformthemes +PLUGIN_EXTENDS = - +PLUGIN_CLASS_NAME = QGtk3ThemePlugin +load(qt_plugin) + +QT += core-private gui-private platformsupport-private + +CONFIG += X11 +QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTK3 +LIBS += $$QT_LIBS_QGTK3 + +HEADERS += \ + qgtk3dialoghelpers.h \ + qgtk3theme.h + +SOURCES += \ + main.cpp \ + qgtk3dialoghelpers.cpp \ + qgtk3theme.cpp diff --git a/src/plugins/platformthemes/gtk2/main.cpp b/src/plugins/platformthemes/gtk3/main.cpp index 34ac3ffc07..c3e81b18e3 100644 --- a/src/plugins/platformthemes/gtk2/main.cpp +++ b/src/plugins/platformthemes/gtk3/main.cpp @@ -32,24 +32,24 @@ ****************************************************************************/ #include <qpa/qplatformthemeplugin.h> -#include "qgtk2theme.h" +#include "qgtk3theme.h" QT_BEGIN_NAMESPACE -class QGtk2ThemePlugin : public QPlatformThemePlugin +class QGtk3ThemePlugin : public QPlatformThemePlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "gtk2.json") + Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "gtk3.json") public: QPlatformTheme *create(const QString &key, const QStringList ¶ms) Q_DECL_OVERRIDE; }; -QPlatformTheme *QGtk2ThemePlugin::create(const QString &key, const QStringList ¶ms) +QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList ¶ms) { Q_UNUSED(params); - if (!key.compare(QLatin1String(QGtk2Theme::name), Qt::CaseInsensitive)) - return new QGtk2Theme; + if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) + return new QGtk3Theme; return 0; } diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index 2f0bceafe6..2a3585464f 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include "qgtk2dialoghelpers.h" +#include "qgtk3dialoghelpers.h" #include <qeventloop.h> #include <qwindow.h> @@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE -class QGtk2Dialog : public QWindow +class QGtk3Dialog : public QWindow { Q_OBJECT public: - QGtk2Dialog(GtkWidget *gtkWidget); - ~QGtk2Dialog(); + QGtk3Dialog(GtkWidget *gtkWidget); + ~QGtk3Dialog(); GtkDialog *gtkDialog() const; @@ -69,30 +69,30 @@ Q_SIGNALS: void reject(); protected: - static void onResponse(QGtk2Dialog *dialog, int response); + static void onResponse(QGtk3Dialog *dialog, int response); private: GtkWidget *gtkWidget; }; -QGtk2Dialog::QGtk2Dialog(GtkWidget *gtkWidget) : gtkWidget(gtkWidget) +QGtk3Dialog::QGtk3Dialog(GtkWidget *gtkWidget) : gtkWidget(gtkWidget) { g_signal_connect_swapped(G_OBJECT(gtkWidget), "response", G_CALLBACK(onResponse), this); g_signal_connect(G_OBJECT(gtkWidget), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); } -QGtk2Dialog::~QGtk2Dialog() +QGtk3Dialog::~QGtk3Dialog() { gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); gtk_widget_destroy(gtkWidget); } -GtkDialog *QGtk2Dialog::gtkDialog() const +GtkDialog *QGtk3Dialog::gtkDialog() const { return GTK_DIALOG(gtkWidget); } -void QGtk2Dialog::exec() +void QGtk3Dialog::exec() { if (modality() == Qt::ApplicationModal) { // block input to the whole app, including other GTK dialogs @@ -106,7 +106,7 @@ void QGtk2Dialog::exec() } } -bool QGtk2Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { setParent(parent); setFlags(flags); @@ -114,29 +114,31 @@ bool QGtk2Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWind gtk_widget_realize(gtkWidget); // creates X window + GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget); if (parent) { - XSetTransientForHint(gdk_x11_drawable_get_xdisplay(gtkWidget->window), - gdk_x11_drawable_get_xid(gtkWidget->window), + GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow); + XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay), + gdk_x11_window_get_xid(gdkWindow), parent->winId()); } if (modality != Qt::NonModal) { - gdk_window_set_modal_hint(gtkWidget->window, true); + gdk_window_set_modal_hint(gdkWindow, true); QGuiApplicationPrivate::showModalWindow(this); } gtk_widget_show(gtkWidget); - gdk_window_focus(gtkWidget->window, 0); + gdk_window_focus(gdkWindow, GDK_CURRENT_TIME); return true; } -void QGtk2Dialog::hide() +void QGtk3Dialog::hide() { QGuiApplicationPrivate::hideModalWindow(this); gtk_widget_hide(gtkWidget); } -void QGtk2Dialog::onResponse(QGtk2Dialog *dialog, int response) +void QGtk3Dialog::onResponse(QGtk3Dialog *dialog, int response) { if (response == GTK_RESPONSE_OK) emit dialog->accept(); @@ -144,95 +146,78 @@ void QGtk2Dialog::onResponse(QGtk2Dialog *dialog, int response) emit dialog->reject(); } -QGtk2ColorDialogHelper::QGtk2ColorDialogHelper() +QGtk3ColorDialogHelper::QGtk3ColorDialogHelper() { - d.reset(new QGtk2Dialog(gtk_color_selection_dialog_new(""))); + d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", 0))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); - GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(d->gtkDialog())); - g_signal_connect_swapped(gtkColorSelection, "color-changed", G_CALLBACK(onColorChanged), this); + g_signal_connect_swapped(d->gtkDialog(), "color-activated", G_CALLBACK(onColorChanged), this); } -QGtk2ColorDialogHelper::~QGtk2ColorDialogHelper() +QGtk3ColorDialogHelper::~QGtk3ColorDialogHelper() { } -bool QGtk2ColorDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +bool QGtk3ColorDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { applyOptions(); return d->show(flags, modality, parent); } -void QGtk2ColorDialogHelper::exec() +void QGtk3ColorDialogHelper::exec() { d->exec(); } -void QGtk2ColorDialogHelper::hide() +void QGtk3ColorDialogHelper::hide() { d->hide(); } -void QGtk2ColorDialogHelper::setCurrentColor(const QColor &color) +void QGtk3ColorDialogHelper::setCurrentColor(const QColor &color) { GtkDialog *gtkDialog = d->gtkDialog(); - GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(gtkDialog)); - GdkColor gdkColor; - gdkColor.red = color.red() << 8; - gdkColor.green = color.green() << 8; - gdkColor.blue = color.blue() << 8; - gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(gtkColorSelection), &gdkColor); - if (color.alpha() < 255) { - gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(gtkColorSelection), true); - gtk_color_selection_set_current_alpha(GTK_COLOR_SELECTION(gtkColorSelection), color.alpha() << 8); - } + if (color.alpha() < 255) + gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), true); + GdkRGBA gdkColor; + gdkColor.red = color.redF(); + gdkColor.green = color.greenF(); + gdkColor.blue = color.blueF(); + gdkColor.alpha = color.alphaF(); + gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(gtkDialog), &gdkColor); } -QColor QGtk2ColorDialogHelper::currentColor() const +QColor QGtk3ColorDialogHelper::currentColor() const { GtkDialog *gtkDialog = d->gtkDialog(); - GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(gtkDialog)); - GdkColor gdkColor; - gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(gtkColorSelection), &gdkColor); - guint16 alpha = gtk_color_selection_get_current_alpha(GTK_COLOR_SELECTION(gtkColorSelection)); - return QColor(gdkColor.red >> 8, gdkColor.green >> 8, gdkColor.blue >> 8, alpha >> 8); + GdkRGBA gdkColor; + gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(gtkDialog), &gdkColor); + return QColor::fromRgbF(gdkColor.red, gdkColor.green, gdkColor.blue, gdkColor.alpha); } -void QGtk2ColorDialogHelper::onAccepted() +void QGtk3ColorDialogHelper::onAccepted() { emit accept(); emit colorSelected(currentColor()); } -void QGtk2ColorDialogHelper::onColorChanged(QGtk2ColorDialogHelper *dialog) +void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog) { emit dialog->currentColorChanged(dialog->currentColor()); } -void QGtk2ColorDialogHelper::applyOptions() +void QGtk3ColorDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); gtk_window_set_title(GTK_WINDOW(gtkDialog), options()->windowTitle().toUtf8()); - GtkWidget *gtkColorSelection = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(gtkDialog)); - gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(gtkColorSelection), options()->testOption(QColorDialogOptions::ShowAlphaChannel)); - - GtkWidget *okButton = 0; - GtkWidget *cancelButton = 0; - GtkWidget *helpButton = 0; - g_object_get(G_OBJECT(gtkDialog), "ok-button", &okButton, "cancel-button", &cancelButton, "help-button", &helpButton, NULL); - if (okButton) - g_object_set(G_OBJECT(okButton), "visible", !options()->testOption(QColorDialogOptions::NoButtons), NULL); - if (cancelButton) - g_object_set(G_OBJECT(cancelButton), "visible", !options()->testOption(QColorDialogOptions::NoButtons), NULL); - if (helpButton) - gtk_widget_hide(helpButton); + gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), options()->testOption(QColorDialogOptions::ShowAlphaChannel)); } -QGtk2FileDialogHelper::QGtk2FileDialogHelper() +QGtk3FileDialogHelper::QGtk3FileDialogHelper() { - d.reset(new QGtk2Dialog(gtk_file_chooser_dialog_new("", 0, + d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL))); @@ -243,11 +228,11 @@ QGtk2FileDialogHelper::QGtk2FileDialogHelper() g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "current-folder-changed", G_CALLBACK(onCurrentFolderChanged), this); } -QGtk2FileDialogHelper::~QGtk2FileDialogHelper() +QGtk3FileDialogHelper::~QGtk3FileDialogHelper() { } -bool QGtk2FileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +bool QGtk3FileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { _dir.clear(); _selection.clear(); @@ -256,12 +241,12 @@ bool QGtk2FileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modal return d->show(flags, modality, parent); } -void QGtk2FileDialogHelper::exec() +void QGtk3FileDialogHelper::exec() { d->exec(); } -void QGtk2FileDialogHelper::hide() +void QGtk3FileDialogHelper::hide() { // After GtkFileChooserDialog has been hidden, gtk_file_chooser_get_current_folder() // & gtk_file_chooser_get_filenames() will return bogus values -> cache the actual @@ -272,18 +257,18 @@ void QGtk2FileDialogHelper::hide() d->hide(); } -bool QGtk2FileDialogHelper::defaultNameFilterDisables() const +bool QGtk3FileDialogHelper::defaultNameFilterDisables() const { return false; } -void QGtk2FileDialogHelper::setDirectory(const QUrl &directory) +void QGtk3FileDialogHelper::setDirectory(const QUrl &directory) { GtkDialog *gtkDialog = d->gtkDialog(); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), directory.toLocalFile().toUtf8()); } -QUrl QGtk2FileDialogHelper::directory() const +QUrl QGtk3FileDialogHelper::directory() const { // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_current_folder() // returns a bogus value -> return the cached value before hiding @@ -300,7 +285,7 @@ QUrl QGtk2FileDialogHelper::directory() const return QUrl::fromLocalFile(ret); } -void QGtk2FileDialogHelper::selectFile(const QUrl &filename) +void QGtk3FileDialogHelper::selectFile(const QUrl &filename) { GtkDialog *gtkDialog = d->gtkDialog(); if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { @@ -312,7 +297,7 @@ void QGtk2FileDialogHelper::selectFile(const QUrl &filename) } } -QList<QUrl> QGtk2FileDialogHelper::selectedFiles() const +QList<QUrl> QGtk3FileDialogHelper::selectedFiles() const { // While GtkFileChooserDialog is hidden, gtk_file_chooser_get_filenames() // returns a bogus value -> return the cached value before hiding @@ -328,12 +313,12 @@ QList<QUrl> QGtk2FileDialogHelper::selectedFiles() const return selection; } -void QGtk2FileDialogHelper::setFilter() +void QGtk3FileDialogHelper::setFilter() { applyOptions(); } -void QGtk2FileDialogHelper::selectNameFilter(const QString &filter) +void QGtk3FileDialogHelper::selectNameFilter(const QString &filter) { GtkFileFilter *gtkFilter = _filters.value(filter); if (gtkFilter) { @@ -342,14 +327,14 @@ void QGtk2FileDialogHelper::selectNameFilter(const QString &filter) } } -QString QGtk2FileDialogHelper::selectedNameFilter() const +QString QGtk3FileDialogHelper::selectedNameFilter() const { GtkDialog *gtkDialog = d->gtkDialog(); GtkFileFilter *gtkFilter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(gtkDialog)); return _filterNames.value(gtkFilter); } -void QGtk2FileDialogHelper::onAccepted() +void QGtk3FileDialogHelper::onAccepted() { emit accept(); @@ -363,7 +348,7 @@ void QGtk2FileDialogHelper::onAccepted() emit fileSelected(files.first()); } -void QGtk2FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk2FileDialogHelper *helper) +void QGtk3FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper) { QString selection; gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtkDialog)); @@ -374,7 +359,7 @@ void QGtk2FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk2FileDi emit helper->currentChanged(QUrl::fromLocalFile(selection)); } -void QGtk2FileDialogHelper::onCurrentFolderChanged(QGtk2FileDialogHelper *dialog) +void QGtk3FileDialogHelper::onCurrentFolderChanged(QGtk3FileDialogHelper *dialog) { emit dialog->directoryEntered(dialog->directory()); } @@ -399,7 +384,7 @@ static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialo } } -void QGtk2FileDialogHelper::applyOptions() +void QGtk3FileDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); const QSharedPointer<QFileDialogOptions> &opts = options(); @@ -430,7 +415,6 @@ void QGtk2FileDialogHelper::applyOptions() if (!initialNameFilter.isEmpty()) selectNameFilter(initialNameFilter); -#if GTK_CHECK_VERSION(2, 20, 0) GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK); if (acceptButton) { if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept)) @@ -448,10 +432,9 @@ void QGtk2FileDialogHelper::applyOptions() else gtk_button_set_label(GTK_BUTTON(rejectButton), GTK_STOCK_CANCEL); } -#endif } -void QGtk2FileDialogHelper::setNameFilters(const QStringList &filters) +void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters) { GtkDialog *gtkDialog = d->gtkDialog(); foreach (GtkFileFilter *filter, _filters) @@ -476,29 +459,29 @@ void QGtk2FileDialogHelper::setNameFilters(const QStringList &filters) } } -QGtk2FontDialogHelper::QGtk2FontDialogHelper() +QGtk3FontDialogHelper::QGtk3FontDialogHelper() { - d.reset(new QGtk2Dialog(gtk_font_selection_dialog_new(""))); + d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", 0))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); } -QGtk2FontDialogHelper::~QGtk2FontDialogHelper() +QGtk3FontDialogHelper::~QGtk3FontDialogHelper() { } -bool QGtk2FontDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +bool QGtk3FontDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { applyOptions(); return d->show(flags, modality, parent); } -void QGtk2FontDialogHelper::exec() +void QGtk3FontDialogHelper::exec() { d->exec(); } -void QGtk2FontDialogHelper::hide() +void QGtk3FontDialogHelper::hide() { d->hide(); } @@ -569,43 +552,36 @@ static QFont qt_fontFromString(const QString &name) return font; } -void QGtk2FontDialogHelper::setCurrentFont(const QFont &font) +void QGtk3FontDialogHelper::setCurrentFont(const QFont &font) { - GtkFontSelectionDialog *gtkDialog = GTK_FONT_SELECTION_DIALOG(d->gtkDialog()); - gtk_font_selection_dialog_set_font_name(gtkDialog, qt_fontToString(font).toUtf8()); + GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog()); + gtk_font_chooser_set_font(gtkDialog, qt_fontToString(font).toUtf8()); } -QFont QGtk2FontDialogHelper::currentFont() const +QFont QGtk3FontDialogHelper::currentFont() const { - GtkFontSelectionDialog *gtkDialog = GTK_FONT_SELECTION_DIALOG(d->gtkDialog()); - gchar *name = gtk_font_selection_dialog_get_font_name(gtkDialog); + GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog()); + gchar *name = gtk_font_chooser_get_font(gtkDialog); QFont font = qt_fontFromString(QString::fromUtf8(name)); g_free(name); return font; } -void QGtk2FontDialogHelper::onAccepted() +void QGtk3FontDialogHelper::onAccepted() { emit currentFontChanged(currentFont()); emit accept(); emit fontSelected(currentFont()); } -void QGtk2FontDialogHelper::applyOptions() +void QGtk3FontDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); const QSharedPointer<QFontDialogOptions> &opts = options(); gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); - - GtkWidget *okButton = gtk_font_selection_dialog_get_ok_button(GTK_FONT_SELECTION_DIALOG(gtkDialog)); - GtkWidget *cancelButton = gtk_font_selection_dialog_get_cancel_button(GTK_FONT_SELECTION_DIALOG(gtkDialog)); - if (okButton) - gtk_widget_set_visible(okButton, !options()->testOption(QFontDialogOptions::NoButtons)); - if (cancelButton) - gtk_widget_set_visible(cancelButton, !options()->testOption(QFontDialogOptions::NoButtons)); } QT_END_NAMESPACE -#include "qgtk2dialoghelpers.moc" +#include "qgtk3dialoghelpers.moc" diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h index 141056637e..438dee861b 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.h +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h @@ -31,8 +31,8 @@ ** ****************************************************************************/ -#ifndef QGTK2DIALOGHELPERS_P_H -#define QGTK2DIALOGHELPERS_P_H +#ifndef QGTK3DIALOGHELPERS_H +#define QGTK3DIALOGHELPERS_H #include <QtCore/qhash.h> #include <QtCore/qlist.h> @@ -46,16 +46,16 @@ typedef struct _GtkFileFilter GtkFileFilter; QT_BEGIN_NAMESPACE -class QGtk2Dialog; +class QGtk3Dialog; class QColor; -class QGtk2ColorDialogHelper : public QPlatformColorDialogHelper +class QGtk3ColorDialogHelper : public QPlatformColorDialogHelper { Q_OBJECT public: - QGtk2ColorDialogHelper(); - ~QGtk2ColorDialogHelper(); + QGtk3ColorDialogHelper(); + ~QGtk3ColorDialogHelper(); bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; void exec() Q_DECL_OVERRIDE; @@ -68,19 +68,19 @@ private Q_SLOTS: void onAccepted(); private: - static void onColorChanged(QGtk2ColorDialogHelper *helper); + static void onColorChanged(QGtk3ColorDialogHelper *helper); void applyOptions(); - QScopedPointer<QGtk2Dialog> d; + QScopedPointer<QGtk3Dialog> d; }; -class QGtk2FileDialogHelper : public QPlatformFileDialogHelper +class QGtk3FileDialogHelper : public QPlatformFileDialogHelper { Q_OBJECT public: - QGtk2FileDialogHelper(); - ~QGtk2FileDialogHelper(); + QGtk3FileDialogHelper(); + ~QGtk3FileDialogHelper(); bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; void exec() Q_DECL_OVERRIDE; @@ -99,8 +99,8 @@ private Q_SLOTS: void onAccepted(); private: - static void onSelectionChanged(GtkDialog *dialog, QGtk2FileDialogHelper *helper); - static void onCurrentFolderChanged(QGtk2FileDialogHelper *helper); + static void onSelectionChanged(GtkDialog *dialog, QGtk3FileDialogHelper *helper); + static void onCurrentFolderChanged(QGtk3FileDialogHelper *helper); void applyOptions(); void setNameFilters(const QStringList &filters); @@ -108,16 +108,16 @@ private: QList<QUrl> _selection; QHash<QString, GtkFileFilter*> _filters; QHash<GtkFileFilter*, QString> _filterNames; - QScopedPointer<QGtk2Dialog> d; + QScopedPointer<QGtk3Dialog> d; }; -class QGtk2FontDialogHelper : public QPlatformFontDialogHelper +class QGtk3FontDialogHelper : public QPlatformFontDialogHelper { Q_OBJECT public: - QGtk2FontDialogHelper(); - ~QGtk2FontDialogHelper(); + QGtk3FontDialogHelper(); + ~QGtk3FontDialogHelper(); bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) Q_DECL_OVERRIDE; void exec() Q_DECL_OVERRIDE; @@ -132,9 +132,9 @@ private Q_SLOTS: private: void applyOptions(); - QScopedPointer<QGtk2Dialog> d; + QScopedPointer<QGtk3Dialog> d; }; QT_END_NAMESPACE -#endif // QGTK2DIALOGHELPERS_P_H +#endif // QGTK3DIALOGHELPERS_H diff --git a/src/plugins/platformthemes/gtk2/qgtk2theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index a7f08bc047..76afc441a4 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -31,8 +31,8 @@ ** ****************************************************************************/ -#include "qgtk2theme.h" -#include "qgtk2dialoghelpers.h" +#include "qgtk3theme.h" +#include "qgtk3dialoghelpers.h" #include <QVariant> #undef signals @@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE -const char *QGtk2Theme::name = "gtk2"; +const char *QGtk3Theme::name = "gtk3"; static QString gtkSetting(const gchar *propertyName) { @@ -54,7 +54,21 @@ static QString gtkSetting(const gchar *propertyName) return str; } -QGtk2Theme::QGtk2Theme() +void gtkMessageHandler(const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data) { + /* Silence false-positive Gtk warnings (we are using Xlib to set + * the WM_TRANSIENT_FOR hint). + */ + if (g_strcmp0(message, "GtkDialog mapped without a transient parent. " + "This is discouraged.") != 0) { + /* For other messages, call the default handler. */ + g_log_default_handler(log_domain, log_level, message, unused_data); + } +} + +QGtk3Theme::QGtk3Theme() { // gtk_init will reset the Xlib error handler, and that causes // Qt applications to quit on X errors. Therefore, we need to manually restore it. @@ -63,9 +77,18 @@ QGtk2Theme::QGtk2Theme() gtk_init(0, 0); XSetErrorHandler(oldErrorHandler); + + /* Initialize some types here so that Gtk+ does not crash when reading + * the treemodel for GtkFontChooser. + */ + g_type_ensure(PANGO_TYPE_FONT_FAMILY); + g_type_ensure(PANGO_TYPE_FONT_FACE); + + /* Use our custom log handler. */ + g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, NULL); } -QVariant QGtk2Theme::themeHint(QPlatformTheme::ThemeHint hint) const +QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const { switch (hint) { case QPlatformTheme::SystemIconThemeName: @@ -77,7 +100,7 @@ QVariant QGtk2Theme::themeHint(QPlatformTheme::ThemeHint hint) const } } -QString QGtk2Theme::gtkFontName() const +QString QGtk3Theme::gtkFontName() const { QString cfgFontName = gtkSetting("gtk-font-name"); if (!cfgFontName.isEmpty()) @@ -85,7 +108,7 @@ QString QGtk2Theme::gtkFontName() const return QGnomeTheme::gtkFontName(); } -bool QGtk2Theme::usePlatformNativeDialog(DialogType type) const +bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const { switch (type) { case ColorDialog: @@ -99,15 +122,15 @@ bool QGtk2Theme::usePlatformNativeDialog(DialogType type) const } } -QPlatformDialogHelper *QGtk2Theme::createPlatformDialogHelper(DialogType type) const +QPlatformDialogHelper *QGtk3Theme::createPlatformDialogHelper(DialogType type) const { switch (type) { case ColorDialog: - return new QGtk2ColorDialogHelper; + return new QGtk3ColorDialogHelper; case FileDialog: - return new QGtk2FileDialogHelper; + return new QGtk3FileDialogHelper; case FontDialog: - return new QGtk2FontDialogHelper; + return new QGtk3FontDialogHelper; default: return 0; } diff --git a/src/plugins/platformthemes/gtk2/qgtk2theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h index 8798fed1f7..1597f6e911 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2theme.h +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h @@ -31,17 +31,17 @@ ** ****************************************************************************/ -#ifndef QGTK2THEME_H -#define QGTK2THEME_H +#ifndef QGTK3THEME_H +#define QGTK3THEME_H #include <private/qgenericunixthemes_p.h> QT_BEGIN_NAMESPACE -class QGtk2Theme : public QGnomeTheme +class QGtk3Theme : public QGnomeTheme { public: - QGtk2Theme(); + QGtk3Theme(); virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; virtual QString gtkFontName() const Q_DECL_OVERRIDE; @@ -54,4 +54,4 @@ public: QT_END_NAMESPACE -#endif // QGTK2THEME_H +#endif // QGTK3THEME_H diff --git a/src/plugins/platformthemes/platformthemes.pro b/src/plugins/platformthemes/platformthemes.pro index 23dcda2c82..f5f54068a2 100644 --- a/src/plugins/platformthemes/platformthemes.pro +++ b/src/plugins/platformthemes/platformthemes.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -contains(QT_CONFIG, gtk2): SUBDIRS += gtk2 +contains(QT_CONFIG, gtk3): SUBDIRS += gtk3 diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 03b7dc266b..55660ce31c 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -8,7 +8,6 @@ qtHaveModule(gui) { !contains(QT_DISABLED_FEATURES, imageformatplugin): SUBDIRS *= imageformats !contains(QT_DISABLED_FEATURES, library): SUBDIRS *= generic } -qtHaveModule(widgets): SUBDIRS *= styles !winrt:!wince*:qtHaveModule(widgets):!contains(QT_DISABLED_FEATURES, printer) { SUBDIRS += printsupport diff --git a/src/plugins/printsupport/cocoa/cocoa.pro b/src/plugins/printsupport/cocoa/cocoa.pro index a3b9e2dfcf..c993b42574 100644 --- a/src/plugins/printsupport/cocoa/cocoa.pro +++ b/src/plugins/printsupport/cocoa/cocoa.pro @@ -5,7 +5,7 @@ PLUGIN_CLASS_NAME = QCocoaPrinterSupportPlugin load(qt_plugin) QT += gui-private printsupport-private -LIBS += -framework Cocoa +LIBS += -framework AppKit SOURCES += main.cpp diff --git a/src/plugins/styles/bb10style/bb10lightstyle.qrc b/src/plugins/styles/bb10style/bb10lightstyle.qrc deleted file mode 100644 index 0777e009bb..0000000000 --- a/src/plugins/styles/bb10style/bb10lightstyle.qrc +++ /dev/null @@ -1,54 +0,0 @@ -<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 deleted file mode 100644 index ad35df6de7..0000000000 --- a/src/plugins/styles/bb10style/bb10style.pro +++ /dev/null @@ -1,28 +0,0 @@ -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 differdeleted file mode 100644 index 578a2383b8..0000000000 --- a/src/plugins/styles/bb10style/bright/button/core_button_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 7cd998af46..0000000000 --- a/src/plugins/styles/bb10style/bright/button/core_button_disabled_selected.png +++ /dev/null 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 differdeleted file mode 100644 index ff0850f616..0000000000 --- a/src/plugins/styles/bb10style/bright/button/core_button_enabled_selected.png +++ /dev/null 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 differdeleted file mode 100644 index 7769f15e44..0000000000 --- a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png +++ /dev/null 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 differdeleted file mode 100644 index 59b5bfa7c2..0000000000 --- a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index c59f60633c..0000000000 --- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_checked.png +++ /dev/null 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 differdeleted file mode 100644 index 49d9cfdf94..0000000000 --- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 35751553e1..0000000000 --- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_disabled_checked.png +++ /dev/null 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 differdeleted file mode 100644 index 2a0c56b503..0000000000 --- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_enabled.png +++ /dev/null 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 differdeleted file mode 100644 index f1c2ee3bed..0000000000 --- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index d58df47cbf..0000000000 --- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed_checked.png +++ /dev/null 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 differdeleted file mode 100644 index 1aa844309f..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button.png +++ /dev/null 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 differdeleted file mode 100644 index 9ac049fb3d..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown.png +++ /dev/null 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 differdeleted file mode 100644 index d11af56b71..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowdown_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index d10779d8d7..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_arrowup.png +++ /dev/null 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 differdeleted file mode 100644 index f9e1c9465b..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 27a321e387..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_button_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index a8270aed56..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_checkmark.png +++ /dev/null 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 differdeleted file mode 100644 index 0198293ad6..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_divider.png +++ /dev/null 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 differdeleted file mode 100644 index 47e7b2d4b6..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menu.png +++ /dev/null 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 differdeleted file mode 100644 index 2bde84e71d..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_dropdown_menuup.png +++ /dev/null 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 differdeleted file mode 100644 index 4935d13c05..0000000000 --- a/src/plugins/styles/bb10style/bright/combobox/core_listitem_active.png +++ /dev/null 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 differdeleted file mode 100644 index 07b8ea21bf..0000000000 --- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png +++ /dev/null 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 differdeleted file mode 100644 index ab1083e9fa..0000000000 --- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 55f8aee066..0000000000 --- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png +++ /dev/null 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 differdeleted file mode 100644 index 34daccc27e..0000000000 --- a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png +++ /dev/null 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 differdeleted file mode 100644 index 7a1e22321d..0000000000 --- a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png +++ /dev/null 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 differdeleted file mode 100644 index 3ff930dea7..0000000000 --- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png +++ /dev/null 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 differdeleted file mode 100644 index 87974668ff..0000000000 --- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_complete.png +++ /dev/null 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 differdeleted file mode 100644 index 8ff257dad3..0000000000 --- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_fill.png +++ /dev/null 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 differdeleted file mode 100644 index 66cf8cac8f..0000000000 --- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vbg.png +++ /dev/null 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 differdeleted file mode 100644 index f18e0abafb..0000000000 --- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vcomplete.png +++ /dev/null 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 differdeleted file mode 100644 index 94e388a7aa..0000000000 --- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_vfill.png +++ /dev/null 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 differdeleted file mode 100644 index 5dc5e52d88..0000000000 --- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_checked.png +++ /dev/null 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 differdeleted file mode 100644 index 077aa79c65..0000000000 --- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 439499040a..0000000000 --- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_disabled_checked.png +++ /dev/null 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 differdeleted file mode 100644 index cb4c6a8136..0000000000 --- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png +++ /dev/null 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 differdeleted file mode 100644 index 88fd1344d2..0000000000 --- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png +++ /dev/null diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png Binary files differdeleted file mode 100644 index 79154e0568..0000000000 --- a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png +++ /dev/null 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 differdeleted file mode 100644 index 169a4e1656..0000000000 --- a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar_v.png +++ /dev/null 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 differdeleted file mode 100644 index c23c0ebc26..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_active.png +++ /dev/null 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 differdeleted file mode 100644 index 6b7224d702..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_cache.png +++ /dev/null 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 differdeleted file mode 100644 index 9de7567e68..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index ad5c35076c..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_enabled.png +++ /dev/null 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 differdeleted file mode 100644 index 076e272794..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_handle.png +++ /dev/null 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 differdeleted file mode 100644 index 5989fcaaeb..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 8cb79118b9..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index 8836534923..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_inactive.png +++ /dev/null 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 differdeleted file mode 100644 index 03062326f2..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_vactive.png +++ /dev/null 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 differdeleted file mode 100644 index b0d94d7127..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_vcache.png +++ /dev/null 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 differdeleted file mode 100644 index ce99b1a3ac..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_vdisabled.png +++ /dev/null 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 differdeleted file mode 100644 index 910b6627d4..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_venabled.png +++ /dev/null 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 differdeleted file mode 100644 index 18a9819af8..0000000000 --- a/src/plugins/styles/bb10style/bright/slider/core_slider_vinactive.png +++ /dev/null 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 differdeleted file mode 100644 index 79245dbf11..0000000000 --- a/src/plugins/styles/bb10style/dark/button/core_button_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 5eb86b70f3..0000000000 --- a/src/plugins/styles/bb10style/dark/button/core_button_disabled_selected.png +++ /dev/null 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 differdeleted file mode 100644 index 7b1a6ce40b..0000000000 --- a/src/plugins/styles/bb10style/dark/button/core_button_enabled_selected.png +++ /dev/null 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 differdeleted file mode 100644 index 97842e1ac4..0000000000 --- a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png +++ /dev/null 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 differdeleted file mode 100644 index c149b64a26..0000000000 --- a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index 5a8af33094..0000000000 --- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_checked.png +++ /dev/null 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 differdeleted file mode 100644 index 74a24522fa..0000000000 --- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 1e953221b6..0000000000 --- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_disabled_checked.png +++ /dev/null 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 differdeleted file mode 100644 index 5e51e7f39b..0000000000 --- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_enabled.png +++ /dev/null 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 differdeleted file mode 100644 index 507a77b3ea..0000000000 --- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index 7fa85428a0..0000000000 --- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed_checked.png +++ /dev/null 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 differdeleted file mode 100644 index a68d93acb5..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button.png +++ /dev/null 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 differdeleted file mode 100644 index 4c1d085360..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown.png +++ /dev/null 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 differdeleted file mode 100644 index 1ee578e07c..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowdown_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index 3239ef4bd6..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_arrowup.png +++ /dev/null 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 differdeleted file mode 100644 index af6793b87c..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index df6d402554..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_button_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index 578c80aa5f..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_checkmark.png +++ /dev/null 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 differdeleted file mode 100644 index 43b1025d36..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_divider.png +++ /dev/null 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 differdeleted file mode 100644 index 1f52362050..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menu.png +++ /dev/null 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 differdeleted file mode 100644 index 62c7a2e558..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_dropdown_menuup.png +++ /dev/null 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 differdeleted file mode 100644 index 1df4a7aad9..0000000000 --- a/src/plugins/styles/bb10style/dark/combobox/core_listitem_active.png +++ /dev/null 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 differdeleted file mode 100644 index 07b8ea21bf..0000000000 --- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png +++ /dev/null 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 differdeleted file mode 100644 index 6bcaf91f87..0000000000 --- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 9b115897e8..0000000000 --- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png +++ /dev/null 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 differdeleted file mode 100644 index 52aa4e4aa2..0000000000 --- a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png +++ /dev/null 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 differdeleted file mode 100644 index 39e3a8a4f5..0000000000 --- a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png +++ /dev/null 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 differdeleted file mode 100644 index 95fcafb437..0000000000 --- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png +++ /dev/null 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 differdeleted file mode 100644 index e849c8f179..0000000000 --- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_complete.png +++ /dev/null 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 differdeleted file mode 100644 index e8fd3b0173..0000000000 --- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_fill.png +++ /dev/null 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 differdeleted file mode 100644 index 1433f3ec33..0000000000 --- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vbg.png +++ /dev/null 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 differdeleted file mode 100644 index d750e4671c..0000000000 --- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vcomplete.png +++ /dev/null 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 differdeleted file mode 100644 index 2c3c0a5e6c..0000000000 --- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_vfill.png +++ /dev/null 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 differdeleted file mode 100644 index 1721586ac5..0000000000 --- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_checked.png +++ /dev/null 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 differdeleted file mode 100644 index e646c9174b..0000000000 --- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 93b3118e8d..0000000000 --- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_disabled_checked.png +++ /dev/null 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 differdeleted file mode 100644 index fd61937d65..0000000000 --- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png +++ /dev/null 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 differdeleted file mode 100644 index 58a1a57b4c..0000000000 --- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png +++ /dev/null diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png Binary files differdeleted file mode 100644 index 384f60758a..0000000000 --- a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png +++ /dev/null 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 differdeleted file mode 100644 index 2542f2acaf..0000000000 --- a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar_v.png +++ /dev/null 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 differdeleted file mode 100644 index 6bdb413ced..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_active.png +++ /dev/null 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 differdeleted file mode 100644 index eea5b3d78e..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_cache.png +++ /dev/null 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 differdeleted file mode 100644 index 6a233315e4..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 2b297e5ca2..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_enabled.png +++ /dev/null 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 differdeleted file mode 100644 index fbd37e5584..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_handle.png +++ /dev/null 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 differdeleted file mode 100644 index 49cb6a42a7..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_disabled.png +++ /dev/null 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 differdeleted file mode 100644 index 803c374015..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png +++ /dev/null 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 differdeleted file mode 100644 index 08a1aecb6c..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_inactive.png +++ /dev/null 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 differdeleted file mode 100644 index c8e467d9e6..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_vactive.png +++ /dev/null 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 differdeleted file mode 100644 index ff160cbb1d..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_vcache.png +++ /dev/null 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 differdeleted file mode 100644 index 27d348122b..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_vdisabled.png +++ /dev/null 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 differdeleted file mode 100644 index ff8a74a19f..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_venabled.png +++ /dev/null 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 differdeleted file mode 100644 index b2b19a5460..0000000000 --- a/src/plugins/styles/bb10style/dark/slider/core_slider_vinactive.png +++ /dev/null diff --git a/src/plugins/styles/bb10style/qbb10brightstyle.cpp b/src/plugins/styles/bb10style/qbb10brightstyle.cpp deleted file mode 100644 index 9f14e3b134..0000000000 --- a/src/plugins/styles/bb10style/qbb10brightstyle.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbb10brightstyle.h" - -#include <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 deleted file mode 100644 index 5b88b0ef95..0000000000 --- a/src/plugins/styles/bb10style/qbb10brightstyle.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBB10BRIGHTSTYLE_H -#define QBB10BRIGHTSTYLE_H - -#include "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 deleted file mode 100644 index 2172536fa3..0000000000 --- a/src/plugins/styles/bb10style/qbb10brightstyle.qrc +++ /dev/null @@ -1,57 +0,0 @@ -<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 deleted file mode 100644 index be2697510e..0000000000 --- a/src/plugins/styles/bb10style/qbb10darkstyle.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbb10darkstyle.h" - -#include <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 deleted file mode 100644 index 65ba7cd283..0000000000 --- a/src/plugins/styles/bb10style/qbb10darkstyle.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBB10DARKSTYLE_H -#define QBB10DARKSTYLE_H - -#include "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 deleted file mode 100644 index 31a5236207..0000000000 --- a/src/plugins/styles/bb10style/qbb10darkstyle.qrc +++ /dev/null @@ -1,57 +0,0 @@ -<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 deleted file mode 100644 index 98607f174a..0000000000 --- a/src/plugins/styles/bb10style/qbb10styleplugin.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qbb10styleplugin.h" -#include "qbb10darkstyle.h" -#include "qbb10brightstyle.h" - -QT_BEGIN_NAMESPACE - -QBB10StylePlugin::QBB10StylePlugin() -{ -} - -QBB10StylePlugin::~QBB10StylePlugin() -{ -} - -QStyle *QBB10StylePlugin::create(const QString &key) -{ - const QString keyLower(key.toLower()); - if (keyLower == QLatin1String("bb10bright")) - return new QBB10BrightStyle; - else if (keyLower == QLatin1String("bb10dark")) - return new QBB10DarkStyle; - - return 0; -} - -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 deleted file mode 100644 index 8058e4859e..0000000000 --- a/src/plugins/styles/bb10style/qbb10styleplugin.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBB10STYLEPLUGIN_H -#define QBB10STYLEPLUGIN_H - -#include <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 deleted file mode 100644 index 8f79b706c3..0000000000 --- a/src/plugins/styles/bb10style/qbb10styleplugin.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "bb10bright", "bb10dark" ] -} diff --git a/src/plugins/styles/bb10style/qpixmapstyle.cpp b/src/plugins/styles/bb10style/qpixmapstyle.cpp deleted file mode 100644 index 3090c42959..0000000000 --- a/src/plugins/styles/bb10style/qpixmapstyle.cpp +++ /dev/null @@ -1,977 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "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_DEAD_CODE_FROM_QT4_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_DEAD_CODE_FROM_QT4_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 QStyleOptionProgressBar *pb = - qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { - vertical = pb->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)) { - const bool vertical = pb->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); - const bool vertical = pbar->orientation == Qt::Vertical; - const bool flip = (pbar->direction == Qt::RightToLeft) ^ pbar->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 QStyleOptionProgressBar *pb = - qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { - vertical = pb->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 deleted file mode 100644 index 3f35e79f23..0000000000 --- a/src/plugins/styles/bb10style/qpixmapstyle.h +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef 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 deleted file mode 100644 index 88b3f90e0c..0000000000 --- a/src/plugins/styles/styles.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs - -blackberry:SUBDIRS += bb10style |