aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Native style, DefaultComboBox: position popup at correct placeRichard Moe Gustavsen2020-06-151-3/+4
| | | | | | | | | Change 4013c4ee caused a regression after renaming layoutRect to layoutMargins. This patch will fix the regression in DefaultComboBox related to that. Change-Id: I05774b582c750e4614c0a70926613114b259a515 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix vertical aligment of CheckBox elementsJan Arve Sæther2020-06-121-0/+2
| | | | | Change-Id: I3cf376c680557c3d43753f6f4c627344192eb30c Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* NativeStyle: add ScrollBarRichard Moe Gustavsen2020-06-128-14/+255
| | | | | Change-Id: Ied2055866a67798ce60105e7251740a3e66b38db Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: remove prefix ('show', 'print') from the debug flagsRichard Moe Gustavsen2020-06-122-19/+25
| | | | | | | | Having them just complicates setting debug flags from QML. Add a separate debug flag "NinePatchMargins" in the drive-by. Change-Id: I56e1cc6f36368976b9325829816ab5a1bdb1f4ba Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: draw contentRect using marginsRichard Moe Gustavsen2020-06-121-2/+6
| | | | | | | | | We need to draw the debug rect using the calculated margins. Otherwise the rect will be drawn wrong once the control is resized. Change-Id: Ieb188900c688205147f991b98b5aeee836571e3d Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: offer layoutMargins to QML, not layoutRectRichard Moe Gustavsen2020-06-112-11/+16
| | | | | | | | | | | | | The layoutRect are, similar to contentRect, calculated based on the minimumSize of the control. Since we don't know what the actual layoutRect will be until a control is resized, we use it instead to calculate what the margins should be between the boundingRect() and layoutRect. We do the same for content rect. This will allows us to calculate the correct margins early on, before knowing what the end size of the control will be. Change-Id: I26b0aedee28533a70fd8dc4918f962f41c4f5185 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: make the debug flags more type safeRichard Moe Gustavsen2020-06-112-44/+30
| | | | | | | | Take the opportunity to clean up the flags a bit, and improve how we print the options to the console. Change-Id: Ia6e81453bfd53a5bfe6328b7cb8f6abcbf2dbed1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Remove qdrawutil.*Jan Arve Sæther2020-06-104-1315/+1
| | | | | | | | This was wrongly added in 2275a0896c7b7e648641f4c6977a02006a581577, but I didn't realize we already had qquickdrawutil.*. Change-Id: I873c0e2fcd2cb6df46966c59882db3eff33bc744 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix issues with the label in GroupBoxJan Arve Sæther2020-06-103-10/+33
| | | | | | | | | | 1. Make it have the correct position, given by the labelPos property. 2. Put a Rectangle with the background color below the label to wipe away the frame strikethrough. Change-Id: I68b6f1b5fda7854f7032dd9716613d025d2eb6ed Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QDebug, print 9-patch margins tooJan Arve Sæther2020-06-101-1/+2
| | | | | Change-Id: I23f2a1ae388f3819b41ed64ca15e8af9c6629fc8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: remove unused codeRichard Moe Gustavsen2020-06-092-3/+0
| | | | | Change-Id: Ica6390311031c14c123d3f49a4f70adfa15be5c0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Reorder properties into the same order as QMargins ctor (l,t,r,b)Jan Arve Sæther2020-06-091-1/+1
| | | | | | | | | | | Otherwise, doing a console.log(groupboxPaddings) results in: DefaultGroupBox.qml(88): QQuickStyleMargins(0, 0, 10, 0) which might mislead people into believeing that the right margin is 10. Change-Id: I25a3db40cb63d11841b72aad7bdf9889e6578e37 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* NativeStyle: add ComboBoxRichard Moe Gustavsen2020-06-098-18/+360
| | | | | | Change-Id: Ia6387857ba012ba7f6df453e64dd9419f7979db8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: make it possible to set nine patch margins from the styleRichard Moe Gustavsen2020-06-0814-13/+69
| | | | | | | | | | | | | | | | | | | Up till now, all images have been scaled using nine patch images with margins set to be at the center. This was doomed to be too simplistic at some point, at that point is now (when working on comboboxes). So instead, calculate the nine patch margins from the style. This will let the different styles set pixel perfect margins per control that matches the image they draw. If left unspecified by a style, the default implementation in QCommonStyle will return the old logic of using the center. We also add support for specifying if an image can be scaled horizontally or vertically by setting the right or bottom nine patch margin to -1 respectively. E.g on macOS, an NSButton cannot be scaled vertically, so the image we draw will not look native if we do. Change-Id: Icaf232748b8d15f06f9b289e164b5c8fb86a6c7b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Initial "port" of QQC2::QWindowsStyleJan Arve Sæther2020-06-0814-6/+11410
| | | | | | | | It also includes qwindowsxpstyle and qwindowsvistastyle, but they do not compile at the moment Change-Id: Ie9ce0bf99d620d65534c2660150117e4747f5c86 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: shuffle some linesRichard Moe Gustavsen2020-06-041-4/+4
| | | | | | | This change is just a refactoring of lines (no-op). Change-Id: I59c7c2e2b003f8b8c41a247d521eaef2f173ae17 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: let DefaultTextField have correct contentRect and sizeRichard Moe Gustavsen2020-06-043-4/+34
| | | | | | | | | | | Set implicitWidth/Height to be the same as in TextField.qml in the default style (and the same for TextArea). And fix the mac style to return correct values when calculating the minimum size. Combined, this should ensure that we improve how we take the content size into account when calculting the implicit size of a TextField (especially on macOS). Change-Id: I39bc8bb0f238dd29d5fe33fc32d888b82d020b0e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: don't use padding when item is smaller than minimumsizeRichard Moe Gustavsen2020-06-041-1/+5
| | | | | | | | Set padding to 0 if the item is resized smaller than minimum, otherwise the image will be wrapped rather than scaled. Change-Id: I803f5d0ff93afcb1b03e936aae766e71675f8d33 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: don't clean geometry flagRichard Moe Gustavsen2020-06-042-15/+10
| | | | | | | | | | | | | | | | | | We used to only repaint the image upon getting a geometryChanged callback, to avoid recursion. But this turns out to fail when the resize is a result of e.g a change in the content size. In that case, we need to recalculate geometry as well, since many of the rects are calculated based on the content size. This patch will change this logic so that we always recalculate style geometry upon a item geometry change, unless we're already polishing (that latter would otherwise produce a warning). Change-Id: I06c2e527d03dca54c555ddb8ab5d9b2a9546163d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: improve debug possibilitiesRichard Moe Gustavsen2020-06-042-18/+79
| | | | | | | | | Add more debug options, which is very helpful when working with QStyle. And use an enum to store it, to use less memory. Change-Id: I03fe3a5c827735641ce952daa797ab53a31f937f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: repaint image when geometry changesRichard Moe Gustavsen2020-06-041-2/+5
| | | | | | | | | When we don't use a nine-patch image for scaling, the size of the image will depend on the size of the item. So we need to repaint it whenever we update geometry. Change-Id: I385325621f5259e3e97ceb5e143ad73682f8b276 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: remove unused codeRichard Moe Gustavsen2020-06-031-5/+0
| | | | | Change-Id: I27263cd6230d4c1dc6c968505183eb27b8618c4f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: remove insets, and use layoutRectRichard Moe Gustavsen2020-06-039-51/+24
| | | | | | | | | | | | | | | We have so far used insets to ensure that the controls end up aligned inside a layout. But this is most likely wrong, since insets in QtQuickControls2 is supposed to only move the background, and not the whole control (including contents, which we used to move as well in Button.qml). So after looking at this one more time, I think the right solution is to leave insets alone, and instead provide a layoutRect from QQuickStyleItem. This rect can later be used by layouts to align the controls correctly. Change-Id: I3cd97d34ca6f629dedef3e2afd2ae9e257f9df22 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>