2018-06-26 14:09:39 +02:00
|
|
|
#include "LastRunCrashDialog.hpp"
|
2018-04-20 00:15:57 +02:00
|
|
|
|
2018-06-01 14:20:46 +02:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
2018-04-20 00:15:57 +02:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Updates.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "util/PostToThread.hpp"
|
2018-06-01 14:20:46 +02:00
|
|
|
|
2018-04-20 00:15:57 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
LastRunCrashDialog::LastRunCrashDialog()
|
|
|
|
{
|
2018-06-01 14:20:46 +02:00
|
|
|
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
|
this->setWindowTitle("Chatterino");
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
auto layout =
|
|
|
|
LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
|
2018-06-01 14:20:46 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
layout.emplace<QLabel>("The application wasn't terminated properly the "
|
|
|
|
"last time it was executed.");
|
2018-06-01 14:20:46 +02:00
|
|
|
|
|
|
|
layout->addSpacing(16);
|
|
|
|
|
2018-06-21 22:44:48 +02:00
|
|
|
// auto update = layout.emplace<QLabel>();
|
2018-06-01 14:20:46 +02:00
|
|
|
auto buttons = layout.emplace<QDialogButtonBox>();
|
|
|
|
|
2018-06-21 22:44:48 +02:00
|
|
|
// auto *installUpdateButton = buttons->addButton("Install Update",
|
|
|
|
// QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false);
|
2018-08-06 21:17:03 +02:00
|
|
|
// QObject::connect(installUpdateButton, &QPushButton::clicked, [this,
|
|
|
|
// update]() mutable {
|
2018-06-28 19:38:57 +02:00
|
|
|
// auto &updateManager = UpdateManager::getInstance();
|
2018-06-01 14:20:46 +02:00
|
|
|
|
2018-06-21 22:44:48 +02:00
|
|
|
// updateManager.installUpdates();
|
|
|
|
// this->setEnabled(false);
|
|
|
|
// update->setText("Downloading updates...");
|
|
|
|
// });
|
2018-06-01 14:20:46 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
auto *okButton =
|
|
|
|
buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole);
|
|
|
|
QObject::connect(okButton, &QPushButton::clicked,
|
|
|
|
[this] { this->accept(); });
|
2018-06-01 14:20:46 +02:00
|
|
|
|
|
|
|
// Updates
|
2018-06-21 22:44:48 +02:00
|
|
|
// auto updateUpdateLabel = [update]() mutable {
|
2018-06-28 19:38:57 +02:00
|
|
|
// auto &updateManager = UpdateManager::getInstance();
|
2018-06-21 22:44:48 +02:00
|
|
|
|
|
|
|
// switch (updateManager.getStatus()) {
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::None: {
|
2018-06-21 22:44:48 +02:00
|
|
|
// update->setText("Not checking for updates.");
|
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::Searching: {
|
2018-06-21 22:44:48 +02:00
|
|
|
// update->setText("Checking for updates...");
|
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::UpdateAvailable: {
|
2018-06-21 22:44:48 +02:00
|
|
|
// update->setText("Update available.");
|
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::NoUpdateAvailable: {
|
2018-06-21 22:44:48 +02:00
|
|
|
// update->setText("No update abailable.");
|
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::SearchFailed: {
|
2018-08-06 21:17:03 +02:00
|
|
|
// update->setText("Error while searching for update.\nEither
|
|
|
|
// the update service is "
|
|
|
|
// "temporarily down or there is an issue
|
|
|
|
// with your installation.");
|
2018-06-21 22:44:48 +02:00
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::Downloading: {
|
2018-06-21 22:44:48 +02:00
|
|
|
// update->setText(
|
2018-08-06 21:17:03 +02:00
|
|
|
// "Downloading the update. Chatterino will close once
|
|
|
|
// the download is done.");
|
2018-06-21 22:44:48 +02:00
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::DownloadFailed: {
|
2018-06-21 22:44:48 +02:00
|
|
|
// update->setText("Download failed.");
|
|
|
|
// } break;
|
2018-06-28 19:38:57 +02:00
|
|
|
// case UpdateManager::WriteFileFailed: {
|
2018-08-06 21:17:03 +02:00
|
|
|
// update->setText("Writing the update file to the hard drive
|
|
|
|
// failed.");
|
2018-06-21 22:44:48 +02:00
|
|
|
// } break;
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
|
|
|
|
// updateUpdateLabel();
|
2018-08-06 21:17:03 +02:00
|
|
|
// this->managedConnect(updateManager.statusUpdated,
|
|
|
|
// [updateUpdateLabel](auto) mutable {
|
|
|
|
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel();
|
|
|
|
// });
|
2018-06-21 22:44:48 +02:00
|
|
|
// });
|
2018-04-20 00:15:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|