2017-05-04 01:47:59 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "DolphinQt2/Settings/InterfacePane.h"
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include "Common/CommonPaths.h"
|
|
|
|
#include "Common/FileSearch.h"
|
|
|
|
#include "Common/FileUtil.h"
|
2017-05-12 12:56:00 -06:00
|
|
|
#include "Common/StringUtil.h"
|
2017-05-04 01:47:59 -06:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
|
2017-06-01 00:49:06 -06:00
|
|
|
#include "DolphinQt2/Settings.h"
|
|
|
|
|
2017-05-04 01:47:59 -06:00
|
|
|
InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
CreateLayout();
|
|
|
|
ConnectLayout();
|
|
|
|
LoadConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterfacePane::CreateLayout()
|
|
|
|
{
|
|
|
|
m_main_layout = new QVBoxLayout;
|
|
|
|
// Create layout here
|
|
|
|
CreateUI();
|
|
|
|
CreateInGame();
|
|
|
|
|
2017-06-20 20:18:34 -06:00
|
|
|
m_main_layout->setContentsMargins(0, 0, 0, 0);
|
2017-05-04 01:47:59 -06:00
|
|
|
m_main_layout->addStretch(1);
|
|
|
|
setLayout(m_main_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterfacePane::CreateUI()
|
|
|
|
{
|
|
|
|
auto* groupbox = new QGroupBox(tr("User Interface"));
|
|
|
|
auto* groupbox_layout = new QVBoxLayout;
|
|
|
|
groupbox->setLayout(groupbox_layout);
|
|
|
|
m_main_layout->addWidget(groupbox);
|
|
|
|
|
2017-05-05 04:38:59 -06:00
|
|
|
auto* combobox_layout = new QFormLayout;
|
|
|
|
groupbox_layout->addLayout(combobox_layout);
|
|
|
|
|
|
|
|
m_combobox_language = new QComboBox;
|
|
|
|
// TODO: Support more languages other then English
|
|
|
|
m_combobox_language->addItem(tr("English"));
|
|
|
|
combobox_layout->addRow(tr("&Language:"), m_combobox_language);
|
|
|
|
|
2017-05-04 01:47:59 -06:00
|
|
|
// Theme Combobox
|
|
|
|
m_combobox_theme = new QComboBox;
|
2017-05-05 04:38:59 -06:00
|
|
|
combobox_layout->addRow(tr("&Theme:"), m_combobox_theme);
|
2017-05-04 01:47:59 -06:00
|
|
|
|
|
|
|
// List avalable themes
|
2017-06-20 22:24:26 -06:00
|
|
|
auto file_search_results =
|
|
|
|
Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR});
|
2017-05-04 01:47:59 -06:00
|
|
|
for (const std::string& filename : file_search_results)
|
|
|
|
{
|
|
|
|
std::string name, ext;
|
|
|
|
SplitPath(filename, nullptr, &name, &ext);
|
|
|
|
name += ext;
|
|
|
|
QString qt_name = QString::fromStdString(name);
|
|
|
|
m_combobox_theme->addItem(qt_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checkboxes
|
|
|
|
m_checkbox_auto_window = new QCheckBox(tr("Auto Adjust Window Size"));
|
|
|
|
m_checkbox_top_window = new QCheckBox(tr("Keep Dolphin on Top"));
|
|
|
|
m_checkbox_render_to_window = new QCheckBox(tr("Render to Main Window"));
|
2017-07-23 07:28:34 -06:00
|
|
|
m_checkbox_use_builtin_title_database = new QCheckBox(tr("Use Built-In Database of Game Names"));
|
2017-05-04 01:47:59 -06:00
|
|
|
groupbox_layout->addWidget(m_checkbox_auto_window);
|
|
|
|
groupbox_layout->addWidget(m_checkbox_top_window);
|
|
|
|
groupbox_layout->addWidget(m_checkbox_render_to_window);
|
2017-07-23 07:28:34 -06:00
|
|
|
groupbox_layout->addWidget(m_checkbox_use_builtin_title_database);
|
2017-05-04 01:47:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void InterfacePane::CreateInGame()
|
|
|
|
{
|
|
|
|
auto* groupbox = new QGroupBox(tr("In Game"));
|
|
|
|
auto* groupbox_layout = new QVBoxLayout;
|
|
|
|
groupbox->setLayout(groupbox_layout);
|
|
|
|
m_main_layout->addWidget(groupbox);
|
|
|
|
|
|
|
|
m_checkbox_confirm_on_stop = new QCheckBox(tr("Confirm on Stop"));
|
|
|
|
m_checkbox_use_panic_handlers = new QCheckBox(tr("Use Panic Handlers"));
|
|
|
|
m_checkbox_enable_osd = new QCheckBox(tr("Enable On Screen Messages"));
|
2017-05-15 08:49:52 -06:00
|
|
|
m_checkbox_show_active_title = new QCheckBox(tr("Show Active Title in Window Title"));
|
2017-05-04 01:47:59 -06:00
|
|
|
m_checkbox_pause_on_focus_lost = new QCheckBox(tr("Pause on Focus Loss"));
|
|
|
|
m_checkbox_hide_mouse = new QCheckBox(tr("Hide Mouse Cursor"));
|
|
|
|
|
|
|
|
groupbox_layout->addWidget(m_checkbox_confirm_on_stop);
|
|
|
|
groupbox_layout->addWidget(m_checkbox_use_panic_handlers);
|
|
|
|
groupbox_layout->addWidget(m_checkbox_enable_osd);
|
2017-05-15 08:49:52 -06:00
|
|
|
groupbox_layout->addWidget(m_checkbox_show_active_title);
|
2017-05-04 01:47:59 -06:00
|
|
|
groupbox_layout->addWidget(m_checkbox_pause_on_focus_lost);
|
|
|
|
groupbox_layout->addWidget(m_checkbox_hide_mouse);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterfacePane::ConnectLayout()
|
|
|
|
{
|
|
|
|
connect(m_checkbox_auto_window, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
|
|
|
connect(m_checkbox_top_window, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
|
|
|
connect(m_checkbox_render_to_window, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
|
|
|
connect(m_combobox_theme, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::activated),
|
2017-05-31 17:15:48 -06:00
|
|
|
&Settings::Instance(), &Settings::SetThemeName);
|
2017-05-05 04:38:59 -06:00
|
|
|
connect(m_combobox_language, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
|
|
|
[this](int index) { OnSaveConfig(); });
|
2017-05-04 01:47:59 -06:00
|
|
|
connect(m_checkbox_confirm_on_stop, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
|
|
|
connect(m_checkbox_use_panic_handlers, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
|
|
|
connect(m_checkbox_enable_osd, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
|
|
|
connect(m_checkbox_pause_on_focus_lost, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
2017-06-01 00:49:06 -06:00
|
|
|
connect(m_checkbox_hide_mouse, &QCheckBox::clicked, &Settings::Instance(),
|
|
|
|
&Settings::SetHideCursor);
|
2017-05-04 01:47:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void InterfacePane::LoadConfig()
|
|
|
|
{
|
|
|
|
const SConfig& startup_params = SConfig::GetInstance();
|
|
|
|
m_checkbox_auto_window->setChecked(startup_params.bRenderWindowAutoSize);
|
|
|
|
m_checkbox_top_window->setChecked(startup_params.bKeepWindowOnTop);
|
|
|
|
m_checkbox_render_to_window->setChecked(startup_params.bRenderToMain);
|
2017-07-23 07:28:34 -06:00
|
|
|
m_checkbox_use_builtin_title_database->setChecked(startup_params.m_use_builtin_title_database);
|
2017-05-04 01:47:59 -06:00
|
|
|
m_combobox_theme->setCurrentIndex(
|
|
|
|
m_combobox_theme->findText(QString::fromStdString(SConfig::GetInstance().theme_name)));
|
|
|
|
|
|
|
|
// In Game Options
|
|
|
|
m_checkbox_confirm_on_stop->setChecked(startup_params.bConfirmStop);
|
|
|
|
m_checkbox_use_panic_handlers->setChecked(startup_params.bUsePanicHandlers);
|
|
|
|
m_checkbox_enable_osd->setChecked(startup_params.bOnScreenDisplayMessages);
|
2017-05-15 08:49:52 -06:00
|
|
|
m_checkbox_show_active_title->setChecked(startup_params.m_show_active_title);
|
2017-05-04 01:47:59 -06:00
|
|
|
m_checkbox_pause_on_focus_lost->setChecked(startup_params.m_PauseOnFocusLost);
|
2017-06-01 00:49:06 -06:00
|
|
|
m_checkbox_hide_mouse->setChecked(Settings::Instance().GetHideCursor());
|
2017-05-04 01:47:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void InterfacePane::OnSaveConfig()
|
|
|
|
{
|
|
|
|
SConfig& settings = SConfig::GetInstance();
|
|
|
|
settings.bRenderWindowAutoSize = m_checkbox_auto_window->isChecked();
|
|
|
|
settings.bKeepWindowOnTop = m_checkbox_top_window->isChecked();
|
|
|
|
settings.bRenderToMain = m_checkbox_render_to_window->isChecked();
|
2017-07-23 07:28:34 -06:00
|
|
|
settings.m_use_builtin_title_database = m_checkbox_use_builtin_title_database->isChecked();
|
2017-05-04 01:47:59 -06:00
|
|
|
|
|
|
|
// In Game Options
|
|
|
|
settings.bConfirmStop = m_checkbox_confirm_on_stop->isChecked();
|
|
|
|
settings.bUsePanicHandlers = m_checkbox_use_panic_handlers->isChecked();
|
|
|
|
settings.bOnScreenDisplayMessages = m_checkbox_enable_osd->isChecked();
|
2017-05-15 08:49:52 -06:00
|
|
|
settings.m_show_active_title = m_checkbox_show_active_title->isChecked();
|
2017-05-04 01:47:59 -06:00
|
|
|
settings.m_PauseOnFocusLost = m_checkbox_pause_on_focus_lost->isChecked();
|
|
|
|
|
|
|
|
settings.SaveSettings();
|
|
|
|
}
|