-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogremove.cpp
49 lines (44 loc) · 1.2 KB
/
dialogremove.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
45
46
47
48
49
#include "dialogremove.h"
#include "ui_dialogremove.h"
#include "translator.h"
DialogRemove::DialogRemove(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogRemove)
{
ui->setupUi(this);
bIsLang = false;
}
DialogRemove::~DialogRemove()
{
QSize WindowSize = size();
JsonConfig["dialog_remove"]["width"] = WindowSize.width();
JsonConfig["dialog_remove"]["height"] = WindowSize.height();
delete ui;
}
void DialogRemove::SetText(QString strText)
{
ui->label->setText( strText );
}
void DialogRemove::SetDialogValues(Json::Value jdata, bool bLang)
{
bIsLang = bLang;
ui->comboBox->clear();
std::vector<std::string> jdatagroups = jdata.getMemberNames();
for (const auto &jvalue : jdatagroups)
{
std::string str = jvalue;
if ( bLang )
{
str.replace( 0, 5, "" );
if ( str == "english" ) continue;
}
ui->comboBox->addItem( QString::fromStdString( str ) );
}
}
void DialogRemove::accept()
{
Translator *translator = (Translator *)parentWidget();
if ( !translator ) return;
translator->RemoveItem( ui->comboBox->itemText( ui->comboBox->currentIndex() ).toStdString(), bIsLang );
close();
}