Skip to content

Commit

Permalink
Add Chinese option to the preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanC committed Jun 5, 2018
1 parent 21700a1 commit 1d56346
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Binary file added assets/pixmaps/flags/Taiwan.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 22 additions & 17 deletions src/dialogs/prefsdialog.cpp
Expand Up @@ -65,12 +65,13 @@ prefsDialog::prefsDialog(QWidget *parent) :
ui->historySlider->setValue(SETTINGS->getHistoryLimit().toInt());

//Startup tab
QStringList list(QStringList() << "English" << "French" << "Dutch" << "German");
QStringList list(QStringList() << "English" << "French" << "Dutch" << "German" << "Chinese");
ui->comboBoxLanguage->addItems(list);
ui->comboBoxLanguage->setItemIcon(0,QIcon(flagPath+"United-kingdom.png"));
ui->comboBoxLanguage->setItemIcon(1,QIcon(flagPath+"France.png"));
ui->comboBoxLanguage->setItemIcon(2,QIcon(flagPath+"Netherlands.png"));
ui->comboBoxLanguage->setItemIcon(3,QIcon(flagPath+"Germany.png"));
ui->comboBoxLanguage->setItemIcon(4,QIcon(flagPath+"Taiwan.png"));

ui->checkBoxMaximize->setChecked(SETTINGS->isMaximizeWindow());
ui->checkBox->setChecked(SETTINGS->isMultiWindowMode());
Expand All @@ -87,6 +88,9 @@ prefsDialog::prefsDialog(QWidget *parent) :
else if(SETTINGS->getUserLanguage() == "de")
ui->comboBoxLanguage->setCurrentIndex(3);

else if(SETTINGS->getUserLanguage() == "zh_TW")
ui->comboBoxLanguage->setCurrentIndex(4);

ui->restartButton->hide();
}

Expand Down Expand Up @@ -135,14 +139,8 @@ void prefsDialog::on_buttonBox_accepted()
if (ui->checkBox->isChecked() != SETTINGS->isMultiWindowMode())
SETTINGS->setMultiWindowMode(ui->checkBox->isChecked());

if(ui->comboBoxLanguage->currentIndex() == 0)
SETTINGS->setUserLanguage("en");
else if(ui->comboBoxLanguage->currentIndex() == 1)
SETTINGS->setUserLanguage("fr");
else if(ui->comboBoxLanguage->currentIndex() == 2)
SETTINGS->setUserLanguage("nl");
else if(ui->comboBoxLanguage->currentIndex() == 3)
SETTINGS->setUserLanguage("de");
// Save language when we close the dialog
set_user_language();
}

void prefsDialog::on_openFolderButton_clicked()
Expand Down Expand Up @@ -178,14 +176,7 @@ void prefsDialog::on_historySlider_sliderMoved(int position)
void prefsDialog::on_restartButton_clicked()
{
// Save language before we quit
if(ui->comboBoxLanguage->currentIndex() == 0)
SETTINGS->setUserLanguage("en");
else if(ui->comboBoxLanguage->currentIndex() == 1)
SETTINGS->setUserLanguage("fr");
else if(ui->comboBoxLanguage->currentIndex() == 2)
SETTINGS->setUserLanguage("nl");
else if(ui->comboBoxLanguage->currentIndex() == 3)
SETTINGS->setUserLanguage("de");
set_user_language();

qApp->quit();
QProcess* proc = new QProcess();
Expand All @@ -196,3 +187,17 @@ void prefsDialog::on_comboBoxLanguage_currentIndexChanged(const QString &arg1)
{
ui->restartButton->show();
}

void prefsDialog::set_user_language()
{
if(ui->comboBoxLanguage->currentIndex() == 0)
SETTINGS->setUserLanguage("en");
else if(ui->comboBoxLanguage->currentIndex() == 1)
SETTINGS->setUserLanguage("fr");
else if(ui->comboBoxLanguage->currentIndex() == 2)
SETTINGS->setUserLanguage("nl");
else if(ui->comboBoxLanguage->currentIndex() == 3)
SETTINGS->setUserLanguage("de");
else if(ui->comboBoxLanguage->currentIndex() == 4)
SETTINGS->setUserLanguage("zh_TW");
}
2 changes: 2 additions & 0 deletions src/dialogs/prefsdialog.h
Expand Up @@ -34,6 +34,8 @@ private slots:

void on_restartButton_clicked();

void set_user_language();

void on_comboBoxLanguage_currentIndexChanged(const QString &arg1);

private:
Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Expand Up @@ -58,6 +58,10 @@ int main(int argc, char *argv[])
{
lang = "nl";
}
else if(sysLanguage == "Chinese")
{
lang = "zh_TW";
}
SETTINGS->setUserLanguage(lang);
}

Expand Down

0 comments on commit 1d56346

Please sign in to comment.