forked from qt-creator/qt-creator
Replace modal dialog with InfoBar in QmlProject
Change-Id: I0dfa8722748ae67ff29ad0aeb72681ee8c413d28 Fixes: QDS-3765 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
@@ -86,7 +86,6 @@ void DesignerSettings::fromSettings(QSettings *settings)
|
||||
restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList());
|
||||
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
|
||||
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true);
|
||||
restoreValue(settings, DesignerSettingsKey::OPEN_QMLPROJECT_IN_QDS, false);
|
||||
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
|
||||
@@ -70,7 +70,6 @@ const char ENABLE_TIMELINEVIEW[] = "EnableTimelineView";
|
||||
const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent";
|
||||
const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
|
||||
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>
|
||||
|
||||
@@ -178,8 +178,6 @@ DesignerSettings SettingsPageWidget::settings() const
|
||||
m_ui.featureTimelineEditorCheckBox->isChecked());
|
||||
settings.insert(DesignerSettingsKey::ALWAYS_DESIGN_MODE,
|
||||
m_ui.designerAlwaysDesignModeCheckBox->isChecked());
|
||||
settings.insert(DesignerSettingsKey::OPEN_QMLPROJECT_IN_QDS,
|
||||
m_ui.openQmlprojectInQDSCheckBox->isChecked());
|
||||
|
||||
return settings;
|
||||
}
|
||||
@@ -249,13 +247,10 @@ void SettingsPageWidget::setSettings(const DesignerSettings &settings)
|
||||
DesignerSettingsKey::ALWAYS_DESIGN_MODE).toBool());
|
||||
m_ui.featureTimelineEditorCheckBox->setChecked(settings.value(
|
||||
DesignerSettingsKey::ENABLE_TIMELINEVIEW).toBool());
|
||||
m_ui.openQmlprojectInQDSCheckBox->setChecked(settings.value(
|
||||
DesignerSettingsKey::OPEN_QMLPROJECT_IN_QDS).toBool());
|
||||
|
||||
if (settings.value(DesignerSettingsKey::STANDALONE_MODE).toBool()) {
|
||||
m_ui.debugGroupBox->hide();
|
||||
m_ui.featureTimelineEditorCheckBox->hide();
|
||||
m_ui.openQmlprojectInQDSCheckBox->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -430,13 +430,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="openQmlprojectInQDSCheckBox">
|
||||
<property name="text">
|
||||
<string>Open "Qt Quick Prototype" projects (.qmlproject) in Qt Design Studio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
@@ -73,6 +73,24 @@ Q_LOGGING_CATEGORY(infoLogger, "QmlProjectManager.QmlBuildSystem", QtInfoMsg)
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
const char openInQDSAppSetting[] = "OpenInQDSApp";
|
||||
|
||||
static void openQDS(const QString &qdsPath, const Utils::FilePath &fileName)
|
||||
{
|
||||
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(),
|
||||
fileName.fileName(),
|
||||
QObject::tr("Failed to start Qt Design Studio."));
|
||||
}
|
||||
}
|
||||
|
||||
QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
|
||||
{
|
||||
@@ -95,45 +113,16 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
|
||||
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."));
|
||||
}
|
||||
if (Core::ICore::infoBar()->canInfoBeAdded(openInQDSAppSetting)) {
|
||||
Utils::InfoBarEntry
|
||||
info(openInQDSAppSetting,
|
||||
tr("Would you like to open the project in Qt Design Studio?"),
|
||||
Utils::InfoBarEntry::GlobalSuppression::Enabled);
|
||||
info.setCustomButtonInfo(tr("Open in Qt Design Studio"), [&, qdsPath, fileName] {
|
||||
Core::ICore::infoBar()->removeInfo(openInQDSAppSetting);
|
||||
openQDS(qdsPath, fileName);
|
||||
});
|
||||
Core::ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user