From d023dfca1e93e0945a1cd2477540873b1aa86277 Mon Sep 17 00:00:00 2001 From: Samuel Ghinet Date: Mon, 17 Jan 2022 13:24:05 +0200 Subject: [PATCH 1/6] Fix creating a project from a Recent preset with custom size When creating a project from a Recent preset, everything worked well if the user selected a predefined size. However, when typing a custom width and custom height, the recent was saved with the selected/active item in the screen size combobox. This patch does the following to fix the issue: * Save the recent info with the screen size written in the text fields (since they're updated when the user selects a different size from combobox but the user can type in any other value, the text fields always reflect the user's choice of width and height) * When loading a preset for display in the UI, if the preset was saved with a custom size that does not exist in the predefined list (i.e. in the combobox), whether that is a custom size or a different orientation of a predefined size, then append an item into the screen size combobox so that this custom size will appear as one of the predefined sizes for the preset. This is both for visual reasons (so that the combobox would have a valid item active on display) and in order to be able to save in the backend model this choice (when the user decides to create the project) * Update the ListField::selectRow function so that it does not attempt to select an item that does not exist. The reason is that, when the user clicks "Create" to create the project, the QWizard will be reset to the first page, and any modification we might have made to the model of the screen size combobox will be gone - and thus the selection would be invalid, which would normally cause the wizard to fail on page->isComplete(). By not allowing it to select an item in this case, we rely on the custom width and custom height fields to hold the real values. Task-number: QDS-5691 Change-Id: I9e848c5f4957252eb414da7e7146f9f8e7be760c Reviewed-by: Miikka Heikkinen Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../jsonwizard/jsonfieldpage.cpp | 15 +++++++--- .../jsonwizard/jsonfieldpage_p.h | 4 +-- src/plugins/studiowelcome/createproject.cpp | 1 + src/plugins/studiowelcome/qdsnewdialog.cpp | 29 +++++++++++-------- src/plugins/studiowelcome/qdsnewdialog.h | 2 ++ src/plugins/studiowelcome/screensizemodel.h | 6 ++++ 6 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index d6080f4e90f..393f6840c9d 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -1157,12 +1157,16 @@ QStandardItemModel *ListField::itemModel() return m_itemModel; } -void ListField::selectRow(int row) +bool ListField::selectRow(int row) { - auto index = itemModel()->index(row, 0); + QModelIndex index = itemModel()->index(row, 0); + if (!index.isValid()) + return false; + selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); this->updateIndex(); + return true; } QItemSelectionModel *ListField::selectionModel() const @@ -1271,12 +1275,15 @@ QVariant ComboBoxField::toSettings() const return {}; } -void ComboBoxField::selectRow(int row) +bool ComboBoxField::selectRow(int row) { - ListField::selectRow(row); + if (!ListField::selectRow(row)) + return false; auto w = qobject_cast(widget()); w->setCurrentIndex(row); + + return true; } int ComboBoxField::selectedRow() const diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h index ed89746d0b2..db8a1b06fb7 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h @@ -282,7 +282,7 @@ public: ~ListField() override; QStandardItemModel *model() { return m_itemModel; } - virtual void selectRow(int row); + virtual bool selectRow(int row); protected: bool parseData(const QVariant &data, QString *errorMessage) override; @@ -351,7 +351,7 @@ private: } public: - void selectRow(int row) override; + bool selectRow(int row) override; int selectedRow() const; }; diff --git a/src/plugins/studiowelcome/createproject.cpp b/src/plugins/studiowelcome/createproject.cpp index 1b6dd93e9d7..ce3b83945fb 100644 --- a/src/plugins/studiowelcome/createproject.cpp +++ b/src/plugins/studiowelcome/createproject.cpp @@ -68,6 +68,7 @@ void CreateProject::processFieldPage(ProjectExplorer::JsonFieldPage *page) auto widthField = dynamic_cast(page->jsonField("CustomScreenWidth")); auto heightField = dynamic_cast(page->jsonField("CustomScreenHeight")); + // TODO: use m_wizard to set these text items? if (widthField && heightField) { if (!m_customWidth.isEmpty() && !m_customHeight.isEmpty()) { widthField->setText(m_customWidth); diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index 83a966caeb0..0324a7de93c 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -170,17 +170,26 @@ void QdsNewDialog::onProjectCanBeCreatedChanged(bool value) emit fieldsValidChanged(); } +void QdsNewDialog::updateScreenSizes() +{ + int index = m_wizard.screenSizeIndex(m_currentPreset->screenSizeName); + if (index > -1) { + setScreenSizeIndex(index); + } else { + index = m_screenSizeModel->appendItem(m_currentPreset->screenSizeName); + setScreenSizeIndex(index); + } + + m_screenSizeModel->reset(); +} + void QdsNewDialog::onWizardCreated(QStandardItemModel *screenSizeModel, QStandardItemModel *styleModel) { m_screenSizeModel->setBackendModel(screenSizeModel); m_styleModel->setBackendModel(styleModel); if (m_qmlDetailsLoaded) { - int index = m_wizard.screenSizeIndex(m_currentPreset->screenSizeName); - if (index > -1) - setScreenSizeIndex(index); - - m_screenSizeModel->reset(); + updateScreenSizes(); emit haveVirtualKeyboardChanged(); emit haveTargetQtVersionChanged(); @@ -288,11 +297,7 @@ void QdsNewDialog::setWizardFactories(QList factories_, emit projectLocationChanged(); // So that QML knows to update the field if (m_qmlDetailsLoaded) { - int index = m_wizard.screenSizeIndex(m_currentPreset->screenSizeName); - if (index > -1) - setScreenSizeIndex(index); - - m_screenSizeModel->reset(); + updateScreenSizes(); } if (m_qmlStylesLoaded) @@ -334,9 +339,9 @@ void QdsNewDialog::accept() .execute(); PresetItem item = m_wizard.preset(); - QString screenSize = m_wizard.screenSizeName(m_qmlScreenSizeIndex); + QString customSizeName = m_qmlCustomWidth + " x " + m_qmlCustomHeight; - m_recentsStore.add(item.categoryId, item.name, screenSize); + m_recentsStore.add(item.categoryId, item.name, customSizeName); m_dialog->close(); m_dialog->deleteLater(); diff --git a/src/plugins/studiowelcome/qdsnewdialog.h b/src/plugins/studiowelcome/qdsnewdialog.h index 476750e5408..a4afa69e927 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.h +++ b/src/plugins/studiowelcome/qdsnewdialog.h @@ -131,6 +131,8 @@ private: QString projectDescription() const { return m_qmlProjectDescription; } + void updateScreenSizes(); + private slots: void onDeletingWizard(); void onWizardCreated(QStandardItemModel *screenSizeModel, QStandardItemModel *styleModel); diff --git a/src/plugins/studiowelcome/screensizemodel.h b/src/plugins/studiowelcome/screensizemodel.h index 597811146e7..0bde90c2690 100644 --- a/src/plugins/studiowelcome/screensizemodel.h +++ b/src/plugins/studiowelcome/screensizemodel.h @@ -87,6 +87,12 @@ public: return {}; } + int appendItem(const QString &text) + { + m_backendModel->appendRow(new QStandardItem{text}); + return rowCount(QModelIndex{}) - 1; + } + QHash roleNames() const override { if (m_backendModel) From bdba99c61b2a797f5c903250293949208943a9d7 Mon Sep 17 00:00:00 2001 From: Tuomo Pelkonen Date: Wed, 19 Jan 2022 08:24:14 +0200 Subject: [PATCH 2/6] Multilanguage: Add multilanguageSupport option to qmlproject Change-Id: I1fc1861e17dc62cec91f5fa27f7e01360a42de78 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: Thomas Hartmann --- .../fileformat/qmlprojectfileformat.cpp | 5 +++++ .../fileformat/qmlprojectitem.cpp | 5 +++++ .../fileformat/qmlprojectitem.h | 4 ++++ .../qmlprojectmanager/qmlmultilanguageaspect.cpp | 5 +++-- src/plugins/qmlprojectmanager/qmlproject.cpp | 7 +++++++ src/plugins/qmlprojectmanager/qmlproject.h | 1 + .../qmlprojectrunconfiguration.cpp | 16 ++++++++++++---- 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp b/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp index 80b2d08ca7e..0b637e24a74 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp @@ -99,6 +99,11 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi if (fileSelectorsProperty.isValid()) projectItem->setFileSelectors(fileSelectorsProperty.value.toStringList()); + const auto multilanguageSupportProperty = rootNode->property( + QLatin1String("multilanguageSupport")); + if (multilanguageSupportProperty.isValid()) + projectItem->setMultilanguageSupport(multilanguageSupportProperty.value.toBool()); + const auto languagesProperty = rootNode->property(QLatin1String("supportedLanguages")); if (languagesProperty.isValid()) projectItem->setSupportedLanguages(languagesProperty.value.toStringList()); diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp index 249474a224f..806c873817b 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp @@ -77,6 +77,11 @@ void QmlProjectItem::setFileSelectors(const QStringList &selectors) m_fileSelectors = selectors; } +void QmlProjectItem::setMultilanguageSupport(const bool isEnabled) +{ + m_multilanguageSupport = isEnabled; +} + void QmlProjectItem::setSupportedLanguages(const QStringList &languages) { if (m_supportedLanguages != languages) diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h index a104e906464..01d3b8572e0 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h @@ -63,6 +63,9 @@ public: QStringList fileSelectors() const { return m_fileSelectors; } void setFileSelectors(const QStringList &selectors); + bool multilanguageSupport() const { return m_multilanguageSupport; } + void setMultilanguageSupport(const bool isEnabled); + QStringList supportedLanguages() const { return m_supportedLanguages; } void setSupportedLanguages(const QStringList &languages); @@ -94,6 +97,7 @@ protected: QString m_targetDirectory; QStringList m_importPaths; QStringList m_fileSelectors; + bool m_multilanguageSupport; QStringList m_supportedLanguages; QString m_primaryLanguage; QString m_mainFile; diff --git a/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp b/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp index 662e904974f..cfb2bfaf474 100644 --- a/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp +++ b/src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp @@ -75,8 +75,9 @@ QmlMultiLanguageAspect::QmlMultiLanguageAspect(ProjectExplorer::Target *target) { setVisible(isMultilanguagePresent()); setSettingsKey(Constants::USE_MULTILANGUAGE_KEY); - setLabel(tr("Use MultiLanguage translation database."), BoolAspect::LabelPlacement::AtCheckBox); - setToolTip(tr("Enable loading application with special desktop SQLite translation database.")); + setLabel(tr("Use MultiLanguage in Form Editor."), BoolAspect::LabelPlacement::AtCheckBox); + setToolTip(tr("By enabling this Form Editor can read translations\n" + "from MultiLanguage plugin.")); setDefaultValue(!databaseFilePath().isEmpty()); QVariantMap getDefaultValues; diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 8e2dd6048e4..83fde3c196e 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -340,6 +340,13 @@ QStringList QmlBuildSystem::customFileSelectors() const return {}; } +bool QmlBuildSystem::multilanguageSupport() const +{ + if (m_projectItem) + return m_projectItem->multilanguageSupport(); + return false; +} + QStringList QmlBuildSystem::supportedLanguages() const { if (m_projectItem) diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index 143c1697d1b..89f5dd34454 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -88,6 +88,7 @@ public: Utils::EnvironmentItems environment() const; QStringList customImportPaths() const; QStringList customFileSelectors() const; + bool multilanguageSupport() const; QStringList supportedLanguages() const; void setSupportedLanguages(QStringList languages); QString primaryLanguage() const; diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index e0c7cb30459..7eb5a4f6786 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -120,16 +120,24 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) connect(target, &Target::kitChanged, this, &RunConfiguration::update); m_multiLanguageAspect = addAspect(target); + auto buildSystem = qobject_cast(activeBuildSystem()); + if (buildSystem) + m_multiLanguageAspect->setValue(buildSystem->multilanguageSupport()); auto envAspect = addAspect(); - connect(m_multiLanguageAspect, &QmlMultiLanguageAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); + connect(m_multiLanguageAspect, + &QmlMultiLanguageAspect::changed, + envAspect, + &EnvironmentAspect::environmentChanged); auto envModifier = [this](Environment env) { - if (auto bs = dynamic_cast(activeBuildSystem())) + if (auto bs = qobject_cast(activeBuildSystem())) env.modify(bs->environment()); - if (m_multiLanguageAspect && m_multiLanguageAspect->value() && !m_multiLanguageAspect->databaseFilePath().isEmpty()) { - env.set("QT_MULTILANGUAGE_DATABASE", m_multiLanguageAspect->databaseFilePath().toString()); + if (m_multiLanguageAspect && m_multiLanguageAspect->value() + && !m_multiLanguageAspect->databaseFilePath().isEmpty()) { + env.set("QT_MULTILANGUAGE_DATABASE", + m_multiLanguageAspect->databaseFilePath().toString()); env.set("QT_MULTILANGUAGE_LANGUAGE", m_multiLanguageAspect->currentLocale()); } else { env.unset("QT_MULTILANGUAGE_DATABASE"); From 2dead05a039ae99f4961dffac5487d2137359616 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 20 Jan 2022 10:50:24 +0100 Subject: [PATCH 3/6] QmlDesigner: Set target to nullptr if project is removed Change-Id: I7ef9450588523f2a1900113f216612949b4e506e Reviewed-by: Reviewed-by: Thomas Hartmann --- src/plugins/qmldesigner/qmldesignerprojectmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp index 51d62a2bbe5..2f8e754b893 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp @@ -173,7 +173,7 @@ void QmlDesignerProjectManager::projectAdded(::ProjectExplorer::Project *project void QmlDesignerProjectManager::aboutToRemoveProject(::ProjectExplorer::Project *) { if (m_projectData) { - m_imageCacheData->collector.setTarget(m_projectData->activeTarget); + m_imageCacheData->collector.setTarget(nullptr); m_projectData.reset(); } } From 1fb54d4f2b0fc398ff86e226cc915cabcb5c0a42 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 20 Jan 2022 11:22:20 +0100 Subject: [PATCH 4/6] QmlDesigner: Delete the preview factory for every project change Change-Id: Ia49608ea327d68ec12969cc079d85895515e1f12 Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../qmldesigner/qmldesignerprojectmanager.cpp | 23 ++++++++++--------- .../qmldesigner/qmldesignerprojectmanager.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp index 2f8e754b893..e9de2cb251b 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp @@ -97,17 +97,20 @@ public: Sqlite::JournalMode::Wal, Sqlite::LockingMode::Normal}; ImageCacheStorage storage{database}; - ImageCacheConnectionManager connectionManager; - ImageCacheCollector collector{connectionManager, - ImageCacheCollectorNullImageHandling::DontCaptureNullImage}; - TimeStampProvider timeStampProvider; AsynchronousExplicitImageCache cache{storage}; - AsynchronousImageFactory factory{storage, timeStampProvider, collector}; }; class QmlDesignerProjectManagerProjectData { public: + QmlDesignerProjectManagerProjectData(ImageCacheStorage &storage) + : factory{storage, timeStampProvider, collector} + {} + ImageCacheConnectionManager connectionManager; + ImageCacheCollector collector{connectionManager, + ImageCacheCollectorNullImageHandling::DontCaptureNullImage}; + TimeStampProvider timeStampProvider; + AsynchronousImageFactory factory; ::ProjectExplorer::Target *activeTarget = nullptr; }; @@ -157,8 +160,8 @@ void QmlDesignerProjectManager::currentEditorChanged(::Core::IEditor *) m_projectData->activeTarget); if (qmlBuildSystem) { - m_imageCacheData->collector.setTarget(m_projectData->activeTarget); - m_imageCacheData->factory.generate(qmlBuildSystem->mainFilePath().toString().toUtf8()); + m_projectData->collector.setTarget(m_projectData->activeTarget); + m_projectData->factory.generate(qmlBuildSystem->mainFilePath().toString().toUtf8()); } } @@ -166,16 +169,14 @@ void QmlDesignerProjectManager::editorsClosed(const QList<::Core::IEditor *> &) void QmlDesignerProjectManager::projectAdded(::ProjectExplorer::Project *project) { - m_projectData = std::make_unique(); + m_projectData = std::make_unique(m_imageCacheData->storage); m_projectData->activeTarget = project->activeTarget(); } void QmlDesignerProjectManager::aboutToRemoveProject(::ProjectExplorer::Project *) { - if (m_projectData) { - m_imageCacheData->collector.setTarget(nullptr); + if (m_projectData) m_projectData.reset(); - } } void QmlDesignerProjectManager::projectRemoved(::ProjectExplorer::Project *) {} diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.h b/src/plugins/qmldesigner/qmldesignerprojectmanager.h index f4a958fac5d..4b993ba74d2 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.h +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.h @@ -62,7 +62,7 @@ private: void projectRemoved(::ProjectExplorer::Project *project); private: - std::unique_ptr m_projectData; std::unique_ptr m_imageCacheData; + std::unique_ptr m_projectData; }; } // namespace QmlDesigner From 189ff75709a4e885e49e25a9ff49669ab0384cf0 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 20 Jan 2022 17:33:01 +0100 Subject: [PATCH 5/6] QmlDesigner: Use logging category Change-Id: I0e578650201f358adbf703bc057a02e8e902aaa2 Reviewed-by: Reviewed-by: Aleksei German Reviewed-by: Qt CI Bot --- .../designercore/model/texttomodelmerger.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index d8fbbb1cd7d..2874cc9c8d7 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -78,6 +78,7 @@ using namespace LanguageUtils; using namespace QmlJS; static Q_LOGGING_CATEGORY(rewriterBenchmark, "qtc.rewriter.load", QtWarningMsg) +static Q_LOGGING_CATEGORY(texttomodelMergerDebug, "qtc.texttomodelmerger.debug", QtDebugMsg) namespace { @@ -574,7 +575,7 @@ public: if (parentObject) *parentObject = objectValue; if (!value) { - qWarning() << Q_FUNC_INFO << "Skipping invalid property name" << propertyName; + qCInfo(texttomodelMergerDebug) << Q_FUNC_INFO << "Skipping invalid property name" << propertyName; return false; } @@ -655,9 +656,10 @@ public: const ObjectValue *containingObject = nullptr; QString name; if (!lookupProperty(propertyPrefix, propertyId, &property, &containingObject, &name)) { - qWarning() << Q_FUNC_INFO << "Unknown property" << propertyPrefix + QLatin1Char('.') + toString(propertyId) - << "on line" << propertyId->identifierToken.startLine - << "column" << propertyId->identifierToken.startColumn; + qCInfo(texttomodelMergerDebug) << Q_FUNC_INFO << "Unknown property" + << propertyPrefix + QLatin1Char('.') + toString(propertyId) + << "on line" << propertyId->identifierToken.startLine + << "column" << propertyId->identifierToken.startColumn; return hasQuotes ? QVariant(cleanedValue) : cleverConvert(cleanedValue); } From f55ec2f930b47717827f3a407c4e62034f95c3e7 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 21 Jan 2022 14:07:29 +0100 Subject: [PATCH 6/6] StudioWelcome: Use theming for extraction dialog Task-number: QDS-5984 Change-Id: I2e5d067e47208214c81d126ebbc78fd7e560b7a0 Reviewed-by: Brook Cronin Reviewed-by: Thomas Hartmann --- .../qml/downloaddialog/PushButton.ui.qml | 119 ++++++++++++++++++ .../studiowelcome/qml/downloaddialog/main.qml | 37 ++++-- 2 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 src/plugins/studiowelcome/qml/downloaddialog/PushButton.ui.qml diff --git a/src/plugins/studiowelcome/qml/downloaddialog/PushButton.ui.qml b/src/plugins/studiowelcome/qml/downloaddialog/PushButton.ui.qml new file mode 100644 index 00000000000..db64b5751d5 --- /dev/null +++ b/src/plugins/studiowelcome/qml/downloaddialog/PushButton.ui.qml @@ -0,0 +1,119 @@ + + +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +import QtQuick 2.15 +import QtQuick.Templates 2.15 +import ExampleCheckout 1.0 +import StudioTheme 1.0 + +Button { + id: control + + implicitWidth: Math.max( + buttonBackground ? buttonBackground.implicitWidth : 0, + textItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + buttonBackground ? buttonBackground.implicitHeight : 0, + textItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + property alias fontpixelSize: textItem.font.pixelSize + //property bool decorated: false + state: "normal" + + background: buttonBackground + Rectangle { + id: buttonBackground + color: "#00000000" + implicitWidth: 100 + implicitHeight: 40 + opacity: enabled ? 1 : 0.3 + radius: 2 + border.color: "#047eff" + anchors.fill: parent + } + + contentItem: textItem + + Text { + id: textItem + text: control.text + font.pixelSize: 18 + + opacity: enabled ? 1.0 : 0.3 + color: Values.themeTextColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + states: [ + State { + name: "normal" + when: !control.down && !control.hovered + + PropertyChanges { + target: buttonBackground + color: Values.themeControlBackground + border.color: Values.themeControlOutline + } + + PropertyChanges { + target: textItem + color: Values.themeTextColor + } + }, + State { + name: "hover" + when: control.hovered && !control.down + PropertyChanges { + target: textItem + color: Values.themeTextColor + } + + PropertyChanges { + target: buttonBackground + color: Values.themeControlBackgroundHover + border.color: Values.themeControlOutline + } + }, + State { + name: "activeQds" + when: control.down + PropertyChanges { + target: textItem + color: "#ffffff" + } + + PropertyChanges { + target: buttonBackground + color: "#2e769e" + border.color: "#00000000" + } + } + ] +} diff --git a/src/plugins/studiowelcome/qml/downloaddialog/main.qml b/src/plugins/studiowelcome/qml/downloaddialog/main.qml index 33acd7e3e4e..0f3bc5f46f4 100644 --- a/src/plugins/studiowelcome/qml/downloaddialog/main.qml +++ b/src/plugins/studiowelcome/qml/downloaddialog/main.qml @@ -30,17 +30,23 @@ import ExampleCheckout 1.0 import QtQuick.Layouts 1.11 import StudioFonts 1.0 +import StudioTheme 1.0 + Rectangle { + + property color currentThemeBackground: Values.welcomeScreenBackground + property color themeTextColor: Values.themeTextColor + id: root property alias url: downloader.url property string path: fileExtractor.targetPath width: 620 height: 300 - color: "#2d2e30" + color: root.currentThemeBackground - property color textColor: "#b9b9ba" + property color textColor: Values.themeTextColor signal canceled signal accepted @@ -51,7 +57,7 @@ Rectangle { StackLayout { id: stackLayout anchors.fill: parent - currentIndex: root.tempFile.length === 0 ? 0 : 1 + currentIndex: root.tempFile.length === 0 ? 1 : 1 FileExtractor { id: fileExtractor @@ -76,7 +82,7 @@ Rectangle { Layout.fillHeight: true Layout.fillWidth: true - DialogButton { + PushButton { id: button x: 532 y: 432 @@ -87,6 +93,7 @@ Rectangle { anchors.rightMargin: 20 enabled: false onClicked: stackLayout.currentIndex = 1 + } CoolProgressBar { @@ -106,7 +113,7 @@ Rectangle { anchors.horizontalCenter: parent.horizontalCenter } - DialogButton { + PushButton{ id: downloadbutton y: 420 enabled: !button.enabled @@ -119,6 +126,7 @@ Rectangle { downloadbutton.enabled = false downloader.start() } + } CircularIndicator { @@ -138,7 +146,7 @@ Rectangle { Layout.fillHeight: true Layout.fillWidth: true - DialogButton { + PushButton { id: nextPageDestination x: 532 y: 432 @@ -152,6 +160,7 @@ Rectangle { stackLayout.currentIndex = 2 fileExtractor.extract() } + } RowLayout { @@ -171,7 +180,7 @@ Rectangle { readOnly: true } - DialogButton { + PushButton{ id: browse text: qsTr("Browse") onClicked: fileExtractor.browse() @@ -189,7 +198,7 @@ Rectangle { visible: !nextPageDestination.enabled } - DialogButton { + PushButton{ id: button5 x: 400 y: 420 @@ -199,6 +208,7 @@ Rectangle { anchors.bottomMargin: 20 anchors.rightMargin: 20 onClicked: root.canceled() + } DialogLabel { @@ -215,8 +225,7 @@ Rectangle { Layout.fillHeight: true Layout.fillWidth: true - - DialogButton { + PushButton{ id: done x: 532 y: 432 @@ -227,6 +236,7 @@ Rectangle { anchors.rightMargin: 20 enabled: fileExtractor.finished onClicked: root.accepted() + } @@ -241,8 +251,7 @@ Rectangle { anchors.bottomMargin: 20 } - - DialogButton { + PushButton{ id: details x: 8 text: qsTr("Details") @@ -250,6 +259,7 @@ Rectangle { anchors.topMargin: 66 anchors.horizontalCenter: parent.horizontalCenter checkable: true + } @@ -291,7 +301,7 @@ Rectangle { Layout.fillHeight: true Layout.fillWidth: true - DialogButton { + PushButton{ id: finish x: 532 y: 432 @@ -301,6 +311,7 @@ Rectangle { anchors.bottomMargin: 20 anchors.rightMargin: 20 onClicked: root.canceled() + } DialogLabel {