update 2.1.0

This commit is contained in:
fourtf 2019-08-18 20:14:00 +02:00
parent 18fb160094
commit 23f1dd4646
13 changed files with 127 additions and 90 deletions

View file

@ -71,7 +71,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
// QTimer::this->scaleChangedEvent(this->getScale()); // QTimer::this->scaleChangedEvent(this->getScale());
this->resize(300, 300); this->resize(300, 150);
} }
float BaseWindow::scale() const float BaseWindow::scale() const

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 267 B

View file

@ -77,21 +77,21 @@ namespace {
void showLastCrashDialog() void showLastCrashDialog()
{ {
#ifndef C_DISABLE_CRASH_DIALOG //#ifndef C_DISABLE_CRASH_DIALOG
LastRunCrashDialog dialog; // LastRunCrashDialog dialog;
switch (dialog.exec()) // switch (dialog.exec())
{ // {
case QDialog::Accepted: // case QDialog::Accepted:
{ // {
}; // };
break; // break;
default: // default:
{ // {
_exit(0); // _exit(0);
} // }
} // }
#endif //#endif
} }
void createRunningFile(const QString &path) void createRunningFile(const QString &path)

View file

@ -2,7 +2,7 @@
#include <QtGlobal> #include <QtGlobal>
#define CHATTERINO_VERSION "2.0.4" #define CHATTERINO_VERSION "2.1.0"
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
# define CHATTERINO_OS "win" # define CHATTERINO_OS "win"
@ -10,4 +10,6 @@
# define CHATTERINO_OS "macos" # define CHATTERINO_OS "macos"
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
# define CHATTERINO_OS "linux" # define CHATTERINO_OS "linux"
#else
# define CHATTERINO_OS "unknown"
#endif #endif

View file

@ -73,7 +73,7 @@ ModerationAction::ModerationAction(const QString &action)
{ {
this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban); 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); this->image_ = Image::fromPixmap(getApp()->resources->buttons.trashCan);
} }

View file

@ -8,6 +8,7 @@
#include "util/PostToThread.hpp" #include "util/PostToThread.hpp"
#include <QDebug> #include <QDebug>
#include <QDesktopServices>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
@ -15,6 +16,7 @@ namespace chatterino {
Updates::Updates() Updates::Updates()
: currentVersion_(CHATTERINO_VERSION) : currentVersion_(CHATTERINO_VERSION)
, updateGuideLink_("https://chatterino.com")
{ {
qDebug() << "init UpdateManager"; qDebug() << "init UpdateManager";
} }
@ -45,7 +47,22 @@ void Updates::installUpdates()
return; 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 = QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update", new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Chatterino is downloading the update " "Chatterino is downloading the update "
@ -54,26 +71,23 @@ void Updates::installUpdates()
box->setAttribute(Qt::WA_DeleteOnClose); box->setAttribute(Qt::WA_DeleteOnClose);
box->show(); box->show();
NetworkRequest req(this->updateUrl_); NetworkRequest req(this->updateExe_);
req.setTimeout(600000); req.setTimeout(600000);
req.onError([this](int) -> bool { req.onError([this](int) -> bool {
this->setStatus_(DownloadFailed); this->setStatus_(DownloadFailed);
postToThread([] { QMessageBox *box =
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
new QMessageBox(QMessageBox::Information, "Chatterino Update", "Failed to download the update. \n\nTry manually "
"Failed while trying to download the update."); "downloading the update.");
box->setAttribute(Qt::WA_DeleteOnClose); box->setAttribute(Qt::WA_DeleteOnClose);
box->show(); box->exec();
box->raise();
});
return true; return true;
}); });
req.onSuccess([this](auto result) -> Outcome { req.onSuccess([this](auto result) -> Outcome {
QByteArray object = result.getData(); QByteArray object = result.getData();
auto filename = combinePath(getPaths()->miscDirectory, "update.zip"); auto filename = combinePath(getPaths()->miscDirectory, "Update.exe");
QFile file(filename); QFile file(filename);
file.open(QIODevice::Truncate | QIODevice::WriteOnly); file.open(QIODevice::Truncate | QIODevice::WriteOnly);
@ -81,15 +95,36 @@ void Updates::installUpdates()
if (file.write(object) == -1) if (file.write(object) == -1)
{ {
this->setStatus_(WriteFileFailed); 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; return Failure;
} }
file.close();
QProcess::startDetached( if (QProcess::startDetached(filename))
combinePath(QCoreApplication::applicationDirPath(), {
"updater.1/ChatterinoUpdater.exe"), QApplication::exit(0);
{filename, "restart"}); }
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; return Success;
}); });
this->setStatus_(Downloading); this->setStatus_(Downloading);
@ -99,56 +134,52 @@ void Updates::installUpdates()
void Updates::checkForUpdates() void Updates::checkForUpdates()
{ {
#ifdef Q_OS_WIN
QString url = QString url =
"https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS
"/stable"; "/stable";
NetworkRequest req(url); NetworkRequest req(url);
req.setTimeout(30000); req.setTimeout(60000);
req.onSuccess([this](auto result) -> Outcome { req.onSuccess([this](auto result) -> Outcome {
auto object = result.parseJson(); auto object = result.parseJson();
/// Version available on every platform
QJsonValue version_val = object.value("version"); 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); this->setStatus_(SearchFailed);
qDebug() << "error updating"; 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; return Failure;
} }
this->onlineVersion_ = version_val.toString(); #if defined Q_OS_WIN || defined Q_OS_MACOS
this->updateUrl_ = update_val.toString(); /// 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_) if (this->currentVersion_ != this->onlineVersion_)
{ {
this->setStatus_(UpdateAvailable); 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 else
{ {
@ -158,7 +189,6 @@ void Updates::checkForUpdates()
}); });
this->setStatus_(Searching); this->setStatus_(Searching);
req.execute(); req.execute();
#endif
} }
Updates::Status Updates::getStatus() const Updates::Status Updates::getStatus() const

View file

@ -40,7 +40,8 @@ private:
QString onlineVersion_; QString onlineVersion_;
Status status_ = None; Status status_ = None;
QString updateUrl_; QString updateExe_;
QString updateGuideLink_;
void setStatus_(Status status); void setStatus_(Status status);
}; };

