mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-21 20:27:45 +00:00
More boring code cleanup
This commit is contained in:
parent
cd2723ebfb
commit
474de3fedc
26 changed files with 48 additions and 73 deletions
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
class CMDInterface {
|
||||
public:
|
||||
CMDInterface(QCommandLineParser& parser);
|
||||
explicit CMDInterface(QCommandLineParser& parser);
|
||||
|
||||
bool parse(QCommandLineParser& parser, LauncherCore& core);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "cmdinterface.h"
|
||||
#include "sapphirelauncher.h"
|
||||
#include "squareboot.h"
|
||||
#include <keychain.h>
|
||||
|
||||
CMDInterface::CMDInterface(QCommandLineParser& parser) {
|
||||
|
|
|
@ -14,7 +14,7 @@ struct ProfileSettings;
|
|||
class AssetUpdater : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AssetUpdater(LauncherCore& launcher);
|
||||
explicit AssetUpdater(LauncherCore& launcher);
|
||||
|
||||
void update(const ProfileSettings& profile);
|
||||
void beginInstall();
|
||||
|
|
|
@ -13,7 +13,7 @@ inline char GetChecksum(unsigned int key) {
|
|||
|
||||
uint32_t TickCount();
|
||||
|
||||
inline QString encryptGameArg(QString arg) {
|
||||
inline QString encryptGameArg(const QString& arg) {
|
||||
unsigned int rawTicks = TickCount();
|
||||
unsigned int ticks = rawTicks & 0xFFFFFFFFu;
|
||||
unsigned int key = ticks & 0xFFFF0000u;
|
||||
|
|
|
@ -7,4 +7,4 @@ class LauncherCore;
|
|||
class ProfileSettings;
|
||||
|
||||
// TODO: convert to a nice signal/slots class like assetupdater
|
||||
void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function<void()> returnFunc);
|
||||
void installGame(LauncherCore& launcher, ProfileSettings& profile, const std::function<void()>& returnFunc);
|
|
@ -28,4 +28,4 @@ struct Headline {
|
|||
|
||||
class LauncherCore;
|
||||
|
||||
void getHeadline(LauncherCore& core, std::function<void(Headline)> return_func);
|
||||
void getHeadline(LauncherCore& core, const std::function<void(Headline)>& return_func);
|
|
@ -148,10 +148,10 @@ public:
|
|||
return profileSettings[index];
|
||||
}
|
||||
|
||||
int getProfileIndex(QString name);
|
||||
int getProfileIndex(const QString& name);
|
||||
Q_INVOKABLE QList<QString> profileList() const;
|
||||
int addProfile();
|
||||
int deleteProfile(QString name);
|
||||
int deleteProfile(const QString& name);
|
||||
|
||||
/*
|
||||
* Begins the login process, and may call SquareBoot or SapphireLauncher depending on the profile type.
|
||||
|
@ -181,7 +181,7 @@ public:
|
|||
void launchExecutable(
|
||||
const ProfileSettings& settings,
|
||||
QProcess* process,
|
||||
QStringList args,
|
||||
const QStringList& args,
|
||||
bool isGame,
|
||||
bool needsRegistrySetup);
|
||||
|
||||
|
@ -242,7 +242,7 @@ private:
|
|||
*/
|
||||
QString getGameArgs(const ProfileSettings& profile, const LoginAuth& auth);
|
||||
|
||||
bool checkIfInPath(QString program);
|
||||
bool checkIfInPath(const QString& program);
|
||||
void readGameData(ProfileSettings& profile);
|
||||
|
||||
QString getDefaultGamePath();
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
QString name, repository, version, path;
|
||||
};
|
||||
|
||||
void processPatch(QueuedPatch patch);
|
||||
void processPatch(const QueuedPatch& patch);
|
||||
|
||||
QVector<QueuedPatch> patchQueue;
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
class SapphireLauncher : QObject {
|
||||
public:
|
||||
SapphireLauncher(LauncherCore& window);
|
||||
explicit SapphireLauncher(LauncherCore& window);
|
||||
|
||||
void login(QString lobbyUrl, const LoginInformation& info);
|
||||
void registerAccount(QString lobbyUrl, const LoginInformation& info);
|
||||
void login(const QString& lobbyUrl, const LoginInformation& info);
|
||||
void registerAccount(const QString& lobbyUrl, const LoginInformation& info);
|
||||
|
||||
private:
|
||||
LauncherCore& window;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
class SquareLauncher : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SquareLauncher(LauncherCore& window);
|
||||
explicit SquareLauncher(LauncherCore& window);
|
||||
|
||||
void getStored(const LoginInformation& info);
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
|||
const QList<QString> dirPath = fileName.left(fileName.lastIndexOf("/")).split('/');
|
||||
|
||||
QString build = dataDir + "/DalamudAssets/";
|
||||
for (auto dir : dirPath) {
|
||||
for (const auto& dir : dirPath) {
|
||||
if (!QDir().exists(build + dir))
|
||||
QDir().mkdir(build + dir);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ uint32_t TickCount() {
|
|||
|
||||
#if defined(Q_OS_LINUX)
|
||||
uint32_t TickCount() {
|
||||
struct timespec ts;
|
||||
struct timespec ts{};
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "launchercore.h"
|
||||
|
||||
void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function<void()> returnFunc) {
|
||||
void installGame(LauncherCore& launcher, ProfileSettings& profile, const std::function<void()>& returnFunc) {
|
||||
QString installDirectory = profile.gamePath;
|
||||
qDebug() << "Installing game to " << installDirectory << "!";
|
||||
|
||||
|
@ -16,7 +16,7 @@ void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function
|
|||
QNetworkRequest request(QUrl("https://gdl.square-enix.com/ffxiv/inst/ffxivsetup.exe"));
|
||||
|
||||
auto reply = launcher.mgr->get(request);
|
||||
launcher.connect(reply, &QNetworkReply::finished, [reply, installDirectory, returnFunc] {
|
||||
QObject::connect(reply, &QNetworkReply::finished, [reply, installDirectory, returnFunc] {
|
||||
QString dataDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
|
||||
QFile file(dataDir + "/ffxivsetup.exe");
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "launchercore.h"
|
||||
|
||||
void getHeadline(LauncherCore& core, std::function<void(Headline)> return_func) {
|
||||
void getHeadline(LauncherCore& core, const std::function<void(Headline)>& return_func) {
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("lang", "en-us");
|
||||
query.addQueryItem("media", "pcapp");
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
@ -7,17 +6,12 @@
|
|||
#include <QJsonObject>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QStandardPaths>
|
||||
#include <QTcpServer>
|
||||
#include <QUrlQuery>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <keychain.h>
|
||||
#include <cotp.h>
|
||||
|
||||
|
@ -179,7 +173,7 @@ QString LauncherCore::getGameArgs(const ProfileSettings& profile, const LoginAut
|
|||
void LauncherCore::launchExecutable(
|
||||
const ProfileSettings& profile,
|
||||
QProcess* process,
|
||||
const QStringList args,
|
||||
const QStringList& args,
|
||||
bool isGame,
|
||||
bool needsRegistrySetup) {
|
||||
QList<QString> arguments;
|
||||
|
@ -482,7 +476,7 @@ ProfileSettings& LauncherCore::getProfile(int index) {
|
|||
return *profileSettings[index];
|
||||
}
|
||||
|
||||
int LauncherCore::getProfileIndex(QString name) {
|
||||
int LauncherCore::getProfileIndex(const QString& name) {
|
||||
for (int i = 0; i < profileSettings.size(); i++) {
|
||||
if (profileSettings[i]->name == name)
|
||||
return i;
|
||||
|
@ -501,7 +495,7 @@ QList<QString> LauncherCore::profileList() const {
|
|||
}
|
||||
|
||||
int LauncherCore::addProfile() {
|
||||
ProfileSettings* newProfile = new ProfileSettings();
|
||||
auto newProfile = new ProfileSettings();
|
||||
newProfile->uuid = QUuid::createUuid();
|
||||
newProfile->name = "New Profile";
|
||||
|
||||
|
@ -517,7 +511,7 @@ int LauncherCore::addProfile() {
|
|||
return profileSettings.size() - 1;
|
||||
}
|
||||
|
||||
int LauncherCore::deleteProfile(QString name) {
|
||||
int LauncherCore::deleteProfile(const QString& name) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < profileSettings.size(); i++) {
|
||||
if (profileSettings[i]->name == name)
|
||||
|
@ -589,7 +583,7 @@ void LauncherCore::saveSettings() {
|
|||
}
|
||||
}
|
||||
|
||||
bool LauncherCore::checkIfInPath(const QString program) {
|
||||
bool LauncherCore::checkIfInPath(const QString& program) {
|
||||
// TODO: also check /usr/local/bin, /bin32 etc (basically read $PATH)
|
||||
const QString directory = "/usr/bin";
|
||||
|
||||
|
@ -629,7 +623,7 @@ QString LauncherCore::getDefaultGamePath() {
|
|||
void LauncherCore::addRegistryKey(const ProfileSettings& settings, QString key, QString value, QString data) {
|
||||
auto process = new QProcess(this);
|
||||
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f"}, false, false);
|
||||
launchExecutable(settings, process, {"reg", "add", std::move(key), "/v", value, "/d", data, "/f"}, false, false);
|
||||
}
|
||||
|
||||
void LauncherCore::readGameData(ProfileSettings& profile) {
|
||||
|
|
|
@ -105,7 +105,7 @@ void Patcher::processPatchList(QNetworkAccessManager& mgr, QString patchList) {
|
|||
|
||||
void Patcher::checkIfDone() {
|
||||
if (remainingPatches <= 0) {
|
||||
for (auto patch : patchQueue) {
|
||||
for (const auto& patch : patchQueue) {
|
||||
processPatch(patch);
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ void Patcher::checkIfDone() {
|
|||
}
|
||||
}
|
||||
|
||||
void Patcher::processPatch(QueuedPatch patch) {
|
||||
void Patcher::processPatch(const QueuedPatch& patch) {
|
||||
if (isBoot()) {
|
||||
physis_bootdata_apply_patch(boot_data, patch.path.toStdString().c_str());
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
SapphireLauncher::SapphireLauncher(LauncherCore& window) : window(window), QObject(&window) {}
|
||||
|
||||
void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) {
|
||||
void SapphireLauncher::login(const QString& lobbyUrl, const LoginInformation& info) {
|
||||
QJsonObject data{{"username", info.username}, {"pass", info.password}};
|
||||
|
||||
QUrl url;
|
||||
|
@ -37,7 +37,7 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) {
|
|||
});
|
||||
}
|
||||
|
||||
void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& info) {
|
||||
void SapphireLauncher::registerAccount(const QString& lobbyUrl, const LoginInformation& info) {
|
||||
QJsonObject data{{"username", info.username}, {"pass", info.password}};
|
||||
QUrl url;
|
||||
url.setScheme("http");
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkReply>
|
||||
#include <QPushButton>
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
class AboutWindow : public QDialog {
|
||||
public:
|
||||
AboutWindow(QWidget* widget = nullptr);
|
||||
explicit AboutWindow(QWidget* widget = nullptr);
|
||||
};
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
ProfileSettings& currentProfile();
|
||||
|
||||
void openPath(const QString path);
|
||||
void openPath(const QString& path);
|
||||
|
||||
public slots:
|
||||
void reloadControls();
|
||||
|
|
|
@ -35,13 +35,13 @@ 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] {
|
||||
QDialog* licenseDialog = new QDialog(this);
|
||||
auto licenseDialog = new QDialog(this);
|
||||
licenseDialog->setWindowTitle("License Agreement");
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
auto layout = new QVBoxLayout();
|
||||
licenseDialog->setLayout(layout);
|
||||
|
||||
QPlainTextEdit* licenseEdit = new QPlainTextEdit();
|
||||
auto licenseEdit = new QPlainTextEdit();
|
||||
licenseEdit->setPlainText(license);
|
||||
licenseEdit->setReadOnly(true);
|
||||
layout->addWidget(licenseEdit);
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
#include "autologinwindow.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QToolTip>
|
||||
#include <keychain.h>
|
||||
|
||||
#include "launchercore.h"
|
||||
#include "launcherwindow.h"
|
||||
|
|
|
@ -12,6 +12,6 @@ void BannerWidget::mousePressEvent(QMouseEvent* event) {
|
|||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
void BannerWidget::setUrl(QUrl url) {
|
||||
this->url = url;
|
||||
void BannerWidget::setUrl(QUrl newUrl) {
|
||||
this->url = newUrl;
|
||||
}
|
||||
|
|
|
@ -2,14 +2,8 @@
|
|||
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QToolTip>
|
||||
|
||||
|
|
|
@ -10,18 +10,15 @@
|
|||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <keychain.h>
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "assetupdater.h"
|
||||
#include "bannerwidget.h"
|
||||
#include "config.h"
|
||||
#include "encryptedarg.h"
|
||||
#include "gameinstaller.h"
|
||||
#include "headline.h"
|
||||
#include "sapphirelauncher.h"
|
||||
#include "settingswindow.h"
|
||||
#include "squareboot.h"
|
||||
#include "squarelauncher.h"
|
||||
|
||||
LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) {
|
||||
|
@ -485,7 +482,7 @@ void LauncherWindow::reloadNews() {
|
|||
|
||||
if (!headline.banner.empty()) {
|
||||
if (core.appSettings.showBanners) {
|
||||
for (auto banner : headline.banner) {
|
||||
for (const auto& banner : headline.banner) {
|
||||
auto request = QNetworkRequest(banner.bannerImage);
|
||||
core.buildRequest(currentProfile(), request);
|
||||
|
||||
|
@ -524,9 +521,9 @@ void LauncherWindow::reloadNews() {
|
|||
}
|
||||
|
||||
if (core.appSettings.showNewsList) {
|
||||
QTreeWidgetItem* newsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("News"));
|
||||
for (auto news : headline.news) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
auto newsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("News"));
|
||||
for (const auto& news : headline.news) {
|
||||
auto item = new QTreeWidgetItem();
|
||||
item->setText(0, news.title);
|
||||
item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat));
|
||||
item->setData(0, Qt::UserRole, news.url);
|
||||
|
@ -534,9 +531,9 @@ void LauncherWindow::reloadNews() {
|
|||
newsItem->addChild(item);
|
||||
}
|
||||
|
||||
QTreeWidgetItem* pinnedItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Pinned"));
|
||||
for (auto pinned : headline.pinned) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
auto pinnedItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Pinned"));
|
||||
for (const auto& pinned : headline.pinned) {
|
||||
auto item = new QTreeWidgetItem();
|
||||
item->setText(0, pinned.title);
|
||||
item->setText(1, QLocale().toString(pinned.date, QLocale::ShortFormat));
|
||||
item->setData(0, Qt::UserRole, pinned.url);
|
||||
|
@ -544,9 +541,9 @@ void LauncherWindow::reloadNews() {
|
|||
pinnedItem->addChild(item);
|
||||
}
|
||||
|
||||
QTreeWidgetItem* topicsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Topics"));
|
||||
for (auto news : headline.topics) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
auto topicsItem = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList("Topics"));
|
||||
for (const auto& news : headline.topics) {
|
||||
auto item = new QTreeWidgetItem();
|
||||
item->setText(0, news.title);
|
||||
item->setText(1, QLocale().toString(news.date, QLocale::ShortFormat));
|
||||
item->setData(0, Qt::UserRole, news.url);
|
||||
|
@ -565,7 +562,7 @@ void LauncherWindow::reloadNews() {
|
|||
}
|
||||
}
|
||||
|
||||
void LauncherWindow::openPath(const QString path) {
|
||||
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);
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QToolTip>
|
||||
#include <keychain.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue