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.setApplicationName("Pineapple Pictures");
|
||||||
a.setApplicationDisplayName(QCoreApplication::translate("main", "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
|
// parse commandline arguments
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
|
parser.addOption(supportedImageFormats);
|
||||||
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
|
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
|
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
|
|
||||||
|
if (parser.isSet(supportedImageFormats)) {
|
||||||
|
fputs(qPrintable(MainWindow::supportedImageFormats().join(QChar('\n'))), stdout);
|
||||||
|
::exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
this->setWindowIcon(QIcon(":/icons/app-icon.svg"));
|
this->setWindowIcon(QIcon(":/icons/app-icon.svg"));
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
// related to jfif: https://codereview.qt-project.org/c/qt/qtbase/+/577730
|
m_pm->setAutoLoadFilterSuffixes(supportedImageFormats());
|
||||||
QStringList formatFilters{ QStringLiteral("*.jfif") };
|
|
||||||
for (const QByteArray &item : QImageReader::supportedImageFormats()) {
|
|
||||||
formatFilters.append(QStringLiteral("*.") % QString::fromLocal8Bit(item));
|
|
||||||
}
|
|
||||||
m_pm->setAutoLoadFilterSuffixes(formatFilters);
|
|
||||||
|
|
||||||
m_fadeOutAnimation = new QPropertyAnimation(this, "windowOpacity");
|
m_fadeOutAnimation = new QPropertyAnimation(this, "windowOpacity");
|
||||||
m_fadeOutAnimation->setDuration(300);
|
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)
|
void MainWindow::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
updateWidgetsPosition();
|
updateWidgetsPosition();
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
void galleryNext();
|
void galleryNext();
|
||||||
void galleryCurrent();
|
void galleryCurrent();
|
||||||
|
|
||||||
|
static QStringList supportedImageFormats();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
void enterEvent(QT_ENTER_EVENT *event) override;
|
void enterEvent(QT_ENTER_EVENT *event) override;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user