qt: fix platform specific file dialog filters

Translations now only contain translation for the description and
extensions are generated in code taking account platform specific
differences.
This commit is contained in:
ts-korhonen
2022-01-23 22:48:36 +02:00
parent 067b49c848
commit f8f3cfbf4c
25 changed files with 724 additions and 487 deletions

31
src/qt/qt_util.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <QStringBuilder>
#include <QStringList>
#include "qt_util.hpp"
namespace util
{
QString DlgFilter(std::initializer_list<QString> extensions, bool last)
{
QStringList temp;
for (auto ext : extensions)
{
#ifdef Q_OS_UNIX
if (ext == "*")
{
temp.append("*");
continue;
}
temp.append("*." % ext.toUpper());
#endif
temp.append("*." % ext);
}
#ifdef Q_OS_UNIX
temp.removeDuplicates();
#endif
return " (" % temp.join(' ') % ")" % (!last ? ";;" : "");
}
}