summaryrefslogtreecommitdiffstats
path: root/src/widgets
Commit message (Collapse)AuthorAgeFilesLines
* doc: Update details about QSystemTrayIconShawn Rutledge2022-01-041-5/+5
| | | | | | | | | | | | - StatusNotifierItem is now more widely implemented (but I'm sure the list could be even longer); but Unity is obsolete - XEmbed is nearly obsolete, so list it after StatusNotifierItem - fix the links: it was meant to have friendly anchor text rather than showing the whole URL inline Pick-to: 6.2 6.3 Change-Id: Id81059f9484a8144b6402e74a500edf81d845b65 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Update copyright year to 2022Kai Köhne2022-01-041-1/+1
| | | | | | | Pick-to: 5.15 6.2 6.3 Change-Id: If6f1d6f9f82a601f8e2b6d36650d6e737518aa60 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Deliver context menu event with correct coordinates to widgets in popupsVolker Hilsheimer2021-12-221-1/+2
| | | | | | | | | | | | | | If a popup is open, Qt delivers events to the popup child under the mouse, so we need to correctly translate the local position of the context menu event to that child's coordate system. This is already done correctly for regular mouse events, so use the same logic here. Fixes: QTBUG-99371 Pick-to: 6.2 6.3 5.15 Change-Id: Ief24c755e76d4d1aa2304b06662ed26ae309f684 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtWidgets: auto-test-export private classes, unbreaking ubsan buildsMarc Mutz2021-12-163-3/+3
| | | | | | | | | | | | These classes are used in their respective tests, but since these only seem to access data members, the missing export macro was never detected. UBSan, however, checks the type_info on each access, so it needs the (polymorphic) class exported. Do so (for -developer-builds). Change-Id: I97b41cfb5dd7f1665cdf4f7a819a42fbf0388621 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix item view auto-scrolling during drag'n'dropVolker Hilsheimer2021-12-101-8/+24
| | | | | | | | | | | | | | | | | | | | Amends 71aaf831d175a164b508ce169131a794d55d6fb0, which wrongly assumed that dragMoveEvent will be called and update the dragged position as we scroll the viewport. This is not the case, so we have to do so manually when the view is in DraggingState. Since dragMoveEvent cannot be faked, and since we cannot fake a mouseMoveEvent (it would throw off the drag'n'drop state machine), calculate the new draggedPosition based on old position and the new offset. As with all drag'n'drop, we cannot test this using an auto test. Task-number: QTBUG-96124 Fixes: QTBUG-98961 Change-Id: Ifcfc1a11aa7258ec4610a548a276b4dd4a814590 Reviewed-by: Zhang Hao <zhanghao@uniontech.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix widget gesture grabbingVolker Hilsheimer2021-12-112-6/+11
| | | | | | | | | | | | | | | | | | After 7369c31ca1f446e81eda1c93ba13767ffcd83efe, unaccepted touch points were not grabbed anymore in calls to activateImplicitTouchGrab. However, gesture recognition relies that widgets for which a gesture has been partially recognized grab also unaccepted touch points. Add a parameter to allow the implicit grabbing to take place also for unaccepted event points. Add test case that replays touch events similar to what Squish is doing, and fails without this fix. Pick-to: 6.2 Change-Id: Idb0b20301b1827be57a03013a59043d97c2ee7b6 Reviewed-by: Stefan Gehn <stefan.gehn@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Use find_package(Qt6 REQUIRED COMPONENTS ...) idiomKai Köhne2021-12-092-2/+2
| | | | | | | | | | Using REQUIRED as a prefix instead of suffix works better with OPTIONAL_COMPONENTS, and is also the order in the CMake manual. Task-number: QTBUG-98867 Pick-to: 6.2 Change-Id: I1ab68408b95d8edf06272a3b9fceccd8d8e597fc Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Add unit test for moving of opaque widgetsVolker Hilsheimer2021-12-081-2/+3
| | | | | | | | | | | | | | | Expose QWidgetRepaintManager's data structures so that we can write unit tests, and verify that they are correct after moving opaque widgets (which triggers the accelerated move code path). Improve the compareWidget logic to not rely on screen grabbing (which requires permissions), but instead use QPlatformBackingStore's toImage function, which is faster and more reliable, and also doesn't require us to show the UI we want to grab full screen in order to avoid issues with overlapping windows etc. Change-Id: Iff2ea419f03a390ab6baca26814fef6ff45f7470 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Code tidies: improve variable naming and add const where possibleVolker Hilsheimer2021-12-081-19/+17
| | | | | | | | | Remove obsolete check for valid sourceRect, we never get into the accelerated code path if it's not. Pick-to: 6.2 Change-Id: I872685fca8cba3a09ed856d727d5baafddee161b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Widgets: setTransientParent() when a QMenu is a windowLiang Qi2021-12-082-0/+26
| | | | | | | | | | | | | On some platforms, such as X11 and Wayland with some compositors, QMenu could be a popup window, which should be set a transient parent to get relative position, which is requested by Wayland. Added transientParentWindow() for QMenuPrivate like QDialogPrivate. Fixes: QTBUG-68636 Pick-to: 6.2 Change-Id: I6d8880cb008ecf61a4c005898b38e3953379a13d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableWidget doc: remove wrong comment for itemExpanded()Christian Ehrlicher2021-12-081-3/+0
| | | | | | | | | | Since Qt5.1 (80fa4b6c8ef) expandAll() emits expanded() but within this change, the comment in itemExpanded() was forgotten. Pick-to: 6.2 Pick-to: 5.15 Change-Id: Ic487e5f8999d6af27a4747b861464058faf03889 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix incorrect rendering when moving widget into screenVolker Hilsheimer2021-12-081-1/+1
| | | | | | | | | | | | When the widget we are moving in was previously outside of its parent's clip rect, then we cannot use the accelerated move code path, as there are no pixels to bitBlt from the previous to the new area. Pick-to: 6.2 Task-number: QTBUG-26269 Task-number: QTBUG-98151 Change-Id: I324c6111de27cdd14cf8de8632a980aa351cc123 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Revert optimizations and fixes for moving/scrolling overlapped widgetsVolker Hilsheimer2021-12-072-80/+28
| | | | | | | | | | | | | | | | | This reverts the QtWidgets changes made in commits 22634e00794e72d68e7578e1962f9f2023870749 and 5b09346cf4322704a866f253b911d467c40df3ba while keeping the auto tests introduced in the former commit. Both commits introduced rendering errors when moving widgets out of or into areas in which they are obscured. Before we apply any further optimizations to this code we need thorough auto test coverage. Task-number: QTBUG-98151 Task-number: QTBUG-26269 Pick-to: 6.2 Change-Id: I9cb82b73776daed59ea0e9f51ff7ddef1c7265b6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QListView: fix a broken qBoundGiuseppe D'Angelo2021-12-061-1/+1
| | | | | | | | | | | | | | | | | If a QListView's model is reset to an empty one, its columnCount() below the root is going to be 0. Therefore, the code was doing a qBound(0, d->column, -1) which is meaningless (high < low). Instead, do the two logical operations explicitly: first do an upper bound on d->column (using qMin) and then lower bound the result by 0 (using qMax). The code worked by chance, because 0 was eventually the correct number to use as a bound for d->column. Change-Id: Ic32077cdab01eaa715137c05ed1f9d66c8eb2f67 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QFontComboBox::setDisplayFontAlbert Astals Cid2021-12-032-0/+28
| | | | | | | | | Allows changing the font used to display a font family [ChangeLog][QtWidgets][QFontComboBox] Added the setDisplayFont() function, in order to be able to control the font used to render the font name and sample text (when previewing the fonts). Change-Id: I94bfef43142c5346237e3069449bd19dbacb7420 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Add QFontComboBox::setSampleTextAlbert Astals Cid2021-12-032-21/+80
| | | | | | | | | Allows setting the sample text to be used [ChangeLog][QtWidgets][QFontComboBox] Added the setSampleText() function, in order to be able to control the sample text displayed by the combobox (when previewing the fonts). Change-Id: Iedcd3bb72bc6aec9a178f14f7fbbe324ba0223ef Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QSizePolicy: make qHash() a hidden friendMarc Mutz2021-12-032-5/+3
| | | | | | | | | | | | | | Less noisy compiler error messages. [ChangeLog][Potentially Source-Incompatible Changes][QSizePolicy] qHash() is now a hidden friend and can only be called by unqualified (qHash(sp)), not by qualified lookup (as in, say, ::qHash(sp) or QT_PREPEND_NAMESPACE(qHash)(sp)). Task-number: QTBUG-98863 Change-Id: I37d26c661c2d8bb74350eb9378bd19fa426678d2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Text editing: smart block and char format after newlineShawn Rutledge2021-12-022-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you are editing in a QTextEdit and press enter to start a new line, calling insertBlock() with no arguments tries to preserve the current charFormat and blockFormat. That is often OK: - if you hit enter at the end of a list item, you probably want another item in the same list - if you are writing code inside a code block, you're probably just writing the next statement on the next line: stay in the same block - margins, indents, tab positions should stay the same (but hopefully your editor has UI to manually reset the block format to default in case you are not continuing in the same style) But there are some exceptions we can apply to be helpful: - nobody ever wants to follow an <hr/> with another one (but hopefully the application has an action to insert one manually) - a heading is more likely to be followed by a paragraph, or perhaps a smaller heading; another heading at the same level is unlikely. We need to reset the char format, not only the block format, because the large font and heavy font weight are stored there. - when adding to a todo list, hitting enter at the end of the last task, let's assume the next task is not yet done, so it will be unchecked by default (else, why are you writing a todo list at all) To achieve that, we need to customize the formats and call the insertBlock() overload that takes them. The no-argument insertBlock() will continue to preserve the formats, because it's an old API that is used for much more than interactive editing. Additionally, word processors tend to let you end a list (for example) by hitting enter twice. In that case, you stay in the same paragraph that you created the first time you hit enter, but now the formats are reset to default, so that you can go on typing an ordinary paragraph, rather than having to mouse up to the toolbar to select the paragraph style in a combobox, or something like that. So we now do that: reset both block and char formats after you hit enter on a blank line; but if you then hit enter again, after the block format has been reset, then you will get the actual blank line (empty block) inserted. [ChangeLog][QtWidgets][QTextEdit] Hitting enter at the end of a line with a special block format (horizontal rule, heading, checklist item) now makes some "smart" adjustments to avoid retaining properties that are unlikely to be continued on the next line. Hitting enter twice now resets block and char formats to default. Fixes: QTBUG-48815 Task-number: QTBUG-80473 Fixes: QTBUG-97459 Change-Id: I3dfdd5b4c0d9ffb4673acc861cb7b5c22291df25 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QTableView: correctly toggle column selection when scrolledVolker Hilsheimer2021-12-021-1/+1
| | | | | | | | | | | | | | | | We need to check whether the horizontal header's selection includes the index for the row at the top, rather than for row 0, as the index we check is based on the scrolled position of the header, so would never be included in the top row when the view is scrolled. This is correctly done in selectRow already. Add a test case that simulates selection of rows and columns by clicking on the header. Fixes: QTBUG-98444 Pick-to: 6.2 Change-Id: I2fa1b32bf75dc96225b40145b713bf7e2ffc29dd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix fail to activate first sub window with QMdiArea::TabbedViewZhang Yu2021-12-021-0/+4
| | | | | | | | | | | | | | | | | | | The first sub window added will activate itself automatically, and isActive is set to true. Therefore the call to setActiveSubWindow to activate the first sub window will be ignored. When showing the mdiarea, all sub windows will be activated in the order in which they were added, so the active window will always be the last sub window added. Fix this by setting isActive to false so that setActiveSubWindow activates the first sub window when the mdiarea becomes active. Fixes: QTBUG-92037 Pick-to: 6.2 Change-Id: Id4a793e2059803c1a4ada916fdae2d3cc02cdf06 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTabBar: clamp maxScrollOffset before using it in qBoundGiuseppe D'Angelo2021-12-011-3/+3
| | | | | | | | | | | | QTabBar's test reveals that maxScrollOffset can be negative, so using it in a call like qBound(0, x, maxScrollOffset) is wrong. Clamp it to 0. Change-Id: Idd635343bf14c904dbcc4d141f10bd0161d2cfb4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Never handle scrollbars styled with box or border changes as transientVolker Hilsheimer2021-11-291-0/+10
| | | | | | | | | | | | | | | | If scrollbars are styled with a style sheet that includes a box or removes off the native border, then we never treat them as transient or overlapping. Otherwise, the layout logic in QAbstractScrollArea will show them on top of the viewport, overlapping the content. Add case to the style sheet test baseline test. It's a test for scrollbars in a scroll area, rather than a test for the styling of the scrollbars themselves. Fixes: QTBUG-98289 Pick-to: 6.2 Change-Id: Ic53ad248b3eedd54722ac7b2fe5256a27092dbc1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QObject: Q_ASSERT the object type before calling a PMFThiago Macieira2021-11-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The old-syle signal-slot syntax had the advantage of not delivering signals to slots in derived classes after that derived class's destructor had finished running (because we called via the virtual qt_metacall). The new syntax made no checks, so a conversion from the old to the new syntax may introduce crashes or other data corruptions at runtime if the destructor had completed. This commit introduces a Q_ASSERT to print the class name that the object is not any more. Since this is in inline code, this should get enabled for users' debug modes and does not therefore depend on Qt being built in debug mode. It required some Private classes to be adapted to the new form, by exposing the public q_func() in the public: part. Pick-to: 6.2 Fixes: QTBUG-33908 Change-Id: Iccb47e5527544b6fbd75fffd16b874cdc08c1f3e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QGraphicsItem: Update input context after InputMethod eventJarkko Koivikko2021-11-271-0/+1
| | | | | | | | | | | | Without updating the input context, the input method goes out of sync with the text control. Fix by updating the input context after InputMethod event. Fixes: QTBUG-98544 Pick-to: 6.2 5.15 Change-Id: Idfb99bb0f886249cdab923b8dbed96277800c064 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix and complete style sheet support for QToolButtonVolker Hilsheimer2021-11-261-39/+51
| | | | | | | | | | | | | | | | | | | Amends 2b2e7b2ac50e5b4f6e1888e594f6e32338dd2a80, which rewrote the rendering to remove the conflation of menu arrows and arrow icons, but introduced double rendering of the arrow icons if only the border was styled. Add a baseline test for style sheets, with a test function for QToolButton configured in various ways and styled with different style sheets. The new test case includes a Qt 5 build system so that we can compare Qt 5.15 with Qt 6. Fixes: QTBUG-98286 Pick-to: 6.2 6.2.2 Change-Id: I09cdc829c1a7e7913df4c3768dbe44b6dba4778b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Skip disabled proxy widgets when (back)tabbingAlexander Volkov2021-11-191-1/+4
| | | | | | | Fixes: QTBUG-98137 Pick-to: 6.2 5.15 Change-Id: If52053dce361b130ef7dcfaf747710d8ceb9bbcd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix assert in QFontComboBox when setting empty fontEskil Abrahamsen Blomfeldt2021-11-181-1/+2
| | | | | | | | | | Don't crash if the font does not have any families set. Pick-to: 6.2 Task-number: QTBUG-97995 Change-Id: I8dc2f2fc00309b6fff6d4a661ec6d659f30808af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Always check keyboard modifiers when generating mouse eventsDavid Schulz2021-11-182-4/+1
| | | | | | | | | | | | | | | | | | | | This is basically a revert of: 634ce491e8e943519593140b858eb2e67253c13e The cached keyboard modifier can get out of sync when switching to another application while a modifier is pressed. In this case we get a key press event but we might not get the key release event, which is expected to reset the cached modifier. Switching back to the Qt application after the modifier was released now still has the old modifier cached. Most prominent example is triggering alt + tab to switch to another application and use the mouse to get back to it. In this case the alt modifier is still cached. Task-number: QTCREATORBUG-26581 Pick-to: 6.2 Change-Id: I9d64b7d730af089778bd1a4b3f1296bcccd5d16d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFontComboBox don't response qApp fontDatabaseChanged()Zhang Hao2021-11-161-0/+4
| | | | | | | | | | | | | | | If QFontComboBox is instantiated in the form of new and call QFontDatabase::addApplicationFont, QFontComboBoxPrivate::_q_updateModel() will be called when the program exits, at this time qApp will crash. Fix this by when program exiting, QFontComboBoxPrivate don't need call _q_updateModel(). Fixes: QTBUG-98099 Done-With: Konstantin Ritt <ritt.ks@gmail.com> Pick-to: 5.15 6.2 Change-Id: I3df3d19c3d1971288d60f2eef386262befbf396b Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Make sure we paint overlapped children and siblings when moving farVolker Hilsheimer2021-11-151-11/+13
| | | | | | | | | | | | | | | | | | | | In paintAndFlush, QWidgetRepaintManager subtracts opaque children if the target isn't overlapped and isMoved is set to true. So in moveRect, set isMoved to true after the blitting of movable areas, and reset it to false if we have overlapped sibling or child regions. Otherwise, moving so far that sourceRect is invalid (none of the original pixels are visible after the move) we end up in a code path that sets isMoved to true even with overlapping children or siblings, which then breaks paintAndFlush's assumptions. Reuse the test case written by Sergiy Korobov <tiamatenko@gmail.com> in earlier attempts to fix this bug. Fixes: QTBUG-26269 Pick-to: 6.2 Change-Id: If7443863f5eee79a80220cd587522122f42a21e4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Test result of qobject_cast before dereferencingLi Xi2021-11-151-6/+7
| | | | | | | | | | | | | Since QMainWindow::setMenuWidget accepts a QWidget (allowing users to implement their own menu widget), we need to use qobject_cast on the stored widget to see if it is a QMenuBar before calling QMenuBar APIs. This qobject_cast may return nullptr. Pick-to: 6.2 Fixes: QTBUG-98247 Change-Id: Iff1dbd24fa7ca09098fe49c179770356c966251d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTabBar: Support scrolling with a kinetic wheelVolker Hilsheimer2021-11-151-4/+42
| | | | | | | | | | | | | | | | | | | | | | | QTabBar implements wheelEvent to move the current index up or down. This is useful for clicky mouse wheels, but a bad user experience when using a kinetic wheel or touch pad, as every pixel movement will change the current index. Instead, scroll the entire tab bar when the wheel event comes from a device that supports scroll phases, without changing the current index. As drive-by's, fix the test introduced in aa09bea00ca88c587cfb1f56 to not leak memory or leave a test-specific style set on the QApplication instance, which can break other tests. Also, make relevant layout code in QTabBar respect the usesScrollButtons property, const'ify local variables, and return an accepted QWheelEvent if the event resulted in a change. [ChangeLog][QtWidgets][QTabBar] Scrolling with a kinetic wheel or touch pad scrolls the entire tab bar, without changing the current index. Change-Id: I990e51466dd25c741877bbf0e197449f897a9efb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QLineEdit: always process an input method eventRichard Moe Gustavsen2021-11-121-4/+0
| | | | | | | | | | | | | | | | | | | | | If a line edit is read-only, it only means that the _user_ should not be able to change the text. Qt itself (or the application, by e.g calling setText()) should not have this restriction. For the QPA plugins to be able adjust the current selection from selection handles, we should always process input method events. It's the callers responsibility to ensure that the focus object supports the actions it sends to the focus object (like ImReadOnly, or ImhNoPredictiveText), and not QLineEdit. This patch will therefore remove the check for shouldEnableInputMethod() before processing the event. This will allow us to adjust the selection from the QPA plugin (iOS/Android). Task-number: QTBUG-91545 Change-Id: Id664ac3605a3fa0bf207635ed31d24c045d29a07 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWidget: always handle IM queriesRichard Moe Gustavsen2021-11-121-2/+1
| | | | | | | | | | | | | | | | | A widget (e.g QLineEdit) will set WA_InputMethodEnabled to false if it's read-only. But it can still contain selected text (e.g from a mouse drag). In many cases, it therefore makes sense to be able to query the focus object for what that selection is, e.g to be able to show selection handles from the QPA plugin (iOS/Android). Therefore, remove the check if a widget has WA_InputMethodEnabled, and always process the query. The caller can always check this flag himself (or Qt::ImEnabled) before sending the query, if needed. Task-number: QTBUG-91545 Change-Id: Ia3dfa289283b5c157ba47cf0b508f9fddadd2861 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFileDialog: Fix adding default suffix when file path contains dotAlexander Volkov2021-11-121-3/+8
| | | | | | | | | | Check that a file name, not the full path, contains a dot. Fixes: QTBUG-59401 Pick-to: 5.15 6.2 Change-Id: I193b2ae457a3ac6a460524dbf200786eb3461cef Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QSlider: Always set the sunken state and the active controlVolker Hilsheimer2021-11-111-6/+7
| | | | | | | | | | | initStyleOption should initialize the state based on which controls are pressed or hovered, not only when painting but also when calling other style APIs. Pick-to: 6.2 Task-number: QTBUG-98093 Change-Id: I482793b7de38657aa36a20d0abab8845155ad0e9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QPushButton: emit released signal when mouse dragged out of boundsChunLin Wang2021-11-101-0/+2
| | | | | | | | | | | | After special processing for hover, QPushButton::mouseMoveEvent() needs to call the base class function, like every virtual override should, to continue processing other logic. Amends 3310e13a17d2249a86fa533e350744c5593be54f Fixes: QTBUG-97937 Pick-to: 6.0 6.2 Change-Id: Ic2e111d6c38371e0aa04423f5fb26c52717bf5fb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Avoid painting outside boundaries when printing QGraphicsProxyWidgetEirik Aavitsland2021-11-091-0/+4
| | | | | | | | | | | Implement clipping to widget geometry when rendering to other paintdevices. Fixes: QTBUG-98026 Pick-to: 6.2 5.15 Change-Id: I5652bdb8cc052ae34f05ea7963943d2b5b28e220 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Draw QTableView grid lines centered between table cellsTor Arne Vestbø2021-11-081-3/+5
| | | | | | | | | | | | | | | | We were reserving space between table cells corresponding to one logical pixel, which on retina screen results in two device pixels. By drawing the grid line with a cosmetic pen, we were only filling one of these pixels, leaving space for leftover pixel dust from earlier blits. By drawing with a non-cosmetic pen of size 1, and ensuring that the grid line is drawn at the center of the grid, we end up filling the entire grid line, without overdrawing the table cells. Pick-to: 6.2 Change-Id: I7f4d2b27380e5a3d221e265a25f7531fdc4a02b3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Initialize QStyleOptionProgressBar with QStyle::State_HorizontalZhang Hao2021-11-081-0/+1
| | | | | | | | | | | | | | In Qt 5, QStyleOptionProgressBar::orientation was Qt::Horizontal by default. In Qt 6, we need to init state with QStyle::State_Horizontal so that code setting up a style option doesn't need to do so explicitly. Amends add8262f72befc4c6a25403a21269030111054d1 Pick-to: 6.2 Fixes: QTBUG-93412 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: Iaa311cf0f4bab72c0bacbd8e698ba24660bca6b8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Don't use QCursor::pos in QTabBar and fix hover handlingVolker Hilsheimer2021-11-052-30/+27
| | | | | | | | | | | | | | | | | | | | | | Relying on QCursor::pos makes tests fragile and prevents multi-seat support. Instead, record the mouse position in the already existing event handling, and use that instead. Styles might use either WA_Hover or enable mouse tracking for the widget to enable hover-effects, so we need to support both. Fix the scenario where a newly inserted tab ends up under the mouse, which was previously not handled correctly (only the case of removing a tab was). Clean up the repaint management when the hovered tab changes; just call update on the old rect, and then later update on the new rect; there's no need to make a copy first, updates are posted and compressed. Add a unit test that makes sure that we paint tabs that should be under the mouse in the hovered state. Since not all styles enable hovering and/or mouse tracking in all cases, use a style sheet for those styles that don't. Change-Id: I7cdbb18e9e04b52651e273680fec87b50cb81e05 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* plaintextEdit draw text with clipRect should consider cusorWidthZhang Hao2021-11-051-1/+1
| | | | | | | | | | | If the width of the text to be drawn is equal to the width of clipRect, the cursor will not be displayed. So we need add cursorWidth to the clipRect when draw text. Fixes: QTBUG-94028 Pick-to: 5.15 Change-Id: I8686953f13c04d224327cf0f865ded7241d80ccd Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QAIV: Reset double-click flag in mousePressEventVolker Hilsheimer2021-11-051-0/+1
| | | | | | | | | | | | | | | Amends 17c1ebf8bfd254ff75cc55e335d1c1fb01da547f, which introduced logic that recognizes double clicks to avoid duplicate clicked() emits. If a slot connected to doubleClicked opens a dialog, then the release-event will not be seen by the item view, leaving the flag incorrectly set and preventing the next clicked signal. Fixes: QTBUG-97853 Pick-to: 6.2 5.15 Change-Id: Iced83e8c66a763672f522265435dc52a745227e4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Revert "Code style fix"Richard Moe Gustavsen2021-11-021-37/+45
| | | | | | | | | | | | | | This reverts commit e1d7df5ce9eb1d370e1b6dcd31ced4029082d63d. The offending patch removed handling of page-up and page-down shortcuts in QScrollView (including subclasses like QTextBrowser). Pick-to: 6.2 Fixes: QTBUG-97908 Fixes: QTBUG-90352 Change-Id: If760e983a082edb53e12e1311e2c7f2676d80bb2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io>
* Add QMenu::menuInAction as a static helperVolker Hilsheimer2021-11-012-0/+12
| | | | | | | | | | | | | | QAction::menu is deprecated, as it makes QAction (a QtGui class) depend on QtWidgets. The template hack works, but shouldn't become a permanent solution and is already deprecated. To get the QMenu out of a QAction that contains it, add a static helper to QMenu instead. QAction continues to store the menu pointer so that we don't have to use a dynamic property or an associative container in QMenu. Change-Id: Ieb6a2b1900d2fc2f16dd5a4a8ab7da98604642d3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qtbase: remove last piece of DwmIsCompositionEnabledYuhang Zhao2021-11-021-20/+2
| | | | | | | | | | | | | DWM composition is always enabled and can't be disabled since Windows 8 [1]. As a drive-by, remove an old workaround for MSVC 2012, which is not supported by Qt6. [1] https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled Change-Id: I2ec055d794c91d69c141dca7cec80beb9468628c Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Fix performance regression when avoiding scrollbar flippingVolker Hilsheimer2021-10-291-4/+7
| | | | | | | | | | | | | | | | | | | | | | Amends 6c4dc722cb9bf765904feefff4fb00bdb0b3dc9f. Don't search for the optimal size of the scrollarea's widget if it can't be found anyway. Try the size with scrollbar first, which covers the vast majority of sizes. Optimizing the loop with e.g. a binary search adds no value, as the size is often just a pixel too small. Since we can't rely on the number of height-for-width calls, we can't meaningfully test this behavior. The number of calls is still very high during showing and resizing; optimizing this further is for a separate commit. Fixes: QTBUG-97811 Pick-to: 6.2 5.15 Change-Id: If145302e6414b32cf1ce7251ff33b0039f584867 Reviewed-by: Jonas Kvinge <jonas@jkvinge.net> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fusion: Consistent width calculation and rendering of menu itemsVolker Hilsheimer2021-10-271-39/+45
| | | | | | | | | | | | | | | | | | The width calculation lacked the addition of the windowItemFrame constant, which was added in the rendering code. This resulted in ellision for long items. To make the code easier to follow, const'ify, rename, and reorder some local variables, and use constants from QFusionStylePrivate instead of (now obsolete and removed) constants copied from the Windows style. Break long lines as a drive-by. Fixes: QTBUG-94481 Pick-to: 6.2 Change-Id: I6d3e9d0feebee58fc70beaaf29236b8473242083 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Calculate effect bounds when drawing widget graphics effectAntti Määttä2021-10-271-4/+5
| | | | | | | | | | | | | Calculate effect bounds for the updated region when drawing the effect so that the whole affected area gets updated. The effect bounds have already been added to the region so it doesn't need to be handled in the drawing function. Pick-to: 6.2 5.15 Fixes: QTBUG-96240 Change-Id: I0c317311622e6299fb1a3015541408d1d83c93de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTabBar: re-layout when tab size hint depends on selected stateVolker Hilsheimer2021-10-261-0/+7
| | | | | | | | | | | | | | | | | QTabBar caches the rects for the tabs to avoid costly recalculation of each tab's size hint. That cache is only updated via layoutTabs if the entire tab bar is resized or modified. However, when a style sheet is set that calculates a different size hint for tabs that are selected, then the tab bar also needs to be laid-out when the current tab changes. To minimize the cost, compare the cached size for the new current tab with its new size hint, and re-layout the tabs when they are different. Fixes: QTBUG-6905 Fixes: QTBUG-8209 Pick-to: 6.2 Change-Id: I110444d18938c2b3446ee58e4a8c6c472b5f12c3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>