summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QCommonStyle: Fix painting arrows when size is evenChristian Ehrlicher6 days1-26/+32
| | | | | | | | | | | | | | | Rework the painting code to not use floating point numbers and make sure the tip of the arrow is painted with one or two points (depending on the size is odd or even) so the arrow is always symmetric. Therefore also no anti-aliasing is needed. Sadly the dpr scaling and also QPainter::drawPolygon() screw things up a little bit with such small sizes, therefore do the dpr handling by ourself to get nice results. Pick-to: 6.7 Fixes: QTBUG-124554 Task-number: QTBUG-114539 Change-Id: I8ab8c2ce3ceb90af5d7c3a0dfeec7f7445e92a4d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Revert "QCommonStyle: paint arrows with anti-aliasing"Axel Spoerl13 days1-4/+5
| | | | | | | | | | | This reverts commit 74e8f673b827c57ebf2bf802840c19e4a1ac848b. Reason for revert: the change as is makes the rendering of arrows in the styles unpleasantly blurry. Pick-to: 6.7 Change-Id: I59ccd7373631a550276465caffb7d3074ff5893c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QCommonStyle: don't use a QImage when drawing arrowsChristian Ehrlicher2024-04-221-11/+8
| | | | | | | | | | Using a QImage as a paintDevice is not needed - directly paint on a QPixmap. Also use styleCachePixmap() which avoids the need for multiplying the size with the dpr. Change-Id: I114f78c20d2b92b4fd135c8f64b452fb81a02baf Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
* QStyleHelper: pass devicePixelRatio to uniqueName()Christian Ehrlicher2024-04-221-1/+1
| | | | | | | | | | | QStyleHelper::uniqueName() took the size of the pixmap to cache but not the dpr. This might lead to a situation (e.g. in a multi-display environment) where we use a pixmap with the wrong dpr and get a pixelated result on the screen. Change-Id: Ifdebeddff3380931398b3284a7757b7da950caa9 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
* QCommonStyle: paint arrows with anti-aliasingChristian Ehrlicher2024-04-221-5/+6
| | | | | | | | | | | | | | | The high-dpi painting fix for the arrow painting was missing QPainter::AntiAliasing flag so the rectangle had some artifacts with certain (small) sizes. Also there is no reason to move the center by 1 pixel to the top left anymore now that we're using decimal values. This amends 3936d254ca0e7259cd97238c31df8413d03fd475. Pick-to: 6.7 Fixes: QTBUG-124554 Task-number: QTBUG-114539 Change-Id: I8a34d7ed937db261ce652bd66234783fb3338cbb Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QStyle: deprecate PM_DialogButtons* enumsChristian Ehrlicher2024-04-171-9/+0
| | | | | | | | | | | | The threee enumerations - PM_DialogButtonsSeparator - PM_DialogButtonsButtonWidth - PM_DialogButtonsButtonHeight Are not documented since Qt3 times and also not used anywhere. Therefore deprecated them and remove the logic to handle them. Change-Id: Ia59fe15482e744123e7fbf04b8d44661afb58b5c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* StyleSheet: respect a font weight set for header sectionsVolker Hilsheimer2024-04-111-3/+6
| | | | | | | | | | | | | | | | | | | | | | QCommonStyle sets the font for a selected header section to bold. This overrides the font weight a calling style might already have set, e.g. when a style sheet is applied to explicitly set a weight for a checked header section: QHeaderView::section:checked { font-size: 20px font-weight: normal } Since setting the weight on a font sets the respective resolve-mask bit, we can avoid overwriting a weight that is already set explicitly. Add baseline test coverage using a QTableWidget. Fixes: QTBUG-122180 Pick-to: 6.7 6.5 Change-Id: I8c6279ad2fd8c5718ebea26e27c64ae823625748 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Widgets: Improve usage of string view typesAnton Kudryavtsev2024-04-081-9/+10
| | | | | | | Use string views in QFontDialog, QColorDialog and QCommonStyle Change-Id: I22f4b4694e2d18b784aaa85aebff8d92b8f0b871 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+1
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFusionStyle: Pass handling of FrameGroupBox to base styleChristian Ehrlicher2024-02-131-1/+1
| | | | | | | | | | | | | | | | | | | The fusion style had an own handling for PE_FrameGroupBox/SC_GroupBoxFrame but failed to handle all cases (e.g. with checkbox, text and horizontal alignment) correct. In contrast, the base class (QCommonStyle) is properly handling all those attributes and returns a correct subControlRect(). Therefore remove the special handling, let styleHint() return the correct value for SH_GroupBox_TextLabelVerticalAlginment based on the groupBox's text alignment and rely on QCommonStyle ability to calculate the correct values. Pick-to: 6.7 6.6 Fixes: QTBUG-85425 Fixes: QTBUG-95472 Change-Id: I98ccf861274026a8fd4a2ef436efc3bb009be056 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
* Remove extra semi-colonsTasuku Suzuki2024-02-061-1/+1
| | | | | Change-Id: I92fddb36cd136fd1bd627955f15d0559b9942d7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Widgets: pass widget to QStyle::pixelMetric()Christian Ehrlicher2024-01-161-22/+22
| | | | | | | | | | | | Make sure to pass the widget to QStyle::pixelMetric() as some styles might use this (e.g. the new windows styles) to determine the correct pixel metric. Pick-to: 6.7 6.6 6.5 6.2 Task-number: QTBUG-1857 Change-Id: I5c32f5af8b284749732b610e56b4e3d8c8ed1946 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* QCommonStyle: use themeHint(IconPixmapSizes) in iconFromWindowsTheme()Christian Ehrlicher2024-01-091-4/+6
| | | | | | | | | | Sync iconFromWindowsTheme() to use themeHint(IconPixmapSizes) similar to iconFromMacTheme(). Pick-to: 6.7 6.6 Task-number: QTBUG-52622 Change-Id: Id06454b010b1946ee0565190672ee8624cffe2de Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Don't show mnemonics in dockwidget titlesSune Vuorela2024-01-071-1/+1
| | | | | | | | | | | | | | | | | | One might want to add an accellerator to dockwidget titles to be used in contexts that isn't directly the title, but still uses the title. Dockwidget title accelerators doesn't work in dock widgets, so don't show them. They are still available in e.g. a right click menu on a dockwidget to hide/show, and here the accellerator might come handy, and also if a dockwidget is tabbed. Pick-to: 6.6 6.7 Change-Id: I196e1aa92a5c53fed735b598653c267509f788b8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
* QWindowsTheme: honor dpr when requesting standard iconsChristian Ehrlicher2023-12-221-4/+9
| | | | | | | | | | | | | The devicePixelRatio was not taken into account when a standard icon was requested from the windows qpa which resulted in blurry icons for a dpr != 1. Therefore pass the dpr-corrected size to QWindowsTheme::standardPixmap() and pass this size to SHDefExtractIcon() to get a correctly scaled icon. Pick-to: 6.7 6.6 Fixes: QTBUG-52622 Change-Id: Ia771dd2f93fa133cf2c4429ef59a9c5cb05ad047 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QCommonStyle: make sure QPainter::save/restore() is called balancedChristian Ehrlicher2023-12-161-54/+52
| | | | | | | | | | | tst_qstylesheetstyle revealed an unbalanced call to save/restore within drawPrimitive(PE_IndicatorSpinUp/Down) due to an early exit. Therefore add a RAII-helper class to make sure QPainter::restore() is always called after a QPainter::save(). Pick-to: 6.7 Change-Id: I1b3851836b36d75357ed8c4532f7d2e44136159e Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QCommonStyle: fix focus rect drawing, don't fill the backgroundDavid Faure2023-12-041-2/+1
| | | | | | | | Regression in the previous commit, 5ef5f2f1b9 Pick-to: 6.6 Change-Id: I03786264d064b7d0cf2b88a5d06aa63ffb19ae8b Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QCommonStyle: draw focus rect using qDrawPlainRectDavid Faure2023-11-291-7/+7
| | | | | | | | | | | | | | A non-aliased drawRect(r.adjusted(0, 0, -1, -1)) no longer does the job in Qt6: hi-dpi is now enabled automatically, which scales the painter and leads to horrible (non symmetric) rendering. I doubt any actual widget style calls into this code (which draws a focus rect with a plain line) but it's still a useful example and fallback when writing a widget style. Pick-to: 6.6 Change-Id: Ib407a7355033258be568b4826fe01c110f02c018 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QCommonStyle: Adjust painting arrows in high-dpi modeChristian Ehrlicher2023-11-261-14/+14
| | | | | | | | | | | PE_IndicatorArrowUp/Down/Left/Right was drawn using integer coordinates for the three edges which lead to artifacts in high-dpi mode. Fix it by using QPointF instead. Pick-to: 6.6 Fixes: QTBUG-114539 Change-Id: I03cbff2ef789e8cee0f3a0d84138d94516340669 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QStyledItemDelegate/TreeView: fix showing lineedit editorChristian Ehrlicher2023-11-211-6/+2
| | | | | | | | | | | | | When the text alignment is AlignRight the opened editor is wrongly aligned and therefore the text can not be read. There is no reason to align the editor window on the right only because of the text alignment. Also remove the hack to not let occupy the editor the whole cell in a QTreeView but in a QTableView. Fixes: QTBUG-98525 Change-Id: I6f2d88e461bcfd505adde745041b5d4fdf679201 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QPushButton: fix QPushButton with icon in rtl modeChristian Ehrlicher2023-11-201-5/+8
| | | | | | | | | | | | | | | In rtl mode the text was not aligned right so a gap between the text and the icon occurred. This was due to the fact that the textFlag given to qt_format_text() was modified based on the application wide rtl/ltr mode and so our Qt::RightToLeft was reverted to Qt::LeftToRight. Therefore only set the textFlag to Qt::AlignRight when the button layout direction does not match the global one. Pick-to: 6.6 Fixes: QTBUG-64373 Change-Id: I283a99de8f59bc3db53c4150f417ffef9ff68db7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QStyle: cleanup iconFromApplicationTheme()Christian Ehrlicher2023-11-041-22/+4
| | | | | | | | Cleanup iconFromApplicationTheme() by merging the code paths for SP_DirLinkIcon and SP_FileLinkIcon. Change-Id: If4c8c850516971a80dffcc59cff7cabdace94585 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QCommonStyle: add missing standard iconsChristian Ehrlicher2023-10-291-0/+13
| | | | | | | | | | | | | Even though there are png files for SP_DirOpen/Closed/LinkIcon, SP_DriveFD/HD/NetIcon, SP_CommandLink and SP_Desktop/ComputerIcon they were not used within QCommonStyle::standardIcon() so the fallback from standardPixmap() with 16x16 pixels were used. As a drive-by use addIconFiles() for the creation of other standard icons. Task-number: QTBUG-118122 Change-Id: Ib651cefd31d1de84721fe11712e51980220ee9e2 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* QCommonStyle: add 128px icons for standardbutton-closetabChristian Ehrlicher2023-10-291-3/+3
| | | | | | | | | Add 128px version of standardbutton-closetab/-down/-hover and the source svg file. Task-number: QTBUG-118122 Change-Id: I8146f022cf440fc43d8c72aa08bd778ffdc64a78 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: add 128px icons for toolbar-extChristian Ehrlicher2023-10-291-2/+2
| | | | | | | | | | | Add 128px version of toolbar-ext-h/toolbar-ext-h-rtl and toolbar-ext-v - created from the available svg. Task-number: QTBUG-118122 Change-Id: I238333242995d6a93ce2cf08ef1b01af02ae2093 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: add 128px icon for cleartextChristian Ehrlicher2023-10-291-1/+1
| | | | | | | | | There was no 128px icon for cleartext - therefore add it including the svg source file. Task-number: QTBUG-118122 Change-Id: I405de9474406efcc43ffe319952f0b596bcfc623 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: add 128px versions of media iconsChristian Ehrlicher2023-10-291-8/+7
| | | | | | | | | Add 128px versions of (nearly) all media icons and including the svg source. Task-number: QTBUG-118122 Change-Id: Iac03f2bb8c0f5fe5d873a996b16eac5808475a19 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: add missing png icons derived from svg onesChristian Ehrlicher2023-10-291-0/+18
| | | | | | | | | | There are svg icons for information/warning/critical/question/ filedialog_start and filedialog_end but no corresponding png icons. Therefore create those from the svg files and add them. Task-number: QTBUG-118122 Change-Id: I2b0eb6450319ba64c41593a1f7705d995187f6b8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: cleanup standardIcon()/standardPixmap() [2/2]Christian Ehrlicher2023-10-291-455/+217
| | | | | | | | | | | | | Factor out the four code paths for standardIcon() (windows, mac, application and resource theme) and use those functions also for standardPixmap() so the returned pixmap is correctly scaled with the current devicePixelRatio. Part 2: move functionality into own functions Task-number: QTBUG-118122 Change-Id: I0763c4db9e7aecf4c52bf0f5770bd3dd87c4a8a4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* QCommonStyle: cleanup standardIcon()/standardPixmap() [1/2]Christian Ehrlicher2023-10-261-257/+257
| | | | | | | | | | | | Factor out the four code paths for standardIcon() (windows, mac, application and resource theme) and use those functions also for standardPixmap() so the returned pixmap is correctly scaled with the current devicePixelRatio. Part1: Add QStyle:: scope to switch statements Task-number: QTBUG-118122 Change-Id: I39c01612c23a0da61c256c682642ae4e75ed8c43 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: use addIconFiles() to avoid copy'n'pasteChristian Ehrlicher2023-10-251-158/+66
| | | | | | | | | | Use addIconFiles() instead repeating the addIcon() function with every size to avoid copy'n'paste errors and make the whole stuff more readable. Task-number: QTBUG-118122 Change-Id: I71ab5ca0526024c6f96e20871018b4af43dac3bf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCommonStyle: simplify removeAnimationChristian Ehrlicher2023-10-211-10/+7
| | | | | | | | | Simplify removeAnimation by directly passing the pointer to remove to the function instead trying to figure them out later on and relying on QObject::sender(). Change-Id: I9de3a138c60b0da8dd1ab23fe8521798b7f4c13c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QCommonStyle: use pmf-style connectChristian Ehrlicher2023-10-211-8/+4
| | | | | | | | Use pmf-style connect in QCommonStyle and remove the unused function animationTargets() as a drive-by Change-Id: I60e361ab00429a95eeab8799743996cea3f1469a Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QCommonStyle: misc cleanupChristian Ehrlicher2023-10-181-30/+19
| | | | | | | | | | Simplify addIconFiles() by passing an initializer list instead an c-array + size Task-number: QTBUG-118122 Change-Id: Id54bbe8436a9106e59b6fede81e31c3065623b4d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qcommonstyle: use rvalue overloads moreAnton Kudryavtsev2023-09-191-5/+4
| | | | | Change-Id: I39bd163ac8203095bbf93a0ada25a179d6bda48c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QStyle: don't use the QPixmapCache when a style sheet is setVolker Hilsheimer2023-07-111-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a style sheet is active, then the palette in the QStyleOption might be a generated, short-lived, temporary QPalette instance. As QPalette's cacheKey is based on instance-counters of the private data structures, it will always be unique for such a QPalette, even if the brushes are the same as in a previous instance. (QPalette::cacheKey is just a 64bit integer, we cannot possibly encode the entire QPalette data in it in a collision-free way, and since a brush in the palette might contain a pixmap or a gradient we couldn't even generate an efficient string representation for it. We could at most cache and reuse QPalette instances based on the attributes in the style sheet rule and in the base palette of the widget. However, this seems fragile; it might be an opportunity for future optimization.) Some styles use the QPixmapCache, with a key that includes the palette's cache key. The key will always be unique if the palette is based on style sheet rules, and then we fill pixmap cache with pixmaps that can never be reused, making the cache both useless and wasteful. To solve this, generate an empty key if we detect that it is for a style object that is the target of a style sheet. Return an empty cache key string from QStyleHelper::uniqueName, which will make QPixmapCache return immediatey when trying to insert or find an object. This is not pretty, but it makes the change minimal and low-risk. Refactoring the respective code paths to e.g. consistently use the BEGIN_STYLE_PIXMAPCACHE helper macro requires larger changes that can only be verified visually, and so are out of scope for a bug fix. This requires changes to code that uses QStyleHelper::uniqueName, as we need to avoid that other key elements are appended to the generated (and maybe empty) key. As a side effect, this ends up with code that makes better use of QStringBuilder. Pick-to: 6.6 Fixes: QTBUG-114473 Change-Id: I011aed0885f105cbf1e8c0bc6b94c46df47761a3 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTabBar: draw text within moving tabAxel Spoerl2023-04-201-1/+4
| | | | | | | | | | | | | | | | | | | | When a tab was moved by dragging, the tab's rectangle was drawn empty, without the tab text. When a tab was moved by animated snap back to its original position, the tab text was already drawn on the original position, while the rectangle was still moving due to animation. Adds the enum value QStyleOptionTab::TabPosition::Moving When this option is set, QCommonStyle draws the tab text at the current position instead of the original home position of the tab. The QMacStyle switches over the TabPosition enum. As a moving tab is laid out like the last tab in the given orientation, the enum value Moving is treated like End. Fixes: QTBUG-112277 Change-Id: I42a2d9c269dadfe9819c12dbc69e3ae995a45b09 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CommonStyle/QSpinBox: fix rendering up/down symbols in high-dpi modeChristian Ehrlicher2023-04-151-16/+15
| | | | | | | | | | | | | | The previous patch for QTBUG-112019 could lead to an uneven length which in results in an incorrect center. Fix it by making sure that the length (and width) of the two rectangles are even so we always get a proper center without fiddling around with float values. Also honor PM_ButtonShiftHorizontal/Vertical now (was forgotten in the last patch). Pick-to: 6.5 Fixes: QTBUG-112019 Fixes: QTBUG-112861 Change-Id: Ifc19b863c761ae545208b996ba60d1f33bceb2b3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Widgets/Styles: pass correct style option struct to subelementsChristian Ehrlicher2023-04-041-1/+7
| | | | | | | | | | | | | | | QHeaderView is using QStyleOptionHeaderV2 which should later be used in the subelements drawings. But since the subelement rect must be adjusted, a copy is done - sadly only to QStyleOptionHeader so we're loosing the V2 information. Therefore explicitly check if it's a V2 and copy it over to the correct structure. Pick-to: 6.5 6.2 Fixes: QTBUG-97571 Change-Id: I1482f118e2114cd6ef21c2a800785bd9910c1c5b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CommonStyle/QSpinBox: fix rendering up/down symbols in high-dpi modeChristian Ehrlicher2023-03-311-9/+44
| | | | | | | | | | Render the Up/Down and Plus/Minus images for QSpinBox in high-dpi mode. Found during investigation of QTBUG-112019. Pick-to: 6.5 Task-number: QTBUG-112019 Change-Id: Ie531311b657180790b0e12a36663012a5f4da6be Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add a platform theme option to affect SH_UnderlineShortcutMikolaj Boc2023-02-071-2/+5
| | | | | | | | | | | | | The style hint SH_UnderlineShortcut can now be turned on/off via the platform theme. No change in functionality so far on any platform, this behaves the same way it did before the change. The change just adds a possibility for platforms to redefine the default underlining behavior. Task-number: QTBUG-76587 Change-Id: Ibda104f1b733371da19825b96e73c22f42faf853 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QToolButton: Elide text when constraints prevent from showing whole textChristian Ehrlicher2023-01-301-1/+2
| | | | | | | | | | Follow-up of b2a282d7c7b8f49819bbc86ed705980438ecb04b - elide the text also when the QToolButton has no icon (=text only) Pick-to: 6.5 6.4 6.2 5.15 Fixes: QTBUG-64132 Change-Id: If4d3758452f37df411931a6628846988a3418d8e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QCommonStyle code cleanupAxel Spoerl2023-01-171-84/+102
| | | | | | | | | | | | | | | | | | | Consistently use int (instead of uint) type for alignment/text formatting flags passed to QStyle::drawItemText (and overrides). Clean variables in QCommonStyle::sizeFromContents - use self-explaining variable names - rename misleading variables - define one variable per line - use consts whereever possible - insert new lines to make code easier to read - correct wrong indentations - use auto in qstyleoption_castis to respect maximum of 100 characters per line Pick-to: 6.5 Change-Id: Ie145c089606436213c813227154fac29962825d0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix build with -no-feature-imageformat_pngTasuku Suzuki2023-01-171-1/+1
| | | | | | Pick-to: 6.5 Change-Id: Ib742665b2c379ff600b6a99432c89567a3f7765b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QListView: Prevent infinite loop when wrapping text of item with null-iconVolker Hilsheimer2023-01-041-5/+14
| | | | | | | | | | | | | | | | | | If an item in a list view has a null icon, then the decorationSize gets calculated as -1, -1. The style would then try to wrap the text to a lineWidth of -1, ending up in an infinite loop in viewItemTextLayout. To prevent that, don't set the HasDecoration flag of the style option when the icon is null, and don't fall back ot the decorationSize unless the flag is set. Add a test for this particular item configuration. This also fixes the widget baseline test with styles that don't provide all standard icons. Pick-to: 6.5 Change-Id: I691db6abede9a9b2ad300f3ee7fbfdae5fb6097f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Revert "Let styles indicate that they support dark mode"Volker Hilsheimer2022-12-081-1/+0
| | | | | | | | | | | This reverts commit 3ee7a9f85c9d4566223f44f7bab04abafdfca82c. Styles that don't support dark mode can overwrite the palette in a QStyle::polish(QPalette &) override instead. Change-Id: I8b84d822d91be5b3f67f76f791a1330bba7ea546 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Let styles indicate that they support dark modeSanthosh Kumar2022-11-261-0/+1
| | | | | | | | | | Add a style hint that allows styles to indicate that they support dark mode. The macOS and Fusion styles support dark mode, the other styles, in particular the Windows Vista style, do not. Task-number: QTBUG-72028 Change-Id: I02cac2e19a21898663f50f09a4ef419a613a73ec Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Widgets: Fix high dpi hover iconChristian Stenger2022-11-161-1/+1
| | | | | | | | Amends aa5a595a98f. Pick-to: 6.4 Change-Id: I4ba7744e70d7d9de2d0b562a67b3828a72940306 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTreeView: fix drawing of background for alternate rowsVolker Hilsheimer2022-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After f4976f86cd265d7505da449dafe15c51e3c8cdc0 we never called the style to draw the background of rows, unless ShowDecorationSelected was set. This broke rendering of alternate row backgrounds, as painting that background for the item's decoration was done by the style function that was no longer called. QStyleOptionViewItem::showDecorationSelected should store the value from the widget's style and be used by the style when rendering. This avoids that a style sheet is ignored when we are already in the virtual table of the parent style. However, in that style option we conflate both the style hint, and whether the entire row should be selected when the selection behavior is SelectRow (as we then need to draw selection in the first column all the way to the second column, not just around the text). To fix this, override the showDecorationSelected back to the style hint value while we are only painting the background, and reset it back before calling the delegate to draw the rest (including the selection). This reverts f4976f86cd265d7505da449dafe15c51e3c8cdc0. Fixes: QTBUG-106227 Pick-to: 6.4 6.2 Change-Id: I5c1ecdf0a0e07b156f35f4e5614593a984754a34 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add QPlatformTheme::MenuBarFocusOnAltPressReleaseVolker Hilsheimer2022-10-231-1/+4
| | | | | | | | | | | | On Windows, pressing and releasing the Alt key moves focus to the menubar. This is implemented in widgets, but not in Qt Quick. Add a new theme hint so that we can make Qt behave natively on all platforms, and make the common style's respective styleHint default to the theme hint. Change-Id: I101bec56afd51e81ebb128c288f8a1e9b7efedb4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>