QT UI for setting
This commit is contained in:
parent
76ce6f02be
commit
5d3ba8af83
6 changed files with 132 additions and 15 deletions
|
|
@ -49,6 +49,9 @@ add_library(citra_qt STATIC EXCLUDE_FROM_ALL
|
|||
configuration/configure_layout.cpp
|
||||
configuration/configure_layout.h
|
||||
configuration/configure_layout.ui
|
||||
configuration/configure_layout_cycle.cpp
|
||||
configuration/configure_layout_cycle.h
|
||||
configuration/configure_layout_cycle.ui
|
||||
configuration/configure_dialog.cpp
|
||||
configuration/configure_dialog.h
|
||||
configuration/configure_general.cpp
|
||||
|
|
|
|||
|
|
@ -2681,13 +2681,21 @@ void GMainWindow::AdjustSpeedLimit(bool increase) {
|
|||
void GMainWindow::ToggleScreenLayout() {
|
||||
const Settings::LayoutOption new_layout = []() {
|
||||
const Settings::LayoutOption current_layout = Settings::values.layout_option.GetValue();
|
||||
const std::vector<Settings::LayoutOption> layouts_to_cycle = Settings::values.layouts_to_cycle.GetValue();
|
||||
const auto current_pos = distance(layouts_to_cycle.begin(),std::find(layouts_to_cycle.begin(),layouts_to_cycle.end(),current_layout));
|
||||
std::vector<Settings::LayoutOption> layouts_to_cycle =
|
||||
Settings::values.layouts_to_cycle.GetValue();
|
||||
const auto current_pos =
|
||||
distance(layouts_to_cycle.begin(),
|
||||
std::find(layouts_to_cycle.begin(), layouts_to_cycle.end(), current_layout));
|
||||
// if the layouts_to_cycle setting has somehow been
|
||||
// cleared out, add just default back in
|
||||
if (layouts_to_cycle.size() == 0) {
|
||||
layouts_to_cycle.push_back(Settings::LayoutOption::Default);
|
||||
}
|
||||
if (current_pos >= layouts_to_cycle.size() - 1) {
|
||||
// either this layout wasn't found or it was last so move to the beginning
|
||||
return layouts_to_cycle[0];
|
||||
}else {
|
||||
return layouts_to_cycle[current_pos+1];
|
||||
} else {
|
||||
return layouts_to_cycle[current_pos + 1];
|
||||
}
|
||||
}();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QtGlobal>
|
||||
#include "citra_qt/configuration/configuration_shared.h"
|
||||
#include "citra_qt/configuration/configure_layout.h"
|
||||
#include "citra_qt/configuration/configure_layout_cycle.h"
|
||||
#include "common/settings.h"
|
||||
#include "ui_configure_layout.h"
|
||||
#ifdef ENABLE_OPENGL
|
||||
|
|
@ -111,6 +112,13 @@ ConfigureLayout::ConfigureLayout(QWidget* parent)
|
|||
ui->bg_button->setIcon(color_icon);
|
||||
ui->bg_button->setEnabled(true);
|
||||
});
|
||||
|
||||
connect(ui->customize_layouts_to_cycle, &QPushButton::clicked, this, [this] {
|
||||
ui->customize_layouts_to_cycle->setEnabled(false);
|
||||
QDialog* layout_cycle_dialog = new ConfigureLayoutCycle(this);
|
||||
layout_cycle_dialog->exec();
|
||||
ui->customize_layouts_to_cycle->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
ConfigureLayout::~ConfigureLayout() = default;
|
||||
|
|
|
|||
67
src/citra_qt/configuration/configure_layout_cycle.cpp
Normal file
67
src/citra_qt/configuration/configure_layout_cycle.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QDialog>
|
||||
#include "citra_qt/configuration/configure_layout_cycle.h"
|
||||
#include "ui_configure_layout_cycle.h"
|
||||
|
||||
ConfigureLayoutCycle::ConfigureLayoutCycle(QWidget* parent)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureLayoutCycle>()) {
|
||||
ui->setupUi(this);
|
||||
SetConfiguration();
|
||||
ConnectEvents();
|
||||
}
|
||||
|
||||
// You MUST define the destructor in the .cpp file
|
||||
ConfigureLayoutCycle::~ConfigureLayoutCycle() = default;
|
||||
|
||||
void ConfigureLayoutCycle::ConnectEvents() {
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
|
||||
&ConfigureLayoutCycle::ApplyConfiguration);
|
||||
}
|
||||
|
||||
void ConfigureLayoutCycle::SetConfiguration() {
|
||||
for (auto option : Settings::values.layouts_to_cycle.GetValue()) {
|
||||
switch (option) {
|
||||
case Settings::LayoutOption::Default:
|
||||
ui->defaultCheck->setChecked(true);
|
||||
break;
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
ui->singleCheck->setChecked(true);
|
||||
break;
|
||||
case Settings::LayoutOption::LargeScreen:
|
||||
ui->largeCheck->setChecked(true);
|
||||
break;
|
||||
case Settings::LayoutOption::SideScreen:
|
||||
ui->sidebysideCheck->setChecked(true);
|
||||
break;
|
||||
case Settings::LayoutOption::SeparateWindows:
|
||||
ui->separateCheck->setChecked(true);
|
||||
break;
|
||||
case Settings::LayoutOption::HybridScreen:
|
||||
ui->hybridCheck->setChecked(true);
|
||||
break;
|
||||
case Settings::LayoutOption::CustomLayout:
|
||||
ui->customCheck->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureLayoutCycle::ApplyConfiguration() {
|
||||
std::vector<Settings::LayoutOption> newSetting{};
|
||||
if (ui->defaultCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::Default);
|
||||
if (ui->singleCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::SingleScreen);
|
||||
if (ui->sidebysideCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::SideScreen);
|
||||
if (ui->largeCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::LargeScreen);
|
||||
if (ui->separateCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::SeparateWindows);
|
||||
if (ui->hybridCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::HybridScreen);
|
||||
if (ui->customCheck->isChecked())
|
||||
newSetting.push_back(Settings::LayoutOption::CustomLayout);
|
||||
Settings::values.layouts_to_cycle = newSetting;
|
||||
accept();
|
||||
}
|
||||
31
src/citra_qt/configuration/configure_layout_cycle.h
Normal file
31
src/citra_qt/configuration/configure_layout_cycle.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2018 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
#include "common/settings.h"
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureLayoutCycle;
|
||||
}
|
||||
|
||||
class ConfigureLayoutCycle : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureLayoutCycle(QWidget* parent = nullptr);
|
||||
~ConfigureLayoutCycle() override;
|
||||
|
||||
public slots:
|
||||
void ApplyConfiguration();
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
void SetConfiguration();
|
||||
void ConnectEvents();
|
||||
|
||||
std::unique_ptr<Ui::ConfigureLayoutCycle> ui;
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<class>ConfigureLayoutCycle</class>
|
||||
<widget class="QDialog" name="ConfigureLayoutCycle">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
<string>Default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -84,7 +84,7 @@
|
|||
<string>Single Screen</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
<string>Large Screen</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<string>Side by Side</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
<string>Separate Windows</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -124,7 +124,7 @@
|
|||
<string>Hybrid</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -134,7 +134,7 @@
|
|||
<string>Custom</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<receiver>ConfigureLayoutCycle</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
|
@ -174,7 +174,7 @@
|
|||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<receiver>ConfigureLayoutCycle</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue