diff --git a/chatterino.pro b/chatterino.pro index c205978e8..a6c29eebd 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -82,6 +82,7 @@ SOURCES += \ src/common/DownloadManager.cpp \ src/common/Env.cpp \ src/common/LinkParser.cpp \ + src/common/Modes.cpp \ src/common/NetworkManager.cpp \ src/common/NetworkPrivate.cpp \ src/common/NetworkRequest.cpp \ @@ -235,6 +236,7 @@ HEADERS += \ src/common/DownloadManager.hpp \ src/common/Env.hpp \ src/common/LinkParser.hpp \ + src/common/Modes.hpp \ src/common/NetworkCommon.hpp \ src/common/NetworkManager.hpp \ src/common/NetworkPrivate.hpp \ diff --git a/src/common/Modes.cpp b/src/common/Modes.cpp new file mode 100644 index 000000000..3b655237d --- /dev/null +++ b/src/common/Modes.cpp @@ -0,0 +1,36 @@ +#include "Modes.hpp" + +#include "util/CombinePath.hpp" + +#include + +namespace chatterino { + +Modes::Modes() +{ + QFile file(combinePath(QCoreApplication::applicationDirPath(), "modes")); + file.open(QIODevice::ReadOnly); + + while (!file.atEnd()) + { + auto line = QString(file.readLine()); + + // we need to know if it is a nightly build to disable updates on windows + if (line == "nightly") + { + this->isNightly = true; + } + else if (line == "portable") + { + this->isPortable = true; + } + } +} + +const Modes &Modes::getInstance() +{ + static Modes instance; + return instance; +} + +} // namespace chatterino diff --git a/src/common/Modes.hpp b/src/common/Modes.hpp new file mode 100644 index 000000000..6bf5cc258 --- /dev/null +++ b/src/common/Modes.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace chatterino { + +class Modes +{ +public: + Modes(); + + static const Modes &getInstance(); + + bool isNightly{}; + bool isPortable{}; +}; + +} // namespace chatterino diff --git a/src/singletons/Paths.cpp b/src/singletons/Paths.cpp index 0ba547135..9164cb6ee 100644 --- a/src/singletons/Paths.cpp +++ b/src/singletons/Paths.cpp @@ -8,6 +8,7 @@ #include #include +#include "common/Modes.hpp" #include "util/CombinePath.hpp" namespace chatterino { @@ -32,7 +33,7 @@ bool Paths::createFolder(const QString &folderPath) bool Paths::isPortable() { - return this->portable_.get(); + return Modes::getInstance().isPortable; } QString Paths::cacheDirectory() diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index 03b270567..b419d5fda 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -1,6 +1,7 @@ #include "Updates.hpp" #include "Settings.hpp" +#include "common/Modes.hpp" #include "common/NetworkRequest.hpp" #include "common/Outcome.hpp" #include "common/Version.hpp" @@ -201,6 +202,14 @@ void Updates::installUpdates() void Updates::checkForUpdates() { + // Disable updates if on nightly and windows. +#ifdef Q_OS_WIN + if (Modes::getInstance().isNightly) + { + return; + } +#endif + QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/" + currentBranch(); diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 5b02b8682..3de87bbbb 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -1,6 +1,7 @@ #include "widgets/Window.hpp" #include "Application.hpp" +#include "common/Modes.hpp" #include "common/Version.hpp" #include "controllers/accounts/AccountController.hpp" #include "providers/twitch/TwitchServer.hpp" @@ -115,18 +116,10 @@ bool Window::event(QEvent *event) void Window::showEvent(QShowEvent *event) { // Startup notification - if (getSettings()->startUpNotification.getValue() < 1) + /*if (getSettings()->startUpNotification.getValue() < 1) { getSettings()->startUpNotification = 1; - - // auto box = new QMessageBox( - // QMessageBox::Information, "Chatterino 2 Beta", - // "Please note that this software is not stable yet. Things are " - // "rough " - // "around the edges and everything is subject to change."); - // box->setAttribute(Qt::WA_DeleteOnClose); - // box->show(); - } + }*/ // Show changelog if (getSettings()->currentVersion.getValue() != "" && @@ -377,16 +370,25 @@ void Window::onAccountSelected() { auto user = getApp()->accounts->twitch.getCurrent(); - //#ifdef CHATTERINO_NIGHTLY_VERSION_STRING - // auto windowTitleEnd = - // QString("Chatterino Nightly " CHATTERINO_VERSION - // " (" UGLYMACROHACK(CHATTERINO_NIGHTLY_VERSION_STRING) ")"); - //#else - auto windowTitleEnd = QString("Chatterino " CHATTERINO_VERSION); - //#endif + // update title + QString title = "Chatterino "; + if (Modes::getInstance().isNightly) + { + title += " Nightly"; + } + title += CHATTERINO_VERSION; - this->setWindowTitle(windowTitleEnd); + if (Modes::getInstance().isNightly) + { +#ifdef CHATTERINO_NIGHTLY_VERSION_STRING + title += + QString(" (" UGLYMACROHACK(CHATTERINO_NIGHTLY_VERSION_STRING) ")"); +#endif + } + this->setWindowTitle(title); + + // update user if (user->isAnon()) { if (this->userLabel_) @@ -401,6 +403,6 @@ void Window::onAccountSelected() this->userLabel_->getLabel().setText(user->getUserName()); } } -} +} // namespace chatterino } // namespace chatterino