Marketplace: Move closer to current plugin setup pattern

Change-Id: I5c88fbe88240c826deb8aef2d1b5ee0f94f2e888
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-07-17 09:25:54 +02:00
parent 3646b65f58
commit d240cbb261
3 changed files with 30 additions and 46 deletions

View File

@@ -7,16 +7,17 @@
namespace Marketplace::Internal {
class MarketplacePlugin : public ExtensionSystem::IPlugin
class MarketplacePlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Marketplace.json")
void initialize() {}
QtMarketplaceWelcomePage welcomePage;
void initialize() final
{
setupQtMarketPlaceWelcomePage(this);
}
};
} // namespace Marketplace
} // Marketplace::Internal
#include "marketplaceplugin.moc"

View File

@@ -18,29 +18,13 @@
#include <QLabel>
#include <QLineEdit>
#include <QShowEvent>
#include <QVBoxLayout>
namespace Marketplace {
namespace Internal {
using namespace Core;
using namespace Utils;
QString QtMarketplaceWelcomePage::title() const
{
return Tr::tr("Marketplace");
}
namespace Marketplace::Internal {
int QtMarketplaceWelcomePage::priority() const
{
return 60;
}
Utils::Id QtMarketplaceWelcomePage::id() const
{
return "Marketplace";
}
class QtMarketplacePageWidget : public QWidget
class QtMarketplacePageWidget final : public QWidget
{
public:
QtMarketplacePageWidget()
@@ -100,7 +84,7 @@ public:
this, &QtMarketplacePageWidget::onTagClicked);
}
void showEvent(QShowEvent *event) override
void showEvent(QShowEvent *event) final
{
if (!m_initialized) {
m_initialized = true;
@@ -123,11 +107,23 @@ private:
bool m_initialized = false;
};
// QtMarketplaceWelcomePage
QWidget *QtMarketplaceWelcomePage::createWidget() const
class QtMarketplaceWelcomePage final : public IWelcomePage
{
return new QtMarketplacePageWidget;
public:
QtMarketplaceWelcomePage() = default;
QString title() const final { return Tr::tr("Marketplace"); }
int priority() const final { return 60; }
Utils::Id id() const final { return "Marketplace"; }
QWidget *createWidget() const final { return new QtMarketplacePageWidget; }
};
void setupQtMarketPlaceWelcomePage(QObject *guard)
{
auto page = new QtMarketplaceWelcomePage;
page->setParent(guard);
}
} // namespace Internal
} // namespace Marketplace
} // Marketplace::Internal

View File

@@ -3,23 +3,10 @@
#pragma once
#include <coreplugin/iwelcomepage.h>
#include <QObject>
#include <QCoreApplication>
namespace Marketplace::Internal {
namespace Marketplace {
namespace Internal {
void setupQtMarketPlaceWelcomePage(QObject *guard);
class QtMarketplaceWelcomePage : public Core::IWelcomePage
{
public:
QtMarketplaceWelcomePage() = default;
QString title() const final;
int priority() const final;
Utils::Id id() const final;
QWidget *createWidget() const final;
};
} // namespace Internal
} // namespace Marketplace
} // namespace Marketplace::Internal