File indexing completed on 2024-06-09 11:44:56

0001 /*
0002     SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include <kicondialog.h>
0008 
0009 #include <QApplication>
0010 #include <QTextStream>
0011 
0012 #include <iostream>
0013 
0014 class Listener : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 public Q_SLOTS:
0019     void dialog1Done()
0020     {
0021         KIconDialog *dialog = new KIconDialog();
0022         dialog->setup(KIconLoader::Toolbar, KIconLoader::Action);
0023         QString icon = dialog->openDialog();
0024         QTextStream(stdout) << "Icon \"" << icon << "\" was chosen (openDialog)\n";
0025         delete dialog;
0026 
0027         icon = KIconDialog::getIcon(KIconLoader::Desktop, KIconLoader::MimeType, true, 48, true, nullptr, QStringLiteral("Test dialog"));
0028         QTextStream(stdout) << "Icon \"" << icon << "\" was chosen (getIcon)\n";
0029     }
0030 
0031     void iconChosen(const QString &name)
0032     {
0033         QTextStream(stdout) << "Icon \"" << name << "\" was chosen (showDialog).\n";
0034     }
0035 };
0036 
0037 int main(int argc, char **argv)
0038 {
0039     QApplication app(argc, argv);
0040     app.setAttribute(Qt::AA_UseHighDpiPixmaps);
0041 
0042     Listener listener;
0043 
0044     KIconDialog dialog;
0045     QObject::connect(&dialog, &KIconDialog::newIconName, &listener, &Listener::iconChosen);
0046     QObject::connect(&dialog, &QDialog::finished, &listener, &Listener::dialog1Done);
0047 
0048     dialog.showDialog();
0049 
0050     return app.exec();
0051 }
0052 
0053 #include "kicondialogtest.moc"