summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Fix indentation in inputMethodQuery implementationsTor Arne Vestbø2021-10-182-4/+4
| | | | | | Change-Id: I406194e084f62f16d432eae63845bcc3da148ac0 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix restoring main window state for maximized/fullscreen windowsVolker Hilsheimer2021-10-164-50/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On systems that asynchronously resize the window to maximized or full screen state, the window will become visible in its normal geometry before it gets the final size by the windowing system. This might cause multiple resize events, to each of which the widget's layout responds with a call to its setGeometry implementation. The QMainWindowLayout is special in that it will shrink dock widgets if there is not enough space for them, but it doesn't grow them back once there is. With the initial resize event being for a smaller size than what was restored, the state is not restored correctly, but remains in the state that fit into the smallest size with which setGeometry got called. To fix this, we have to keep the restored state around until the window either gets a size that is large enough for it to fit, or until we can be reasonably certain that the windowing system is done resizing the window while transitioning it to the maximized or full screen state. Since across the various platforms and windowing systems there is no reliable way to know when the window reaches its final size, we have to use a timer that we (re)start for each call to setGeometry with a size that's not large enough. Once the timer times out, we have to give up; then the last layout state calculated is the final state. To calculate the size of the layout, introduce a function to the QDockAreaLayout that returns the size required for the current sizes of the docks. Refactor sizeHint and minimumSize (which were identical) into a helper template that takes member-function pointers to call the respective method from the dock area layout's content items. Add a test case for various permutations of the scenario. The timeout of 150ms is based on running this test case repeatedly on various desktop platforms and X11 window managers. Fixes: QTBUG-46620 Change-Id: I489675c2c40d3308ac8194aeb4267172b2fb38be Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* widgets: Fix typos in source code commentsJonas Kvinge2021-10-159-11/+11
| | | | | | Pick-to: 6.2 Change-Id: I22f71a53b0f7f0698450123343e25548c889c3e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Take overshoot into account when laying out QAbstractScrollAreaVolker Hilsheimer2021-10-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | QAbstractScrollAreaPrivate::layoutChildren() positions the viewport, but did not take the overshoot from scrolling with a scroller into account. If the scroll area was resized during a scroll, then this resulted in the roll back overcompensating for the overshoot, placing the viewport outside the visible area. Fix this by taking the overshoot into account when positioning the viewport. Add a test case. We have to use QWindow-based mouse event simulation, as the QWidget based move events use QCursor::setPos, which doesn't reliably go through the gesture framework. Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-with: Zhang Hao <zhanghao@uniontech.com> Fixes: QTBUG-94769 Pick-to: 5.15 6.2 Change-Id: Idf650c91e5a9cffa996e23e743939243b1d4fcc0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* widgets: Fix typos in documentationJonas Kvinge2021-10-1213-17/+17
| | | | | | Pick-to: 5.15 6.2 Change-Id: I6b77f0ec043d08da3b7958d780dce9595daf97a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Reduce the width of a hfw-widget if scrollbar would be flippingVolker Hilsheimer2021-10-111-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | For a widget that implements height-for-width, the vertical scrollbar becoming visible might be just enough to make the scrollbar unnecessary. In that situation, the scrollbar flips on and off continuously. To avoid that situation, make the width of the widget smaller until the height fits without scrollbar, up to the point where we have space for the scrollbar anyway. The calcuation here is assumed to be cheap, but depends on the heightForWidth implementation in the widget. Running the while-loop a few dozen times should have no performance impact during resizing and laying out the scroll area contents. Add a test that confirms that within a brief period of time we only get the one hide-event we expect. Done-with: Zou Ya <zouya@uniontech.com> Fixes: QTBUG-92958 Pick-to: 6.2 5.15 Change-Id: I0faeb5f9b1a226aada958c18333d9c2ac8203dd1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix QTabBar's SelectPreviousTab behaviorQiang Li2021-10-091-2/+3
| | | | | | | | | | | | | | When setCurrentIndex is called by removeTab, the old current index might no longer be valid. Only update the lastTab value of the new current tab if the old current index is still valid. As a drive-by, use the validIndex helper function. Fixes: QTBUG-94352 Pick-to: 6.2 Change-Id: I945e2093a90a1fccbba86d32b1113f83fedd41de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add style hint for preventing spin box selection on up/downVolker Hilsheimer2021-10-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | On a mobile device, selecting text in a line edit brings up the text action popup for select/copy/cut. In a spinbox where the user changes the value using the buttons, this can be very irritating, without providing any usability - the user is unlikely to start typing, at least not without first transferring focus into the lineedit first to bring up the keyboard. This style hint allows styles to override the default behavior of QAbstractSpinBox. Implement the customization for the Android style, and add a test case for QSpinBox. [ChangeLog][QtWidgets][QStyle] A new style hint, SH_SpinBox_SelectOnStep, specifies whether pressing the up/down buttons or keys in a spinbox will automatically select the text. Fixes: QTBUG-93366 Change-Id: If06365a7c62087a2213145e13119f56544ac33b5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix handling of grouping characters when validating doublesEdward Welbourne2021-10-071-12/+16
| | | | | | | | | | | | | | | | | | | In QDoubleSpinBoxPrivate::validateAndInterpret() some code still assumed checking one entry in a QString is enough (it isn't - the grouping separator may be a surrogate pair) and nothing considered the case of an empty grouping separator (as can arise if the user sets that in their system configuration, as a brute-force way to suppress digit-grouping). Failure to consider this case failed an assertion on dereferencing the first character of the separator. Handle the case of empty separator and suppress tests that try to match a separator, when there is no separator. Pick-to: 6.2 Fixes: QTBUG-96734 Change-Id: I63d3205ef8656a2cd2c0d855a25e712ad66e2429 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Refactor QStatusBar to reduce memory allocationVolker Hilsheimer2021-09-071-80/+62
| | | | | | | | | | | | | | | | | | | Reading through the code contemplating what might have caused QTBUG-89141 brought up some opportunities for improvement. * updated coding style and variable names * use ranged for where possible and meaningful * replacing a QList of pointers to heap-allocated structs with a list of values Since the QList population code makes sure that we never have gaps (we only insert within the existing range), the test for null-entries is not needed, and was perhaps just precausion to avoid nullptr dereference. Task-number: QTBUG-89141 Change-Id: I4694d820427a221f1334d2428f50069751919aef Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-013-5/+5
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QToolButton: reimplement the fix for QTBUG-95255Giuseppe D'Angelo2021-08-272-7/+10
| | | | | | | | | | | | | | | | | The code in 188d739400e10fc8571bbf2ec86d5cd338b04a5d uses a connect() to a lambda, passing UniqueConnection to avoid establishing the connection more than once. The problem is that UniqueConnection does not work with lambdas; it works only with "regular" PMFs to QObject subclasses. Re-do the same fix, but without a connection: use the checkStateSet() virtual from the base class that will notify us if setChecked() is being called on the tool button, and from there synchronize the state of the default action. Change-Id: Id512812c562cd6d20bc1a489753b33c269919d32 Fixes: QTBUG-95255 Pick-to: 6.2 6.1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLineEdit: account for the placeholderText when computing lineRectZhang Hao2021-08-231-3/+10
| | | | | | | | | | | | | | | If in a QLineEdit the placeholderText uses e.g. Tibetan language, then the height of font as reported by QFontMetrics might be less than the height of the boundingRect calculated for the placeholderText. This can cause the placeholderText to display incompletely. Fix this by using QFontMetrics::boundingRect instead of QFontMetrics::height when computing lineRect. Fixes: QTBUG-95341 Pick-to: 5.15 6.1 6.2 Change-Id: I9eef35fd89c5c1d79f6dd703355634d6905ca967 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove unnecessary type conversionZhang Qipeng2021-08-201-1/+1
| | | | | Change-Id: I3d1b998b84753706ee78ecb5e498f70e9f935fd5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Report ImAbsolutePosition for QLineEditTor Arne Vestbø2021-08-181-0/+1
| | | | | | | | | | | ImAbsolutePosition was added in f8dbed12266c42785c1e4758eed05833ec035f33, based on requirements on Android, but without an implementation for QLineEdit. It would seem sensible to fall back to the cursor position in this case, as QLineEdit doesn't support multiple blocks. Pick-to: 6.2 Change-Id: Iff1255270ceef069f03ce457df633d7b675f1a28 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTabBar: don't overwrite data, fix refactoring error for vertical tabsVolker Hilsheimer2021-08-181-1/+1
| | | | | | | | | | | | | | | | | | | Amends 359616066e64eed947c6c91cb8902285ed79dd0d, which incorrectly changed - tabList[i].minRect = QRect(0, miny, sz.width(), sz.height()); + tab->data = QRect(0, miny, sz.width(), sz.height()); in the code laying out verticals tabs (correct done for the horizontal case). Since QDockWidget uses the user data for tabs to maintain the mapping between tabs and dock widget, this broke the layout logic. Fixes: QTBUG-95841 Pick-to: 6.2 6.1 Change-Id: Ie785e1205b426bbc4954b965f619f4c603490f76 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStyle: allow styles to control the margin around icons in QLineEditWang Peng2021-08-171-1/+1
| | | | | | | | | The styles can't control the margin of the icon container, and its value is hardcoded to a quarter of the iconSize, which is very unfriendly. Add a PixelMetric enum value to allow styles to control the margin. Change-Id: I21274b68d24150db7be78513fe9125f775aa2b00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCompleter: QCompleter unexpectedly changes QLineEdit textTianlu Shao2021-08-101-0/+1
| | | | | | | | | | | | | | | When qcompleter and qlineedit are used together, the currentcompletion() of qcompleter is its first item by default. Therefore, when qlineedit makes the initial value, then selects the text and enters, qcompleter will modify the default first item to qlineedit text. The judgment that completionprefix() of the completer is not empty is modified and added here, because completionprefix() is always empty when there is no match. Fixes: QTBUG-20894 Pick-to: 6.2 6.1 5.15 Change-Id: Id47f7f4da0a93d03a4e7b056ec731615b0803d13 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tianlu Shao <shaotianlu@uniontech.com>
* Document that hiding/disabling a menu is best done via the menuActionVolker Hilsheimer2021-08-101-1/+3
| | | | | | | Task-number: QTBUG-95072 Pick-to: 6.2 Change-Id: I83afe13b129a35b39c62abe553061cc4a390fd65 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Allow dragging of a floating dockwidget on macOS with a custom titlebarAndy Shaw2021-08-021-1/+1
| | | | | | | | | | This amends 3224c6d7d150164241c13ccf7d47377a39c0a6bb to account for the case when the dockwidget is already floating. Task-number: QTBUG-70137 Pick-to: 6.2 6.1 5.15 Change-Id: If8b345565b11b44beb3fb4b697cfe812c29c6396 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QMenuBar: remove addAction() functionsMarc Mutz2021-07-282-93/+3
| | | | | | | | | | | They're now in QWidget itself. Remove them from the API, but not the ABI. [ChangeLog][QtWidgets][QMenuBar] The addAction() functions have been moved down into QWidget. Change-Id: Iaa023ff227686e8e67a2b5594f0fbc31b95177a3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: clean up API removalsMarc Mutz2021-07-273-104/+2
| | | | | | | | | | | As suggested by Peppe and Lars, use one file per module to hold the removed functions, not one per major version and subdir. Also, make the remove macro more like QT_DEPRECATED_SINCE. Change-Id: I2ade51ccc8cb8720ece493936775dfd3b5d438d7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMenu: actually deprecate all trailing-shortcut addAction() overloadsMarc Mutz2021-07-231-0/+4
| | | | | | | | | | The templated ones were forgotten. Amends 09d1196281ccd03dac55781ac91f6c4eb7bb4de9. Change-Id: I042f25be814fc38e681acfe655124a66e78a1045 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Sync default action when checking tool button programmaticallyVolker Hilsheimer2021-07-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | QAbstractButton::setChecked is not virtual, so QToolButton cannot override to synchronize the default action's checked state. This resulted in button and default action not being in sync when the checked state of the button was changed programmatically, while changing the checked state on the action kept the button in sync. Connect to the button's own toggled signal instead to keep the state of the default action in sync. Make it a unique connection to allow multiple calls to setDefaultAction, which are used by QToolButton to keep the button updated if properties of the default action change. Add a test that confirms that button and action are synchronized both ways, and that we only get single signal emissions when changing either programmatically. Fixes: QTBUG-95255 Pick-to: 6.2 6.1 Change-Id: I0e027faf1da763ef1878e46e85bfa70073c8bf82 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Always update the input method when QLineEdit receives focusTang Haixiang2021-07-201-0/+3
| | | | | | | | | | | | | | | The line edit receiving focus might require different input method capabilities (e.g. be a password edit), so the input method needs to be refreshed when focus is received. This implicitly happens on tab focus when the text is selected or the cursor is moved within an input mask, but neither of those might happen, and for click-focus it never happened. Fixes: QTBUG-86846 Pick-to: 5.15 6.1 6.2 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I47c5275d3a9d4d190ebce64269a345431346c17c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMenu/QToolBar: remove addAction() functionsMarc Mutz2021-07-135-332/+166
| | | | | | | | | | | | | | | | | | | | They're now in QWidget itself. Remove them from the API, but not the ABI. The QToolBar case is straight-forward. QMenu is a bit more complicated: Since QT_CONFIG(shortcut) builds changed the signature of an existing function instead of adding/removing an overload, we have to deal with two cases: In a QT_CONFIG(shortcut) build, these overloads that take a trailing QKeySequence parameter have been deprecated and therefore cannot be removed. In a !QT_CONFIG(shortcut) build, the same functions are 1:1 copies of QWidget functions and can be removed (from the API). [ChangeLog][QtWidgets][QMenu/QToolBar] The addAction() functions have been moved down into QWidget. Change-Id: I49997b3440c137a1d4e3858d1d27d34a191e1eed Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QLineEdit: don't change layout direction on keyboard inputVolker Hilsheimer2021-07-131-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QLineEdit was the only widget in Qt that flips the widget's layout direction if a key press changes the document's layout direction. This resulted in inconsistent behavior: setting text to RTL content programmatically didn't set the widget's layout direction to RTL, but the first key press (even if just a cursor key or a latin1 character) did. Clearing the text with keyboard shortcuts changed the layout direction, doing the same using the clear button or context menu actions didn't. In addition, the automatic changing overrode whatever the UI developer set, or what Qt detected as the global layout direction based on the active translation. Remove the automatic flipping. [ChangeLog][QtWidgets][QLineEdit] QLineEdit used to change the layout direction on each key press, based on the text content. This feature resulted in an inconsistent and erratic user experience, and has been removed. Fixes: QTBUG-95011 Pick-to: 6.2 Change-Id: Ib653350d35e25ce431cca1abe9b45bdf33d035fe Reviewed-by: Fan RuiJie <fanruijie@uniontech.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QObject: optimize the common case of findChildren(QString())Marc Mutz2021-07-132-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Outside tests, all in-tree callers of QObject::findChildren() pass no name to match, and in my experience that is also true for the vast majority of out-of-tree users. Avoid the temporary QString creation in the caller and the repeated QString::isNull() checks in the implementation by overloading findChildren() without a name argument and checking for name.isNull() only once, forking off into separate helper functions. Adjust in-tree callers that used an explicit `QString()` argument in order to pass options, which goes to show that `name` should never have been the first argument of findChilden() in the first place, even though I appreciate the symmetry with findChild() (the use-cases of which, however, are radically different). Change a `findChildren().size() == 0` call found while scanning for findChildren() calls to `!findChild()` as a drive-by. Modernize loops in the various qt_qFindChild{,ren}_helper() overloads to match how the new code looks. [ChangeLog][QtCore][QObject] Added findChildren() overload taking no name (thus optimizing this common case). Change-Id: Ifc56e5438023d079b40c67f11ae274a3e128ad5e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix placement of placeholder text in QLineEdits with action iconsVolker Hilsheimer2021-07-062-5/+9
| | | | | | | | | | | | | | | | | | | | After dc794f7622bc00f7ca50fab65d6965695d6d2972, side widgets only got space if they were not fading out, but the logic was not correctly accounting for side widgets that never fade, such as buttons added via QLineEdit::addAction. Fix this to give visible widgets space, unless they are fading out. That was the intent of the original change. Rename the variable to make its purpose clearer, and reset it at the end of the fade-out animation. Add a much-needed test that relies on private APIs to verify that the effective margins are calculated correctly. Fixes: QTBUG-94824 Pick-to: 6.2 6.1 5.15 Change-Id: If2ee6be52be9e4f9be1e91f72f27681ce27def6d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Consistent indentation for all Q_PROPERTYsAndreas Buhr2021-06-2412-17/+34
| | | | | | | | Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I8c97a0b2de2bed78456322be271724fc47479d83 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use On icon for pressed dock widget title buttons without frameVolker Hilsheimer2021-06-241-2/+4
| | | | | | | | | | | | | | | The QCommonStyle provides explicit pixmaps for the SP_TitleBarCloseButton and SP_TitleBarNormalButton, but never showed the "down" pixmap on macOS because the button has no frame, so the On state flag was never set. Set the style states so that the "down" pixmap is used on a button that is either pressed or checked if it doesn't have a frame. Since QIcon only has two states, use the "On" state for both pressed and checked. Pick-to: 6.2 Task-number: QTBUG-38776 Change-Id: Ic04070196b97a4fb66d7a2669e9894fd7960230e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use UTC when parsing only a date or only a time, not a date-timeEdward Welbourne2021-06-232-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | This should reduce the amount of fall-out from DST complications. Also document the assumptions of QDateTimeParser's two fromString() methods (and fix the punctuation on the QDateTime parameter). Adjusted some tests to match. Since only QDateTime-returning methods will show the difference, and it's at least somewhat odd to be using those on QDateEdit or QTimeEdit, this should have little impact on API users. [ChangeLog][QtCore][Behavior Change] QDateEdit and QTimeEdit now operate in UTC, to avoid spurious complications arising from time-zone transitions (e.g. DST) causing the implicit other half to combine with the part being edited to make an invalid result. Returns from their dateTime() and other methods returning QDateTime (max/min) shall thus be in UTC where previously they were in local time. QDateTimeEdit continues using local time. The default can be over-ridden by setTimeSpec(), as ever. Change-Id: I44fece004c12342fe536bbe3048217d236fd97b2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of day-of-week in QDateTimeParser and QDateTimeEditEdward Welbourne2021-06-231-7/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDTP's absoluteMax(), setDigit() and getDigit() simply treated day-of-week as synonym for day-of-month. Consequently, QDTE::stepBy() did the same. This meant that wrapping happened at the month boundary, so would jump within the week if it wrapped around, otherwise the up/down arrow would "jam" at a particular day of the week when further steps would leave the month. Instead, when wrapping, wrap round the week while still moving the day-of-month to match, jumping back or forward a week to stay within the month on hitting a month boundary; otherwise, stop backwards stepping on hitting the locale-specific day of the week, or forward stepping when the step would be to or past this first day. Fixed various bugs found in the course of testing this. [ChangeLog][QtWidgets][QDateTimeEdit] Corrected handling of weekdays. Previously, changes to the week-day were simply changes to the day of the month. Weekday fields are now handled as such: changes to them do change the day of the month, but a change that would step past the end (or start) of the month is adjusted to the relevant day of the nearest week within the month. When wrapping is disabled, the locale-specific first and last days of the week are the bounds. Formats which specify day of week but not day of month will now preserve day of week when changing month or year, selecting the nearest day of month that matches. Change-Id: I7868b000fea7a4bc17a1b5687c44bcd56d42ae90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: close visible gap between tab bar base line and tabsVolker Hilsheimer2021-06-111-1/+1
| | | | | | | | | | | | | | | | Dock widgets enable the QTabBar::drawBase property, but the clip region left a gap of 3 pixels on each side between the base line and the tabs. Correct the size of the hole cut into the clip region accordingly. Visually tested on macOS 10.15.7 and macOS 11.2.1 using the dockwidgets and tabdialog example. As a drive-by, fix a spelling mistake in related documentation. Fixes: QTBUG-86362 Pick-to: 6.2 6.1 Change-Id: Iada027999467741d0590576ee4508e6f41fb056d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QTabBar: don't let tab shine through (semi-transparent) scroll buttonsVolker Hilsheimer2021-06-091-0/+14
| | | | | | | | | | | | | | | On styles where the tab bar's scroll buttons are rendered semi- transparently, or where the buttons don't fill their entire rect (for example have rounded edges), the tab that's covered by the buttons should not shine through the gaps, or even shine through the button. Clip the painter so that the area of each button is not painted by the tabs. Fixes: QTBUG-50866 Pick-to: 6.1 6.2 Change-Id: Ie81f6d260f36d5a17868822e683745844a6a6b2f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix scrolling of tab bar when the visible tab is wider than the visible spaceVolker Hilsheimer2021-06-091-4/+9
| | | | | | | | | | | | | | When finding the index we need to scroll to, use the one where both start and end of the tab rect are outside the currently visible section. Otherwise we wouldn't scroll when the left-most index ends outside the visible section. Add test, which requires that the scroll buttons have object names. Fixes: QTBUG-70498 Pick-to: 6.2 6.1 5.15 Change-Id: Id153c77dd5fca146612375e0ff39bd1f3e0536b1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Add a note about a limitation in QDockWidget on macOSAndy Shaw2021-06-081-0/+5
| | | | | | Pick-to: 6.1 5.15 Change-Id: I3599304d2dab9a6e64f110644b22e65494f3c0a8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* macOS: allow Qt::AA_DontShowShortcutsInContextMenus overridesVolker Hilsheimer2021-06-072-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Following the discussion in QTBUG-69452, the resulting change in cc33dd079796437bafed8f42de7fbf8f17d19ec8, and the documentation of QAction::shortcutVisibleInContextMenu, the intention is that the attribute allows the overriding of the platform default. However, QAction did ask both the attribute and the platform integration, making the override impossible. Instead, ask only the attribute, but default the value of the attribute to what the platform integration provides. [ChangeLog][QtGui][QAction] The shortcutVisibleInContextMenu property defaults to the value of the Qt::AA_DontShowShortcutsInContextMenus attribute, which in turn defaults to the platform integration. To override the default, set the application attribute after instantiating QApplication, or override the default for each QAction instance. Task-number: QTBUG-73990 Pick-to: 5.15 6.1 Change-Id: Iaba330913555d93d05efe1b3965a6aea39db5554 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Clarify the QLineEdit document of editingFinished signalZhang Hao2021-06-071-1/+2
| | | | | | | | | | | | QLineEdit gets focus and don't type any character when QLineEdit lost focus, document say QLineEdit will issue editingFinished signal. In fact,QLineEdit doesn't issue editingFinished signal. Fix this by clarify the document. Fixes: QTBUG-94057 Pick-to: 6.1 Change-Id: I88eed2ec7a28823598dc46f1df26fd305eb99c1f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix misplacement of placeholder text in QLineEdit with RTL contentFan RuiJie2021-06-042-3/+13
| | | | | | | | | | | | | | | | | | | | | | | The placeholder text was rendered in the wrong position after clicking on the clear button in a QLineEdit with right-to-left content. The button was still taking up space while it was fading out, so the first paintEvent rendered the placeholder with space reserved for the clear button. Once the button gets hidden, no new update was issued, so garbage was left behind. Fix this by not giving a fading-out clear button any margin space. The result of this is that the placeholder text is visible underneath the fading-out clear button. This is preferable to the placeholder text being first rendered next to the fading-out clear button, and then popping to the edge when the clear button is hidden (which would have been the result of issuing a complete update for the line edit at the end of the fade-out animation). Fixes: QTBUG-93742 Pick-to: 6.1 6.0 5.15 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: Id0429362a60bba6839aa02068b00edb15e3ab8ab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QDateTime{Parser,EditPrivate}: clean up initializationEdward Welbourne2021-06-032-19/+7
| | | | | | | | Initialize members by assigning them where declared, where possible, rather than duplicating initializations in constructors. Change-Id: I35c398581ad649210aaec979ea7c6c2fc2cb0bca Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix copy-and-paste bug in QDTEP::getMaximum()Edward Welbourne2021-06-031-2/+2
| | | | | | | | | It had a copy of a line from getMinimum(). The results were predictably broken. Pick-to: 5.15 6.1 Change-Id: I3582edb08696bec4311f43fc426f7e54dc069f53 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QWidgetTextControl: ignore GroupSwitchModifier for BackSpaceIgor Kushnir2021-05-311-1/+1
| | | | | | | | | | | | | | | | | "The keypad and group switch modifier should not make a difference" when matches a QKeySequence, see QKeyEvent::matches() implementation. Qt(xcb) treats AltGr as GroupSwitchModifier in hard code, which should come from Qt 4 era. Nowadays, with different xkb setups, Mode_switch could be different keys. When it is AltGr, Qt will get AltGr as GroupSwitchModifier. When it is not AltGr, another key like Less/Greaterkey(details in bug report), GroupSwitchModifier will not be set in the case. Fixes: QTBUG-36565 Pick-to: 5.15 6.0 6.1 Change-Id: I7251963d41a70d61800d25e43d5012b859693f69 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Make the code format more standardizedXiao YaoBing2021-05-311-1/+1
| | | | | Change-Id: I33fa0800df2dd3cfd525c27234dc6fbd46fd1e9b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* doc: Fix typo in setViewportMargins() docsWenTao Song2021-05-301-1/+1
| | | | | | | | There was a duplicated word in the api documentation. Fixes: QTBUG-94073 Change-Id: I1344a89aa579be5272a44831daa9451eb8030431 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QComboBox: propagate style change on widget to internal containerVolker Hilsheimer2021-05-312-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | When changing the style of the combobox, the change will not propagate to the internal container widget, so the changeEvent handler won't be called. This is correct (as per QWidget::setStyle documentation). QComboBoxPrivateContainer asks the combobox style for relevant settings, such as the frame style, which is then used for sizing and positioning. If the combobox's and container's settings become inconsistent, then the combobox popup will not get the correct size and/or position. Move some of the style-dependent changes into a separate function and call it when the QComboBox::changeEvent handles the style change so that both widgets have a consistent set of settings. Add a test case that verifies that the style is asked for the relevant setting when the style changes. Note: QComboBox does a lot of style-dependent setup work in different places, which is quite messy and complex. Trying to consolidate that further breaks tests though, so this change is doing the minimum necessary to fix the reported issue. Pick-to: 6.1 5.15 Fixes: QTBUG-92488 Change-Id: Ia957d504b2d800add26fc0565be727b5c08a5358 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QComboBox: add space for scrollbar if needed after showing popupVolker Hilsheimer2021-05-311-6/+13
| | | | | | | | | | | | | | | | | QComboBox tests if a horizontal scrollbar is needed before sizing and showing the popup, but QListView only knows whether a scrollbar is needed only after laying itself out during the initial show and paint event. So test whether the need has arisen as part of this initial layout, and then provide the additional space. Resizing the widget after showing it is not ideal, but in practice makes no visible difference (and it's either way preferable to not being able to access the item covered by the scrollbar). Pick-to: 6.1 5.15 Fixes: QTBUG-93736 Change-Id: I0bf077e18116ce174ae7f9218cb3b0dfa82964e1 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Partially modified to use C++11 standard nullptrXiao YaoBing2021-05-272-2/+2
| | | | | Change-Id: Ibfd76357ceb56b347afe7122fc252b866b21cb11 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-2/+2
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDockWidget, macOS: don't drag on native widgetsRichard Moe Gustavsen2021-05-121-4/+18
| | | | | | | | | | | | | | | | | | | | | | | When using native dock widgets on macOS, it will currently fail if you try to drag on a dock widget inside QMainWindow to make it floating. The reason is that the drag will basically start as as drag inside one NSWindow (QMainWindow), but continue as a drag on another NSWindow (QDockWidget). And this is not handled well by AppKit, especially since the NSView where the drag was started is reparented into a new NSWindow (the floating QDockWidget) while the dragging is ongoing. And there seems to be no practical solution to how we can support this from the cocoa QPA plugin This patch will therefore change the logic in QDockWidget to simply make the dock widget floating if you drag on it, rather than actually starting a drag (but only for the described case). Pick-to: 6.1 5.15 Fixes: QTBUG-70137 Change-Id: Ic309ee8f419b9c14894255205867bce11dc0c414 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>