summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/launcher/ui/setupwizard/SearchWizardPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'archived/projt-launcher/launcher/ui/setupwizard/SearchWizardPage.cpp')
-rw-r--r--archived/projt-launcher/launcher/ui/setupwizard/SearchWizardPage.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/archived/projt-launcher/launcher/ui/setupwizard/SearchWizardPage.cpp b/archived/projt-launcher/launcher/ui/setupwizard/SearchWizardPage.cpp
new file mode 100644
index 0000000000..573c7844f7
--- /dev/null
+++ b/archived/projt-launcher/launcher/ui/setupwizard/SearchWizardPage.cpp
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// SPDX-FileCopyrightText: 2026 Project Tick
+// SPDX-FileContributor: Project Tick Team
+
+#include "SearchWizardPage.h"
+
+#include <QComboBox>
+#include <QLabel>
+#include <QVBoxLayout>
+
+#include "Application.h"
+#include "BuildConfig.h"
+#include "ui/widgets/HubSearchProvider.h"
+
+SearchWizardPage::SearchWizardPage(QWidget* parent) : BaseWizardPage(parent)
+{
+ setObjectName(QStringLiteral("searchPage"));
+
+ auto* layout = new QVBoxLayout(this);
+ layout->setContentsMargins(0, 0, 0, 0);
+
+ m_descriptionLabel = new QLabel(this);
+ m_descriptionLabel->setWordWrap(true);
+
+ m_providerCombo = new QComboBox(this);
+ for (const auto& provider : hubSearchProviders())
+ {
+ m_providerCombo->addItem(provider.displayName, provider.id);
+ }
+
+ const QString currentProvider =
+ APPLICATION->settings() ? normalizedHubSearchProviderId(APPLICATION->settings()->get("HubSearchEngine").toString())
+ : defaultHubSearchProviderId();
+ const int currentIndex = m_providerCombo->findData(currentProvider);
+ m_providerCombo->setCurrentIndex(currentIndex >= 0 ? currentIndex : 0);
+
+ layout->addWidget(m_descriptionLabel);
+ layout->addWidget(m_providerCombo);
+ layout->addStretch(1);
+
+ retranslate();
+}
+
+SearchWizardPage::~SearchWizardPage() = default;
+
+bool SearchWizardPage::validatePage()
+{
+ if (APPLICATION->settings())
+ {
+ APPLICATION->settings()->set("HubSearchEngine", m_providerCombo->currentData().toString());
+ }
+ return true;
+}
+
+void SearchWizardPage::retranslate()
+{
+ setTitle(tr("Search"));
+ setSubTitle(tr("Choose the default search engine for Launcher Hub."));
+ m_descriptionLabel->setText(tr("When you type plain text like \"How to install Linux?\" into the Hub address bar, %1 will search with this provider by default.")
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME));
+}