From b0dabc6a4054018bda6943ea5c82a26d218d57ae Mon Sep 17 00:00:00 2001 From: TotalCaesar659 <14265316+TotalCaesar659@users.noreply.github.com> Date: Sun, 12 Apr 2020 20:12:42 +0300 Subject: [PATCH] Update "File" menu to match Windows version --- Qt/mainwindow.cpp | 35 ++++++++++++++++++++++++++++------- Qt/mainwindow.h | 6 ++++-- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index 7103290f1d93..19aae3108259 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -80,6 +80,13 @@ void MainWindow::newFrame() void MainWindow::updateMenus() { + foreach(QAction * action, saveStateGroup->actions()) { + if (g_Config.iCurrentStateSlot == action->data().toInt()) { + action->setChecked(true); + break; + } + } + foreach(QAction * action, displayRotationGroup->actions()) { if (g_Config.iInternalScreenRotation == action->data().toInt()) { action->setChecked(true); @@ -165,7 +172,7 @@ void MainWindow::bootDone() } /* SIGNALS */ -void MainWindow::openAct() +void MainWindow::loadAct() { QString filename = QFileDialog::getOpenFileName(NULL, "Load File", g_Config.currentDirectory.c_str(), "PSP ROMs (*.pbp *.elf *.iso *.cso *.prx)"); if (QFile::exists(filename)) @@ -184,6 +191,13 @@ void MainWindow::closeAct() SetGameTitle(""); } +void MainWindow::openmsAct() +{ + QString confighome = getenv("XDG_CONFIG_HOME"); + QString memorystick = confighome + "/ppsspp/PSP"; + QDesktopServices::openUrl(QUrl(memorystick)); +} + void SaveStateActionFinished(SaveState::Status status, const std::string &message, void *userdata) { // TODO: Improve messaging? @@ -508,21 +522,28 @@ void MainWindow::createMenus() { // File MenuTree* fileMenu = new MenuTree(this, menuBar(), QT_TR_NOOP("&File")); - fileMenu->add(new MenuAction(this, SLOT(openAct()), QT_TR_NOOP("&Open..."), QKeySequence::Open)) + fileMenu->add(new MenuAction(this, SLOT(loadAct()), QT_TR_NOOP("&Load..."))) ->addEnableState(UISTATE_MENU); fileMenu->add(new MenuAction(this, SLOT(closeAct()), QT_TR_NOOP("&Close"), QKeySequence::Close)) ->addDisableState(UISTATE_MENU); fileMenu->addSeparator(); - fileMenu->add(new MenuAction(this, SLOT(qlstateAct()), QT_TR_NOOP("Quickload State"), Qt::Key_F4)) + fileMenu->add(new MenuAction(this, SLOT(openmsAct()), QT_TR_NOOP("Open &Memory stick"))) + ->addEnableState(UISTATE_MENU); + fileMenu->addSeparator(); + MenuTree* savestateMenu = new MenuTree(this, fileMenu, QT_TR_NOOP("Saves&tate slot")); + saveStateGroup = new MenuActionGroup(this, savestateMenu, SLOT(saveStateGroup_triggered(QAction *)), + QStringList() << "1" << "2" << "3" << "4" << "5", + QList() << 0 << 1 << 2 << 3 << 4); + fileMenu->add(new MenuAction(this, SLOT(qlstateAct()), QT_TR_NOOP("L&oad state"), Qt::Key_F4)) ->addDisableState(UISTATE_MENU); - fileMenu->add(new MenuAction(this, SLOT(qsstateAct()), QT_TR_NOOP("Quicksave State"), Qt::Key_F2)) + fileMenu->add(new MenuAction(this, SLOT(qsstateAct()), QT_TR_NOOP("S&ave state"), Qt::Key_F2)) ->addDisableState(UISTATE_MENU); - fileMenu->add(new MenuAction(this, SLOT(lstateAct()), QT_TR_NOOP("&Load State File..."))) + fileMenu->add(new MenuAction(this, SLOT(lstateAct()), QT_TR_NOOP("&Load state file..."))) ->addDisableState(UISTATE_MENU); - fileMenu->add(new MenuAction(this, SLOT(sstateAct()), QT_TR_NOOP("&Save State File..."))) + fileMenu->add(new MenuAction(this, SLOT(sstateAct()), QT_TR_NOOP("&Save state file..."))) ->addDisableState(UISTATE_MENU); fileMenu->addSeparator(); - fileMenu->add(new MenuAction(this, SLOT(exitAct()), QT_TR_NOOP("E&xit"), QKeySequence::Quit)); + fileMenu->add(new MenuAction(this, SLOT(exitAct()), QT_TR_NOOP("E&xit"), Qt::ALT + Qt::Key_F4)); // Emulation MenuTree* emuMenu = new MenuTree(this, menuBar(), QT_TR_NOOP("&Emulation")); diff --git a/Qt/mainwindow.h b/Qt/mainwindow.h index 95df4e9b11a6..6d2b1755cc25 100644 --- a/Qt/mainwindow.h +++ b/Qt/mainwindow.h @@ -68,8 +68,10 @@ public slots: private slots: // File - void openAct(); + void loadAct(); void closeAct(); + void openmsAct(); + void saveStateGroup_triggered(QAction *action) { g_Config.iCurrentStateSlot = action->data().toInt(); } void qlstateAct(); void qsstateAct(); void lstateAct(); @@ -178,7 +180,7 @@ private slots: *screenScalingFilterGroup, *textureFilteringGroup, *frameSkippingTypeGroup, *frameSkippingGroup, *renderingModeGroup, *renderingResolutionGroup, - *displayRotationGroup; + *displayRotationGroup, *saveStateGroup; std::queue msgQueue_; std::mutex msgMutex_;