forked from qt-creator/qt-creator
QmlDesigner: Add examples download path setting
Add a PathChooser to StudioSettingsPage which enables setting the location to which the QtDesignStudio examples are extracted. Task-number: QDS-6174 Change-Id: I99232edf3c1200a84daaadf4a0d118317a5ea009 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
8851810658
commit
5d660d7afe
@@ -28,11 +28,19 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/archive.h>
|
#include <utils/archive.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/networkaccessmanager.h>
|
#include <utils/networkaccessmanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <private/qqmldata_p.h>
|
#include <private/qqmldata_p.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/pluginspec.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
|
||||||
|
#include <studiowelcomeplugin.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -229,12 +237,9 @@ FileExtractor::FileExtractor(QObject *parent)
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_targetPath = Utils::FilePath::fromString(
|
m_targetPath = Utils::FilePath::fromString(
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
|
Core::ICore::settings()
|
||||||
|
->value(StudioWelcome::Internal::EXAMPLES_DOWNLOAD_PATH)
|
||||||
if (!m_targetPath.isEmpty())
|
.toString());
|
||||||
m_targetPath = m_targetPath.pathAppended("QtDesignStudio");
|
|
||||||
else
|
|
||||||
m_targetPath = "/temp/";
|
|
||||||
|
|
||||||
m_timer.setInterval(100);
|
m_timer.setInterval(100);
|
||||||
m_timer.setSingleShot(false);
|
m_timer.setSingleShot(false);
|
||||||
@@ -247,6 +252,32 @@ FileExtractor::FileExtractor(QObject *parent)
|
|||||||
|
|
||||||
emit birthTimeChanged();
|
emit birthTimeChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ExtensionSystem::PluginSpec *pluginSpec
|
||||||
|
= Utils::findOrDefault(ExtensionSystem::PluginManager::plugins(),
|
||||||
|
Utils::equal(&ExtensionSystem::PluginSpec::name,
|
||||||
|
QString("StudioWelcome")));
|
||||||
|
|
||||||
|
if (!pluginSpec)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ExtensionSystem::IPlugin *plugin = pluginSpec->plugin();
|
||||||
|
|
||||||
|
if (!plugin)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto studioWelcomePlugin = qobject_cast<StudioWelcome::Internal::StudioWelcomePlugin *>(plugin);
|
||||||
|
|
||||||
|
if (studioWelcomePlugin) {
|
||||||
|
QObject::connect(studioWelcomePlugin,
|
||||||
|
&StudioWelcome::Internal::StudioWelcomePlugin::examplesDownloadPathChanged,
|
||||||
|
this,
|
||||||
|
[this](const QString &path) {
|
||||||
|
m_targetPath = Utils::FilePath::fromString(path);
|
||||||
|
emit targetPathChanged();
|
||||||
|
emit targetFolderExistsChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileExtractor::~FileExtractor() {}
|
FileExtractor::~FileExtractor() {}
|
||||||
|
@@ -66,6 +66,7 @@
|
|||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
@@ -777,6 +778,18 @@ void setSettingIfDifferent(const QString &key, bool value, bool &dirty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Utils::FilePath defaultExamplesPath = Utils::FilePath::fromString(
|
||||||
|
QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::DocumentsLocation))
|
||||||
|
.pathAppended("QtDesignStudio");
|
||||||
|
|
||||||
|
static QString examplesPathSetting()
|
||||||
|
{
|
||||||
|
return Core::ICore::settings()
|
||||||
|
->value(EXAMPLES_DOWNLOAD_PATH, defaultExamplesPath.toString())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
WelcomeMode::~WelcomeMode()
|
WelcomeMode::~WelcomeMode()
|
||||||
{
|
{
|
||||||
delete m_modeWidget;
|
delete m_modeWidget;
|
||||||
@@ -786,19 +799,18 @@ StudioSettingsPage::StudioSettingsPage()
|
|||||||
: m_buildCheckBox(new QCheckBox(tr("Build")))
|
: m_buildCheckBox(new QCheckBox(tr("Build")))
|
||||||
, m_debugCheckBox(new QCheckBox(tr("Debug")))
|
, m_debugCheckBox(new QCheckBox(tr("Debug")))
|
||||||
, m_analyzeCheckBox(new QCheckBox(tr("Analyze")))
|
, m_analyzeCheckBox(new QCheckBox(tr("Analyze")))
|
||||||
|
, m_pathChooser(new Utils::PathChooser())
|
||||||
{
|
{
|
||||||
const QString toolTip = tr(
|
const QString toolTip = tr(
|
||||||
"Hide top-level menus with advanced functionality to simplify the UI. <b>Build</b> is "
|
"Hide top-level menus with advanced functionality to simplify the UI. <b>Build</b> is "
|
||||||
"generally not required in the context of Qt Design Studio.<b>Debug</b> and <b>Analyze</b>"
|
"generally not required in the context of Qt Design Studio.<b>Debug</b> and <b>Analyze</b>"
|
||||||
"are only required for debugging and profiling.");
|
"are only required for debugging and profiling.");
|
||||||
|
|
||||||
QVBoxLayout *boxLayout = new QVBoxLayout(this);
|
QVBoxLayout *boxLayout = new QVBoxLayout();
|
||||||
setLayout(boxLayout);
|
setLayout(boxLayout);
|
||||||
auto groupBox = new QGroupBox(tr("Hide Menu"));
|
auto groupBox = new QGroupBox(tr("Hide Menu"));
|
||||||
groupBox->setToolTip(toolTip);
|
groupBox->setToolTip(toolTip);
|
||||||
boxLayout->addWidget(groupBox);
|
boxLayout->addWidget(groupBox);
|
||||||
boxLayout->addSpacerItem(
|
|
||||||
new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
|
||||||
|
|
||||||
auto verticalLayout = new QVBoxLayout();
|
auto verticalLayout = new QVBoxLayout();
|
||||||
groupBox->setLayout(verticalLayout);
|
groupBox->setLayout(verticalLayout);
|
||||||
@@ -816,6 +828,28 @@ StudioSettingsPage::StudioSettingsPage()
|
|||||||
m_buildCheckBox->setChecked(hideBuildMenuSetting());
|
m_buildCheckBox->setChecked(hideBuildMenuSetting());
|
||||||
m_debugCheckBox->setChecked(hideDebugMenuSetting());
|
m_debugCheckBox->setChecked(hideDebugMenuSetting());
|
||||||
m_analyzeCheckBox->setChecked(hideAnalyzeMenuSetting());
|
m_analyzeCheckBox->setChecked(hideAnalyzeMenuSetting());
|
||||||
|
|
||||||
|
auto examplesGroupBox = new QGroupBox(tr("Examples"));
|
||||||
|
boxLayout->addWidget(examplesGroupBox);
|
||||||
|
|
||||||
|
auto horizontalLayout = new QHBoxLayout();
|
||||||
|
examplesGroupBox->setLayout(horizontalLayout);
|
||||||
|
|
||||||
|
auto label = new QLabel(tr("Examples path:"));
|
||||||
|
m_pathChooser->setFilePath(Utils::FilePath::fromString(examplesPathSetting()));
|
||||||
|
auto resetButton = new QPushButton(tr("Reset Path"));
|
||||||
|
|
||||||
|
connect(resetButton, &QPushButton::clicked, this, [this]() {
|
||||||
|
m_pathChooser->setFilePath(defaultExamplesPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
horizontalLayout->addWidget(label);
|
||||||
|
horizontalLayout->addWidget(m_pathChooser);
|
||||||
|
horizontalLayout->addWidget(resetButton);
|
||||||
|
|
||||||
|
|
||||||
|
boxLayout->addSpacerItem(
|
||||||
|
new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StudioSettingsPage::apply()
|
void StudioSettingsPage::apply()
|
||||||
@@ -840,6 +874,14 @@ void StudioSettingsPage::apply()
|
|||||||
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
|
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
|
||||||
restartDialog.exec();
|
restartDialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSettings *s = Core::ICore::settings();
|
||||||
|
const QString value = m_pathChooser->filePath().toString();
|
||||||
|
|
||||||
|
if (s->value(EXAMPLES_DOWNLOAD_PATH, false).toString() != value) {
|
||||||
|
s->setValue(EXAMPLES_DOWNLOAD_PATH, value);
|
||||||
|
emit s_pluginInstance->examplesDownloadPathChanged(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioWelcomeSettingsPage::StudioWelcomeSettingsPage()
|
StudioWelcomeSettingsPage::StudioWelcomeSettingsPage()
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -35,6 +36,8 @@ QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
|||||||
namespace StudioWelcome {
|
namespace StudioWelcome {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
const char EXAMPLES_DOWNLOAD_PATH[] = "StudioWelcome/ExamplesDownloadPath";
|
||||||
|
|
||||||
class StudioSettingsPage : public Core::IOptionsPageWidget
|
class StudioSettingsPage : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -46,6 +49,7 @@ private:
|
|||||||
QCheckBox *m_buildCheckBox;
|
QCheckBox *m_buildCheckBox;
|
||||||
QCheckBox *m_debugCheckBox;
|
QCheckBox *m_debugCheckBox;
|
||||||
QCheckBox *m_analyzeCheckBox;
|
QCheckBox *m_analyzeCheckBox;
|
||||||
|
Utils::PathChooser *m_pathChooser;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StudioWelcomeSettingsPage : public Core::IOptionsPage
|
class StudioWelcomeSettingsPage : public Core::IOptionsPage
|
||||||
@@ -76,6 +80,9 @@ public:
|
|||||||
void pauseRemoveSplashTimer();
|
void pauseRemoveSplashTimer();
|
||||||
void resumeRemoveSplashTimer();
|
void resumeRemoveSplashTimer();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void examplesDownloadPathChanged(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class WelcomeMode *m_welcomeMode = nullptr;
|
class WelcomeMode *m_welcomeMode = nullptr;
|
||||||
QTimer m_removeSplashTimer;
|
QTimer m_removeSplashTimer;
|
||||||
|
Reference in New Issue
Block a user