-
Notifications
You must be signed in to change notification settings - Fork 0
/
setlanguage.cpp
44 lines (40 loc) · 1.27 KB
/
setlanguage.cpp
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
#include "setlanguage.h"
#include "ui_setlanguage.h"
#include <QShortcut>
#include <QKeyEvent>
#include <QMessageBox>
SetLanguage::SetLanguage(QWidget *parent) :
QDialog(parent),
ui(new Ui::SetLanguage)
{
ui->setupUi(this);
setWindowTitle(tr("change language"));
QStringList lang;
lang << "english" << "french" << "polish";
ui->comboBox->addItems(lang);
setWindowFlags(Qt::WindowTitleHint);
QShortcut *shortcut1 = new QShortcut(QKeySequence(Qt::Key_Return),this);//Enter button
QShortcut *shortcut2 = new QShortcut(QKeySequence(Qt::Key_Enter),this);//Enter button
connect(shortcut1, SIGNAL(activated()), this, SLOT(on_ok_clicked()));
connect(shortcut2, SIGNAL(activated()), this, SLOT(on_ok_clicked()));
}
SetLanguage::~SetLanguage()
{
delete ui;
}
void SetLanguage::on_ok_clicked()
{
if(ui->comboBox->currentText()=="english")
cl="en";
else if(ui->comboBox->currentText()=="french")
cl="fr";
else if(ui->comboBox->currentText()=="polish")
cl="pl";
QMessageBox::information(0, qApp->QObject::tr("Information"),
qApp->QObject::tr("Please restart this app to change language"),QMessageBox::Ok);
close();
}
void SetLanguage::keyPressEvent(QKeyEvent *e) {
if(e->key() == Qt::Key_Escape)
close();
}