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 <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-07-16 15:25:36 -06:00
|
|
|
#include "DolphinQt2/QtUtils/ListTabWidget.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
|
|
|
|
2017-07-16 15:25:36 -06:00
|
|
|
static int AddTab(ListTabWidget* tab_widget, const QString& label, QWidget* widget,
|
|
|
|
const char* icon_name)
|
|
|
|
{
|
|
|
|
int index = tab_widget->addTab(widget, label);
|
|
|
|
auto set_icon = [=] { tab_widget->setTabIcon(index, Resources::GetScaledThemeIcon(icon_name)); };
|
|
|
|
QObject::connect(&Settings::Instance(), &Settings::ThemeChanged, set_icon);
|
|
|
|
set_icon();
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
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;
|
2016-05-09 07:34:07 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Add content to layout before dialog buttons.
|
2017-07-16 15:25:36 -06:00
|
|
|
m_tabs = new ListTabWidget();
|
|
|
|
layout->addWidget(m_tabs);
|
2017-06-21 02:27:21 -06:00
|
|
|
|
2017-07-16 15:25:36 -06:00
|
|
|
AddTab(m_tabs, tr("General"), new GeneralPane(), "config");
|
|
|
|
AddTab(m_tabs, tr("Interface"), new InterfacePane(), "browse");
|
2017-06-21 02:27:21 -06:00
|
|
|
auto* audio_pane = new AudioPane;
|
2017-07-16 15:11:11 -06:00
|
|
|
m_audio_pane_index = AddTab(m_tabs, tr("Audio"), audio_pane, "play");
|
2017-07-16 15:25:36 -06:00
|
|
|
AddTab(m_tabs, tr("Paths"), new PathPane(), "browse");
|
|
|
|
|
2017-06-21 02:27:21 -06:00
|
|
|
connect(this, &SettingsWindow::EmulationStarted,
|
|
|
|
[audio_pane] { audio_pane->OnEmulationStateChanged(true); });
|
|
|
|
connect(this, &SettingsWindow::EmulationStopped,
|
|
|
|
[audio_pane] { audio_pane->OnEmulationStateChanged(false); });
|
|
|
|
|
2017-07-16 15:25:36 -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
|
|
|
|
2017-07-16 15:25:36 -06:00
|
|
|
setLayout(layout);
|
2016-05-09 07:34:07 -06:00
|
|
|
}
|
2017-07-16 15:11:11 -06:00
|
|
|
|
|
|
|
void SettingsWindow::SelectAudioPane()
|
|
|
|
{
|
|
|
|
m_tabs->setCurrentIndex(m_audio_pane_index);
|
|
|
|
}
|