Qt: More updates.

This commit is contained in:
BearOso 2023-08-06 15:59:24 -05:00
parent 03c9a10cc2
commit 4f91b2430f
8 changed files with 52 additions and 16 deletions

View File

@ -49,7 +49,7 @@ void main()
EmuCanvasOpenGL::EmuCanvasOpenGL(EmuConfig *config, QWidget *parent, QWidget *main_window)
: EmuCanvas(config, parent, main_window)
{
setMinimumSize(256, 224);
setMinimumSize(256 / devicePixelRatioF(), 224 / devicePixelRatioF());
setUpdatesEnabled(false);
setAutoFillBackground(false);
setAttribute(Qt::WA_NoSystemBackground, true);

View File

@ -8,7 +8,7 @@
EmuCanvasQt::EmuCanvasQt(EmuConfig *config, QWidget *parent, QWidget *main_window)
: EmuCanvas(config, parent, main_window)
{
setMinimumSize(256, 224);
setMinimumSize(256 / devicePixelRatioF(), 224 / devicePixelRatioF());
}
EmuCanvasQt::~EmuCanvasQt()

View File

@ -15,7 +15,7 @@ using namespace QNativeInterface;
EmuCanvasVulkan::EmuCanvasVulkan(EmuConfig *config, QWidget *parent, QWidget *main_window)
: EmuCanvas(config, parent, main_window)
{
setMinimumSize(256, 224);
setMinimumSize(256 / devicePixelRatioF(), 224 / devicePixelRatioF());
setUpdatesEnabled(false);
setAutoFillBackground(false);
setAttribute(Qt::WA_NoSystemBackground, true);

View File

@ -185,8 +185,20 @@ std::string EmuConfig::findConfigFile()
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)
{
// General
@ -203,20 +215,22 @@ void EmuConfig::setDefaults(int section)
if (section == -1 || section == 1)
{
// Display
display_driver = {};
display_device_index = 0;
restart_set(display_driver, "vulkan");
restart_set(display_device_index, 0);
enable_vsync = true;
;
bilinear_filter = true;
;
reduce_input_lag = true;
adjust_for_vrr = false;
use_shader = false;
restart_set(use_shader, false);
if (use_shader)
restart_set(shader, "");
else
shader = {};
last_shader_folder = {};
scale_image = true;
;
maintain_aspect_ratio = true;
use_integer_scaling = false;
aspect_ratio_numerator = 4;
@ -233,10 +247,10 @@ void EmuConfig::setDefaults(int section)
if (section == -1 || section == 2)
{
// Sound
sound_driver = {};
restart_set(sound_driver, "cubeb");
sound_device = {};
playback_rate = 48000;
audio_buffer_size_ms = 64;
restart_set(playback_rate, 48000);
restart_set(audio_buffer_size_ms, 64);
adjust_input_rate_automatically = true;
input_rate = 31979;
@ -301,6 +315,8 @@ void EmuConfig::setDefaults(int section)
patch_location = eROMDirectory;
export_location = eROMDirectory;
}
return restart;
}
void EmuConfig::config(std::string filename, bool write)

View File

@ -10,7 +10,7 @@ struct EmuConfig
{
static std::string findConfigFile();
static std::string findConfigDir();
void setDefaults(int section = -1);
bool setDefaults(int section = -1);
void config(std::string filename, bool write);
void loadFile(std::string filename)
{

View File

@ -333,7 +333,8 @@ void EmuMainWindow::createWidgets()
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)

View File

@ -45,9 +45,21 @@ EmuSettingsWindow::EmuSettingsWindow(QWidget *parent, EmuApplication *app_)
});
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()->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);
if (!isVisible())
open();
closeButton->setDefault(false);
}

View File

@ -114,6 +114,9 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="defaultsButton">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string>Restore Defaults</string>
</property>
@ -121,6 +124,9 @@
<iconset theme="view-refresh">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>