File indexing completed on 2021-12-21 14:36:50

0001 /*
0002     SPDX-FileCopyrightText: 2003, 2004 Jean-Baptiste Mardelle <bj@altern.org>
0003     SPDX-FileCopyrightText: 2007, 2010, 2012, 2014, 2016 Rolf Eike Beer <kde@opensource.sf-tec.de>
0004     SPDX-FileCopyrightText: 2016 Andrius Ć tikoans <andrius@stikonas.eu>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "detailedconsole.h"
0009 
0010 #include <KLocalizedString>
0011 #include <KMessageBox>
0012 #include <QApplication>
0013 #include <QDialogButtonBox>
0014 #include <QPushButton>
0015 
0016 KgpgDetailedInfo::KgpgDetailedInfo(QWidget *parent, const QString &boxLabel, const QString &errormessage,
0017         const QStringList &keysList, const QString &caption)
0018     : QDialog(parent)
0019 {
0020     if (!caption.isEmpty())
0021         setWindowTitle(caption);
0022     else
0023         setWindowTitle(i18n("Info"));
0024 
0025     // FIXME: hopefully KMessageBox will provide a helper for this one day...
0026     // code copied from KMessageBox for now
0027     QPushButton *detailsButton = new QPushButton;
0028     detailsButton->setObjectName(QStringLiteral("detailsButton"));
0029     detailsButton->setText(QApplication::translate("KMessageBox", "&Details") + QStringLiteral(" >>"));
0030     detailsButton->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
0031 
0032     QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
0033     buttonBox->addButton(detailsButton, QDialogButtonBox::HelpRole);
0034     buttonBox->addButton(QDialogButtonBox::Ok);
0035     buttonBox->button(QDialogButtonBox::Ok)->setFocus();
0036 
0037     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0038     okButton->setDefault(true);
0039     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0040     connect(buttonBox, &QDialogButtonBox::accepted, this, &KgpgDetailedInfo::accept);
0041     connect(buttonBox, &QDialogButtonBox::rejected, this, &KgpgDetailedInfo::reject);
0042     okButton->setDefault(true);
0043     setModal(true);
0044     KMessageBox::createKMessageBox(this, buttonBox, QMessageBox::Information, boxLabel, keysList, QString(), nullptr,
0045             KMessageBox::Options(), errormessage);
0046 }