diff --git a/src/kmessagebox.cpp b/src/kmessagebox.cpp index befcc06..6a6dafe 100644 --- a/src/kmessagebox.cpp +++ b/src/kmessagebox.cpp @@ -1,1163 +1,1199 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Waldo Bastian (bastian@kde.org) Copyright 2012 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kmessagebox.h" #include "kmessagebox_p.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if 0 // NOTE waiting for the notification framework plan #include #endif #include #include // Some i18n filters, that standard button texts are piped through // (the new KGuiItem object with filtered text is created from the old one). // Filter for the Yes-button text in standard message dialogs, // after the message caption/text have been translated. #define I18N_FILTER_BUTTON_YES(src, dst) \ KGuiItem dst(src); \ dst.setText( QApplication::translate( "KMessageBox", src.text().toUtf8().constData(), "@action:button filter-yes" ) ); // Filter for the No-button text in standard message dialogs, // after the message caption/text have been translated. #define I18N_FILTER_BUTTON_NO(src, dst) \ KGuiItem dst(src); \ dst.setText( QApplication::translate( "KMessageBox", src.text().toUtf8().constData(), "@action:button filter-no" ) ); // Filter for the Continue-button text in standard message dialogs, // after the message caption/text have been translated. #define I18N_FILTER_BUTTON_CONTINUE(src, dst) \ KGuiItem dst(src); \ dst.setText( QApplication::translate( "KMessageBox", src.text().toUtf8().constData(), "@action:button filter-continue" ) ); // Filter for the Cancel-button text in standard message dialogs, // after the message caption/text have been translated. #define I18N_FILTER_BUTTON_CANCEL(src, dst) \ KGuiItem dst(src); \ dst.setText( QApplication::translate( "KMessageBox", src.text().toUtf8().constData(), "@action:button filter-cancel" ) ); // Called after the button texts in standard message dialogs // have been filtered by the messages above. Not visible to user. #define I18N_POST_BUTTON_FILTER \ QApplication::translate( "KMessageBox", ".", "@action:button post-filter" ); namespace KMessageBox { /* * this static is used by the createKMessageBox function to enqueue dialogs * FIXME what should we do about this static? */ QDialogButtonBox::StandardButton KWIDGETSADDONS_EXPORT(*KMessageBox_exec_hook)(QDialog *) = nullptr; static void applyOptions(QDialog *dialog, KMessageBox::Options options) { if (options & KMessageBox::WindowModal) { dialog->setWindowModality(Qt::WindowModal); } dialog->setModal(true); } // This method has been copied from KWindowSystem to avoid depending on it static void setMainWindow(QWidget *subWidget, WId mainWindowId) { #ifdef Q_OS_OSX if (!QWidget::find(mainWindowId)) { return; } #endif // Set the WA_NativeWindow attribute to force the creation of the QWindow. // Without this QWidget::windowHandle() returns 0. subWidget->setAttribute(Qt::WA_NativeWindow, true); QWindow *subWindow = subWidget->windowHandle(); Q_ASSERT(subWindow); QWindow *mainWindow = QWindow::fromWinId(mainWindowId); if (!mainWindow) { // foreign windows not supported on all platforms return; } // mainWindow is not the child of any object, so make sure it gets deleted at some point QObject::connect(subWidget, &QObject::destroyed, mainWindow, &QObject::deleteLater); subWindow->setTransientParent(mainWindow); } /** * Create a QDialog whose parent is a foreign window */ static QDialog *createWIdDialog(WId parent_id) { QWidget *parent = QWidget::find(parent_id); QDialog *dialog = new QDialog(parent, Qt::Dialog); if (!parent && parent_id) { setMainWindow(dialog, parent_id); } return dialog; } class DialogButtonsHelper : public QObject { Q_OBJECT public: DialogButtonsHelper(QDialog *dialog, QDialogButtonBox *buttons) : QObject(dialog), m_dialog(dialog), m_buttons(buttons), m_details(nullptr) { connect(m_buttons, &QDialogButtonBox::clicked, this, &DialogButtonsHelper::onButtonClicked); } void setDetailsWidget(QWidget *widget) { m_details = widget; } public Q_SLOTS: void onButtonClicked(QAbstractButton *button) { QDialogButtonBox::StandardButton code = m_buttons->standardButton(button); if (code != QDialogButtonBox::NoButton) { m_dialog->done(code); } } private: QDialog *const m_dialog; QDialogButtonBox *const m_buttons; QWidget *m_details; }; QDialogButtonBox::StandardButton createKMessageBox(QDialog *dialog, QDialogButtonBox *buttons, QMessageBox::Icon icon, const QString &text, const QStringList &strlist, const QString &ask, bool *checkboxReturn, Options options, const QString &details) { QIcon tmpIcon; QStyle *style = dialog ? dialog->style() : QApplication::style(); switch (icon) { case QMessageBox::Information: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, dialog); break; case QMessageBox::Warning: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, dialog); break; case QMessageBox::Critical: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, dialog); break; case QMessageBox::Question: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, dialog); break; default: break; } return createKMessageBox(dialog, buttons, tmpIcon, text, strlist, ask, checkboxReturn, options, details, icon); } QDialogButtonBox::StandardButton createKMessageBox(QDialog *dialog, QDialogButtonBox *buttons, const QIcon &icon, const QString &text, const QStringList &strlist, const QString &ask, bool *checkboxReturn, Options options, const QString &details, QMessageBox::Icon notifyType) { DialogButtonsHelper *buttonsHelper = new DialogButtonsHelper(dialog, buttons); QWidget *mainWidget = new QWidget(dialog); QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget); const int spacingHint = mainWidget->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); mainLayout->setSpacing(spacingHint * 2); // provide extra spacing mainLayout->setContentsMargins(0, 0, 0, 0); buttons->setParent(dialog); QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->setContentsMargins(0, 0, 0, 0); hLayout->setSpacing(-1); // use default spacing mainLayout->addLayout(hLayout, 5); QLabel *iconLabel = new QLabel(mainWidget); if (!icon.isNull()) { QStyleOption option; option.initFrom(mainWidget); iconLabel->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget))); } QVBoxLayout *iconLayout = new QVBoxLayout(); iconLayout->addStretch(1); iconLayout->addWidget(iconLabel); iconLayout->addStretch(5); hLayout->addLayout(iconLayout, 0); hLayout->addSpacing(spacingHint); QLabel *messageLabel = new QLabel(text, mainWidget); messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink); Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard; if (options & KMessageBox::AllowLink) { flags |= Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard; } messageLabel->setTextInteractionFlags(flags); QRect desktop = QApplication::desktop()->screenGeometry(dialog); bool usingSqueezedTextLabel = false; if (messageLabel->sizeHint().width() > desktop.width() * 0.5) { // enable automatic wrapping of messages which are longer than 50% of screen width messageLabel->setWordWrap(true); // use a squeezed label if text is still too wide usingSqueezedTextLabel = messageLabel->sizeHint().width() > desktop.width() * 0.85; if (usingSqueezedTextLabel) { delete messageLabel; messageLabel = new KSqueezedTextLabel(text, mainWidget); messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink); messageLabel->setTextInteractionFlags(flags); } } QPalette messagePal(messageLabel->palette()); messagePal.setColor(QPalette::Window, Qt::transparent); messageLabel->setPalette(messagePal); bool usingScrollArea = desktop.height() / 3 < messageLabel->sizeHint().height(); if (usingScrollArea) { QScrollArea *messageScrollArea = new QScrollArea(mainWidget); messageScrollArea->setWidget(messageLabel); messageScrollArea->setFrameShape(QFrame::NoFrame); messageScrollArea->setWidgetResizable(true); QPalette scrollPal(messageScrollArea->palette()); scrollPal.setColor(QPalette::Window, Qt::transparent); messageScrollArea->viewport()->setPalette(scrollPal); hLayout->addWidget(messageScrollArea, 5); } else { hLayout->addWidget(messageLabel, 5); } const bool usingListWidget = !strlist.isEmpty(); if (usingListWidget) { // enable automatic wrapping since the listwidget has already a good initial width messageLabel->setWordWrap(true); QListWidget *listWidget = new QListWidget(mainWidget); listWidget->addItems(strlist); QStyleOptionViewItem styleOption; styleOption.initFrom(listWidget); QFontMetrics fm(styleOption.font); int w = listWidget->width(); for (const QString &str : strlist) { w = qMax(w, fm.boundingRect(str).width()); } const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height(); w += borderWidth; if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width w = qRound(desktop.width() * 0.85); } listWidget->setMinimumWidth(w); mainLayout->addWidget(listWidget, usingScrollArea ? 10 : 50); listWidget->setSelectionMode(QListWidget::NoSelection); messageLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); } else if (!usingScrollArea) { mainLayout->addStretch(15); } QPointer checkbox = nullptr; if (!ask.isEmpty()) { checkbox = new QCheckBox(ask, mainWidget); mainLayout->addWidget(checkbox); if (checkboxReturn) { checkbox->setChecked(*checkboxReturn); } } QVBoxLayout *topLayout = new QVBoxLayout; dialog->setLayout(topLayout); topLayout->addWidget(mainWidget); if (!details.isEmpty()) { QHBoxLayout *detailsHLayout = new QHBoxLayout(); detailsHLayout->addSpacing(2 * spacingHint + iconLayout->sizeHint().width()); KCollapsibleGroupBox *detailsGroup = new KCollapsibleGroupBox(); detailsGroup->setTitle(QApplication::translate("KMessageBox", "Details")); QVBoxLayout *detailsLayout = new QVBoxLayout(detailsGroup); if (details.length() < 512) { QLabel *detailsLabel = new QLabel(details); detailsLabel->setOpenExternalLinks(options & KMessageBox::AllowLink); Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard; if (options & KMessageBox::AllowLink) { flags |= Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard; }; detailsLabel->setTextInteractionFlags(flags); detailsLabel->setWordWrap(true); detailsLabel->setMinimumSize(detailsLabel->sizeHint()); detailsLayout->addWidget(detailsLabel, 50); } else { QTextBrowser *detailTextEdit = new QTextBrowser(); detailTextEdit->setText(details); detailTextEdit->setReadOnly(true); detailTextEdit->setMinimumHeight(detailTextEdit->fontMetrics().lineSpacing() * 11); detailsLayout->addWidget(detailTextEdit, 50); } if (!usingListWidget) { mainLayout->setStretchFactor(hLayout, 10); } detailsHLayout->addWidget(detailsGroup); topLayout->addLayout(detailsHLayout); buttonsHelper->setDetailsWidget(detailsGroup); } topLayout->addWidget(buttons); topLayout->setSizeConstraint(QLayout::SetFixedSize); if (!usingListWidget && !usingScrollArea && !usingSqueezedTextLabel && details.isEmpty()) { dialog->setFixedSize(dialog->sizeHint() + QSize(10, 10)); } if ((options & KMessageBox::Dangerous)) { QPushButton *cancelButton = buttons->button(QDialogButtonBox::Cancel); QPushButton *noButton = buttons->button(QDialogButtonBox::No); if (cancelButton && cancelButton->isEnabled()) { cancelButton->setDefault(true); cancelButton->setFocus(); } else if (noButton && noButton->isEnabled()) { noButton->setDefault(true); noButton->setFocus(); } } #ifndef Q_OS_WIN // FIXME problems with KNotify on Windows if ((options & KMessageBox::Notify)) { QString message = text; if (!strlist.isEmpty()) { message += QLatin1Char('\n') + strlist.join(QLatin1Char('\n')); } notifyInterface()->sendNotification(notifyType, message, dialog->topLevelWidget()); } #endif if (KMessageBox_exec_hook) { return KMessageBox_exec_hook(dialog); } if ((options & KMessageBox::NoExec)) { return QDialogButtonBox::NoButton; // We have to return something. } // We use a QPointer because the dialog may get deleted // during exec() if the parent of the dialog gets deleted. // In that case the QPointer will reset to 0. QPointer guardedDialog = dialog; const QDialogButtonBox::StandardButton result = QDialogButtonBox::StandardButton(guardedDialog->exec()); if (checkbox && checkboxReturn) { *checkboxReturn = checkbox->isChecked(); } delete guardedDialog; return result; } ButtonCode questionYesNo(QWidget *parent, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return questionYesNoList(parent, text, QStringList(), caption, buttonYes, buttonNo, dontAskAgainName, options); } bool shouldBeShownYesNo(const QString &dontShowAgainName, ButtonCode &result) { if (dontShowAgainName.isEmpty()) { return true; } return dontAskAgainInterface()->shouldBeShownYesNo(dontShowAgainName, result); } bool shouldBeShownContinue(const QString &dontShowAgainName) { if (dontShowAgainName.isEmpty()) { return true; } return dontAskAgainInterface()->shouldBeShownContinue(dontShowAgainName); } void saveDontShowAgainYesNo(const QString &dontShowAgainName, ButtonCode result) { if (dontShowAgainName.isEmpty()) { return; } dontAskAgainInterface()->saveDontShowAgainYesNo(dontShowAgainName, result); } void saveDontShowAgainContinue(const QString &dontShowAgainName) { if (dontShowAgainName.isEmpty()) { return; } dontAskAgainInterface()->saveDontShowAgainContinue(dontShowAgainName); } void enableAllMessages() { dontAskAgainInterface()->enableAllMessages(); } void enableMessage(const QString &dontShowAgainName) { dontAskAgainInterface()->enableMessage(dontShowAgainName); } void setDontShowAgainConfig(KConfig *cfg) { dontAskAgainInterface()->setConfig(cfg); } static ButtonCode questionYesNoListInternal(QDialog *dialog, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes_, const KGuiItem &buttonNo_, const QString &dontAskAgainName, Options options) { ButtonCode res; if (!shouldBeShownYesNo(dontAskAgainName, res)) { delete dialog; return res; } I18N_FILTER_BUTTON_YES(buttonYes_, buttonYes) I18N_FILTER_BUTTON_NO(buttonNo_, buttonNo) I18N_POST_BUTTON_FILTER dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Question") : caption); dialog->setObjectName(QStringLiteral("questionYesNo")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), buttonYes); KGuiItem::assign(buttonBox->button(QDialogButtonBox::No), buttonNo); applyOptions(dialog, options); bool checkboxResult = false; const int result = createKMessageBox(dialog, buttonBox, QMessageBox::Question, text, strlist, dontAskAgainName.isEmpty() ? QString() : QApplication::translate("KMessageBox", "Do not ask again"), &checkboxResult, options); res = (result == QDialogButtonBox::Yes ? Yes : No); if (checkboxResult) { saveDontShowAgainYesNo(dontAskAgainName, res); } return res; } ButtonCode questionYesNoList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return questionYesNoListInternal(new QDialog(parent), text, strlist, caption, buttonYes, buttonNo, dontAskAgainName, options); } static ButtonCode questionYesNoCancelInternal(QDialog *dialog, const QString &text, const QString &caption, const KGuiItem &buttonYes_, const KGuiItem &buttonNo_, const KGuiItem &buttonCancel_, const QString &dontAskAgainName, Options options) { ButtonCode res; if (!shouldBeShownYesNo(dontAskAgainName, res)) { delete dialog; return res; } I18N_FILTER_BUTTON_YES(buttonYes_, buttonYes) I18N_FILTER_BUTTON_NO(buttonNo_, buttonNo) I18N_FILTER_BUTTON_CANCEL(buttonCancel_, buttonCancel) I18N_POST_BUTTON_FILTER dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Question") : caption); dialog->setObjectName(QStringLiteral("questionYesNoCancel")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), buttonYes); KGuiItem::assign(buttonBox->button(QDialogButtonBox::No), buttonNo); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), buttonCancel); applyOptions(dialog, options); bool checkboxResult = false; const int result = createKMessageBox(dialog, buttonBox, QMessageBox::Question, text, QStringList(), dontAskAgainName.isEmpty() ? QString() : QApplication::translate("KMessageBox", "Do not ask again"), &checkboxResult, options); if (result == QDialogButtonBox::Yes) { res = Yes; } else if (result == QDialogButtonBox::No) { res = No; } else { return Cancel; } if (checkboxResult) { saveDontShowAgainYesNo(dontAskAgainName, res); } return res; } ButtonCode questionYesNoCancel(QWidget *parent, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return questionYesNoCancelInternal(new QDialog(parent), text, caption, buttonYes, buttonNo, buttonCancel, dontAskAgainName, options); } ButtonCode warningYesNo(QWidget *parent, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return warningYesNoList(parent, text, QStringList(), caption, buttonYes, buttonNo, dontAskAgainName, options); } static ButtonCode warningYesNoListInternal(QDialog *dialog, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes_, const KGuiItem &buttonNo_, const QString &dontAskAgainName, Options options) { ButtonCode res; if (!shouldBeShownYesNo(dontAskAgainName, res)) { delete dialog; return res; } I18N_FILTER_BUTTON_YES(buttonYes_, buttonYes) I18N_FILTER_BUTTON_NO(buttonNo_, buttonNo) I18N_POST_BUTTON_FILTER dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Warning") : caption); dialog->setObjectName(QStringLiteral("warningYesNoList")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), buttonYes); KGuiItem::assign(buttonBox->button(QDialogButtonBox::No), buttonNo); applyOptions(dialog, options); bool checkboxResult = false; const int result = createKMessageBox(dialog, buttonBox, QMessageBox::Warning, text, strlist, dontAskAgainName.isEmpty() ? QString() : QApplication::translate("KMessageBox", "Do not ask again"), &checkboxResult, options); res = (result == QDialogButtonBox::Yes ? Yes : No); if (checkboxResult) { saveDontShowAgainYesNo(dontAskAgainName, res); } return res; } ButtonCode warningYesNoList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return warningYesNoListInternal(new QDialog(parent), text, strlist, caption, buttonYes, buttonNo, dontAskAgainName, options); } ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &caption, const KGuiItem &buttonContinue, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningContinueCancelList(parent, text, QStringList(), caption, buttonContinue, buttonCancel, dontAskAgainName, options); } static ButtonCode warningContinueCancelListInternal(QDialog *dialog, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonContinue_, const KGuiItem &buttonCancel_, const QString &dontAskAgainName, Options options, const QString &details) { if (!shouldBeShownContinue(dontAskAgainName)) { delete dialog; return Continue; } I18N_FILTER_BUTTON_CONTINUE(buttonContinue_, buttonContinue) I18N_FILTER_BUTTON_CANCEL(buttonCancel_, buttonCancel) I18N_POST_BUTTON_FILTER dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Warning") : caption); dialog->setObjectName(QStringLiteral("warningYesNo")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), buttonContinue); KGuiItem::assign(buttonBox->button(QDialogButtonBox::No), buttonCancel); applyOptions(dialog, options); bool checkboxResult = false; const int result = createKMessageBox(dialog, buttonBox, QMessageBox::Warning, text, strlist, dontAskAgainName.isEmpty() ? QString() : QApplication::translate("KMessageBox", "Do not ask again"), &checkboxResult, options, details); if (result != QDialogButtonBox::Yes) { return Cancel; } if (checkboxResult) { saveDontShowAgainContinue(dontAskAgainName); } return Continue; } ButtonCode warningContinueCancelList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonContinue, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningContinueCancelListInternal(new QDialog(parent), text, strlist, caption, buttonContinue, buttonCancel, dontAskAgainName, options, QString()); } ButtonCode warningContinueCancelDetailed(QWidget *parent, const QString &text, const QString &caption, const KGuiItem &buttonContinue, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options, const QString &details) { return warningContinueCancelListInternal(new QDialog(parent), text, QStringList(), caption, buttonContinue, buttonCancel, dontAskAgainName, options, details); } ButtonCode warningYesNoCancel(QWidget *parent, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningYesNoCancelList(parent, text, QStringList(), caption, buttonYes, buttonNo, buttonCancel, dontAskAgainName, options); } static ButtonCode warningYesNoCancelListInternal(QDialog *dialog, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes_, const KGuiItem &buttonNo_, const KGuiItem &buttonCancel_, const QString &dontAskAgainName, Options options) { ButtonCode res; if (!shouldBeShownYesNo(dontAskAgainName, res)) { delete dialog; return res; } I18N_FILTER_BUTTON_YES(buttonYes_, buttonYes) I18N_FILTER_BUTTON_NO(buttonNo_, buttonNo) I18N_FILTER_BUTTON_CANCEL(buttonCancel_, buttonCancel) I18N_POST_BUTTON_FILTER dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Warning") : caption); dialog->setObjectName(QStringLiteral("warningYesNoCancel")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), buttonYes); KGuiItem::assign(buttonBox->button(QDialogButtonBox::No), buttonNo); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), buttonCancel); applyOptions(dialog, options); bool checkboxResult = false; const int result = createKMessageBox(dialog, buttonBox, QMessageBox::Warning, text, strlist, dontAskAgainName.isEmpty() ? QString() : QApplication::translate("KMessageBox", "Do not ask again"), &checkboxResult, options); if (result == QDialogButtonBox::Yes) { res = Yes; } else if (result == QDialogButtonBox::No) { res = No; } else { return Cancel; } if (checkboxResult) { saveDontShowAgainYesNo(dontAskAgainName, res); } return res; } ButtonCode warningYesNoCancelList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningYesNoCancelListInternal(new QDialog(parent), text, strlist, caption, buttonYes, buttonNo, buttonCancel, dontAskAgainName, options); } void error(QWidget *parent, const QString &text, const QString &caption, Options options) { errorList(parent, text, QStringList(), caption, options); } static void errorListInternal(QDialog *dialog, const QString &text, const QStringList &strlist, const QString &caption, Options options) { dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Error") : caption); dialog->setObjectName(QStringLiteral("error")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Ok); applyOptions(dialog, options); createKMessageBox(dialog, buttonBox, QMessageBox::Critical, text, strlist, QString(), nullptr, options); } void errorList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption, Options options) { errorListInternal(new QDialog(parent), text, strlist, caption, options); } static void detailedErrorInternal(QDialog *dialog, const QString &text, const QString &details, const QString &caption, Options options) { dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Error") : caption); dialog->setObjectName(QStringLiteral("error")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->addButton(QDialogButtonBox::Ok); buttonBox->button(QDialogButtonBox::Ok)->setFocus(); applyOptions(dialog, options); createKMessageBox(dialog, buttonBox, QMessageBox::Critical, text, QStringList(), QString(), nullptr, options, details); } void detailedError(QWidget *parent, const QString &text, const QString &details, const QString &caption, Options options) { detailedErrorInternal(new QDialog(parent), text, details, caption, options); } static void sorryInternal(QDialog *dialog, const QString &text, - const QString &caption, Options options) + const QString &caption, + const KGuiItem &buttonOk_, + Options options) { + I18N_FILTER_BUTTON_YES(buttonOk_, buttonOk) + I18N_POST_BUTTON_FILTER + dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Sorry") : caption); dialog->setObjectName(QStringLiteral("sorry")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Ok); + KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), buttonOk); applyOptions(dialog, options); createKMessageBox(dialog, buttonBox, QMessageBox::Warning, text, QStringList(), QString(), nullptr, options); } void sorry(QWidget *parent, const QString &text, const QString &caption, Options options) { - sorryInternal(new QDialog(parent), text, caption, options); + sorryInternal(new QDialog(parent), text, caption, KStandardGuiItem::ok(), options); +} + +void sorry(QWidget *parent, const QString &text, + const QString &caption, const KGuiItem &item, Options options) +{ + sorryInternal(new QDialog(parent), text, caption, item, options); } static void detailedSorryInternal(QDialog *dialog, const QString &text, const QString &details, - const QString &caption, Options options) + const QString &caption, + const KGuiItem &buttonOk_, + Options options) { + I18N_FILTER_BUTTON_YES(buttonOk_, buttonOk) + I18N_POST_BUTTON_FILTER + dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Sorry") : caption); dialog->setObjectName(QStringLiteral("sorry")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->addButton(QDialogButtonBox::Ok); buttonBox->button(QDialogButtonBox::Ok)->setFocus(); + KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), buttonOk); applyOptions(dialog, options); createKMessageBox(dialog, buttonBox, QMessageBox::Warning, text, QStringList(), QString(), nullptr, options, details); } void detailedSorry(QWidget *parent, const QString &text, const QString &details, const QString &caption, Options options) { - detailedSorryInternal(new QDialog(parent), text, details, caption, options); + detailedSorryInternal(new QDialog(parent), text, details, caption, KStandardGuiItem::ok(), options); +} + +void detailedSorry(QWidget *parent, const QString &text, + const QString &details, + const QString &caption, + const KGuiItem &buttonOk, + Options options) +{ + detailedSorryInternal(new QDialog(parent), text, details, caption, buttonOk, options); } void information(QWidget *parent, const QString &text, const QString &caption, const QString &dontShowAgainName, Options options) { informationList(parent, text, QStringList(), caption, dontShowAgainName, options); } static void informationListInternal(QDialog *dialog, const QString &text, const QStringList &strlist, const QString &caption, const QString &dontShowAgainName, Options options) { if (!shouldBeShownContinue(dontShowAgainName)) { delete dialog; return; } dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Information") : caption); dialog->setObjectName(QStringLiteral("information")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Ok); applyOptions(dialog, options); bool checkboxResult = false; createKMessageBox(dialog, buttonBox, QMessageBox::Information, text, strlist, dontShowAgainName.isEmpty() ? QString() : QApplication::translate("KMessageBox", "Do not show this message again"), &checkboxResult, options); if (checkboxResult) { saveDontShowAgainContinue(dontShowAgainName); } } void informationList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption, const QString &dontShowAgainName, Options options) { informationListInternal(new QDialog(parent), text, strlist, caption, dontShowAgainName, options); } void about(QWidget *parent, const QString &text, const QString &caption, Options options) { QDialog *dialog = new QDialog(parent, Qt::Dialog); if (!caption.isEmpty()) { dialog->setWindowTitle(caption); } dialog->setObjectName(QStringLiteral("about")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Ok); applyOptions(dialog, options); if (qApp->windowIcon().isNull()) { QPixmap ret = QMessageBox::standardIcon(QMessageBox::Information); dialog->setWindowIcon(ret); } createKMessageBox(dialog, buttonBox, qApp->windowIcon(), text, QStringList(), QString(), nullptr, options); } static ButtonCode messageBoxInternal(QDialog *dialog, DialogType type, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontShow, Options options) { switch (type) { case QuestionYesNo: return questionYesNoListInternal(dialog, text, QStringList(), caption, buttonYes, buttonNo, dontShow, options); case QuestionYesNoCancel: return questionYesNoCancelInternal(dialog, text, caption, buttonYes, buttonNo, buttonCancel, dontShow, options); case WarningYesNo: return warningYesNoListInternal(dialog, text, QStringList(), caption, buttonYes, buttonNo, dontShow, options); case WarningContinueCancel: return warningContinueCancelListInternal(dialog, text, QStringList(), caption, KGuiItem(buttonYes.text()), buttonCancel, dontShow, options, QString()); case WarningYesNoCancel: return warningYesNoCancelListInternal(dialog, text, QStringList(), caption, buttonYes, buttonNo, buttonCancel, dontShow, options); case Information: informationListInternal(dialog, text, QStringList(), caption, dontShow, options); return KMessageBox::Ok; case Error: errorListInternal(dialog, text, QStringList(), caption, options); return KMessageBox::Ok; case Sorry: - sorryInternal(dialog, text, caption, options); + sorryInternal(dialog, text, caption, KStandardGuiItem::ok(), options); return KMessageBox::Ok; } return KMessageBox::Cancel; } ButtonCode messageBox(QWidget *parent, DialogType type, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontShow, Options options) { return messageBoxInternal(new QDialog(parent), type, text, caption, buttonYes, buttonNo, buttonCancel, dontShow, options); } ButtonCode questionYesNoWId(WId parent_id, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return questionYesNoListWId(parent_id, text, QStringList(), caption, buttonYes, buttonNo, dontAskAgainName, options); } ButtonCode questionYesNoListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return questionYesNoListInternal(createWIdDialog(parent_id), text, strlist, caption, buttonYes, buttonNo, dontAskAgainName, options); } ButtonCode questionYesNoCancelWId(WId parent_id, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return questionYesNoCancelInternal(createWIdDialog(parent_id), text, caption, buttonYes, buttonNo, buttonCancel, dontAskAgainName, options); } ButtonCode warningYesNoWId(WId parent_id, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return warningYesNoListWId(parent_id, text, QStringList(), caption, buttonYes, buttonNo, dontAskAgainName, options); } ButtonCode warningYesNoListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const QString &dontAskAgainName, Options options) { return warningYesNoListInternal(createWIdDialog(parent_id), text, strlist, caption, buttonYes, buttonNo, dontAskAgainName, options); } ButtonCode warningContinueCancelWId(WId parent_id, const QString &text, const QString &caption, const KGuiItem &buttonContinue, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningContinueCancelListWId(parent_id, text, QStringList(), caption, buttonContinue, buttonCancel, dontAskAgainName, options); } ButtonCode warningContinueCancelListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonContinue, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningContinueCancelListInternal(createWIdDialog(parent_id), text, strlist, caption, buttonContinue, buttonCancel, dontAskAgainName, options, QString()); } ButtonCode warningYesNoCancelWId(WId parent_id, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningYesNoCancelListWId(parent_id, text, QStringList(), caption, buttonYes, buttonNo, buttonCancel, dontAskAgainName, options); } ButtonCode warningYesNoCancelListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontAskAgainName, Options options) { return warningYesNoCancelList(createWIdDialog(parent_id), text, strlist, caption, buttonYes, buttonNo, buttonCancel, dontAskAgainName, options); } void errorWId(WId parent_id, const QString &text, const QString &caption, Options options) { errorListWId(parent_id, text, QStringList(), caption, options); } void errorListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption, Options options) { errorListInternal(createWIdDialog(parent_id), text, strlist, caption, options); } void detailedErrorWId(WId parent_id, const QString &text, const QString &details, const QString &caption, Options options) { detailedErrorInternal(createWIdDialog(parent_id), text, details, caption, options); } void sorryWId(WId parent_id, const QString &text, const QString &caption, Options options) { QWidget *parent = QWidget::find(parent_id); QDialog *dialog = new QDialog(parent, Qt::Dialog); dialog->setWindowTitle(caption.isEmpty() ? QApplication::translate("KMessageBox", "Sorry") : caption); dialog->setObjectName(QStringLiteral("sorry")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Ok); applyOptions(dialog, options); if (parent == nullptr && parent_id) { setMainWindow(dialog, parent_id); } createKMessageBox(dialog, buttonBox, QMessageBox::Warning, text, QStringList(), QString(), nullptr, options); } void detailedSorryWId(WId parent_id, const QString &text, const QString &details, const QString &caption, Options options) { - detailedSorryInternal(createWIdDialog(parent_id), text, details, caption, options); + detailedSorryInternal(createWIdDialog(parent_id), text, details, caption, KStandardGuiItem::ok(), options); +} + +void detailedSorryWId(WId parent_id, const QString &text, + const QString &details, + const QString &caption, + const KGuiItem &buttonOk, + Options options) +{ + detailedSorryInternal(createWIdDialog(parent_id), text, details, caption, buttonOk, options); } void informationWId(WId parent_id, const QString &text, const QString &caption, const QString &dontShowAgainName, Options options) { informationListWId(parent_id, text, QStringList(), caption, dontShowAgainName, options); } void informationListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption, const QString &dontShowAgainName, Options options) { informationListInternal(createWIdDialog(parent_id), text, strlist, caption, dontShowAgainName, options); } ButtonCode messageBoxWId(WId parent_id, DialogType type, const QString &text, const QString &caption, const KGuiItem &buttonYes, const KGuiItem &buttonNo, const KGuiItem &buttonCancel, const QString &dontShow, Options options) { return messageBoxInternal(createWIdDialog(parent_id), type, text, caption, buttonYes, buttonNo, buttonCancel, dontShow, options); } } // namespace #include "kmessagebox.moc" diff --git a/src/kmessagebox.h b/src/kmessagebox.h index bc155ed..428f431 100644 --- a/src/kmessagebox.h +++ b/src/kmessagebox.h @@ -1,1076 +1,1162 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Waldo Bastian (bastian@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //krazy:excludeall=dpointer #ifndef KMESSAGEBOX_H #define KMESSAGEBOX_H #include #include #include #include #include class KMessageBoxDontAskAgainInterface; class KMessageBoxNotifyInterface; class QDialog; class QDialogButtonBox; class QWidget; class QStringList; class KConfig; /** * Easy message dialog box. * * Provides convenience functions for some i18n'ed standard dialogs, * as well as audible notification via @ref KNotification * * The text in message boxes is wrapped automatically. The text may either * be plaintext or richtext. If the text is plaintext, a newline-character * may be used to indicate the end of a paragraph. * * \image html kmessagebox.png "KMessageBox (using questionYesNo())" * * @author Waldo Bastian (bastian@kde.org) */ namespace KMessageBox { /** * Button types. **/ enum ButtonCode { Ok = 1, Cancel = 2, Yes = 3, No = 4, Continue = 5 }; enum DialogType { QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4, Information = 5, // Reserved for: SSLMessageBox = 6 Sorry = 7, Error = 8, QuestionYesNoCancel = 9 }; enum Option { Notify = 1, ///< Emit a KNotify event AllowLink = 2, ///< The message may contain links. Dangerous = 4, ///< The action to be confirmed by the dialog is a potentially destructive one. The default button will be set to Cancel or No, depending on which is available. PlainCaption = 8, ///< Do not use KApplication::makeStdCaption() NoExec = 16, ///< Do not call exec() in createKMessageBox() WindowModal = 32 ///< The window is to be modal relative to its parent. By default, it is application modal. }; Q_DECLARE_FLAGS(Options, Option) } // namespace // This declaration must be defined before first Option is used in method signatures AND outside the namespace Q_DECLARE_OPERATORS_FOR_FLAGS(KMessageBox::Options) namespace KMessageBox { /** * Display a simple "question" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Question"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Option * * @return 'Yes' is returned if the Yes-button is pressed. 'No' is returned * if the No-button is pressed. * * To be used for questions like "Do you have a printer?" * * The default button is "Yes". Pressing "Esc" selects "No". */ KWIDGETSADDONS_EXPORT ButtonCode questionYesNo(QWidget *parent, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display a simple "question" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Question"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param buttonCancel The text for the third button. * The default is KStandardGuiItem::cancel(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return 'Yes' is returned if the Yes-button is pressed. 'No' is returned * if the No-button is pressed. * * To be used for questions like "Do you want to discard the message or save it for later?", * * The default button is "Yes". Pressing "Esc" selects "Cancel". */ KWIDGETSADDONS_EXPORT ButtonCode questionYesNoCancel(QWidget *parent, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display a "question" dialog with a listbox to show information to the user * * @param parent Parent widget. * @param text Message string. * @param strlist List of strings to be written in the listbox. If the list is * empty, it doesn't show any listbox, working as questionYesNo. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Question"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return 'Yes' is returned if the Yes-button is pressed. 'No' is returned * if the No-button is pressed. * * To be used for questions like "Do you really want to delete these files?" * And show the user exactly which files are going to be deleted in case * he presses "Yes" * * The default button is "Yes". Pressing "Esc" selects "No". */ KWIDGETSADDONS_EXPORT ButtonCode questionYesNoList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display a "warning" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Warning"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return @p Yes is returned if the Yes-button is pressed. @p No is returned * if the No-button is pressed. * * To be used for questions "Shall I update your configuration?" * The text should explain the implication of both options. * * The default button is "No". Pressing "Esc" selects "No". */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNo(QWidget *parent, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous)); /** * Display a "warning" dialog with a listbox to show information to the user * * @param parent Parent widget. * @param text Message string. * @param strlist List of strings to be written in the listbox. If the list is * empty, it doesn't show any listbox, working as questionYesNo. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Question"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return 'Yes' is returned if the Yes-button is pressed. 'No' is returned * if the No-button is pressed. * * To be used for questions like "Do you really want to delete these files?" * And show the user exactly which files are going to be deleted in case * he presses "Yes" * * The default button is "No". Pressing "Esc" selects "No". */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous)); /** * Display a "warning" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Warning"). * @param buttonContinue The text for the first button. * The default is KStandardGuiItem::cont(). * @param buttonCancel The text for the second button. * The default is KStandardGuiItem::cancel(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return @p Continue is returned if the Continue-button is pressed. * @p Cancel is returned if the Cancel-button is pressed. * * To be used for questions like "You are about to Print. Are you sure?" * the continueButton should then be labeled "Print". * * The default button is buttonContinue. Pressing "Esc" selects "Cancel". */ KWIDGETSADDONS_EXPORT ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &caption = QString(), const KGuiItem &buttonContinue = KStandardGuiItem::cont(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display a "warning" dialog with a collapsible "Details" section. * * @since 5.61 */ KWIDGETSADDONS_EXPORT ButtonCode warningContinueCancelDetailed(QWidget *parent, const QString &text, const QString &caption = QString(), const KGuiItem &buttonContinue = KStandardGuiItem::cont(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify, const QString &details = QString()); /** * Display a "warning" dialog with a listbox to show information to the user. * * @param parent Parent widget. * @param text Message string. * @param strlist List of strings to be written in the listbox. If the * list is empty, it doesn't show any listbox, working * as warningContinueCancel. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Warning"). * @param buttonContinue The text for the first button. * The default is KStandardGuiItem::cont(). * @param buttonCancel The text for the second button. * The default is KStandardGuiItem::cancel(). * @param dontAskAgainName If provided, a checkbox is added with which * further confirmation can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * * @param options see Options * * @return @p Continue is returned if the Continue-button is pressed. * @p Cancel is returned if the Cancel-button is pressed. * * To be used for questions like "You are about to Print. Are you sure?" * the continueButton should then be labeled "Print". * * The default button is buttonContinue. Pressing "Esc" selects "Cancel". */ KWIDGETSADDONS_EXPORT ButtonCode warningContinueCancelList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonContinue = KStandardGuiItem::cont(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display a Yes/No/Cancel "warning" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Warning"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param buttonCancel The text for the third button. * The default is KStandardGuiItem::cancel(). * @param dontAskAgainName If provided, a checkbox is added with which * further questions can be turned off. If turned off * all questions will be automatically answered with the * last answer (either Yes or No). * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return @p Yes is returned if the Yes-button is pressed. @p No is returned * if the No-button is pressed. @p Cancel is retunred if the Cancel- * button is pressed. * * To be used for questions "Do you want to save your changes?" * The text should explain the implication of choosing 'No'. * * The default button is "Yes". Pressing "Esc" selects "Cancel" */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoCancel(QWidget *parent, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display a Yes/No/Cancel "warning" dialog with a listbox to show information * to the user. * * @param parent Parent widget. * @param text Message string. * @param strlist List of strings to be written in the listbox. If the * list is empty, it doesn't show any listbox, working * as warningYesNoCancel. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Warning"). * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param buttonCancel The text for the third button. * The default is KStandardGuiItem::cancel(). * @param dontAskAgainName If provided, a checkbox is added with which * further questions can be turned off. If turned off * all questions will be automatically answered with the * last answer (either Yes or No). * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * If @p dontAskAgainName starts with a ':' then the setting * is stored in the global config file. * @param options see Options * * @return @p Yes is returned if the Yes-button is pressed. @p No is returned * if the No-button is pressed. @p Cancel is retunred if the Cancel- * button is pressed. * * To be used for questions "Do you want to save your changes?" * The text should explain the implication of choosing 'No'. * * The default button is "Yes". Pressing "Esc" selects "Cancel" */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoCancelList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * Display an "Error" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Error"). * @param options see Options * * Your program messed up and now it's time to inform the user. * To be used for important things like "Sorry, I deleted your hard disk." * * If your program detects the action specified by the user is somehow * not allowed, this should never be reported with error(). Use sorry() * instead to explain to the user that this action is not allowed. * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The OK button will always have the i18n'ed text '&OK'. */ KWIDGETSADDONS_EXPORT void error(QWidget *parent, const QString &text, const QString &caption = QString(), Options options = Notify); /** * Display an "Error" dialog with a listbox. * * @param parent Parent widget. * @param text Message string. * @param strlist List of strings to be written in the listbox. If the * list is empty, it doesn't show any listbox, working * as error(). * @param caption Message box title. The application name is added to * the title. The default title is i18n("Error"). * @param options see Options * * Your program messed up and now it's time to inform the user. * To be used for important things like "Sorry, I deleted your hard disk." * * If your program detects the action specified by the user is somehow * not allowed, this should never be reported with error(). Use sorry() * instead to explain to the user that this action is not allowed. * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The OK button will always have the i18n'ed text '&OK'. */ KWIDGETSADDONS_EXPORT void errorList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString(), Options options = Notify); /** * Displays an "Error" dialog with a "Details >>" button. * * @param parent Parent widget. * @param text Message string. * @param details Detailed message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Error"). * @param options see Options * * Your program messed up and now it's time to inform the user. * To be used for important things like "Sorry, I deleted your hard disk." * * The @p details message can contain additional information about * the problem and can be shown on request to advanced/interested users. * * If your program detects the action specified by the user is somehow * not allowed, this should never be reported with error(). Use sorry() * instead to explain to the user that this action is not allowed. * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The OK button will always have the i18n'ed text '&OK'. */ KWIDGETSADDONS_EXPORT void detailedError(QWidget *parent, const QString &text, const QString &details, const QString &caption = QString(), Options options = Notify); /** * Display a "Sorry" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Sorry"). * @param options see OptionsType * * Either your program messed up and asks for understanding * or your user did something stupid. * * To be used for small problems like * "Sorry, I can't find the file you specified." * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The ok button will always have the i18n'ed text '&OK'. + * See the overload with a KGuiItem argument to change that. */ - KWIDGETSADDONS_EXPORT void sorry(QWidget *parent, const QString &text, const QString &caption = QString(), Options options = Notify); +/** + * Display a "Sorry" dialog. + * + * @param parent Parent widget. + * @param text Message string. + * @param caption Message box title. The application name is added to + * the title. The default title is i18n("Sorry"). + * @param buttonOk The text for the only button. + * The default is KStandardGuiItem::ok(). + * @param options see OptionsType + * + * Either your program messed up and asks for understanding + * or your user did something stupid. + * + * To be used for small problems like + * "Sorry, I can't find the file you specified." + * + * The default button is "&OK". Pressing "Esc" selects the OK-button. + * + * There is only one button, therefore it's the default button, and pressing "Esc" selects it as well. + * @since 5.63 + */ +KWIDGETSADDONS_EXPORT void sorry(QWidget *parent, + const QString &text, + const QString &caption /*= QString()*/, + const KGuiItem &buttonOk /*= KStandardGuiItem::ok()*/, + Options options = Notify); // TODO KF6 merge with previous overload + /** * Displays a "Sorry" dialog with a "Details >>" button. * * @param parent Parent widget. * @param text Message string. * @param details Detailed message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Sorry"). * @param options see Options * * Either your program messed up and asks for understanding * or your user did something stupid. * * To be used for small problems like * "Sorry, I can't find the file you specified." * * And then @p details can contain something like * "foobar.txt was not found in any of * the following directories: * /usr/bin,/usr/local/bin,/usr/sbin" * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The ok button will always have the i18n'ed text '&OK'. + * See the overload with a KGuiItem argument to change that. */ KWIDGETSADDONS_EXPORT void detailedSorry(QWidget *parent, const QString &text, const QString &details, const QString &caption = QString(), Options options = Notify); +/** + * Displays a "Sorry" dialog with a "Details >>" button. + * + * @param parent Parent widget. + * @param text Message string. + * @param details Detailed message string. + * @param caption Message box title. The application name is added to + * the title. The default title is i18n("Sorry"). + * @param buttonOk The text for the only button. + * The default is KStandardGuiItem::ok(). + * @param options see Options + * + * Either your program messed up and asks for understanding + * or your user did something stupid. + * + * To be used for small problems like + * "Sorry, I can't find the file you specified." + * + * And then @p details can contain something like + * "foobar.txt was not found in any of + * the following directories: + * /usr/bin,/usr/local/bin,/usr/sbin" + * + * There is only one button, therefore it's the default button, and pressing "Esc" selects it as well. + * @since 5.63 + */ + +KWIDGETSADDONS_EXPORT void detailedSorry(QWidget *parent, + const QString &text, + const QString &details, + const QString &caption /* = QString() */, + const KGuiItem &buttonOk /*= KStandardGuiItem::ok()*/, + Options options = Notify); // TODO KF6: merge with previous overload + /** * Display an "Information" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Information"). * @param dontShowAgainName If provided, a checkbox is added with which * further notifications can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * @param options see Options * * * Your program wants to tell the user something. * To be used for things like: * "Your bookmarks have been rearranged." * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The OK button will always have the i18n'ed text '&OK'. */ KWIDGETSADDONS_EXPORT void information(QWidget *parent, const QString &text, const QString &caption = QString(), const QString &dontShowAgainName = QString(), Options options = Notify); /** * Display an "Information" dialog with a listbox. * * @param parent Parent widget. * @param text Message string. * @param strlist List of strings to be written in the listbox. If the * list is empty, it doesn't show any listbox, working * as information. * @param caption Message box title. The application name is added to * the title. The default title is i18n("Information"). * @param dontShowAgainName If provided, a checkbox is added with which * further notifications can be turned off. * The string is used to lookup and store the setting * in the applications config file. * The setting is stored in the "Notification Messages" group. * @param options see Options * * * Your program wants to tell the user something. * To be used for things like: * "The following bookmarks have been rearranged:" * * The default button is "&OK". Pressing "Esc" selects the OK-button. * * NOTE: The OK button will always have the i18n'ed text '&OK'. */ KWIDGETSADDONS_EXPORT void informationList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString(), const QString &dontShowAgainName = QString(), Options options = Notify); /** * Enable all messages which have been turned off with the * @p dontShowAgainName feature. */ KWIDGETSADDONS_EXPORT void enableAllMessages(); /** * Re-enable a specific @p dontShowAgainName messages that had * previously been turned off. * @see saveDontShowAgainYesNo() * @see saveDontShowAgainContinue() */ KWIDGETSADDONS_EXPORT void enableMessage(const QString &dontShowAgainName); /** * Display an "About" dialog. * * @param parent Parent widget. * @param text Message string. * @param caption Message box title. The application name is added to * the title. The default title is i18n("About \"). * @param options see Options * * * Your program wants to show some general information about the application * like the authors's names and email addresses. * * The default button is "&OK". * * NOTE: The ok button will always have the i18n'ed text '&OK'. */ KWIDGETSADDONS_EXPORT void about(QWidget *parent, const QString &text, const QString &caption = QString(), Options options = Notify); /** * Alternate method to show a messagebox: * * @param parent Parent widget. * @param type type of message box: QuestionYesNo, WarningYesNo, WarningContinueCancel... * @param text Message string. * @param caption Message box title. * @param buttonYes The text for the first button. * The default is KStandardGuiItem::yes(). * @param buttonNo The text for the second button. * The default is KStandardGuiItem::no(). * @param buttonCancel The text for the third button. * The default is KStandardGuiItem::cancel(). * @param dontShowAskAgainName If provided, a checkbox is added with which * further questions/information can be turned off. If turned off * all questions will be automatically answered with the * last answer (either Yes or No), if the message box needs an answer. * The string is used to lookup and store the setting * in the applications config file. * @param options see Options * Note: for ContinueCancel, buttonYes is the continue button and buttonNo is unused. * and for Information, none is used. * @return a button code, as defined in KMessageBox. */ KWIDGETSADDONS_EXPORT ButtonCode messageBox(QWidget *parent, DialogType type, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontShowAskAgainName = QString(), Options options = Notify); /** * @return true if the corresponding yes/no message box should be shown. * @param dontShowAgainName the name that identify the message box. If * empty, true is always returned. * @param result is set to the result (Yes or No) that was chosen the last * time the message box was shown. Only meaningful, if the message box * should not be shown. */ KWIDGETSADDONS_EXPORT bool shouldBeShownYesNo(const QString &dontShowAgainName, ButtonCode &result); /** * @return true if the corresponding continue/cancel message box should be * shown. * @param dontShowAgainName the name that identify the message box. If * empty, true is always returned. */ KWIDGETSADDONS_EXPORT bool shouldBeShownContinue(const QString &dontShowAgainName); /** * Save the fact that the yes/no message box should not be shown again. * @param dontShowAgainName the name that identify the message box. If * empty, this method does nothing. * @param result the value (Yes or No) that should be used as the result * for the message box. */ KWIDGETSADDONS_EXPORT void saveDontShowAgainYesNo(const QString &dontShowAgainName, ButtonCode result); /** * Save the fact that the continue/cancel message box should not be shown * again. * @param dontShowAgainName the name that identify the message box. If * empty, this method does nothing. */ KWIDGETSADDONS_EXPORT void saveDontShowAgainContinue(const QString &dontShowAgainName); /** * Use @p cfg for all settings related to the dontShowAgainName feature. * If @p cfg is 0 (default) KGlobal::config() will be used. */ KWIDGETSADDONS_EXPORT void setDontShowAgainConfig(KConfig *cfg); #ifndef KWIDGETSADDONS_NO_DEPRECATED /** * @deprecated since 5.0, use setDontShowAgainConfig() */ KWIDGETSADDONS_DEPRECATED_EXPORT inline void setDontShowAskAgainConfig(KConfig *cfg) { setDontShowAgainConfig(cfg); } #endif /** * Use @p dontAskAgainInterface for all settings related to the donShowAgain feature. * This method does not take ownership of @p dontAskAgainInterface. * * @since 5.0 */ KWIDGETSADDONS_EXPORT void setDontShowAgainInterface(KMessageBoxDontAskAgainInterface *dontAskAgainInterface); /** * Use @p notifyInterface to send notifications. * This method does not take ownership of @p notifyInterface. * * @since 5.0 */ KWIDGETSADDONS_EXPORT void setNotifyInterface(KMessageBoxNotifyInterface *notifyInterface); /** * Create content and layout of a standard dialog * * @param dialog The parent dialog base * @param buttons a QDialogButtonBox instance. This function will take care of connecting to it. * @param icon Which predefined icon the message box shall show. * @param text Message string. * @param strlist List of strings to be written in the listbox. * If the list is empty, it doesn't show any listbox * @param ask The text of the checkbox. If empty none will be shown. * @param checkboxReturn The result of the checkbox. If it's initially * true then the checkbox will be checked by default. * May be a null pointer. * @param options see Options * @param details Detailed message string. * @return A QDialogButtonBox::StandardButton button code, not a KMessageBox * button code, based on the buttonmask given to the constructor of * the @p dialog (ie. will return QDialogButtonBox::Yes instead of * KMessageBox::Yes). Will return QDialogButtonBox::NoButton if the * message box is queued for display instead of exec()ed immediately * or if the option NoExec is set. * @note Unless NoExec is used, * the @p dialog that is passed in is deleted by this * function. Do not delete it yourself. */ KWIDGETSADDONS_EXPORT QDialogButtonBox::StandardButton createKMessageBox(QDialog *dialog, QDialogButtonBox *buttons, QMessageBox::Icon icon, //krazy:exclude=qclasses const QString &text, const QStringList &strlist, const QString &ask, bool *checkboxReturn, Options options, const QString &details = QString()); /** * Create content and layout of a standard dialog * * @param dialog The parent dialog base * @param buttons a QDialogButtonBox instance. This function will take care of connecting to it. * @param icon A QPixmap containing the icon to be displayed in the * dialog next to the text. * @param text Message string. * @param strlist List of strings to be written in the listbox. * If the list is empty, it doesn't show any listbox * @param ask The text of the checkbox. If empty none will be shown. * @param checkboxReturn The result of the checkbox. If it's initially * true then the checkbox will be checked by default. * May be a null pointer. * @param options see Options * @param details Detailed message string. * @param notifyType The type of notification to send when this message * is presentend. * @return A QDialogButtonBox::StandardButton button code, not a KMessageBox * button code, based on the buttonmask given to the constructor of * the @p dialog (ie. will return QDialogButtonBox::Yes instead of * KMessageBox::Yes). Will return QDialogButtonBox::NoButton if the * message box is queued for display instead of exec()ed immediately * or if the option NoExec is set. * @note Unless NoExec is used, * the @p dialog that is passed in is deleted by this * function. Do not delete it yourself. */ KWIDGETSADDONS_EXPORT QDialogButtonBox::StandardButton createKMessageBox(QDialog *dialog, QDialogButtonBox *buttons, const QIcon &icon, const QString &text, const QStringList &strlist, const QString &ask, bool *checkboxReturn, Options options, const QString &details = QString(), QMessageBox::Icon notifyType = QMessageBox::Information); //krazy:exclude=qclasses /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode questionYesNoWId(WId parent_id, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode questionYesNoCancelWId(WId parent_id, const QString &text, - const QString &caption = QString(), + const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode questionYesNoListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoWId(WId parent_id, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous)); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous)); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode warningContinueCancelWId(WId parent_id, const QString &text, const QString &caption = QString(), const KGuiItem &buttonContinue = KStandardGuiItem::cont(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode warningContinueCancelListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonContinue = KStandardGuiItem::cont(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoCancelWId(WId parent_id, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode warningYesNoCancelListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontAskAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void errorWId(WId parent_id, const QString &text, const QString &caption = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void errorListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void detailedErrorWId(WId parent_id, const QString &text, const QString &details, const QString &caption = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void sorryWId(WId parent_id, const QString &text, const QString &caption = QString(), Options options = Notify); +/** + * This function accepts the window id of the parent window, instead + * of QWidget*. It should be used only when necessary. + * @since 5.63 + */ +KWIDGETSADDONS_EXPORT void sorryWId(WId parent_id, + const QString &text, + const QString &caption /*= QString()*/, + const KGuiItem &buttonOk /*= KStandardGuiItem::ok()*/, + Options options = Notify); // TODO KF6 merge with previous overload + /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void detailedSorryWId(WId parent_id, const QString &text, const QString &details, const QString &caption = QString(), Options options = Notify); +/** + * This function accepts the window id of the parent window, instead + * of QWidget*. It should be used only when necessary. + * @since 5.63 + */ +KWIDGETSADDONS_EXPORT void detailedSorryWId(WId parent_id, + const QString &text, + const QString &details, + const QString &caption /*= QString()*/, + const KGuiItem &buttonOk /*= KStandardGuiItem::ok()*/, + Options options = Notify); // TODO KF6 merge with previous overload + /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void informationWId(WId parent_id, const QString &text, const QString &caption = QString(), const QString &dontShowAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT void informationListWId(WId parent_id, const QString &text, const QStringList &strlist, const QString &caption = QString(), const QString &dontShowAgainName = QString(), Options options = Notify); /** * This function accepts the window id of the parent window, instead * of QWidget*. It should be used only when necessary. */ KWIDGETSADDONS_EXPORT ButtonCode messageBoxWId(WId parent_id, DialogType type, const QString &text, const QString &caption = QString(), const KGuiItem &buttonYes = KStandardGuiItem::yes(), const KGuiItem &buttonNo = KStandardGuiItem::no(), const KGuiItem &buttonCancel = KStandardGuiItem::cancel(), const QString &dontShowAskAgainName = QString(), Options options = Notify); } #endif diff --git a/tests/kmessageboxtest.cpp b/tests/kmessageboxtest.cpp index 2e30731..80f88f3 100644 --- a/tests/kmessageboxtest.cpp +++ b/tests/kmessageboxtest.cpp @@ -1,372 +1,372 @@ #undef QT_NO_CAST_FROM_ASCII #include "kmessagebox.h" #include #include #include #include class ExampleWidget : public QLabel { public: ExampleWidget(QWidget *parent = nullptr); }; ExampleWidget::ExampleWidget(QWidget *parent) : QLabel(parent) { // Make the top-level layout; a vertical box to contain all widgets // and sub-layouts. QSize sh; setText(QStringLiteral("

