aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle
Commit message (Collapse)AuthorAgeFilesLines
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-10-071-4/+4
| | | | | | | | Modify special case locations to use the new API as well. Task-number: QTBUG-86815 Change-Id: I4a690095fcd4b1141550de86b6820ae2dd579429 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Native style, StyleItem: add property 'minimumSize'Richard Moe Gustavsen2020-10-063-2/+17
| | | | | | | | | | | | | Some items, like the scrollbar handle, can scale the handle down to 0 if no minimumSize is set. This will truncate the image drawn by QStyle. This patch will expose the minimum size read from QStyle to the QML control. We can then set ScrollBar.minimumSize to the correct value. Change-Id: Ib87e3ca7ea661bf41ab8057941fec7364b606177 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style, macOS: handle focus frame special case from c++Richard Moe Gustavsen2020-10-061-1/+22
| | | | | | | | | | Move the expression that finds the correct target for TextArea from QML to C++. Keeping the code in QML simply became to messy when trying to also detect if a TextArea is inside a ScrollView. Change-Id: I3906dd37df73eaceffd60413d2378db7eab5f1bb Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* nativestyle: SpinBox on WindowsJan Arve Sæther2020-10-063-14/+12
| | | | | Change-Id: I334af68282a59099698e46020b0644318eae5cce Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix build after qtbase changesAllan Sandfeld Jensen2020-10-051-10/+10
| | | | | | | | | | 93dad2bf91d414a41c6e2c7db6c75171b4917d4d requires adaptation on declarations. Note the declarations should probably end up removed for Qt6. Change-Id: I8aef41f9be32374506212a953aceecd1ddc75eae Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickStyleMargins: use lowercase for QML type nameMitch Curtis2020-10-021-1/+2
| | | | | | | | | | Value types must be lowercase. Fixes the following error: Invalid QML element name "StyleMargins"; value type names must begin with a lowercase letter Change-Id: I2b0ff7ed60bd8844dec95fa57d196e868c1d671d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* macOS: don't set the nine-patch margin exactly on the button widthRichard Moe Gustavsen2020-09-301-1/+1
| | | | | | | | | There is a subtle shadow line at the exact button width, which becomes visible for wide comboboxes. So move the margin one pixel to the left so that we don't scale the image on top of the line. Change-Id: I8780874fdd39178e7cf2fde24117589f222ea324 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: improve debug outputRichard Moe Gustavsen2020-09-302-35/+55
| | | | | | | | | | | | | Improve the debug implementation so that you don't need to modify the application to get debug output. You can now instead just do e.g: QQC2_NATIVESTYLE_DEBUG="myButton output contentRect" QQC2_NATIVESTYLE_DEBUG="combobox ninepatchmargins" QQC2_NATIVESTYLE_DEBUG="all layoutrect" Change-Id: I58cbcfb241bc0be20cae73735bc277d0662a476a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: don't use transient scrollbarsRichard Moe Gustavsen2020-09-301-1/+1
| | | | | | | | We don't want to hide the scrollbars on desktop when it's not moving. Change-Id: I6ce555b06a598560a7253e2b8e6db71405b9322b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* NativeStyle: add focus frame to the macOS styleRichard Moe Gustavsen2020-09-297-0/+407
| | | | | | | | | | | | | | This patch will add a focus frame to the macOS style. We use one focus frame item that we move around according to changes to the focus object. It's normally the background delegate's responsibility to draw a focus frame, so we take care to only draw the native focus frame for controls with default delegates. (to be consistent with the other styles) Change-Id: Iaa7202675c1aad2fc19682563ac1afb6e686c105 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* windows: Add hover animation to Button and CheckBoxJan Arve Sæther2020-09-294-19/+27
| | | | | | | | Move the hover animation handling API from macOS ScrollBar down to QQuickStyleItem. Change-Id: I36c8b173a15d0f4e10a59b7f3ccfe635e05c73e7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* NativeStyle: add focusFrameRadius to QStyleRichard Moe Gustavsen2020-09-2912-0/+48
| | | | | | | | | | | To be able to show a focus frame around a control from QML, we need to know the control's geometry and radius. For the geometry we can use the already existing layout rect. But for the latter we need to add focusFrameRadius enums to QStyle using the already existing pixel metric function. Change-Id: I45619194766cccbf824d93073a4dcea3a0893fbe Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* NativeStyle, macOS: adjust layout rectsRichard Moe Gustavsen2020-09-281-59/+38
| | | | | | | | | Go trough the layout rects, and adjust them so the look correct (by using nativestyle manual test and PixelTool). Change-Id: Idbd132b75fb2f87f8ff24cbe3a490ba6b3d2adc6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* CMake: Regenerate projects before API changeAlexandru Croitor2020-09-251-1/+0
| | | | | | | Task-number: QTBUG-86815 Change-Id: Ie0688d13b1787da3c1fc241a7d864aa014ca1d70 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* NativeStyle, macOS: don't draw focus from QStyleRichard Moe Gustavsen2020-09-252-160/+0
| | | | | | | | | We're no longer going to draw a static focus frame from QStyle. Subsequent patches will add a dynamic focus frame in combination with QML. Change-Id: I08b13b4c51cab74cd1bc6ec66b879b49774ad267 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* NativeStyle: rename 'nativeBackground' to '__nativeBackground'Richard Moe Gustavsen2020-09-2511-56/+52
| | | | | | | | | Since all properties that we add to the QML style files will bleed into the API of the control, prepend '__' to nativeBackground to mark it as private. Change-Id: I0cb474e054c3a3824985cf39b4bb675fb57b0696 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix fallback styles overwriting themesMitch Curtis2020-09-241-8/+2
| | | | | | | | | | | | | | | | | | | | | In Qt 5, QtQuickControls2Plugin::registerTypes() was responsible for calling initializeTheme() on each style plugin. Now that we delegate more work to the QML engine, each style plugin calls initializeTheme() via registerTypes(). To avoid fallback styles overwriting font and palette data set by the current style, we need to check if the theme has been intialized before calling initializeTheme(). To do this, we add a static "themeInitialized" bool that QQuickStylePlugin sets to true after calling intializeTheme() for the first time. It checks this value and avoids calling intializeTheme() if it's true. We also need to make QQuickStylePlugin ensure that the theme it's initializing belongs to the current style. Fixes: QTBUG-86303 Change-Id: Ie65e646677c78622829f4949c41cb79204cf5786 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* NativeStyle, TextField: add missing layoutRectRichard Moe Gustavsen2020-09-241-0/+1
| | | | | | | | | QQuickStyleItemTextField didn't set a layoutRect. This was just an oversight, and causes layout issues when trying to read it to position the focus frame. Change-Id: Ic959fd315da38e9700dc079c75993feca29c0c61 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* nativestyle: Port Windows XP styleJan Arve Sæther2020-09-178-458/+336
| | | | | | | Some controls needs more care, but that's for follow-up commits Change-Id: Ia7afeccf06f2f12dbef1402bf5975807cad8adcb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: support progressbars with a range from 0 - 1Richard Moe Gustavsen2020-09-171-0/+5
| | | | | | | | | | | | | | A ProgressBar is based on floating point numbers, meaning that it can have e.g from == 0.5, to == 1.5, and value == 0.8. A ProgressBar in QStyle on the other hand is integer-based. So add some extra code to convert floats to ints before passing the values to QStyle. But only do this for ranges smaller than 100, to ensure that we don't overflow ranges that are really large. And let "to" start at 0 in case the range ends close to Number.MAX_VALUE. Change-Id: I2707647911ee31c91b435697d4ae840b304c5c69 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: implement implicit minimum sizeRichard Moe Gustavsen2020-09-175-9/+17
| | | | | | | | | | | | | | | | | | | | QStyle doesn't calculate a sensible minimum implicit size for us, only a implicit size that matches the size of the contents. This means that if the contents is empty (e.g a TextField that has no text), the implicit size will typically be smaller than what a sensible minimum should be. Note that for widgets, a sensible preffered size is set from the widgets themselves, and not QStyle. Which explains why the sizes we get from QStyle can sometimes be too small. Therefore, add a sensible minimum implicit size to all the controls that suffers from this problem. We let QStyle continue to calculate the actual minimum size given the contents as before (which will end up as the StyleItem's implicit size), and instead fix the recommended minimum size directly in the QML style files. Change-Id: Ic4097776e40d0de64312e4099d7fe4c7fc1ca9d1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix compile warnings from missing override attributeVolker Hilsheimer2020-09-151-16/+16
| | | | | | | Add it, and remove redundant virtual where it was used. Change-Id: I7e0635f8d9eafbad49de63302a5b8f5cd25c0080 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix build after qtbase changesVolker Hilsheimer2020-09-153-3/+2
| | | | | Change-Id: I240b7410a409bb2f72213c02f50870f4ed99db9a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove the subControl property from ProgressBarJan Arve Sæther2020-09-103-28/+11
| | | | | | | | | | It shouldn't be needed in the API anymore, since a progress bar will either paint background and contentItem itself, or it won't paint any of those (therefore a custom progress bar have to provide both a background and a contentItem) Change-Id: Ic44fff97f5fc46453e9bbc9cada094b92fbe2aae Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix ProgressBar on WindowsJan Arve Sæther2020-09-092-5/+14
| | | | | | | | | | | | | | Also remove the two custom progress bars from the manual test where one has a custom background, and the other has a custom contentItem. If you want to customize a progress bar, you need to provide customizations for both the background and the contentItem. You cannot provide a custom background (or contentItem) alone, since its almost impossible to create a custom background that fits well with the contentItem of all the other possible styles it might be using. Change-Id: I82a87513e73f319bcecbfaed341ac4949f64c3bb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix bug when interpreting environment variable QQC2_STYLEJan Arve Sæther2020-09-081-3/+3
| | | | | | | QString: :compare() return 0 if they are equal, just like strcmp... Change-Id: Ib79513fed158f5068f27d77dfabe18fcff597aee Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: call QQuickStylePlugin::registerTypes() from style pluginsMitch Curtis2020-09-071-0/+3
| | | | | | | | This ensures that we received the warning we expect in tst_StyleImports::importStyleWithoutControls when run with native styles. Change-Id: I290f4e72222688e68ae36ace36f1d8be4bedaf31 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: fix warnings in QStyle codeMitch Curtis2020-09-071-2/+3
| | | | | | | | These break the build unless Qt is configured with -no-warnings-are-errors. Change-Id: I4a96efc0b29db60e7945fb9739a13da81f8d4c24 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: don't use ID's inside the stylesRichard Moe Gustavsen2020-09-072-7/+4
| | | | | | | Using ID's violates the rule we have for styles. Change-Id: I923199a62ed2dc3f8563ee9eda593905d8b076f9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: fix namespace buildsRichard Moe Gustavsen2020-09-072-2/+6
| | | | | Change-Id: I7ef28cc93fd4acad9849fecb3d4c2cab79f0acdb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: set a sensible default width for TextFieldRichard Moe Gustavsen2020-09-071-2/+3
| | | | | | | | | | Set the default width of an empty TextField to 90px (which is a number found by creating an NSTextField in XCode and measuring it with pixeltool). This should also make tst_QQuickPopup::macOS::cursorShape() pass. Change-Id: Ia2a059668c2e1eaea3eef20015a8ea99468dd8ad Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: set the default system palette as QQuickTheme::System palettewip/nativestyleRichard Moe Gustavsen2020-08-281-0/+4
| | | | | | | | | | After introducing the new registration system in Controls, the theme palette picked up colors from the Default style. Until this is fixed, set the system palette explicitly. Task-number: QTBUG-86303 Change-Id: Ib4c90856bd5410c042160b532175a48fdaea0fbd Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: remove versioning from importsRichard Moe Gustavsen2020-08-2813-59/+59
| | | | | Change-Id: I73319d18ca6540227ce6bf4bdcf217a3c279c64c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: clean-up importsRichard Moe Gustavsen2020-08-287-7/+0
| | | | | Change-Id: Id05edfccb617c72db902f5a7147ed8433be62e7c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: make StyleItem::control notifyableRichard Moe Gustavsen2020-08-281-1/+2
| | | | | | | | | | | | Even though 'control' should only be set once and never change, the QML engine will complain if you have a binding to e.g control.pressed, since both 'control' and 'pressed' in theory can change. So add a NOTIFY section to silence the engine. Change-Id: I64b79b7fd163cbeb5de78504f3b58d915edc278b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Native style: add hover effects to ScrollBar on macOSRichard Moe Gustavsen2020-08-262-0/+28
| | | | | Change-Id: I61bb0c2b1fd4dce2939bc4fe91a498a280802cb9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: remove superfluous width bindingRichard Moe Gustavsen2020-08-261-1/+0
| | | | | Change-Id: Ieb640d93e6eb09eb58e5b2ab48a399991d453eb5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: clean-up QStyle using a post routineRichard Moe Gustavsen2020-08-201-0/+23
| | | | | | | | | | | | | | | | | | When we delete QStyle, it will free up it's own internal resources. Especially on macOS, this means releasing a lot of NSViews and NSCells from the QMacStyle destructor. If we did this from ~QtQuickControls2NativeStylePlugin, it would happen when the plugin was unloaded from a Q_DESTRUCTOR_FUNCTION in QLibrary, which is very late in the tear-down process, and after qGuiApp has been set to nullptr, NSApplication has stopped running, and perhaps also other static platform variables (e.g in AppKit?) has been deleted. And to our best guess, this is also why we see a crash in AppKit from the destructor in QMacStyle. So for this reason, we delete QStyle from a post routine rather than from the destructor. Change-Id: I9dfb0d3394f14e5cd8b88d5a5fbbf3b73284faf1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Native style: don't draw frame around TextAreaRichard Moe Gustavsen2020-08-205-152/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In controls, it's seems to be undefined if the style should draw a frame around TextArea or not. E.g the Imagine style do, but the the Fusion style does not. This is a bit unfortunate, because depending on how you use a TextArea, you might want a frame around the TextArea itself, or the ScrollView around it (including the scrollbars), or not at all (*). For this reason, we should not draw a frame around the TextArea, but leave it to the user to compose the (style independent) structure, e.g Frame { ScrollView { TextArea{} } } Frame { TextArea {} }. TextArea {} This patch will remove drawing a frame around TextArea from the native style. Then at least Fusion, macOS and Windows will work the same way. This also means that we can remove the QQuickStyleItemTextArea, since we end up not using QStyle at all for drawing a TextArea. (*) Compared to Widgets, a QPlainTextEdit inherits from QAbstractScrollArea, which inherits from QFrame. In QFrame, you can choose frameShape, and even set it to NoFrame. Change-Id: Icabfa294744e87ccf262855faa0992f2d71ec4cb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: increase combobox minimum sizeRichard Moe Gustavsen2020-08-131-1/+1
| | | | | | | | | | After testing on Big Sur, it becomes clear that the minimum size (which is also the size of the nine patch image) needs to be larger in order for the combobox to render correctly. Change-Id: Iac70efa348afb7efb0af9453dd392b40ba3a9f89 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: add configure optionsRichard Moe Gustavsen2020-08-122-2/+2
| | | | | Change-Id: I54521f85aa821369ba3ff57fb037ae4996845c97 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: increase text field minimum sizeRichard Moe Gustavsen2020-08-111-3/+3
| | | | | | | | | | After testing on Big Sur, it becomes clear that the minimum size (which is also the size of the nine patch image) needs to be larger in order for the text field to render correctly. Change-Id: I74ede6415545f0ddee3fc2175772c1b07c2c3999 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: fix leaks in qquickmacstyleRichard Moe Gustavsen2020-08-101-0/+14
| | | | | | | | | | | After running the "leaks" app in Instruments, several places showed up to leak memory. This patch will add auto release pools at those places to stop that from happening. Change-Id: If7f49290fde60e71d1a40c10bc3d538df6c1da5c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Native style: support building with cmakeRichard Moe Gustavsen2020-07-302-1/+149
| | | | | | Change-Id: Idec0507a8bbdfc345e731a9e376ef8dd00534946 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: add DialRichard Moe Gustavsen2020-06-268-0/+236
| | | | | Change-Id: Iad09b9f6080994528d65dcddc9eda49dbba356f7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: support checkable buttonsRichard Moe Gustavsen2020-06-261-1/+1
| | | | | Change-Id: Id80add4e7c3611f9a12695745300d335a015cb43 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: move window tests inside window() scopeRichard Moe Gustavsen2020-06-171-2/+2
| | | | | Change-Id: I0c9860eca383b45926fc2134a54807a845d6bc35 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Make sure the focus rect is drawnJan Arve Sæther2020-06-172-10/+15
| | | | | | | | | | | | | | In windows style, the focus rect is drawn when the button is drawn, but we are only drawing the bevel, so the focus rect was not drawn. We move the logic of drawing the focus rect so that it is drawn when drawing the bevel instead. Also, we have to set the QStyle::State_KeyboardFocusChange in order for the focus rect to be drawn Change-Id: I4463ae1dd0f23ecc5bb0a84c563fda33dc6e93c8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix active focus handlingJan Arve Sæther2020-06-171-3/+3
| | | | | | | | | | We should connect to the control instead of the QQuickStyleItem This was also the case for the "enabled" and "window" properties (however, they worked fine, since those properties are inherited by the parent/child relationship) Change-Id: Ibcc5dbe8ea10201db558a534e46233617093e9b7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: add ProgressBarRichard Moe Gustavsen2020-06-179-78/+265
| | | | | Change-Id: Ie48002b083615afd4f8f8ab3b1303a8f5c39f81b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>