Merge pull request #6497 from spycrab/qt_file
Qt: Implement missing "File" menu items
This commit is contained in:
commit
305b3dc835
|
@ -28,6 +28,7 @@
|
||||||
#include "Core/Config/NetplaySettings.h"
|
#include "Core/Config/NetplaySettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Core/HW/DVD/DVDInterface.h"
|
||||||
#include "Core/HW/GCKeyboard.h"
|
#include "Core/HW/GCKeyboard.h"
|
||||||
#include "Core/HW/GCPad.h"
|
#include "Core/HW/GCPad.h"
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
|
@ -232,6 +233,10 @@ void MainWindow::ConnectMenuBar()
|
||||||
// File
|
// File
|
||||||
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
||||||
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
||||||
|
connect(m_menu_bar, &MenuBar::EjectDisc, this, &MainWindow::EjectDisc);
|
||||||
|
connect(m_menu_bar, &MenuBar::ChangeDisc, this, &MainWindow::ChangeDisc);
|
||||||
|
connect(m_menu_bar, &MenuBar::BootDVDBackup, this,
|
||||||
|
[this](const QString& drive) { StartGame(drive); });
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
|
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
|
||||||
|
@ -413,12 +418,30 @@ void MainWindow::ConnectStack()
|
||||||
tabifyDockWidget(m_log_widget, m_breakpoint_widget);
|
tabifyDockWidget(m_log_widget, m_breakpoint_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::Open()
|
QString MainWindow::PromptFileName()
|
||||||
{
|
{
|
||||||
QString file = QFileDialog::getOpenFileName(
|
return QFileDialog::getOpenFileName(
|
||||||
this, tr("Select a File"), QDir::currentPath(),
|
this, tr("Select a File"), QDir::currentPath(),
|
||||||
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.tgc *.wbfs *.ciso *.gcz *.wad);;"
|
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.tgc *.wbfs *.ciso *.gcz *.wad);;"
|
||||||
"All Files (*)"));
|
"All Files (*)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ChangeDisc()
|
||||||
|
{
|
||||||
|
QString file = PromptFileName();
|
||||||
|
|
||||||
|
if (!file.isEmpty())
|
||||||
|
Core::RunAsCPUThread([&file] { DVDInterface::ChangeDisc(file.toStdString()); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::EjectDisc()
|
||||||
|
{
|
||||||
|
Core::RunAsCPUThread(DVDInterface::EjectDisc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::Open()
|
||||||
|
{
|
||||||
|
QString file = PromptFileName();
|
||||||
if (!file.isEmpty())
|
if (!file.isEmpty())
|
||||||
StartGame(file);
|
StartGame(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,11 @@ private:
|
||||||
void OnExportRecording();
|
void OnExportRecording();
|
||||||
void ShowTASInput();
|
void ShowTASInput();
|
||||||
|
|
||||||
|
void ChangeDisc();
|
||||||
|
void EjectDisc();
|
||||||
|
|
||||||
|
QString PromptFileName();
|
||||||
|
|
||||||
void EnableScreenSaver(bool enable);
|
void EnableScreenSaver(bool enable);
|
||||||
|
|
||||||
void OnStopComplete();
|
void OnStopComplete();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
|
#include "Common/CDUtils.h"
|
||||||
#include "Core/Boot/Boot.h"
|
#include "Core/Boot/Boot.h"
|
||||||
#include "Core/CommonTitles.h"
|
#include "Core/CommonTitles.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
@ -74,6 +75,10 @@ void MenuBar::OnEmulationStateChanged(Core::State state)
|
||||||
bool running = state != Core::State::Uninitialized;
|
bool running = state != Core::State::Uninitialized;
|
||||||
bool playing = running && state != Core::State::Paused;
|
bool playing = running && state != Core::State::Paused;
|
||||||
|
|
||||||
|
// File
|
||||||
|
m_eject_disc->setEnabled(running);
|
||||||
|
m_change_disc->setEnabled(running);
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
m_play_action->setEnabled(!playing);
|
m_play_action->setEnabled(!playing);
|
||||||
m_play_action->setVisible(!playing);
|
m_play_action->setVisible(!playing);
|
||||||
|
@ -122,11 +127,34 @@ void MenuBar::OnDebugModeToggled(bool enabled)
|
||||||
removeAction(m_symbols->menuAction());
|
removeAction(m_symbols->menuAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuBar::AddDVDBackupMenu(QMenu* file_menu)
|
||||||
|
{
|
||||||
|
m_backup_menu = file_menu->addMenu(tr("Boot from DVD Backup"));
|
||||||
|
|
||||||
|
const std::vector<std::string> drives = cdio_get_devices();
|
||||||
|
// Windows Limitation of 24 character drives
|
||||||
|
for (size_t i = 0; i < drives.size() && i < 24; i++)
|
||||||
|
{
|
||||||
|
auto drive = QString::fromStdString(drives[i]);
|
||||||
|
AddAction(m_backup_menu, drive, this, [this, drive] { emit BootDVDBackup(drive); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuBar::AddFileMenu()
|
void MenuBar::AddFileMenu()
|
||||||
{
|
{
|
||||||
QMenu* file_menu = addMenu(tr("&File"));
|
QMenu* file_menu = addMenu(tr("&File"));
|
||||||
m_open_action = AddAction(file_menu, tr("&Open..."), this, &MenuBar::Open,
|
m_open_action = AddAction(file_menu, tr("&Open..."), this, &MenuBar::Open,
|
||||||
QKeySequence(QStringLiteral("Ctrl+O")));
|
QKeySequence(QStringLiteral("Ctrl+O")));
|
||||||
|
|
||||||
|
file_menu->addSeparator();
|
||||||
|
|
||||||
|
m_change_disc = AddAction(file_menu, tr("Change &Disc..."), this, &MenuBar::ChangeDisc);
|
||||||
|
m_eject_disc = AddAction(file_menu, tr("&Eject Disc"), this, &MenuBar::EjectDisc);
|
||||||
|
|
||||||
|
AddDVDBackupMenu(file_menu);
|
||||||
|
|
||||||
|
file_menu->addSeparator();
|
||||||
|
|
||||||
m_exit_action = AddAction(file_menu, tr("E&xit"), this, &MenuBar::Exit,
|
m_exit_action = AddAction(file_menu, tr("E&xit"), this, &MenuBar::Exit,
|
||||||
QKeySequence(QStringLiteral("Alt+F4")));
|
QKeySequence(QStringLiteral("Alt+F4")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ signals:
|
||||||
// File
|
// File
|
||||||
void Open();
|
void Open();
|
||||||
void Exit();
|
void Exit();
|
||||||
|
void ChangeDisc();
|
||||||
|
void BootDVDBackup(const QString& backup);
|
||||||
|
void EjectDisc();
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
void Play();
|
void Play();
|
||||||
|
@ -102,6 +105,7 @@ private:
|
||||||
void OnEmulationStateChanged(Core::State state);
|
void OnEmulationStateChanged(Core::State state);
|
||||||
|
|
||||||
void AddFileMenu();
|
void AddFileMenu();
|
||||||
|
void AddDVDBackupMenu(QMenu* file_menu);
|
||||||
|
|
||||||
void AddEmulationMenu();
|
void AddEmulationMenu();
|
||||||
void AddStateLoadMenu(QMenu* emu_menu);
|
void AddStateLoadMenu(QMenu* emu_menu);
|
||||||
|
@ -148,6 +152,9 @@ private:
|
||||||
// File
|
// File
|
||||||
QAction* m_open_action;
|
QAction* m_open_action;
|
||||||
QAction* m_exit_action;
|
QAction* m_exit_action;
|
||||||
|
QAction* m_change_disc;
|
||||||
|
QAction* m_eject_disc;
|
||||||
|
QMenu* m_backup_menu;
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
QAction* m_wad_install_action;
|
QAction* m_wad_install_action;
|
||||||
|
|
Loading…
Reference in New Issue