feat: cli argument to list supported image formats
This commit is contained in:
parent
cd01a05f23
commit
a6e31a2c4d
|
@ -40,13 +40,20 @@ int main(int argc, char *argv[])
|
|||
a.setApplicationName("Pineapple Pictures");
|
||||
a.setApplicationDisplayName(QCoreApplication::translate("main", "Pineapple Pictures"));
|
||||
|
||||
// commandline options
|
||||
QCommandLineOption supportedImageFormats(QStringLiteral("supported-image-formats"), QCoreApplication::translate("main", "List supported image format suffixes, and quit program."));
|
||||
// parse commandline arguments
|
||||
QCommandLineParser parser;
|
||||
parser.addOption(supportedImageFormats);
|
||||
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
|
||||
parser.addHelpOption();
|
||||
|
||||
parser.process(a);
|
||||
|
||||
if (parser.isSet(supportedImageFormats)) {
|
||||
fputs(qPrintable(MainWindow::supportedImageFormats().join(QChar('\n'))), stdout);
|
||||
::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
|
|
|
@ -57,12 +57,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
this->setWindowIcon(QIcon(":/icons/app-icon.svg"));
|
||||
this->setMouseTracking(true);
|
||||
|
||||
// related to jfif: https://codereview.qt-project.org/c/qt/qtbase/+/577730
|
||||
QStringList formatFilters{ QStringLiteral("*.jfif") };
|
||||
for (const QByteArray &item : QImageReader::supportedImageFormats()) {
|
||||
formatFilters.append(QStringLiteral("*.") % QString::fromLocal8Bit(item));
|
||||
}
|
||||
m_pm->setAutoLoadFilterSuffixes(formatFilters);
|
||||
m_pm->setAutoLoadFilterSuffixes(supportedImageFormats());
|
||||
|
||||
m_fadeOutAnimation = new QPropertyAnimation(this, "windowOpacity");
|
||||
m_fadeOutAnimation->setDuration(300);
|
||||
|
@ -278,6 +273,19 @@ void MainWindow::galleryCurrent()
|
|||
}
|
||||
}
|
||||
|
||||
QStringList MainWindow::supportedImageFormats()
|
||||
{
|
||||
QStringList formatFilters {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
|
||||
QStringLiteral("*.jfif")
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
|
||||
};
|
||||
for (const QByteArray &item : QImageReader::supportedImageFormats()) {
|
||||
formatFilters.append(QStringLiteral("*.") % QString::fromLocal8Bit(item));
|
||||
}
|
||||
return formatFilters;
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
updateWidgetsPosition();
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
void galleryNext();
|
||||
void galleryCurrent();
|
||||
|
||||
static QStringList supportedImageFormats();
|
||||
|
||||
protected slots:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void enterEvent(QT_ENTER_EVENT *event) override;
|
||||
|
|
Loading…
Reference in New Issue
Block a user