Commit Graph

12 Commits

Author SHA1 Message Date
Mitch Curtis 23cad8990c Fix gallery example defaulting to Basic instead of the platform default
The example used to default to the Default style, and when that was
renamed to Basic and the default style behavior changed, we forgot to
adapt the style property in the QML Settings instance.

We should now not set any value as a default, and instead ensure that
the style is set on the QSettings in C++.

Pick-to: 6.1 6.0
Change-Id: Ia8654f28ae6adc9171d667c2c5c3603a15251cab
Fixes: QTBUG-91989
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-24 09:20:59 +01:00
Mitch Curtis 71249db0cb gallery: don't store QQuickStyle::name() in settings on startup
It's no longer empty if not specified, so just skip that step
altogether. Add the desktop styles to the list of selectable styles,
but only on the correct platforms. Only set the style at startup if it
wasn't specified via QT_QUICK_CONTROLS_STYLE. I tried to detect if a
-style application argument was passed, but it doesn't show up in the
list of arguments.

Change-Id: I7c216372580a012693b7a01d138d79c8d46afe66
Fixes: QTBUG-88955
Pick-to: 6.0 6.0.0
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-11-30 15:12:47 +01:00
Mitch Curtis 9219e86aa5 Rename "Default" style to "Basic"
[ChangeLog][Styles] The Default style was renamed to Basic to account
for the introduction of the platform styles (macOS, Windows), which
will be used by default (where possible) when no style is specified.

Fixes: QTBUG-85984
Task-number: QTBUG-68814
Task-number: QTBUG-86403
Change-Id: I22b3199c8662e4ee5d55a1be1a51c9856ac62376
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-09-24 13:48:49 +02:00
Volker Hilsheimer 0e0f7c0b7b Fix compile warning from deprecated application attributes
AA_DisableHighDpiScaling and AA_UseHighDpiPixmaps have been deprecated.

As of 90358f6042d1fe2db849e17e1b0c875fb0560b20
and 2dc46c09026362cc267b1183faf09fb29479ef93 in qtbase, respectively,
these settings are deprecated and have no effect.

Change-Id: I1eb1f77a64893dd077bd08216d26633d43e1e0e3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-15 17:45:04 +02:00
Mitch Curtis 501bc44bb0 Use qmlRegisterModuleImport() to register styles
This patch completes the cumulative work done in previous patches.

- Uses qmlRegisterModuleImport() to register styles. This has some
  added requirements:
  - Each style must now be a QML module -- that is, it must have a
    qmldir file.
  - As a result of the above, the module must be available within the
    QML import path in order to be found.
  - The various forms of accepted style names have been reduced down to
    one ("Material", "MyStyle", etc). See below for an explanation of
    why.
  - The following API in QQuickStyle is removed:
    addStylePath(), availableStyles(), path(), stylePathList(). These
    no longer make sense now that we reuse the existing QML import
    system.
- Adds the tst_qquickstyleselector auto test back as "styleimports".

qmlRegisterModuleImport() vs resolvedUrl()

    Previously we would use QQuickStyleSelector to select individual
    QML files based on which style was set. We'd do this once when
    QtQuick.Controls was first imported.

    With Qt 6, and the requirement that each style be a proper QML
    module, qmlRegisterModuleImport() was introduced. This allows us
    to "link" one import with another. For an example of what this
    looks like in practice, suppose the style was set to "MyStyle",
    and the fallback to "Material". The "QtQuick.Controls" import
    will be linked to "MyStyle", "MyStyle" to
    "QtQuick.Controls.Material", and as a final fallback (for controls
    like Action which only the Default style implements),
    "QtQuick.Controls.Material" to "QtQuick.Controls.Default".
    This is the same behavior as in Qt 5 (see qquickstyleselector.cpp):

    // 1) requested style (e.g. "MyStyle", included in d->selectors)
    // 2) fallback style (e.g. "Material", included in d->selectors)
    // 3) default style (empty selector, not in d->selectors)

    This is a necessary step to enable compilation of QML to C++.

