Qt: Add option to switch/change discs from physical device
This commit is contained in:
parent
0af334bba5
commit
96fb81733d
|
@ -504,22 +504,24 @@ void MainWindow::onStartFileActionTriggered()
|
|||
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(filename.toStdString()));
|
||||
}
|
||||
|
||||
void MainWindow::onStartDiscActionTriggered()
|
||||
std::string MainWindow::getDeviceDiscPath(const QString& title)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
const auto devices = CDImage::GetDeviceList();
|
||||
if (devices.empty())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Start Disc"),
|
||||
QMessageBox::critical(this, title,
|
||||
tr("Could not find any CD-ROM devices. Please ensure you have a CD-ROM drive connected and "
|
||||
"sufficient permissions to access it."));
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// if there's only one, select it automatically
|
||||
if (devices.size() == 1)
|
||||
{
|
||||
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(std::move(devices.front().first)));
|
||||
return;
|
||||
ret = std::move(devices.front().first);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList input_options;
|
||||
|
@ -527,19 +529,30 @@ void MainWindow::onStartDiscActionTriggered()
|
|||
input_options.append(tr("%1 (%2)").arg(QString::fromStdString(name)).arg(QString::fromStdString(path)));
|
||||
|
||||
QInputDialog input_dialog(this);
|
||||
input_dialog.setWindowTitle(title);
|
||||
input_dialog.setLabelText(tr("Select disc drive:"));
|
||||
input_dialog.setInputMode(QInputDialog::TextInput);
|
||||
input_dialog.setOptions(QInputDialog::UseListViewForComboBoxItems);
|
||||
input_dialog.setComboBoxEditable(false);
|
||||
input_dialog.setComboBoxItems(std::move(input_options));
|
||||
if (input_dialog.exec() == 0)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
const int selected_index = input_dialog.comboBoxItems().indexOf(input_dialog.textValue());
|
||||
if (selected_index < 0 || static_cast<u32>(selected_index) >= devices.size())
|
||||
return ret;
|
||||
|
||||
ret = std::move(devices[selected_index].first);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MainWindow::onStartDiscActionTriggered()
|
||||
{
|
||||
std::string path(getDeviceDiscPath(tr("Start Disc")));
|
||||
if (path.empty())
|
||||
return;
|
||||
|
||||
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(std::move(devices[selected_index].first)));
|
||||
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(std::move(path)));
|
||||
}
|
||||
|
||||
void MainWindow::onStartBIOSActionTriggered()
|
||||
|
@ -563,6 +576,15 @@ void MainWindow::onChangeDiscFromGameListActionTriggered()
|
|||
switchToGameListView();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeDiscFromDeviceActionTriggered()
|
||||
{
|
||||
std::string path(getDeviceDiscPath(tr("Change Disc")));
|
||||
if (path.empty())
|
||||
return;
|
||||
|
||||
m_host_interface->changeDisc(QString::fromStdString(path));
|
||||
}
|
||||
|
||||
void MainWindow::onChangeDiscMenuAboutToShow()
|
||||
{
|
||||
m_host_interface->populateChangeDiscSubImageMenu(m_ui.menuChangeDisc, m_ui.actionGroupChangeDiscSubImages);
|
||||
|
@ -1080,6 +1102,8 @@ void MainWindow::connectSignals()
|
|||
&QtHostInterface::resumeSystemFromMostRecentState);
|
||||
connect(m_ui.actionChangeDisc, &QAction::triggered, [this] { m_ui.menuChangeDisc->exec(QCursor::pos()); });
|
||||
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
|
||||
connect(m_ui.actionChangeDiscFromDevice, &QAction::triggered, this,
|
||||
&MainWindow::onChangeDiscFromDeviceActionTriggered);
|
||||
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
||||
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
||||
connect(m_ui.menuChangeDisc, &QMenu::aboutToShow, this, &MainWindow::onChangeDiscMenuAboutToShow);
|
||||
|
|
|
@ -82,6 +82,7 @@ private Q_SLOTS:
|
|||
void onStartBIOSActionTriggered();
|
||||
void onChangeDiscFromFileActionTriggered();
|
||||
void onChangeDiscFromGameListActionTriggered();
|
||||
void onChangeDiscFromDeviceActionTriggered();
|
||||
void onChangeDiscMenuAboutToShow();
|
||||
void onChangeDiscMenuAboutToHide();
|
||||
void onLoadStateMenuAboutToShow();
|
||||
|
@ -147,6 +148,7 @@ private:
|
|||
void updateDebugMenuGPURenderer();
|
||||
void updateDebugMenuCropMode();
|
||||
void ensureGameListLoaded();
|
||||
std::string getDeviceDiscPath(const QString& title);
|
||||
|
||||
Ui::MainWindow m_ui;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
||||
</property>
|
||||
<addaction name="actionChangeDiscFromFile"/>
|
||||
<addaction name="actionChangeDiscFromDevice"/>
|
||||
<addaction name="actionChangeDiscFromGameList"/>
|
||||
<addaction name="actionRemoveDisc"/>
|
||||
<actiongroup name="actionGroupChangeDiscSubImages" />
|
||||
|
@ -602,6 +603,11 @@
|
|||
<string>From File...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChangeDiscFromDevice">
|
||||
<property name="text">
|
||||
<string>From Device...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChangeDiscFromGameList">
|
||||
<property name="text">
|
||||
<string>From Game List...</string>
|
||||
|
|
Loading…
Reference in New Issue