quake-tools/source/quam/main_window.cc

40 lines
843 B
C++
Raw Normal View History

2019-09-27 00:09:09 -07:00
#include "common.h"
#include "quam/main_window.h"
#include "quam/pak.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow{parent},
2019-09-28 01:17:55 -07:00
Ui::MainWindow{},
m_errors{}
2019-09-27 00:09:09 -07:00
{
setupUi(this);
2019-09-28 01:17:55 -07:00
actionOpen->setShortcut(QKeySequence{QKeySequence::Open});
actionQuit->setShortcut(QKeySequence{QKeySequence::Quit});
tableWidget->sortByColumn(Pak::ColumnId, Qt::AscendingOrder);
2019-09-27 00:09:09 -07:00
}
2019-09-28 01:17:55 -07:00
void MainWindow::fileOpen() {
auto fileName =
QFileDialog::getOpenFileName(
this,
tr("Open Archive"),
QString{},
tr("Quake PACK file (*.pak);;"
"Quake WAD2 file (*.wad);;"
2019-09-28 01:17:55 -07:00
"All files (*)"));
if(!fileName.isEmpty()) {
try {
auto st = openReadBin(fileName.toStdString());
auto pak = readPak(st);
setTableToPakDir(*tableWidget, pak);
2019-09-28 01:17:55 -07:00
} catch(std::exception const &exc) {
m_errors.showMessage(tr(exc.what()));
}
}
2019-09-27 00:09:09 -07:00
}
// EOF