mirror of https://github.com/snes9xgit/snes9x.git
Qt: More updates.
This commit is contained in:
parent
03c9a10cc2
commit
4f91b2430f
|
@ -49,7 +49,7 @@ void main()
|
||||||
EmuCanvasOpenGL::EmuCanvasOpenGL(EmuConfig *config, QWidget *parent, QWidget *main_window)
|
EmuCanvasOpenGL::EmuCanvasOpenGL(EmuConfig *config, QWidget *parent, QWidget *main_window)
|
||||||
: EmuCanvas(config, parent, main_window)
|
: EmuCanvas(config, parent, main_window)
|
||||||
{
|
{
|
||||||
setMinimumSize(256, 224);
|
setMinimumSize(256 / devicePixelRatioF(), 224 / devicePixelRatioF());
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
setAutoFillBackground(false);
|
setAutoFillBackground(false);
|
||||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
EmuCanvasQt::EmuCanvasQt(EmuConfig *config, QWidget *parent, QWidget *main_window)
|
EmuCanvasQt::EmuCanvasQt(EmuConfig *config, QWidget *parent, QWidget *main_window)
|
||||||
: EmuCanvas(config, parent, main_window)
|
: EmuCanvas(config, parent, main_window)
|
||||||
{
|
{
|
||||||
setMinimumSize(256, 224);
|
setMinimumSize(256 / devicePixelRatioF(), 224 / devicePixelRatioF());
|
||||||
}
|
}
|
||||||
|
|
||||||
EmuCanvasQt::~EmuCanvasQt()
|
EmuCanvasQt::~EmuCanvasQt()
|
||||||
|
|
|
@ -15,7 +15,7 @@ using namespace QNativeInterface;
|
||||||
EmuCanvasVulkan::EmuCanvasVulkan(EmuConfig *config, QWidget *parent, QWidget *main_window)
|
EmuCanvasVulkan::EmuCanvasVulkan(EmuConfig *config, QWidget *parent, QWidget *main_window)
|
||||||
: EmuCanvas(config, parent, main_window)
|
: EmuCanvas(config, parent, main_window)
|
||||||
{
|
{
|
||||||
setMinimumSize(256, 224);
|
setMinimumSize(256 / devicePixelRatioF(), 224 / devicePixelRatioF());
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
setAutoFillBackground(false);
|
setAutoFillBackground(false);
|
||||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|
|
@ -185,8 +185,20 @@ std::string EmuConfig::findConfigFile()
|
||||||
return path.string();
|
return path.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuConfig::setDefaults(int section)
|
bool EmuConfig::setDefaults(int section)
|
||||||
{
|
{
|
||||||
|
main_window_width = 640;
|
||||||
|
main_window_height = 480;
|
||||||
|
|
||||||
|
bool restart = false;
|
||||||
|
auto restart_set = [&](auto& dst, auto str) {
|
||||||
|
if (dst != str)
|
||||||
|
{
|
||||||
|
restart = true;
|
||||||
|
dst = str;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (section == -1 || section == 0)
|
if (section == -1 || section == 0)
|
||||||
{
|
{
|
||||||
// General
|
// General
|
||||||
|
@ -203,20 +215,22 @@ void EmuConfig::setDefaults(int section)
|
||||||
if (section == -1 || section == 1)
|
if (section == -1 || section == 1)
|
||||||
{
|
{
|
||||||
// Display
|
// Display
|
||||||
display_driver = {};
|
restart_set(display_driver, "vulkan");
|
||||||
display_device_index = 0;
|
restart_set(display_device_index, 0);
|
||||||
enable_vsync = true;
|
enable_vsync = true;
|
||||||
;
|
;
|
||||||
bilinear_filter = true;
|
bilinear_filter = true;
|
||||||
;
|
;
|
||||||
reduce_input_lag = true;
|
reduce_input_lag = true;
|
||||||
adjust_for_vrr = false;
|
adjust_for_vrr = false;
|
||||||
use_shader = false;
|
restart_set(use_shader, false);
|
||||||
shader = {};
|
if (use_shader)
|
||||||
|
restart_set(shader, "");
|
||||||
|
else
|
||||||
|
shader = {};
|
||||||
last_shader_folder = {};
|
last_shader_folder = {};
|
||||||
|
|
||||||
scale_image = true;
|
scale_image = true;
|
||||||
;
|
|
||||||
maintain_aspect_ratio = true;
|
maintain_aspect_ratio = true;
|
||||||
use_integer_scaling = false;
|
use_integer_scaling = false;
|
||||||
aspect_ratio_numerator = 4;
|
aspect_ratio_numerator = 4;
|
||||||
|
@ -233,10 +247,10 @@ void EmuConfig::setDefaults(int section)
|
||||||
if (section == -1 || section == 2)
|
if (section == -1 || section == 2)
|
||||||
{
|
{
|
||||||
// Sound
|
// Sound
|
||||||
sound_driver = {};
|
restart_set(sound_driver, "cubeb");
|
||||||
sound_device = {};
|
sound_device = {};
|
||||||
playback_rate = 48000;
|
restart_set(playback_rate, 48000);
|
||||||
audio_buffer_size_ms = 64;
|
restart_set(audio_buffer_size_ms, 64);
|
||||||
|
|
||||||
adjust_input_rate_automatically = true;
|
adjust_input_rate_automatically = true;
|
||||||
input_rate = 31979;
|
input_rate = 31979;
|
||||||
|
@ -301,6 +315,8 @@ void EmuConfig::setDefaults(int section)
|
||||||
patch_location = eROMDirectory;
|
patch_location = eROMDirectory;
|
||||||
export_location = eROMDirectory;
|
export_location = eROMDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuConfig::config(std::string filename, bool write)
|
void EmuConfig::config(std::string filename, bool write)
|
||||||
|
@ -370,7 +386,7 @@ void EmuConfig::config(std::string filename, bool write)
|
||||||
|
|
||||||
if (settings.contains(key))
|
if (settings.contains(key))
|
||||||
entry = settings.value(key).toString().toLower();
|
entry = settings.value(key).toString().toLower();
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (size_t i = 0; i < map.size(); i++)
|
for (size_t i = 0; i < map.size(); i++)
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct EmuConfig
|
||||||
{
|
{
|
||||||
static std::string findConfigFile();
|
static std::string findConfigFile();
|
||||||
static std::string findConfigDir();
|
static std::string findConfigDir();
|
||||||
void setDefaults(int section = -1);
|
bool setDefaults(int section = -1);
|
||||||
void config(std::string filename, bool write);
|
void config(std::string filename, bool write);
|
||||||
void loadFile(std::string filename)
|
void loadFile(std::string filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -333,7 +333,8 @@ void EmuMainWindow::createWidgets()
|
||||||
|
|
||||||
void EmuMainWindow::resizeToMultiple(int multiple)
|
void EmuMainWindow::resizeToMultiple(int multiple)
|
||||||
{
|
{
|
||||||
resize((224 * multiple) * app->config->aspect_ratio_numerator / app->config->aspect_ratio_denominator, (224 * multiple) + menuBar()->height());
|
double hidpi_height = 224 / devicePixelRatioF();
|
||||||
|
resize((hidpi_height * multiple) * app->config->aspect_ratio_numerator / app->config->aspect_ratio_denominator, (hidpi_height * multiple) + menuBar()->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuMainWindow::setBypassCompositor(bool bypass)
|
void EmuMainWindow::setBypassCompositor(bool bypass)
|
||||||
|
|
|
@ -45,9 +45,21 @@ EmuSettingsWindow::EmuSettingsWindow(QWidget *parent, EmuApplication *app_)
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(defaultsButton, &QPushButton::clicked, [&](bool) {
|
connect(defaultsButton, &QPushButton::clicked, [&](bool) {
|
||||||
app->config->setDefaults(stackedWidget->currentIndex());
|
auto section = stackedWidget->currentIndex();
|
||||||
|
bool restart_needed = app->config->setDefaults(stackedWidget->currentIndex());
|
||||||
stackedWidget->currentWidget()->hide();
|
stackedWidget->currentWidget()->hide();
|
||||||
stackedWidget->currentWidget()->show();
|
stackedWidget->currentWidget()->show();
|
||||||
|
|
||||||
|
if (restart_needed)
|
||||||
|
{
|
||||||
|
if (section == 1) // Display
|
||||||
|
app->window->recreateCanvas();
|
||||||
|
else if (section == 2) // Sound
|
||||||
|
app->restartAudio();
|
||||||
|
else if (section == 4 || section == 5) // Controller Bindings
|
||||||
|
app->updateBindings();
|
||||||
|
}
|
||||||
|
app->updateSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,4 +73,5 @@ void EmuSettingsWindow::show(int page)
|
||||||
stackedWidget->setCurrentIndex(page);
|
stackedWidget->setCurrentIndex(page);
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
open();
|
open();
|
||||||
|
closeButton->setDefault(false);
|
||||||
}
|
}
|
|
@ -114,6 +114,9 @@
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="defaultsButton">
|
<widget class="QPushButton" name="defaultsButton">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::TabFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Restore Defaults</string>
|
<string>Restore Defaults</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -121,6 +124,9 @@
|
||||||
<iconset theme="view-refresh">
|
<iconset theme="view-refresh">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
Loading…
Reference in New Issue