-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialogmodify.cpp
53 lines (46 loc) · 1.36 KB
/
dialogmodify.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
50
51
52
53
#include "dialogmodify.h"
#include "ui_dialogmodify.h"
#include "translator.h"
DialogModify::DialogModify(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogModify)
{
bIsLangKey = false;
ui->setupUi(this);
ui->lineEdit->setFocus(Qt::FocusReason::ActiveWindowFocusReason);
}
DialogModify::~DialogModify()
{
QSize WindowSize = size();
JsonConfig["dialog_modify"]["width"] = WindowSize.width();
JsonConfig["dialog_modify"]["height"] = WindowSize.height();
delete ui;
}
void DialogModify::Setup(Json::Value jdata)
{
ui->comboBox->clear();
std::vector<std::string> jdatagroups = jdata.getMemberNames();
for (const auto &jvalue : jdatagroups)
{
std::string str = jvalue;
if ( bIsLangKey )
str.replace( 0, 5, "" );
ui->comboBox->addItem( QString::fromStdString( str ) );
}
// Set the string
OldString = ui->comboBox->itemText( ui->comboBox->currentIndex() );
ui->lineEdit->setText( OldString );
}
void DialogModify::accept()
{
Translator *translator = dynamic_cast<Translator *>( parentWidget() );
if ( !translator ) return;
translator->OnItemModified( OldString, ui->lineEdit->text(), bIsLangKey ),
close();
}
void DialogModify::OnItemChanged( int slot )
{
// Set the string
OldString = ui->comboBox->itemText( slot );
ui->lineEdit->setText( OldString );
}