diff --git a/README.md b/README.md index 081ae83..58b7478 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ If you still have questions, please read the [FAQ](https://xiv.zone/astra/faq) f ## Features * Traditional desktop interface which looks native to your system, utilizing Qt - a proven application framework. - * A Tablet/TV interface designed for touchscreens or handhelds such as the Steam Deck is also available. - * Can even run without a GUI, ideal for users comfortable with a CLI or for automation. + * Supports single-window scenarios such as the Steam Deck seamlessly. * Native support for Windows, macOS and Linux! * Handles running Wine for macOS and Linux users - creating a seamless and native-feeling launcher experience, compared to running other FFXIV launchers in Wine. diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index ee544c7..2263d82 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1,39 +1,12 @@ add_subdirectory(core) - -if(ENABLE_CLI) - add_subdirectory(cli) -endif() - -if(ENABLE_DESKTOP) - add_subdirectory(desktop) -endif() - -if(ENABLE_TABLET) - add_subdirectory(tablet) -endif() +add_subdirectory(desktop) add_executable(astra - main.cpp - tablet/qml/qml.qrc) - -if(ENABLE_DESKTOP) - set(INTERFACES ${INTERFACES} astra_desktop) - target_compile_definitions(astra PRIVATE ENABLE_DESKTOP) -endif() - -if(ENABLE_TABLET) - set(INTERFACES ${INTERFACES} astra_tablet) - target_compile_definitions(astra PRIVATE ENABLE_TABLET) -endif() - -if(ENABLE_CLI) - set(INTERFACES ${INTERFACES} astra_cli) - target_compile_definitions(astra PRIVATE ENABLE_CLI) -endif() + main.cpp) target_link_libraries(astra PUBLIC astra_core - ${INTERFACES}) + astra_desktop) target_compile_features(astra PUBLIC cxx_std_17) set_target_properties(astra PROPERTIES CXX_EXTENSIONS OFF) diff --git a/launcher/cli/CMakeLists.txt b/launcher/cli/CMakeLists.txt deleted file mode 100644 index ad03ebd..0000000 --- a/launcher/cli/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(HEADERS - include/cmdinterface.h) - -set(SRC - src/cmdinterface.cpp) - -add_library(astra_cli STATIC ${HEADERS} ${SRC}) -target_include_directories(astra_cli PUBLIC include) -target_link_libraries(astra_cli PUBLIC - astra_core - Qt5::Core - Qt5::Network) \ No newline at end of file diff --git a/launcher/cli/include/cmdinterface.h b/launcher/cli/include/cmdinterface.h deleted file mode 100644 index 27012a7..0000000 --- a/launcher/cli/include/cmdinterface.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "launchercore.h" -#include - -/* - * The CLI interface for Astra, driven primarily by the command-line. - */ -class CMDInterface { -public: - explicit CMDInterface(QCommandLineParser& parser); - - bool parse(QCommandLineParser& parser, LauncherCore& core); - -private: - QCommandLineOption profileOption = { - "default-profile", - "Profile to use for default profile and autologin.", - "profile"}; - QCommandLineOption autologinOption = { - "autologin", - "Auto-login with the default profile. This requires the profile to have remember username/password enabled!"}; -}; \ No newline at end of file diff --git a/launcher/cli/src/cmdinterface.cpp b/launcher/cli/src/cmdinterface.cpp deleted file mode 100644 index 244d400..0000000 --- a/launcher/cli/src/cmdinterface.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "cmdinterface.h" - -CMDInterface::CMDInterface(QCommandLineParser& parser) { - parser.addOption(autologinOption); - parser.addOption(profileOption); -} - -bool CMDInterface::parse(QCommandLineParser& parser, LauncherCore& core) { - if (parser.isSet(profileOption)) { - core.defaultProfileIndex = core.getProfileIndex(parser.value(profileOption)); - - if (core.defaultProfileIndex == -1) { - qInfo() << "The profile \"" << parser.value(profileOption) << "\" does not exist!"; - return false; - } - } - - if (parser.isSet(autologinOption)) { - auto& profile = core.getProfile(core.defaultProfileIndex); - - return core.autoLogin(profile); - } - - return true; -} diff --git a/launcher/core/src/patcher.cpp b/launcher/core/src/patcher.cpp index add3a41..1413b8b 100644 --- a/launcher/core/src/patcher.cpp +++ b/launcher/core/src/patcher.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, const QString& patchL dialog->setLabelText("Updating the FINAL FANTASY XIV Game version."); } - const QStringList parts = patchList.split(QRegExp("\n|\r\n|\r")); + const QStringList parts = patchList.split("\n|\r\n|\r"); remainingPatches = parts.size() - 7; diff --git a/launcher/desktop/CMakeLists.txt b/launcher/desktop/CMakeLists.txt index 37ecbd6..01088d4 100644 --- a/launcher/desktop/CMakeLists.txt +++ b/launcher/desktop/CMakeLists.txt @@ -14,7 +14,7 @@ set(SRC src/gamescopesettingswindow.cpp src/launcherwindow.cpp src/settingswindow.cpp - src/autologinwindow.cpp) + src/autologinwindow.cpp include/virtualwindow.h src/virtualwindow.cpp src/virtualdialog.cpp include/virtualdialog.h) add_library(astra_desktop STATIC ${HEADERS} ${SRC}) target_include_directories(astra_desktop PUBLIC include) diff --git a/launcher/desktop/include/aboutwindow.h b/launcher/desktop/include/aboutwindow.h index 553c17a..85f067a 100644 --- a/launcher/desktop/include/aboutwindow.h +++ b/launcher/desktop/include/aboutwindow.h @@ -1,8 +1,8 @@ #pragma once -#include +#include "virtualdialog.h" -class AboutWindow : public QDialog { +class AboutWindow : public VirtualDialog { public: - explicit AboutWindow(QWidget* widget = nullptr); + explicit AboutWindow(DesktopInterface& interface, QWidget* widget = nullptr); }; \ No newline at end of file diff --git a/launcher/desktop/include/autologinwindow.h b/launcher/desktop/include/autologinwindow.h index ded82a5..f358029 100644 --- a/launcher/desktop/include/autologinwindow.h +++ b/launcher/desktop/include/autologinwindow.h @@ -1,15 +1,15 @@ #pragma once -#include +#include "virtualdialog.h" class LauncherCore; class LauncherWindow; struct ProfileSettings; -class AutoLoginWindow : public QDialog { +class AutoLoginWindow : public VirtualDialog { Q_OBJECT public: - AutoLoginWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent = nullptr); + AutoLoginWindow(DesktopInterface& interface, ProfileSettings& settings, LauncherCore& core, QWidget* parent = nullptr); signals: void loginCanceled(); diff --git a/launcher/desktop/include/desktopinterface.h b/launcher/desktop/include/desktopinterface.h index 9506c5a..f59b50b 100644 --- a/launcher/desktop/include/desktopinterface.h +++ b/launcher/desktop/include/desktopinterface.h @@ -1,7 +1,11 @@ #pragma once +#include +#include + #include "launcherwindow.h" #include "autologinwindow.h" +#include "virtualdialog.h" /* * The desktop, mouse and keyboard-driven interface for Astra. Primarily meant @@ -11,7 +15,16 @@ class DesktopInterface { public: explicit DesktopInterface(LauncherCore& core); + void addWindow(VirtualWindow* window); + void addDialog(VirtualDialog* dialog); + + bool oneWindow = true; + bool isSteamDeck = true; + private: + QMdiArea* mdiArea = nullptr; + QMainWindow* mdiWindow = nullptr; + LauncherWindow* window = nullptr; AutoLoginWindow* autoLoginWindow = nullptr; }; \ No newline at end of file diff --git a/launcher/desktop/include/gamescopesettingswindow.h b/launcher/desktop/include/gamescopesettingswindow.h index 1d85bce..5cc6c47 100644 --- a/launcher/desktop/include/gamescopesettingswindow.h +++ b/launcher/desktop/include/gamescopesettingswindow.h @@ -8,11 +8,13 @@ #include #include +#include "virtualdialog.h" + class LauncherCore; class LauncherWindow; struct ProfileSettings; -class GamescopeSettingsWindow : public QDialog { +class GamescopeSettingsWindow : public VirtualDialog { public: - GamescopeSettingsWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent = nullptr); + GamescopeSettingsWindow(DesktopInterface& interface, ProfileSettings& settings, LauncherCore& core, QWidget* parent = nullptr); }; diff --git a/launcher/desktop/include/launcherwindow.h b/launcher/desktop/include/launcherwindow.h index 0679689..973e5b3 100644 --- a/launcher/desktop/include/launcherwindow.h +++ b/launcher/desktop/include/launcherwindow.h @@ -11,11 +11,14 @@ #include "headline.h" #include "launchercore.h" +#include "virtualwindow.h" -class LauncherWindow : public QMainWindow { +class DesktopInterface; + +class LauncherWindow : public VirtualWindow { Q_OBJECT public: - explicit LauncherWindow(LauncherCore& new_headline, QWidget* parent = nullptr); + explicit LauncherWindow(DesktopInterface& interface, LauncherCore& new_headline, QWidget* parent = nullptr); ProfileSettings& currentProfile(); @@ -59,4 +62,6 @@ private: #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) QAction* wineCfg; #endif + + DesktopInterface& interface; }; \ No newline at end of file diff --git a/launcher/desktop/include/settingswindow.h b/launcher/desktop/include/settingswindow.h index 511837c..9508f5c 100644 --- a/launcher/desktop/include/settingswindow.h +++ b/launcher/desktop/include/settingswindow.h @@ -9,13 +9,15 @@ #include #include +#include "virtualdialog.h" + class LauncherCore; class LauncherWindow; struct ProfileSettings; -class SettingsWindow : public QDialog { +class SettingsWindow : public VirtualDialog { public: - SettingsWindow(int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent = nullptr); + SettingsWindow(DesktopInterface& interface, int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent = nullptr); public slots: void reloadControls(); @@ -79,4 +81,6 @@ private: LauncherWindow& window; LauncherCore& core; + + DesktopInterface& interface; }; diff --git a/launcher/desktop/include/virtualdialog.h b/launcher/desktop/include/virtualdialog.h new file mode 100644 index 0000000..1b41206 --- /dev/null +++ b/launcher/desktop/include/virtualdialog.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include + +class DesktopInterface; + +class VirtualDialog : public QObject { + Q_OBJECT +public: + VirtualDialog(DesktopInterface& interface, QWidget* parent = nullptr); + + void setWindowTitle(QString title); + void show(); + void hide(); + void close(); + void setWindowModality(Qt::WindowModality modality); + void setLayout(QLayout* layout); + + QWidget* getRootWidget(); + + QMdiSubWindow* mdi_window = nullptr; + QDialog* normal_dialog = nullptr; + +private: + DesktopInterface& interface; +}; \ No newline at end of file diff --git a/launcher/desktop/include/virtualwindow.h b/launcher/desktop/include/virtualwindow.h new file mode 100644 index 0000000..e2340eb --- /dev/null +++ b/launcher/desktop/include/virtualwindow.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include + +class DesktopInterface; + +class VirtualWindow : public QObject { + Q_OBJECT +public: + VirtualWindow(DesktopInterface& interface, QWidget* parent = nullptr); + + void setWindowTitle(QString title); + void setCentralWidget(QWidget* widget); + void show(); + void showMaximized(); + void hide(); + + QMenuBar* menuBar(); + + QWidget* getRootWidget(); + + QMdiSubWindow* mdi_window = nullptr; + QMainWindow* normal_window = nullptr; + +private: + DesktopInterface& interface; +}; \ No newline at end of file diff --git a/launcher/desktop/src/aboutwindow.cpp b/launcher/desktop/src/aboutwindow.cpp index 34bdd8f..26f59af 100644 --- a/launcher/desktop/src/aboutwindow.cpp +++ b/launcher/desktop/src/aboutwindow.cpp @@ -8,11 +8,11 @@ #include "config.h" #include "license.h" -AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { +AboutWindow::AboutWindow(DesktopInterface& interface, QWidget* widget) : VirtualDialog(interface, widget) { setWindowTitle("About"); setWindowModality(Qt::WindowModality::ApplicationModal); - auto mainLayout = new QVBoxLayout(this); + auto mainLayout = new QVBoxLayout(); setLayout(mainLayout); auto mainLabel = new QLabel(); @@ -34,8 +34,8 @@ AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { auto licenseLabel = new QLabel(); licenseLabel->setText("License: GNU General Public License Version 3"); - connect(licenseLabel, &QLabel::linkActivated, [this] { - auto licenseDialog = new QDialog(this); + connect(licenseLabel, &QLabel::linkActivated, [&interface] { + auto licenseDialog = new VirtualDialog(interface); licenseDialog->setWindowTitle("License Agreement"); auto layout = new QVBoxLayout(); diff --git a/launcher/desktop/src/autologinwindow.cpp b/launcher/desktop/src/autologinwindow.cpp index 9ff906b..e12f9e4 100644 --- a/launcher/desktop/src/autologinwindow.cpp +++ b/launcher/desktop/src/autologinwindow.cpp @@ -11,12 +11,12 @@ #include "launcherwindow.h" #include "sapphirelauncher.h" -AutoLoginWindow::AutoLoginWindow(ProfileSettings& profile, LauncherCore& core, QWidget* parent) - : QDialog(parent) { +AutoLoginWindow::AutoLoginWindow(DesktopInterface& interface, ProfileSettings& profile, LauncherCore& core, QWidget* parent) + : VirtualDialog(interface, parent) { setWindowTitle("Auto Login"); setWindowModality(Qt::WindowModality::ApplicationModal); - auto mainLayout = new QFormLayout(this); + auto mainLayout = new QFormLayout(); setLayout(mainLayout); auto label = new QLabel("Currently logging in..."); diff --git a/launcher/desktop/src/desktopinterface.cpp b/launcher/desktop/src/desktopinterface.cpp index 57cd5e6..6050f58 100644 --- a/launcher/desktop/src/desktopinterface.cpp +++ b/launcher/desktop/src/desktopinterface.cpp @@ -3,12 +3,20 @@ #include "gameinstaller.h" DesktopInterface::DesktopInterface(LauncherCore& core) { - window = new LauncherWindow(core); + if(oneWindow) { + mdiArea = new QMdiArea(); + mdiWindow = new QMainWindow(); + mdiWindow->setWindowTitle("Combined Interface"); + mdiWindow->setCentralWidget(mdiArea); + mdiWindow->show(); + } + + window = new LauncherWindow(*this, core); auto& defaultProfile = core.getProfile(core.defaultProfileIndex); if (!defaultProfile.isGameInstalled()) { - auto messageBox = new QMessageBox(window); + auto messageBox = new QMessageBox(); messageBox->setIcon(QMessageBox::Icon::Question); messageBox->setText("No Game Found"); messageBox->setInformativeText("FFXIV is not installed. Would you like to install it now?"); @@ -38,21 +46,22 @@ DesktopInterface::DesktopInterface(LauncherCore& core) { #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) if (!core.isSteam && !defaultProfile.isWineInstalled()) { - auto messageBox = new QMessageBox(window); + auto messageBox = new QMessageBox(); messageBox->setIcon(QMessageBox::Icon::Critical); + messageBox->setAttribute(Qt::WA_DeleteOnClose); messageBox->setText("No Wine Found"); messageBox->setInformativeText("Wine is not installed but is required to FFXIV on this operating system."); - messageBox->setWindowModality(Qt::WindowModal); + //messageBox->setWindowModality(Qt::WindowModal); messageBox->addButton(QMessageBox::StandardButton::Ok); messageBox->setDefaultButton(QMessageBox::StandardButton::Ok); - messageBox->exec(); + messageBox->show(); } #endif if(defaultProfile.autoLogin) { - autoLoginWindow = new AutoLoginWindow(defaultProfile, core); + autoLoginWindow = new AutoLoginWindow(*this, defaultProfile, core); autoLoginWindow->show(); QObject::connect(autoLoginWindow, &AutoLoginWindow::loginCanceled,[=] { @@ -60,6 +69,22 @@ DesktopInterface::DesktopInterface(LauncherCore& core) { window->show(); }); } else { - window->show(); + if(oneWindow) { + window->showMaximized(); + } else { + window->show(); + } + } +} + +void DesktopInterface::addWindow(VirtualWindow* window) { + if(oneWindow) { + mdiArea->addSubWindow(window->mdi_window); + } +} + +void DesktopInterface::addDialog(VirtualDialog* dialog) { + if(oneWindow) { + mdiArea->addSubWindow(dialog->mdi_window); } } \ No newline at end of file diff --git a/launcher/desktop/src/gamescopesettingswindow.cpp b/launcher/desktop/src/gamescopesettingswindow.cpp index 2c836f7..eb977bb 100644 --- a/launcher/desktop/src/gamescopesettingswindow.cpp +++ b/launcher/desktop/src/gamescopesettingswindow.cpp @@ -9,12 +9,12 @@ #include "launchercore.h" -GamescopeSettingsWindow::GamescopeSettingsWindow(ProfileSettings& settings, LauncherCore& core, QWidget* parent) - : QDialog(parent) { +GamescopeSettingsWindow::GamescopeSettingsWindow(DesktopInterface& interface, ProfileSettings& settings, LauncherCore& core, QWidget* parent) + : VirtualDialog(interface, parent) { setWindowTitle("Gamescope Settings"); setWindowModality(Qt::WindowModality::ApplicationModal); - auto mainLayout = new QFormLayout(this); + auto mainLayout = new QFormLayout(); setLayout(mainLayout); auto fullscreenBox = new QCheckBox("Fullscreen"); diff --git a/launcher/desktop/src/launcherwindow.cpp b/launcher/desktop/src/launcherwindow.cpp index b9a25b0..b9b2948 100644 --- a/launcher/desktop/src/launcherwindow.cpp +++ b/launcher/desktop/src/launcherwindow.cpp @@ -21,8 +21,9 @@ #include "sapphirelauncher.h" #include "settingswindow.h" #include "squarelauncher.h" +#include "desktopinterface.h" -LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) { +LauncherWindow::LauncherWindow(DesktopInterface& interface, LauncherCore& core, QWidget* parent) : VirtualWindow(interface, parent), core(core), interface(interface) { setWindowTitle("Astra"); connect(&core, &LauncherCore::settingsChanged, this, &LauncherWindow::reloadControls); @@ -125,7 +126,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo auto installGameAction = gameMenu->addAction("Install game..."); connect(installGameAction, &QAction::triggered, [this] { // TODO: lol duplication - auto messageBox = new QMessageBox(this); + auto messageBox = new QMessageBox(); messageBox->setIcon(QMessageBox::Icon::Question); messageBox->setText("Warning"); messageBox->setInformativeText("FFXIV will be installed to your selected game directory."); @@ -157,8 +158,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo QAction* settingsAction = fileMenu->addAction("Configure Astra..."); settingsAction->setIcon(QIcon::fromTheme("configure")); settingsAction->setMenuRole(QAction::MenuRole::PreferencesRole); - connect(settingsAction, &QAction::triggered, [=] { - auto window = new SettingsWindow(0, *this, this->core, this); + connect(settingsAction, &QAction::triggered, [=, &interface] { + auto window = new SettingsWindow(interface, 0, *this, this->core); connect(&this->core, &LauncherCore::settingsChanged, window, &SettingsWindow::reloadControls); window->show(); }); @@ -166,8 +167,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo QAction* profilesAction = fileMenu->addAction("Configure Profiles..."); profilesAction->setIcon(QIcon::fromTheme("configure")); profilesAction->setMenuRole(QAction::MenuRole::NoRole); - connect(profilesAction, &QAction::triggered, [=] { - auto window = new SettingsWindow(1, *this, this->core, this); + connect(profilesAction, &QAction::triggered, [=, &interface] { + auto window = new SettingsWindow(interface, 1, *this, this->core); connect(&this->core, &LauncherCore::settingsChanged, window, &SettingsWindow::reloadControls); window->show(); }); @@ -191,15 +192,15 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo QMenu* helpMenu = menuBar()->addMenu("Help"); QAction* showAbout = helpMenu->addAction("About Astra"); showAbout->setIcon(QIcon::fromTheme("help-about")); - connect(showAbout, &QAction::triggered, [=] { - auto window = new AboutWindow(this); + connect(showAbout, &QAction::triggered, [=, &interface] { + auto window = new AboutWindow(interface); window->show(); }); QAction* showAboutQt = helpMenu->addAction("About Qt"); showAboutQt->setIcon(QIcon::fromTheme("help-about")); connect(showAboutQt, &QAction::triggered, [=] { - QMessageBox::aboutQt(this); + QMessageBox::aboutQt(nullptr); }); layout = new QGridLayout(); @@ -393,7 +394,13 @@ void LauncherWindow::reloadControls() { launchOfficial->setEnabled(currentProfile().isGameInstalled()); launchSysInfo->setEnabled(currentProfile().isGameInstalled()); launchCfgBackup->setEnabled(currentProfile().isGameInstalled()); - openGameDir->setEnabled(currentProfile().isGameInstalled()); + + // Steam Deck's Game session has no file manager, so no point in having it here... + if(interface.isSteamDeck) { + openGameDir->setDisabled(true); + } else { + openGameDir->setEnabled(currentProfile().isGameInstalled()); + } #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) wineCfg->setEnabled(currentProfile().isWineInstalled()); diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index b81d00f..0fe4a8a 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -15,12 +15,12 @@ #include "launchercore.h" #include "launcherwindow.h" -SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent) - : core(core), window(window), QDialog(parent) { +SettingsWindow::SettingsWindow(DesktopInterface& interface, int defaultTab, LauncherWindow& window, LauncherCore& core, QWidget* parent) + : core(core), window(window), interface(interface), VirtualDialog(interface, parent) { setWindowTitle("Settings"); setWindowModality(Qt::WindowModality::ApplicationModal); - auto mainLayout = new QVBoxLayout(this); + auto mainLayout = new QVBoxLayout(); setLayout(mainLayout); auto tabWidget = new QTabWidget(); @@ -332,7 +332,7 @@ void SettingsWindow::setupGameTab(QFormLayout& layout) { auto selectDirectoryButton = new QPushButton("Select Game Directory"); connect(selectDirectoryButton, &QPushButton::pressed, [this] { - getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory"); + getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(nullptr, "Open Game Directory"); this->reloadControls(); this->core.saveSettings(); @@ -445,7 +445,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) { otpSecretButton = new QPushButton("Enter OTP Secret"); connect(otpSecretButton, &QPushButton::pressed, [=] { - auto otpSecret = QInputDialog::getText(this, "OTP Input", "Enter your OTP Secret:"); + auto otpSecret = QInputDialog::getText(nullptr, "OTP Input", "Enter your OTP Secret:"); getCurrentProfile().setKeychainValue("otpsecret", otpSecret); }); @@ -511,7 +511,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { }); connect(selectWineButton, &QPushButton::pressed, [this] { - getCurrentProfile().winePath = QFileDialog::getOpenFileName(this, "Open Wine Executable"); + getCurrentProfile().winePath = QFileDialog::getOpenFileName(nullptr, "Open Wine Executable"); this->core.saveSettings(); this->reloadControls(); @@ -535,7 +535,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { auto selectPrefixButton = new QPushButton("Select Wine Prefix"); connect(selectPrefixButton, &QPushButton::pressed, [this] { - getCurrentProfile().winePrefixPath = QFileDialog::getExistingDirectory(this, "Open Wine Prefix"); + getCurrentProfile().winePrefixPath = QFileDialog::getExistingDirectory(nullptr, "Open Wine Prefix"); this->core.saveSettings(); this->reloadControls(); @@ -588,7 +588,7 @@ void SettingsWindow::setupWineTab(QFormLayout& layout) { configureGamescopeButton = new QPushButton("Configure..."); connect(configureGamescopeButton, &QPushButton::pressed, [&] { - auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this->core, this); + auto gamescopeSettingsWindow = new GamescopeSettingsWindow(interface, getCurrentProfile(), this->core, this->getRootWidget()); gamescopeSettingsWindow->show(); }); gamescopeButtonLayout->addWidget(configureGamescopeButton); diff --git a/launcher/desktop/src/virtualdialog.cpp b/launcher/desktop/src/virtualdialog.cpp new file mode 100644 index 0000000..4981548 --- /dev/null +++ b/launcher/desktop/src/virtualdialog.cpp @@ -0,0 +1,75 @@ +#include "virtualdialog.h" + +#include + +#include "desktopinterface.h" + +VirtualDialog::VirtualDialog(DesktopInterface& interface, QWidget* widget) : interface(interface) { + if(interface.oneWindow) { + mdi_window = new QMdiSubWindow(); + mdi_window->setAttribute(Qt::WA_DeleteOnClose); + } else { + normal_dialog = new QDialog(); + } + + interface.addDialog(this); +} + +void VirtualDialog::setWindowTitle(QString title) { + if(interface.oneWindow) { + mdi_window->setWindowTitle(title); + } else { + normal_dialog->setWindowTitle(title); + } +} + +void VirtualDialog::show() { + if (interface.oneWindow) { + mdi_window->show(); + } else { + normal_dialog->show(); + } +} + +void VirtualDialog::hide() { + if(interface.oneWindow) { + mdi_window->hide(); + } else { + normal_dialog->hide(); + } +} + +void VirtualDialog::close() { + if(interface.oneWindow) { + mdi_window->close(); + } else { + normal_dialog->close(); + } +} + +void VirtualDialog::setWindowModality(Qt::WindowModality modality) { + if(interface.oneWindow) { + mdi_window->setWindowModality(modality); + } else { + normal_dialog->setWindowModality(modality); + } +} + +void VirtualDialog::setLayout(QLayout* layout) { + if(interface.oneWindow) { + QWidget* emptyWidget = new QWidget(); + emptyWidget->setLayout(layout); + + mdi_window->layout()->addWidget(emptyWidget); + } else { + normal_dialog->setLayout(layout); + } +} + +QWidget* VirtualDialog::getRootWidget() { + if(interface.oneWindow) { + return mdi_window; + } else { + return normal_dialog; + } +} diff --git a/launcher/desktop/src/virtualwindow.cpp b/launcher/desktop/src/virtualwindow.cpp new file mode 100644 index 0000000..493458f --- /dev/null +++ b/launcher/desktop/src/virtualwindow.cpp @@ -0,0 +1,82 @@ +#include "virtualwindow.h" + +#include +#include + +#include "desktopinterface.h" + +VirtualWindow::VirtualWindow(DesktopInterface& interface, QWidget* widget) : interface(interface) { + if(interface.oneWindow) { + mdi_window = new QMdiSubWindow(); + mdi_window->setAttribute(Qt::WA_DeleteOnClose); + } else { + normal_window = new QMainWindow(); + } + + interface.addWindow(this); +} + +void VirtualWindow::setWindowTitle(QString title) { + if(interface.oneWindow) { + mdi_window->setWindowTitle(title); + } else { + normal_window->setWindowTitle(title); + } +} + +void VirtualWindow::show() { + if(interface.oneWindow) { + mdi_window->show(); + } else { + normal_window->show(); + } +} + +void VirtualWindow::setCentralWidget(QWidget* widget) { + if(interface.oneWindow) { + mdi_window->layout()->addWidget(widget); + } else { + normal_window->setCentralWidget(widget); + } +} + +void VirtualWindow::hide() { + if(interface.oneWindow) { + mdi_window->hide(); + } else { + normal_window->hide(); + } +} + +QMenuBar* VirtualWindow::menuBar() { + if(interface.oneWindow) { + if(mdi_window->layout()->menuBar() == nullptr) { + auto bar = new QMenuBar(); + bar->setObjectName("test"); + qDebug() << "new obj name: " << bar->objectName(); + mdi_window->layout()->setMenuBar(bar); + } + + qDebug() << mdi_window->layout()->menuBar()->objectName(); + + return dynamic_cast(mdi_window->layout()->menuBar()); + } else { + return normal_window->menuBar(); + } +} + +void VirtualWindow::showMaximized() { + if(interface.oneWindow) { + mdi_window->showMaximized(); + } else { + normal_window->showMaximized(); + } +} + +QWidget* VirtualWindow::getRootWidget() { + if(interface.oneWindow) { + return mdi_window; + } else { + return normal_window; + } +} diff --git a/launcher/main.cpp b/launcher/main.cpp index 5ee151b..2f0efe7 100755 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -3,8 +3,6 @@ #include #include -#include "../launcher/tablet/include/tabletinterface.h" -#include "cmdinterface.h" #include "config.h" #include "desktopinterface.h" #include "gameinstaller.h" @@ -14,6 +12,7 @@ int main(int argc, char* argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar); QApplication app(argc, argv); @@ -31,28 +30,11 @@ int main(int argc, char* argv[]) { auto helpOption = parser.addHelpOption(); auto versionOption = parser.addVersionOption(); - QCommandLineOption desktopOption("desktop", "Open a desktop interface."); -#ifdef ENABLE_DESKTOP - parser.addOption(desktopOption); -#endif - - QCommandLineOption tabletOption("tablet", "Open a tablet interface."); -#ifdef ENABLE_TABLET - parser.addOption(tabletOption); -#endif - - QCommandLineOption cliOption("cli", "Don't open a main window, and use the cli interface."); -#ifdef ENABLE_CLI - parser.addOption(cliOption); -#endif - QCommandLineOption steamOption("steam", "Simulate booting the launcher via Steam."); #ifdef ENABLE_STEAM parser.addOption(steamOption); #endif - auto cmd = std::make_unique(parser); - parser.process(app); if (parser.isSet(versionOption)) { @@ -68,23 +50,7 @@ int main(int argc, char* argv[]) { #else LauncherCore c(false); #endif - std::unique_ptr desktopInterface; - std::unique_ptr tabletInterface; - - if (parser.isSet(tabletOption)) { -#ifdef ENABLE_TABLET - tabletInterface = std::make_unique(c); -#endif - } else if (parser.isSet(cliOption)) { -#ifdef ENABLE_CLI - if (!cmd->parse(parser, c)) - return -1; -#endif - } else { -#ifdef ENABLE_DESKTOP - desktopInterface = std::make_unique(c); -#endif - } + std::unique_ptr desktopInterface = std::make_unique(c); return QApplication::exec(); } diff --git a/launcher/tablet/CMakeLists.txt b/launcher/tablet/CMakeLists.txt deleted file mode 100644 index 0398b4d..0000000 --- a/launcher/tablet/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -set(HEADERS - include/tabletinterface.h) - -set(SRC - src/tabletinterface.cpp) - -add_library(astra_tablet STATIC ${HEADERS} ${SRC}) -target_include_directories(astra_tablet PUBLIC include) -target_link_libraries(astra_tablet PUBLIC - astra_core - Qt5::Core - Qt5::Network - Qt5::Quick) \ No newline at end of file diff --git a/launcher/tablet/include/tabletinterface.h b/launcher/tablet/include/tabletinterface.h deleted file mode 100644 index bb429d4..0000000 --- a/launcher/tablet/include/tabletinterface.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -#include "launchercore.h" - -/* - * The tablet-oriented (name to change), touch and gamepad-driven interface for Astra. The interface is - * simpler due to size constraints. - */ -class TabletInterface { -public: - explicit TabletInterface(LauncherCore& core); - -private: - QQmlApplicationEngine* applicationEngine = nullptr; -}; \ No newline at end of file diff --git a/launcher/tablet/qml/main.qml b/launcher/tablet/qml/main.qml deleted file mode 100644 index a6ddb5f..0000000 --- a/launcher/tablet/qml/main.qml +++ /dev/null @@ -1,73 +0,0 @@ -import QtQuick 2.7 -import QtQuick.Controls 2.15 -import QtQuick.Window 2.0 -import Astra 1.0 - -ApplicationWindow { - id: window - - width: 640 - height: 480 - - visible: true - - Label { - id: usernameLabel - - text: "Username" - } - - TextField { - id: usernameField - - anchors.top: usernameLabel.bottom - } - - Label { - id: passwordLabel - - text: "Password" - - anchors.top: usernameField.bottom - } - - TextField { - id: passwordField - - echoMode: TextInput.Password - - anchors.top: passwordLabel.bottom - } - - Label { - id: otpLabel - - text: "One-Time Password" - - anchors.top: passwordField.bottom - } - - TextField { - id: otpField - - anchors.top: otpLabel.bottom - } - - Button { - id: loginButton - - text: "Login" - - anchors.top: otpField.bottom - - onClicked: { - var info = core.createNewLoginInfo(); - info.settings = core.getProfileQML(0); - info.username = usernameField.text - info.password = passwordField.text - info.oneTimePassword = otpField.text - - core.login(info); - } - } -} \ No newline at end of file diff --git a/launcher/tablet/qml/qml.qrc b/launcher/tablet/qml/qml.qrc deleted file mode 100644 index dc7d52f..0000000 --- a/launcher/tablet/qml/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - main.qml - - \ No newline at end of file diff --git a/launcher/tablet/src/tabletinterface.cpp b/launcher/tablet/src/tabletinterface.cpp deleted file mode 100644 index a3a7fa8..0000000 --- a/launcher/tablet/src/tabletinterface.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "tabletinterface.h" - -#include -#include - -TabletInterface::TabletInterface(LauncherCore& core) { - qmlRegisterType("Astra", 1, 0, "ProfileSettings"); - qmlRegisterType("Astra", 1, 0, "LoginInformation"); - - applicationEngine = new QQmlApplicationEngine(); - - applicationEngine->rootContext()->setContextProperty("core", &core); - applicationEngine->load("qrc:/main.qml"); -}