From 8f43e08ce7b816d736eebc92f2c12ceba0456fb6 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Wed, 10 May 2023 22:33:39 +0200 Subject: [PATCH] Eradicate hardcoded names from various window names --- src/Application.cpp | 6 ++--- src/singletons/Updates.cpp | 30 +++++++++++++------------ src/singletons/WindowManager.cpp | 9 +++++--- src/widgets/dialogs/LoginDialog.cpp | 3 ++- src/widgets/dialogs/QualityPopup.cpp | 4 +++- src/widgets/dialogs/SettingsDialog.cpp | 3 ++- src/widgets/settingspages/AboutPage.cpp | 3 ++- src/widgets/splits/Split.cpp | 9 +++++--- 8 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index b794a7966..412555a99 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -110,9 +110,9 @@ void Application::initialize(Settings &settings, Paths &paths) getSettings()->currentVersion.getValue() != "" && getSettings()->currentVersion.getValue() != CHATTERINO_VERSION) { - auto box = new QMessageBox(QMessageBox::Information, "Chatterino 2", - "Show changelog?", - QMessageBox::Yes | QMessageBox::No); + auto box = new QMessageBox( + QMessageBox::Information, Version::instance().fullVersion(), + "Show changelog?", QMessageBox::Yes | QMessageBox::No); box->setAttribute(Qt::WA_DeleteOnClose); if (box->exec() == QMessageBox::Yes) { diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index c54d63e7b..26c4fee12 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -81,17 +81,19 @@ void Updates::installUpdates() assert(false); return; } + auto windowName = + QString("%1 - Update").arg(Version::instance().fullVersion()); #ifdef Q_OS_MACOS QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, "A link will open in your browser. Download and install to update."); box->setAttribute(Qt::WA_DeleteOnClose); box->exec(); QDesktopServices::openUrl(this->updateExe_); #elif defined Q_OS_LINUX QMessageBox *box = - new QMessageBox(QMessageBox::Information, "Chatterino Update", + new QMessageBox(QMessageBox::Information, windowName, "Automatic updates are currently not available on " "linux. Please redownload the app to update."); box->setAttribute(Qt::WA_DeleteOnClose); @@ -101,7 +103,7 @@ void Updates::installUpdates() if (getPaths()->isPortable()) { QMessageBox *box = - new QMessageBox(QMessageBox::Information, "Chatterino Update", + new QMessageBox(QMessageBox::Information, windowName, "Chatterino is downloading the update " "in the background and will run the " "updater once it is finished."); @@ -110,23 +112,23 @@ void Updates::installUpdates() NetworkRequest(this->updatePortable_) .timeout(600000) - .onError([this](NetworkResult) { + .onError([this, windowName](NetworkResult) { this->setStatus_(DownloadFailed); postToThread([] { QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, "Failed while trying to download the update."); box->setAttribute(Qt::WA_DeleteOnClose); box->show(); box->raise(); }); }) - .onSuccess([this](auto result) -> Outcome { + .onSuccess([this, windowName](auto result) -> Outcome { if (result.status() != 200) { auto *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, QStringLiteral("The update couldn't be downloaded " "(HTTP status %1).") .arg(result.status())); @@ -164,7 +166,7 @@ void Updates::installUpdates() else { QMessageBox *box = - new QMessageBox(QMessageBox::Information, "Chatterino Update", + new QMessageBox(QMessageBox::Information, windowName, "Chatterino is downloading the update " "in the background and will run the " "updater once it is finished."); @@ -173,21 +175,21 @@ void Updates::installUpdates() NetworkRequest(this->updateExe_) .timeout(600000) - .onError([this](NetworkResult) { + .onError([this, windowName](NetworkResult) { this->setStatus_(DownloadFailed); QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, "Failed to download the update. \n\nTry manually " "downloading the update."); box->setAttribute(Qt::WA_DeleteOnClose); box->exec(); }) - .onSuccess([this](auto result) -> Outcome { + .onSuccess([this, windowName](auto result) -> Outcome { if (result.status() != 200) { auto *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, QStringLiteral("The update couldn't be downloaded " "(HTTP status %1).") .arg(result.status())); @@ -207,7 +209,7 @@ void Updates::installUpdates() { this->setStatus_(WriteFileFailed); QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, "Failed to save the update file. This could be due to " "window settings or antivirus software.\n\nTry " "manually " @@ -228,7 +230,7 @@ void Updates::installUpdates() else { QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", + QMessageBox::Information, windowName, "Failed to execute update binary. This could be due to " "window " "settings or antivirus software.\n\nTry manually " diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 15053ccd1..989b33a57 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -3,6 +3,7 @@ #include "Application.hpp" #include "common/Args.hpp" #include "common/QLogging.hpp" +#include "common/Version.hpp" #include "debug/AssertInGuiThread.hpp" #include "messages/MessageElement.hpp" #include "providers/irc/Irc2.hpp" @@ -57,9 +58,11 @@ void WindowManager::showSettingsDialog(QWidget *parent, { if (getArgs().dontSaveSettings) { - QMessageBox::critical(parent, "Chatterino - Editing Settings Forbidden", - "Settings cannot be edited when running with\n" - "commandline arguments such as '-c'."); + QMessageBox::critical( + parent, + Version::instance().fullVersion() + " - Editing Settings Forbidden", + "Settings cannot be edited when running with\n" + "commandline arguments such as '-c'."); } else { diff --git a/src/widgets/dialogs/LoginDialog.cpp b/src/widgets/dialogs/LoginDialog.cpp index 18b3acf80..2822ed5b3 100644 --- a/src/widgets/dialogs/LoginDialog.cpp +++ b/src/widgets/dialogs/LoginDialog.cpp @@ -4,6 +4,7 @@ #include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "common/QLogging.hpp" +#include "common/Version.hpp" #include "controllers/accounts/AccountController.hpp" #include "providers/twitch/TwitchAccount.hpp" #include "util/Clipboard.hpp" @@ -81,7 +82,7 @@ BasicLoginWidget::BasicLoginWidget() this->ui_.loginButton.setText("Log in (Opens in browser)"); this->ui_.pasteCodeButton.setText("Paste login info"); this->ui_.unableToOpenBrowserHelper.setWindowTitle( - "Chatterino - unable to open in browser"); + Version::instance().fullVersion() + " - unable to open in browser"); this->ui_.unableToOpenBrowserHelper.setWordWrap(true); this->ui_.unableToOpenBrowserHelper.hide(); this->ui_.unableToOpenBrowserHelper.setText( diff --git a/src/widgets/dialogs/QualityPopup.cpp b/src/widgets/dialogs/QualityPopup.cpp index 9c7d519db..309ad29c0 100644 --- a/src/widgets/dialogs/QualityPopup.cpp +++ b/src/widgets/dialogs/QualityPopup.cpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "common/QLogging.hpp" +#include "common/Version.hpp" #include "singletons/WindowManager.hpp" #include "util/StreamLink.hpp" #include "widgets/Window.hpp" @@ -35,7 +36,8 @@ void QualityPopup::showDialog(const QString &channelURL, QStringList options) { QualityPopup *instance = new QualityPopup(channelURL, options); - instance->window()->setWindowTitle("Chatterino - select stream quality"); + instance->window()->setWindowTitle(Version::instance().fullVersion() + + "- select stream quality"); instance->setAttribute(Qt::WA_DeleteOnClose, true); instance->show(); diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 5bd218860..ddf7583cd 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "common/Args.hpp" +#include "common/Version.hpp" #include "controllers/commands/CommandController.hpp" #include "controllers/hotkeys/HotkeyController.hpp" #include "singletons/Settings.hpp" @@ -34,7 +35,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) parent) { this->setObjectName("SettingsDialog"); - this->setWindowTitle("Chatterino Settings"); + this->setWindowTitle(Version::instance().fullVersion() + " - Settings"); // Disable the ? button in the titlebar until we decide to use it this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); diff --git a/src/widgets/settingspages/AboutPage.cpp b/src/widgets/settingspages/AboutPage.cpp index 05037621e..7f72125b8 100644 --- a/src/widgets/settingspages/AboutPage.cpp +++ b/src/widgets/settingspages/AboutPage.cpp @@ -230,7 +230,8 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name, auto window = new BasePopup({BaseWindow::Flags::EnableCustomFrame, BaseWindow::DisableLayoutSave}, parent); - window->setWindowTitle("Chatterino - License for " + name); + window->setWindowTitle(Version::instance().fullVersion() + + " - License for " + name); window->setAttribute(Qt::WA_DeleteOnClose); auto layout = new QVBoxLayout(); auto *edit = new QTextEdit; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index a6ae50dae..a3bb0645e 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -5,6 +5,7 @@ #include "common/NetworkRequest.hpp" #include "common/NetworkResult.hpp" #include "common/QLogging.hpp" +#include "common/Version.hpp" #include "controllers/accounts/AccountController.hpp" #include "controllers/commands/CommandController.hpp" #include "controllers/hotkeys/HotkeyController.hpp" @@ -194,7 +195,8 @@ namespace { { auto window = new BasePopup(BaseWindow::Flags::EnableCustomFrame, parent); - window->setWindowTitle("Chatterino - " + title); + window->setWindowTitle(Version::instance().fullVersion() + " - " + + title); window->setAttribute(Qt::WA_DeleteOnClose); auto layout = new QVBoxLayout(); layout->addWidget(new QLabel(description)); @@ -375,7 +377,7 @@ Split::Split(QWidget *parent) if (getSettings()->askOnImageUpload.getValue()) { QMessageBox msgBox(this->window()); - msgBox.setWindowTitle("Chatterino"); + msgBox.setWindowTitle(Version::instance().fullVersion()); msgBox.setText("Image upload"); msgBox.setInformativeText( "You are uploading an image to a 3rd party service not in " @@ -445,7 +447,8 @@ void Split::addShortcuts() [](std::vector) -> QString { auto *popup = new DebugPopup; popup->setAttribute(Qt::WA_DeleteOnClose); - popup->setWindowTitle("Chatterino - Debug popup"); + popup->setWindowTitle(Version::instance().fullVersion() + + " - Debug popup"); popup->show(); return ""; }},