QmlDesigner: Fix SpinBox showing group separator

In Qt 6.7.3 the StudioControls SpinBoxes were showing group separators
caused by the validator fixup function which takes the system locale
to generated the presented string.
We fix this with a design studio specific locale that is assigned to the
controls that show numbers.

Task-number: QDS-13536
Change-Id: I26682b08a8e29cd5dc09b3ff09212568bfa4fe52
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Henning Gruendl
2024-09-09 17:11:53 +02:00
committed by Henning Gründl
parent 989eae1667
commit e3842cf236
9 changed files with 86 additions and 10 deletions

View File

@@ -4,6 +4,7 @@
import QtQuick import QtQuick
import QtQuick.Templates as T import QtQuick.Templates as T
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
import StudioQuickUtils
T.SpinBox { T.SpinBox {
id: control id: control
@@ -71,6 +72,8 @@ T.SpinBox {
signal dragging signal dragging
signal indicatorPressed signal indicatorPressed
locale: Utils.locale
// Use custom wheel handling due to bugs // Use custom wheel handling due to bugs
property bool __wheelEnabled: false property bool __wheelEnabled: false
wheelEnabled: false wheelEnabled: false

View File

@@ -4,6 +4,7 @@
import QtQuick import QtQuick
import QtQuick.Templates as T import QtQuick.Templates as T
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
import StudioQuickUtils
T.SpinBox { T.SpinBox {
id: control id: control
@@ -54,6 +55,8 @@ T.SpinBox {
signal dragEnded signal dragEnded
signal dragging signal dragging
locale: Utils.locale
// Use custom wheel handling due to bugs // Use custom wheel handling due to bugs
property bool __wheelEnabled: false property bool __wheelEnabled: false
wheelEnabled: false wheelEnabled: false

View File

@@ -27,7 +27,6 @@
#include <formeditor/transitiontool.h> #include <formeditor/transitiontool.h>
#include <formeditor/view3dtool.h> #include <formeditor/view3dtool.h>
#include <studioquickwidget.h> #include <studioquickwidget.h>
#include <windowmanager.h>
#ifndef QDS_USE_PROJECTSTORAGE #ifndef QDS_USE_PROJECTSTORAGE
# include <metainfo.h> # include <metainfo.h>
#endif #endif
@@ -311,7 +310,6 @@ bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *e
//TODO Move registering those types out of the property editor, since they are used also in the states editor //TODO Move registering those types out of the property editor, since they are used also in the states editor
Quick2PropertyEditorView::registerQmlTypes(); Quick2PropertyEditorView::registerQmlTypes();
StudioQuickWidget::registerDeclarativeType(); StudioQuickWidget::registerDeclarativeType();
QmlDesignerBase::WindowManager::registerDeclarativeType();
Exception::setWarnAboutException(!QmlDesignerPlugin::instance() Exception::setWarnAboutException(!QmlDesignerPlugin::instance()
->settings() ->settings()

View File

@@ -45,6 +45,7 @@ extend_qtc_plugin(QmlDesignerBase
PUBLIC_INCLUDES studio PUBLIC_INCLUDES studio
SOURCES_PREFIX studio SOURCES_PREFIX studio
SOURCES SOURCES
studioquickutils.cpp studioquickutils.h
studiostyle.cpp studiostyle.h studiostyle.cpp studiostyle.h
studiostyle_p.cpp studiostyle_p.h studiostyle_p.cpp studiostyle_p.h
studioquickwidget.cpp studioquickwidget.h studioquickwidget.cpp studioquickwidget.h

View File

@@ -8,6 +8,8 @@
#include "studio/studiostyle.h" #include "studio/studiostyle.h"
#include <designersettings.h> #include <designersettings.h>
#include <studioquickutils.h>
#include <windowmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/appinfo.h> #include <utils/appinfo.h>
@@ -89,6 +91,9 @@ bool QmlDesignerBasePlugin::initialize(const QStringList &arguments, QString *)
if (arguments.contains("-qml-lite-designer")) if (arguments.contains("-qml-lite-designer"))
enbableLiteMode(); enbableLiteMode();
WindowManager::registerDeclarativeType();
StudioQuickUtils::registerDeclarativeType();
d = std::make_unique<Data>(); d = std::make_unique<Data>();
if (Core::ICore::settings()->value("QML/Designer/StandAloneMode", false).toBool()) if (Core::ICore::settings()->value("QML/Designer/StandAloneMode", false).toBool())
d->studioConfigSettingsPage = std::make_unique<StudioConfigSettingsPage>(); d->studioConfigSettingsPage = std::make_unique<StudioConfigSettingsPage>();

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "studioquickutils.h"
#include <coreplugin/icore.h>
namespace QmlDesigner {
StudioQuickUtils::StudioQuickUtils()
{
m_locale = QLocale("DesignStudioLocale");
m_locale.setNumberOptions(QLocale::OmitGroupSeparator);
}
void StudioQuickUtils::registerDeclarativeType()
{
qmlRegisterSingletonType<StudioQuickUtils>(
"StudioQuickUtils", 1, 0, "Utils", [](QQmlEngine *, QJSEngine *) {
return new StudioQuickUtils();
});
}
const QLocale &StudioQuickUtils::locale() const
{
return m_locale;
}
StudioQuickUtils::~StudioQuickUtils() {}
} // namespace QmlDesigner

View File

@@ -0,0 +1,39 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "../qmldesignerbase_global.h"
#include <QtQml/qqml.h>
#include <QLocale>
namespace QmlDesigner {
class QMLDESIGNERBASE_EXPORT StudioQuickUtils : public QObject
{
Q_OBJECT
Q_PROPERTY(QLocale locale READ locale NOTIFY localeChanged)
public:
~StudioQuickUtils();
StudioQuickUtils(const StudioQuickUtils &) = delete;
void operator=(const StudioQuickUtils &) = delete;
static void registerDeclarativeType();
const QLocale &locale() const;
signals:
void localeChanged();
private:
StudioQuickUtils();
QLocale m_locale;
};
} // namespace QmlDesigner

View File

@@ -11,9 +11,7 @@
#include <QScreen> #include <QScreen>
#include <QWindow> #include <QWindow>
namespace QmlDesignerBase { namespace QmlDesigner {
QPointer<WindowManager> WindowManager::m_instance = nullptr;
WindowManager::WindowManager() WindowManager::WindowManager()
{ {
@@ -56,4 +54,4 @@ QRect WindowManager::getScreenGeometry(QPoint point)
return screen->geometry(); return screen->geometry();
} }
} // namespace QmlDesignerBase } // namespace QmlDesigner

View File

@@ -10,7 +10,7 @@
QT_FORWARD_DECLARE_CLASS(QWindow) QT_FORWARD_DECLARE_CLASS(QWindow)
namespace QmlDesignerBase { namespace QmlDesigner {
class QMLDESIGNERBASE_EXPORT WindowManager : public QObject class QMLDESIGNERBASE_EXPORT WindowManager : public QObject
{ {
@@ -34,8 +34,6 @@ signals:
private: private:
WindowManager(); WindowManager();
static QPointer<WindowManager> m_instance;
}; };
} // namespace QmlDesignerBase } // namespace QmlDesigner