-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelSelector.cpp
More file actions
38 lines (31 loc) · 1.18 KB
/
Copy pathLevelSelector.cpp
File metadata and controls
38 lines (31 loc) · 1.18 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
//
// Created by silly on 29.05.25.
//
#include "LevelSelector.h"
#include "AppWideVariables.h"
#include "MainWindow.h"
LevelSelector::LevelSelector() : MDISubWindow(nullptr, "Select level:", QRect(150, 40, 700, 800))
{
centerWidget = new QWidget(this);
layout()->addWidget(centerWidget);
const QString path = QDir::currentPath() + "/levels/";
model->setRootPath(path);
tree = new QTreeView();
tree->setHeaderHidden(true);
tree->header()->setSectionResizeMode(QHeaderView::Stretch);
tree->setModel(model);
tree->setRootIndex(model->index(path));
connect(tree, &QTreeView::activated, this, [this](const QModelIndex &index) {
if (!index.isValid() && !model) return;
if (!model->fileInfo(index).isDir())
{
const auto fileInfo = model->fileInfo(index);
QCoreApplication::instance()->setProperty("levelName", fileInfo.dir().dirName()+"|"+fileInfo.fileName());
AppWideVariables::instance().levelPath = model->filePath(index);
MainWindow::instance()->openLevelMDIWindows();
close();
}
});
sublayout = new QGridLayout(centerWidget);
sublayout->addWidget(tree, 0, 0);
}