qmlpreview: fix calling right localeIsoCode method

Also add some QTC_CHECK to get at least some warning
in case the functions are renamed in future.

Change-Id: Ie4e78855152e9946950603c95fa881755e850c62
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
(cherry picked from commit 165ccb828d)
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tim Jenssen
2020-10-14 14:02:49 +02:00
parent 996ed6e378
commit 57e77ec449
2 changed files with 15 additions and 7 deletions

View File

@@ -84,7 +84,9 @@ QmlPreviewPlugin::QmlPreviewPlugin()
if (s_previewPlugin) {
auto fpsAction = new FpsAction;
designerActionManager.addDesignerAction(fpsAction);
s_previewPlugin->setProperty("fpsHandler", QVariant::fromValue<QmlPreview::QmlPreviewFpsHandler>(FpsLabelAction::fpsHandler));
bool hasFpsHandler =
s_previewPlugin->setProperty("fpsHandler", QVariant::fromValue<QmlPreview::QmlPreviewFpsHandler>(FpsLabelAction::fpsHandler));
QTC_CHECK(hasFpsHandler);
auto switchLanguageAction = new SwitchLanguageAction;
designerActionManager.addDesignerAction(switchLanguageAction);
}
@@ -132,7 +134,9 @@ void QmlPreviewPlugin::setQmlFile()
if (s_previewPlugin) {
const Utils::FilePath qmlFileName =
QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
s_previewPlugin->setProperty("previewedFile", qmlFileName.toString());
bool hasPreviewedFile =
s_previewPlugin->setProperty("previewedFile", qmlFileName.toString());
QTC_CHECK(hasPreviewedFile);
}
}
@@ -146,14 +150,18 @@ float QmlPreviewPlugin::zoomFactor()
void QmlPreviewPlugin::setZoomFactor(float zoomFactor)
{
if (s_previewPlugin)
s_previewPlugin->setProperty("zoomFactor", zoomFactor);
if (s_previewPlugin) {
bool hasZoomFactor = s_previewPlugin->setProperty("zoomFactor", zoomFactor);
QTC_CHECK(hasZoomFactor);
}
}
void QmlPreviewPlugin::setLanguageLocale(const QString &locale)
{
if (auto s_previewPlugin = getPreviewPlugin())
s_previewPlugin->setProperty("locale", locale);
if (auto s_previewPlugin = getPreviewPlugin()) {
bool hasLocaleIsoCode = s_previewPlugin->setProperty("localeIsoCode", locale);
QTC_CHECK(hasLocaleIsoCode);
}
}
QObject *QmlPreviewPlugin::getPreviewPlugin()

View File

@@ -95,7 +95,7 @@ void QmlMultiLanguageAspect::setCurrentLocale(const QString &locale)
return;
m_currentLocale = locale;
if (auto previewPlugin = getPreviewPlugin())
previewPlugin->setProperty("locale", locale);
previewPlugin->setProperty("localeIsoCode", locale);
}
QString QmlMultiLanguageAspect::currentLocale() const