mirror-chatterino2/src/widgets/dialogs/LastRunCrashDialog.cpp

88 lines
3.4 KiB
C++
Raw Normal View History

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