summaryrefslogtreecommitdiffstats
path: root/src/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Move overrideCursor() from QApplication to QGuiApplicationSze Howe Koh2021-06-191-3/+3
| | | | | | | | The transfer occurred in Qt 5 Pick-to: 5.15 6.1 6.2 Change-Id: Id3428809d89c804112d9dc02f2a476cb03bd2c98 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Do not alter a widget's backing window's format once createdLaszlo Agocs2021-06-181-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing anything on a QWindow's QSurfaceFormat has zero and null effects once the underlying native window has been created. Letting QWidget update the format is wrong in this case, because we always expect that the value returned from QWindow::format() reflects reality. (reality being the settings with which the underlying native resource was created, which is typically frozen after QWindow::create(), not the state of some QWidget attribute. There are certain exceptions to this, such as when preparing to recreate the underlying native window, in which case one will want to update all relevant fields of the format based on the current values of the widget attributes, which is exactly what QWidgetPrivate::create() implements, and that's good.) Such a mismatch can have fatal consequences when OpenGL and friends are involved, but this always depends heavily on the platform and windowing system. For example, claiming that the alpha buffer size is 0 when the native window was created with 8, or vice versa, can break OpenGL-related code (both in Qt itself and in applications), that tries to create a QOpengGLContext configured based on what QWindow::format() returns. If that format describes settings that are incompatible with the actual underlying native window, we end up with the classic Invalid pixel format, EGL_BAD_MATCH, and alike errors. This is exactly what is happening when a QOpenGLWidget (or QQuickWidget) is placed in a QDockWidget where one of the ancestors is forced to native (winId() was called or WA_NativeWindow was set). When undocking, various code paths in QWidget will try to update the opaque flag of the widget, which in turn calls updateIsTranslucent. Now, if this function unconditionally changes the alphaBufferSize in the QWindow's QSurfaceFormat (even though this is completely futile to do, it has no visible effect in practice), we get the problem described above: rendering breaking down due to OpenGL contexts created with a pixel format incompatible with the native window. Prevent all this by not touching the format once the QWindow has a QPlatformWindow. This is the right thing to do, regardless of the bug in question: a window's (or context's or any other native resource wrapping class's) format must describe the underlying native resource and must never deviate, unless we are preparing to create a new native resource underneath. When it comes to the autotest, this changes the test added in 555661b625c40f21a6a3e4c73e928a6e8a46db20: the autotest logic is inverted because what we should test for is that the QSurfaceFormat stays untouched once the application makes a - futile - attribute change on the widget. Fixes: QTBUG-85714 Pick-to: 6.2 6.1 Change-Id: I7bf90711867e8a0fd474895625bf9530a7821fd5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Remove old configure-related filesJoerg Bornemann2021-06-181-647/+0
| | | | | | | | | | | | | Remove the configure.json and configure.pri files that were used for the qmake-based configure. Remove the .prev_*.cmake files that were a by-product of configurejson2cmake.py. Pick-to: 6.2 Task-number: QTBUG-89536 Change-Id: Ie827562f7fd2513d59f69234d77b8b93124ea78e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix recursion crash when calling setStyleSheet with `qproperty-styleSheet`Zhang Yu2021-06-181-0/+3
| | | | | | | | | | | When calling `setStyleSheet` with property `qproperty-styleSheet`, `QStyleSheetStyle::polish` will call`QStyleSheetStyle::setProperties`, and then`QStyleSheetStyle::setProperties` goes on to call `setProperty`.Because there is property `qproperty-styleSheet`, it will update stylesheet by calling QStyleSheetStyle::polish`. This causes the recursive call to crash. Fixes: QTBUG-94448 Pick-to: 5.15 6.2 Change-Id: I79c51192a939b0b62e5b1d0dcc90d38f79e28222 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Add a style hint to draw the left/top border lines when header is hiddenAndy Shaw2021-06-163-0/+28
| | | | | | | | | | | | Since there is no header then the cells appear with no actual border so it can look a bit strange without it. This ensures that the border is at least shown when there is no header to represent it if the style hint is turned on. This gives an option for those who want it to have it turned on. Fixes: QTBUG-85523 Change-Id: Ib94874bddddd31738fbcd41c6f77a2e0fa2ef443 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make dockwidget title bar buttons show againVolker Hilsheimer2021-06-141-4/+6
| | | | | | | | | | Amends f61304fc77a622170ef3bbcbcb37c5a90c6f87ea, which renamed the files but didn't adjust the code. Task-number: QTBUG-38776 Pick-to: 6.1 6.2 Change-Id: If54dd986975dd28f147a98628317b1369d0c690f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QAIV: Don't open editor on release when press closed editorVolker Hilsheimer2021-06-142-2/+18
| | | | | | | | | | | | | | | | | A mouse press that transfers focus from an open editor back to the view will close the editor. To prevent that the corresponding release then opens the same editor again we need to know that the closeEditor call was caused by the mouse press. Since Qt first generates the focusOut event, and then delivers the mouse press, we have to start a zero-timer to check whether we are in the same event delivery process. If so, ignore the corresponding release. Add test case that simulates that chain of events. Fixes: QTBUG-20456 Pick-to: 6.2 6.1 Change-Id: I28fa32bfbc776db207c594c329961f575ae58ea9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Deliver WindowActivate/Deactivate events to QWindowVolker Hilsheimer2021-06-111-0/+1
| | | | | | | | | | We need those events to trigger palette color group changes in QQuickItem without having to connect every item to yet another QWindow signal. Task-number: QTBUG-93752 Pick-to: 6.2 Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@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>
* Correctly support style sheet for toolbutton menus and arrowsVolker Hilsheimer2021-06-111-25/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | QToolButton can show an arrow instead of an icon, and that arrow can, as per the documentation, styled via the ::down/up/left/right-arrow pseudo element. This was not working at all, as the implementation confused the down-arrow with the menu arrow. Implement this correctly for all arrow types. A QToolButton can also have different ways to show a menu, either by using a separate section of the button that can be clicked; this section can be styled via ::menu-button and ::menu-arrow. Or by instant or delayed menu popup when clicking the button itself, in which case the button shows an indicator in the button itelf; that indicator can be styled via the ::menu-indicator pseudo element. The old implementation confused the various options, and the name of the PseudeoElement_ToolButonDownArrow didn't help with that. So rename that element to PseudoElement_ToolButtonMenuIndicator, and render it when there is no separate drop down. Fixes: QTBUG-27640 Pick-to: 6.1 6.2 Change-Id: Ia142a5d7498fa717e70f4e5382305e305b29effa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* In headers with only the arrow styled, prevent overlapping with textVolker Hilsheimer2021-06-111-2/+19
| | | | | | | | | | | | | | | | | | A style sheet that styles only the header arrow, but not the header section or label, resulted in an overlapped text and header if the text was also right aligned. To prevent this, add the space required by the arrow to the size calculation, and shorten the space accordingly before rendering the right-aligned label. Make corresponding adjustments to vertical headers with bottom-aligned labels. Fixes: QTBUG-84117 Pick-to: 6.2 Change-Id: I782d9538b695ad55d2d70b6d230f66059598768f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Check scrollbar ScrollBarOverlap when computing QListView marginsZhang Hao2021-06-101-0/+1
| | | | | | | | | | | | | | | | | When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if QStyle::PM_ScrollView_ScrollBarOverlap returns true, the text displayed an empty line. Fix this by not reserving the width of the vertical scrollbar if the flow is TopToBottom and the vertical scrollbar, and QStyle returns true for PM_ScrollView_ScrollBarOverlap. Amends aeef92c3c33e4ebcb7e5d8dd955020f4f4600e84 Pick-to: 6.1 6.2 Fixes: QTBUG-94248 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I4d47c7e86bbb86474cb1a99bb26d8b67f0e8a7e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* QAbstractItemView: block autoScroll from interfering with QScrollerVolker Hilsheimer2021-06-091-0/+4
| | | | | | | | | | | | | | | | When pressing an index in order to start a flick gesture, QAIV sets the current index. When QScroller changes state to Dragging, then QAIV restores the current index to what it was before the press, as the user is clearly scrolling the view. With autoScroll enabled, this will produce an ugly jump if the old current index is no longer in the viewport. To prevent this, disable autoScroll before restoring the currentIndex. Fixes: QTBUG-64543 Pick-to: 6.2 6.1 5.15 Change-Id: I3e0a18a6a179d80b9d810fce5aa658f0cfff9a29 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>
* QListView: add assert for static analyzerVolker Hilsheimer2021-06-081-0/+2
| | | | | | | | | | | | The loop that initializes the item should execute at least once, so the pointer should be pointing to something valid. The static analyzer doesn't see that, and warns about unguarded access to the item pointer in report with hash d008dbef4573afca54be0139e2971a4a. Add asserts for both the condition that makes the loop run at least once, and for the item pointer not being nullptr. Pick-to: 6.1 Change-Id: I94b9f3db3b3ce3d82445cf66788c05854b441aaf Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Calculate space requirement of menu items based on widest elementsVolker Hilsheimer2021-06-081-4/+5
| | | | | | | | | | | | | | | | | | Since icon, checkmark, text, and shortcut are each rendered aligned within their own column, we need to take the widest of each element into account when calculating the size requirement of each item. Otherwise an item with very long text but no icon will get enough space for the text, but no space for the icon, resulting in the text running over the shortcut or edge of the menu. Fortunately, QStyleOptionMenuItem provides us with the necessary information. Fixes: QTBUG-86754 Pick-to: 5.15 6.1 Change-Id: I0cf0e9adfe480d1004106e7475e498e718bf027b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@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>
* Fix rearranging of icons in listview via drag'n'dropVolker Hilsheimer2021-06-081-0/+2
| | | | | | | | | | | | | | | | | | | | Since 0f1008a5936c903ca9448193df7df6117e2c617b, views record if they moved the item in the model, and prevent the deletion of the source item in QAbstractItemView by setting the dropEventMoved private data member. However, QListView in icon mode is special: it doesn't rearrange the model, it repositions the icons in the view. While the dropEventMoved logic was applied to the drag event filter to prevent deletion, the variable was never set in the filterDropEvent handler. The drop event got ignored, breaking rearranging of icons. Fix this by setting the dropEventMoved member in filterDropEvent. Fixes: QTBUG-94226 Pick-to: 5.15 6.1 Change-Id: I963f5db0f81bcd0d25eef05d9a265be00a5871f6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QAItemView: in MultiSelection, press deselects only if no drag can startVolker Hilsheimer2021-06-081-3/+10
| | | | | | | | | | | | | | | | | | | | In MultiSelection mode, items are by default toggled on press, which follows the example of standard Windows controls. However, when dragging is enabled, then the press might be the beginning of a drag'n'drop operation, and deselecting the item on press breaks the selection and user experience. Don't toggle the selection for presses on an already selected item that might get dragged; instead, wait for the release event. Extend the test case slightly to cover the special case. Dragging a selection in a drag-enabled and MultiSelection item view wasn't possible before either. Fixes: QTBUG-59888 Change-Id: Ibd3e95a71ea63dd1e9bc3c8a723eafa9a1c21afa Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* QAbstractItemView: don't toggle extended selection on Ctrl+PressVolker Hilsheimer2021-06-071-0/+9
| | | | | | | | | | | | | | | | | | | In ExtendedSelection mode, a Ctrl+Press might be both the start of a selection toggle, or the start of a Ctrl+Drag operation. If we already toggle on the press, then it's impossible to drag the existing selection while the Control key is pressed. Ignore Ctrl+Press events and let the corresponding release event toggle the selection. Adjust the relevant test cases accordingly. The QItemDelegate test case used a click+control event incorrectly, such an event doesn't change the clicked state and should not be eaten, and now it does change the selection, so fix the test. Task-number: QTBUG-59888 Change-Id: Ia76126e31c28bc97d3e93e54965bdb1d0b8ac6a4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@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>
* QAbstractItemView: Don't change selection if editor ate release eventVolker Hilsheimer2021-06-071-1/+2
| | | | | | | | | If a QItemDelegate implementation eats a release event (which they don't do by default), then don't change the selection. Task-number: QTBUG-59888 Change-Id: Ia08637627ce1da34ff9bdac63dfc72e5f53befac Reviewed-by: Lars Knoll <lars.knoll@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>
* QAbstractItemView: don't block dragging after double clickVolker Hilsheimer2021-06-033-3/+7
| | | | | | | | | | | | | | | | | | | | | After d6551fe12520 it was no longer possible to start a drag with a double click (where the first click selects an item, and the second press+move starts the drag). Resetting the pressedItem variable to block the emission of the clicked() signal had this unwanted side effect. Instead, use an explicit boolean to store that the next release event will be the result of a double click, so that the clicked() signal is not emitted again (preventing the double-emission was the purpose of change d6551fe12520). Task-number: QTBUG-77771 Fixes: QTBUG-94087 Pick-to: 6.1 5.15 Change-Id: I082c5169d89eb980dcd7985ef3d302b6ff060fb9 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Olivier BARTHELEMY <perso.olivier.barthelemy@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@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>
* QFileDialog::saveFileContent crashes on acceptDong Rui2021-06-031-2/+2
| | | | | | | | | | | When using QFileDialog::saveFileCOntent, there is a risk of crash. Using deleteLater in the dialogClosed lambda in QFileDialog::saveFileContent Pick-to: 5.15 Fixes: QTBUG-90442 Change-Id: I200ccda9d973af2fa9b6ce9d72a518b154ef2019 Reviewed-by: Morten Johan Sørvig <morten.sorvig@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>
* Fix PageDown behavior and PageUPTang Haixiang2021-05-311-14/+39
| | | | | | | | | | | | | When the PageDown is pressed, the current's rect cannot be used to match the item, because we don't know the size of the rect. Move the rect by the height of the viewport, and then move the rect upwards until it matches the button <= viewport's bottom of the item Fixes: QTBUG-92583 Pick-to: 6.1 Change-Id: I210edc0e8b942984f3fc20e7752c6e1315152ea1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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-274-4/+4
| | | | | Change-Id: Ibfd76357ceb56b347afe7122fc252b866b21cb11 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-269-26/+26
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Add missing prepositionPaul Wicking2021-05-251-2/+2
| | | | | | | Fixes: QTBUG-93969 Pick-to: 6.1 Change-Id: I60e08ab7f17459b6cff969767273228a8406cfc3 Reviewed-by: Johanna Vanhatapio <johanna.vanhatapio@qt.io>
* Type erase native interfaces via string instead of typeidTor Arne Vestbø2021-05-201-2/+2
| | | | | | | | | | The latter forces users to build with RTTI enabled, as the typeid use is in our public headers. Surprisingly this is also the case even without instantiating the relevant template. Change-Id: Icd18a2b85b250e0b77960797e5c43b7eaf9bd891 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix BASE argument of qt_add_resourcesJoerg Bornemann2021-05-181-192/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BASE argument of qt_add_resources now denotes the root point of the alias of the file. Before, BASE was merely prepended to every file that got passed to qt_add_resources. Old behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "images/button.png") Alias is "../shared/images/button.png", and pro2cmake generated QT_RESOURCE_ALIAS assignments to fix this. New behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "../shared/images/button.png") The alias is "images/button.png". No extra QT_RESOURCE_ALIAS assignment is needed. The new behavior is in effect for user projects and for Qt repositories that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE. Qt repositories will be ported one by one to this new behavior. Then the old code path can be removed. Pick-to: 6.1 Task-number: QTBUG-86726 Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: remove unnecessary add_dependencies()Li Xinwei2021-05-171-2/+0
| | | | | | | | | | | | | The dependencies to moc, uic and rcc have already been handled by qt_manual_moc(), qt_enable_autogen_tool() and _qt_internal_process_resource(). This allows not building some of the debug executables in a multi-config scenario. Task-number: QTBUG-88414 Change-Id: I6c162721f3ddf6b4b410345ad012073abbdfd9df Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Rejig native interface plumbingTor Arne Vestbø2021-05-122-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The initial approach for providing public access to native interfaces via T::nativeInteface<I>() was based on the template not being defined, and then having explicit instantiations of the supported types in a source file, so that the accessors were exported and available to the user. This worked fine for "simple" types such as QOpenGLContext and QOffscreenSurface, but presented a problem in the context of classes with subclasses, such as Q{Core,Gui}Application. To ensure that a native interface for QCoreApplication was accessible both from QCoreApplication and its subclasses, while at the same time preventing a native interface for QGuiApplication to be accessible for QCoreApplication, the nativeInterface() template function had to be declared in each subclass. Which in turn meant specializing each native interface once for each subclass it was available in. This quickly became tedious to manage, and the requirements for exposing a new native interface wasn't very clear with all these template specializations and explicit instantiations spread around. To improve on this situation, while also squashing a few other birds at the same time, we change the approach to use type erasure. The definition of T::nativeInteface<I>() is now inline, passing on the requested interface to a per type (T, not I) helper function, with the interface type flattened to a std::type_info. The type_info requested by the user is then compared to the available types in a single per-type (T) "switch statement", which is a lot easier to follow for someone trying to trace the logic of how a native interface is resolved. We can safely rely on type_info being stable between the user application and the Qt library as a result of exporting the type info for each native interface, by explicitly ensuring they have a key function. This is the same mechanism that ensures we can safely dynamic_cast these interfaces, even across library boundaries. The use of a free standing templated helper function instead of a member function in the type T, is to avoid shadowing issues, and to not pollute the class namespace of T with the helper function. Since we are already changing the plumbing for how a user resolves a native interface for a type T, we take the opportunity to add a few extra safeguards to the machinery. First, we add a static assert in the T::nativeInteface<I>() definition, that ensures that only compatible interfaces, as declared by the interface themselves, are allowed. This ensures a compile time error when an incompatible interface is requested, which improves on the link time errors we had prior to this patch, and also offsets the one downside of type erasure, namely that errors are only caught at runtime. Secondly, each interface meant for public consumption through T::nativeInteface<I>() is declared with a revision, which is checked when requesting the interface. This allows us to bump the revision when we make breaking changes to the interface that would have otherwise been binary incompatible. Since the user will never see this interface due to the revision check, they will not end up calling methods that have been removed or renamed. One advantage of moving to a type-erased approach for the plumbing is that we're not longer exposing the native interface types as part of the T::nativeInteface symbols. This means that if we ever want to rename a native interface, the only exported symbol that the user code relies on is the type info. Renaming is then possible by just exporting the type info for the old interface, but leaving it empty. Since no class in Qt implements the old native interface, the user will just get a nullptr back, similarly to bumping the revision of an interface. Change-Id: Ie50d8fb536aafe2836370caacb22afbcfaf1712a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@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>
* Respect Password and NoEcho mode while pre-editingVolker Hilsheimer2021-05-121-1/+15
| | | | | | | | | | | | | | | During composition of text using an input method, incomplete characters should not be visible at all in NoEcho mode, and should be replaced by the password character in Password mode. In NoEcho mode, when the cursor is always at position 0, the pre-edit cursor should also always be at that position so that the UI doesn't give away the length of the text entered so far. Task-number: QTBUG-84664 Change-Id: I44a30eee3f5c6fe9fa00073b0a8ac3c333fbaa59 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Do not remove non-widget items when removeWidget() called with nullptrPiotr Srebrny2021-05-111-0/+5
| | | | | | | | | | | child->widget() returns null if the layout item is not a widget. Thus, calling removeWidget(nullptr) will remove all non-widget items such as layouts or strechers. Change-Id: I772c1158d0f7e8e2850b6e571b0405a2896f09b8 Pick-to: 6.0 6.1 5.15 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Check scrollbar visibility when computing QListView marginsChen Bin2021-05-111-1/+1
| | | | | | | | | | | | | | | | | When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if the text needs a newline display and the vbar is not shown, the width of the item was subtracted from the width of the scrollbar. In most cases, the listview needs to reserve the size of the scrollbar. But if the flow is TopToBottom and the vertical scrollbar is not visible, the width of the vertical scrollbar cannot be reserved. Fixes: QTBUG-92366 Pick-to: 5.15 6.0 6.1 Change-Id: I73cce691099a253d409019dbb3fe9a16e1830bb1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Improve handling of minimumHeightForWidth()Jan Arve Sæther2021-05-105-1/+55
| | | | | | | | | This also aligns the implementation with QWidgetItem::heightForWidth() Fixes: QTBUG-92599 Pick-to: 5.15 6.1 Change-Id: I0de68c61ec37a16a8c338575d07ff9e8168a0b98 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Don't draw focus frame if widget has style rules that affect borderDoris Verria2021-05-071-0/+9
| | | | | | | | | | | | | Skip drawing the focus ring if the widget has a custom styled border, custom focus ring, or any rule that affects the border. For QPushButton, if the style rule has a background set, the bevel will be drawn in the Windows style. Skip drawing the Mac focus frame in that case too. Fixes: QTBUG-93032 Pick-to: 5.15 6.1 Change-Id: I7c4d4bf6f6ce7bbcd17cd620586c5efa44f2b8d6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix compiler warning, explicitly use 64bit shiftVolker Hilsheimer2021-05-071-1/+1
| | | | | | | | | | | | | | | The 1 literal is an int, shifted by an int, and then passed into resize, which takes a 64 bit value. This makes MSVC complain about warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) Silence that warning by explicitly making the 1 a 64bit long long. Change-Id: Ica354166de4adae20e05e176dc72b7ccd1af053f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add note about the risk of setting min-width/height in a style sheetVolker Hilsheimer2021-05-071-2/+8
| | | | | | | Task-number: QTBUG-86677 Pick-to: 6.1 5.15 Change-Id: I1e5e10ee79d80fee40d04afe439489d6ce16a43e Reviewed-by: Andy Shaw <andy.shaw@qt.io>