diff --git a/src/86box.c b/src/86box.c index 8569ae53f..deded3382 100644 --- a/src/86box.c +++ b/src/86box.c @@ -183,6 +183,7 @@ int confirm_save = 1; /* (C) enable save confirmation */ int enable_discord = 0; /* (C) enable Discord integration */ int pit_mode = -1; /* (C) force setting PIT mode */ int fm_driver = 0; /* (C) select FM sound driver */ +int open_dir_usr_path = 0; /* default file open dialog directory of usr_path */ /* Statistics. */ extern int mmuflush; diff --git a/src/config.c b/src/config.c index 8d488936e..f518b35bc 100644 --- a/src/config.c +++ b/src/config.c @@ -611,6 +611,8 @@ load_general(void) enable_discord = !!config_get_int(cat, "enable_discord", 0); + open_dir_usr_path = config_get_int(cat, "open_dir_usr_path", 0); + video_framerate = config_get_int(cat, "video_gl_framerate", -1); video_vsync = config_get_int(cat, "video_gl_vsync", 0); strncpy(video_shader, config_get_string(cat, "video_gl_shader", ""), sizeof(video_shader)); @@ -2380,6 +2382,11 @@ save_general(void) else config_delete_var(cat, "enable_discord"); + if (open_dir_usr_path) + config_set_int(cat, "open_dir_usr_path", open_dir_usr_path); + else + config_delete_var(cat, "open_dir_usr_path"); + if (video_framerate != -1) config_set_int(cat, "video_gl_framerate", video_framerate); else diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 93a9fa0a1..ca7fbb99c 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -137,6 +137,7 @@ extern int fm_driver; /* (C) select FM sound driver */ extern char exe_path[2048]; /* path (dir) of executable */ extern char usr_path[1024]; /* path (dir) of user data */ extern char cfg_path[1024]; /* full path of config file */ +extern int open_dir_usr_path; /* default file open dialog directory of usr_path */ #ifndef USE_NEW_DYNAREC extern FILE *stdlog; /* file to log output to */ #endif diff --git a/src/qt/qt_mediamenu.cpp b/src/qt/qt_mediamenu.cpp index ebfe68bef..96fba3808 100644 --- a/src/qt/qt_mediamenu.cpp +++ b/src/qt/qt_mediamenu.cpp @@ -28,6 +28,7 @@ #include extern "C" { +#include <86box/86box.h> #include <86box/config.h> #include <86box/device.h> #include <86box/timer.h> @@ -173,7 +174,7 @@ void MediaMenu::cassetteNewImage() { void MediaMenu::cassetteSelectImage(bool wp) { auto filename = QFileDialog::getOpenFileName(parentWidget, QString(), - QString(), + getMediaOpenDirectory(), tr("Cassette images") % util::DlgFilter({ "pcm","raw","wav","cas" }) % tr("All files") % @@ -247,7 +248,7 @@ void MediaMenu::cartridgeSelectImage(int i) { auto filename = QFileDialog::getOpenFileName( parentWidget, QString(), - QString(), + getMediaOpenDirectory(), tr("Cartridge images") % util::DlgFilter({ "a","b","jrc" }) % tr("All files") % @@ -291,7 +292,7 @@ void MediaMenu::floppySelectImage(int i, bool wp) { auto filename = QFileDialog::getOpenFileName( parentWidget, QString(), - QString(), + getMediaOpenDirectory(), tr("All images") % util::DlgFilter({ "0??","1??","??0","86f","bin","cq?","d??","flp","hdm","im?","json","td0","*fd?","mfm","xdf" }) % tr("Advanced sector images") % @@ -400,7 +401,7 @@ void MediaMenu::cdromMount(int i) { auto filename = QFileDialog::getOpenFileName( parentWidget, QString(), - QString(), + getMediaOpenDirectory(), tr("CD-ROM images") % util::DlgFilter({ "iso","cue" }) % tr("All files") % @@ -571,7 +572,7 @@ void MediaMenu::moSelectImage(int i, bool wp) { auto filename = QFileDialog::getOpenFileName( parentWidget, QString(), - QString(), + getMediaOpenDirectory(), tr("MO images") % util::DlgFilter({ "im?", "mdi" }) % tr("All files") % @@ -656,6 +657,13 @@ void MediaMenu::moUpdateMenu(int i) { menu->setTitle(QString::asprintf(tr("MO %i (%ls): %ls").toUtf8().constData(), i + 1, busName.toStdU16String().data(), name.isEmpty() ? tr("(empty)").toStdU16String().data() : name.toStdU16String().data())); } +QString MediaMenu::getMediaOpenDirectory() { + QString openDirectory; + if (open_dir_usr_path > 0) { + openDirectory = QString::fromUtf8(usr_path); + } + return openDirectory; +} // callbacks from 86box C code extern "C" { diff --git a/src/qt/qt_mediamenu.hpp b/src/qt/qt_mediamenu.hpp index 3c45b2414..94f547d3f 100644 --- a/src/qt/qt_mediamenu.hpp +++ b/src/qt/qt_mediamenu.hpp @@ -66,6 +66,8 @@ private: QMap zipMenus; QMap moMenus; + QString getMediaOpenDirectory(); + int cassetteRecordPos; int cassettePlayPos; int cassetteRewindPos; diff --git a/src/qt/qt_progsettings.cpp b/src/qt/qt_progsettings.cpp index b11466c08..0b4f0e955 100644 --- a/src/qt/qt_progsettings.cpp +++ b/src/qt/qt_progsettings.cpp @@ -113,12 +113,14 @@ ProgSettings::ProgSettings(QWidget *parent) : mouseSensitivity = mouse_sensitivity; ui->horizontalSlider->setValue(mouseSensitivity * 100.); + ui->openDirUsrPath->setChecked(open_dir_usr_path > 0); } void ProgSettings::accept() { strcpy(icon_set, ui->comboBox->currentData().toString().toUtf8().data()); lang_id = ui->comboBoxLanguage->currentData().toUInt(); + open_dir_usr_path = ui->openDirUsrPath->isChecked() ? 1 : 0; loadTranslators(QCoreApplication::instance()); reloadStrings(); diff --git a/src/qt/qt_progsettings.ui b/src/qt/qt_progsettings.ui index 11bb39b74..05775489f 100644 --- a/src/qt/qt_progsettings.ui +++ b/src/qt/qt_progsettings.ui @@ -7,7 +7,7 @@ 0 0 458 - 303 + 374 @@ -29,24 +29,14 @@ QLayout::SetFixedSize - - - - Qt::Horizontal + + + + false - - - 40 - 20 - - - - - - - (System Default) + (Default) @@ -58,30 +48,6 @@ - - - - Default - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Default - - - @@ -89,8 +55,8 @@ - - + + Default @@ -109,25 +75,15 @@ - - - - Language: - - - - - + + Qt::Horizontal - - - 40 - 20 - + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + @@ -151,18 +107,72 @@ - - - - false - + + - (Default) + (System Default) + + + + Language: + + + + + + + Default + + + + + + + Default + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p>When selecting media images (CD-ROM, floppy, etc.) the open dialog will start in the same directory as the 86Box configuration file. This setting will likely only make a difference on macOS.</p></body></html> + + + Select media images from program working directory + + +