aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle
Commit message (Collapse)AuthorAgeFilesLines
* macOS, Slider: draw a focus rect, and not a focus ringRichard Moe Gustavsen2021-05-051-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | In the mac style, we draw the focus ring for a slider from QML around the handle. This has shown to be fragile, since UIKit doesn't draw the handle in the center of the rect we get when we query UIKit (using the [cell knobRectFlipped:slider.isFlipped]). And then the focus ring will be offset as well. While we could try to adjust the rect manually from QQuickMacStyle, this will only be quaranteed to work on top of the current macOS SDK (macosx11.1). So for that reason, this patch falls back to use the less correct, but more future safe, solution of drawng the focus ring as a rect around the handle instead. While this doesn't look native, it still looks better (and correct, for the uninformed) compared to an eliptic ring that is misplaced on the target. Fixes: QTBUG-93423 Pick-to: 6.1 6.0 Change-Id: Ibc00f12f9606cd66c8ff384967aa3ea0d7727964 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: fix up some commentsRichard Moe Gustavsen2021-05-051-3/+3
| | | | | Change-Id: Id3d3db4b49dcbbc662a24eabb65ac6908577a4af Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* CMake: Avoid duplicate symbol errors due to a common resource nameAlexandru Croitor2021-04-271-1/+1
| | | | | | | | | | | | | | | The macOS nativestyle plugin uses the 'qmake_immediate' resource name, which conflicts with any test / example that might create a resource with the same name. This is problematic in static builds because it causes duplicate symbol errors when linking. Use a different unique resource name instead. Pick-to: 6.1 6.0 Fixes: QTBUG-93172 Change-Id: I29dee69190d75fe11c8993353349e3db2004d276 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix build without features.imageformat_pngTasuku Suzuki2021-04-271-6/+3
| | | | | Change-Id: Idc5a1c175fa942e90830ae8b81f6627a729f7220 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix build without features.imageformat-xpmTasuku Suzuki2021-04-261-0/+2
| | | | | Change-Id: Ib125517f87be0dac22eaeba059a6cdfd18abb7b7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Native style: fix statically built apps that links to both widgets and controlsRichard Moe Gustavsen2021-04-222-4/+24
| | | | | | | | | | | | | | | | | | | | | | The c++ symbols are already namespaced into QQC2. But since there is no namespace concept in obj-c, we use QT_MANGLE_NAMESPACE to wrap those symbols into a "fake" namespace by concatinating symbol name and namespace name together. The problem is that QT_MANGLE_NAMESPACE only take the QT_NAMESPACE into account, and not the additional QQC2 namespace. The result is that the application will fail linking because of duplicate obj-c symbols when you combine widgets and controls in a statically linked application. This patch will redefine the affected macros locally in qquickmacstyle_mac, so that both the Qt namespace and the controls namespace are taken into account. Pick-to: 6.0 6.1 6.1.0 Fixes: QTBUG-92883 Change-Id: Ic2f84ad9c0005fdd2553729d897cee113a4ff24d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* CMake: Fix qml module version to use the repo project versionAlexandru Croitor2021-04-151-1/+1
| | | | | | | | | | | Use PROJECT_VERSION instead of CMAKE_PROJECT_VERSION, so that the repo project version is used in a top-level build, rather than the version of the qt5 project. Pick-to: 6.1 6.0 Task-number: QTBUG-92861 Change-Id: Ifd12d6309f358b9b72372a5c069141ecb7322bc7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove redundant qmldir filesAlexey Edelev2021-02-231-32/+0
| | | | | | | | | | qmldir files to be generated by the cmake build procedure and don't need to be stored in the source tree. Task-number: QTBUG-88263 Change-Id: Idff2800b5b2b6cb74d79a2f42fff717522c10ade Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Fix namespaced Qt buildKarsten Heimrich2021-02-171-3/+3
| | | | | | Pick-to: 6.1 Change-Id: I688bdd73c939304f572d0e162e7aa09499bf737f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Remove QMake project filesJoerg Bornemann2021-02-111-32/+0
| | | | | | | | | | This includes removal of the corresponding .prev_CMakeLists.txt files. Pick-to: 6.1 Task-number: QTBUG-88742 Change-Id: I4247294258629c92e80914518e9208019090c815 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Fix MSVC warnings about precision loss when converting double to floatFriedemann Kleint2021-01-142-2/+2
| | | | | | | The warnings appeared after porting QCcolor to float. Change-Id: I248f15a7a403281e849f030e412c159f9732261e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickStyleItem: add debug flag 'SaveImage'Richard Moe Gustavsen2021-01-132-0/+12
| | | | | Change-Id: Ifbaadd993924022b1351927aaf3987cb94c74df8 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Windows: add 9p margins to scrollbarRichard Moe Gustavsen2021-01-132-0/+28
| | | | | | Pick-to: 6.0 Change-Id: I8d56f7b7071c51d4dfc88e12864bc3e0e7c5ab10 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Use CMAKE_PROJECT_VERSION for VERSION of QML modulesMitch Curtis2021-01-131-1/+1
| | | | | | | | | | This ensures that the modules provide versions matching the current Qt version. Change-Id: I164b54af60de3b2b6ca6f54c417eb58b1eafd1e5 Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickStyleItem: use correct enum numberRichard Moe Gustavsen2021-01-111-1/+1
| | | | | | | | | | It should of course be 4, not 3. The result of it being 3 is that we would always also print info when debugging imagerect. Pick-to: 6.0 Change-Id: I257159b25b8aad1848d82af9855ecd194e7360a0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Only connect to the items window signals if it has a windowJan Arve Sæther2020-12-162-2/+15
| | | | | | | | | | | | | | | | | If the styleitem was created in a control without a window, it failed to connect to the activeChanged() signal of QQuickWindow. It would consequently warn about invalid null parameter to QObject::connect() If the control was added to a window at a later point, it would also not connect to the activeChanged() signal of QQuickWindow. This could cause that the control was rendered as it would be rendered in an inactive window, even if the window actually was active. Task-number: QTBUG-88553 Pick-to: 6.0 Change-Id: I3aa5948e150f0f4baa204943ec43ea8922421e75 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add support for ScrollBar arrow buttonsJan Arve Sæther2020-12-105-19/+73
| | | | | | | | | | | In order to achieve this, it separates out QQuickSpinButton into a separate file (and renames it since it's not only purposed for SpinBox anymore). This allows it to be also used by QQuickScrollBar. Fixes: QTBUG-88115 Pick-to: 6.0 Change-Id: I2dea42b29750b7bc619031f40a43717fc10c177b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* CMake: Fix nativestyle qmldir dependenciesAlexandru Croitor2020-12-102-4/+4
| | | | | | | | | | | | | | | pro2cmake chokes on converting the nativestyle project, because it expects to find a second argument after the depends clause. Add an 'auto', and regenerate the project. Amends a3253c37903e95706f011bc03093160236b57bdc Pick-to: 6.0 Task-number: QTBUG-88492 Change-Id: I4c9114780e17f5bc21a43511e75207eaef5e7550 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qquickstyleitem: let the image size be aligned with dprRichard Moe Gustavsen2020-11-302-8/+45
| | | | | | | | | | | | | | The size of the image we paint the item on should have a size that will return a whole number when it's divided by the current dpr. Otherwise the texture mapping that occurs in the scenegraph later will work on fractions that will cause drawing glitches to occur. Fixes: QTBUG-89006 Pick-to: 6.0 6.0.0 Change-Id: I5e65aebbda9598d88bef7af2398b3fe3f2d16a87 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* qquickstyleitem: ensure that the size of the node is at least the size of ↵Richard Moe Gustavsen2020-11-301-21/+20
| | | | | | | | | | | | | | | the texture The size of the node should not be smaller than the size of the texture. Otherwise the image will look truncated or wrapped. This is especially important now that the image can be scaled up to be dpr aligned. Task-number: QTBUG-89006 Pick-to: 6.0 6.0.0 Change-Id: I0bd82faec89d6e7c2e79541a30d6b98200ebd5a0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Windows, CT_LineEdit: don't take dpr into account when calculating geometryRichard Moe Gustavsen2020-11-301-6/+4
| | | | | | | | | | | | | | | | The geometry calculated by the style should not take dpr into account. The nativestyle framework (and the scenegraph) understands that all geometry returned by QStyle will need to be scaled according to the dpr. We will for example set a dpr on the QPainter (or the QImage it draws on) before we ask QStyle to draw. This means that the style should not scale the geometry used in the drawing calls to QPainter since QPainter will do this automatically. Task-number: QTBUG-89006 Pick-to: 6.0 6.0.0 Change-Id: Idfcc6690e0ae0062ca00cb829510d2b68c26ebd4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Make adjustments for using QFont::setFamilies()Andy Shaw2020-11-301-2/+2
| | | | | | | | | | Since we only depend on using setFamilies() now instead of setFamily() then we can rely on the fact that it will be resolved correctly, so we can remove the code that was ensuring that family() would take precedence if families() was empty. Change-Id: Iea1464ec840dc76c04a4acae445cab367e03d3ca Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows, TextField: ensure we set a valid minimum sizeRichard Moe Gustavsen2020-11-201-1/+5
| | | | | | | | | | | | The current implementation would sometimes return a minimum size with a height equal to 3. And when trying to divide the image at the center for use with a nine patch image later, we would get drawing artifacts. This patch will ensure that we set a valid minimumsize. Pick-to: 6.0 Change-Id: I9ee72c525966462ced596c5191153d3e2a0d68fe Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: use the same scale from all placesRichard Moe Gustavsen2020-11-201-2/+4
| | | | | | | | | To be on the safe side, let's ensure that we set the same scale one the scene graph node as on the image it's created from Pick-to: 6.0 Change-Id: Ib8a86dd29f6f458d4c43dd36c6838dd632cb4078 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Complete add QtQuick.Layout dependency to native style qmldirFawzi Mohamed2020-11-181-1/+2
| | | | | | | | Cmake recreates the qmldir, so dependencies need to be listed in it too Fixes: QTBUG-88492 Change-Id: Ibcb7555216ba2804b545534d9ce8b304d6172f29 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add QtQuick.Layout dependency to native style qmldirFawzi Mohamed2020-11-181-1/+2
| | | | | | | | | | | | | | Without it qmlimportscanner misses the dependency of FocusFrame.qml and static builds fail to add the dependency leading to a QComponent is not ready error. This happens because the qml file is in a qrc, and thus not visible to qmlimportscanner. Adding a depends QtQuick.Layouts fixes it (and updating the controls dependency to drop the version) Fixes: QTBUG-88492 Change-Id: I9be3e26c3a03b663cb90618368f3480f141a6b04 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* macOS: don't use a focus frame around TextAreaRichard Moe Gustavsen2020-11-171-24/+2
| | | | | | | | | | | As it turns out, text areas in general should not show a focus frame. We don't do that for widgets, and AppKit doesn't do that for NSTextView. And for good reason, we don't want to show a big focus ring around the whole text edit in e.g a text editor application. Change-Id: Idc344c9f8d9f4a11dce22b2d2284800f05cd551a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix static build using native stylesFawzi Mohamed2020-11-161-0/+10
| | | | | | | | | | | | Ensure that the qml registration function of macOS, Windows and native styles get linked and executed in static builds by referencing the initialization function in the plugin constructor. This is intrusive and ugly, but is the method currently used in other plugins. Fixes: QTBUG-88463 Change-Id: I1b41ec89116066f46818f40ad155d12f6e719ca7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QChar constructor explicitlyVolker Hilsheimer2020-11-141-1/+1
| | | | | | | Prepare for upcoming changes in qtbase. Change-Id: Iace6fb0c99a0256b4665ff8ee6962c8ea837a74a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove usage of Qt4CompatiblePaintingAllan Sandfeld Jensen2020-11-122-12/+0
| | | | | | | Matching qtbase Change-Id: I1bd569995197158727ed5dff5b86e041c7af2177 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Register native styles under 2.0 in addition to 6.0Mitch Curtis2020-11-113-13/+29
| | | | | | | | | | | | | | | | | | Since we changed the logic that decides the default style, users with QML that imports 2.x versions of QtQuick.Controls will get errors if the default style that is chosen is a native style: qrc:/main.qml:53:1: module "QtQuick.Controls.macOS" version 2.15 is not installed qrc:/main.qml: Failed to load dependencies for module "QtQuick.Controls" version 2.15 We use PAST_MAJOR_VERSIONS to register the module for 2.x, and not just 6.0, and register the types of those styles under version 2.0 in addition to 6.0. This should not cause any problems for existing QML code. Fixes: QTBUG-87658 Change-Id: I976078c0aea3fbebe4e04f5ba4d8056c0ca7a0e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Native style/GroupBox: Add contentsMargins for GroupBox on WindowsJan Arve Sæther2020-11-061-0/+9
| | | | | | | | | | | QWindowsStyle did not add these margins because the layout did that. (It had a 9 pixel margin all around it) However, Qt Quick Controls2 expects that the contentPadding includes that margin. We therefore change the subControlRect implementation for (CC_GroupBox,SC_GroupBoxContents) to add those margins. Change-Id: I953a49340dc085716b4e9ecf736a5438e7cc4bbd Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickStyleItem: use imageSize directlyRichard Moe Gustavsen2020-11-041-10/+9
| | | | | | | | There is no reason to calculate the image size over and over. Just calculate imgSize once. Change-Id: Idf49a64102de18ba535899d4a46085de79e7ca2f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickStyleItem: reuse QImage when painting, if possibleRichard Moe Gustavsen2020-11-041-2/+7
| | | | | | | | | | If the size of the QImage we draw on hasn't changed between subsequent calls to paintControlToImage, we can just reuse the one we already got. This way we avoid creating and throwing away images unnecessary. Change-Id: Icf65bb8d9008a21e7114e588df46bc1e4cbdea97 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: add separate Info debug flagRichard Moe Gustavsen2020-11-022-19/+23
| | | | | | | | | | | | | | | Add an extra debug flag that lets us distinguish between general information, like geometry info, and explicit debug statements. E.g when writing: qqc2Debug() << "entering this block" ...you sometimes only want to print that line, and not all the additional "noise" you also get if this would print out general information. Change-Id: I86f60557f7c9b08e24c3de55bd0d526e095c6104 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix deprecation warnings related to QIcon::pixmap()Friedemann Kleint2020-11-021-27/+37
| | | | | Change-Id: I5eb7441ce557773e5253d3ce623be637819bab0d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix deprecation warnings related to QMetaTypeFriedemann Kleint2020-11-021-1/+1
| | | | | Change-Id: I4e6c1b03915c33f6225c0fb7f86e6acb7715cd4d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* nativestyle: refactor many functions to be constRichard Moe Gustavsen2020-11-0228-102/+102
| | | | | | | | Many of the virtual functions should be const, as they should not modify the state of the item. Change-Id: I94a7f9ae56204c8f8f737911e15d81f82d8add83 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* macOS: draw the handle as a part of the backgroundRichard Moe Gustavsen2020-10-301-1/+5
| | | | | | | | | | | | | | | | In dark mode, the slider handle is semi-transparent. If we draw the handle and the groove separately like we do today, the handle will end up _on top of_ the groove rather than as a part of it. The result is that you will see the groove behind the handle, which is wrong. Since we already draw the groove with tick marks without using a nine-patch image, we might as well draw the handle at the same time. This will give us the correct appearance. Change-Id: Ie582f99450c824d6955e3c0783dad89ab41160ef Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* macOS: clean up slider qstyle implementationRichard Moe Gustavsen2020-10-301-81/+31
| | | | | | | | | | | | | | | | | | | | | The current implementation doesn't work if drawing the groove and the handle together. The reason is that we transformed the CGContext as a way to flip the groove when drawing the slider in inverted (upside down) mode, which would also affect the position of the handle. Since we don't have an inverted API in Slider, we can simplify the code greatly in QStyle and remove all the transformation code. If we are to support inverted mode in the future, this can be achieved much easier by simply setting the scale on the Slider (or the style item) to -1. We also change the way we draw tick marks on both sides of the slider to use the API in NSSliderCell directly rather than manipulating the CGContext. Change-Id: I882a9e7eb69944da590d9d6b5ffb85c1f960cdaf Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style/Button: Avoid that the label gets elidedJan Arve Sæther2020-10-291-1/+1
| | | | | | | | | | | | | This was observed on Button on Windows style, where the labels size hint was a fractional number (e.g. 38.26). This got truncated by QQuickStyleItem::contentSize(), which caused the content item to get less space than it actually needed It was only observed on Button, but it was likely to also happen with other control types. Change-Id: I50b98fa7d54e5be2cedeeaf60018367689f168cf Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QuickStyleItem: refactor updatePaintNode()Richard Moe Gustavsen2020-10-291-20/+23
| | | | | | | | | Refactor the padding part, since there is no reason to go through all the if-tests if we don't use nine patch image scaling. Change-Id: If89c13aec0e6de955f032145ee325974c7169d6c Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* macOS: Update slider metrics by explicitly asking it to layoutRichard Moe Gustavsen2020-10-281-33/+4
| | | | | | | Cherry-picked from qtbase:873579d1579 Change-Id: Icb9ba3cabe9d5bd6670a6e4659701d06ff048d13 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* macOS: Don't assume NSSlider is never flippedRichard Moe Gustavsen2020-10-281-7/+7
| | | | | | | Cherry-picked from qtbase:6f850c080aac36 Change-Id: Ib6fd2ffa918a8bd5c4e7f0a3198eff36b3298f6d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* macOS: stop using the deprecated APIRichard Moe Gustavsen2020-10-281-3/+0
| | | | | | Change-Id: If1481afbfbc2e655e2b09a232abb16aa2dd792fe Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* nativestyle: only draw the control if the control is visibleRichard Moe Gustavsen2020-10-282-1/+16
| | | | | | | | Check if the control is visible before taking the time to draw the image. Change-Id: Icb64b85355e1341279a95e9035ae18d91c14d6a8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickStyleItem: add proper constructorRichard Moe Gustavsen2020-10-282-2/+3
| | | | | | | | | QQuickStyleItem has been missing a proper constructor that calls the constructur of the base class. This patch will add one. Change-Id: I7ba16b84a548bf8674723aa0d569b929111d07cf Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* nativestyle, slider: ensure that we set correct slider positionRichard Moe Gustavsen2020-10-271-2/+1
| | | | | | | | | | slider.position is a number between 0 and 1. And when the position is 1, styleOption.sliderPosition should be equal to styleOption.maximum. So no reason to subtract "min" (which is also not a normalized number). Change-Id: I9f9ff2e112e224b3aa32bda12aa1963a6e74c6ca Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: Add ComboBox for WindowsJan Arve Sæther2020-10-272-35/+60
| | | | | Change-Id: I59f64b3941bd0744bba6f6079b9ab3fc30063447 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: Fix bug in layoutMargins()Jan Arve Sæther2020-10-262-3/+7
| | | | | | | | | | | | | | It should return margin of 0 if style()->subElementRect(XXXLayoutItem) returned an invalid rect. This means that we cannot rely on m_styleItemGeometry.layoutRect blindly. Change-Id: If6b5a40481c8199a63f3446abc9e7dd1c670d181 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>