View file

@ -44,8 +44,8 @@ void initUpdateButton(Button &button,
button.setVisible(Updates::getInstance().shouldShowUpdateButton()); button.setVisible(Updates::getInstance().shouldShowUpdateButton());
auto imageUrl = Updates::getInstance().isError() auto imageUrl = Updates::getInstance().isError()
? ":/images/download_update_error.png" ? ":/buttons/updateError.png"
: ":/images/download_update.png"; : ":/buttons/update.png";
button.setPixmap(QPixmap(imageUrl)); button.setPixmap(QPixmap(imageUrl));
}; };

View file

@ -97,7 +97,6 @@ private:
void addCustomButtons(); void addCustomButtons();
pajlada::Signals::SignalHolder signalHolder_; pajlada::Signals::SignalHolder signalHolder_;
std::shared_ptr<UpdateDialog> updateDialogHandle_;
std::vector<pajlada::Signals::ScopedConnection> connections_; std::vector<pajlada::Signals::ScopedConnection> connections_;
}; };

View file

@ -115,27 +115,27 @@ void Window::showEvent(QShowEvent *event)
{ {
getSettings()->startUpNotification = 1; getSettings()->startUpNotification = 1;
auto box = new QMessageBox( // auto box = new QMessageBox(
QMessageBox::Information, "Chatterino 2 Beta", // QMessageBox::Information, "Chatterino 2 Beta",
"Please note that this software is not stable yet. Things are " // "Please note that this software is not stable yet. Things are "
"rough " // "rough "
"around the edges and everything is subject to change."); // "around the edges and everything is subject to change.");
box->setAttribute(Qt::WA_DeleteOnClose); // box->setAttribute(Qt::WA_DeleteOnClose);
box->show(); // box->show();
} }
// Show changelog // Show changelog
if (getSettings()->currentVersion.getValue() != "" && if (getSettings()->currentVersion.getValue() != "" &&
getSettings()->currentVersion.getValue() != CHATTERINO_VERSION) getSettings()->currentVersion.getValue() != CHATTERINO_VERSION)
{ {
auto box = new QMessageBox(QMessageBox::Information, auto box = new QMessageBox(QMessageBox::Information, "Chatterino 2",
"Chatterino 2 Beta", "Show changelog?", "Show changelog?",
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
box->setAttribute(Qt::WA_DeleteOnClose); box->setAttribute(Qt::WA_DeleteOnClose);
if (box->exec() == QMessageBox::Yes) if (box->exec() == QMessageBox::Yes)
{ {
QDesktopServices::openUrl( 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(); auto user = getApp()->accounts->twitch.getCurrent();
#ifdef CHATTERINO_NIGHTLY_VERSION_STRING //#ifdef CHATTERINO_NIGHTLY_VERSION_STRING
auto windowTitleEnd = // auto windowTitleEnd =
QString("Chatterino Nightly " CHATTERINO_VERSION // QString("Chatterino Nightly " CHATTERINO_VERSION
" (" UGLYMACROHACK(CHATTERINO_NIGHTLY_VERSION_STRING) ")"); // " (" UGLYMACROHACK(CHATTERINO_NIGHTLY_VERSION_STRING) ")");
#else //#else
auto windowTitleEnd = QString("Chatterino Beta " CHATTERINO_VERSION); auto windowTitleEnd = QString("Chatterino " CHATTERINO_VERSION);
#endif //#endif
this->setWindowTitle(windowTitleEnd); this->setWindowTitle(windowTitleEnd);

View file

@ -88,7 +88,7 @@ BasicLoginWidget::BasicLoginWidget()
this->setLayout(&this->ui_.layout); this->setLayout(&this->ui_.layout);
this->ui_.loginButton.setText("Log in (Opens in browser)"); 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_.loginButton);
this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton); this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton);

View file

@ -26,8 +26,10 @@ UpdateDialog::UpdateDialog()
this->ui_.installButton = install; this->ui_.installButton = install;
auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole); auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
QObject::connect(install, &QPushButton::clicked, this, QObject::connect(install, &QPushButton::clicked, this, [this] {
[this] { this->close(); }); Updates::getInstance().installUpdates();
this->close();
});
QObject::connect(dismiss, &QPushButton::clicked, this, [this] { QObject::connect(dismiss, &QPushButton::clicked, this, [this] {
this->buttonClicked.invoke(Dismiss); this->buttonClicked.invoke(Dismiss);
this->close(); this->close();
@ -37,6 +39,8 @@ UpdateDialog::UpdateDialog()
this->connections_.managedConnect( this->connections_.managedConnect(
Updates::getInstance().statusUpdated, Updates::getInstance().statusUpdated,
[this](auto status) { this->updateStatusChanged(status); }); [this](auto status) { this->updateStatusChanged(status); });
this->setScaleIndependantHeight(150);
} }
void UpdateDialog::updateStatusChanged(Updates::Status status) 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 " QString("An update (%1) is available.\n\nDo you want to "
"download and install it?") "download and install it?")
.arg(Updates::getInstance().getOnlineVersion())); .arg(Updates::getInstance().getOnlineVersion()));
this->updateGeometry();
} }
break; break;