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>
|
2023-12-31 12:11:42 -05:00
|
|
|
#include <QDesktopServices>
|
2023-09-23 15:21:36 -04:00
|
|
|
#include <QFormLayout>
|
2023-08-31 14:18:50 +02:00
|
|
|
#include <QListWidget>
|
|
|
|
#include <QProcess>
|
2023-12-31 12:11:42 -05:00
|
|
|
#include <QUrl>
|
2023-08-31 14:18:50 +02:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2023-12-31 12:11:42 -05:00
|
|
|
static QMap<QString, QPair<QString, QString>> applications = {
|
|
|
|
{QStringLiteral("Gear Editor"), {QStringLiteral("zone.xiv.armoury"), QStringLiteral("novus-armoury")}},
|
|
|
|
{QStringLiteral("Excel Editor"), {QStringLiteral("zone.xiv.karaku"), QStringLiteral("novus-karuku")}},
|
|
|
|
{QStringLiteral("Data Explorer"), {QStringLiteral("zone.xiv.sagasu"), QStringLiteral("novus-sagasu")}},
|
|
|
|
{QStringLiteral("Model Viewer"), {QStringLiteral("zone.xiv.mdlviewer"), QStringLiteral("novus-mdlviewer")}}};
|
|
|
|
|
|
|
|
static QMap<QString, QString> links = {{QStringLiteral("XIV Dev Wiki"), QStringLiteral("https://xiv.dev")},
|
|
|
|
{QStringLiteral("XIV Docs"), QStringLiteral("https://docs.xiv.zone")}};
|
2023-08-31 14:18:50 +02:00
|
|
|
|
2023-10-10 18:02:13 -04:00
|
|
|
MainWindow::MainWindow()
|
2023-10-10 18:09:14 -04:00
|
|
|
: NovusMainWindow()
|
2023-10-10 18:02:13 -04:00
|
|
|
{
|
2023-10-10 18:21:12 -04:00
|
|
|
setupMenubar();
|
|
|
|
|
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);
|
|
|
|
|
2023-12-31 12:11:42 -05:00
|
|
|
for (const auto &key : applications.keys()) {
|
|
|
|
auto application = new QListWidgetItem();
|
|
|
|
application->setText(key);
|
|
|
|
application->setIcon(QIcon::fromTheme(applications[key].first));
|
|
|
|
|
|
|
|
appList->addItem(application);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto linksHeader = new QListWidgetItem();
|
|
|
|
linksHeader->setText(QStringLiteral("Links"));
|
|
|
|
linksHeader->setFlags(Qt::NoItemFlags);
|
|
|
|
|
|
|
|
appList->addItem(linksHeader);
|
|
|
|
|
|
|
|
for (const auto &key : links.keys()) {
|
|
|
|
auto application = new QListWidgetItem();
|
|
|
|
application->setText(key);
|
|
|
|
application->setIcon(QIcon::fromTheme(QStringLiteral("internet-web-browser")));
|
|
|
|
|
|
|
|
appList->addItem(application);
|
2023-08-31 14:18:50 +02:00
|
|
|
}
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
connect(appList, &QListWidget::itemClicked, [this](QListWidgetItem *item) {
|
2023-12-31 12:11:42 -05:00
|
|
|
if (applications.contains(item->text())) {
|
|
|
|
const QString exec = QStringLiteral("./") + applications[item->text()].second;
|
2023-08-31 14:18:50 +02:00
|
|
|
|
2023-12-31 12:11:42 -05:00
|
|
|
qDebug() << "Launching" << exec;
|
2023-08-31 14:18:50 +02:00
|
|
|
|
2023-12-31 12:11:42 -05:00
|
|
|
QProcess::startDetached(exec, QStringList());
|
|
|
|
} else if (links.contains(item->text())) {
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput(links[item->text()]));
|
|
|
|
}
|
2023-08-31 14:18:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
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-12-09 22:35:59 -05:00
|
|
|
KConfigGroup game = config.group(QStringLiteral("Game"));
|
2023-09-23 15:21:36 -04:00
|
|
|
|
2023-08-31 14:18:50 +02:00
|
|
|
auto gameCombo = new QComboBox();
|
2023-12-31 12:11:42 -05:00
|
|
|
gameCombo->setMaximumWidth(175);
|
2023-09-26 00:37:55 -04:00
|
|
|
formLayout->addRow(QStringLiteral("Current Game"), gameCombo);
|
2023-12-31 12:11:42 -05:00
|
|
|
formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
|
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);
|
|
|
|
}
|
2023-10-12 23:45:05 -04:00
|
|
|
|
|
|
|
#include "moc_mainwindow.cpp"
|