Added 3DS controls in main window.

This commit is contained in:
RedTrainer97 2017-03-30 16:26:29 +02:00
parent d78c87e3db
commit ef56b7dcc7
7 changed files with 211 additions and 33 deletions

View File

@ -168,6 +168,7 @@ void Config::ReadValues() {
qt_config->endGroup();
UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool();
UISettings::values.show_3DS_controls = qt_config->value("show3dsControls", true).toBool();
UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool();
UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool();
UISettings::values.confirm_before_closing = qt_config->value("confirmClose", true).toBool();
@ -278,6 +279,7 @@ void Config::SaveValues() {
qt_config->endGroup();
qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode);
qt_config->setValue("show3dsControls", UISettings::values.single_window_mode);
qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar);
qt_config->setValue("showStatusBar", UISettings::values.show_status_bar);
qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing);

View File

@ -51,7 +51,6 @@ void ConfigureAudio::setConfiguration() {
}
}
ui->audio_device_combo_box->setCurrentIndex(new_device_index);
ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum());
}
void ConfigureAudio::applyConfiguration() {
@ -62,8 +61,6 @@ void ConfigureAudio::applyConfiguration() {
Settings::values.audio_device_id =
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
.toStdString();
Settings::values.volume = (float)ui->volume_slider->value() / ui->volume_slider->maximum();
Settings::Apply();
}

View File

@ -50,33 +50,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Volume:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="volume_slider">
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View File

@ -69,6 +69,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
ConnectMenuEvents();
ConnectWidgetEvents();
ui.centralwidget->setStyleSheet("background-color: white;");
setWindowTitle(QString("Citra %1| %2-%3")
.arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
show();
@ -79,6 +81,10 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
if (args.length() >= 2) {
BootGame(args[1]);
}
volume_slider = ui.centralwidget->findChild<QSlider*>("volume_slider");
volume_slider->setValue(Settings::values.volume * volume_slider->maximum());
connect(volume_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateVolume()));
}
GMainWindow::~GMainWindow() {
@ -93,6 +99,15 @@ void GMainWindow::InitializeWidgets() {
render_window = new GRenderWindow(this, emu_thread.get());
render_window->hide();
left_widget = ui.centralwidget->findChild<QWidget*>("left_widget");
left_widget->hide();
central_widget = ui.centralwidget->findChild<QWidget*>("central_widget");
central_widget->hide();
right_widget = ui.centralwidget->findChild<QWidget*>("right_widget");
right_widget->hide();
game_list = new GameList();
ui.horizontalLayout->addWidget(game_list);
@ -243,6 +258,8 @@ void GMainWindow::RestoreUIState() {
ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
ToggleWindowMode();
ui.action_Show_3DS_Controls->setChecked(UISettings::values.show_3DS_controls);
ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar);
OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked());
@ -280,6 +297,8 @@ void GMainWindow::ConnectMenuEvents() {
// View
connect(ui.action_Single_Window_Mode, &QAction::triggered, this,
&GMainWindow::ToggleWindowMode);
connect(ui.action_Show_3DS_Controls, &QAction::triggered, this,
&GMainWindow::Toggle3dsControls);
connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this,
&GMainWindow::OnDisplayTitleBars);
connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible);
@ -412,6 +431,11 @@ void GMainWindow::BootGame(const QString& filename) {
render_window->show();
render_window->setFocus();
central_widget->show();
if (ui.action_Show_3DS_Controls->isChecked()) {
left_widget->show();
right_widget->show();
}
emulation_running = true;
OnStartGame();
@ -442,6 +466,9 @@ void GMainWindow::ShutdownGame() {
ui.action_Pause->setEnabled(false);
ui.action_Stop->setEnabled(false);
render_window->hide();
left_widget->hide();
central_widget->hide();
right_widget->hide();
game_list->show();
// Disable status bar updates
@ -586,7 +613,7 @@ void GMainWindow::ToggleWindowMode() {
if (ui.action_Single_Window_Mode->isChecked()) {
// Render in the main window...
render_window->BackupGeometry();
ui.horizontalLayout->addWidget(render_window);
ui.centralwidget->findChild<QWidget*>("central_widget")->layout()->addWidget(render_window);
render_window->setFocusPolicy(Qt::ClickFocus);
if (emulation_running) {
render_window->setVisible(true);
@ -596,7 +623,9 @@ void GMainWindow::ToggleWindowMode() {
} else {
// Render in a separate window...
ui.horizontalLayout->removeWidget(render_window);
ui.centralwidget->findChild<QWidget*>("central_widget")
->layout()
->removeWidget(render_window);
render_window->setParent(nullptr);
render_window->setFocusPolicy(Qt::NoFocus);
if (emulation_running) {
@ -607,6 +636,18 @@ void GMainWindow::ToggleWindowMode() {
}
}
void GMainWindow::Toggle3dsControls() {
if (ui.action_Show_3DS_Controls->isChecked()) {
if (emulation_running) {
left_widget->show();
right_widget->show();
}
} else {
left_widget->hide();
right_widget->hide();
}
}
void GMainWindow::OnConfigure() {
ConfigureDialog configureDialog(this);
auto result = configureDialog.exec();
@ -669,6 +710,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
UISettings::values.microprofile_visible = microProfileDialog->isVisible();
#endif
UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked();
UISettings::values.show_3DS_controls = ui.action_Show_3DS_Controls->isChecked();
UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked();
UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked();
UISettings::values.first_start = false;
@ -681,6 +723,8 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
ShutdownGame();
render_window->close();
left_widget->close();
right_widget->close();
QWidget::closeEvent(event);
}
@ -719,6 +763,10 @@ bool GMainWindow::ConfirmChangeGame() {
return answer != QMessageBox::No;
}
void GMainWindow::UpdateVolume() {
Settings::values.volume = (float)volume_slider->value() / volume_slider->maximum();
}
#ifdef main
#undef main
#endif

View File

@ -125,6 +125,8 @@ private slots:
void OnDisplayTitleBars(bool);
void ToggleWindowMode();
void OnCreateGraphicsSurfaceViewer();
void Toggle3dsControls();
void UpdateVolume();
private:
void UpdateStatusBar();
@ -133,6 +135,9 @@ private:
GRenderWindow* render_window;
GameList* game_list;
QWidget* left_widget;
QWidget* central_widget;
QWidget* right_widget;
// Status bar elements
QLabel* emu_speed_label = nullptr;
@ -161,6 +166,8 @@ private:
QAction* actions_recent_files[max_recent_files_item];
QSlider* volume_slider;
protected:
void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;

View File

@ -37,6 +37,146 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="left_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Volume</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QSlider" name="volume_slider">
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="central_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="right_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="wifi_check_box">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>WiFi</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>3D</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QSlider" name="three_d_slider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
@ -45,7 +185,7 @@
<x>0</x>
<y>0</y>
<width>1081</width>
<height>19</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@ -88,6 +228,7 @@
</widget>
<addaction name="action_Single_Window_Mode"/>
<addaction name="action_Display_Dock_Widget_Headers"/>
<addaction name="action_Show_3DS_Controls"/>
<addaction name="action_Show_Status_Bar"/>
<addaction name="menu_View_Debugging"/>
</widget>
@ -188,6 +329,15 @@
<string>Create Pica Surface Viewer</string>
</property>
</action>
<action name="action_Show_3DS_Controls">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show 3DS Controls</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -26,6 +26,7 @@ struct Values {
bool microprofile_visible;
bool single_window_mode;
bool show_3DS_controls;
bool display_titlebar;
bool show_status_bar;