-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadgames.cpp
More file actions
44 lines (33 loc) · 1.01 KB
/
Copy pathloadgames.cpp
File metadata and controls
44 lines (33 loc) · 1.01 KB
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 "loadgames.h"
#include "ui_loadgames.h"
#include "filepath.h"
#include <stdexcept>
#include <fstream>
#include <iomanip>
loadGames::loadGames(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::loadGames)
{
ui->setupUi(this);
}
loadGames::~loadGames()
{
delete ui;
}
std::string loadGames::load() /// this function is for show load games
{
std::ifstream file(SAVE_CONFIG);
if (!file)
throw std::runtime_error("save config file cannot be open"); // exception handeling // if runtime error
std::string saveName;
while(file >> quoted(saveName)) {
ui->comboBox->addItem(QString::fromStdString(saveName));
}
this->show();
QEventLoop loop;
connect(ui->btn_load, SIGNAL(clicked(bool)), &loop, SLOT(quit())); // signal and slots
loop.exec();
connect(ui->btn_load, SIGNAL(clicked(bool)), &loop, SLOT(quit())); // signal and slots
this->hide();
return ui->comboBox->currentText().toStdString();
}