53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#include "quam/main_window.h"
|
|
|
|
#include "quam/archive.h"
|
|
#include "quam/project.h"
|
|
|
|
#include <QErrorMessage>
|
|
#include <QFileDialog>
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
QMainWindow{parent},
|
|
Ui::MainWindow{},
|
|
m_errors{new QErrorMessage{this}}
|
|
{
|
|
setupUi(this);
|
|
|
|
actionClose->setShortcut(QKeySequence{QKeySequence::Close});
|
|
actionOpen->setShortcut(QKeySequence{QKeySequence::Open});
|
|
actionQuit->setShortcut(QKeySequence{QKeySequence::Quit});
|
|
}
|
|
|
|
MainWindow::~MainWindow() {
|
|
}
|
|
|
|
void MainWindow::fileOpen() {
|
|
auto fileName =
|
|
QFileDialog::getOpenFileName(
|
|
this,
|
|
tr("Open Archive"),
|
|
QString{},
|
|
tr("Quake archive file (*.pak *.wad);;"
|
|
"Quake PACK file (*.pak);;"
|
|
"Quake WAD2 file (*.wad);;"
|
|
"All files (*)"));
|
|
|
|
if(!fileName.isEmpty()) {
|
|
try {
|
|
auto st = openReadBin(fileName.toStdString());
|
|
auto arc = Arc::readArchive(st);
|
|
new Project{std::move(arc), m_errors, mdiArea};
|
|
} catch(std::exception const &exc) {
|
|
m_errors->showMessage(tr(exc.what()));
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::fileClose() {
|
|
if(auto win = mdiArea->activeSubWindow()) {
|
|
mdiArea->removeSubWindow(win);
|
|
}
|
|
}
|
|
|
|
// EOF
|