Merge pull request #1345 from Trial97/time2
feat:Added option to use system locale
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
#include "LanguageSelectionWidget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QTreeView>
|
||||
#include <QCheckBox>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "translations/TranslationsModel.h"
|
||||
#include "settings/Setting.h"
|
||||
#include "translations/TranslationsModel.h"
|
||||
|
||||
LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
LanguageSelectionWidget::LanguageSelectionWidget(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
@ -31,6 +31,13 @@ LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
||||
helpUsLabel->setWordWrap(true);
|
||||
verticalLayout->addWidget(helpUsLabel);
|
||||
|
||||
formatCheckbox = new QCheckBox(this);
|
||||
formatCheckbox->setObjectName(QStringLiteral("formatCheckbox"));
|
||||
formatCheckbox->setCheckState(APPLICATION->settings()->get("UseSystemLocale").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
connect(formatCheckbox, &QCheckBox::stateChanged,
|
||||
[this]() { APPLICATION->translations()->setUseSystemLocale(formatCheckbox->isChecked()); });
|
||||
verticalLayout->addWidget(formatCheckbox);
|
||||
|
||||
auto translations = APPLICATION->translations();
|
||||
auto index = translations->selectedIndex();
|
||||
languageView->setModel(translations.get());
|
||||
@ -38,7 +45,7 @@ LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
||||
languageView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
languageView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
connect(languageView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &LanguageSelectionWidget::languageRowChanged);
|
||||
verticalLayout->setContentsMargins(0,0,0,0);
|
||||
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
auto language_setting = APPLICATION->settings()->getSetting("Language");
|
||||
connect(language_setting.get(), &Setting::SettingChanged, this, &LanguageSelectionWidget::languageSettingChanged);
|
||||
@ -53,15 +60,14 @@ QString LanguageSelectionWidget::getSelectedLanguageKey() const
|
||||
void LanguageSelectionWidget::retranslate()
|
||||
{
|
||||
QString text = tr("Don't see your language or the quality is poor?<br/><a href=\"%1\">Help us with translations!</a>")
|
||||
.arg(BuildConfig.TRANSLATIONS_URL);
|
||||
.arg(BuildConfig.TRANSLATIONS_URL);
|
||||
helpUsLabel->setText(text);
|
||||
|
||||
formatCheckbox->setText(tr("Use system locales"));
|
||||
}
|
||||
|
||||
void LanguageSelectionWidget::languageRowChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
{
|
||||
if (current == previous)
|
||||
{
|
||||
if (current == previous) {
|
||||
return;
|
||||
}
|
||||
auto translations = APPLICATION->translations();
|
||||
@ -70,7 +76,7 @@ void LanguageSelectionWidget::languageRowChanged(const QModelIndex& current, con
|
||||
translations->updateLanguage(key);
|
||||
}
|
||||
|
||||
void LanguageSelectionWidget::languageSettingChanged(const Setting &, const QVariant)
|
||||
void LanguageSelectionWidget::languageSettingChanged(const Setting&, const QVariant)
|
||||
{
|
||||
auto translations = APPLICATION->translations();
|
||||
auto index = translations->selectedIndex();
|
||||
|
@ -21,23 +21,24 @@ class QVBoxLayout;
|
||||
class QTreeView;
|
||||
class QLabel;
|
||||
class Setting;
|
||||
class QCheckBox;
|
||||
|
||||
class LanguageSelectionWidget: public QWidget
|
||||
{
|
||||
class LanguageSelectionWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LanguageSelectionWidget(QWidget *parent = 0);
|
||||
virtual ~LanguageSelectionWidget() { };
|
||||
public:
|
||||
explicit LanguageSelectionWidget(QWidget* parent = 0);
|
||||
virtual ~LanguageSelectionWidget(){};
|
||||
|
||||
QString getSelectedLanguageKey() const;
|
||||
void retranslate();
|
||||
|
||||
protected slots:
|
||||
void languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void languageSettingChanged(const Setting &, const QVariant);
|
||||
protected slots:
|
||||
void languageRowChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||
void languageSettingChanged(const Setting&, const QVariant);
|
||||
|
||||
private:
|
||||
QVBoxLayout *verticalLayout = nullptr;
|
||||
QTreeView *languageView = nullptr;
|
||||
QLabel *helpUsLabel = nullptr;
|
||||
private:
|
||||
QVBoxLayout* verticalLayout = nullptr;
|
||||
QTreeView* languageView = nullptr;
|
||||
QLabel* helpUsLabel = nullptr;
|
||||
QCheckBox* formatCheckbox = nullptr;
|
||||
};
|
||||
|
Reference in New Issue
Block a user