2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-14 08:24:06 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2023-09-23 15:45:38 -04:00
|
|
|
#include <KAboutApplicationDialog>
|
|
|
|
#include <KAboutData>
|
2023-07-08 10:33:12 -04:00
|
|
|
#include <QAction>
|
|
|
|
#include <QApplication>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDesktopServices>
|
2022-04-14 08:24:06 -04:00
|
|
|
#include <QHBoxLayout>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QMenuBar>
|
2022-04-14 08:24:06 -04:00
|
|
|
#include <QTableWidget>
|
|
|
|
#include <QTreeWidget>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QUrl>
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-07-08 10:33:12 -04:00
|
|
|
#include "filepropertieswindow.h"
|
2023-09-23 15:45:38 -04:00
|
|
|
#include "filetreewindow.h"
|
2023-07-08 10:33:12 -04:00
|
|
|
|
2023-10-10 18:02:13 -04:00
|
|
|
MainWindow::MainWindow(GameData *data)
|
|
|
|
: data(data)
|
|
|
|
{
|
2023-10-10 17:55:49 -04:00
|
|
|
setWindowTitle(QStringLiteral("Sagasu"));
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
auto fileMenu = menuBar()->addMenu(QStringLiteral("File"));
|
2023-07-09 12:14:32 -04:00
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
auto quitAction = fileMenu->addAction(QStringLiteral("Quit"));
|
|
|
|
quitAction->setIcon(QIcon::fromTheme(QStringLiteral("gtk-quit")));
|
2023-07-09 12:14:32 -04:00
|
|
|
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
auto helpMenu = menuBar()->addMenu(QStringLiteral("Help"));
|
2023-07-08 10:33:12 -04:00
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
auto donateAction = helpMenu->addAction(QStringLiteral("Donate"));
|
2023-07-08 10:33:12 -04:00
|
|
|
connect(donateAction, &QAction::triggered, this, [] {
|
2023-09-26 00:37:55 -04:00
|
|
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://redstrate.com/fund")));
|
2023-07-08 10:33:12 -04:00
|
|
|
});
|
2023-09-26 00:37:55 -04:00
|
|
|
donateAction->setIcon(QIcon::fromTheme(QStringLiteral("help-donate")));
|
2023-07-08 10:33:12 -04:00
|
|
|
|
|
|
|
helpMenu->addSeparator();
|
|
|
|
|
2023-10-10 17:55:49 -04:00
|
|
|
auto aboutNovusAction = helpMenu->addAction(QStringLiteral("About Sagasu"));
|
2023-09-26 00:37:55 -04:00
|
|
|
aboutNovusAction->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
|
2023-07-08 10:33:12 -04:00
|
|
|
connect(aboutNovusAction, &QAction::triggered, this, [this] {
|
2023-09-23 15:45:38 -04:00
|
|
|
auto window = new KAboutApplicationDialog(KAboutData::applicationData(), this);
|
2023-07-08 10:33:12 -04:00
|
|
|
window->show();
|
|
|
|
});
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
auto aboutQtAction = helpMenu->addAction(QStringLiteral("About Qt"));
|
|
|
|
aboutQtAction->setIcon(QIcon(QStringLiteral(":/qt-project.org/qmessagebox/images/qtlogo-64.png")));
|
2023-07-08 10:33:12 -04:00
|
|
|
connect(aboutQtAction, &QAction::triggered, QApplication::instance(), &QApplication::aboutQt);
|
|
|
|
|
2023-04-09 15:32:09 -04:00
|
|
|
mdiArea = new QMdiArea();
|
|
|
|
setCentralWidget(mdiArea);
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-04-09 15:32:09 -04:00
|
|
|
auto tree = new FileTreeWindow(data);
|
|
|
|
connect(tree, &FileTreeWindow::openFileProperties, this, [=](QString path) {
|
|
|
|
qInfo() << "opening properties window for " << path;
|
|
|
|
auto window = mdiArea->addSubWindow(new FilePropertiesWindow(data, path));
|
|
|
|
window->show();
|
|
|
|
});
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-04-09 15:32:09 -04:00
|
|
|
mdiArea->addSubWindow(tree);
|
2022-04-14 08:24:06 -04:00
|
|
|
}
|