Hello.

")); sh = sizeHint(); qWarning("SizeHint = %d x %d", sh.width(), sh.height()); setText(QStringLiteral("Hello.")); sh = sizeHint(); qWarning("SizeHint = %d x %d", sh.width(), sh.height()); setText(QStringLiteral("

Hello
World

")); sh = sizeHint(); qWarning("SizeHint = %d x %d", sh.width(), sh.height()); // setText("Hello\nWorld"); sh = sizeHint(); qWarning("SizeHint = %d x %d", sh.width(), sh.height()); setMinimumSize(sizeHint()); } void showResult(int test, int i) { printf("Test %d. returned %d ", test, i); switch (i) { case KMessageBox::Ok : printf("(%s)\n", "Ok"); break; case KMessageBox::Cancel : printf("(%s)\n", "Cancel"); break; case KMessageBox::Yes : printf("(%s)\n", "Yes"); break; case KMessageBox::No : printf("(%s)\n", "No"); break; case KMessageBox::Continue : printf("(%s)\n", "Continue"); break; default: printf("(%s)\n", "ERROR!"); exit(1); } } bool testMessageBox(int test) { QStringList list; list.append(QStringLiteral("Hello")); list.append(QStringLiteral("World")); int i; switch (test) { case 1: { ExampleWidget *w = new ExampleWidget(); w->show(); i = KMessageBox::warningContinueCancel(w, QString::fromLatin1("You are about to .\n" "Are you sure?"), QStringLiteral("Print"), KGuiItem(QStringLiteral("&Print")), KStandardGuiItem::cancel(), QStringLiteral("dontask")); i = KMessageBox::warningContinueCancel(nullptr, QString::fromLatin1("You are about to .\n" "Are you sure?"), QStringLiteral("Print"), KGuiItem(QStringLiteral("&Print")), KStandardGuiItem::cancel(), QStringLiteral("dontask"), KMessageBox::AllowLink); i = KMessageBox::questionYesNo(nullptr, QStringLiteral("

