Merge branch 'master' into vmm

This commit is contained in:
Alexander Babikov
2025-06-08 17:40:54 +05:00
6 changed files with 67 additions and 5 deletions

View File

@@ -2053,6 +2053,7 @@ escp_close(void *priv)
free(dev->page);
}
FT_Done_Face(dev->fontface);
free(dev);
}

View File

@@ -2194,4 +2194,13 @@ msgid "Toggle pause"
msgstr "Переключить паузу"
msgid "Toggle mute"
msgstr "Переключить беззвучный режим"
msgstr "Переключить беззвучный режим"
msgid "Text files"
msgstr "Текстовые файлы"
msgid "ROM files"
msgstr "Файлы ПЗУ"
msgid "SoundFont files"
msgstr "Файлы SoundFont"

View File

@@ -31,6 +31,7 @@
#include <QLabel>
#include <QDir>
#include <QSettings>
#include <QStringBuilder>
extern "C" {
#include <86box/86box.h>
@@ -45,6 +46,7 @@ extern "C" {
#include "qt_filefield.hpp"
#include "qt_models_common.hpp"
#include "qt_util.hpp"
#ifdef Q_OS_LINUX
# include <sys/stat.h>
# include <sys/sysmacros.h>
@@ -276,11 +278,25 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep)
}
case CONFIG_FNAME:
{
auto *fileField = new FileField();
auto *fileField = new FileField(this);
fileField->setObjectName(config->name);
fileField->setFileName(selected);
fileField->setFilter(QString(config->file_filter).left(static_cast<int>(strcspn(config->file_filter,
"|"))));
/* Get the actually used part of the filter */
QString filter = QString(config->file_filter).left(static_cast<int>(strcspn(config->file_filter, "|")));
/* Extract the description and the extension list */
QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter);
QString description = match.captured(1);
QString extensions = match.captured(2);
QStringList extensionList;
/* Split the extension list up and strip the filename globs */
QRegularExpression re("\\*\\.(.*)");
int i = 0;
while (extensions.section(' ', i, i) != "") {
QString extension = re.match(extensions.section(' ', i, i)).captured(1);
extensionList.append(extension);
i++;
}
fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true));
this->ui->formLayout->addRow(tr(config->description), fileField);
break;
}

View File

@@ -92,6 +92,29 @@ DlgFilter(std::initializer_list<QString> extensions, bool last)
return " (" % temp.join(' ') % ")" % (!last ? ";;" : "");
}
QString
DlgFilter(QStringList 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 ? ";;" : "");
}
QString currentUuid()
{
auto configPath = QFileInfo(cfg_path).dir().canonicalPath();

View File

@@ -11,6 +11,7 @@ namespace util {
static constexpr auto UUID_MIN_LENGTH = 36;
/* Creates extension list for qt filedialog */
QString DlgFilter(std::initializer_list<QString> extensions, bool last = false);
QString DlgFilter(QStringList extensions, bool last = false);
/* Returns screen the widget is on */
QScreen *screenOfWidget(QWidget *widget);
#ifdef Q_OS_WINDOWS

View File

@@ -161,6 +161,7 @@ fluidsynth_init(UNUSED(const device_t *info))
fluid_settings_setnum(data->settings, "synth.sample-rate", 44100);
fluid_settings_setnum(data->settings, "synth.gain", device_get_config_int("output_gain") / 100.0f);
fluid_settings_setint(data->settings, "synth.dynamic-sample-loading", device_get_config_int("dynamic_sample_loading"));
data->synth = new_fluid_synth(data->settings);
@@ -324,7 +325,7 @@ static const device_config_t fluidsynth_config[] = {
.type = CONFIG_FNAME,
.default_string = NULL,
.default_int = 0,
.file_filter = "SF2 Sound Fonts (*.sf2)|*.sf2",
.file_filter = "SoundFont files (*.sf2 *.sf3)|*.sf2,*.sf3",
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
@@ -509,6 +510,17 @@ static const device_config_t fluidsynth_config[] = {
},
.bios = { { 0 } }
},
{
.name = "dynamic_sample_loading",
.description = "Dynamic Sample Loading",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
};