From 23f1dd464622e1fc92c612de8fb385beaf466494 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 18 Aug 2019 20:14:00 +0200 Subject: [PATCH] update 2.1.0 --- lib/appbase/widgets/BaseWindow.cpp | 2 +- resources/buttons/update.png | Bin 344 -> 268 bytes resources/buttons/updateError.png | Bin 332 -> 267 bytes src/RunGui.cpp | 28 ++-- src/common/Version.hpp | 4 +- .../moderationactions/ModerationAction.cpp | 2 +- src/singletons/Updates.cpp | 128 +++++++++++------- src/singletons/Updates.hpp | 3 +- src/util/InitUpdateButton.cpp | 4 +- src/widgets/Notebook.hpp | 1 - src/widgets/Window.cpp | 34 ++--- src/widgets/dialogs/LoginDialog.cpp | 2 +- src/widgets/dialogs/UpdateDialog.cpp | 9 +- 13 files changed, 127 insertions(+), 90 deletions(-) diff --git a/lib/appbase/widgets/BaseWindow.cpp b/lib/appbase/widgets/BaseWindow.cpp index c3fa8eca4..43f94d651 100644 --- a/lib/appbase/widgets/BaseWindow.cpp +++ b/lib/appbase/widgets/BaseWindow.cpp @@ -71,7 +71,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) // QTimer::this->scaleChangedEvent(this->getScale()); - this->resize(300, 300); + this->resize(300, 150); } float BaseWindow::scale() const diff --git a/resources/buttons/update.png b/resources/buttons/update.png index 925194180db9e19e08b7997216f44cb49df118aa..eca3c50441918438da3f203b095294160f42e671 100644 GIT binary patch delta 203 zcmV;+05t#D0*nHXNq@os01m{x-V zk4GyLasM{ifaXdSZuuJ>*SC+YKP=T&es~02AX>Z$!&hfF=h0+p-j3i9s(1 zQvo9}U~*sv%!q*|2Q*+-46Gk?!FoUy1FQ0aCNRY!A~*AUPR4AeLlpo3002ovPDHLk FV1gs7RzLs% delta 280 zcmeBSy1_KTv;Hsx1K(lBUUXY4=aKQfIWr+s|@_vLIU%x*o-COpdaM`lekC!CgZ?)<&{&qH{ cdN1RLg|32kYfWBhzboFyt=akR{0An|GLjV8( diff --git a/resources/buttons/updateError.png b/resources/buttons/updateError.png index 5c1fec1084b33cd24673c5120b8bbd51c7a78db2..a1e30e22c5977d91f7fda4568939de1cb41c272e 100644 GIT binary patch delta 216 zcmV;}04M*<0*eBWBnkm@Qb$4nuFf3kks%v@!2kdb!2!6DYwZ940H8@kK~zXf?Uexv zfFKM-XNTzi=j#%SUrJ?v(+r8g2W4QsKcr?*RWUFp2qBIarZ{$?TzQzcfuc)%_@MG3 zrwlpe-*Wtk?0N!QuU#ugZ$ZkA*GFnO`c1ayr->%A^^jjXT5G_4T}YL`3m{_L&fC&M z7GQ`${&gSvo%7%(~T11iM8k^>%4DF)sFo$y{T#lWjPVF_HZh{y_D-9EP4 Sv1IK40000R(UWul=({UHVhzC(EUukUerB1_o?2+ zj)Qkpr3_~r{kSXKMVW2$f(6=(1e+rRE{FnUbTnRcWgJNm6R9t8HAyny=GvtMRLaU4 zE7&V>rm1ONhZ|3tqa$43!V_FvyOR2@KNjQKWv=1JUM}01z0lcT?Qhnv#rv&9B4);% zeV8w~@PbbBM{mc2-f0=U`p-_tKfEk)X5!fontk&1t>?-LP3A8!jxU^}@?y7udqLa2 dnK{R$3v-1o&gOqFzYXXu22WQ%mvv4FO#n@raz_9F diff --git a/src/RunGui.cpp b/src/RunGui.cpp index 4da91a500..7c56d8d3a 100644 --- a/src/RunGui.cpp +++ b/src/RunGui.cpp @@ -77,21 +77,21 @@ namespace { void showLastCrashDialog() { -#ifndef C_DISABLE_CRASH_DIALOG - LastRunCrashDialog dialog; + //#ifndef C_DISABLE_CRASH_DIALOG + // LastRunCrashDialog dialog; - switch (dialog.exec()) - { - case QDialog::Accepted: - { - }; - break; - default: - { - _exit(0); - } - } -#endif + // switch (dialog.exec()) + // { + // case QDialog::Accepted: + // { + // }; + // break; + // default: + // { + // _exit(0); + // } + // } + //#endif } void createRunningFile(const QString &path) diff --git a/src/common/Version.hpp b/src/common/Version.hpp index 4101f3a56..26e06a1dc 100644 --- a/src/common/Version.hpp +++ b/src/common/Version.hpp @@ -2,7 +2,7 @@ #include -#define CHATTERINO_VERSION "2.0.4" +#define CHATTERINO_VERSION "2.1.0" #if defined(Q_OS_WIN) # define CHATTERINO_OS "win" @@ -10,4 +10,6 @@ # define CHATTERINO_OS "macos" #elif defined(Q_OS_LINUX) # define CHATTERINO_OS "linux" +#else +# define CHATTERINO_OS "unknown" #endif diff --git a/src/controllers/moderationactions/ModerationAction.cpp b/src/controllers/moderationactions/ModerationAction.cpp index 199ea5521..b4cbe1fc0 100644 --- a/src/controllers/moderationactions/ModerationAction.cpp +++ b/src/controllers/moderationactions/ModerationAction.cpp @@ -73,7 +73,7 @@ ModerationAction::ModerationAction(const QString &action) { this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban); } - else if (action.startsWith("/delete")) + else if (action.startsWith("/delete ")) { this->image_ = Image::fromPixmap(getApp()->resources->buttons.trashCan); } diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index ff32e88dd..c78eb6e9b 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -8,6 +8,7 @@ #include "util/PostToThread.hpp" #include +#include #include #include @@ -15,6 +16,7 @@ namespace chatterino { Updates::Updates() : currentVersion_(CHATTERINO_VERSION) + , updateGuideLink_("https://chatterino.com") { qDebug() << "init UpdateManager"; } @@ -45,7 +47,22 @@ void Updates::installUpdates() return; } -#ifdef Q_OS_WIN +#ifdef Q_OS_MACOS + QMessageBox *box = new QMessageBox( + QMessageBox::Information, "Chatterino Update", + "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", + "Automatic updates are currently not available on " + "linux. Please redownload the app to update."); + box->setAttribute(Qt::WA_DeleteOnClose); + box->exec(); + QDesktopServices::openUrl(this->updateGuideLink_); +#elif defined Q_OS_WIN QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update", "Chatterino is downloading the update " @@ -54,26 +71,23 @@ void Updates::installUpdates() box->setAttribute(Qt::WA_DeleteOnClose); box->show(); - NetworkRequest req(this->updateUrl_); + NetworkRequest req(this->updateExe_); req.setTimeout(600000); req.onError([this](int) -> bool { this->setStatus_(DownloadFailed); - postToThread([] { - QMessageBox *box = - new QMessageBox(QMessageBox::Information, "Chatterino Update", - "Failed while trying to download the update."); - box->setAttribute(Qt::WA_DeleteOnClose); - box->show(); - box->raise(); - }); - + QMessageBox *box = + new QMessageBox(QMessageBox::Information, "Chatterino Update", + "Failed to download the update. \n\nTry manually " + "downloading the update."); + box->setAttribute(Qt::WA_DeleteOnClose); + box->exec(); return true; }); req.onSuccess([this](auto result) -> Outcome { QByteArray object = result.getData(); - auto filename = combinePath(getPaths()->miscDirectory, "update.zip"); + auto filename = combinePath(getPaths()->miscDirectory, "Update.exe"); QFile file(filename); file.open(QIODevice::Truncate | QIODevice::WriteOnly); @@ -81,15 +95,36 @@ void Updates::installUpdates() if (file.write(object) == -1) { this->setStatus_(WriteFileFailed); + QMessageBox *box = new QMessageBox( + QMessageBox::Information, "Chatterino Update", + "Failed to save the update file. This could be due to " + "window settings or antivirus software.\n\nTry manually " + "downloading the update."); + box->setAttribute(Qt::WA_DeleteOnClose); + box->exec(); + + QDesktopServices::openUrl(this->updateExe_); return Failure; } + file.close(); - QProcess::startDetached( - combinePath(QCoreApplication::applicationDirPath(), - "updater.1/ChatterinoUpdater.exe"), - {filename, "restart"}); + if (QProcess::startDetached(filename)) + { + QApplication::exit(0); + } + else + { + QMessageBox *box = new QMessageBox( + QMessageBox::Information, "Chatterino Update", + "Failed to execute update binary. This could be due to window " + "settings or antivirus software.\n\nTry manually downloading " + "the update."); + box->setAttribute(Qt::WA_DeleteOnClose); + box->exec(); + + QDesktopServices::openUrl(this->updateExe_); + } - QApplication::exit(0); return Success; }); this->setStatus_(Downloading); @@ -99,56 +134,52 @@ void Updates::installUpdates() void Updates::checkForUpdates() { -#ifdef Q_OS_WIN QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable"; NetworkRequest req(url); - req.setTimeout(30000); + req.setTimeout(60000); req.onSuccess([this](auto result) -> Outcome { auto object = result.parseJson(); + /// Version available on every platform QJsonValue version_val = object.value("version"); - QJsonValue update_val = object.value("update"); - if (!version_val.isString() || !update_val.isString()) + if (!version_val.isString()) { this->setStatus_(SearchFailed); qDebug() << "error updating"; - - postToThread([] { - QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", - "Error while searching for updates.\n\nEither the service " - "is down " - "temporarily or everything is broken."); - box->setAttribute(Qt::WA_DeleteOnClose); - box->show(); - box->raise(); - }); return Failure; } - this->onlineVersion_ = version_val.toString(); - this->updateUrl_ = update_val.toString(); +#if defined Q_OS_WIN || defined Q_OS_MACOS + /// Windows downloads an installer for the new version + QJsonValue updateExe_val = object.value("updateexe"); + if (!updateExe_val.isString()) + { + this->setStatus_(SearchFailed); + qDebug() << "error updating"; + return Failure; + } + this->updateExe_ = updateExe_val.toString(); +#elif defined Q_OS_LINUX + QJsonValue updateGuide_val = object.value("updateguide"); + if (updateGuide_val.isString()) + { + this->updateGuideLink_ = updateGuide_val.toString(); + } +#else + return Failure; +#endif + + /// Current version + this->onlineVersion_ = version_val.toString(); + + /// Update available :) if (this->currentVersion_ != this->onlineVersion_) { this->setStatus_(UpdateAvailable); - postToThread([this] { - QMessageBox *box = new QMessageBox( - QMessageBox::Information, "Chatterino Update", - "An update for chatterino is available.\n\nDo you " - "want to download and install it?", - QMessageBox::Yes | QMessageBox::No); - box->setAttribute(Qt::WA_DeleteOnClose); - box->show(); - box->raise(); - if (box->exec() == QMessageBox::Yes) - { - this->installUpdates(); - } - }); } else { @@ -158,7 +189,6 @@ void Updates::checkForUpdates() }); this->setStatus_(Searching); req.execute(); -#endif } Updates::Status Updates::getStatus() const diff --git a/src/singletons/Updates.hpp b/src/singletons/Updates.hpp index ff3df8bb5..95daaa018 100644 --- a/src/singletons/Updates.hpp +++ b/src/singletons/Updates.hpp @@ -40,7 +40,8 @@ private: QString onlineVersion_; Status status_ = None; - QString updateUrl_; + QString updateExe_; + QString updateGuideLink_; void setStatus_(Status status); }; diff --git a/src/util/InitUpdateButton.cpp b/src/util/InitUpdateButton.cpp index f86cc5b32..3b4a1e6a1 100644 --- a/src/util/InitUpdateButton.cpp +++ b/src/util/InitUpdateButton.cpp @@ -44,8 +44,8 @@ void initUpdateButton(Button &button, button.setVisible(Updates::getInstance().shouldShowUpdateButton()); auto imageUrl = Updates::getInstance().isError() - ? ":/images/download_update_error.png" - : ":/images/download_update.png"; + ? ":/buttons/updateError.png" + : ":/buttons/update.png"; button.setPixmap(QPixmap(imageUrl)); }; diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index 67b80e55e..2e8b39bbd 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -97,7 +97,6 @@ private: void addCustomButtons(); pajlada::Signals::SignalHolder signalHolder_; - std::shared_ptr updateDialogHandle_; std::vector connections_; }; diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 3df02f0c9..7df35bf40 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -115,27 +115,27 @@ void Window::showEvent(QShowEvent *event) { 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(); + // 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() != "" && getSettings()->currentVersion.getValue() != CHATTERINO_VERSION) { - auto box = new QMessageBox(QMessageBox::Information, - "Chatterino 2 Beta", "Show changelog?", + auto box = new QMessageBox(QMessageBox::Information, "Chatterino 2", + "Show changelog?", QMessageBox::Yes | QMessageBox::No); box->setAttribute(Qt::WA_DeleteOnClose); if (box->exec() == QMessageBox::Yes) { QDesktopServices::openUrl( - QUrl("https://fourtf.com/chatterino-changelog/")); + QUrl("https://www.chatterino.com/changelog")); } } @@ -372,13 +372,13 @@ 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 Beta " CHATTERINO_VERSION); -#endif + //#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 this->setWindowTitle(windowTitleEnd); diff --git a/src/widgets/dialogs/LoginDialog.cpp b/src/widgets/dialogs/LoginDialog.cpp index a1bd065cc..9fb70d296 100644 --- a/src/widgets/dialogs/LoginDialog.cpp +++ b/src/widgets/dialogs/LoginDialog.cpp @@ -88,7 +88,7 @@ BasicLoginWidget::BasicLoginWidget() this->setLayout(&this->ui_.layout); this->ui_.loginButton.setText("Log in (Opens in browser)"); - this->ui_.pasteCodeButton.setText("Paste code"); + this->ui_.pasteCodeButton.setText("Paste login info"); this->ui_.horizontalLayout.addWidget(&this->ui_.loginButton); this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton); diff --git a/src/widgets/dialogs/UpdateDialog.cpp b/src/widgets/dialogs/UpdateDialog.cpp index 7eac073fd..bd10c5f2e 100644 --- a/src/widgets/dialogs/UpdateDialog.cpp +++ b/src/widgets/dialogs/UpdateDialog.cpp @@ -26,8 +26,10 @@ UpdateDialog::UpdateDialog() this->ui_.installButton = install; auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole); - QObject::connect(install, &QPushButton::clicked, this, - [this] { this->close(); }); + QObject::connect(install, &QPushButton::clicked, this, [this] { + Updates::getInstance().installUpdates(); + this->close(); + }); QObject::connect(dismiss, &QPushButton::clicked, this, [this] { this->buttonClicked.invoke(Dismiss); this->close(); @@ -37,6 +39,8 @@ UpdateDialog::UpdateDialog() this->connections_.managedConnect( Updates::getInstance().statusUpdated, [this](auto status) { this->updateStatusChanged(status); }); + + this->setScaleIndependantHeight(150); } void UpdateDialog::updateStatusChanged(Updates::Status status) @@ -51,6 +55,7 @@ void UpdateDialog::updateStatusChanged(Updates::Status status) QString("An update (%1) is available.\n\nDo you want to " "download and install it?") .arg(Updates::getInstance().getOnlineVersion())); + this->updateGeometry(); } break;