added button to test custom translation file
This commit is contained in:
parent
95dd3fc04c
commit
1224eae1c0
5 changed files with 34 additions and 3 deletions
|
@ -26,6 +26,8 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
{
|
||||
languageLabel = new QLabel;
|
||||
languageBox = new QComboBox;
|
||||
customTranslationButton = new QPushButton("...");
|
||||
customTranslationButton->setMaximumWidth(50);
|
||||
|
||||
QString setLanguage = settingsCache->getLang();
|
||||
QStringList qmFiles = findQmFiles();
|
||||
|
@ -40,12 +42,14 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
picDownloadCheckBox->setChecked(settingsCache->getPicDownload());
|
||||
|
||||
connect(languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
|
||||
connect(customTranslationButton, SIGNAL(clicked()), this, SLOT(customTranslationButtonClicked()));
|
||||
connect(picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int)));
|
||||
|
||||
QGridLayout *personalGrid = new QGridLayout;
|
||||
personalGrid->addWidget(languageLabel, 0, 0);
|
||||
personalGrid->addWidget(languageBox, 0, 1);
|
||||
personalGrid->addWidget(picDownloadCheckBox, 1, 0, 1, 2);
|
||||
personalGrid->addWidget(customTranslationButton, 0, 2);
|
||||
personalGrid->addWidget(picDownloadCheckBox, 1, 0, 1, 3);
|
||||
|
||||
personalGroupBox = new QGroupBox;
|
||||
personalGroupBox->setLayout(personalGrid);
|
||||
|
@ -136,9 +140,19 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked()
|
|||
|
||||
void GeneralSettingsPage::languageBoxChanged(int index)
|
||||
{
|
||||
settingsCache->setCustomTranslationFile(QString());
|
||||
settingsCache->setLang(languageBox->itemData(index).toString());
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::customTranslationButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
settingsCache->setCustomTranslationFile(path);
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::retranslateUi()
|
||||
{
|
||||
personalGroupBox->setTitle(tr("Personal settings"));
|
||||
|
@ -555,6 +569,7 @@ DlgSettings::DlgSettings(QWidget *parent)
|
|||
: QDialog(parent)
|
||||
{
|
||||
connect(settingsCache, SIGNAL(langChanged()), this, SLOT(updateLanguage()));
|
||||
connect(settingsCache, SIGNAL(customTranslationFileChanged()), this, SLOT(updateLanguage()));
|
||||
|
||||
contentsWidget = new QListWidget;
|
||||
contentsWidget->setViewMode(QListView::IconMode);
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
GeneralSettingsPage();
|
||||
void retranslateUi();
|
||||
private slots:
|
||||
void customTranslationButtonClicked();
|
||||
void deckPathButtonClicked();
|
||||
void picsPathButtonClicked();
|
||||
void cardDatabasePathButtonClicked();
|
||||
|
@ -39,6 +40,7 @@ signals:
|
|||
private:
|
||||
QStringList findQmFiles();
|
||||
QString languageName(const QString &qmFile);
|
||||
QPushButton *customTranslationButton;
|
||||
QLineEdit *deckPathEdit, *picsPathEdit, *cardDatabasePathEdit;
|
||||
QGroupBox *personalGroupBox, *pathsGroupBox;
|
||||
QComboBox *languageBox;
|
||||
|
|
|
@ -62,7 +62,10 @@ void installNewTranslator()
|
|||
qtTranslator->load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qApp->installTranslator(qtTranslator);
|
||||
|
||||
translator->load(translationPrefix + "_" + lang, ":/translations");
|
||||
if (!settingsCache->getCustomTranslationFile().isEmpty())
|
||||
translator->load(settingsCache->getCustomTranslationFile());
|
||||
else
|
||||
translator->load(translationPrefix + "_" + lang, ":/translations");
|
||||
qApp->installTranslator(translator);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ SettingsCache::SettingsCache()
|
|||
{
|
||||
settings = new QSettings(this);
|
||||
|
||||
customTranslationFile = settings->value("personal/custom_translation").toString();
|
||||
lang = settings->value("personal/lang").toString();
|
||||
|
||||
deckPath = settings->value("paths/decks").toString();
|
||||
|
@ -36,6 +37,13 @@ SettingsCache::SettingsCache()
|
|||
priceTagFeature = settings->value("deckeditor/pricetags", false).toBool();
|
||||
}
|
||||
|
||||
void SettingsCache::setCustomTranslationFile(const QString &_customTranslationFile)
|
||||
{
|
||||
customTranslationFile = _customTranslationFile;
|
||||
settings->setValue("personal/custom_translation", customTranslationFile);
|
||||
emit customTranslationFileChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setLang(const QString &_lang)
|
||||
{
|
||||
lang = _lang;
|
||||
|
|
|
@ -8,6 +8,7 @@ class QSettings;
|
|||
class SettingsCache : public QObject {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void customTranslationFileChanged();
|
||||
void langChanged();
|
||||
void picsPathChanged();
|
||||
void cardDatabasePathChanged();
|
||||
|
@ -25,7 +26,7 @@ signals:
|
|||
private:
|
||||
QSettings *settings;
|
||||
|
||||
QString lang;
|
||||
QString customTranslationFile, lang;
|
||||
QString deckPath, picsPath, cardDatabasePath;
|
||||
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
||||
bool picDownload;
|
||||
|
@ -43,6 +44,7 @@ private:
|
|||
bool priceTagFeature;
|
||||
public:
|
||||
SettingsCache();
|
||||
QString getCustomTranslationFile() const { return customTranslationFile; }
|
||||
QString getLang() const { return lang; }
|
||||
QString getDeckPath() const { return deckPath; }
|
||||
QString getPicsPath() const { return picsPath; }
|
||||
|
@ -67,6 +69,7 @@ public:
|
|||
QString getSoundPath() const { return soundPath; }
|
||||
bool getPriceTagFeature() const { return priceTagFeature; }
|
||||
public slots:
|
||||
void setCustomTranslationFile(const QString &_customTranslationFile);
|
||||
void setLang(const QString &_lang);
|
||||
void setDeckPath(const QString &_deckPath);
|
||||
void setPicsPath(const QString &_picsPath);
|
||||
|
|
Loading…
Reference in a new issue