diff options
Diffstat (limited to 'src/plugins')
21 files changed, 197 insertions, 258 deletions
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index fe1aff0cc4..d0b5e4a12a 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -59,7 +59,6 @@ using namespace QtAndroid; namespace QtAndroidInput { static bool m_ignoreMouseEvents = false; - static bool m_softwareKeyboardVisible = false; static QRect m_softwareKeyboardRect; static QList<QWindowSystemInterface::TouchPoint> m_touchPoints; @@ -115,7 +114,7 @@ namespace QtAndroidInput bool isSoftwareKeyboardVisible() { - return m_softwareKeyboardVisible; + return QJNIObjectPrivate::callStaticMethod<jboolean>(applicationClass(), "isSoftwareKeyboardVisible"); } QRect softwareKeyboardRect() @@ -806,7 +805,6 @@ namespace QtAndroidInput static void keyboardVisibilityChanged(JNIEnv */*env*/, jobject /*thiz*/, jboolean visibility) { - m_softwareKeyboardVisible = visibility; if (!visibility) m_softwareKeyboardRect = QRect(); diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 9e4007b37a..8ef009041f 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -238,6 +238,11 @@ namespace QtAndroid QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "notifyObjectFocus","(I)V", accessibilityObjectId); } + void notifyQtAndroidPluginRunning(bool running) + { + QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "notifyQtAndroidPluginRunning","(Z)V", running); + } + jobject createBitmap(QImage img, JNIEnv *env) { if (!m_bitmapClass) @@ -644,11 +649,12 @@ static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, jint widthPixels, jint heightPixels, jint desktopWidthPixels, jint desktopHeightPixels, jdouble xdpi, jdouble ydpi, - jdouble scaledDensity, jdouble density) + jdouble scaledDensity, jdouble density, bool forceUpdate) { // Android does not give us the correct screen size for immersive mode, but // the surface does have the right size + bool updateDesktopSize = m_desktopWidthPixels != desktopWidthPixels; widthPixels = qMax(widthPixels, desktopWidthPixels); heightPixels = qMax(heightPixels, desktopHeightPixels); @@ -669,7 +675,9 @@ static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4), qRound(double(heightPixels) / ydpi * 25.4)); m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels); - m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); + if (updateDesktopSize || forceUpdate) { + m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); + } } } @@ -795,7 +803,7 @@ static JNINativeMethod methods[] = { {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"waitForServiceSetup", "()V", (void *)waitForServiceSetup}, - {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, + {"setDisplayMetrics", "(IIIIDDDDZ)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"updateWindow", "()V", (void *)updateWindow}, {"updateApplicationState", "(I)V", (void *)updateApplicationState}, diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 72b864de19..641b2dbdb4 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -98,6 +98,7 @@ namespace QtAndroid void notifyAccessibilityLocationChange(); void notifyObjectHide(uint accessibilityObjectId); void notifyObjectFocus(uint accessibilityObjectId); + void notifyQtAndroidPluginRunning(bool running); const char *classErrorMsgFmt(); const char *methodErrorMsgFmt(); diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 687cced1e2..96eee24c2f 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -95,6 +95,7 @@ private: static QAndroidInputContext *m_androidInputContext = 0; static char const *const QtNativeInputConnectionClassName = "org/qtproject/qt5/android/QtNativeInputConnection"; static char const *const QtExtractedTextClassName = "org/qtproject/qt5/android/QtExtractedText"; +static char const *const QtObjectType = "QDialog"; static jclass m_extractedTextClass = 0; static jmethodID m_classConstructorMethodID = 0; static jfieldID m_partialEndOffsetFieldID = 0; @@ -646,7 +647,7 @@ void QAndroidInputContext::updateSelectionHandles() } auto curRect = im->cursorRectangle(); - QPoint cursorPoint = qGuiApp->focusWindow()->mapToGlobal(QPoint(curRect.x() + (curRect.width() / 2), curRect.y() + curRect.height())); + QPoint cursorPoint(window->mapToGlobal(QPoint(curRect.x() + (curRect.width() / 2), curRect.y() + curRect.height()))); QPoint editMenuPoint(cursorPoint.x(), cursorPoint.y()); m_handleMode &= ShowEditPopup; m_handleMode |= ShowCursor; @@ -666,10 +667,12 @@ void QAndroidInputContext::updateSelectionHandles() if (cpos > anchor) std::swap(leftRect, rightRect); - QPoint leftPoint(leftRect.bottomLeft().toPoint() * pixelDensity); - QPoint righPoint(rightRect.bottomRight().toPoint() * pixelDensity); - QPoint editPoint(leftRect.united(rightRect).topLeft().toPoint() * pixelDensity); - QtAndroidInput::updateHandles(m_handleMode, editPoint, EditContext::AllButtons, leftPoint, righPoint, + QPoint leftPoint(window->mapToGlobal(leftRect.bottomLeft().toPoint())); + QPoint righPoint(window->mapToGlobal(rightRect.bottomRight().toPoint())); + QPoint editPoint(window->mapToGlobal(leftRect.united(rightRect) + .topLeft().toPoint())); + QtAndroidInput::updateHandles(m_handleMode, editPoint * pixelDensity, EditContext::AllButtons, + leftPoint * pixelDensity, righPoint * pixelDensity, query.value(Qt::ImCurrentSelection).toString().isRightToLeft()); m_hideCursorHandleTimer.stop(); } @@ -693,7 +696,17 @@ void QAndroidInputContext::handleLocationChanged(int handleId, int x, int y) double pixelDensity = window ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); - QPointF point(x / pixelDensity, y / pixelDensity); + auto object = m_focusObject->parent(); + int dialogMoveX = 0; + while (object) { + if (QString::compare(object->metaObject()->className(), + QtObjectType, Qt::CaseInsensitive) == 0) { + dialogMoveX += object->property("x").toInt(); + } + object = object->parent(); + }; + + QPointF point((x / pixelDensity) - dialogMoveX, y / pixelDensity); point.setY(point.y() - leftRect.width() / 2); QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition @@ -892,7 +905,34 @@ void QAndroidInputContext::update(Qt::InputMethodQueries queries) QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery(queries); if (query.isNull()) return; -#warning TODO extract the needed data from query + + if (query->value(Qt::ImCursorPosition).toInt() >= 0 && + query->value(Qt::ImSurroundingText).toString() != nullptr && + query->value(Qt::ImSurroundingText).toString() + .left(query->value(Qt::ImCursorPosition).toInt()).length()>=0) { + // Cursos position should be always valid + // when object is composing + if (focusObjectIsComposing()) + return; + if (m_focusObject->isWidgetType()) + updateCursorPosition(); + else + updateCursorPositionInRange(query); + } +} + +void QAndroidInputContext::updateCursorPositionInRange(const QSharedPointer<QInputMethodQueryEvent> &query) +{ + QObject *input = qGuiApp->focusObject(); + QList<QInputMethodEvent::Attribute> attributes; + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, + query->value(Qt::ImCursorPosition).toInt(), 1)); + + QInputMethodEvent event(QString(), attributes); + QCoreApplication::sendEvent(input, &event); + QtAndroidInput::updateSelection(query->value(Qt::ImCursorPosition).toInt(), + query->value(Qt::ImCursorPosition).toInt(), 0, + query->value(Qt::ImSurroundingText).toString().length()); } void QAndroidInputContext::invokeAction(QInputMethod::Action action, int cursorPosition) @@ -925,14 +965,9 @@ void QAndroidInputContext::showInputPanel() if (query.isNull()) return; - disconnect(m_updateCursorPosConnection); - if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern - m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition())); - else - m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition())); - QRect rect = cursorRect(); - QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(), + if (!isInputPanelVisible()) + QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(), inputItemRectangle().height(), query->value(Qt::ImHints).toUInt(), query->value(Qt::ImEnterKeyType).toUInt()); diff --git a/src/plugins/platforms/android/qandroidinputcontext.h b/src/plugins/platforms/android/qandroidinputcontext.h index 02a66c367a..521061b02c 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.h +++ b/src/plugins/platforms/android/qandroidinputcontext.h @@ -156,13 +156,13 @@ private: void focusObjectStartComposing(); bool focusObjectStopComposing(); QRect cursorRect(); + void updateCursorPositionInRange(const QSharedPointer<QInputMethodQueryEvent> &query); private: ExtractedText m_extractedText; QString m_composingText; int m_composingTextStart; int m_composingCursor; - QMetaObject::Connection m_updateCursorPosConnection; HandleModes m_handleMode; int m_batchEditNestingLevel; QObject *m_focusObject; diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index aaeb9199d8..3074dee26f 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -90,6 +90,7 @@ Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOr Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; bool QAndroidPlatformIntegration::m_showPasswordEnabled = false; +static bool m_running = false; void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { @@ -158,6 +159,10 @@ void QAndroidPlatformNativeInterface::customEvent(QEvent *event) api->accessibility()->setActive(QtAndroidAccessibility::isActive()); #endif // QT_NO_ACCESSIBILITY + if (!m_running) { + m_running = true; + QtAndroid::notifyQtAndroidPluginRunning(m_running); + } api->flushPendingUpdates(); } diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 0b03a98fd6..e88cc54143 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -294,9 +294,13 @@ void QCocoaMenu::syncSeparatorsCollapsible(bool enable) for (NSMenuItem *item in m_nativeMenu.itemArray) { if (item.separatorItem) { - if (auto *cocoaItem = qt_objc_cast<QCocoaNSMenuItem *>(item).platformMenuItem) - cocoaItem->setVisible(!previousIsSeparator); - item.hidden = previousIsSeparator; + // hide item if previous was a separator, or if it's explicitly hidden + bool itemVisible = !previousIsSeparator; + if (auto *cocoaItem = qt_objc_cast<QCocoaNSMenuItem *>(item).platformMenuItem) { + cocoaItem->setVisible(!previousIsSeparator && cocoaItem->isVisible()); + itemVisible = cocoaItem->isVisible(); + } + item.hidden = !itemVisible; } if (!item.hidden) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h index 029d29be9d..e6bbf14367 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.h +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h @@ -117,6 +117,7 @@ public: inline bool isMerged() const { return m_merged; } inline bool isEnabled() const { return m_enabled && m_parentEnabled; } inline bool isSeparator() const { return m_isSeparator; } + inline bool isVisible() const { return m_isVisible; } QCocoaMenu *menu() const { return m_menu; } MenuRole effectiveRole() const; diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm index 978d73f7d9..a4e4ad2f62 100644 --- a/src/plugins/platforms/cocoa/qnsview_dragging.mm +++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm @@ -297,7 +297,9 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); Q_ASSERT(nativeDrag); nativeDrag->exitDragLoop(); - nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation)); + // for internal drag'n'drop, don't override the action the drop event accepted + if (!nativeDrag->currentDrag()) + nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation)); // Qt starts drag-and-drop on a mouse button press event. Cococa in // this case won't send the matching release event, so we have to diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index b42f2d0e7e..8695cfc642 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -103,21 +103,14 @@ if (!m_platformWindow) return; - // get m_buttons in sync - // Don't send frme strut events if we are in the middle of a mouse drag. - if (m_buttons != Qt::NoButton) - return; - switch (theEvent.type) { case NSEventTypeLeftMouseDown: - case NSEventTypeLeftMouseDragged: m_frameStrutButtons |= Qt::LeftButton; break; case NSEventTypeLeftMouseUp: m_frameStrutButtons &= ~Qt::LeftButton; break; case NSEventTypeRightMouseDown: - case NSEventTypeRightMouseDragged: m_frameStrutButtons |= Qt::RightButton; break; case NSEventTypeRightMouseUp: @@ -132,6 +125,22 @@ break; } + // m_buttons can sometimes get out of sync with the button state in AppKit + // E.g if the QNSView where a drag starts is reparented to another window + // while the drag is ongoing, it will not get the corresponding mouseUp + // call. This will result in m_buttons to be stuck on Qt::LeftButton. + // Since we know which buttons was pressed/released directly on the frame + // strut, we can rectify m_buttons here so that we at least don't return early + // from the drag test underneath because of the faulty m_buttons state. + // FIXME: get m_buttons in sync with AppKit/NSEvent all over in QNSView. + m_buttons &= ~m_frameStrutButtons; + + if (m_buttons != Qt::NoButton) { + // Don't send frame strut events if we are in the middle of + // a mouse drag that didn't start on the frame strut. + return; + } + NSWindow *window = [self window]; NSPoint windowPoint = [theEvent locationInWindow]; diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index a7f94dd31f..a4f033c5cd 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -514,15 +514,23 @@ // from within a undo callback. NSUndoManager *undoMgr = self.undoManager; [undoMgr removeAllActions]; + + [undoMgr beginUndoGrouping]; + [undoMgr registerUndoWithTarget:self selector:@selector(undo) object:nil]; + [undoMgr endUndoGrouping]; [undoMgr beginUndoGrouping]; [undoMgr registerUndoWithTarget:self selector:@selector(undo) object:nil]; [undoMgr endUndoGrouping]; - // Schedule an operation that we immediately pop off to be able to schedule a redo + // Schedule operations that we immediately pop off to be able to schedule redos + [undoMgr beginUndoGrouping]; + [undoMgr registerUndoWithTarget:self selector:@selector(registerRedo) object:nil]; + [undoMgr endUndoGrouping]; [undoMgr beginUndoGrouping]; [undoMgr registerUndoWithTarget:self selector:@selector(registerRedo) object:nil]; [undoMgr endUndoGrouping]; [undoMgr undo]; + [undoMgr undo]; // Note that, perhaps because of a bug in UIKit, the buttons on the shortcuts bar ends up // disabled if a undo/redo callback doesn't lead to a [UITextInputDelegate textDidChange]. @@ -530,6 +538,11 @@ // become disabled when there is nothing more to undo (Qt didn't change anything upon receiving // an undo request). This seems to be OK behavior, so we let it stay like that unless it shows // to cause problems. + + // QTBUG-63393: Having two operations on the rebuilt undo stack keeps the undo/redo widgets + // always enabled on the shortcut bar. This workaround was found by experimenting with + // removing the removeAllActions call, and is related to the unknown internal implementation + // details of how the shortcut bar updates the dimming of its buttons. }); } diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm index 3154536aad..4dd1f9f035 100644 --- a/src/plugins/platforms/ios/quiaccessibilityelement.mm +++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm @@ -123,8 +123,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement); if (val) { return val->currentValue().toString().toNSString(); } else if (QAccessibleTextInterface *text = iface->textInterface()) { - // FIXME doesn't work? - return text->text(0, text->characterCount() - 1).toNSString(); + return text->text(0, text->characterCount()).toNSString(); } return [super accessibilityHint]; @@ -158,8 +157,16 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement); if (state.searchEdit) traits |= UIAccessibilityTraitSearchField; - if (iface->role() == QAccessible::Button) + const auto accessibleRole = iface->role(); + if (accessibleRole == QAccessible::Button) { traits |= UIAccessibilityTraitButton; + } else if (accessibleRole == QAccessible::EditableText) { + static auto defaultTextFieldTraits = []{ + auto *textField = [[[UITextField alloc] initWithFrame:CGRectZero] autorelease]; + return textField.accessibilityTraits; + }(); + traits |= defaultTextFieldTraits; + } if (iface->valueInterface()) traits |= UIAccessibilityTraitAdjustable; diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index d21e50c248..a518cb314b 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -477,6 +477,9 @@ void QRfbRawEncoder::write() // server->screen()->geometry().height()); // } + const QImage screenImage = client->server()->screenImage(); + rgn &= screenImage.rect(); + const auto rectsInRegion = rgn.rectCount(); { @@ -492,8 +495,6 @@ void QRfbRawEncoder::write() if (rectsInRegion <= 0) return; - const QImage screenImage = client->server()->screenImage(); - for (const QRect &tileRect: rgn) { const QRfbRect rect(tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height()); diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 41ece2ccf4..a3e61adf64 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -136,139 +136,11 @@ static constexpr const auto KeyTbl = qMakeArray( Emkb2Qt< Qt::Key_F21, 'F','2','1' >, Emkb2Qt< Qt::Key_F22, 'F','2','2' >, Emkb2Qt< Qt::Key_F23, 'F','2','3' >, - Emkb2Qt< Qt::Key_Space, ' ' >, - Emkb2Qt< Qt::Key_Comma, ',' >, - Emkb2Qt< Qt::Key_Minus, '-' >, - Emkb2Qt< Qt::Key_Period, '.' >, - Emkb2Qt< Qt::Key_Slash, '/' >, - Emkb2Qt< Qt::Key_0, 'D','i','g','i','t','0' >, - Emkb2Qt< Qt::Key_1, 'D','i','g','i','t','1' >, - Emkb2Qt< Qt::Key_2, 'D','i','g','i','t','2' >, - Emkb2Qt< Qt::Key_3, 'D','i','g','i','t','3' >, - Emkb2Qt< Qt::Key_4, 'D','i','g','i','t','4' >, - Emkb2Qt< Qt::Key_5, 'D','i','g','i','t','5' >, - Emkb2Qt< Qt::Key_6, 'D','i','g','i','t','6' >, - Emkb2Qt< Qt::Key_7, 'D','i','g','i','t','7' >, - Emkb2Qt< Qt::Key_8, 'D','i','g','i','t','8' >, - Emkb2Qt< Qt::Key_9, 'D','i','g','i','t','9' >, - Emkb2Qt< Qt::Key_Semicolon, ';' >, - Emkb2Qt< Qt::Key_Equal, '=' >, - Emkb2Qt< Qt::Key_A, 'K','e','y','A' >, - Emkb2Qt< Qt::Key_B, 'K','e','y','B' >, - Emkb2Qt< Qt::Key_C, 'K','e','y','C' >, - Emkb2Qt< Qt::Key_D, 'K','e','y','D' >, - Emkb2Qt< Qt::Key_E, 'K','e','y','E' >, - Emkb2Qt< Qt::Key_F, 'K','e','y','F' >, - Emkb2Qt< Qt::Key_G, 'K','e','y','G' >, - Emkb2Qt< Qt::Key_H, 'K','e','y','H' >, - Emkb2Qt< Qt::Key_I, 'K','e','y','I' >, - Emkb2Qt< Qt::Key_J, 'K','e','y','J' >, - Emkb2Qt< Qt::Key_K, 'K','e','y','K' >, - Emkb2Qt< Qt::Key_L, 'K','e','y','L' >, - Emkb2Qt< Qt::Key_M, 'K','e','y','M' >, - Emkb2Qt< Qt::Key_N, 'K','e','y','N' >, - Emkb2Qt< Qt::Key_O, 'K','e','y','O' >, - Emkb2Qt< Qt::Key_P, 'K','e','y','P' >, - Emkb2Qt< Qt::Key_Q, 'K','e','y','Q' >, - Emkb2Qt< Qt::Key_R, 'K','e','y','R' >, - Emkb2Qt< Qt::Key_S, 'K','e','y','S' >, - Emkb2Qt< Qt::Key_T, 'K','e','y','T' >, - Emkb2Qt< Qt::Key_U, 'K','e','y','U' >, - Emkb2Qt< Qt::Key_V, 'K','e','y','V' >, - Emkb2Qt< Qt::Key_W, 'K','e','y','W' >, - Emkb2Qt< Qt::Key_X, 'K','e','y','X' >, - Emkb2Qt< Qt::Key_Y, 'K','e','y','Y' >, - Emkb2Qt< Qt::Key_Z, 'K','e','y','Z' >, - Emkb2Qt< Qt::Key_BracketLeft, '[' >, - Emkb2Qt< Qt::Key_Backslash, '\\' >, - Emkb2Qt< Qt::Key_BracketRight, ']' >, - Emkb2Qt< Qt::Key_Apostrophe, '\'' >, - Emkb2Qt< Qt::Key_QuoteLeft, 'B','a','c','k','q','u','o','t','e' >, - Emkb2Qt< Qt::Key_multiply, 'N','u','m','p','a','d','M','u','l','t','i','p','l','y' >, - Emkb2Qt< Qt::Key_Minus, 'N','u','m','p','a','d','S','u','b','t','r','a','c','t' >, - Emkb2Qt< Qt::Key_Period, 'N','u','m','p','a','d','D','e','c','i','m','a','l' >, - Emkb2Qt< Qt::Key_Plus, 'N','u','m','p','a','d','A','d','d' >, - Emkb2Qt< Qt::Key_division, 'N','u','m','p','a','d','D','i','v','i','d','e' >, - Emkb2Qt< Qt::Key_Equal, 'N','u','m','p','a','d','E','q','u','a','l' >, - Emkb2Qt< Qt::Key_0, 'N','u','m','p','a','d','0' >, - Emkb2Qt< Qt::Key_1, 'N','u','m','p','a','d','1' >, - Emkb2Qt< Qt::Key_2, 'N','u','m','p','a','d','2' >, - Emkb2Qt< Qt::Key_3, 'N','u','m','p','a','d','3' >, - Emkb2Qt< Qt::Key_4, 'N','u','m','p','a','d','4' >, - Emkb2Qt< Qt::Key_5, 'N','u','m','p','a','d','5' >, - Emkb2Qt< Qt::Key_6, 'N','u','m','p','a','d','6' >, - Emkb2Qt< Qt::Key_7, 'N','u','m','p','a','d','7' >, - Emkb2Qt< Qt::Key_8, 'N','u','m','p','a','d','8' >, - Emkb2Qt< Qt::Key_9, 'N','u','m','p','a','d','9' >, - Emkb2Qt< Qt::Key_Comma, 'N','u','m','p','a','d','C','o','m','m','a' >, - Emkb2Qt< Qt::Key_Enter, 'N','u','m','p','a','d','E','n','t','e','r' >, Emkb2Qt< Qt::Key_Paste, 'P','a','s','t','e' >, Emkb2Qt< Qt::Key_AltGr, 'A','l','t','R','i','g','h','t' >, Emkb2Qt< Qt::Key_Help, 'H','e','l','p' >, - Emkb2Qt< Qt::Key_Equal, '=' >, Emkb2Qt< Qt::Key_yen, 'I','n','t','l','Y','e','n' >, - - Emkb2Qt< Qt::Key_Exclam, '\x21' >, - Emkb2Qt< Qt::Key_QuoteDbl, '\x22' >, - Emkb2Qt< Qt::Key_NumberSign, '\x23' >, - Emkb2Qt< Qt::Key_Dollar, '\x24' >, - Emkb2Qt< Qt::Key_Percent, '\x25' >, - Emkb2Qt< Qt::Key_Ampersand, '\x26' >, - Emkb2Qt< Qt::Key_ParenLeft, '\x28' >, - Emkb2Qt< Qt::Key_ParenRight, '\x29' >, - Emkb2Qt< Qt::Key_Asterisk, '\x2a' >, - Emkb2Qt< Qt::Key_Plus, '\x2b' >, - Emkb2Qt< Qt::Key_Colon, '\x3a' >, - Emkb2Qt< Qt::Key_Semicolon, '\x3b' >, - Emkb2Qt< Qt::Key_Less, '\x3c' >, - Emkb2Qt< Qt::Key_Equal, '\x3d' >, - Emkb2Qt< Qt::Key_Greater, '\x3e' >, - Emkb2Qt< Qt::Key_Question, '\x3f' >, - Emkb2Qt< Qt::Key_At, '\x40' >, - Emkb2Qt< Qt::Key_BracketLeft, '\x5b' >, - Emkb2Qt< Qt::Key_Backslash, '\x5c' >, - Emkb2Qt< Qt::Key_BracketRight, '\x5d' >, - Emkb2Qt< Qt::Key_AsciiCircum, '\x5e' >, - Emkb2Qt< Qt::Key_Underscore, '\x5f' >, - Emkb2Qt< Qt::Key_QuoteLeft, '\x60'>, - Emkb2Qt< Qt::Key_BraceLeft, '\x7b'>, - Emkb2Qt< Qt::Key_Bar, '\x7c'>, - Emkb2Qt< Qt::Key_BraceRight, '\x7d'>, - Emkb2Qt< Qt::Key_AsciiTilde, '\x7e'>, - Emkb2Qt< Qt::Key_Space, '\x20' >, - Emkb2Qt< Qt::Key_Comma, '\x2c' >, - Emkb2Qt< Qt::Key_Minus, '\x2d' >, - Emkb2Qt< Qt::Key_Period, '\x2e' >, - Emkb2Qt< Qt::Key_Slash, '\x2f' >, - Emkb2Qt< Qt::Key_Apostrophe, '\x27' >, - Emkb2Qt< Qt::Key_Menu, 'C','o','n','t','e','x','t','M','e','n','u' >, - - Emkb2Qt< Qt::Key_Agrave, '\xc3','\xa0' >, - Emkb2Qt< Qt::Key_Aacute, '\xc3','\xa1' >, - Emkb2Qt< Qt::Key_Acircumflex, '\xc3','\xa2' >, - Emkb2Qt< Qt::Key_Adiaeresis, '\xc3','\xa4' >, - Emkb2Qt< Qt::Key_AE, '\xc3','\xa6' >, - Emkb2Qt< Qt::Key_Atilde, '\xc3','\xa3' >, - Emkb2Qt< Qt::Key_Aring, '\xc3','\xa5' >, - Emkb2Qt< Qt::Key_Ccedilla, '\xc3','\xa7' >, - Emkb2Qt< Qt::Key_Egrave, '\xc3','\xa8' >, - Emkb2Qt< Qt::Key_Eacute, '\xc3','\xa9' >, - Emkb2Qt< Qt::Key_Ecircumflex, '\xc3','\xaa' >, - Emkb2Qt< Qt::Key_Ediaeresis, '\xc3','\xab' >, - Emkb2Qt< Qt::Key_Icircumflex, '\xc3','\xae' >, - Emkb2Qt< Qt::Key_Idiaeresis, '\xc3','\xaf' >, - Emkb2Qt< Qt::Key_Ocircumflex, '\xc3','\xb4' >, - Emkb2Qt< Qt::Key_Odiaeresis, '\xc3','\xb6' >, - Emkb2Qt< Qt::Key_Ograve, '\xc3','\xb2' >, - Emkb2Qt< Qt::Key_Oacute, '\xc3','\xb3' >, - Emkb2Qt< Qt::Key_Ooblique, '\xc3','\xb8' >, - Emkb2Qt< Qt::Key_Otilde, '\xc3','\xb5' >, - Emkb2Qt< Qt::Key_Ucircumflex, '\xc3','\xbb' >, - Emkb2Qt< Qt::Key_Udiaeresis, '\xc3','\xbc' >, - Emkb2Qt< Qt::Key_Ugrave, '\xc3','\xb9' >, - Emkb2Qt< Qt::Key_Uacute, '\xc3','\xba' >, - Emkb2Qt< Qt::Key_Ntilde, '\xc3','\xb1' >, - Emkb2Qt< Qt::Key_ydiaeresis, '\xc3','\xbf' > + Emkb2Qt< Qt::Key_Menu, 'C','o','n','t','e','x','t','M','e','n','u' > >::Data{} ); @@ -469,29 +341,21 @@ Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent if (it1 != KeyTbl.end() && (qstrcmp(searchKey1.em, it1->em) == 0)) { qtKey = static_cast<Qt::Key>(it1->qt); } - - } else if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0 || - qstrncmp(emscriptKey->code, "Digit", 5) == 0) { - emkb2qt_t searchKey{emscriptKey->code, 0}; // search emcsripten code - auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey); - if (it1 != KeyTbl.end() && !(searchKey < *it1)) { - qtKey = static_cast<Qt::Key>(it1->qt); - } } - if (qtKey == Qt::Key_unknown) { - emkb2qt_t searchKey{emscriptKey->key, 0}; // search unicode key + emkb2qt_t searchKey{emscriptKey->key, 0}; + // search key auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey); if (it1 != KeyTbl.end() && !(searchKey < *it1)) { qtKey = static_cast<Qt::Key>(it1->qt); } } - if (qtKey == Qt::Key_unknown) {//try harder with shifted number keys - emkb2qt_t searchKey1{emscriptKey->key, 0}; - for (auto it1 = KeyTbl.cbegin(); it1 != KeyTbl.end(); ++it1) - if (it1 != KeyTbl.end() && (qstrcmp(searchKey1.em, it1->em) == 0)) { - qtKey = static_cast<Qt::Key>(it1->qt); - } + + if (qtKey == Qt::Key_unknown) { + // cast to unicode key + QString str = QString::fromUtf8(emscriptKey->key); + ushort c = str.unicode()->toUpper().unicode(); // uppercase + qtKey = static_cast<Qt::Key>(c); } return qtKey; @@ -817,7 +681,7 @@ int QWasmEventTranslator::handleTouch(int eventType, const EmscriptenTouchEvent quint64 QWasmEventTranslator::getTimestamp() { - return QDeadlineTimer::current().deadlineNSecs() / 1000; + return static_cast<quint64>(emscripten_performance_now()); } struct KeyMapping { Qt::Key from, to; }; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index d2c22f4100..0e1abaa3be 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2156,6 +2156,7 @@ QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt, QWindowsWindowData result = m_data; result.flags = creationData.flags; result.embedded = creationData.embedded; + result.hasFrame = (creationData.style & (WS_DLGFRAME | WS_THICKFRAME)); return result; } diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 42c7a52bd4..a032085f0b 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -668,7 +668,8 @@ void QXcbCursor::setPos(const QPoint &pos) { QXcbVirtualDesktop *virtualDesktop = nullptr; queryPointer(connection(), &virtualDesktop, nullptr); - xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y()); + if (virtualDesktop) + xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y()); xcb_flush(xcb_connection()); } diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index e8286381a2..98045cdab9 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -60,11 +60,11 @@ Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s) const ret |= Qt::ShiftModifier; if (s & XCB_MOD_MASK_CONTROL) ret |= Qt::ControlModifier; - if (s & rmod_masks.alt) + if ((s & rmod_masks.alt) == rmod_masks.alt) ret |= Qt::AltModifier; - if (s & rmod_masks.meta) + if ((s & rmod_masks.meta) == rmod_masks.meta) ret |= Qt::MetaModifier; - if (s & rmod_masks.altgr) + if ((s & rmod_masks.altgr) == rmod_masks.altgr) ret |= Qt::GroupSwitchModifier; return ret; } diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 707896b457..464d038671 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -114,17 +114,13 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t } auto dpiChangedCallback = [](QXcbVirtualDesktop *desktop, const QByteArray &, const QVariant &property, void *) { - bool ok; - int dpiTimes1k = property.toInt(&ok); - if (!ok) + if (!desktop->setDpiFromXSettings(property)) return; - int dpi = dpiTimes1k / 1024; - if (desktop->m_forcedDpi == dpi) - return; - desktop->m_forcedDpi = dpi; + const auto dpi = desktop->forcedDpi(); for (QXcbScreen *screen : desktop->connection()->screens()) QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen->QPlatformScreen::screen(), dpi, dpi); }; + setDpiFromXSettings(xSettings()->setting("Xft/DPI")); xSettings()->registerCallbackForProperty("Xft/DPI", dpiChangedCallback, nullptr); } @@ -425,6 +421,19 @@ void QXcbVirtualDesktop::readXResources() } } +bool QXcbVirtualDesktop::setDpiFromXSettings(const QVariant &property) +{ + bool ok; + int dpiTimes1k = property.toInt(&ok); + if (!ok) + return false; + int dpi = dpiTimes1k / 1024; + if (m_forcedDpi == dpi) + return false; + m_forcedDpi = dpi; + return true; +} + QSurfaceFormat QXcbVirtualDesktop::surfaceFormatFor(const QSurfaceFormat &format) const { const xcb_visualid_t xcb_visualid = connection()->hasDefaultVisualId() ? connection()->defaultVisualId() diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index bf48dd5d5b..c3a59dc9d1 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -118,6 +118,8 @@ private: QByteArray &stringValue); void readXResources(); + bool setDpiFromXSettings(const QVariant &property); + xcb_screen_t *m_screen; const int m_number; QList<QPlatformScreen *> m_screens; diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index abaeac3bca..3ca793061c 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -74,13 +74,18 @@ Q_DECLARE_METATYPE(sqlite3_stmt*) QT_BEGIN_NAMESPACE -static QString _q_escapeIdentifier(const QString &identifier) +static QString _q_escapeIdentifier(const QString &identifier, QSqlDriver::IdentifierType type) { QString res = identifier; + // If it contains [ and ] then we assume it to be escaped properly already as this indicates + // the syntax is exactly how it should be + if (identifier.contains(QLatin1Char('[')) && identifier.contains(QLatin1Char(']'))) + return res; if (!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"'))) { res.replace(QLatin1Char('"'), QLatin1String("\"\"")); res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); - res.replace(QLatin1Char('.'), QLatin1String("\".\"")); + if (type == QSqlDriver::TableName) + res.replace(QLatin1Char('.'), QLatin1String("\".\"")); } return res; } @@ -905,13 +910,24 @@ static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool only { QString schema; QString table(tableName); - int indexOfSeparator = tableName.indexOf(QLatin1Char('.')); + const int indexOfSeparator = tableName.indexOf(QLatin1Char('.')); if (indexOfSeparator > -1) { - schema = tableName.left(indexOfSeparator).append(QLatin1Char('.')); - table = tableName.mid(indexOfSeparator + 1); + const int indexOfCloseBracket = tableName.indexOf(QLatin1Char(']')); + if (indexOfCloseBracket != tableName.size() - 1) { + // Handles a case like databaseName.tableName + schema = tableName.left(indexOfSeparator + 1); + table = tableName.mid(indexOfSeparator + 1); + } else { + const int indexOfOpenBracket = tableName.lastIndexOf(QLatin1Char('['), indexOfCloseBracket); + if (indexOfOpenBracket > 0) { + // Handles a case like databaseName.[tableName] + schema = tableName.left(indexOfOpenBracket); + table = tableName.mid(indexOfOpenBracket); + } + } } - q.exec(QLatin1String("PRAGMA ") + schema + QLatin1String("table_info (") + _q_escapeIdentifier(table) + QLatin1Char(')')); - + q.exec(QLatin1String("PRAGMA ") + schema + QLatin1String("table_info (") + + _q_escapeIdentifier(table, QSqlDriver::TableName) + QLatin1Char(')')); QSqlIndex ind; while (q.next()) { bool isPk = q.value(5).toInt(); @@ -973,8 +989,7 @@ QVariant QSQLiteDriver::handle() const QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const { - Q_UNUSED(type); - return _q_escapeIdentifier(identifier); + return _q_escapeIdentifier(identifier, type); } static void handle_sqlite_callback(void *qobj,int aoperation, char const *adbname, char const *atablename, diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 9ddca74a1e..ea43cfc826 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -195,10 +195,6 @@ const int QMacStylePrivate::PushButtonLeftOffset = 6; const int QMacStylePrivate::PushButtonRightOffset = 12; const int QMacStylePrivate::PushButtonContentPadding = 6; -const int pushButtonBevelRectOffsets[3] = { - QMacStylePrivate::PushButtonLeftOffset, 5, 5 -}; - QVector<QPointer<QObject> > QMacStylePrivate::scrollBars; // Title bar gradient colors for Lion were determined by inspecting PSDs exported @@ -1247,7 +1243,7 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int } case Button_PopupButton: case SegmentedControl_Single: { - const qreal innerRadius = cw.type == Button_PushButton ? 3 : 4; + const qreal innerRadius = 4; const qreal outerRadius = innerRadius + focusRingWidth; hOffset = targetRect.left(); vOffset = targetRect.top(); @@ -1603,8 +1599,7 @@ QRectF QMacStylePrivate::CocoaControl::adjustedControlFrame(const QRectF &rect) const auto frameSize = defaultFrameSize(); if (type == QMacStylePrivate::Button_SquareButton) { frameRect = rect.adjusted(3, 1, -3, -1) - .adjusted(focusRingWidth, focusRingWidth, -focusRingWidth, -focusRingWidth) - .adjusted(-6.5, 0, 6.5, 0); + .adjusted(focusRingWidth, focusRingWidth, -focusRingWidth, -focusRingWidth); } else if (type == QMacStylePrivate::Button_PushButton) { // Start from the style option's top-left corner. frameRect = QRectF(rect.topLeft(), @@ -1613,8 +1608,6 @@ QRectF QMacStylePrivate::CocoaControl::adjustedControlFrame(const QRectF &rect) frameRect = frameRect.translated(0, 1.5); else if (size == QStyleHelper::SizeMini) frameRect = frameRect.adjusted(0, 0, -8, 0).translated(4, 4); - frameRect = frameRect.adjusted(-pushButtonBevelRectOffsets[size], 0, - pushButtonBevelRectOffsets[size], 0); } else { // Center in the style option's rect. frameRect = QRectF(QPointF(0, (rect.height() - frameSize.height()) / 2.0), @@ -1627,9 +1620,6 @@ QRectF QMacStylePrivate::CocoaControl::adjustedControlFrame(const QRectF &rect) frameRect = frameRect.adjusted(0, 0, -4, 0).translated(2, 1); else if (size == QStyleHelper::SizeMini) frameRect = frameRect.adjusted(0, 0, -9, 0).translated(5, 0); - if (type == QMacStylePrivate::Button_PullDown) - frameRect = frameRect.adjusted(-pushButtonBevelRectOffsets[size], 0, - pushButtonBevelRectOffsets[size], 0); } else if (type == QMacStylePrivate::ComboBox) { frameRect = frameRect.adjusted(0, 0, -6, 0).translated(4, 0); } @@ -3791,11 +3781,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QRect textRect = itemTextRect( btn.fontMetrics, freeContentRect, Qt::AlignCenter, isEnabled, btn.text); if (hasMenu) { - if (ct == QMacStylePrivate::Button_SquareButton) - textRect.moveTo(w ? 8 : 11, textRect.top()); - else - textRect.moveTo(w ? (15 - pushButtonBevelRectOffsets[d->effectiveAquaSizeConstrain(b, w)]) - : 11, textRect.top()); // Supports Qt Quick Controls + textRect.moveTo(w ? 15 : 11, textRect.top()); // Supports Qt Quick Controls } // Draw the icon: if (hasIcon) { @@ -4394,8 +4380,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // line-break the string if it doesn't fit the given rect. It's better to draw outside // the rect and possibly overlap something than to have part of the text disappear. [s.toNSString() drawAtPoint:CGPointMake(xpos, yPos) - withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c, - NSObliquenessAttributeName: [NSNumber numberWithDouble: myFont.italic() ? 0.3 : 0.0]}]; + withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c, + NSObliquenessAttributeName: [NSNumber numberWithDouble: myFont.italic() ? 0.3 : 0.0], + NSUnderlineStyleAttributeName: [NSNumber numberWithInt: myFont.underline() ? NSUnderlineStyleSingle + : NSUnderlineStyleNone]}]; d->restoreNSGraphicsContext(cgCtx); } else { @@ -4943,24 +4931,14 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, = qstyleoption_cast<const QStyleOptionButton *>(opt)) { if ((buttonOpt->features & QStyleOptionButton::Flat)) break; // leave rect alone - if ((buttonOpt->features & QStyleOptionButton::CommandLinkButton)) { - rect = opt->rect; - if (controlSize == QStyleHelper::SizeLarge) - rect.adjust(+6, +4, -6, -8); - else if (controlSize == QStyleHelper::SizeSmall) - rect.adjust(+5, +4, -5, -6); - else - rect.adjust(+1, 0, -1, -2); - break; - } } rect = opt->rect; if (controlSize == QStyleHelper::SizeLarge) { - rect.adjust(0, +4, 0, -8); + rect.adjust(+6, +4, -6, -8); } else if (controlSize == QStyleHelper::SizeSmall) { - rect.adjust(0, +4, 0, -6); + rect.adjust(+5, +4, -5, -6); } else { - rect.adjust(0, 0, 0, -2); + rect.adjust(+1, 0, -1, -2); } break; case SE_RadioButtonLayoutItem: @@ -6389,12 +6367,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, break; #endif case QStyle::CT_PushButton: { - bool isFlat = false; - if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { +if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) if (btn->features & QStyleOptionButton::CommandLinkButton) return QCommonStyle::sizeFromContents(ct, opt, sz, widget); - isFlat = btn->features & QStyleOptionButton::Flat; - } // By default, we fit the contents inside a normal rounded push button. // Do this by add enough space around the contents so that rounded @@ -6409,24 +6384,12 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, // All values as measured from HIThemeGetButtonBackgroundBounds() if (controlSize != QStyleHelper::SizeMini) sz.rwidth() += 12; // We like 12 over here. - - if (controlSize == QStyleHelper::SizeLarge) { - if (!isFlat) - sz.rwidth() -= 12; - if (sz.height() > 16) - sz.rheight() += pushButtonDefaultHeight[QStyleHelper::SizeLarge] - 16; - else - sz.setHeight(pushButtonDefaultHeight[QStyleHelper::SizeLarge]); - } else { - if (!isFlat) - sz.rwidth() -= 10; - if (controlSize == QStyleHelper::SizeMini) - sz.setHeight(24); - else - sz.setHeight(pushButtonDefaultHeight[QStyleHelper::SizeSmall]); - } - if (isFlat) - sz.rwidth() -= 13; + if (controlSize == QStyleHelper::SizeLarge && sz.height() > 16) + sz.rheight() += pushButtonDefaultHeight[QStyleHelper::SizeLarge] - 16; + else if (controlSize == QStyleHelper::SizeMini) + sz.setHeight(24); // FIXME Our previous HITheme-based logic returned this. + else + sz.setHeight(pushButtonDefaultHeight[controlSize]); break; } case QStyle::CT_MenuItem: |