summaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dialogs/languagedialog.cpp
blob: b68ce10a0f184de0568bdd89cb91e9e499fe28c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "iconmanager.h"
#include "languagedialog.h"
#include "ui_languagedialog.h"
#include "uiconfig.h"

LanguageDialog::LanguageDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LanguageDialog)
{
    ui->setupUi(this);
}

LanguageDialog::~LanguageDialog()
{
    delete ui;
}

void LanguageDialog::setLanguages(const QMap<QString, QString>& langs)
{
    for (const QString& langName : langs.keys())
        ui->comboBox->addItem(langName, langs[langName]);
}

QString LanguageDialog::getSelectedLang() const
{
    return ui->comboBox->currentData().toString();
}

void LanguageDialog::setSelectedLang(const QString& lang)
{
    int idx = ui->comboBox->findData(lang);
    if (idx < 0)
        idx = 0;

    ui->comboBox->setCurrentIndex(idx);
}

bool LanguageDialog::didAskForDefaultLanguage()
{
    return CFG_UI.General.LanguageAsked.get();
}

void LanguageDialog::askedForDefaultLanguage()
{
    CFG_UI.General.LanguageAsked.set(true);
}

void LanguageDialog::showEvent(QShowEvent*)
{
    setWindowIcon(ICONS.SQLITESTUDIO_APP);
}