1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00

Reorganize menu bar

Now it makes way more logical sense, there's a real "Settings" menu now.
Wine settings is relocated there, and now there's an easy way to open
the game directory in the "Tools" menu.
This commit is contained in:
Joshua Goins 2022-02-24 09:28:11 -05:00
parent 5e1fc20276
commit d7398ce0fd
4 changed files with 53 additions and 43 deletions

View file

@ -4,6 +4,7 @@
#include <keychain.h>
#include <QFormLayout>
#include <QApplication>
#include <QDesktopServices>
#include "settingswindow.h"
#include "squareboot.h"
@ -16,53 +17,61 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
connect(&core, &LauncherCore::settingsChanged, this, &LauncherWindow::reloadControls);
QMenu* fileMenu = menuBar()->addMenu("File");
QMenu* toolsMenu = menuBar()->addMenu("Tools");
QAction* settingsAction = fileMenu->addAction("Settings...");
QAction* launchOfficial = toolsMenu->addAction("Open Official Client...");
launchOfficial->setIcon(QIcon::fromTheme("application-x-executable"));
connect(launchOfficial, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivboot.exe"});
});
QAction* launchSysInfo = toolsMenu->addAction("Open System Info...");
launchSysInfo->setIcon(QIcon::fromTheme("application-x-executable"));
connect(launchSysInfo, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivsysinfo64.exe"});
});
QAction* launchCfgBackup = toolsMenu->addAction("Open Config Backup...");
launchCfgBackup->setIcon(QIcon::fromTheme("application-x-executable"));
connect(launchCfgBackup, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivconfig64.exe"});
});
toolsMenu->addSeparator();
QAction* openGameDir = toolsMenu->addAction("Open Game Directory...");
openGameDir->setIcon(QIcon::fromTheme("document-open"));
connect(openGameDir, &QAction::triggered, [=] {
openPath(currentProfile().gamePath);
});
QMenu* fileMenu = menuBar()->addMenu("Settings");
QAction* settingsAction = fileMenu->addAction("Configure Astra...");
settingsAction->setIcon(QIcon::fromTheme("settings"));
connect(settingsAction, &QAction::triggered, [=] {
auto window = new SettingsWindow(*this, this->core, this);
connect(&this->core, &LauncherCore::settingsChanged, window, &SettingsWindow::reloadControls);
window->show();
});
QMenu* toolsMenu = menuBar()->addMenu("Tools");
QAction* launchOfficial = toolsMenu->addAction("Launch Official Client...");
connect(launchOfficial, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivboot.exe"});
});
QAction* launchSysInfo = toolsMenu->addAction("Launch System Info...");
connect(launchSysInfo, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivsysinfo64.exe"});
});
QAction* launchCfgBackup = toolsMenu->addAction("Launch Config Backup...");
connect(launchCfgBackup, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {currentProfile().gamePath + "/boot/ffxivconfig64.exe"});
});
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
QMenu* wineMenu = toolsMenu->addMenu("Wine");
QAction* wineCfg = wineMenu->addAction("winecfg");
QAction* wineCfg = fileMenu->addAction("Configure Wine...");
wineCfg->setIcon(QIcon::fromTheme("settings"));
connect(wineCfg, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {"winecfg.exe"});
});
QAction* controlPanel = wineMenu->addAction("Control Panel");
connect(controlPanel, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {"control.exe"});
});
#endif
QMenu* helpMenu = menuBar()->addMenu("Help");
QAction* showAbout = helpMenu->addAction("About Astra");
showAbout->setIcon(QIcon::fromTheme("help-about"));
connect(showAbout, &QAction::triggered, [=] {
QMessageBox::about(this, "About Astra", "The source code is available <a href='https://github.com/redstrate/astra'>here</a>.");
});
QAction* showAboutQt = helpMenu->addAction("About Qt");
showAboutQt->setIcon(QIcon::fromTheme("help-about"));
connect(showAboutQt, &QAction::triggered, [=] {
QApplication::aboutQt();
});
@ -222,3 +231,14 @@ void LauncherWindow::reloadControls() {
currentlyReloadingControls = false;
}
void LauncherWindow::openPath(const QString path) {
#if defined(Q_OS_WIN)
// for some reason, windows requires special treatment (what else is new?)
const QFileInfo fileInfo(path);
QProcess::startDetached("explorer.exe", QStringList(QDir::toNativeSeparators(fileInfo.canonicalFilePath())));
#else
QDesktopServices::openUrl("file://" + path);
#endif
}

View file

@ -15,6 +15,8 @@ public:
ProfileSettings currentProfile() const;
ProfileSettings& currentProfile();
void openPath(const QString path);
public slots:
void reloadControls();

View file

@ -129,7 +129,7 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg
auto gameDirectoryButton = new QPushButton("Open Game Directory");
connect(gameDirectoryButton, &QPushButton::pressed,
[this] { openPath(getCurrentProfile().gamePath); });
[&window, this] { window.openPath(getCurrentProfile().gamePath); });
gameDirButtonLayout->addWidget(gameDirectoryButton);
#ifdef ENABLE_WATCHDOG
@ -275,7 +275,7 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg
auto openPrefixButton = new QPushButton("Open Wine Prefix");
connect(openPrefixButton, &QPushButton::pressed,
[this] { openPath(getCurrentProfile().winePrefixPath); });
[&window, this] { window.openPath(getCurrentProfile().winePrefixPath); });
winePrefixButtonLayout->addWidget(openPrefixButton);
auto enableDXVKhud = new QCheckBox("Enable DXVK HUD");
@ -486,14 +486,3 @@ void SettingsWindow::reloadControls() {
ProfileSettings& SettingsWindow::getCurrentProfile() {
return this->core.getProfile(profileWidget->currentRow());
}
void SettingsWindow::openPath(const QString path) {
#if defined(Q_OS_WIN)
// for some reason, windows requires special treatment (what else is new?)
const QFileInfo fileInfo(path);
QProcess::startDetached("explorer.exe", QStringList(QDir::toNativeSeparators(fileInfo.canonicalFilePath())));
#else
QDesktopServices::openUrl("file://" + path);
#endif
}

View file

@ -20,7 +20,6 @@ public slots:
void reloadControls();
private:
void openPath(const QString path);
ProfileSettings& getCurrentProfile();
QListWidget* profileWidget = nullptr;