File indexing completed on 2024-03-24 15:35:15

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2002 Dirk Mueller <mueller@kde.org>
0004     SPDX-FileCopyrightText: 2003 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include <QApplication>
0010 #include <QDebug>
0011 #include <QUrl>
0012 #include <kopenwithdialog.h>
0013 
0014 int main(int argc, char **argv)
0015 {
0016     QApplication::setApplicationName(QStringLiteral("kopenwithdialogtest"));
0017     QApplication app(argc, argv);
0018     QList<QUrl> list;
0019 
0020     list += QUrl(QStringLiteral("file:///tmp/testfile.txt"));
0021 
0022     // Test with one URL
0023     KOpenWithDialog *dlg = new KOpenWithDialog(list, QString(), QString());
0024     if (dlg->exec()) {
0025         qDebug() << "Dialog ended successfully\ntext: " << dlg->text();
0026     } else {
0027         qDebug() << "Dialog was canceled.";
0028     }
0029     delete dlg;
0030 
0031     // Test with two URLs
0032     list += QUrl(QStringLiteral("http://www.kde.org/index.html"));
0033     dlg = new KOpenWithDialog(list, QString(), QString(), nullptr);
0034     if (dlg->exec()) {
0035         qDebug() << "Dialog ended successfully\ntext: " << dlg->text();
0036     } else {
0037         qDebug() << "Dialog was canceled.";
0038     }
0039     delete dlg;
0040 
0041     // Test with a MIME type
0042     QString mimetype = QStringLiteral("text/plain");
0043     dlg = new KOpenWithDialog(mimetype, QStringLiteral("kwrite"), nullptr);
0044     if (dlg->exec()) {
0045         qDebug() << "Dialog ended successfully\ntext: " << dlg->text();
0046     } else {
0047         qDebug() << "Dialog was canceled.";
0048     }
0049     delete dlg;
0050 
0051     return 0;
0052 }