From 386e3c3c121ba75a7077379a236eff3b12b3e220 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Jul 2024 15:18:12 +0200 Subject: [PATCH] QmlJsEditor: Use a SelectionAspect for the open mode choice Change-Id: Ieac7371bfa71dfc5387e442d717eb53a4fae6fb8 Reviewed-by: Semih Yavuz --- .../qmljseditor/qmljseditorsettings.cpp | 19 +++++++------------ src/plugins/qmljseditor/qmljseditorsettings.h | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/plugins/qmljseditor/qmljseditorsettings.cpp b/src/plugins/qmljseditor/qmljseditorsettings.cpp index 8c67b009926..a06610405db 100644 --- a/src/plugins/qmljseditor/qmljseditorsettings.cpp +++ b/src/plugins/qmljseditor/qmljseditorsettings.cpp @@ -223,6 +223,12 @@ QmlJsEditingSettings::QmlJsEditingSettings() foldAuxData.setLabelText(Tr::tr("Auto-fold auxiliary data")); uiQmlOpenMode.setSettingsKey(group, UIQML_OPEN_MODE); + uiQmlOpenMode.setUseDataAsSavedValue(); + uiQmlOpenMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); + uiQmlOpenMode.setLabelText(Tr::tr("Open .ui.qml files with:")); + uiQmlOpenMode.addOption({Tr::tr("Always Ask")}); + uiQmlOpenMode.addOption({Tr::tr("Qt Design Studio"), {}, Core::Constants::MODE_DESIGN}); + uiQmlOpenMode.addOption({Tr::tr("Qt Creator"), {}, Core::Constants::MODE_EDIT}); useLatestQmlls.setSettingsKey(group, USE_LATEST_QMLLS); useLatestQmlls.setEnabler(&useQmlls); @@ -344,15 +350,6 @@ public: { QmlJsEditingSettings &s = settings(); - uiQmlOpenComboBox = new QComboBox; - uiQmlOpenComboBox->addItem(Tr::tr("Always Ask"), ""); - uiQmlOpenComboBox->addItem(Tr::tr("Qt Design Studio"), Core::Constants::MODE_DESIGN); - uiQmlOpenComboBox->addItem(Tr::tr("Qt Creator"), Core::Constants::MODE_EDIT); - const int comboIndex = qMax(0, uiQmlOpenComboBox->findData(s.uiQmlOpenMode())); - uiQmlOpenComboBox->setCurrentIndex(comboIndex); - uiQmlOpenComboBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - uiQmlOpenComboBox->setSizeAdjustPolicy(QComboBox::QComboBox::AdjustToContents); - analyzerMessageModel.setHeader({Tr::tr("Enabled"), Tr::tr("Disabled for non Qt Quick UI"), Tr::tr("Message")}); @@ -398,7 +395,7 @@ public: title(Tr::tr("Features")), Column { s.foldAuxData, - Form { Tr::tr("Open .ui.qml files with:"), uiQmlOpenComboBox }, + Row { s.uiQmlOpenMode, st } }, }, Group{ @@ -432,7 +429,6 @@ public: { QmlJsEditingSettings &s = settings(); s.apply(); - s.uiQmlOpenMode.setValue(uiQmlOpenComboBox->currentData().toString()); QList disabled; QList disabledForNonQuickUi; @@ -481,7 +477,6 @@ private: menu.exec(analyzerMessagesView->mapToGlobal(position)); } - QComboBox *uiQmlOpenComboBox; QTreeView *analyzerMessagesView; Utils::TreeModel analyzerMessageModel; }; diff --git a/src/plugins/qmljseditor/qmljseditorsettings.h b/src/plugins/qmljseditor/qmljseditorsettings.h index bdcbfe74cf9..040d6a363ee 100644 --- a/src/plugins/qmljseditor/qmljseditorsettings.h +++ b/src/plugins/qmljseditor/qmljseditorsettings.h @@ -34,7 +34,7 @@ public: Utils::BoolAspect ignoreMinimumQmllsVersion{this}; Utils::BoolAspect disableBuiltinCodemodel{this}; Utils::BoolAspect generateQmllsIniFiles{this}; - Utils::StringAspect uiQmlOpenMode{this}; + Utils::SelectionAspect uiQmlOpenMode{this}; Utils::StringAspect formatCommand{this}; Utils::StringAspect formatCommandOptions{this}; Utils::IntegersAspect disabledMessages{this};