-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlangdialog.cpp
41 lines (35 loc) · 1.1 KB
/
langdialog.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
#include "langdialog.h"
#include "ui_langdialog.h"
#include "showmesshelper.h"
#include <QHash>
#include <QTimer>
LangDialog::LangDialog(QComboBox *cbx, QWidget *parent) :
QDialog(parent),
ui(new Ui::LangDialog)
{
ui->setupUi(this);
defLblTxt = ui->label->text();
// ui->cbLang = cbx;
if(cbx && cbx->count() > 0){
for(int i = 0, iMax = cbx->count(); i < iMax; i++ ){
ui->cbLang->addItem(cbx->itemIcon(i), cbx->itemText(i), cbx->itemData(i));
}
ui->cbLang->setCurrentIndex(cbx->currentIndex());
}else{
QTimer::singleShot(1, this, SLOT(reject()) );
}
}
LangDialog::~LangDialog()
{
delete ui;
}
void LangDialog::on_buttonBox_accepted()
{
emit onLangSelected(ui->cbLang->currentData().toString());
accept();
}
void LangDialog::on_cbLang_currentIndexChanged(int index)
{
ui->label->setText( ShowMessHelper::machine2human(QString("uk;en").split(";"),
QString("Виберіть будь-ласка мову;Please select a language").split(";") ).value(ui->cbLang->itemData(index).toString(), defLblTxt) );
}