Skip to content
Permalink
Browse files
Merge pull request #10155 from malleoz/toggle-hotkeys-on-qfiledialog
Disable hotkeys on static QFileDialog calls
  • Loading branch information
leoetlino committed Oct 12, 2021
2 parents c2d17f3 + 839b040 commit 0315fcf
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 81 deletions.
@@ -262,6 +262,8 @@ add_executable(dolphin-emu
NetPlay/NetPlaySetupDialog.h
NetPlay/PadMappingDialog.cpp
NetPlay/PadMappingDialog.h
QtUtils/DolphinFileDialog.cpp
QtUtils/DolphinFileDialog.h
QtUtils/DoubleClickEventFilter.cpp
QtUtils/DoubleClickEventFilter.h
QtUtils/ElidedButton.cpp
@@ -5,7 +5,6 @@

#include <QApplication>
#include <QCoreApplication>
#include <QFileDialog>
#include <QFileInfo>
#include <QHeaderView>
#include <QMenu>
@@ -23,6 +22,7 @@
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"

#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
#include "DolphinQt/Resources.h"
@@ -211,7 +211,8 @@ void FilesystemWidget::PopulateDirectory(int partition_id, QStandardItem* root,

QString FilesystemWidget::SelectFolder()
{
return QFileDialog::getExistingDirectory(this, QObject::tr("Choose the folder to extract to"));
return DolphinFileDialog::getExistingDirectory(this,
QObject::tr("Choose the folder to extract to"));
}

void FilesystemWidget::ShowContextMenu(const QPoint&)
@@ -296,7 +297,7 @@ void FilesystemWidget::ShowContextMenu(const QPoint&)
case EntryType::File:
menu->addAction(tr("Extract File..."), this, [this, partition, path] {
auto dest =
QFileDialog::getSaveFileName(this, tr("Save File to"), QFileInfo(path).fileName());
DolphinFileDialog::getSaveFileName(this, tr("Save File to"), QFileInfo(path).fileName());

if (!dest.isEmpty())
ExtractFile(partition, path, dest);
@@ -4,7 +4,6 @@
#include <QComboBox>
#include <QCryptographicHash>
#include <QDir>
#include <QFileDialog>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
@@ -19,6 +18,7 @@
#include "DiscIO/Volume.h"

#include "DolphinQt/Config/InfoWidget.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ImageConverter.h"

#include "UICommon/UICommon.h"
@@ -190,8 +190,8 @@ QWidget* InfoWidget::CreateBannerGraphic(const QPixmap& image)

void InfoWidget::SaveBanner()
{
QString path = QFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
tr("PNG image file (*.png);; All Files (*)"));
QString path = DolphinFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
tr("PNG image file (*.png);; All Files (*)"));
ToQPixmap(m_game.GetBannerImage()).save(path, "PNG");
}

@@ -11,7 +11,6 @@

#include <QCheckBox>
#include <QComboBox>
#include <QFileDialog>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
@@ -26,6 +25,7 @@
#include "DiscIO/Blob.h"
#include "DiscIO/ScrubbedBlob.h"
#include "DiscIO/WIABlob.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
#include "UICommon/GameFile.h"
@@ -374,7 +374,7 @@ void ConvertDialog::Convert()

if (m_files.size() > 1)
{
dst_dir = QFileDialog::getExistingDirectory(
dst_dir = DolphinFileDialog::getExistingDirectory(
this, tr("Select where you want to save the converted images"),
QFileInfo(QString::fromStdString(m_files[0]->GetFilePath())).dir().absolutePath());

@@ -383,7 +383,7 @@ void ConvertDialog::Convert()
}
else
{
dst_path = QFileDialog::getSaveFileName(
dst_path = DolphinFileDialog::getSaveFileName(
this, tr("Select where you want to save the converted image"),
QFileInfo(QString::fromStdString(m_files[0]->GetFilePath()))
.dir()
@@ -164,6 +164,7 @@
<ClCompile Include="NKitWarningDialog.cpp" />
<ClCompile Include="QtUtils\AspectRatioWidget.cpp" />
<ClCompile Include="QtUtils\BlockUserInputFilter.cpp" />
<ClCompile Include="QtUtils\DolphinFileDialog.cpp" />
<ClCompile Include="QtUtils\DoubleClickEventFilter.cpp" />
<ClCompile Include="QtUtils\ElidedButton.cpp" />
<ClCompile Include="QtUtils\FileOpenEventFilter.cpp" />
@@ -217,6 +218,7 @@
<ClInclude Include="Debugger\RegisterColumn.h" />
<ClInclude Include="GBAHost.h" />
<ClInclude Include="QtUtils\ActionHelper.h" />
<ClInclude Include="QtUtils\DolphinFileDialog.h" />
<ClInclude Include="QtUtils\FlowLayout.h" />
<ClInclude Include="QtUtils\ImageConverter.h" />
<ClInclude Include="QtUtils\ModalMessageBox.h" />
@@ -6,7 +6,6 @@
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QEvent>
#include <QFileDialog>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QIcon>
@@ -27,6 +26,7 @@
#include "Core/FifoPlayer/FifoRecorder.h"

#include "DolphinQt/FIFO/FIFOAnalyzer.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/Resources.h"
@@ -189,8 +189,8 @@ void FIFOPlayerWindow::ConnectWidgets()

void FIFOPlayerWindow::LoadRecording()
{
QString path = QFileDialog::getOpenFileName(this, tr("Open FIFO log"), QString(),
tr("Dolphin FIFO Log (*.dff)"));
QString path = DolphinFileDialog::getOpenFileName(this, tr("Open FIFO log"), QString(),
tr("Dolphin FIFO Log (*.dff)"));

if (path.isEmpty())
return;
@@ -200,8 +200,8 @@ void FIFOPlayerWindow::LoadRecording()

void FIFOPlayerWindow::SaveRecording()
{
QString path = QFileDialog::getSaveFileName(this, tr("Save FIFO log"), QString(),
tr("Dolphin FIFO Log (*.dff)"));
QString path = DolphinFileDialog::getSaveFileName(this, tr("Save FIFO log"), QString(),
tr("Dolphin FIFO Log (*.dff)"));

if (path.isEmpty())
return;
@@ -26,6 +26,7 @@
#include "Core/HW/SI/SI_Device.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"
@@ -183,7 +184,7 @@ void GBAWidget::UnloadROM()

void GBAWidget::PromptForEReaderCards()
{
const QStringList card_paths = QFileDialog::getOpenFileNames(
const QStringList card_paths = DolphinFileDialog::getOpenFileNames(
this, tr("Select e-Reader Cards"), QString(), tr("e-Reader Cards (*.raw);;All Files (*)"),
nullptr, QFileDialog::Options());

@@ -205,9 +206,10 @@ void GBAWidget::DoState(bool export_state)
return;

QString state_path = QDir::toNativeSeparators(
(export_state ? QFileDialog::getSaveFileName : QFileDialog::getOpenFileName)(
(export_state ? DolphinFileDialog::getSaveFileName : DolphinFileDialog::getOpenFileName)(
this, tr("Select a File"), QString(),
tr("mGBA Save States (*.ss0 *.ss1 *.ss2 *.ss3 *.ss4 *.ss5 *.ss6 *.ss7 *.ss8 *.ss9);;"
tr("mGBA Save States (*.ss0 *.ss1 *.ss2 *.ss3 *.ss4 "
"*.ss5 *.ss6 *.ss7 *.ss8 *.ss9);;"
"All Files (*)"),
nullptr, QFileDialog::Options()));

@@ -5,7 +5,6 @@

#include <QComboBox>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
@@ -19,6 +18,8 @@
#include "Core/HW/GCMemcard/GCMemcard.h"
#include "Core/HW/Sram.h"

#include "DolphinQt/QtUtils/DolphinFileDialog.h"

GCMemcardCreateNewDialog::GCMemcardCreateNewDialog(QWidget* parent) : QDialog(parent)
{
m_combobox_size = new QComboBox();
@@ -69,7 +70,7 @@ bool GCMemcardCreateNewDialog::CreateCard()
const u16 size = static_cast<u16>(m_combobox_size->currentData().toInt());
const bool is_shift_jis = m_radio_shiftjis->isChecked();

const QString path = QFileDialog::getSaveFileName(
const QString path = DolphinFileDialog::getSaveFileName(
this, tr("Create New Memory Card"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
tr("GameCube Memory Cards (*.raw *.gcp)") + QStringLiteral(";;") + tr("All Files (*)"));

@@ -11,7 +11,6 @@

#include <QDialogButtonBox>
#include <QDir>
#include <QFileDialog>
#include <QGridLayout>
#include <QGroupBox>
#include <QHeaderView>
@@ -40,6 +39,7 @@
#include "Core/HW/GCMemcard/GCMemcardUtils.h"

#include "DolphinQt/GCMemcardCreateNewDialog.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"

constexpr int ROW_HEIGHT = 36;
@@ -339,7 +339,7 @@ void GCMemcardManager::SetSlotFile(int slot, QString path)

void GCMemcardManager::SetSlotFileInteractive(int slot)
{
QString path = QDir::toNativeSeparators(QFileDialog::getOpenFileName(
QString path = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
this,
slot == 0 ? tr("Set memory card file for Slot A") : tr("Set memory card file for Slot B"),
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
@@ -418,7 +418,7 @@ void GCMemcardManager::ExportFiles(Memcard::SavefileFormat format)
const QString qformatdesc = GetFormatDescription(format);
const std::string default_path =
fmt::format("{}/{}{}", File::GetUserPath(D_GCUSER_IDX), basename, extension);
const QString qfilename = QFileDialog::getSaveFileName(
const QString qfilename = DolphinFileDialog::getSaveFileName(
this, tr("Export Save File"), QString::fromStdString(default_path),
QStringLiteral("%1 (*%2);;%3 (*)")
.arg(qformatdesc, QString::fromStdString(extension), tr("All Files")));
@@ -435,9 +435,9 @@ void GCMemcardManager::ExportFiles(Memcard::SavefileFormat format)
return;
}

const QString qdirpath =
QFileDialog::getExistingDirectory(this, QObject::tr("Export Save Files"),
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)));
const QString qdirpath = DolphinFileDialog::getExistingDirectory(
this, QObject::tr("Export Save Files"),
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)));
if (qdirpath.isEmpty())
return;

@@ -567,7 +567,7 @@ void GCMemcardManager::ImportFile()
if (!card)
return;

const QStringList paths = QFileDialog::getOpenFileNames(
const QStringList paths = DolphinFileDialog::getOpenFileNames(
this, tr("Import Save File(s)"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
QStringLiteral("%1 (*.gci *.gcs *.sav);;%2 (*.gci);;%3 (*.gcs);;%4 (*.sav);;%5 (*)")
.arg(tr("Supported file formats"), GetFormatDescription(Memcard::SavefileFormat::GCI),
@@ -59,6 +59,7 @@
#include "DolphinQt/GameList/GridProxyModel.h"
#include "DolphinQt/GameList/ListProxyModel.h"
#include "DolphinQt/MenuBar.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/DoubleClickEventFilter.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
@@ -254,7 +255,7 @@ void GameList::MakeEmptyView()
m_empty->installEventFilter(event_filter);
connect(event_filter, &DoubleClickEventFilter::doubleClicked, [this] {
auto current_dir = QDir::currentPath();
auto dir = QFileDialog::getExistingDirectory(this, tr("Select a Directory"), current_dir);
auto dir = DolphinFileDialog::getExistingDirectory(this, tr("Select a Directory"), current_dir);
if (!dir.isEmpty())
Settings::Instance().AddPath(dir);
});
@@ -489,7 +490,7 @@ void GameList::OpenProperties()

void GameList::ExportWiiSave()
{
const QString export_dir = QFileDialog::getExistingDirectory(
const QString export_dir = DolphinFileDialog::getExistingDirectory(
this, tr("Select Export Directory"), QString::fromStdString(File::GetUserPath(D_USER_IDX)),
QFileDialog::ShowDirsOnly);
if (export_dir.isEmpty())
@@ -7,7 +7,6 @@
#include <QDir>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QFileDialog>
#include <QFileInfo>
#include <QIcon>
#include <QMimeData>
@@ -91,6 +90,7 @@
#include "DolphinQt/NetPlay/NetPlayBrowser.h"
#include "DolphinQt/NetPlay/NetPlayDialog.h"
#include "DolphinQt/NetPlay/NetPlaySetupDialog.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/FileOpenEventFilter.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/ParallelProgressDialog.h"
@@ -712,7 +712,7 @@ void MainWindow::RefreshGameList()
QStringList MainWindow::PromptFileNames()
{
auto& settings = Settings::Instance().GetQSettings();
QStringList paths = QFileDialog::getOpenFileNames(
QStringList paths = DolphinFileDialog::getOpenFileNames(
this, tr("Select a File"),
settings.value(QStringLiteral("mainwindow/lastdir"), QString{}).toString(),
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.tgc *.wbfs *.ciso *.gcz *.wia *.rvz *.wad "
@@ -1278,15 +1278,17 @@ void MainWindow::ShowFIFOPlayer()

void MainWindow::StateLoad()
{
QString path = QFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(),
tr("All Save States (*.sav *.s##);; All Files (*)"));
QString path =
DolphinFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(),
tr("All Save States (*.sav *.s##);; All Files (*)"));
State::LoadAs(path.toStdString());
}

void MainWindow::StateSave()
{
QString path = QFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
tr("All Save States (*.sav *.s##);; All Files (*)"));
QString path =
DolphinFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
tr("All Save States (*.sav *.s##);; All Files (*)"));
State::SaveAs(path.toStdString());
}

@@ -1612,9 +1614,10 @@ void MainWindow::OnImportNANDBackup()
if (response == QMessageBox::No)
return;

QString file = QFileDialog::getOpenFileName(this, tr("Select the save file"), QDir::currentPath(),
tr("BootMii NAND backup file (*.bin);;"
"All Files (*)"));
QString file =
DolphinFileDialog::getOpenFileName(this, tr("Select the save file"), QDir::currentPath(),
tr("BootMii NAND backup file (*.bin);;"
"All Files (*)"));

if (file.isEmpty())
return;
@@ -1637,10 +1640,10 @@ void MainWindow::OnImportNANDBackup()
},
[this] {
std::optional<std::string> keys_file = RunOnObject(this, [this] {
return QFileDialog::getOpenFileName(this, tr("Select the keys file (OTP/SEEPROM dump)"),
QDir::currentPath(),
tr("BootMii keys file (*.bin);;"
"All Files (*)"))
return DolphinFileDialog::getOpenFileName(
this, tr("Select the keys file (OTP/SEEPROM dump)"), QDir::currentPath(),
tr("BootMii keys file (*.bin);;"
"All Files (*)"))
.toStdString();
});
if (keys_file)
@@ -1659,8 +1662,8 @@ void MainWindow::OnImportNANDBackup()

void MainWindow::OnPlayRecording()
{
QString dtm_file = QFileDialog::getOpenFileName(this, tr("Select the Recording File to Play"),
QString(), tr("Dolphin TAS Movies (*.dtm)"));
QString dtm_file = DolphinFileDialog::getOpenFileName(
this, tr("Select the Recording File to Play"), QString(), tr("Dolphin TAS Movies (*.dtm)"));

if (dtm_file.isEmpty())
return;
@@ -1729,8 +1732,8 @@ void MainWindow::OnStopRecording()
void MainWindow::OnExportRecording()
{
Core::RunAsCPUThread([this] {
QString dtm_file = QFileDialog::getSaveFileName(this, tr("Save Recording File As"), QString(),
tr("Dolphin TAS Movies (*.dtm)"));
QString dtm_file = DolphinFileDialog::getSaveFileName(
this, tr("Save Recording File As"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
if (!dtm_file.isEmpty())
Movie::SaveRecording(dtm_file.toStdString());
});

0 comments on commit 0315fcf

Please sign in to comment.