summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp2
-rw-r--r--src/plugins/platforms/android/androidjniaccessibility.cpp14
-rw-r--r--src/plugins/platforms/cocoa/messages.cpp2
-rw-r--r--src/plugins/platforms/cocoa/messages.h11
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm37
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm16
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm11
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.mm20
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.mm18
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm32
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm1
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.mm25
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.cpp32
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowssystemtrayicon.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp2
-rw-r--r--src/plugins/sqldrivers/oci/qsql_oci.cpp2
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp191
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql_p.h24
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm567
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac_p.h4
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac_p_p.h72
29 files changed, 599 insertions, 528 deletions
diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
index 6016d460fc..48693ccdb0 100644
--- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
@@ -222,7 +222,7 @@ bool QComposeInputContext::checkComposeTable()
int next = 1;
do {
// if we are at the end of the table, then we have nothing to do here
- if (it + next != m_composeTable.end()) {
+ if (it + next != m_composeTable.constEnd()) {
QComposeTableElement nextElem = *(it + next);
if (isDuplicate(elem, nextElem)) {
elem = nextElem;
diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
index e4d670239f..a3bc58bb89 100644
--- a/src/plugins/platforms/android/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
@@ -105,15 +105,15 @@ namespace QtAndroidAccessibility
{
QAccessibleInterface *iface = interfaceFromId(objectId);
if (iface && iface->isValid()) {
- jintArray jArray = env->NewIntArray(jsize(iface->childCount()));
- for (int i = 0; i < iface->childCount(); ++i) {
+ const int childCount = iface->childCount();
+ QVarLengthArray<jint, 8> ifaceIdArray(childCount);
+ for (int i = 0; i < childCount; ++i) {
QAccessibleInterface *child = iface->child(i);
- if (child && child->isValid()) {
- QAccessible::Id ifaceId = QAccessible::uniqueId(child);
- jint jid = ifaceId;
- env->SetIntArrayRegion(jArray, i, 1, &jid);
- }
+ if (child && child->isValid())
+ ifaceIdArray.append(QAccessible::uniqueId(child));
}
+ jintArray jArray = env->NewIntArray(jsize(ifaceIdArray.count()));
+ env->SetIntArrayRegion(jArray, 0, ifaceIdArray.count(), ifaceIdArray.data());
return jArray;
}
diff --git a/src/plugins/platforms/cocoa/messages.cpp b/src/plugins/platforms/cocoa/messages.cpp
index 85b814ce1c..8eea1e654e 100644
--- a/src/plugins/platforms/cocoa/messages.cpp
+++ b/src/plugins/platforms/cocoa/messages.cpp
@@ -75,7 +75,7 @@ QString qt_mac_applicationmenu_string(int type)
QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption)
{
QString captionNoAmpersand(caption);
- captionNoAmpersand.remove(QChar('&'));
+ captionNoAmpersand.remove(QLatin1Char('&'));
const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive))
return QPlatformMenuItem::AboutRole;
diff --git a/src/plugins/platforms/cocoa/messages.h b/src/plugins/platforms/cocoa/messages.h
index a9c9cc42e5..e41898fe59 100644
--- a/src/plugins/platforms/cocoa/messages.h
+++ b/src/plugins/platforms/cocoa/messages.h
@@ -45,6 +45,17 @@
QT_BEGIN_NAMESPACE
+enum {
+ ServicesAppMenuItem = 0,
+ HideAppMenuItem,
+ HideOthersAppMenuItem,
+ ShowAllAppMenuItem,
+ PreferencesAppMenuItem,
+ QuitAppMenuItem,
+ AboutAppMenuItem
+};
+
+
QString msgAboutQt();
QString qt_mac_applicationmenu_string(int type);
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 9fa7487623..301771fd53 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -60,8 +60,9 @@ QT_BEGIN_NAMESPACE
class QCocoaScreen;
-class QCocoaIntegration : public QPlatformIntegration
+class QCocoaIntegration : public QObject, public QPlatformIntegration
{
+ Q_OBJECT
public:
enum Option {
UseFreeTypeFontEngine = 0x1
@@ -120,6 +121,9 @@ public:
void beep() const override;
+private Q_SLOTS:
+ void focusWindowChanged(QWindow *);
+
private:
static QCocoaIntegration *mInstance;
Options mOptions;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index dd17848109..55b3805df3 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -179,6 +179,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
QMacInternalPasteboardMime::initializeMimeTypes();
QCocoaMimeTypes::initializeMimeTypes();
QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false);
+
+ connect(qGuiApp, &QGuiApplication::focusWindowChanged,
+ this, &QCocoaIntegration::focusWindowChanged);
}
QCocoaIntegration::~QCocoaIntegration()
@@ -222,6 +225,8 @@ QCocoaIntegration::Options QCocoaIntegration::options() const
return mOptions;
}
+Q_LOGGING_CATEGORY(lcCocoaScreen, "qt.qpa.cocoa.screens");
+
/*!
\brief Synchronizes the screen list, adds new screens, removes deleted ones
*/
@@ -261,9 +266,11 @@ void QCocoaIntegration::updateScreens()
if (screen) {
remainingScreens.remove(screen);
screen->updateGeometry();
+ qCDebug(lcCocoaScreen) << "Updated properties of" << screen;
} else {
screen = new QCocoaScreen(i);
mScreens.append(screen);
+ qCDebug(lcCocoaScreen) << "Adding" << screen;
screenAdded(screen);
}
siblings << screen;
@@ -280,6 +287,7 @@ void QCocoaIntegration::updateScreens()
mScreens.removeOne(screen);
// Prevent stale references to NSScreen during destroy
screen->m_screenIndex = -1;
+ qCDebug(lcCocoaScreen) << "Removing" << screen;
destroyScreen(screen);
}
}
@@ -505,4 +513,33 @@ void QCocoaIntegration::beep() const
NSBeep();
}
+void QCocoaIntegration::focusWindowChanged(QWindow *focusWindow)
+{
+ // Don't revert icon just because we lost focus
+ if (!focusWindow)
+ return;
+
+ static bool hasDefaultApplicationIcon = [](){
+ NSImage *genericApplicationIcon = [[NSWorkspace sharedWorkspace]
+ iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)];
+ NSImage *applicationIcon = [NSImage imageNamed:NSImageNameApplicationIcon];
+
+ NSRect rect = NSMakeRect(0, 0, 32, 32);
+ return [applicationIcon CGImageForProposedRect:&rect context:nil hints:nil]
+ == [genericApplicationIcon CGImageForProposedRect:&rect context:nil hints:nil];
+ }();
+
+ // Don't let the window icon override an explicit application icon set in the Info.plist
+ if (!hasDefaultApplicationIcon)
+ return;
+
+ // Or an explicit application icon set on QGuiApplication
+ if (!qGuiApp->windowIcon().isNull())
+ return;
+
+ setApplicationIcon(focusWindow->icon());
+}
+
+#include "moc_qcocoaintegration.cpp"
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h
index 4392de2f9b..f5fa93cbb5 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.h
+++ b/src/plugins/platforms/cocoa/qcocoamenu.h
@@ -93,6 +93,8 @@ public:
void timerEvent(QTimerEvent *e) override;
+ void syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUpdate);
+
private:
QCocoaMenuItem *itemOrNull(int index) const;
void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem);
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index eeb4c01791..a54284dbae 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -434,6 +434,11 @@ void QCocoaMenu::timerEvent(QTimerEvent *e)
void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
{
+ syncMenuItem_helper(menuItem, false /*menubarUpdate*/);
+}
+
+void QCocoaMenu::syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUpdate)
+{
QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
if (!m_menuItems.contains(cocoaItem)) {
@@ -443,8 +448,9 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
const bool wasMerged = cocoaItem->isMerged();
NSMenuItem *oldItem = cocoaItem->nsItem();
+ NSMenuItem *syncedItem = cocoaItem->sync();
- if (cocoaItem->sync() != oldItem) {
+ if (syncedItem != oldItem) {
// native item was changed for some reason
if (oldItem) {
if (wasMerged) {
@@ -462,6 +468,14 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
// when an item's enabled state changes after menuWillOpen:
scheduleUpdate();
}
+
+ // This may be a good moment to attach this item's eventual submenu to the
+ // synced item, but only on the condition we're all currently hooked to the
+ // menunbar. A good indicator of this being the right moment is knowing that
+ // we got called from QCocoaMenuBar::updateMenuBarImmediately().
+ if (menubarUpdate)
+ if (QCocoaMenu *submenu = cocoaItem->menu())
+ submenu->setAttachedItem(syncedItem);
}
void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h
index 0a46e80695..32a8fd89b4 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.h
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.h
@@ -72,6 +72,8 @@ public:
QList<QCocoaMenuItem*> merged() const;
NSMenuItem *itemForRole(QPlatformMenuItem::MenuRole r);
+ void syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate);
+
private:
static QCocoaWindow *findWindowForMenubar();
static QCocoaMenuBar *findGlobalMenubar();
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 36655dffab..fd28a4d7da 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -155,7 +155,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor
}
}
- syncMenu(menu);
+ syncMenu_helper(menu, false /*internaCall*/);
if (needsImmediateUpdate())
updateMenuBarImmediately();
@@ -183,11 +183,16 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
{
+ syncMenu_helper(menu, false /*internaCall*/);
+}
+
+void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate)
+{
QMacAutoReleasePool pool;
QCocoaMenu *cocoaMenu = static_cast<QCocoaMenu *>(menu);
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
- cocoaMenu->syncMenuItem(item);
+ cocoaMenu->syncMenuItem_helper(item, menubarUpdate);
BOOL shouldHide = YES;
if (cocoaMenu->isVisible()) {
@@ -357,7 +362,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
menu->setAttachedItem(item);
menu->setMenuParent(mb);
// force a sync?
- mb->syncMenu(menu);
+ mb->syncMenu_helper(menu, true /*menubarUpdate*/);
menu->propagateEnabledState(!disableForModal);
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index d135b244e0..eaf310ec51 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -149,10 +149,6 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu)
QMacAutoReleasePool pool;
m_menu = static_cast<QCocoaMenu *>(menu);
if (m_menu) {
- if (m_native) {
- // Skip automatic menu item validation
- m_native.action = nil;
- }
m_menu->setMenuParent(this);
m_menu->propagateEnabledState(isEnabled());
} else {
@@ -369,24 +365,20 @@ NSMenuItem *QCocoaMenuItem::sync()
return m_native;
}
-QT_BEGIN_NAMESPACE
-extern QString qt_mac_applicationmenu_string(int type);
-QT_END_NAMESPACE
-
QString QCocoaMenuItem::mergeText()
{
QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader aboutMenuItem]) {
- return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName());
+ return qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName());
} else if (m_native== [loader aboutQtMenuItem]) {
if (m_text == QString("About Qt"))
return msgAboutQt();
else
return m_text;
} else if (m_native == [loader preferencesMenuItem]) {
- return qt_mac_applicationmenu_string(4);
+ return qt_mac_applicationmenu_string(PreferencesAppMenuItem);
} else if (m_native == [loader quitMenuItem]) {
- return qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName());
+ return qt_mac_applicationmenu_string(QuitAppMenuItem).arg(qt_mac_applicationName());
} else if (m_text.contains('\t')) {
return m_text.left(m_text.indexOf('\t'));
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
index 01a3c04afb..0d9bb5009d 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
@@ -47,14 +47,8 @@
#include <QtCore/private/qcore_mac_p.h>
#include <QtCore/private/qthread_p.h>
#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qdebug.h>
#include <QtGui/private/qguiapplication_p.h>
-QT_FORWARD_DECLARE_CLASS(QCFString)
-QT_FORWARD_DECLARE_CLASS(QString)
-
@implementation QCocoaMenuLoader
+ (instancetype)sharedMenuLoader
@@ -314,13 +308,13 @@ QT_FORWARD_DECLARE_CLASS(QString)
{
#ifndef QT_NO_TRANSLATION
- [servicesItem setTitle:qt_mac_applicationmenu_string(0).toNSString()];
- [hideItem setTitle:qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()).toNSString()];
- [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(2).toNSString()];
- [showAllItem setTitle:qt_mac_applicationmenu_string(3).toNSString()];
- [preferencesItem setTitle:qt_mac_applicationmenu_string(4).toNSString()];
- [quitItem setTitle:qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()).toNSString()];
- [aboutItem setTitle:qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()).toNSString()];
+ [servicesItem setTitle:qt_mac_applicationmenu_string(ServicesAppMenuItem).toNSString()];
+ [hideItem setTitle:qt_mac_applicationmenu_string(HideAppMenuItem).arg(qt_mac_applicationName()).toNSString()];
+ [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(HideOthersAppMenuItem).toNSString()];
+ [showAllItem setTitle:qt_mac_applicationmenu_string(ShowAllAppMenuItem).toNSString()];
+ [preferencesItem setTitle:qt_mac_applicationmenu_string(PreferencesAppMenuItem).toNSString()];
+ [quitItem setTitle:qt_mac_applicationmenu_string(QuitAppMenuItem).arg(qt_mac_applicationName()).toNSString()];
+ [aboutItem setTitle:qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName()).toNSString()];
#endif
}
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h
index b44f8873e4..3d59c3de79 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.h
+++ b/src/plugins/platforms/cocoa/qcocoascreen.h
@@ -98,6 +98,10 @@ public:
QList<QPlatformScreen *> m_siblings;
};
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QCocoaScreen *screen);
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm
index 2c0d04dc3e..ed1b19cd53 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.mm
+++ b/src/plugins/platforms/cocoa/qcocoascreen.mm
@@ -288,4 +288,22 @@ QRectF QCocoaScreen::mapFromNative(CGRect rect, QCocoaScreen *screen)
return qt_mac_flip(QRectF::fromCGRect(rect), screen->geometry());
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QCocoaScreen(" << (const void *)screen;
+ if (screen) {
+ debug << ", index=" << screen->m_screenIndex;
+ debug << ", native=" << screen->nativeScreen();
+ debug << ", geometry=" << screen->geometry();
+ debug << ", dpr=" << screen->devicePixelRatio();
+ debug << ", name=" << screen->name();
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 8ac3ec228f..c3160e32c2 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -79,6 +79,8 @@ static void qt_closePopups()
}
}
+Q_LOGGING_CATEGORY(lcCocoaNotifications, "qt.qpa.cocoa.notifications");
+
static void qRegisterNotificationCallbacks()
{
static const QLatin1String notificationHandlerPrefix(Q_NOTIFICATION_PREFIX);
@@ -110,11 +112,24 @@ static void qRegisterNotificationCallbacks()
if (QNSView *qnsView = qnsview_cast(notification.object))
cocoaWindows += qnsView.platformWindow;
} else {
- qCWarning(lcQpaCocoaWindow) << "Unhandled notifcation"
+ qCWarning(lcCocoaNotifications) << "Unhandled notifcation"
<< notification.name << "for" << notification.object;
return;
}
+ if (lcCocoaNotifications().isDebugEnabled()) {
+ if (cocoaWindows.isEmpty()) {
+ qCDebug(lcCocoaNotifications) << "Could not find forwarding target for" <<
+ qPrintable(notificationName) << "from" << notification.object;
+ } else {
+ QVector<QCocoaWindow *> debugWindows;
+ for (QCocoaWindow *cocoaWindow : cocoaWindows)
+ debugWindows += cocoaWindow;
+ qCDebug(lcCocoaNotifications) << "Forwarding" << qPrintable(notificationName) <<
+ "to" << debugWindows;
+ }
+ }
+
// FIXME: Could be a foreign window, look up by iterating top level QWindows
for (QCocoaWindow *cocoaWindow : cocoaWindows) {
@@ -1427,6 +1442,21 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
applyContentBorderThickness(nsWindow);
+ // Prevent CoreGraphics RGB32 -> RGB64 backing store conversions on deep color
+ // displays by forcing 8-bit components, unless a deep color format has been
+ // requested. This conversion uses significant CPU time.
+ QSurface::SurfaceType surfaceType = QPlatformWindow::window()->surfaceType();
+ bool usesCoreGraphics = surfaceType == QSurface::RasterSurface || surfaceType == QSurface::RasterGLSurface;
+ QSurfaceFormat surfaceFormat = QPlatformWindow::window()->format();
+ bool usesDeepColor = surfaceFormat.redBufferSize() > 8 ||
+ surfaceFormat.greenBufferSize() > 8 ||
+ surfaceFormat.blueBufferSize() > 8;
+ bool usesLayer = view().layer;
+ if (usesCoreGraphics && !usesDeepColor && !usesLayer) {
+ [nsWindow setDynamicDepthLimit:NO];
+ [nsWindow setDepthLimit:NSWindowDepthTwentyfourBitRGB];
+ }
+
return nsWindow;
}
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index a0ffc11967..90a6f936e2 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1878,6 +1878,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
}
else {
NSImage *nsimage = qt_mac_create_nsimage(pixmapCursor);
+ nsimage.size = NSSizeFromCGSize((pixmapCursor.size() / pixmapCursor.devicePixelRatioF()).toCGSize());
nativeCursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSZeroPoint];
[nsimage release];
}
diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
index 799704a407..e846fa043c 100644
--- a/src/plugins/platforms/cocoa/qnswindow.mm
+++ b/src/plugins/platforms/cocoa/qnswindow.mm
@@ -46,6 +46,8 @@
#include <qpa/qwindowsysteminterface.h>
#include <qoperatingsystemversion.h>
+Q_LOGGING_CATEGORY(lcCocoaEvents, "qt.qpa.cocoa.events");
+
static bool isMouseEvent(NSEvent *ev)
{
switch ([ev type]) {
@@ -116,6 +118,22 @@ static bool isMouseEvent(NSEvent *ev)
return qnsview_cast(self.contentView).platformWindow;
}
+- (NSString *)description
+{
+ NSMutableString *description = [NSMutableString stringWithString:qt_objcDynamicSuper()];
+
+#ifndef QT_NO_DEBUG_STREAM
+ QString contentViewDescription;
+ QDebug debug(&contentViewDescription);
+ debug.nospace() << "; contentView=" << qnsview_cast(self.contentView) << ">";
+
+ NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1];
+ [description replaceCharactersInRange:lastCharacter withString:contentViewDescription.toNSString()];
+#endif
+
+ return description;
+}
+
- (BOOL)canBecomeKeyWindow
{
QCocoaWindow *pw = self.platformWindow;
@@ -177,6 +195,8 @@ static bool isMouseEvent(NSEvent *ev)
- (void)sendEvent:(NSEvent*)theEvent
{
+ qCDebug(lcCocoaEvents) << "Sending" << theEvent << "to" << self;
+
// We might get events for a NSWindow after the corresponding platform
// window has been deleted, as the NSWindow can outlive the QCocoaWindow
// e.g. if being retained by other parts of AppKit, or in an auto-release
@@ -185,6 +205,10 @@ static bool isMouseEvent(NSEvent *ev)
if (!self.platformWindow)
return;
+ // Prevent deallocation of this NSWindow during event delivery, as we
+ // have logic further below that depends on the window being alive.
+ [[self retain] autorelease];
+
const char *eventType = object_getClassName(theEvent);
if (QWindowSystemInterface::handleNativeEvent(self.platformWindow->window(),
QByteArray::fromRawData(eventType, qstrlen(eventType)), theEvent, nullptr)) {
@@ -221,6 +245,7 @@ static bool isMouseEvent(NSEvent *ev)
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
- (void)dealloc
{
+ qCDebug(lcQpaCocoaWindow) << "dealloc" << self;
qt_objcDynamicSuper();
}
#pragma clang diagnostic pop
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
index 3eb8675d77..75bb786b28 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
@@ -61,6 +61,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatforminputcontextfactory_p.h>
#include <qpa/qplatforminputcontext.h>
+#include <qpa/qplatformtheme.h>
#include <qpa/qplatformservices.h>
@@ -167,6 +168,37 @@ QAbstractEventDispatcher *QOffscreenIntegration::createEventDispatcher() const
#endif
}
+static QString themeName() { return QStringLiteral("offscreen"); }
+
+QStringList QOffscreenIntegration::themeNames() const
+{
+ return QStringList(themeName());
+}
+
+// Restrict the styles to "fusion" to prevent native styles requiring native
+// window handles (eg Windows Vista style) from being used.
+class OffscreenTheme : public QPlatformTheme
+{
+public:
+ OffscreenTheme() {}
+
+ QVariant themeHint(ThemeHint h) const override
+ {
+ switch (h) {
+ case StyleNames:
+ return QVariant(QStringList(QStringLiteral("fusion")));
+ default:
+ break;
+ }
+ return QPlatformTheme::themeHint(h);
+ }
+};
+
+QPlatformTheme *QOffscreenIntegration::createPlatformTheme(const QString &name) const
+{
+ return name == themeName() ? new OffscreenTheme() : nullptr;
+}
+
QPlatformFontDatabase *QOffscreenIntegration::fontDatabase() const
{
return m_fontDatabase.data();
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h
index 4c7df207eb..c84c1f7c50 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.h
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h
@@ -69,6 +69,9 @@ public:
QPlatformFontDatabase *fontDatabase() const override;
QAbstractEventDispatcher *createEventDispatcher() const override;
+ QStringList themeNames() const;
+ QPlatformTheme *createPlatformTheme(const QString &name) const;
+
static QOffscreenIntegration *createOffscreenIntegration();
private:
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index cf83525c6c..1efb01d52e 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -992,7 +992,9 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode,
break;
case QFileDialogOptions::Directory:
case QFileDialogOptions::DirectoryOnly:
- flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST;
+ // QTBUG-63645: Restrict to file system items, as Qt cannot deal with
+ // places like 'Network', etc.
+ flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM;
break;
case QFileDialogOptions::ExistingFiles:
flags |= FOS_FILEMUSTEXIST | FOS_ALLOWMULTISELECT;
@@ -1201,6 +1203,8 @@ void QWindowsNativeFileDialogBase::onSelectionChange()
{
const QList<QUrl> current = selectedFiles();
m_data.setSelectedFiles(current);
+ qDebug() << __FUNCTION__ << current << current.size();
+
if (current.size() == 1)
emit currentChanged(current.front());
}
@@ -1397,7 +1401,7 @@ QList<QUrl> QWindowsNativeOpenFileDialog::dialogResult() const
for (IShellItem *item : QWindowsShellItem::itemsFromItemArray(items)) {
QWindowsShellItem qItem(item);
const QString path = qItem.path();
- if (path.isEmpty()) {
+ if (path.isEmpty() && !qItem.isDir()) {
const QString temporaryCopy = createTemporaryItemCopy(qItem);
if (temporaryCopy.isEmpty())
qWarning() << "Unable to create a local copy of" << qItem;
diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
index 3ee591de8c..901d132ea5 100644
--- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
+++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
@@ -354,7 +354,7 @@ HICON QWindowsSystemTrayIcon::createIcon(const QIcon &icon)
m_hIcon = nullptr;
if (icon.isNull())
return oldIcon;
- const QSize requestedSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
+ const QSize requestedSize = QSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
const QSize size = icon.actualSize(requestedSize);
const QPixmap pm = icon.pixmap(size);
if (!pm.isNull())
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 24eab2c662..33815eeb54 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -74,6 +74,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/QDebug>
+#include <QtCore/QLibraryInfo>
#include <dwmapi.h>
@@ -1579,7 +1580,7 @@ void QWindowsWindow::setGeometry(const QRect &rectIn)
setFlag(WithinSetGeometry);
setGeometry_sys(rect);
clearFlag(WithinSetGeometry);
- if (m_data.geometry != rect) {
+ if (m_data.geometry != rect && (isVisible() || QLibraryInfo::isDebugBuild())) {
qWarning("%s: Unable to set geometry %dx%d+%d+%d on %s/'%s'."
" Resulting geometry: %dx%d+%d+%d "
"(frame: %d, %d, %d, %d, custom margin: %d, %d, %d, %d"
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index d97c532b67..e60b5213ff 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -249,7 +249,7 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
isTablet = true;
tabletData.pointerType = QTabletEvent::Eraser;
dbgType = QLatin1String("eraser");
- } else if (name.contains("cursor")) {
+ } else if (name.contains("cursor") && !(name.contains("cursor controls") && name.contains("trackball"))) {
isTablet = true;
tabletData.pointerType = QTabletEvent::Cursor;
dbgType = QLatin1String("cursor");
diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp
index 5800b84fc6..2d16c3d60c 100644
--- a/src/plugins/sqldrivers/oci/qsql_oci.cpp
+++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp
@@ -2640,7 +2640,7 @@ QSqlIndex QOCIDriver::primaryIndex(const QString& tablename) const
QString stmt(QLatin1String("select b.column_name, b.index_name, a.table_name, a.owner "
"from all_constraints a, all_ind_columns b "
"where a.constraint_type='P' "
- "and b.index_name = a.constraint_name "
+ "and b.index_name = a.index_name "
"and b.index_owner = a.owner"));
bool buildIndex = false;
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 7699bede27..1dce2f28c1 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -181,13 +181,14 @@ public:
QPSQLDriver::Protocol getPSQLVersion();
bool setEncodingUtf8();
void setDatestyle();
+ void setByteaOutput();
void detectBackslashEscape();
};
void QPSQLDriverPrivate::appendTables(QStringList &tl, QSqlQuery &t, QChar type)
{
QString query;
- if (pro >= QPSQLDriver::Version73) {
+ if (pro >= QPSQLDriver::Version7_3) {
query = QString::fromLatin1("select pg_class.relname, pg_namespace.nspname from pg_class "
"left join pg_namespace on (pg_class.relnamespace = pg_namespace.oid) "
"where (pg_class.relkind = '%1') and (pg_class.relname !~ '^Inv') "
@@ -525,7 +526,7 @@ int QPSQLResult::numRowsAffected()
QVariant QPSQLResult::lastInsertId() const
{
Q_D(const QPSQLResult);
- if (d->drv_d_func()->pro >= QPSQLDriver::Version81) {
+ if (d->drv_d_func()->pro >= QPSQLDriver::Version8_1) {
QSqlQuery qry(driver()->createResult());
// Most recent sequence value obtained from nextval
if (qry.exec(QLatin1String("SELECT lastval();")) && qry.next())
@@ -698,11 +699,25 @@ void QPSQLDriverPrivate::setDatestyle()
PQclear(result);
}
+void QPSQLDriverPrivate::setByteaOutput()
+{
+ if (pro >= QPSQLDriver::Version9) {
+ // Server version before QPSQLDriver::Version9 only supports escape mode for bytea type,
+ // but bytea format is set to hex by default in PSQL 9 and above. So need to force the
+ // server to use the old escape mode when connects to the new server.
+ PGresult *result = exec("SET bytea_output TO escape");
+ int status = PQresultStatus(result);
+ if (status != PGRES_COMMAND_OK)
+ qWarning("%s", PQerrorMessage(connection));
+ PQclear(result);
+ }
+}
+
void QPSQLDriverPrivate::detectBackslashEscape()
{
// standard_conforming_strings option introduced in 8.2
// http://www.postgresql.org/docs/8.2/static/runtime-config-compatible.html
- if (pro < QPSQLDriver::Version82) {
+ if (pro < QPSQLDriver::Version8_2) {
hasBackslashEscape = true;
} else {
hasBackslashEscape = false;
@@ -724,11 +739,11 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin)
{
switch (vMin) {
case 1:
- return QPSQLDriver::Version71;
+ return QPSQLDriver::Version7_1;
case 3:
- return QPSQLDriver::Version73;
+ return QPSQLDriver::Version7_3;
case 4:
- return QPSQLDriver::Version74;
+ return QPSQLDriver::Version7_4;
default:
return QPSQLDriver::Version7;
}
@@ -738,76 +753,102 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin)
{
switch (vMin) {
case 1:
- return QPSQLDriver::Version81;
+ return QPSQLDriver::Version8_1;
case 2:
- return QPSQLDriver::Version82;
+ return QPSQLDriver::Version8_2;
case 3:
- return QPSQLDriver::Version83;
+ return QPSQLDriver::Version8_3;
case 4:
- return QPSQLDriver::Version84;
+ return QPSQLDriver::Version8_4;
default:
return QPSQLDriver::Version8;
}
break;
}
case 9:
- return QPSQLDriver::Version9;
+ {
+ switch (vMin) {
+ case 1:
+ return QPSQLDriver::Version9_1;
+ case 2:
+ return QPSQLDriver::Version9_2;
+ case 3:
+ return QPSQLDriver::Version9_3;
+ case 4:
+ return QPSQLDriver::Version9_4;
+ case 5:
+ return QPSQLDriver::Version9_5;
+ case 6:
+ return QPSQLDriver::Version9_6;
+ default:
+ return QPSQLDriver::Version9;
+ }
break;
+ }
+ case 10:
+ return QPSQLDriver::Version10;
default:
+ if (vMaj > 10)
+ return QPSQLDriver::UnknownLaterVersion;
break;
}
return QPSQLDriver::VersionUnknown;
}
+static QPSQLDriver::Protocol qFindPSQLVersion(const QString &versionString)
+{
+ const QRegExp rx(QStringLiteral("(\\d+)(?:\\.(\\d+))?"));
+ if (rx.indexIn(versionString) != -1) {
+ // Beginning with PostgreSQL version 10, a major release is indicated by
+ // increasing the first part of the version, e.g. 10 to 11.
+ // Before version 10, a major release was indicated by increasing either
+ // the first or second part of the version number, e.g. 9.5 to 9.6.
+ int vMaj = rx.cap(1).toInt();
+ int vMin;
+ if (vMaj >= 10) {
+ vMin = 0;
+ } else {
+ if (rx.cap(2).isEmpty())
+ return QPSQLDriver::VersionUnknown;
+ vMin = rx.cap(2).toInt();
+ }
+ return qMakePSQLVersion(vMaj, vMin);
+ }
+
+ return QPSQLDriver::VersionUnknown;
+}
+
QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion()
{
QPSQLDriver::Protocol serverVersion = QPSQLDriver::Version6;
PGresult* result = exec("select version()");
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
- QString val = QString::fromLatin1(PQgetvalue(result, 0, 0));
-
- QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)"));
- rx.setMinimal(true); // enforce non-greedy RegExp
+ serverVersion = qFindPSQLVersion(
+ QString::fromLatin1(PQgetvalue(result, 0, 0)));
+ }
+ PQclear(result);
- if (rx.indexIn(val) != -1) {
- int vMaj = rx.cap(1).toInt();
- int vMin = rx.cap(2).toInt();
- serverVersion = qMakePSQLVersion(vMaj, vMin);
+ QPSQLDriver::Protocol clientVersion =
#if defined(PG_MAJORVERSION)
- if (rx.indexIn(QLatin1String(PG_MAJORVERSION)) != -1)
+ qFindPSQLVersion(QLatin1String(PG_MAJORVERSION));
#elif defined(PG_VERSION)
- if (rx.indexIn(QLatin1String(PG_VERSION)) != -1)
+ qFindPSQLVersion(QLatin1String(PG_VERSION));
#else
- if (0)
+ QPSQLDriver::VersionUnknown;
#endif
- {
- vMaj = rx.cap(1).toInt();
- vMin = rx.cap(2).toInt();
- QPSQLDriver::Protocol clientVersion = qMakePSQLVersion(vMaj, vMin);
-
- if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) {
- //Client version before QPSQLDriver::Version9 only supports escape mode for bytea type,
- //but bytea format is set to hex by default in PSQL 9 and above. So need to force the
- //server use the old escape mode when connects to the new server with old client library.
- PQclear(result);
- result = exec("SET bytea_output=escape; ");
- status = PQresultStatus(result);
- } else if (serverVersion == QPSQLDriver::VersionUnknown) {
- serverVersion = clientVersion;
- if (serverVersion != QPSQLDriver::VersionUnknown)
- qWarning("The server version of this PostgreSQL is unknown, falling back to the client version.");
- }
- }
- }
+
+ if (serverVersion == QPSQLDriver::VersionUnknown) {
+ serverVersion = clientVersion;
+ if (serverVersion != QPSQLDriver::VersionUnknown)
+ qWarning("The server version of this PostgreSQL is unknown, falling back to the client version.");
}
- PQclear(result);
- //keep the old behavior unchanged
+ // Keep the old behavior unchanged
if (serverVersion == QPSQLDriver::VersionUnknown)
serverVersion = QPSQLDriver::Version6;
- if (serverVersion < QPSQLDriver::Version71) {
+ if (serverVersion < QPSQLDriver::Version7_3) {
qWarning("This version of PostgreSQL is not supported and may not work.");
}
@@ -857,7 +898,7 @@ bool QPSQLDriver::hasFeature(DriverFeature f) const
return true;
case PreparedQueries:
case PositionalPlaceholders:
- return d->pro >= QPSQLDriver::Version82;
+ return d->pro >= QPSQLDriver::Version8_2;
case BatchOperations:
case NamedPlaceholders:
case SimpleLocking:
@@ -866,7 +907,7 @@ bool QPSQLDriver::hasFeature(DriverFeature f) const
case CancelQuery:
return false;
case BLOB:
- return d->pro >= QPSQLDriver::Version71;
+ return d->pro >= QPSQLDriver::Version7_1;
case Unicode:
return d->isUtf8;
}
@@ -929,6 +970,7 @@ bool QPSQLDriver::open(const QString & db,
d->detectBackslashEscape();
d->isUtf8 = d->setEncodingUtf8();
d->setDatestyle();
+ d->setByteaOutput();
setOpen(true);
setOpenError(false);
@@ -993,12 +1035,7 @@ bool QPSQLDriver::commitTransaction()
// This hack is used to tell if the transaction has succeeded for the protocol versions of
// PostgreSQL below. For 7.x and other protocol versions we are left in the dark.
// This hack can dissapear once there is an API to query this sort of information.
- if (d->pro == QPSQLDriver::Version8 ||
- d->pro == QPSQLDriver::Version81 ||
- d->pro == QPSQLDriver::Version82 ||
- d->pro == QPSQLDriver::Version83 ||
- d->pro == QPSQLDriver::Version84 ||
- d->pro == QPSQLDriver::Version9) {
+ if (d->pro >= QPSQLDriver::Version8) {
transaction_failed = qstrcmp(PQcmdStatus(res), "ROLLBACK") == 0;
}
@@ -1085,8 +1122,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
else
schema = std::move(schema).toLower();
- switch(d->pro) {
- case QPSQLDriver::Version6:
+ if (d->pro == QPSQLDriver::Version6) {
stmt = QLatin1String("select pg_att1.attname, int(pg_att1.atttypid), pg_cl.relname "
"from pg_attribute pg_att1, pg_attribute pg_att2, pg_class pg_cl, pg_index pg_ind "
"where pg_cl.relname = '%1_pkey' "
@@ -1095,9 +1131,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
"and pg_att1.attrelid = pg_ind.indrelid "
"and pg_att1.attnum = pg_ind.indkey[pg_att2.attnum-1] "
"order by pg_att2.attnum");
- break;
- case QPSQLDriver::Version7:
- case QPSQLDriver::Version71:
+ } else if (d->pro == QPSQLDriver::Version7 || d->pro == QPSQLDriver::Version7_1) {
stmt = QLatin1String("select pg_att1.attname, pg_att1.atttypid::int, pg_cl.relname "
"from pg_attribute pg_att1, pg_attribute pg_att2, pg_class pg_cl, pg_index pg_ind "
"where pg_cl.relname = '%1_pkey' "
@@ -1106,15 +1140,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
"and pg_att1.attrelid = pg_ind.indrelid "
"and pg_att1.attnum = pg_ind.indkey[pg_att2.attnum-1] "
"order by pg_att2.attnum");
- break;
- case QPSQLDriver::Version73:
- case QPSQLDriver::Version74:
- case QPSQLDriver::Version8:
- case QPSQLDriver::Version81:
- case QPSQLDriver::Version82:
- case QPSQLDriver::Version83:
- case QPSQLDriver::Version84:
- case QPSQLDriver::Version9:
+ } else if (d->pro >= QPSQLDriver::Version7_3) {
stmt = QLatin1String("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
"pg_class.relname "
"FROM pg_attribute, pg_class "
@@ -1129,10 +1155,8 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
else
stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
"pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema));
- break;
- case QPSQLDriver::VersionUnknown:
- qFatal("PSQL version is unknown");
- break;
+ } else {
+ qFatal("QPSQLDriver::primaryIndex(tablename): unknown PSQL version, query statement not set");
}
i.exec(stmt.arg(tbl));
@@ -1166,8 +1190,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
schema = std::move(schema).toLower();
QString stmt;
- switch(d->pro) {
- case QPSQLDriver::Version6:
+ if (d->pro == QPSQLDriver::Version6) {
stmt = QLatin1String("select pg_attribute.attname, int(pg_attribute.atttypid), "
"pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
"int(pg_attribute.attrelid), pg_attribute.attnum "
@@ -1175,8 +1198,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
"where pg_class.relname = '%1' "
"and pg_attribute.attnum > 0 "
"and pg_attribute.attrelid = pg_class.oid ");
- break;
- case QPSQLDriver::Version7:
+ } else if (d->pro == QPSQLDriver::Version7) {
stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
"pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
"pg_attribute.attrelid::int, pg_attribute.attnum "
@@ -1184,8 +1206,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
"where pg_class.relname = '%1' "
"and pg_attribute.attnum > 0 "
"and pg_attribute.attrelid = pg_class.oid ");
- break;
- case QPSQLDriver::Version71:
+ } else if (d->pro == QPSQLDriver::Version7_1) {
stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
"pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
"pg_attrdef.adsrc "
@@ -1196,15 +1217,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
"and pg_attribute.attnum > 0 "
"and pg_attribute.attrelid = pg_class.oid "
"order by pg_attribute.attnum ");
- break;
- case QPSQLDriver::Version73:
- case QPSQLDriver::Version74:
- case QPSQLDriver::Version8:
- case QPSQLDriver::Version81:
- case QPSQLDriver::Version82:
- case QPSQLDriver::Version83:
- case QPSQLDriver::Version84:
- case QPSQLDriver::Version9:
+ } else if (d->pro >= QPSQLDriver::Version7_3) {
stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
"pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
"pg_attrdef.adsrc "
@@ -1222,15 +1235,13 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
else
stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
"pg_namespace where pg_namespace.nspname = '%1')").arg(schema));
- break;
- case QPSQLDriver::VersionUnknown:
- qFatal("PSQL version is unknown");
- break;
+ } else {
+ qFatal("QPSQLDriver::record(tablename): unknown PSQL version, query statement not set");
}
QSqlQuery query(createResult());
query.exec(stmt.arg(tbl));
- if (d->pro >= QPSQLDriver::Version71) {
+ if (d->pro >= QPSQLDriver::Version7_1) {
while (query.next()) {
int len = query.value(3).toInt();
int precision = query.value(4).toInt();
diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h
index 3ff38f3c48..2873a9f851 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql_p.h
+++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h
@@ -76,15 +76,23 @@ public:
VersionUnknown = -1,
Version6 = 6,
Version7 = 7,
- Version71 = 8,
- Version73 = 9,
- Version74 = 10,
+ Version7_1 = 8,
+ Version7_3 = 9,
+ Version7_4 = 10,
Version8 = 11,
- Version81 = 12,
- Version82 = 13,
- Version83 = 14,
- Version84 = 15,
- Version9 = 16
+ Version8_1 = 12,
+ Version8_2 = 13,
+ Version8_3 = 14,
+ Version8_4 = 15,
+ Version9 = 16,
+ Version9_1 = 17,
+ Version9_2 = 18,
+ Version9_3 = 19,
+ Version9_4 = 20,
+ Version9_5 = 21,
+ Version9_6 = 22,
+ Version10 = 23,
+ UnknownLaterVersion = 100000
};
explicit QPSQLDriver(QObject *parent=0);
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index b24ecee102..c6ae7c1b79 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -311,6 +311,9 @@ static const QColor tabBarCloseButtonCrossSelected(115, 115, 115);
static const int closeButtonSize = 14;
static const qreal closeButtonCornerRadius = 2.0;
+static const int headerSectionArrowHeight = 6;
+static const int headerSectionSeparatorInset = 2;
+
#if QT_CONFIG(tabbar)
static bool isVerticalTabs(const QTabBar::Shape shape) {
return (shape == QTabBar::RoundedEast
@@ -569,7 +572,6 @@ static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape)
case QTabBar::TriangularSouth:
ttd = kThemeTabSouth;
break;
- default: // Added to remove the warning, since all values are taken care of, really!
case QTabBar::RoundedNorth:
case QTabBar::TriangularNorth:
ttd = kThemeTabNorth;
@@ -622,47 +624,6 @@ static QString qt_mac_removeMnemonics(const QString &original)
return returnText;
}
-OSStatus qt_mac_shape2QRegionHelper(int inMessage, HIShapeRef, const CGRect *inRect, void *inRefcon)
-{
- QRegion *region = static_cast<QRegion *>(inRefcon);
- if (!region)
- return paramErr;
-
- switch (inMessage) {
- case kHIShapeEnumerateRect:
- *region += QRect(inRect->origin.x, inRect->origin.y,
- inRect->size.width, inRect->size.height);
- break;
- case kHIShapeEnumerateInit:
- // Assume the region is already setup correctly
- case kHIShapeEnumerateTerminate:
- default:
- break;
- }
- return noErr;
-}
-
-/*!
- \internal
- Create's a mutable shape, it's the caller's responsibility to release.
- WARNING: this function clamps the coordinates to SHRT_MIN/MAX on 10.4 and below.
-*/
-HIMutableShapeRef qt_mac_toHIMutableShape(const QRegion &region)
-{
- HIMutableShapeRef shape = HIShapeCreateMutable();
- if (region.rectCount() < 2 ) {
- QRect qtRect = region.boundingRect();
- CGRect cgRect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height());
- HIShapeUnionWithRect(shape, &cgRect);
- } else {
- for (const QRect &qtRect : region) {
- CGRect cgRect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height());
- HIShapeUnionWithRect(shape, &cgRect);
- }
- }
- return shape;
-}
-
bool qt_macWindowIsTextured(const QWidget *window)
{
if (QWindow *w = window->windowHandle())
@@ -1518,18 +1479,6 @@ void QMacStylePrivate::initHIThemePushButton(const QStyleOptionButton *btn,
}
}
-#if QT_CONFIG(pushbutton)
-bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option)
-{
- QMacStyle *macStyle = qobject_cast<QMacStyle *>(pushButton->style());
- if (!macStyle)
- return false;
- HIThemeButtonDrawInfo bdi;
- macStyle->d_func()->initHIThemePushButton(option, pushButton, kThemeStateActive, &bdi);
- return bdi.kind == kThemeBevelButton;
-}
-#endif
-
/**
Creates a HIThemeButtonDrawInfo structure that specifies the correct button
kind and other details to use for drawing the given combobox. Which button
@@ -1537,6 +1486,7 @@ bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOpti
explicit user style settings, etc.
*/
void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,
+ CocoaControl *cw,
const QWidget *widget, const ThemeDrawState &tds) const
{
bdi->version = qt_mac_hitheme_version;
@@ -1550,6 +1500,8 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
bdi->state = tds;
QStyleHelper::WidgetSizePolicy aSize = aquaSizeConstrain(combo, widget);
+ cw->first = combo->editable ? ComboBox : Button_PopupButton;
+ cw->second = aSize;
switch (aSize) {
case QStyleHelper::SizeMini:
bdi->kind = combo->editable ? ThemeButtonKind(kThemeComboBoxMini)
@@ -1579,21 +1531,29 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
// them forever). So anyway, the height threshold should be smaller
// in this case, or the style gets confused when it needs to render
// or return any subcontrol size of the poor thing.
- if (h < 9)
+ if (h < 9) {
bdi->kind = kThemeComboBoxMini;
- else if (h < 22)
+ cw->second = QStyleHelper::SizeMini;
+ } else if (h < 22) {
bdi->kind = kThemeComboBoxSmall;
- else
+ cw->second = QStyleHelper::SizeSmall;
+ } else {
bdi->kind = kThemeComboBox;
+ cw->second = QStyleHelper::SizeLarge;
+ }
} else
#endif
{
- if (h < 21)
+ if (h < 21) {
bdi->kind = kThemeComboBoxMini;
- else if (h < 26)
+ cw->second = QStyleHelper::SizeMini;
+ } else if (h < 26) {
bdi->kind = kThemeComboBoxSmall;
- else
+ cw->second = QStyleHelper::SizeSmall;
+ } else {
bdi->kind = kThemeComboBox;
+ cw->second = QStyleHelper::SizeLarge;
+ }
}
} else {
// Even if we specify that we want the kThemePopupButton, Carbon
@@ -1601,12 +1561,16 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
// do the same size check explicit to have the size of the inner
// text field be correct. Therefore, do this even if the user specifies
// the use of LargeButtons explicit.
- if (h < 21)
+ if (h < 21) {
bdi->kind = kThemePopupButtonMini;
- else if (h < 26)
+ cw->second = QStyleHelper::SizeMini;
+ } else if (h < 26) {
bdi->kind = kThemePopupButtonSmall;
- else
+ cw->second = QStyleHelper::SizeSmall;
+ } else {
bdi->kind = kThemePopupButton;
+ cw->second = QStyleHelper::SizeLarge;
+ }
}
break;
}
@@ -1616,51 +1580,54 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
Carbon draws comboboxes (and other views) outside the rect given as argument. Use this function to obtain
the corresponding inner rect for drawing the same combobox so that it stays inside the given outerBounds.
*/
-CGRect QMacStylePrivate::comboboxInnerBounds(const CGRect &outerBounds, int buttonKind)
+CGRect QMacStylePrivate::comboboxInnerBounds(const CGRect &outerBounds, const CocoaControl &cocoaWidget)
{
CGRect innerBounds = outerBounds;
// Carbon draw parts of the view outside the rect.
// So make the rect a bit smaller to compensate
// (I wish HIThemeGetButtonBackgroundBounds worked)
- switch (buttonKind){
- case kThemePopupButton:
- innerBounds.origin.x += 2;
- innerBounds.origin.y += 2;
- innerBounds.size.width -= 5;
- innerBounds.size.height -= 6;
- break;
- case kThemePopupButtonSmall:
- innerBounds.origin.x += 3;
- innerBounds.origin.y += 3;
- innerBounds.size.width -= 6;
- innerBounds.size.height -= 7;
- break;
- case kThemePopupButtonMini:
- innerBounds.origin.x += 2;
- innerBounds.origin.y += 2;
- innerBounds.size.width -= 5;
- innerBounds.size.height -= 6;
- break;
- case kThemeComboBox:
- innerBounds.origin.x += 3;
- innerBounds.origin.y += 2;
- innerBounds.size.width -= 6;
- innerBounds.size.height -= 8;
- break;
- case kThemeComboBoxSmall:
- innerBounds.origin.x += 3;
- innerBounds.origin.y += 3;
- innerBounds.size.width -= 7;
- innerBounds.size.height -= 8;
- break;
- case kThemeComboBoxMini:
- innerBounds.origin.x += 3;
- innerBounds.origin.y += 3;
- innerBounds.size.width -= 4;
- innerBounds.size.height -= 8;
- break;
- default:
- break;
+ if (cocoaWidget.first == Button_PopupButton) {
+ switch (cocoaWidget.second) {
+ case QStyleHelper::SizeSmall:
+ innerBounds.origin.x += 3;
+ innerBounds.origin.y += 3;
+ innerBounds.size.width -= 6;
+ innerBounds.size.height -= 7;
+ break;
+ case QStyleHelper::SizeMini:
+ innerBounds.origin.x += 2;
+ innerBounds.origin.y += 2;
+ innerBounds.size.width -= 5;
+ innerBounds.size.height -= 6;
+ break;
+ case QStyleHelper::SizeLarge:
+ case QStyleHelper::SizeDefault:
+ innerBounds.origin.x += 2;
+ innerBounds.origin.y += 2;
+ innerBounds.size.width -= 5;
+ innerBounds.size.height -= 6;
+ }
+ } else if (cocoaWidget.first == ComboBox) {
+ switch (cocoaWidget.second) {
+ case QStyleHelper::SizeSmall:
+ innerBounds.origin.x += 3;
+ innerBounds.origin.y += 3;
+ innerBounds.size.width -= 7;
+ innerBounds.size.height -= 8;
+ break;
+ case QStyleHelper::SizeMini:
+ innerBounds.origin.x += 3;
+ innerBounds.origin.y += 3;
+ innerBounds.size.width -= 4;
+ innerBounds.size.height -= 8;
+ break;
+ case QStyleHelper::SizeLarge:
+ case QStyleHelper::SizeDefault:
+ innerBounds.origin.x += 3;
+ innerBounds.origin.y += 2;
+ innerBounds.size.width -= 6;
+ innerBounds.size.height -= 8;
+ }
}
return innerBounds;
@@ -1704,11 +1671,11 @@ QRect QMacStylePrivate::comboboxEditBounds(const QRect &outerBounds, const HIThe
create it manually by drawing a small Carbon combo onto a pixmap (use pixmap cache), chop
it up, and copy it back onto the widget. Othervise, draw the combobox supplied by Carbon directly.
*/
-void QMacStylePrivate::drawCombobox(const CGRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p)
+void QMacStylePrivate::drawCombobox(const CGRect &outerBounds, const HIThemeButtonDrawInfo &bdi, const CocoaControl &cw, QPainter *p)
{
if (!(bdi.kind == kThemeComboBox && outerBounds.size.height > 28)){
// We have an unscaled combobox, or popup-button; use Carbon directly.
- const CGRect innerBounds = QMacStylePrivate::comboboxInnerBounds(outerBounds, bdi.kind);
+ const CGRect innerBounds = QMacStylePrivate::comboboxInnerBounds(outerBounds, cw);
HIThemeDrawButton(&innerBounds, &bdi, QMacCGContext(p), kHIThemeOrientationNormal, 0);
} else {
QPixmap buffer;
@@ -1751,69 +1718,6 @@ void QMacStylePrivate::drawCombobox(const CGRect &outerBounds, const HIThemeButt
}
}
-/**
- Carbon tableheaders don't scale (sight). So create it manually by drawing a small Carbon header
- onto a pixmap (use pixmap cache), chop it up, and copy it back onto the widget.
-*/
-void QMacStylePrivate::drawTableHeader(const CGRect &outerBounds,
- bool drawTopBorder, bool drawLeftBorder, const HIThemeButtonDrawInfo &bdi, QPainter *p)
-{
- static int headerHeight = qt_mac_aqua_get_metric(ListHeaderHeight);
-
- QPixmap buffer;
- QString key = QString(QLatin1String("$qt_tableh%1-%2-%3")).arg(int(bdi.state)).arg(int(bdi.adornment)).arg(int(bdi.value));
- if (!QPixmapCache::find(key, buffer)) {
- CGRect headerNormalRect = {{0., 0.}, {16., CGFloat(headerHeight)}};
- buffer = QPixmap(headerNormalRect.size.width, headerNormalRect.size.height);
- buffer.fill(Qt::transparent);
- QPainter buffPainter(&buffer);
- HIThemeDrawButton(&headerNormalRect, &bdi, QMacCGContext(&buffPainter), kHIThemeOrientationNormal, 0);
- buffPainter.end();
- QPixmapCache::insert(key, buffer);
- }
- const int buttonw = qRound(outerBounds.size.width);
- const int buttonh = qRound(outerBounds.size.height);
- const int framew = 1;
- const int frameh_n = 4;
- const int frameh_s = 3;
- const int transh = buffer.height() - frameh_n - frameh_s;
- int center = buttonh - frameh_s - int(transh / 2.0f) + 1; // Align bottom;
-
- int skipTopBorder = 0;
- if (!drawTopBorder)
- skipTopBorder = 1;
-
- p->translate(outerBounds.origin.x, outerBounds.origin.y);
-
- p->drawPixmap(QRect(QRect(0, -skipTopBorder, buttonw - framew , frameh_n)), buffer, QRect(framew, 0, 1, frameh_n));
- p->drawPixmap(QRect(0, buttonh - frameh_s, buttonw - framew, frameh_s), buffer, QRect(framew, buffer.height() - frameh_s, 1, frameh_s));
- // Draw upper and lower center blocks
- p->drawPixmap(QRect(0, frameh_n - skipTopBorder, buttonw - framew, center - frameh_n + skipTopBorder), buffer, QRect(framew, frameh_n, 1, 1));
- p->drawPixmap(QRect(0, center, buttonw - framew, buttonh - center - frameh_s), buffer, QRect(framew, buffer.height() - frameh_s, 1, 1));
- // Draw right center block borders
- p->drawPixmap(QRect(buttonw - framew, frameh_n - skipTopBorder, framew, center - frameh_n), buffer, QRect(buffer.width() - framew, frameh_n, framew, 1));
- p->drawPixmap(QRect(buttonw - framew, center, framew, buttonh - center - 1), buffer, QRect(buffer.width() - framew, buffer.height() - frameh_s, framew, 1));
- // Draw right corners
- p->drawPixmap(QRect(buttonw - framew, -skipTopBorder, framew, frameh_n), buffer, QRect(buffer.width() - framew, 0, framew, frameh_n));
- p->drawPixmap(QRect(buttonw - framew, buttonh - frameh_s, framew, frameh_s), buffer, QRect(buffer.width() - framew, buffer.height() - frameh_s, framew, frameh_s));
- // Draw center transition block
- p->drawPixmap(QRect(0, center - qRound(transh / 2.0f), buttonw - framew, buffer.height() - frameh_n - frameh_s), buffer, QRect(framew, frameh_n + 1, 1, transh));
- // Draw right center transition block border
- p->drawPixmap(QRect(buttonw - framew, center - qRound(transh / 2.0f), framew, buffer.height() - frameh_n - frameh_s), buffer, QRect(buffer.width() - framew, frameh_n + 1, framew, transh));
- if (drawLeftBorder){
- // Draw left center block borders
- p->drawPixmap(QRect(0, frameh_n - skipTopBorder, framew, center - frameh_n + skipTopBorder), buffer, QRect(0, frameh_n, framew, 1));
- p->drawPixmap(QRect(0, center, framew, buttonh - center - 1), buffer, QRect(0, buffer.height() - frameh_s, framew, 1));
- // Draw left corners
- p->drawPixmap(QRect(0, -skipTopBorder, framew, frameh_n), buffer, QRect(0, 0, framew, frameh_n));
- p->drawPixmap(QRect(0, buttonh - frameh_s, framew, frameh_s), buffer, QRect(0, buffer.height() - frameh_s, framew, frameh_s));
- // Draw left center transition block border
- p->drawPixmap(QRect(0, center - qRound(transh / 2.0f), framew, buffer.height() - frameh_n - frameh_s), buffer, QRect(0, frameh_n + 1, framew, transh));
- }
-
- p->translate(-outerBounds.origin.x, -outerBounds.origin.y);
-}
-
QMacStylePrivate::QMacStylePrivate()
: backingStoreNSView(nil)
{
@@ -1849,36 +1753,36 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
return tds;
}
-static QCocoaWidget cocoaWidgetFromHIThemeButtonKind(ThemeButtonKind kind)
+ QMacStylePrivate::CocoaControl QMacStylePrivate::cocoaControlFromHIThemeButtonKind(ThemeButtonKind kind)
{
- QCocoaWidget w;
+ CocoaControl w;
switch (kind) {
case kThemePopupButton:
case kThemePopupButtonSmall:
case kThemePopupButtonMini:
- w.first = QCocoaPopupButton;
+ w.first = Button_PopupButton;
break;
case kThemeComboBox:
- w.first = QCocoaComboBox;
+ w.first = ComboBox;
break;
case kThemeArrowButton:
- w.first = QCocoaDisclosureButton;
+ w.first = Button_Disclosure;
break;
case kThemeCheckBox:
case kThemeCheckBoxSmall:
case kThemeCheckBoxMini:
- w.first = QCocoaCheckBox;
+ w.first = Button_CheckBox;
break;
case kThemeRadioButton:
case kThemeRadioButtonSmall:
case kThemeRadioButtonMini:
- w.first = QCocoaRadioButton;
+ w.first = Button_RadioButton;
break;
case kThemePushButton:
case kThemePushButtonSmall:
case kThemePushButtonMini:
- w.first = QCocoaPushButton;
+ w.first = Button_PushButton;
break;
default:
break;
@@ -1914,13 +1818,13 @@ static NSButton *makeButton(NSButtonType type, NSBezelStyle style)
return b;
}
-NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
+NSView *QMacStylePrivate::cocoaControl(CocoaControl widget) const
{
NSView *bv = cocoaControls.value(widget, nil);
if (!bv) {
switch (widget.first) {
- case QCocoaBox: {
+ case Box: {
NSBox *bc = [[NSBox alloc] init];
bc.title = @"";
bc.titlePosition = NSNoTitle;
@@ -1929,48 +1833,48 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
bv = bc;
break;
}
- case QCocoaCheckBox:
+ case Button_CheckBox:
bv = makeButton(NSSwitchButton, NSRegularSquareBezelStyle);
break;
- case QCocoaDisclosureButton:
+ case Button_Disclosure:
bv = makeButton(NSOnOffButton, NSDisclosureBezelStyle);
break;
- case QCocoaPopupButton:
- case QCocoaPullDownButton: {
+ case Button_PopupButton:
+ case Button_PullDown: {
NSPopUpButton *bc = [[NSPopUpButton alloc] init];
bc.title = @"";
- if (widget.first == QCocoaPullDownButton)
+ if (widget.first == Button_PullDown)
bc.pullsDown = YES;
bv = bc;
break;
}
- case QCocoaPushButton:
+ case Button_PushButton:
bv = makeButton(NSMomentaryLightButton, NSRoundedBezelStyle);
break;
- case QCocoaRadioButton:
+ case Button_RadioButton:
bv = makeButton(NSRadioButton, NSRegularSquareBezelStyle);
break;
- case QCocoaComboBox:
+ case ComboBox:
bv = [[NSComboBox alloc] init];
break;
- case QCocoaProgressIndicator:
+ case ProgressIndicator_Determinate:
bv = [[NSProgressIndicator alloc] init];
break;
- case QCocoaIndeterminateProgressIndicator:
+ case ProgressIndicator_Indeterminate:
bv = [[QIndeterminateProgressIndicator alloc] init];
break;
- case QCocoaHorizontalScroller:
+ case Scroller_Horizontal:
bv = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)];
break;
- case QCocoaVerticalScroller:
+ case Scroller_Vertical:
// Cocoa sets the orientation from the view's frame
// at construction time, and it cannot be changed later.
bv = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)];
break;
- case QCocoaHorizontalSlider:
+ case Slider_Horizontal:
bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)];
break;
- case QCocoaVerticalSlider:
+ case Slider_Vertical:
// Cocoa sets the orientation from the view's frame
// at construction time, and it cannot be changed later.
bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)];
@@ -1991,10 +1895,10 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
default:
break;
}
- } else if (widget.first == QCocoaProgressIndicator ||
- widget.first == QCocoaIndeterminateProgressIndicator) {
+ } else if (widget.first == ProgressIndicator_Determinate ||
+ widget.first == ProgressIndicator_Indeterminate) {
auto *pi = static_cast<NSProgressIndicator *>(bv);
- pi.indeterminate = (widget.first == QCocoaIndeterminateProgressIndicator);
+ pi.indeterminate = (widget.first == ProgressIndicator_Indeterminate);
switch (widget.second) {
case QStyleHelper::SizeSmall:
pi.controlSize = NSSmallControlSize;
@@ -2013,15 +1917,15 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
return bv;
}
-NSCell *QMacStylePrivate::cocoaCell(QCocoaWidget widget) const
+NSCell *QMacStylePrivate::cocoaCell(CocoaControl widget) const
{
NSCell *cell = cocoaCells[widget];
if (!cell) {
switch (widget.first) {
- case QCocoaStepper:
+ case Stepper:
cell = [[NSStepperCell alloc] init];
break;
- case QCocoaDisclosureButton: {
+ case Button_Disclosure: {
NSButtonCell *bc = [[NSButtonCell alloc] init];
bc.buttonType = NSOnOffButton;
bc.bezelStyle = NSDisclosureBezelStyle;
@@ -2049,31 +1953,31 @@ NSCell *QMacStylePrivate::cocoaCell(QCocoaWidget widget) const
return cell;
}
-void QMacStylePrivate::drawNSViewInRect(QCocoaWidget widget, NSView *view, const QRect &qtRect, QPainter *p, bool isQWidget, QCocoaDrawRectBlock drawRectBlock) const
+void QMacStylePrivate::drawNSViewInRect(CocoaControl widget, NSView *view, const QRect &qtRect, QPainter *p, bool isQWidget, DrawRectBlock drawRectBlock) const
{
QPoint offset;
- if (widget == QCocoaWidget(QCocoaRadioButton, QStyleHelper::SizeLarge))
+ if (widget == CocoaControl(Button_RadioButton, QStyleHelper::SizeLarge))
offset.setY(2);
- else if (widget == QCocoaWidget(QCocoaRadioButton, QStyleHelper::SizeSmall))
+ else if (widget == CocoaControl(Button_RadioButton, QStyleHelper::SizeSmall))
offset = QPoint(-1, 2);
- else if (widget == QCocoaWidget(QCocoaRadioButton, QStyleHelper::SizeMini))
+ else if (widget == CocoaControl(Button_RadioButton, QStyleHelper::SizeMini))
offset.setY(2);
- else if (widget == QCocoaWidget(QCocoaPopupButton, QStyleHelper::SizeSmall)
- || widget == QCocoaWidget(QCocoaCheckBox, QStyleHelper::SizeLarge))
+ else if (widget == CocoaControl(Button_PopupButton, QStyleHelper::SizeSmall)
+ || widget == CocoaControl(Button_CheckBox, QStyleHelper::SizeLarge))
offset.setY(1);
- else if (widget == QCocoaWidget(QCocoaCheckBox, QStyleHelper::SizeSmall))
+ else if (widget == CocoaControl(Button_CheckBox, QStyleHelper::SizeSmall))
offset.setX(-1);
- else if (widget == QCocoaWidget(QCocoaCheckBox, QStyleHelper::SizeMini))
+ else if (widget == CocoaControl(Button_CheckBox, QStyleHelper::SizeMini))
offset = QPoint(7, 5);
- else if (widget == QCocoaWidget(QCocoaPopupButton, QStyleHelper::SizeMini))
+ else if (widget == CocoaControl(Button_PopupButton, QStyleHelper::SizeMini))
offset = QPoint(2, -1);
- else if (widget == QCocoaWidget(QCocoaPullDownButton, QStyleHelper::SizeLarge))
+ else if (widget == CocoaControl(Button_PullDown, QStyleHelper::SizeLarge))
offset = isQWidget ? QPoint(3, -1) : QPoint(-1, -3);
- else if (widget == QCocoaWidget(QCocoaPullDownButton, QStyleHelper::SizeSmall))
+ else if (widget == CocoaControl(Button_PullDown, QStyleHelper::SizeSmall))
offset = QPoint(2, 1);
- else if (widget == QCocoaWidget(QCocoaPullDownButton, QStyleHelper::SizeMini))
+ else if (widget == CocoaControl(Button_PullDown, QStyleHelper::SizeMini))
offset = QPoint(5, 0);
- else if (widget == QCocoaWidget(QCocoaComboBox, QStyleHelper::SizeLarge))
+ else if (widget == CocoaControl(ComboBox, QStyleHelper::SizeLarge))
offset = QPoint(3, 0);
QMacCGContext ctx(p);
@@ -2094,12 +1998,12 @@ void QMacStylePrivate::drawNSViewInRect(QCocoaWidget widget, NSView *view, const
restoreNSGraphicsContext(ctx);
}
-void QMacStylePrivate::resolveCurrentNSView(QWindow *window)
+void QMacStylePrivate::resolveCurrentNSView(QWindow *window) const
{
backingStoreNSView = window ? (NSView *)window->winId() : nil;
}
-void QMacStylePrivate::drawColorlessButton(const CGRect &macRect, HIThemeButtonDrawInfo *bdi,
+void QMacStylePrivate::drawColorlessButton(const CGRect &macRect, HIThemeButtonDrawInfo *bdi, const CocoaControl &cw,
QPainter *p, const QStyleOption *opt) const
{
int xoff = 0,
@@ -2147,7 +2051,7 @@ void QMacStylePrivate::drawColorlessButton(const CGRect &macRect, HIThemeButtonD
// Carbon combos don't scale. Therefore we draw it
// ourselves, if a scaled version is needed.
QPainter tmpPainter(&activePixmap);
- QMacStylePrivate::drawCombobox(macRect, *bdi, &tmpPainter);
+ QMacStylePrivate::drawCombobox(macRect, *bdi, cw, &tmpPainter);
} else {
QMacCGContext cg(&activePixmap);
CGRect newRect = CGRectMake(xoff, yoff, macRect.size.width, macRect.size.height);
@@ -2162,7 +2066,7 @@ void QMacStylePrivate::drawColorlessButton(const CGRect &macRect, HIThemeButtonD
if (!combo && !button && bdi->value == kThemeButtonOff) {
pm = activePixmap;
} else if ((combo && !editableCombo) || button) {
- QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi->kind);
+ CocoaControl cw = cocoaControlFromHIThemeButtonKind(bdi->kind);
NSButton *bc = (NSButton *)cocoaControl(cw);
[bc highlight:pressed];
bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive;
@@ -3131,7 +3035,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
QMacCGContext cg(p);
QWindow *window = w && w->window() ? w->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
- const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
+ d->resolveCurrentNSView(window);
switch (pe) {
case PE_IndicatorArrowUp:
case PE_IndicatorArrowDown:
@@ -3139,7 +3043,17 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
case PE_IndicatorArrowLeft: {
p->save();
p->setRenderHint(QPainter::Antialiasing);
- int xOffset = opt->direction == Qt::LeftToRight ? 2 : -1;
+ const int xOffset = 1; // FIXME: opt->direction == Qt::LeftToRight ? 2 : -1;
+ qreal halfSize = 0.5 * qMin(opt->rect.width(), opt->rect.height());
+ const qreal penWidth = qMax(halfSize / 3.0, 1.25);
+#if QT_CONFIG(toolbutton)
+ if (const QToolButton *tb = qobject_cast<const QToolButton *>(w)) {
+ // When stroking the arrow, make sure it fits in the tool button
+ if (tb->arrowType() != Qt::NoArrow)
+ halfSize -= penWidth;
+ }
+#endif
+
QMatrix matrix;
matrix.translate(opt->rect.center().x() + xOffset, opt->rect.center().y() + 2);
QPainterPath path;
@@ -3157,13 +3071,15 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
matrix.rotate(-90);
break;
}
- path.moveTo(0, 5);
- path.lineTo(-4, -3);
- path.lineTo(4, -3);
p->setMatrix(matrix);
- p->setPen(Qt::NoPen);
- p->setBrush(QColor(0, 0, 0, 135));
- p->drawPath(path);
+
+ path.moveTo(-halfSize, -halfSize * 0.5);
+ path.lineTo(0.0, halfSize * 0.5);
+ path.lineTo(halfSize, -halfSize * 0.5);
+
+ const QPen arrowPen(opt->palette.text(), penWidth,
+ Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+ p->strokePath(path, arrowPen);
p->restore();
break; }
#if QT_CONFIG(tabbar)
@@ -3211,7 +3127,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
if (groupBox->features & QStyleOptionFrame::Flat) {
QCommonStyle::drawPrimitive(pe, groupBox, p, w);
} else {
- const auto cw = QCocoaWidget(QCocoaBox, QStyleHelper::SizeDefault);
+ const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Box, QStyleHelper::SizeDefault);
auto *box = static_cast<NSBox *>(d->cocoaControl(cw));
d->drawNSViewInRect(cw, box, groupBox->rect, p, w != nullptr, ^(CGContextRef ctx, const CGRect &rect) {
CGContextTranslateCTM(ctx, 0, rect.origin.y + rect.size.height);
@@ -3386,10 +3302,11 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
else
bdi.value = kThemeButtonOff;
CGRect macRect = opt->rect.toCGRect();
+ const QMacStylePrivate::CocoaControl cw = QMacStylePrivate::cocoaControlFromHIThemeButtonKind(bdi.kind);
if (!drawColorless)
HIThemeDrawButton(&macRect, &bdi, cg, kHIThemeOrientationNormal, 0);
else
- d->drawColorlessButton(macRect, &bdi, p, opt);
+ d->drawColorlessButton(macRect, &bdi, cw, p, opt);
break; }
case PE_FrameFocusRect:
// Use the our own focus widget stuff.
@@ -3397,7 +3314,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
case PE_IndicatorBranch: {
if (!(opt->state & State_Children))
break;
- NSButtonCell *triangleCell = static_cast<NSButtonCell *>(d->cocoaCell(QCocoaWidget(QCocoaDisclosureButton, QStyleHelper::SizeLarge)));
+ const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Button_Disclosure, QStyleHelper::SizeLarge);
+ NSButtonCell *triangleCell = static_cast<NSButtonCell *>(d->cocoaCell(cw));
[triangleCell setState:(opt->state & State_Open) ? NSOnState : NSOffState];
bool viewHasFocus = (w && w->hasFocus()) || (opt->state & State_HasFocus);
[triangleCell setBackgroundStyle:((opt->state & State_Selected) && viewHasFocus) ? NSBackgroundStyleDark : NSBackgroundStyleLight];
@@ -3627,70 +3545,15 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QMacCGContext cg(p);
QWindow *window = w && w->window() ? w->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
- const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
+ d->resolveCurrentNSView(window);
switch (ce) {
case CE_HeaderSection:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- HIThemeButtonDrawInfo bdi;
- bdi.version = qt_mac_hitheme_version;
State flags = header->state;
QRect ir = header->rect;
- bdi.kind = kThemeListHeaderButton;
- bdi.adornment = kThemeAdornmentNone;
- bdi.state = kThemeStateActive;
- if (flags & State_On)
- bdi.value = kThemeButtonOn;
- else
- bdi.value = kThemeButtonOff;
-
- if (header->orientation == Qt::Horizontal){
- switch (header->position) {
- case QStyleOptionHeader::Beginning:
- ir.adjust(-1, -1, 0, 0);
- break;
- case QStyleOptionHeader::Middle:
- ir.adjust(-1, -1, 0, 0);
- break;
- case QStyleOptionHeader::OnlyOneSection:
- case QStyleOptionHeader::End:
- ir.adjust(-1, -1, 1, 0);
- break;
- default:
- break;
- }
-
- if (header->position != QStyleOptionHeader::Beginning
- && header->position != QStyleOptionHeader::OnlyOneSection) {
- bdi.adornment = header->direction == Qt::LeftToRight
- ? kThemeAdornmentHeaderButtonLeftNeighborSelected
- : kThemeAdornmentHeaderButtonRightNeighborSelected;
- }
- }
-
- if (flags & State_Active) {
- if (!(flags & State_Enabled))
- bdi.state = kThemeStateUnavailable;
- else if (flags & State_Sunken)
- bdi.state = kThemeStatePressed;
- } else {
- if (flags & State_Enabled)
- bdi.state = kThemeStateInactive;
- else
- bdi.state = kThemeStateUnavailableInactive;
- }
-
- if (header->sortIndicator != QStyleOptionHeader::None) {
- bdi.value = kThemeButtonOn;
- if (header->sortIndicator == QStyleOptionHeader::SortDown)
- bdi.adornment = kThemeAdornmentHeaderButtonSortUp;
- }
- if (flags & State_HasFocus)
- bdi.adornment = kThemeAdornmentFocus;
-
- ir = visualRect(header->direction, header->rect, ir);
- CGRect bounds = ir.toCGRect();
+#if 0 // FIXME: What's this solving exactly?
bool noVerticalHeader = true;
#if QT_CONFIG(tableview)
if (w)
@@ -3698,12 +3561,22 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
noVerticalHeader = !table->verticalHeader()->isVisible();
#endif
- bool drawTopBorder = header->orientation == Qt::Horizontal;
- bool drawLeftBorder = header->orientation == Qt::Vertical
- || header->position == QStyleOptionHeader::OnlyOneSection
- || (header->position == QStyleOptionHeader::Beginning && noVerticalHeader);
- d->drawTableHeader(bounds, drawTopBorder, drawLeftBorder, bdi, p);
+ const bool drawLeftBorder = header->orientation == Qt::Vertical
+ || header->position == QStyleOptionHeader::OnlyOneSection
+ || (header->position == QStyleOptionHeader::Beginning && noVerticalHeader);
+#endif
+
+ const bool pressed = (flags & State_Sunken) && !(flags & State_On);
+ p->fillRect(ir, pressed ? header->palette.dark() : header->palette.button());
+ p->setPen(QPen(header->palette.dark(), 1.0));
+ if (header->orientation == Qt::Horizontal)
+ p->drawLine(QLineF(ir.right() + 0.5, ir.top() + headerSectionSeparatorInset,
+ ir.right() + 0.5, ir.bottom() - headerSectionSeparatorInset));
+ else
+ p->drawLine(QLineF(ir.left() + headerSectionSeparatorInset, ir.bottom(),
+ ir.right() - headerSectionSeparatorInset, ir.bottom()));
}
+
break;
case CE_HeaderLabel:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
@@ -3820,12 +3693,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
} else {
QCommonStyle::drawControl(ce, &myTb, p, w);
}
- } else {
+ } else
+#endif // QT_NO_ACCESSIBILITY
+ {
QCommonStyle::drawControl(ce, &myTb, p, w);
}
-#else
- Q_UNUSED(tb)
-#endif
}
break;
case CE_ToolBoxTabShape:
@@ -3883,9 +3755,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4;
}
+ QMacStylePrivate::CocoaControl cw = QMacStylePrivate::cocoaControlFromHIThemeButtonKind(bdi.kind);
+ if (hasMenu)
+ cw.first = QMacStylePrivate::Button_PullDown;
if (hasMenu && bdi.kind != kThemeBevelButton) {
- QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
- cw.first = QCocoaPullDownButton;
NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(cw);
[pdb highlight:(bdi.state == kThemeStatePressed)];
pdb.enabled = bdi.state != kThemeStateUnavailable && bdi.state != kThemeStateUnavailableInactive;
@@ -3893,7 +3766,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
rect.adjust(0, 0, cw.second == QStyleHelper::SizeSmall ? -4 : cw.second == QStyleHelper::SizeMini ? -9 : -6, 0);
d->drawNSViewInRect(cw, pdb, rect, p, w != 0);
} else if (hasMenu && bdi.state == kThemeStatePressed)
- d->drawColorlessButton(newRect, &bdi, p, opt);
+ d->drawColorlessButton(newRect, &bdi, cw, p, opt);
else
HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0);
@@ -4451,7 +4324,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
const QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject));
QIndeterminateProgressIndicator *ipi = nil;
if (isIndeterminate || animation)
- ipi = static_cast<QIndeterminateProgressIndicator *>(d->cocoaControl({ QCocoaIndeterminateProgressIndicator, aquaSize }));
+ ipi = static_cast<QIndeterminateProgressIndicator *>(d->cocoaControl({ QMacStylePrivate::ProgressIndicator_Indeterminate, aquaSize }));
if (isIndeterminate) {
// QIndeterminateProgressIndicator derives from NSProgressIndicator. We use a single
// instance that we start animating as soon as one of the progress bars is indeterminate.
@@ -4478,7 +4351,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
[ipi stopAnimation];
}
- const QCocoaWidget cw = { QCocoaProgressIndicator, aquaSize };
+ const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::ProgressIndicator_Determinate, aquaSize);
auto *pi = static_cast<NSProgressIndicator *>(d->cocoaControl(cw));
d->drawNSViewInRect(cw, pi, rect, p, w != nullptr, ^(CGContextRef ctx, const CGRect &rect) {
d->setupVerticalInvertedXform(ctx, reverse, vertical, rect);
@@ -4691,14 +4564,31 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
// Subtract width needed for arrow, if there is one
if (header->sortIndicator != QStyleOptionHeader::None) {
if (opt->state & State_Horizontal)
- rect.setWidth(rect.width() - (opt->rect.height() / 2) - (margin * 2));
+ rect.setWidth(rect.width() - (headerSectionArrowHeight) - (margin * 2));
else
- rect.setHeight(rect.height() - (opt->rect.width() / 2) - (margin * 2));
+ rect.setHeight(rect.height() - (headerSectionArrowHeight) - (margin * 2));
}
}
rect = visualRect(opt->direction, opt->rect, rect);
break;
}
+ case SE_HeaderArrow: {
+ int h = opt->rect.height();
+ int w = opt->rect.width();
+ int x = opt->rect.x();
+ int y = opt->rect.y();
+ int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
+
+ if (opt->state & State_Horizontal) {
+ rect.setRect(x + w - margin * 2 - headerSectionArrowHeight, y + 5,
+ headerSectionArrowHeight, h - margin * 2 - 5);
+ } else {
+ rect.setRect(x + 5, y + h - margin * 2 - headerSectionArrowHeight,
+ w - margin * 2 - 5, headerSectionArrowHeight);
+ }
+ rect = visualRect(opt->direction, opt->rect, rect);
+ break;
+ }
case SE_ProgressBarGroove:
// Wrong in the secondary dimension, but accurate enough in the main dimension.
rect = opt->rect;
@@ -5159,7 +5049,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
QMacCGContext cg(p);
QWindow *window = widget && widget->window() ? widget->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
- const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
+ d->resolveCurrentNSView(window);
switch (cc) {
case CC_ScrollBar:
if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
@@ -5265,7 +5155,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
d->setupNSGraphicsContext(cg, NO /* flipped */);
- const QCocoaWidget cw(isHorizontal ? QCocoaHorizontalScroller : QCocoaVerticalScroller, cocoaSize);
+ const auto controlType = isHorizontal ? QMacStylePrivate::Scroller_Horizontal : QMacStylePrivate::Scroller_Vertical;
+ const auto cw = QMacStylePrivate::CocoaControl(controlType, cocoaSize);
NSScroller *scroller = static_cast<NSScroller *>(d->cocoaControl(cw));
if (isTransient) {
@@ -5347,8 +5238,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
case CC_Slider:
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
const bool isHorizontal = sl->orientation == Qt::Horizontal;
+ const auto ct = isHorizontal ? QMacStylePrivate::Slider_Horizontal : QMacStylePrivate::Slider_Vertical;
const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
- const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs);
+ const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *slider = static_cast<NSSlider *>(d->cocoaControl(cw));
if (!setupSlider(slider, sl))
break;
@@ -5483,7 +5375,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
d->setupNSGraphicsContext(cg, NO);
const auto aquaSize = d->effectiveAquaSizeConstrain(opt, widget);
- NSStepperCell *cell = static_cast<NSStepperCell *>(d->cocoaCell(QCocoaWidget(QCocoaStepper, aquaSize)));
+ const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Stepper, aquaSize);
+ NSStepperCell *cell = static_cast<NSStepperCell *>(d->cocoaCell(cw));
cell.enabled = (sb->state & State_Enabled);
const CGRect newRect = [cell drawingRectForBounds:updown.toCGRect()];
@@ -5511,19 +5404,20 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
case CC_ComboBox:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
HIThemeButtonDrawInfo bdi;
- d->initComboboxBdi(combo, &bdi, widget, tds);
+ QMacStylePrivate::CocoaControl cw;
+ d->initComboboxBdi(combo, &bdi, &cw, widget, tds);
CGRect rect = combo->rect.toCGRect();
if (combo->editable)
rect.origin.y += tds == kThemeStateInactive ? 1 : 2;
if (tds != kThemeStateInactive)
- QMacStylePrivate::drawCombobox(rect, bdi, p);
+ QMacStylePrivate::drawCombobox(rect, bdi, cw, p);
else if (!widget && combo->editable) {
- QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
+ const auto cw = QMacStylePrivate::cocoaControlFromHIThemeButtonKind(bdi.kind);
NSView *cb = d->cocoaControl(cw);
QRect r = combo->rect.adjusted(3, 0, 0, 0);
d->drawNSViewInRect(cw, cb, r, p, widget != 0);
} else
- d->drawColorlessButton(rect, &bdi, p, opt);
+ d->drawColorlessButton(rect, &bdi, cw, p, opt);
}
break;
case CC_TitleBar:
@@ -5703,7 +5597,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
p->fillPath(path, brush);
}
proxy()->drawControl(CE_ToolButtonLabel, opt, p, widget);
- } else {
+ } else
+#endif // QT_NO_ACCESSIBILITY
+ {
ThemeButtonKind bkind = kThemeBevelButton;
switch (d->aquaSizeConstrain(opt, widget)) {
case QStyleHelper::SizeDefault:
@@ -5786,7 +5682,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
label.rect = buttonRect.adjusted(fw, fw, -fw, -fw);
proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
}
-#endif
}
break;
#if QT_CONFIG(dial)
@@ -5822,8 +5717,9 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
const bool hasTicks = sl->tickPosition != QSlider::NoTicks;
const bool isHorizontal = sl->orientation == Qt::Horizontal;
+ const auto ct = isHorizontal ? QMacStylePrivate::Slider_Horizontal : QMacStylePrivate::Slider_Vertical;
const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
- const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs);
+ const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *slider = static_cast<NSSlider *>(d->cocoaControl(cw));
if (!setupSlider(slider, sl))
break;
@@ -5848,9 +5744,10 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
break;
}
- const auto controlSize = d->effectiveAquaSizeConstrain(opt, widget);
const bool isHorizontal = sb->orientation == Qt::Horizontal;
- const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalScroller : QCocoaVerticalScroller, controlSize);
+ const auto ct = isHorizontal ? QMacStylePrivate::Scroller_Horizontal : QMacStylePrivate::Scroller_Vertical;
+ const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
+ const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *scroller = static_cast<NSScroller *>(d->cocoaControl(cw));
if (!setupScroller(scroller, sb)) {
sc = SC_None;
@@ -5956,8 +5853,9 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
// And nothing else since 10.7
if (part != NSScrollerNoPart) {
- const auto controlSize = d->effectiveAquaSizeConstrain(opt, widget);
- const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalScroller : QCocoaVerticalScroller, controlSize);
+ const auto ct = isHorizontal ? QMacStylePrivate::Scroller_Horizontal : QMacStylePrivate::Scroller_Vertical;
+ const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
+ const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *scroller = static_cast<NSScroller *>(d->cocoaControl(cw));
if (setupScroller(scroller, sb))
ret = QRectF::fromCGRect([scroller rectForPart:part]).toRect();
@@ -5968,8 +5866,9 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
const bool hasTicks = sl->tickPosition != QSlider::NoTicks;
const bool isHorizontal = sl->orientation == Qt::Horizontal;
+ const auto ct = isHorizontal ? QMacStylePrivate::Slider_Horizontal : QMacStylePrivate::Slider_Vertical;
const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
- const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs);
+ const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *slider = static_cast<NSSlider *>(d->cocoaControl(cw));
if (!setupSlider(slider, sl))
break;
@@ -6063,7 +5962,8 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
case CC_ComboBox:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
HIThemeButtonDrawInfo bdi;
- d->initComboboxBdi(combo, &bdi, widget, d->getDrawState(opt->state));
+ QMacStylePrivate::CocoaControl cw;
+ d->initComboboxBdi(combo, &bdi, &cw, widget, d->getDrawState(opt->state));
switch (sc) {
case SC_ComboBoxEditField:{
@@ -6078,7 +5978,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
break; }
case SC_ComboBoxListBoxPopup:{
if (combo->editable) {
- const CGRect inner = QMacStylePrivate::comboboxInnerBounds(combo->rect.toCGRect(), bdi.kind);
+ const CGRect inner = QMacStylePrivate::comboboxInnerBounds(combo->rect.toCGRect(), cw);
QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
const int comboTop = combo->rect.top();
ret = QRect(qRound(inner.origin.x),
@@ -6230,7 +6130,8 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
Q_UNREACHABLE();
}
- NSStepperCell *cell = static_cast<NSStepperCell *>(d->cocoaCell(QCocoaWidget(QCocoaStepper, aquaSize)));
+ const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Stepper, aquaSize);
+ NSStepperCell *cell = static_cast<NSStepperCell *>(d->cocoaCell(cw));
const CGRect outRect = [cell drawingRectForBounds:ret.toCGRect()];
ret = QRectF::fromCGRect(outRect).toRect();
@@ -6554,20 +6455,10 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
// We compensate for this by adding some extra space here to make room for the frame when drawing:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
const auto widgetSize = d->aquaSizeConstrain(opt, widget);
- int bkind = 0;
- switch (widgetSize) {
- default:
- case QStyleHelper::SizeLarge:
- bkind = combo->editable ? kThemeComboBox : kThemePopupButton;
- break;
- case QStyleHelper::SizeSmall:
- bkind = combo->editable ? int(kThemeComboBoxSmall) : int(kThemePopupButtonSmall);
- break;
- case QStyleHelper::SizeMini:
- bkind = combo->editable ? kThemeComboBoxMini : kThemePopupButtonMini;
- break;
- }
- const CGRect diffRect = QMacStylePrivate::comboboxInnerBounds(CGRectZero, bkind);
+ QMacStylePrivate::CocoaControl cw;
+ cw.first = combo->editable ? QMacStylePrivate::ComboBox : QMacStylePrivate::Button_PopupButton;
+ cw.second = widgetSize;
+ const CGRect diffRect = QMacStylePrivate::comboboxInnerBounds(CGRectZero, cw);
sz.rwidth() -= qRound(diffRect.size.width);
sz.rheight() -= qRound(diffRect.size.height);
} else if (ct == CT_PushButton || ct == CT_ToolButton){
@@ -6808,16 +6699,4 @@ int QMacStyle::layoutSpacing(QSizePolicy::ControlType control1,
return_SIZE(10, 8, 6); // guess
}
-/*
-FontHash::FontHash()
-{
- QHash<QByteArray, QFont>::operator=(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFonts());
-}
-
-Q_GLOBAL_STATIC(FontHash, app_fonts)
-FontHash *qt_app_fonts_hash()
-{
- return app_fonts();
-}
-*/
QT_END_NAMESPACE
diff --git a/src/plugins/styles/mac/qmacstyle_mac_p.h b/src/plugins/styles/mac/qmacstyle_mac_p.h
index 6011baeea2..d6874001d3 100644
--- a/src/plugins/styles/mac/qmacstyle_mac_p.h
+++ b/src/plugins/styles/mac/qmacstyle_mac_p.h
@@ -117,10 +117,6 @@ public:
private:
Q_DISABLE_COPY(QMacStyle)
Q_DECLARE_PRIVATE(QMacStyle)
-
-#if QT_CONFIG(pushbutton)
- friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
-#endif
};
QT_END_NAMESPACE
diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h
index 528edfcda1..078509d551 100644
--- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h
+++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h
@@ -167,28 +167,6 @@ QT_BEGIN_NAMESPACE
#define CT1(c) CT2(c, c)
#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
-enum QCocoaWidgetKind {
- QCocoaBox, // QGroupBox
- QCocoaCheckBox,
- QCocoaComboBox, // Editable QComboBox
- QCocoaDisclosureButton, // Disclosure triangle, like in QTreeView
- QCocoaPopupButton, // Non-editable QComboBox
- QCocoaProgressIndicator,
- QCocoaIndeterminateProgressIndicator,
- QCocoaPullDownButton, // QPushButton with menu
- QCocoaPushButton,
- QCocoaRadioButton,
- QCocoaHorizontalScroller,
- QCocoaVerticalScroller,
- QCocoaHorizontalSlider,
- QCocoaVerticalSlider,
- QCocoaStepper // QSpinBox buttons
-};
-
-typedef QPair<QCocoaWidgetKind, QStyleHelper::WidgetSizePolicy> QCocoaWidget;
-
-typedef void (^QCocoaDrawRectBlock)(CGContextRef, const CGRect &);
-
#define SIZE(large, small, mini) \
(controlSize == QStyleHelper::SizeLarge ? (large) : controlSize == QStyleHelper::SizeSmall ? (small) : (mini))
@@ -199,14 +177,32 @@ typedef void (^QCocoaDrawRectBlock)(CGContextRef, const CGRect &);
return sizes[controlSize]; \
} while (false)
-#if QT_CONFIG(pushbutton)
-bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
-#endif
-
class QMacStylePrivate : public QCommonStylePrivate
{
Q_DECLARE_PUBLIC(QMacStyle)
public:
+ enum CocoaControlType {
+ Box, // QGroupBox
+ Button_CheckBox,
+ Button_Disclosure, // Disclosure triangle, like in QTreeView
+ Button_PopupButton, // Non-editable QComboBox
+ Button_PullDown, // QPushButton with menu
+ Button_PushButton,
+ Button_RadioButton,
+ ComboBox, // Editable QComboBox
+ ProgressIndicator_Determinate,
+ ProgressIndicator_Indeterminate,
+ Scroller_Horizontal,
+ Scroller_Vertical,
+ Slider_Horizontal,
+ Slider_Vertical,
+ Stepper // QSpinBox buttons
+ };
+
+ typedef QPair<CocoaControlType, QStyleHelper::WidgetSizePolicy> CocoaControl;
+
+ typedef void (^DrawRectBlock)(CGContextRef, const CGRect &);
+
QMacStylePrivate();
~QMacStylePrivate();
@@ -235,6 +231,7 @@ public:
// Utility functions
void drawColorlessButton(const CGRect &macRect, HIThemeButtonDrawInfo *bdi,
+ const CocoaControl &cw,
QPainter *p, const QStyleOption *opt) const;
QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;
@@ -243,15 +240,14 @@ public:
const HIThemeButtonDrawInfo *bdi) const;
void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,
+ CocoaControl *cw,
const QWidget *widget, const ThemeDrawState &tds) const;
- static CGRect comboboxInnerBounds(const CGRect &outerBounds, int buttonKind);
+ static CGRect comboboxInnerBounds(const CGRect &outerBounds, const CocoaControl &cocoaWidget);
static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi);
- static void drawCombobox(const CGRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p);
- static void drawTableHeader(const CGRect &outerBounds, bool drawTopBorder, bool drawLeftBorder,
- const HIThemeButtonDrawInfo &bdi, QPainter *p);
+ static void drawCombobox(const CGRect &outerBounds, const HIThemeButtonDrawInfo &bdi, const CocoaControl &cw, QPainter *p);
bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi,
ThemeButtonKind buttonKindToCheck) const;
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,
@@ -260,16 +256,18 @@ public:
void setAutoDefaultButton(QObject *button) const;
- NSView *cocoaControl(QCocoaWidget widget) const;
- NSCell *cocoaCell(QCocoaWidget widget) const;
+ NSView *cocoaControl(CocoaControl widget) const;
+ NSCell *cocoaCell(CocoaControl widget) const;
+
+ static CocoaControl cocoaControlFromHIThemeButtonKind(ThemeButtonKind kind);
void setupNSGraphicsContext(CGContextRef cg, bool flipped) const;
void restoreNSGraphicsContext(CGContextRef cg) const;
void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const;
- void drawNSViewInRect(QCocoaWidget widget, NSView *view, const QRect &rect, QPainter *p, bool isQWidget = true, QCocoaDrawRectBlock drawRectBlock = nil) const;
- void resolveCurrentNSView(QWindow *window);
+ void drawNSViewInRect(CocoaControl widget, NSView *view, const QRect &rect, QPainter *p, bool isQWidget = true, DrawRectBlock drawRectBlock = nil) const;
+ void resolveCurrentNSView(QWindow *window) const;
void drawFocusRing(QPainter *p, const QRect &targetRect, int hMargin, int vMargin, qreal radius = 0) const;
@@ -283,9 +281,9 @@ public:
mutable QPointer<QFocusFrame> focusWidget;
QT_MANGLE_NAMESPACE(NotificationReceiver) *receiver;
- NSView *backingStoreNSView;
- mutable QHash<QCocoaWidget, NSView *> cocoaControls;
- mutable QHash<QCocoaWidget, NSCell *> cocoaCells;
+ mutable NSView *backingStoreNSView;
+ mutable QHash<CocoaControl, NSView *> cocoaControls;
+ mutable QHash<CocoaControl, NSCell *> cocoaCells;
QFont smallSystemFont;
QFont miniSystemFont;