Improve Qt Design Studio visibility in Qt Creator

Fixes: QDS-3765
Change-Id: I877da7c0caf153a48c17dbc9ced87ef54c1a082c
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Aleksei German
2021-03-09 17:53:36 +01:00
parent 637d45c66a
commit 3ad3f3ec16
5 changed files with 81 additions and 6 deletions

View File

@@ -86,6 +86,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList()); restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList());
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true); restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true); restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true);
restoreValue(settings, DesignerSettingsKey::OPEN_QMLPROJECT_IN_QDS, false);
settings->endGroup(); settings->endGroup();
settings->endGroup(); settings->endGroup();

View File

@@ -70,6 +70,7 @@ const char ENABLE_TIMELINEVIEW[] = "EnableTimelineView";
const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent"; const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent";
const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode"; const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer"; const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
const char OPEN_QMLPROJECT_IN_QDS[] = "OpenQmlprojectInQDS"; /* This key value is used in QmlProjectManager */
} }
class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant> class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant>

View File

@@ -178,6 +178,8 @@ DesignerSettings SettingsPageWidget::settings() const
m_ui.featureTimelineEditorCheckBox->isChecked()); m_ui.featureTimelineEditorCheckBox->isChecked());
settings.insert(DesignerSettingsKey::ALWAYS_DESIGN_MODE, settings.insert(DesignerSettingsKey::ALWAYS_DESIGN_MODE,
m_ui.designerAlwaysDesignModeCheckBox->isChecked()); m_ui.designerAlwaysDesignModeCheckBox->isChecked());
settings.insert(DesignerSettingsKey::OPEN_QMLPROJECT_IN_QDS,
m_ui.openQmlprojectInQDSCheckBox->isChecked());
return settings; return settings;
} }
@@ -247,10 +249,13 @@ void SettingsPageWidget::setSettings(const DesignerSettings &settings)
DesignerSettingsKey::ALWAYS_DESIGN_MODE).toBool()); DesignerSettingsKey::ALWAYS_DESIGN_MODE).toBool());
m_ui.featureTimelineEditorCheckBox->setChecked(settings.value( m_ui.featureTimelineEditorCheckBox->setChecked(settings.value(
DesignerSettingsKey::ENABLE_TIMELINEVIEW).toBool()); DesignerSettingsKey::ENABLE_TIMELINEVIEW).toBool());
m_ui.openQmlprojectInQDSCheckBox->setChecked(settings.value(
DesignerSettingsKey::OPEN_QMLPROJECT_IN_QDS).toBool());
if (settings.value(DesignerSettingsKey::STANDALONE_MODE).toBool()) { if (settings.value(DesignerSettingsKey::STANDALONE_MODE).toBool()) {
m_ui.debugGroupBox->hide(); m_ui.debugGroupBox->hide();
m_ui.featureTimelineEditorCheckBox->hide(); m_ui.featureTimelineEditorCheckBox->hide();
m_ui.openQmlprojectInQDSCheckBox->hide();
} }
} }

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>960</width> <width>973</width>
<height>840</height> <height>862</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -416,6 +416,13 @@
<string>Features</string> <string>Features</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QCheckBox" name="designerAlwaysDesignModeCheckBox">
<property name="text">
<string>Always open ui.qml files in Design mode</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QCheckBox" name="featureTimelineEditorCheckBox"> <widget class="QCheckBox" name="featureTimelineEditorCheckBox">
<property name="text"> <property name="text">
@@ -423,10 +430,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="designerAlwaysDesignModeCheckBox"> <widget class="QCheckBox" name="openQmlprojectInQDSCheckBox">
<property name="text"> <property name="text">
<string>Always open ui.qml files in Design mode</string> <string>Open &quot;Qt Quick Prototype&quot; projects (.qmlproject) in Qt Design Studio</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@@ -53,11 +53,14 @@
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/checkablemessagebox.h>
#include <QDebug> #include <QDebug>
#include <QLoggingCategory>
#include <QMessageBox>
#include <QRegularExpression> #include <QRegularExpression>
#include <QTextCodec> #include <QTextCodec>
#include <QLoggingCategory> #include <QTimer>
using namespace Core; using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -79,6 +82,64 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
setNeedsBuildConfigurations(false); setNeedsBuildConfigurations(false);
setBuildSystemCreator([](Target *t) { return new QmlBuildSystem(t); }); setBuildSystemCreator([](Target *t) { return new QmlBuildSystem(t); });
QSettings *settings = Core::ICore::settings();
const QString qdsStandaloneEntry = "QML/Designer/StandAloneMode"; //entry from qml settings
const QString qdsInstallationEntry = "QML/Designer/DesignStudioInstallation"; //set in installer
const bool isDesigner = settings->value(qdsStandaloneEntry, false).toBool();
if (!isDesigner) {
const QString qdsPath = settings->value(qdsInstallationEntry).toString();
const bool foundQDS = Utils::FilePath::fromString(qdsPath).exists();
if (foundQDS) {
auto lambda = [fileName, qdsPath]() {
const QString projectName = fileName.fileName();
const QString doNotShowAgainKey = "OpenInQDSApp"; //entry that is used only here
const QString openInQDSKey = "QML/Designer/OpenQmlprojectInQDS"; //entry from qml settings
QSettings *settings = Core::ICore::settings();
const bool shouldAskAgain = Utils::CheckableMessageBox::shouldAskAgain(settings,
doNotShowAgainKey);
bool openInQDS = false;
if (shouldAskAgain) {
bool dontShow = false;
const auto dialogResult =
Utils::CheckableMessageBox::question(Core::ICore::dialogParent(),
projectName,
tr("Would you like to open the project in Qt Design Studio?"),
tr("Do not show this dialog anymore."),
&dontShow);
openInQDS = (dialogResult == QDialogButtonBox::Yes);
if (dontShow) {
Utils::CheckableMessageBox::doNotAskAgain(settings, doNotShowAgainKey);
settings->setValue(openInQDSKey, openInQDS);
}
} else {
openInQDS = settings->value(openInQDSKey, false).toBool();
}
if (openInQDS) {
bool qdsStarted = false;
//-a and -client arguments help to append project to open design studio application
if (Utils::HostOsInfo::isMacHost())
qdsStarted = QProcess::startDetached("/usr/bin/open", {"-a", qdsPath, fileName.toString()});
else
qdsStarted = QProcess::startDetached(qdsPath, {"-client", fileName.toString()});
if (!qdsStarted) {
QMessageBox::warning(Core::ICore::dialogParent(),
projectName,
tr("Failed to start Qt Design Studio."));
}
}
};
QTimer::singleShot(0, this, lambda);
}
}
} }
QmlBuildSystem::QmlBuildSystem(Target *target) QmlBuildSystem::QmlBuildSystem(Target *target)