Do you have a printer? thisisaverylongdkldhklghklghklashgkllasghkdlsghkldfghklsabla bla bbla bla. It also has this URL.

"), QStringLiteral("Bla"), KGuiItem(QStringLiteral("Yes")), KGuiItem(QStringLiteral("No")), QStringLiteral("bla"), KMessageBox::AllowLink); break; } case 2: i = KMessageBox::questionYesNo(nullptr, QStringLiteral("Do you have a printer?"), QStringLiteral("Printer setup")); break; case 3: i = KMessageBox::questionYesNo(nullptr, QStringLiteral("Does your printer support color or only black and white?"), QStringLiteral("Printer setup"), KGuiItem(QStringLiteral("&Color")), KGuiItem(QLatin1String("&Black & White"))); break; case 4: i = KMessageBox::warningYesNo(nullptr, QString::fromLatin1("KDVI could not locate the program 'dvipdfm' on your computer. That program is " "absolutely needed by the export function. You can, however, convert " "the DVI-file to PDF using the print function of KDVI, but that will often " "produce files which print ok, but are of inferior quality if viewed in the " "Acrobat Reader. It may be wise to upgrade to a more recent version of your " "TeX distribution which includes the 'dvipdfm' program.\n" "Hint to the perplexed system administrator: KDVI uses the shell's PATH variable " "when looking for programs.") ); break; case 5: i = KMessageBox::warningYesNo(nullptr, QString::fromLatin1("Your printer has been added.\n" "Do you want to update your configuration?"), QStringLiteral("Printer Setup")); break; case 6: i = KMessageBox::warningContinueCancel(nullptr, QString::fromLatin1("You are about to print.\n" "Are you sure?"), QStringLiteral("Print"), KGuiItem(QStringLiteral("&Print"))); break; case 7: i = KMessageBox::warningContinueCancel(nullptr, QString::fromLatin1("You are about to .\n" "Are you sure?"), QStringLiteral("Print"), KGuiItem(QStringLiteral("&Print")), KStandardGuiItem::cancel(), QStringLiteral("dontask")); i = KMessageBox::warningContinueCancel(nullptr, QString::fromLatin1("You are about to .\n" "Are you sure?"), QStringLiteral("Print"), KGuiItem(QStringLiteral("&Print")), KStandardGuiItem::cancel(), QStringLiteral("dontask")); break; case 8: i = KMessageBox::warningYesNoCancel(nullptr, QString::fromLatin1("Your document contains unsaved changes.\n" "Do you want to save your changes?\n")); break; case 9: i = KMessageBox::warningYesNoCancel(nullptr, QString::fromLatin1("Your document contains unsaved changes.\n" "Do you want to save your changes?\n"), QStringLiteral("Close")); break; case 10: i = KMessageBox::warningYesNoCancel(nullptr, QString::fromLatin1("Your document contains unsaved changes.\n" "Do you want to save or discard your changes?\n"), QStringLiteral("Close"), KGuiItem(QStringLiteral("&Save")), KGuiItem(QStringLiteral("&Discard"))); break; case 11: i = KMessageBox::Ok; KMessageBox::error(nullptr, QStringLiteral("Oops, Your harddisk is unreadable.")); break; case 12: i = KMessageBox::Ok; KMessageBox::detailedError(nullptr, QStringLiteral("Oops, Your harddisk is unreadable."), QStringLiteral("We don't know more yet."), QStringLiteral("Uh ooh")); break; case 13: i = KMessageBox::Ok; - KMessageBox::sorry(nullptr, QStringLiteral("Sorry, Your harddisk appears to be empty.")); + KMessageBox::sorry(nullptr, QStringLiteral("Sorry, Your harddisk appears to be empty."), QString(), KGuiItem(QStringLiteral("Abort"))); break; case 14: i = KMessageBox::Ok; - KMessageBox::detailedSorry(nullptr, QStringLiteral("Sorry, Your harddisk appears to be empty."), QStringLiteral("We don't know more yet."), QStringLiteral("Oops")); + KMessageBox::detailedSorry(nullptr, QStringLiteral("Sorry, Your harddisk appears to be empty."), QStringLiteral("We don't know more yet."), QStringLiteral("Oops"), KGuiItem(QStringLiteral("Abort"))); break; case 15: i = KMessageBox::Ok; KMessageBox::information(nullptr, QString::fromLatin1("You can enable the menubar again " "with the right mouse button menu.")); break; case 16: i = KMessageBox::Ok; KMessageBox::information(nullptr, QString::fromLatin1("You can enable the menubar again " "with the right mouse button menu."), QStringLiteral("Menubar Info")); break; case 17: i = KMessageBox::Ok; KMessageBox::information(nullptr, QStringLiteral("You can enable the menubar again\nwith the right mouse button menu."), QString(), QStringLiteral("Enable_Menubar")); break; case 18: i = KMessageBox::Ok; KMessageBox::enableAllMessages(); break; case 19: i = KMessageBox::Ok; KMessageBox::information(nullptr, QStringLiteral("Return of the annoying popup message."), QString(), QStringLiteral("Enable_Menubar")); break; case 20: { QStringList strlist; strlist << QStringLiteral("/dev/hda") << QStringLiteral("/etc/inittab") << QStringLiteral("/usr/somefile") << QString::fromLatin1("/some/really/" "long/file/name/which/is/in/a/really/deep/directory/in/a/really/large/" "hard/disk/of/your/system") << QStringLiteral("/and/another/one"); i = KMessageBox::questionYesNoList(nullptr, QStringLiteral("Do you want to delete the following files?"), strlist); } break; case 21: { QStringList strlist; printf("Filling StringList...\n"); for (int j = 1; j <= 6000; j++) { strlist.append(QStringLiteral("/tmp/tmp.%1").arg(j)); } printf("Completed...\n"); i = KMessageBox::questionYesNoList(nullptr, QStringLiteral("Do you want to delete the following files?"), strlist); } break; case 22: i = KMessageBox::Ok; KMessageBox::informationList(nullptr, QStringLiteral("The following words have been found:"), list); break; case 23: i = KMessageBox::Ok; KMessageBox::informationList(nullptr, QStringLiteral("The following words have been found:"), list, QStringLiteral("Search Words")); break; case 24: i = KMessageBox::Ok; KMessageBox::informationList(nullptr, QStringLiteral("The follwoing words have been found:"), list, QString(), QStringLiteral("Search_Words")); break; case 25: { i = KMessageBox::Ok; QString msg; for (int j = 0; j < 200; ++j) { msg.append("LongMessageWithoutAnyBreaksShouldAppearSqueezed."); } KMessageBox::sorry(nullptr, msg); break; } default: return false; // done } // Switch showResult(test, i); return true; } int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); app.setApplicationName(QStringLiteral("kmessageboxtest")); // Syntax: kmessageboxtest if (argc > 1) { testMessageBox(QByteArray(argv[1]).toInt()); return 0; } // No argument specified, run all tests int test = 1; while (++test) { if (!testMessageBox(test)) { break; } } return 0; } #if 0 //this is my sequence for testing messagebox layout: KMessageBox::questionYesNoCancel( 0, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "long", KStandardGuiItem::saveAs(), KGuiItem("dsdddddd"), KStandardGuiItem::cancel() ); KMessageBox::questionYesNoCancel( 0, "ddddddddddddddddddddd ddddddddddddddddddddd dddddddddd dddddddddd ddddddddddddddddddd dddddddddddd ddddddddd", "long wrap", KStandardGuiItem::saveAs(), KGuiItem("dsdddddd"), KStandardGuiItem::cancel() ); KMessageBox::questionYesNoCancel( 0, "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd", "height", KStandardGuiItem::saveAs(), KGuiItem("dsdddddd"), KStandardGuiItem::cancel() ); QStringList strlist; strlist << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfgh\nghghgfhgf" << "f\ngfg\nhg\nhghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf" << "fgfghghghgfhgf"; KMessageBox::errorList(0, "short\n", strlist, "short"); KMessageBox::errorList(0, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", strlist, "short"); KMessageBox::errorList(0, "ddddddddddddddddddddd ddddddddddddddddddddd dddddddddd dddddddddd ddddddddddddddddddd dddddddddddd ddddddddd", strlist, "short"); KMessageBox::errorList(0, "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd", strlist, "short"); KMessageBox::detailedError(0, "sss", "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" ); KMessageBox::detailedError(0, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" ); KMessageBox::detailedError(0, "ddddddddddddddddddddd ddddddddddddddddddddd dddddddddd dddddddddd ddddddddddddddddddd dddddddddddd ddddddddd", "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" ); KMessageBox::detailedError(0, "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd", "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd" ); #endif