diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-01-09 04:38:35 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-01-09 04:38:35 +0100 |
commit | c08053d8b87de4d0fd4f9ac51021e03dfd851420 (patch) | |
tree | 8c947a06781438d8dc2e139e81634bf39b7f3a76 /application/setupwizard | |
parent | e71786d7b97c6e3b7aa91d085c935ef67832abc3 (diff) | |
download | MultiMC-c08053d8b87de4d0fd4f9ac51021e03dfd851420.tar MultiMC-c08053d8b87de4d0fd4f9ac51021e03dfd851420.tar.gz MultiMC-c08053d8b87de4d0fd4f9ac51021e03dfd851420.tar.lz MultiMC-c08053d8b87de4d0fd4f9ac51021e03dfd851420.tar.xz MultiMC-c08053d8b87de4d0fd4f9ac51021e03dfd851420.zip |
NOISSUE split out language selection widget, use it in settings
Diffstat (limited to 'application/setupwizard')
-rw-r--r-- | application/setupwizard/LanguageWizardPage.cpp | 55 | ||||
-rw-r--r-- | application/setupwizard/LanguageWizardPage.h | 11 |
2 files changed, 10 insertions, 56 deletions
diff --git a/application/setupwizard/LanguageWizardPage.cpp b/application/setupwizard/LanguageWizardPage.cpp index 9a8fd37f..ca93c6f5 100644 --- a/application/setupwizard/LanguageWizardPage.cpp +++ b/application/setupwizard/LanguageWizardPage.cpp @@ -2,41 +2,19 @@ #include <MultiMC.h> #include <translations/TranslationsModel.h> +#include "widgets/LanguageSelectionWidget.h" #include <QVBoxLayout> -#include <QTreeView> -#include <QHeaderView> -#include <QLabel> LanguageWizardPage::LanguageWizardPage(QWidget *parent) : BaseWizardPage(parent) { setObjectName(QStringLiteral("languagePage")); - verticalLayout = new QVBoxLayout(this); - verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - languageView = new QTreeView(this); - languageView->setObjectName(QStringLiteral("languageView")); - languageView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - languageView->setAlternatingRowColors(true); - languageView->setRootIsDecorated(false); - languageView->setItemsExpandable(false); - languageView->setWordWrap(true); - languageView->header()->setCascadingSectionResizes(true); - languageView->header()->setStretchLastSection(false); - verticalLayout->addWidget(languageView); - helpUsLabel = new QLabel(this); - helpUsLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse); - helpUsLabel->setOpenExternalLinks(true); - helpUsLabel->setWordWrap(true); - verticalLayout->addWidget(helpUsLabel); - retranslate(); + auto layout = new QVBoxLayout(this); + mainWidget = new LanguageSelectionWidget(this); + layout->setContentsMargins(0,0,0,0); + layout->addWidget(mainWidget); - auto translations = MMC->translations(); - auto index = translations->selectedIndex(); - languageView->setModel(translations.get()); - languageView->setCurrentIndex(index); - languageView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - languageView->header()->setSectionResizeMode(0, QHeaderView::Stretch); - connect(languageView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &LanguageWizardPage::languageRowChanged); + retranslate(); } LanguageWizardPage::~LanguageWizardPage() @@ -57,8 +35,7 @@ void LanguageWizardPage::refresh() bool LanguageWizardPage::validatePage() { auto settings = MMC->settings(); - auto translations = MMC->translations(); - QString key = translations->data(languageView->currentIndex(), Qt::UserRole).toString(); + QString key = mainWidget->getSelectedLanguageKey(); settings->set("Language", key); return true; } @@ -67,21 +44,5 @@ void LanguageWizardPage::retranslate() { setTitle(tr("Language")); setSubTitle(tr("Select the language to use in MultiMC")); - QString text = - tr("Don't see your language or the quality is poor?") + - "<br/>" + - QString("<a href=\"https://github.com/MultiMC/MultiMC5/wiki/Translating-MultiMC\">%1</a>").arg("Help us with translations!"); - helpUsLabel->setText(text); -} - -void LanguageWizardPage::languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous) -{ - if (current == previous) - { - return; - } - auto translations = MMC->translations(); - QString key = translations->data(current, Qt::UserRole).toString(); - translations->selectLanguage(key); - translations->updateLanguage(key); + mainWidget->retranslate(); } diff --git a/application/setupwizard/LanguageWizardPage.h b/application/setupwizard/LanguageWizardPage.h index bfc02c95..45a0e5c0 100644 --- a/application/setupwizard/LanguageWizardPage.h +++ b/application/setupwizard/LanguageWizardPage.h @@ -2,9 +2,7 @@ #include "BaseWizardPage.h" -class QVBoxLayout; -class QTreeView; -class QLabel; +class LanguageSelectionWidget; class LanguageWizardPage : public BaseWizardPage { @@ -23,11 +21,6 @@ public: protected: void retranslate() override; -protected slots: - void languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous); - private: - QVBoxLayout *verticalLayout = nullptr; - QTreeView *languageView = nullptr; - QLabel *helpUsLabel = nullptr; + LanguageSelectionWidget *mainWidget = nullptr; }; |