From fe094cae2844b9d573efae9743f563208bda39e4 Mon Sep 17 00:00:00 2001 From: Styleoshin Date: Sun, 24 Sep 2017 16:03:08 +0100 Subject: [PATCH] citra-qt : Implementing toolbar events --- src/citra_qt/main.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ src/citra_qt/main.h | 1 + src/citra_qt/main.ui | 12 +++++++++--- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 8adbcfe86..74d8f63cb 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -105,6 +105,7 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { ConnectMenuEvents(); ConnectWidgetEvents(); + ConnectToolbarEvents(); setWindowTitle(QString("Citra %1| %2-%3") .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); @@ -325,6 +326,37 @@ void GMainWindow::ConnectMenuEvents() { connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); } +void GMainWindow::ConnectToolbarEvents(){ + // File + connect(ui.action_Toolbar_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); + + // Toggle fullscreen + connect(ui.action_Toolbar_Toggle_Fullscreen, &QAction::triggered, this, [this] { + if (isFullScreen()) { + showNormal(); + ui.action_Toolbar_Toggle_Fullscreen->setIcon(QIcon(":toolbar_icons/rc/fullscreen.png")); + } else { + showFullScreen(); + ui.action_Toolbar_Toggle_Fullscreen->setIcon(QIcon(":toolbar_icons/rc/fullscreen_exit.png")); + } + } ); + + // Emulation + connect(ui.action_Toolbar_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame); + connect(ui.action_Toolbar_Start_Pause, &QAction::triggered, this, [this] { + if (emulation_running) { + OnPauseGame(); + emulation_running = false; + } else { + OnStartGame(); + emulation_running = true; + } + } ); + + // Configure + connect(ui.action_Toolbar_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); +} + void GMainWindow::OnDisplayTitleBars(bool show) { QList widgets = findChildren(); @@ -483,6 +515,10 @@ void GMainWindow::ShutdownGame() { disconnect(render_window, SIGNAL(Closed()), this, SLOT(OnStopGame())); // Update the GUI + ui.action_Toolbar_Start_Pause->setEnabled(false); + ui.action_Toolbar_Start_Pause->setIcon(QIcon(":toolbar_icons/rc/play.png")); + ui.action_Toolbar_Start_Pause->setToolTip(tr("Start")); + ui.action_Toolbar_Stop->setEnabled(false); ui.action_Start->setEnabled(false); ui.action_Start->setText(tr("Start")); ui.action_Pause->setEnabled(false); @@ -610,6 +646,12 @@ void GMainWindow::OnStartGame() { ui.action_Pause->setEnabled(true); ui.action_Stop->setEnabled(true); + + ui.action_Toolbar_Start_Pause->setEnabled(true); + ui.action_Toolbar_Start_Pause->setIcon(QIcon(":toolbar_icons/rc/pause.png")); + ui.action_Toolbar_Start_Pause->setToolTip(tr("Pause")); + + ui.action_Toolbar_Stop->setEnabled(true); } void GMainWindow::OnPauseGame() { @@ -618,6 +660,9 @@ void GMainWindow::OnPauseGame() { ui.action_Start->setEnabled(true); ui.action_Pause->setEnabled(false); ui.action_Stop->setEnabled(true); + + ui.action_Toolbar_Start_Pause->setIcon(QIcon(":toolbar_icons/rc/play.png")); + ui.action_Toolbar_Start_Pause->setToolTip(tr("Continue")); } void GMainWindow::OnStopGame() { diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index d59a6d67d..4f9219850 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -75,6 +75,7 @@ private: void ConnectWidgetEvents(); void ConnectMenuEvents(); + void ConnectToolbarEvents(); bool LoadROM(const QString& filename); void BootGame(const QString& filename); diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 666ac57c5..39ff1b739 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -103,13 +103,16 @@ + + true + Toolbar - 30 - 28 + 35 + 30 @@ -248,6 +251,9 @@ + + false + :/toolbar_icons/rc/start.png:/toolbar_icons/rc/start.png @@ -276,7 +282,7 @@ - false + true