File indexing completed on 2024-05-12 05:12:52
0001 /* 0002 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "crashwidget.h" 0008 #include <KLocalizedString> 0009 #include <QLabel> 0010 #include <QPushButton> 0011 #include <QVBoxLayout> 0012 0013 using namespace Akregator; 0014 0015 CrashWidget::CrashWidget(QWidget *parent) 0016 : QWidget(parent) 0017 { 0018 auto vbox = new QVBoxLayout(this); 0019 0020 auto labelLayout = new QHBoxLayout; 0021 auto label = new QLabel(i18n("Akregator did not close correctly. Would you like to restore the previous session?"), this); 0022 label->setObjectName(QLatin1StringView("restoresessionlabel")); 0023 label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 0024 QFont font = label->font(); 0025 font.setBold(true); 0026 font.setPixelSize(20); 0027 label->setFont(font); 0028 vbox->addLayout(labelLayout); 0029 labelLayout->addStretch(0); 0030 labelLayout->addWidget(label); 0031 labelLayout->addStretch(0); 0032 0033 auto buttonLayout = new QHBoxLayout; 0034 vbox->addLayout(buttonLayout); 0035 buttonLayout->addStretch(0); 0036 0037 auto restoreSessionButton = new QPushButton(QIcon::fromTheme(QStringLiteral("window-new")), i18n("Restore Session"), this); 0038 restoreSessionButton->setObjectName(QLatin1StringView("restoresessionbutton")); 0039 restoreSessionButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 0040 buttonLayout->addWidget(restoreSessionButton); 0041 connect(restoreSessionButton, &QPushButton::clicked, this, &CrashWidget::slotRestoreSession); 0042 0043 auto dontRestoreSessionButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-close")), i18n("Do Not Restore Session"), this); 0044 dontRestoreSessionButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 0045 dontRestoreSessionButton->setObjectName(QLatin1StringView("dontrestoresessionbutton")); 0046 buttonLayout->addWidget(dontRestoreSessionButton); 0047 connect(dontRestoreSessionButton, &QPushButton::clicked, this, &CrashWidget::slotDontRestoreSession); 0048 0049 auto askMeLaterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("chronometer")), i18n("Ask me later"), this); 0050 askMeLaterButton->setObjectName(QLatin1StringView("askmelaterbutton")); 0051 buttonLayout->addWidget(askMeLaterButton); 0052 connect(askMeLaterButton, &QPushButton::clicked, this, &CrashWidget::slotAskMeLater); 0053 askMeLaterButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 0054 buttonLayout->addStretch(0); 0055 } 0056 0057 CrashWidget::~CrashWidget() = default; 0058 0059 void CrashWidget::slotRestoreSession() 0060 { 0061 Q_EMIT restoreSession(RestoreSession); 0062 } 0063 0064 void CrashWidget::slotDontRestoreSession() 0065 { 0066 Q_EMIT restoreSession(NotRestoreSession); 0067 } 0068 0069 void CrashWidget::slotAskMeLater() 0070 { 0071 Q_EMIT restoreSession(AskMeLater); 0072 } 0073 0074 #include "moc_crashwidget.cpp"