dolphin/Source/Core/DolphinQt2/Config/SettingsWindow.cpp

78 lines
2.5 KiB
C++
Raw Normal View History

// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
2017-05-31 23:53:46 +00:00
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include "DolphinQt2/Config/SettingsWindow.h"
2017-06-21 08:27:21 +00:00
#include "DolphinQt2/MainWindow.h"
#include "DolphinQt2/QtUtils/ListTabWidget.h"
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"
2017-06-28 04:36:27 +00:00
#include "DolphinQt2/Settings/AdvancedPane.h"
2017-06-21 08:27:21 +00:00
#include "DolphinQt2/Settings/AudioPane.h"
2018-01-04 00:41:31 +00:00
#include "DolphinQt2/Settings/GameCubePane.h"
#include "DolphinQt2/Settings/GeneralPane.h"
#include "DolphinQt2/Settings/InterfacePane.h"
#include "DolphinQt2/Settings/PathPane.h"
#include "DolphinQt2/Settings/WiiPane.h"
#include "Core/Core.h"
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;
}
SettingsWindow::SettingsWindow(QWidget* parent) : QDialog(parent)
{
// Set Window Properties
setWindowTitle(tr("Settings"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
// Main Layout
QVBoxLayout* layout = new QVBoxLayout;
// Add content to layout before dialog buttons.
m_tabs = new ListTabWidget();
layout->addWidget(m_tabs);
2017-06-21 08:27:21 +00:00
m_general_pane_index = AddTab(m_tabs, tr("General"), new GeneralPane(), "config");
AddTab(m_tabs, tr("Interface"), new InterfacePane(), "browse");
m_audio_pane_index = AddTab(m_tabs, tr("Audio"), new AudioPane(), "play");
2018-01-04 00:41:31 +00:00
AddTab(m_tabs, tr("GameCube"), new GameCubePane(), "gcpad");
AddTab(m_tabs, tr("Paths"), new PathPane(), "browse");
auto* wii_pane = new WiiPane;
AddTab(m_tabs, tr("Wii"), wii_pane, "wiimote");
connect(&Settings::Instance(), &Settings::EmulationStateChanged, [wii_pane](Core::State state) {
wii_pane->OnEmulationStateChanged(state != Core::State::Uninitialized);
});
2017-06-28 04:36:27 +00:00
AddTab(m_tabs, tr("Advanced"), new AdvancedPane(), "config");
// Dialog box buttons
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(ok_box, &QDialogButtonBox::accepted, this, &SettingsWindow::accept);
layout->addWidget(ok_box);
setLayout(layout);
}
void SettingsWindow::SelectAudioPane()
{
m_tabs->setCurrentIndex(m_audio_pane_index);
}
void SettingsWindow::SelectGeneralPane()
{
m_tabs->setCurrentIndex(m_general_pane_index);
}