Reducing the set of accepted style names

    The problem

    In QtQuickControls2Plugin() we need to call
    QQuickStylePrivate::init(baseUrl()) in order to detect if the style
    is a custom style in QQuickStyleSpec::resolve() (by checking if the
    style path starts with the base URL). In Qt 5, init() is called in
    QtQuickControls2Plugin::registerTypes(), but in Qt 6 that's too
    late, because we need to call qmlRegisterModuleImport() in the
    constructor. qmlRegisterModuleImport() itself requires the style to
    have already been set in order to create the correct import URI
    ("QtQuick.Controls.X" for built-in styles, "MyCustomStyle" for
    custom styles).

    The solution

    By reducing the valid forms for style names down to one:

    ./myapp -style MyStyle

    we solve the problem of needing baseUrl() to determine if the
    style is a custom style or not, but needing to call it too early
    (since we now call qmlRegisterModuleImport() in
    QtQuickControls2Plugin(), which itself requires the style to have
    already been set). baseUrl() can't have been set before the
    constructor is finished.

    All of the various forms for _setting_ a style are still valid;
    environment variables, qtquickcontrols2.conf, etc.

[ChangeLog][Important Behavior Changes] Custom styles must now have
a qmldir that lists the files that the style implements. For example,
for a style that only implements Button:
---
module MyStyle
Button 1.0 Button.qml
---
In addition, there is now only one valid, case-sensitive form for style
names: "Material", "MyStyle", etc.
These changes are done to help enable the compilation of QML code to
C++, as well as improve tooling capabilities.

[ChangeLog][Important Behavior Changes] The following API was removed:
- QQuickStyle::addStylePath()
- QQuickStyle::availableStyles()
- QQuickStyle::path()
- QQuickStyle::stylePathList()
- QT_QUICK_CONTROLS_STYLE_PATH
This API is no longer necessary and/or able to be provided now that
styles are treated as regular QML modules.

Task-number: QTBUG-82922
Change-Id: I3b281131903c7c3c1cf0616eb7486a872dccd730
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-26 11:46:07 +02:00
J-P Nurmi de6d7e1de7 Gallery: utilize the new icon-support for the tool buttons
Change-Id: I275856925ebf82c0ed8822d45299fd4d5c9218ba
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2017-04-26 07:34:24 +00:00
J-P Nurmi 51240b75cc Update license headers to silence qtqa/tst_license warnings
Sync with the qtbase/header.XXX. The license headers were matching
qtbase/header.XXX-OLD, which makes qtqa/tst_license flood warnings:

   Old license being used for foo.qdoc

Change-Id: I199bf303a2d648e0d5f7bc01cb0814a5f945eeff
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2017-02-24 13:04:52 +00:00
J-P Nurmi 4264061a20 Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: If797ac58344b20e8de4379343131c097247ba2f2
2017-01-11 10:48:42 +01:00
J-P Nurmi 00a062649b Welcome to 2017
Change-Id: If68cff4efacc7dc5719c8b8e61937e85e9076870
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2017-01-09 17:29:40 +00:00
J-P Nurmi f5467114b7 QQuickStyle::availableStyles()
This allows us to introduce platform-specific styles, such as the iOS
style, and make them appear correctly in the Gallery example so that we
don't have to hard-code the lists separately for different platforms.

[ChangeLog][Controls][QQuickStyle] Added availableStyles() method that
returns the list of available built-in styles.

Change-Id: Ieea88577f402cbc52a844d6777e64c6bd55c5ab9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2016-11-10 11:28:10 +00:00
J-P Nurmi e8cd9c0458 Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: Ia8879787703c32db44119b25be10adc83adc40bb
2016-04-20 16:23:33 +02:00
Mitch Curtis 1cb0faf788 Flatten and rename example install path and directory structure
Change-Id: Ib04e79d72c37fa4507517da2d3b1c28ccd73eaed
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-04-19 12:27:35 +00:00