diff options
Diffstat (limited to 'src/plugins')
67 files changed, 481 insertions, 311 deletions
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/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 4e901ba015..f83d15f48e 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -334,6 +334,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; @@ -345,6 +346,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..61ececc93a 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" @@ -485,42 +487,6 @@ void qt_mac_transformProccessToForegroundApplication() } } } - -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; - } - returnText.truncate(finalDest); - return returnText; -} - static CGColorSpaceRef m_genericColorSpace = 0; static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash; static bool m_postRoutineRegistered = false; @@ -774,7 +740,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 7775cdbde6..af5905f846 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 0fc1bff325..76406539c3 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..42ddce6e23 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" 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 a545dbddd5..4c6b1bac9f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -47,7 +47,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformscreen.h> -#include <Cocoa/Cocoa.h> +#include <AppKit/AppKit.h> #include <Carbon/Carbon.h> #include <QDebug> @@ -685,7 +685,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 +1350,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 bad67f2516..e754855e7f 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/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..c59e0941b2 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 @@ -103,8 +103,6 @@ public: } }; -QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp - class Q_WIDGETS_EXPORT QMacWindowChangeEvent { private: 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/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/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/platforms/ios/qiosmessagedialog.h b/src/plugins/platforms/ios/qiosmessagedialog.h new file mode 100644 index 0000000000..a9bd42324e --- /dev/null +++ b/src/plugins/platforms/ios/qiosmessagedialog.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QIOSMESSAGEDIALOG_H +#define QIOSMESSAGEDIALOG_H + +#include <QtCore/qeventloop.h> +#include <qpa/qplatformdialoghelper.h> + +QT_BEGIN_NAMESPACE + +Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertController); +Q_FORWARD_DECLARE_OBJC_CLASS(UIAlertAction); + +class QIOSMessageDialog : public QPlatformMessageDialogHelper +{ +public: + QIOSMessageDialog(); + ~QIOSMessageDialog(); + + void exec() Q_DECL_OVERRIDE; + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) Q_DECL_OVERRIDE; + void hide() Q_DECL_OVERRIDE; + +private: + QEventLoop m_eventLoop; + UIAlertController *m_alertController; + QString messageTextPlain(); + UIAlertAction *createAction(StandardButton button); +}; + +QT_END_NAMESPACE + +#endif // QIOSMESSAGEDIALOG_H + 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/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/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 870e7fec07..fcd9911a56 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -239,8 +239,6 @@ private: }; typedef QMap<Qt::DropAction, CursorEntry> ActionCursorMap; - typedef ActionCursorMap::Iterator ActionCursorMapIt; - typedef ActionCursorMap::ConstIterator ActionCursorMapConstIt; const Mode m_mode; QWindowsDrag *m_drag; @@ -318,7 +316,7 @@ void QWindowsOleDropSource::createCursors() if (cursorPixmap.isNull()) cursorPixmap = m_drag->defaultCursor(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()) { @@ -399,7 +397,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { HRESULT hr = S_OK; do { - if (fEscapePressed) { + if (fEscapePressed || QWindowsDrag::isCanceled()) { hr = ResultFromScode(DRAGDROP_S_CANCEL); break; } @@ -447,7 +445,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(); @@ -679,6 +677,8 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, \ingroup qt-lighthouse-win */ +bool QWindowsDrag::m_canceled = false; + QWindowsDrag::QWindowsDrag() : m_dropDataObject(0), m_cachedDropTargetHelper(0) { @@ -808,6 +808,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 9a5e0b17f2..b031faa884 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -87,6 +87,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; } @@ -98,6 +100,8 @@ public: QPixmap defaultCursor(Qt::DropAction action) const; 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 c8eaccd956..a30e545807 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> 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 3685197430..ca3e2527e9 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> diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 797a96cda7..81525775c6 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/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 2a53b18890..55bae05523 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/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/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 |