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

Begin consolidating GUI work

Also contains some stuff for future Qt6 version
This commit is contained in:
Joshua Goins 2022-10-24 13:03:29 -04:00
parent 8bef7274e1
commit 59d7d842aa
29 changed files with 326 additions and 299 deletions

View file

@ -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.

View file

@ -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)

View file

@ -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)

View file

@ -1,23 +0,0 @@
#pragma once
#include "launchercore.h"
#include <QCommandLineParser>
/*
* 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!"};
};

View file

@ -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;
}

View file

@ -3,6 +3,7 @@
#include <QFile>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QRegExp>
#include <QStandardPaths>
#include <physis.hpp>
#include <utility>
@ -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;

View file

@ -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)

View file

@ -1,8 +1,8 @@
#pragma once
#include <QDialog>
#include "virtualdialog.h"
class AboutWindow : public QDialog {
class AboutWindow : public VirtualDialog {
public:
explicit AboutWindow(QWidget* widget = nullptr);
explicit AboutWindow(DesktopInterface& interface, QWidget* widget = nullptr);
};

View file

@ -1,15 +1,15 @@
#pragma once
#include <QDialog>
#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();

View file

@ -1,7 +1,11 @@
#pragma once
#include <QMdiArea>
#include <QMainWindow>
#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;
};

View file

@ -8,11 +8,13 @@
#include <QListWidget>
#include <QPushButton>
#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);
};

View file

@ -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;
};

View file

@ -9,13 +9,15 @@
#include <QListWidget>
#include <QPushButton>
#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;
};

View file

@ -0,0 +1,28 @@
#pragma once
#include <QMdiSubWindow>
#include <QWidget>
#include <QDialog>
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;
};

View file

@ -0,0 +1,29 @@
#pragma once
#include <QMdiSubWindow>
#include <QWidget>
#include <QMainWindow>
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;
};

View file

@ -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("<a href='a'>License: GNU General Public License Version 3</a>");
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();

View file

@ -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...");

View file

@ -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);
}
}

View file

@ -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");

View file

@ -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());

View file

@ -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);

View file

@ -0,0 +1,75 @@
#include "virtualdialog.h"
#include <QLayout>
#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;
}
}

View file

@ -0,0 +1,82 @@
#include "virtualwindow.h"
#include <QLayout>
#include <QMenuBar>
#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<QMenuBar*>(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;
}
}

View file

@ -3,8 +3,6 @@
#include <QApplication>
#include <QCommandLineParser>
#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<CMDInterface>(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> desktopInterface;
std::unique_ptr<TabletInterface> tabletInterface;
if (parser.isSet(tabletOption)) {
#ifdef ENABLE_TABLET
tabletInterface = std::make_unique<TabletInterface>(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<DesktopInterface>(c);
#endif
}
std::unique_ptr<DesktopInterface> desktopInterface = std::make_unique<DesktopInterface>(c);
return QApplication::exec();
}

View file

@ -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)

View file

@ -1,17 +0,0 @@
#pragma once
#include <QQmlApplicationEngine>
#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;
};

View file

@ -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);
}
}
}

View file

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View file

@ -1,14 +0,0 @@
#include "tabletinterface.h"
#include <QQmlContext>
#include <QQuickView>
TabletInterface::TabletInterface(LauncherCore& core) {
qmlRegisterType<ProfileSettings>("Astra", 1, 0, "ProfileSettings");
qmlRegisterType<LoginInformation>("Astra", 1, 0, "LoginInformation");
applicationEngine = new QQmlApplicationEngine();
applicationEngine->rootContext()->setContextProperty("core", &core);
applicationEngine->load("qrc:/main.qml");
}