1 #include "LastRunCrashDialog.hpp" 2 3 #include <QDialogButtonBox> 4 #include <QLabel> 5 #include <QPushButton> 6 #include <QVBoxLayout> 7 8 #include "singletons/Updates.hpp" 9 #include "util/LayoutCreator.hpp" 10 #include "util/PostToThread.hpp" 11 12 namespace chatterino { 13 LastRunCrashDialog()14LastRunCrashDialog::LastRunCrashDialog() 15 { 16 this->setWindowFlag(Qt::WindowContextHelpButtonHint, false); 17 this->setWindowTitle("Chatterino"); 18 19 auto layout = 20 LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>(); 21 22 layout.emplace<QLabel>("The application wasn't terminated properly the " 23 "last time it was executed."); 24 25 layout->addSpacing(16); 26 27 // auto update = layout.emplace<QLabel>(); 28 auto buttons = layout.emplace<QDialogButtonBox>(); 29 30 // auto *installUpdateButton = buttons->addButton("Install Update", 31 // QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false); 32 // QObject::connect(installUpdateButton, &QPushButton::clicked, [this, 33 // update]() mutable { 34 // auto &updateManager = UpdateManager::instance(); 35 36 // updateManager.installUpdates(); 37 // this->setEnabled(false); 38 // update->setText("Downloading updates..."); 39 // }); 40 41 auto *okButton = 42 buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole); 43 QObject::connect(okButton, &QPushButton::clicked, [this] { 44 this->accept(); 45 }); 46 47 // Updates 48 // auto updateUpdateLabel = [update]() mutable { 49 // auto &updateManager = UpdateManager::instance(); 50 51 // switch (updateManager.getStatus()) { 52 // case UpdateManager::None: { 53 // update->setText("Not checking for updates."); 54 // } break; 55 // case UpdateManager::Searching: { 56 // update->setText("Checking for updates..."); 57 // } break; 58 // case UpdateManager::UpdateAvailable: { 59 // update->setText("Update available."); 60 // } break; 61 // case UpdateManager::NoUpdateAvailable: { 62 // update->setText("No update abailable."); 63 // } break; 64 // case UpdateManager::SearchFailed: { 65 // update->setText("Error while searching for update.\nEither 66 // the update service is " 67 // "temporarily down or there is an issue 68 // with your installation."); 69 // } break; 70 // case UpdateManager::Downloading: { 71 // update->setText( 72 // "Downloading the update. Chatterino will close once 73 // the download is done."); 74 // } break; 75 // case UpdateManager::DownloadFailed: { 76 // update->setText("Download failed."); 77 // } break; 78 // case UpdateManager::WriteFileFailed: { 79 // update->setText("Writing the update file to the hard drive 80 // failed."); 81 // } break; 82 // } 83 // }; 84 85 // updateUpdateLabel(); 86 // this->managedConnect(updateManager.statusUpdated, 87 // [updateUpdateLabel](auto) mutable { 88 // postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); 89 // }); 90 // }); 91 } 92 93 } // namespace chatterino 94