File indexing completed on 2024-05-12 04:00:00

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
0004     SPDX-FileCopyrightText: 2018 Olivier Churlaud <olivier@churlaud.com>
0005     SPDX-FileCopyrightText: 2016 Juan Carlos Torres <carlosdgtorres@gmail.com>
0006 
0007     SPDX-License-Identifier: LGPL-3.0-or-later
0008 */
0009 
0010 #include <KMessageBox>
0011 #include <QApplication>
0012 
0013 #include <iostream>
0014 
0015 int main(int argc, char *argv[])
0016 {
0017     QApplication app(argc, argv);
0018 
0019     // Define the question answer buttons
0020     KGuiItem primaryAction(QStringLiteral("Hello"), // the button label
0021                            QStringLiteral("view-filter"), // iconName, can be empty to fallback to default
0022                            QStringLiteral("This is a tooltip"),
0023                            QStringLiteral("This is a WhatsThis help text."));
0024 
0025     KGuiItem secondaryAction(QStringLiteral("Bye")); // the button label
0026 
0027     KMessageBox::ButtonCode res = KMessageBox::questionTwoActions(nullptr, // Parent, here none
0028                                                                            // The description can contain HTML
0029                                                                   QStringLiteral("Description to tell you to click<br />on <b>either</b> button"),
0030                                                                   QStringLiteral("My Title"),
0031                                                                   primaryAction,
0032                                                                   secondaryAction);
0033 
0034     if (res == KMessageBox::PrimaryAction) {
0035         std::cout << "You clicked Hello\n";
0036         return EXIT_SUCCESS;
0037     } else {
0038         std::cout << "You clicked Bye\n";
0039         return EXIT_FAILURE;
0040     }
0041 }