aboutsummaryrefslogtreecommitdiff
path: root/Source/MapEditor/mainwindow.cpp
blob: 58c37f63f51de393e510feda5fd755b4709add66 (plain) (blame)
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
80
81
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->LoadMap_Btn, SIGNAL(released()), this, SLOT(onLoadMap()));

    ui->openGLWidget->

    appSettings();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::onLoadMap(void)
{
    QString path = QFileDialog::getOpenFileName(this,
                                                "Open map file",
                                                _last_dir,
                                                "Map files (*.LVL)");

    QFile f(path);

    if(checkFile(f) == false)
    {
        return;
    }

    QDataStream txt(&f);


}

bool MainWindow::checkFile(QFile& f)
{
    QFileInfo fi(f);

    if(fi.exists() == false)
    {
        return false;
    }

    if(f.open(QFile::ReadWrite) == false)
    {
        return false;
    }

    QDir d(fi.absoluteFilePath());

    _last_dir = d.absolutePath();

    return true;
}

void MainWindow::appSettings(void)
{
    QSettings set("./settings.ini",QSettings::IniFormat);

    set.beginGroup("app_settings");

    _last_dir = set.value("last_dir").toString();

    set.endGroup();
}

void MainWindow::closeEvent(QCloseEvent*)
{
    QSettings set("./settings.ini",QSettings::IniFormat);

    set.beginGroup("app_settings");

    set.setValue("last_dir",_last_dir);

    set.endGroup();
}