From af95f81a9b6798cd573c7d9a1dd5ce2c22a98639 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 19 Sep 2024 15:11:49 +0200 Subject: [PATCH] Core: Add Terms & Conditions check to install wizard Change-Id: I71eb880acf835c2c26530036199bb00e05c98697 Reviewed-by: Alessandro Portale --- .../coreplugin/plugininstallwizard.cpp | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp index 4bb7fd263c0..bdae4e6395f 100644 --- a/src/plugins/coreplugin/plugininstallwizard.cpp +++ b/src/plugins/coreplugin/plugininstallwizard.cpp @@ -252,6 +252,13 @@ public: bool isComplete() const final { return m_isComplete; } + int nextId() const override + { + if (!m_data->pluginSpec || !m_data->pluginSpec->termsAndConditions()) + return WizardPage::nextId() + 1; + return WizardPage::nextId(); + } + std::unique_ptr m_tempDir; TaskTreeRunner m_taskTreeRunner; InfoLabel *m_label = nullptr; @@ -360,6 +367,48 @@ private: Data *m_data = nullptr; }; +class AcceptTermsAndConditionsPage : public WizardPage +{ +public: + AcceptTermsAndConditionsPage(Data *data, QWidget *parent) + : WizardPage(parent) + , m_data(data) + { + setTitle(Tr::tr("Accept Terms and Conditions")); + + using namespace Layouting; + // clang-format off + Column { + Label { bindTo(&m_intro) }, br, + TextEdit { + bindTo(&m_terms), + readOnly(true), + }, br, + m_accept = new QCheckBox(Tr::tr("I accept the terms and conditions.")), + }.attachTo(this); + // clang-format on + + connect(m_accept, &QCheckBox::toggled, this, [this]() { emit completeChanged(); }); + } + + void initializePage() final + { + QTC_ASSERT(m_data->pluginSpec, return); + m_intro->setText(Tr::tr("The plugin %1 requires you to accept the following terms and " + "conditions:") + .arg(m_data->pluginSpec->name())); + m_terms->setMarkdown(m_data->pluginSpec->termsAndConditions()->text); + } + + bool isComplete() const final { return m_accept->isChecked(); } + +private: + Data *m_data = nullptr; + QLabel *m_intro = nullptr; + QCheckBox *m_accept = nullptr; + QTextEdit *m_terms = nullptr; +}; + static std::function postCopyOperation() { return [](const FilePath &filePath) { @@ -418,6 +467,9 @@ bool executePluginInstallWizard(const FilePath &archive) auto checkArchivePage = new CheckArchivePage(&data, &wizard); wizard.addPage(checkArchivePage); + auto acceptTAndCPage = new AcceptTermsAndConditionsPage(&data, &wizard); + wizard.addPage(acceptTAndCPage); + auto installLocationPage = new InstallLocationPage(&data, &wizard); wizard.addPage(installLocationPage);