mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 00:35:46 -04:00
BIOS: Add option to set search directory elsewhere
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "biossettingswidget.h"
|
||||
#include "core/bios.h"
|
||||
#include "qthostinterface.h"
|
||||
#include "qtutils.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "settingwidgetbinder.h"
|
||||
#include <QtWidgets/QFileDialog>
|
||||
@ -9,6 +10,9 @@
|
||||
static void populateDropDownForRegion(ConsoleRegion region, QComboBox* cb,
|
||||
std::vector<std::pair<std::string, const BIOS::ImageInfo*>>& images)
|
||||
{
|
||||
QSignalBlocker sb(cb);
|
||||
cb->clear();
|
||||
|
||||
cb->addItem(QIcon(QStringLiteral(":/icons/system-search.png")),
|
||||
QT_TRANSLATE_NOOP("BIOSSettingsWidget", "Auto-Detect"));
|
||||
|
||||
@ -94,14 +98,7 @@ BIOSSettingsWidget::BIOSSettingsWidget(QtHostInterface* host_interface, QWidget*
|
||||
tr("Patches the BIOS to skip the console's boot animation. Does not work with all games, "
|
||||
"but usually safe to enabled."));
|
||||
|
||||
auto images = m_host_interface->FindBIOSImagesInUserDirectory();
|
||||
populateDropDownForRegion(ConsoleRegion::NTSC_J, m_ui.imageNTSCJ, images);
|
||||
populateDropDownForRegion(ConsoleRegion::NTSC_U, m_ui.imageNTSCU, images);
|
||||
populateDropDownForRegion(ConsoleRegion::PAL, m_ui.imagePAL, images);
|
||||
|
||||
setDropDownValue(m_ui.imageNTSCJ, m_host_interface->GetStringSettingValue("BIOS", "PathNTSCJ", ""));
|
||||
setDropDownValue(m_ui.imageNTSCU, m_host_interface->GetStringSettingValue("BIOS", "PathNTSCU", ""));
|
||||
setDropDownValue(m_ui.imagePAL, m_host_interface->GetStringSettingValue("BIOS", "PathPAL", ""));
|
||||
refreshList();
|
||||
|
||||
connect(m_ui.imageNTSCJ, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
m_host_interface->SetStringSettingValue("BIOS", "PathNTSCJ",
|
||||
@ -118,6 +115,52 @@ BIOSSettingsWidget::BIOSSettingsWidget(QtHostInterface* host_interface, QWidget*
|
||||
m_ui.imagePAL->itemData(index).toString().toStdString().c_str());
|
||||
m_host_interface->applySettings();
|
||||
});
|
||||
|
||||
connect(m_ui.refresh, &QPushButton::clicked, this, &BIOSSettingsWidget::refreshList);
|
||||
|
||||
std::string current_search_directory = g_host_interface->GetBIOSDirectory();
|
||||
m_ui.searchDirectory->setText(QString::fromStdString(current_search_directory));
|
||||
connect(m_ui.searchDirectory, &QLineEdit::textChanged, [this](const QString& text) {
|
||||
if (text.isEmpty())
|
||||
{
|
||||
m_host_interface->RemoveSettingValue("BIOS", "SearchDirectory");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_host_interface->SetStringSettingValue("BIOS", "SearchDirectory", text.toStdString().c_str());
|
||||
}
|
||||
refreshList();
|
||||
});
|
||||
connect(m_ui.browseSearchDirectory, &QPushButton::clicked, this, &BIOSSettingsWidget::browseSearchDirectory);
|
||||
connect(m_ui.openSearchDirectory, &QPushButton::clicked, this, &BIOSSettingsWidget::openSearchDirectory);
|
||||
}
|
||||
|
||||
BIOSSettingsWidget::~BIOSSettingsWidget() = default;
|
||||
|
||||
void BIOSSettingsWidget::refreshList()
|
||||
{
|
||||
auto images = m_host_interface->FindBIOSImagesInDirectory(m_host_interface->GetBIOSDirectory().c_str());
|
||||
populateDropDownForRegion(ConsoleRegion::NTSC_J, m_ui.imageNTSCJ, images);
|
||||
populateDropDownForRegion(ConsoleRegion::NTSC_U, m_ui.imageNTSCU, images);
|
||||
populateDropDownForRegion(ConsoleRegion::PAL, m_ui.imagePAL, images);
|
||||
|
||||
setDropDownValue(m_ui.imageNTSCJ, m_host_interface->GetStringSettingValue("BIOS", "PathNTSCJ", ""));
|
||||
setDropDownValue(m_ui.imageNTSCU, m_host_interface->GetStringSettingValue("BIOS", "PathNTSCU", ""));
|
||||
setDropDownValue(m_ui.imagePAL, m_host_interface->GetStringSettingValue("BIOS", "PathPAL", ""));
|
||||
}
|
||||
|
||||
void BIOSSettingsWidget::browseSearchDirectory()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(QtUtils::GetRootWidget(this), tr("Select Directory"),
|
||||
m_ui.searchDirectory->text());
|
||||
if (directory.isEmpty())
|
||||
return;
|
||||
|
||||
m_ui.searchDirectory->setText(directory);
|
||||
}
|
||||
|
||||
void BIOSSettingsWidget::openSearchDirectory()
|
||||
{
|
||||
QString dir = QString::fromStdString(m_host_interface->GetBIOSDirectory());
|
||||
QtUtils::OpenURL(this, QUrl::fromLocalFile(dir));
|
||||
}
|
||||
|
@ -15,6 +15,11 @@ public:
|
||||
explicit BIOSSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog);
|
||||
~BIOSSettingsWidget();
|
||||
|
||||
private Q_SLOTS:
|
||||
void refreshList();
|
||||
void browseSearchDirectory();
|
||||
void openSearchDirectory();
|
||||
|
||||
private:
|
||||
Ui::BIOSSettingsWidget m_ui;
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>472</width>
|
||||
<height>259</height>
|
||||
<width>529</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -32,13 +32,6 @@
|
||||
<string>BIOS Selection</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>NTSC-J (Japan):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="imageNTSCJ">
|
||||
<property name="sizePolicy">
|
||||
@ -49,23 +42,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>NTSC-U/C (US/Canada):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="imageNTSCU">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
@ -73,6 +49,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>NTSC-J (Japan):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>NTSC-U/C (US/Canada):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="imagePAL">
|
||||
<property name="sizePolicy">
|
||||
@ -83,6 +73,80 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="imageNTSCU">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="openSearchDirectory">
|
||||
<property name="text">
|
||||
<string>Open in Explorer...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refresh">
|
||||
<property name="text">
|
||||
<string>Refresh List</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>BIOS Directory</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>DuckStation will search for BIOS images in this directory.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="searchDirectory"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="browseSearchDirectory">
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Reference in New Issue
Block a user