2023-08-31 14:21:19 +02:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-08-31 14:18:50 +02:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2023-09-23 15:21:36 -04:00
|
|
|
#include <KConfig>
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QFormLayout>
|
2023-08-31 14:18:50 +02:00
|
|
|
#include <QListWidget>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
static QMap<QString, QString> applications = {{QStringLiteral("Armoury"), QStringLiteral("armoury")},
|
|
|
|
{QStringLiteral("EXD Viewer"), QStringLiteral("exdviewer")},
|
|
|
|
{QStringLiteral("Explorer"), QStringLiteral("explorer")},
|
|
|
|
{QStringLiteral("Model Viewer"), QStringLiteral("mdlviewer")}};
|
2023-08-31 14:18:50 +02:00
|
|
|
|
|
|
|
MainWindow::MainWindow() {
|
2023-09-26 00:37:55 -04:00
|
|
|
setWindowTitle(QStringLiteral("Novus SDK"));
|
2023-08-31 14:18:50 +02:00
|
|
|
|
|
|
|
auto appList = new QListWidget();
|
|
|
|
|
|
|
|
auto applicationHeader = new QListWidgetItem();
|
2023-09-26 00:37:55 -04:00
|
|
|
applicationHeader->setText(QStringLiteral("Applications"));
|
2023-08-31 14:18:50 +02:00
|
|
|
applicationHeader->setFlags(Qt::NoItemFlags);
|
|
|
|
|
|
|
|
appList->addItem(applicationHeader);
|
|
|
|
|
|
|
|
for(const auto& name : applications.keys()) {
|
|
|
|
appList->addItem(name);
|
|
|
|
}
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
connect(appList, &QListWidget::itemClicked, [this](QListWidgetItem *item) {
|
|
|
|
const QString exec = QStringLiteral("./") + applications[item->text()];
|
2023-08-31 14:18:50 +02:00
|
|
|
|
|
|
|
qDebug() << "Launching" << exec;
|
|
|
|
|
|
|
|
QProcess::startDetached(exec, QStringList());
|
|
|
|
});
|
|
|
|
|
|
|
|
auto appListLayout = new QVBoxLayout();
|
|
|
|
appListLayout->addWidget(appList);
|
|
|
|
|
|
|
|
auto centralFrame = new QFrame();
|
|
|
|
centralFrame->setLayout(appListLayout);
|
|
|
|
|
|
|
|
auto formLayout = new QFormLayout();
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
KConfig config(QStringLiteral("novusrc"));
|
2023-09-23 15:21:36 -04:00
|
|
|
KConfigGroup game = config.group("Game");
|
|
|
|
|
2023-08-31 14:18:50 +02:00
|
|
|
auto gameCombo = new QComboBox();
|
2023-09-26 00:37:55 -04:00
|
|
|
formLayout->addRow(QStringLiteral("Current Game"), gameCombo);
|
2023-08-31 14:18:50 +02:00
|
|
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
2023-09-23 15:21:36 -04:00
|
|
|
gameCombo->addItem(game.readEntry("GameDir"));
|
2023-08-31 14:18:50 +02:00
|
|
|
|
|
|
|
auto mainLayout = new QVBoxLayout();
|
|
|
|
mainLayout->addWidget(centralFrame);
|
|
|
|
mainLayout->addLayout(formLayout);
|
|
|
|
auto centralWidget = new QWidget();
|
|
|
|
centralWidget->setLayout(mainLayout);
|
|
|
|
|
|
|
|
setCentralWidget(centralWidget);
|
|
|
|
}
|