File indexing completed on 2024-12-08 04:34:37

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "dialogs/showimagedialog.h"
0008 #include <QApplication>
0009 #include <QCommandLineOption>
0010 #include <QCommandLineParser>
0011 #include <QPixmap>
0012 
0013 int main(int argc, char **argv)
0014 {
0015     QApplication app(argc, argv);
0016     QCommandLineParser parser;
0017     parser.addVersionOption();
0018     parser.addHelpOption();
0019     parser.addPositionalArgument({QStringLiteral("file")}, QStringLiteral("Image file"));
0020     const QCommandLineOption isAnimatedImageOption({QStringLiteral("isAnimatedImage")},
0021                                                    QStringLiteral("Whether the image file contains animation (e.g. for GIF files)"));
0022     parser.addOption(isAnimatedImageOption);
0023     parser.process(app);
0024 
0025     if (parser.positionalArguments().isEmpty()) {
0026         parser.showHelp(1); // exits
0027     }
0028 
0029     const QString fileName = parser.positionalArguments().value(0);
0030 
0031     ShowImageDialog dlg(nullptr);
0032     ShowImageWidget::ImageInfo info;
0033     info.isAnimatedImage = parser.isSet(isAnimatedImageOption);
0034     info.bigImagePath = fileName;
0035     info.pixmap = QPixmap(fileName);
0036     dlg.setImageInfo(info);
0037     dlg.resize(800, 600);
0038     dlg.show();
0039 
0040     return app.exec();
0041 }