File indexing completed on 2024-05-12 05:46:54
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (C) 2018 Friedrich W. H. Kossebau <kossebau@kde.org> 0004 * Copyright (C) 2018 Olivier Churlaud <olivier@churlaud.com> 0005 * Copyright (C) 2016 by Juan Carlos Torres <carlosdgtorres@gmail.com> 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Library General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 3 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Library General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Library General Public License 0018 * along with this library; see the file COPYING.LIB. If not, write to 0019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #include <QApplication> 0024 #include <KMessageBox> 0025 0026 #include <iostream> 0027 0028 int main (int argc, char *argv[]) 0029 { 0030 QApplication app(argc, argv); 0031 0032 // Define a button 0033 KGuiItem yesButton( 0034 QStringLiteral("Hello"), // the button label 0035 QStringLiteral("view-filter"), // iconName, can be empty to fallback to default 0036 QStringLiteral("This is a tooltip"), 0037 QStringLiteral("This is a WhatsThis help text.") 0038 ); 0039 0040 KMessageBox::ButtonCode res = KMessageBox::questionYesNo( 0041 nullptr, // Parent, here none 0042 // The description can contain HTML 0043 QStringLiteral("Description to tell you to click<br />on <b>either</b> button"), 0044 QStringLiteral("My Title"), 0045 yesButton 0046 /*noButton not explicitly set, falls back to default*/ 0047 ); 0048 0049 if (res == KMessageBox::Yes) { 0050 std::cout << "You clicked Hello\n"; 0051 return EXIT_SUCCESS; 0052 } else { 0053 std::cout << "You clicked No\n"; 0054 return EXIT_FAILURE; 0055 } 0056 }