File indexing completed on 2024-04-28 03:59:18

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2013 Aurélien Gâteau <agateau@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 #include <iostream>
0008 
0009 #include <kmessagebox.h>
0010 
0011 #include <QApplication>
0012 
0013 int main(int argc, char **argv)
0014 {
0015     QApplication::setApplicationName(QStringLiteral("kmessageboxwidtest"));
0016     QApplication app(argc, argv);
0017     if (argc != 2) {
0018         std::cerr << "Usage: " << qPrintable(QApplication::applicationName()) << " <window id>\n";
0019         std::cerr << '\n';
0020         std::cerr << "You can get a window id using a tool like `xwininfo`.\n";
0021         return 1;
0022     }
0023 
0024     bool ok;
0025     int winId = QByteArray(argv[1]).toInt(&ok, 0);
0026     if (!ok) {
0027         std::cerr << '"' << argv[1] << "\" is not a number\n";
0028         return 1;
0029     }
0030 
0031     int ret = KMessageBox::warningContinueCancelWId(winId, QStringLiteral("Are you sure you want to continue?"), QStringLiteral("Dangerous stuff"));
0032 
0033     std::cout << "Returned " << ret << '\n';
0034     return ret;
0035 }