-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputdialog.cpp
79 lines (66 loc) · 1.92 KB
/
inputdialog.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "inputdialog.h"
#include "ui_inputdialog.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QDebug>
#include "overload.h"
InputDialog::InputDialog(std::vector<Servant> & servants,Profile & userProfile,QDir saveFolder,QWidget *parent) :
QDialog(parent),
ui(new Ui::InputDialog),
tempUserProfile( userProfile ),
tempSaveFolder( saveFolder ),
tempServants( servants )
{
ui->setupUi(this);
}
InputDialog::~InputDialog()
{
delete ui;
}
void InputDialog::on_loadButton_clicked()
{
if( ui->loadButton->text() == "Load Profile" )
{
QString filter = "Servant Info File (*.svi)";
QString file_name = QFileDialog::getOpenFileName(this,tr("Open File"),tempSaveFolder.absolutePath(),filter);
QFile file(file_name);
if( !file.open(QFile::ReadOnly | QFile::Text ) )
{
QMessageBox::warning( this,"title","file not open" );
return;
}
tempUserProfile.neededMaterialList.clear();
tempUserProfile.servants.clear();
QDataStream loadData(&file);
loadData.setVersion(QDataStream::Qt_5_9);
qint32 versionType;
loadData >> versionType;
loadData >> tempUserProfile;
loadData >> tempUserProfile.recommendedLevel;
loadData >> tempUserProfile.singularityChosen;
for( auto & userServants : tempUserProfile.servants )
{
loadData >> userServants.tracking;
loadData >> userServants.favorite;
}
file.close();
InputDialog::done( 0 );
}
else
{
tempUserProfile = Profile();
tempUserProfile.profileName = ui->lineEdit->text();
InputDialog::done( 0 );
}
}
void InputDialog::on_lineEdit_textChanged(const QString &arg1)
{
if( arg1 == "" )
{
ui->loadButton->setText( "Load Profile" );
}
else
{
ui->loadButton->setText( "Start program as " + arg1 );
}
}