diff --git a/launcher/cli/include/cmdinterface.h b/launcher/cli/include/cmdinterface.h index f093f83..27012a7 100644 --- a/launcher/cli/include/cmdinterface.h +++ b/launcher/cli/include/cmdinterface.h @@ -8,7 +8,7 @@ */ class CMDInterface { public: - CMDInterface(QCommandLineParser& parser); + explicit CMDInterface(QCommandLineParser& parser); bool parse(QCommandLineParser& parser, LauncherCore& core); diff --git a/launcher/cli/src/cmdinterface.cpp b/launcher/cli/src/cmdinterface.cpp index 998177f..542142b 100644 --- a/launcher/cli/src/cmdinterface.cpp +++ b/launcher/cli/src/cmdinterface.cpp @@ -1,6 +1,5 @@ #include "cmdinterface.h" #include "sapphirelauncher.h" -#include "squareboot.h" #include CMDInterface::CMDInterface(QCommandLineParser& parser) { diff --git a/launcher/core/include/assetupdater.h b/launcher/core/include/assetupdater.h index e4a523f..e9721c6 100644 --- a/launcher/core/include/assetupdater.h +++ b/launcher/core/include/assetupdater.h @@ -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(); diff --git a/launcher/core/include/encryptedarg.h b/launcher/core/include/encryptedarg.h index 80f607b..1aeca14 100644 --- a/launcher/core/include/encryptedarg.h +++ b/launcher/core/include/encryptedarg.h @@ -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; diff --git a/launcher/core/include/gameinstaller.h b/launcher/core/include/gameinstaller.h index 63003f7..5ab997d 100644 --- a/launcher/core/include/gameinstaller.h +++ b/launcher/core/include/gameinstaller.h @@ -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 returnFunc); \ No newline at end of file +void installGame(LauncherCore& launcher, ProfileSettings& profile, const std::function& returnFunc); \ No newline at end of file diff --git a/launcher/core/include/headline.h b/launcher/core/include/headline.h index a889683..b8bbec5 100644 --- a/launcher/core/include/headline.h +++ b/launcher/core/include/headline.h @@ -28,4 +28,4 @@ struct Headline { class LauncherCore; -void getHeadline(LauncherCore& core, std::function return_func); \ No newline at end of file +void getHeadline(LauncherCore& core, const std::function& return_func); \ No newline at end of file diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index e35606a..0d9c7d3 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -148,10 +148,10 @@ public: return profileSettings[index]; } - int getProfileIndex(QString name); + int getProfileIndex(const QString& name); Q_INVOKABLE QList 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(); diff --git a/launcher/core/include/patcher.h b/launcher/core/include/patcher.h index 021aea4..777d0f1 100644 --- a/launcher/core/include/patcher.h +++ b/launcher/core/include/patcher.h @@ -29,7 +29,7 @@ private: QString name, repository, version, path; }; - void processPatch(QueuedPatch patch); + void processPatch(const QueuedPatch& patch); QVector patchQueue; diff --git a/launcher/core/include/sapphirelauncher.h b/launcher/core/include/sapphirelauncher.h index 4fed69d..76345c6 100644 --- a/launcher/core/include/sapphirelauncher.h +++ b/launcher/core/include/sapphirelauncher.h @@ -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; diff --git a/launcher/core/include/squarelauncher.h b/launcher/core/include/squarelauncher.h index 053695f..50e2b95 100644 --- a/launcher/core/include/squarelauncher.h +++ b/launcher/core/include/squarelauncher.h @@ -6,7 +6,7 @@ class SquareLauncher : public QObject { Q_OBJECT public: - SquareLauncher(LauncherCore& window); + explicit SquareLauncher(LauncherCore& window); void getStored(const LoginInformation& info); diff --git a/launcher/core/src/assetupdater.cpp b/launcher/core/src/assetupdater.cpp index 97385a3..8521d36 100644 --- a/launcher/core/src/assetupdater.cpp +++ b/launcher/core/src/assetupdater.cpp @@ -309,7 +309,7 @@ void AssetUpdater::checkIfCheckingIsDone() { const QList 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); diff --git a/launcher/core/src/encryptedarg.cpp b/launcher/core/src/encryptedarg.cpp index dfef2d0..55dbff4 100644 --- a/launcher/core/src/encryptedarg.cpp +++ b/launcher/core/src/encryptedarg.cpp @@ -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); diff --git a/launcher/core/src/gameinstaller.cpp b/launcher/core/src/gameinstaller.cpp index 964f779..8084593 100644 --- a/launcher/core/src/gameinstaller.cpp +++ b/launcher/core/src/gameinstaller.cpp @@ -7,7 +7,7 @@ #include "launchercore.h" -void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function returnFunc) { +void installGame(LauncherCore& launcher, ProfileSettings& profile, const std::function& 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"); diff --git a/launcher/core/src/headline.cpp b/launcher/core/src/headline.cpp index 12d4c6f..d8ee222 100644 --- a/launcher/core/src/headline.cpp +++ b/launcher/core/src/headline.cpp @@ -9,7 +9,7 @@ #include "launchercore.h" -void getHeadline(LauncherCore& core, std::function return_func) { +void getHeadline(LauncherCore& core, const std::function& return_func) { QUrlQuery query; query.addQueryItem("lang", "en-us"); query.addQueryItem("media", "pcapp"); diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index ab278a6..a88b655 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,17 +6,12 @@ #include #include #include -#include #include -#include #include #include -#include -#include #include -#include -#include #include +#include #include #include @@ -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 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 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) { diff --git a/launcher/core/src/patcher.cpp b/launcher/core/src/patcher.cpp index 83bd6f3..3159870 100644 --- a/launcher/core/src/patcher.cpp +++ b/launcher/core/src/patcher.cpp @@ -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 { diff --git a/launcher/core/src/sapphirelauncher.cpp b/launcher/core/src/sapphirelauncher.cpp index 25fc92e..f6ed125 100644 --- a/launcher/core/src/sapphirelauncher.cpp +++ b/launcher/core/src/sapphirelauncher.cpp @@ -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"); diff --git a/launcher/core/src/squareboot.cpp b/launcher/core/src/squareboot.cpp index 0e7cc73..a13f0e8 100644 --- a/launcher/core/src/squareboot.cpp +++ b/launcher/core/src/squareboot.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include diff --git a/launcher/desktop/include/aboutwindow.h b/launcher/desktop/include/aboutwindow.h index 737e5a7..553c17a 100644 --- a/launcher/desktop/include/aboutwindow.h +++ b/launcher/desktop/include/aboutwindow.h @@ -4,5 +4,5 @@ class AboutWindow : public QDialog { public: - AboutWindow(QWidget* widget = nullptr); + explicit AboutWindow(QWidget* widget = nullptr); }; \ No newline at end of file diff --git a/launcher/desktop/include/launcherwindow.h b/launcher/desktop/include/launcherwindow.h index 6f899e8..58cf6ab 100644 --- a/launcher/desktop/include/launcherwindow.h +++ b/launcher/desktop/include/launcherwindow.h @@ -19,7 +19,7 @@ public: ProfileSettings& currentProfile(); - void openPath(const QString path); + void openPath(const QString& path); public slots: void reloadControls(); diff --git a/launcher/desktop/src/aboutwindow.cpp b/launcher/desktop/src/aboutwindow.cpp index fdac03f..34bdd8f 100644 --- a/launcher/desktop/src/aboutwindow.cpp +++ b/launcher/desktop/src/aboutwindow.cpp @@ -35,13 +35,13 @@ AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { auto licenseLabel = new QLabel(); licenseLabel->setText("License: GNU General Public License Version 3"); 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); diff --git a/launcher/desktop/src/autologinwindow.cpp b/launcher/desktop/src/autologinwindow.cpp index 2d818bd..532f4d7 100644 --- a/launcher/desktop/src/autologinwindow.cpp +++ b/launcher/desktop/src/autologinwindow.cpp @@ -1,18 +1,12 @@ #include "autologinwindow.h" -#include #include -#include #include -#include -#include #include #include -#include #include #include #include -#include #include "launchercore.h" #include "launcherwindow.h" diff --git a/launcher/desktop/src/bannerwidget.cpp b/launcher/desktop/src/bannerwidget.cpp index 58f847a..da12a38 100644 --- a/launcher/desktop/src/bannerwidget.cpp +++ b/launcher/desktop/src/bannerwidget.cpp @@ -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; } diff --git a/launcher/desktop/src/gamescopesettingswindow.cpp b/launcher/desktop/src/gamescopesettingswindow.cpp index 350bfb7..c9a2f9a 100644 --- a/launcher/desktop/src/gamescopesettingswindow.cpp +++ b/launcher/desktop/src/gamescopesettingswindow.cpp @@ -2,14 +2,8 @@ #include #include -#include #include -#include -#include -#include #include -#include -#include #include #include diff --git a/launcher/desktop/src/launcherwindow.cpp b/launcher/desktop/src/launcherwindow.cpp index 7b24434..4233f21 100644 --- a/launcher/desktop/src/launcherwindow.cpp +++ b/launcher/desktop/src/launcherwindow.cpp @@ -10,18 +10,15 @@ #include #include #include -#include #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); diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index bcf9747..1d69507 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -5,11 +5,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include