2016-05-09 07:34:07 -06:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-05-31 17:53:46 -06:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListWidget>
|
2017-06-20 20:18:34 -06:00
|
|
|
#include <QScrollBar>
|
2017-05-31 17:53:46 -06:00
|
|
|
#include <QStackedWidget>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2016-05-09 07:34:07 -06:00
|
|
|
#include "DolphinQt2/Config/SettingsWindow.h"
|
2017-06-21 02:27:21 -06:00
|
|
|
#include "DolphinQt2/MainWindow.h"
|
2017-06-05 01:15:15 -06:00
|
|
|
#include "DolphinQt2/Resources.h"
|
2017-05-04 01:47:59 -06:00
|
|
|
#include "DolphinQt2/Settings.h"
|
2017-06-21 02:27:21 -06:00
|
|
|
#include "DolphinQt2/Settings/AudioPane.h"
|
2017-05-03 22:19:51 -06:00
|
|
|
#include "DolphinQt2/Settings/GeneralPane.h"
|
2017-05-04 01:47:59 -06:00
|
|
|
#include "DolphinQt2/Settings/InterfacePane.h"
|
2017-05-31 02:08:04 -06:00
|
|
|
#include "DolphinQt2/Settings/PathPane.h"
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
SettingsWindow::SettingsWindow(QWidget* parent) : QDialog(parent)
|
2016-05-09 07:34:07 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// Set Window Properties
|
|
|
|
setWindowTitle(tr("Settings"));
|
2017-06-29 18:52:53 -06:00
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Main Layout
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
|
|
|
QHBoxLayout* content = new QHBoxLayout;
|
|
|
|
// Content's widgets
|
|
|
|
{
|
|
|
|
// Category list
|
|
|
|
MakeCategoryList();
|
|
|
|
content->addWidget(m_categories);
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Actual Settings UI
|
|
|
|
SetupSettingsWidget();
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2017-06-20 16:00:49 -06:00
|
|
|
content->addWidget(m_settings_outer);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Add content to layout before dialog buttons.
|
|
|
|
layout->addLayout(content);
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Dialog box buttons
|
|
|
|
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
|
|
|
connect(ok_box, &QDialogButtonBox::accepted, this, &SettingsWindow::accept);
|
|
|
|
layout->addWidget(ok_box);
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
setLayout(layout);
|
2016-05-09 07:34:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::SetupSettingsWidget()
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
m_settings_outer = new QStackedWidget;
|
|
|
|
m_settings_outer->setCurrentIndex(0);
|
2017-05-04 01:47:59 -06:00
|
|
|
|
2017-05-03 22:19:51 -06:00
|
|
|
// Panes initalised here
|
|
|
|
m_settings_outer->addWidget(new GeneralPane);
|
2017-05-04 01:47:59 -06:00
|
|
|
m_settings_outer->addWidget(new InterfacePane);
|
2017-06-21 02:27:21 -06:00
|
|
|
|
|
|
|
auto* audio_pane = new AudioPane;
|
|
|
|
connect(this, &SettingsWindow::EmulationStarted,
|
|
|
|
[audio_pane] { audio_pane->OnEmulationStateChanged(true); });
|
|
|
|
connect(this, &SettingsWindow::EmulationStopped,
|
|
|
|
[audio_pane] { audio_pane->OnEmulationStateChanged(false); });
|
|
|
|
m_settings_outer->addWidget(audio_pane);
|
|
|
|
|
2017-05-31 02:08:04 -06:00
|
|
|
m_settings_outer->addWidget(new PathPane);
|
2016-05-09 07:34:07 -06:00
|
|
|
}
|
|
|
|
|
2017-06-05 01:15:15 -06:00
|
|
|
void SettingsWindow::AddCategoryToList(const QString& title, const std::string& icon_name)
|
2016-05-09 07:34:07 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
QListWidgetItem* button = new QListWidgetItem();
|
|
|
|
button->setText(title);
|
|
|
|
button->setTextAlignment(Qt::AlignVCenter);
|
|
|
|
button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
2017-06-05 01:15:15 -06:00
|
|
|
|
|
|
|
auto set_icon = [=] { button->setIcon(Resources::GetScaledThemeIcon(icon_name)); };
|
|
|
|
QObject::connect(&Settings::Instance(), &Settings::ThemeChanged, set_icon);
|
|
|
|
set_icon();
|
2016-06-24 02:43:46 -06:00
|
|
|
m_categories->addItem(button);
|
2016-05-09 07:34:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::MakeCategoryList()
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
m_categories = new QListWidget;
|
|
|
|
m_categories->setIconSize(QSize(32, 32));
|
|
|
|
m_categories->setMovement(QListView::Static);
|
|
|
|
m_categories->setSpacing(0);
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2017-06-05 01:15:15 -06:00
|
|
|
AddCategoryToList(tr("General"), "config");
|
|
|
|
AddCategoryToList(tr("Interface"), "browse");
|
2017-06-21 02:27:21 -06:00
|
|
|
AddCategoryToList(tr("Audio"), "play");
|
2017-06-05 01:15:15 -06:00
|
|
|
AddCategoryToList(tr("Paths"), "browse");
|
2016-06-24 02:43:46 -06:00
|
|
|
connect(m_categories, &QListWidget::currentItemChanged, this, &SettingsWindow::changePage);
|
2017-06-20 20:18:34 -06:00
|
|
|
|
|
|
|
m_categories->setFixedWidth(m_categories->sizeHintForColumn(0) +
|
|
|
|
m_categories->verticalScrollBar()->sizeHint().width() +
|
|
|
|
2 * m_categories->frameWidth());
|
2016-05-09 07:34:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsWindow::changePage(QListWidgetItem* current, QListWidgetItem* previous)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!current)
|
|
|
|
current = previous;
|
|
|
|
m_settings_outer->setCurrentIndex(m_categories->row(current));
|
2016-05-09 07:34:07 -06:00
|
|
|
}
|