forked from qt-creator/qt-creator
QtSupport: Use setupXXX for welcome page contributions
Change-Id: I5ff8a5527c908381bb67f011d39aaeb926a89c40 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/iwelcomepage.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
#include <coreplugin/welcomepagehelper.h>
|
#include <coreplugin/welcomepagehelper.h>
|
||||||
@@ -42,17 +43,27 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QtSupport {
|
namespace QtSupport::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
const char C_FALLBACK_ROOT[] = "ProjectsFallbackRoot";
|
const char C_FALLBACK_ROOT[] = "ProjectsFallbackRoot";
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(ExampleSetModel, s_exampleSetModel)
|
Q_GLOBAL_STATIC(ExampleSetModel, s_exampleSetModel)
|
||||||
|
|
||||||
ExamplesWelcomePage::ExamplesWelcomePage(bool showExamples)
|
class ExamplesWelcomePage final : public Core::IWelcomePage
|
||||||
: m_showExamples(showExamples)
|
|
||||||
{
|
{
|
||||||
}
|
public:
|
||||||
|
explicit ExamplesWelcomePage(bool showExamples)
|
||||||
|
: m_showExamples(showExamples)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString title() const final;
|
||||||
|
int priority() const final;
|
||||||
|
Id id() const final;
|
||||||
|
QWidget *createWidget() const final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const bool m_showExamples;
|
||||||
|
};
|
||||||
|
|
||||||
QString ExamplesWelcomePage::title() const
|
QString ExamplesWelcomePage::title() const
|
||||||
{
|
{
|
||||||
@@ -69,7 +80,7 @@ Id ExamplesWelcomePage::id() const
|
|||||||
return m_showExamples ? "Examples" : "Tutorials";
|
return m_showExamples ? "Examples" : "Tutorials";
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath ExamplesWelcomePage::copyToAlternativeLocation(const FilePath &proFile,
|
static FilePath copyToAlternativeLocation(const FilePath &proFile,
|
||||||
FilePaths &filesToOpen,
|
FilePaths &filesToOpen,
|
||||||
const FilePaths &dependencies)
|
const FilePaths &dependencies)
|
||||||
{
|
{
|
||||||
@@ -106,12 +117,12 @@ FilePath ExamplesWelcomePage::copyToAlternativeLocation(const FilePath &proFile,
|
|||||||
enum { Copy = QDialog::Accepted + 1, Keep = QDialog::Accepted + 2 };
|
enum { Copy = QDialog::Accepted + 1, Keep = QDialog::Accepted + 2 };
|
||||||
auto bb = new QDialogButtonBox;
|
auto bb = new QDialogButtonBox;
|
||||||
QPushButton *copyBtn = bb->addButton(Tr::tr("&Copy Project and Open"), QDialogButtonBox::AcceptRole);
|
QPushButton *copyBtn = bb->addButton(Tr::tr("&Copy Project and Open"), QDialogButtonBox::AcceptRole);
|
||||||
connect(copyBtn, &QAbstractButton::released, &d, [&d] { d.done(Copy); });
|
QObject::connect(copyBtn, &QAbstractButton::released, &d, [&d] { d.done(Copy); });
|
||||||
copyBtn->setDefault(true);
|
copyBtn->setDefault(true);
|
||||||
QPushButton *keepBtn = bb->addButton(Tr::tr("&Keep Project and Open"), QDialogButtonBox::RejectRole);
|
QPushButton *keepBtn = bb->addButton(Tr::tr("&Keep Project and Open"), QDialogButtonBox::RejectRole);
|
||||||
connect(keepBtn, &QAbstractButton::released, &d, [&d] { d.done(Keep); });
|
QObject::connect(keepBtn, &QAbstractButton::released, &d, [&d] { d.done(Keep); });
|
||||||
lay->addWidget(bb, 2, 0, 1, 2);
|
lay->addWidget(bb, 2, 0, 1, 2);
|
||||||
connect(chooser, &PathChooser::validChanged, copyBtn, &QWidget::setEnabled);
|
QObject::connect(chooser, &PathChooser::validChanged, copyBtn, &QWidget::setEnabled);
|
||||||
int code = d.exec();
|
int code = d.exec();
|
||||||
if (code == Copy) {
|
if (code == Copy) {
|
||||||
const QString exampleDirName = projectDir.fileName();
|
const QString exampleDirName = projectDir.fileName();
|
||||||
@@ -162,7 +173,7 @@ FilePath ExamplesWelcomePage::copyToAlternativeLocation(const FilePath &proFile,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExamplesWelcomePage::openProject(const ExampleItem *item)
|
static void openProject(const ExampleItem *item)
|
||||||
{
|
{
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
FilePath proFile = item->projectPath;
|
FilePath proFile = item->projectPath;
|
||||||
@@ -220,7 +231,7 @@ protected:
|
|||||||
if (exampleItem->isVideo)
|
if (exampleItem->isVideo)
|
||||||
QDesktopServices::openUrl(QUrl::fromUserInput(exampleItem->videoUrl));
|
QDesktopServices::openUrl(QUrl::fromUserInput(exampleItem->videoUrl));
|
||||||
else if (exampleItem->hasSourceCode)
|
else if (exampleItem->hasSourceCode)
|
||||||
ExamplesWelcomePage::openProject(exampleItem);
|
openProject(exampleItem);
|
||||||
else
|
else
|
||||||
HelpManager::showHelpUrl(QUrl::fromUserInput(exampleItem->docUrl),
|
HelpManager::showHelpUrl(QUrl::fromUserInput(exampleItem->docUrl),
|
||||||
HelpManager::ExternalHelpAlways);
|
HelpManager::ExternalHelpAlways);
|
||||||
@@ -345,5 +356,10 @@ QWidget *ExamplesWelcomePage::createWidget() const
|
|||||||
return new ExamplesPageWidget(m_showExamples);
|
return new ExamplesPageWidget(m_showExamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
void setupGettingStartedWelcomePage()
|
||||||
} // namespace QtSupport
|
{
|
||||||
|
static ExamplesWelcomePage examplesPage{true};
|
||||||
|
static ExamplesWelcomePage tutorialPage{false};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // QtSupport::Internal
|
||||||
|
@@ -3,34 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/iwelcomepage.h>
|
namespace QtSupport::Internal {
|
||||||
#include <utils/filepath.h>
|
|
||||||
|
|
||||||
namespace QtSupport {
|
void setupGettingStartedWelcomePage();
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class ExampleItem;
|
} // QtSupport::Internal
|
||||||
|
|
||||||
class ExamplesWelcomePage : public Core::IWelcomePage
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ExamplesWelcomePage(bool showExamples);
|
|
||||||
|
|
||||||
QString title() const final;
|
|
||||||
int priority() const final;
|
|
||||||
Utils::Id id() const final;
|
|
||||||
QWidget *createWidget() const final;
|
|
||||||
|
|
||||||
static void openProject(const ExampleItem *item);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static Utils::FilePath copyToAlternativeLocation(const Utils::FilePath &fileInfo,
|
|
||||||
Utils::FilePaths &filesToOpen,
|
|
||||||
const Utils::FilePaths &dependencies);
|
|
||||||
const bool m_showExamples;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace QtSupport
|
|
||||||
|
@@ -50,9 +50,6 @@ class QtSupportPluginPrivate
|
|||||||
public:
|
public:
|
||||||
QtOptionsPage qtOptionsPage;
|
QtOptionsPage qtOptionsPage;
|
||||||
|
|
||||||
ExamplesWelcomePage examplesPage{true};
|
|
||||||
ExamplesWelcomePage tutorialPage{false};
|
|
||||||
|
|
||||||
QtOutputFormatterFactory qtOutputFormatterFactory;
|
QtOutputFormatterFactory qtOutputFormatterFactory;
|
||||||
|
|
||||||
UicGeneratorFactory uicGeneratorFactory;
|
UicGeneratorFactory uicGeneratorFactory;
|
||||||
@@ -113,6 +110,7 @@ void QtSupportPlugin::initialize()
|
|||||||
|
|
||||||
setupDesktopQtVersion();
|
setupDesktopQtVersion();
|
||||||
setupEmbeddedLinuxQtVersion();
|
setupEmbeddedLinuxQtVersion();
|
||||||
|
setupGettingStartedWelcomePage();
|
||||||
|
|
||||||
theProcessRunner() = processRunnerCallback;
|
theProcessRunner() = processRunnerCallback;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user