From 5b95cfda40a3d6a033da80ada57a34ae6e20b593 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 22 Dec 2022 23:03:52 +0100 Subject: [PATCH] Qt: Improve Check Config utility Warn if the user selects a weird file. Allow more file types and show them all by default. --- rpcs3/rpcs3qt/config_checker.cpp | 4 ++-- rpcs3/rpcs3qt/main_window.cpp | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/rpcs3/rpcs3qt/config_checker.cpp b/rpcs3/rpcs3qt/config_checker.cpp index 15c6eccf90..88c847edef 100644 --- a/rpcs3/rpcs3qt/config_checker.cpp +++ b/rpcs3/rpcs3qt/config_checker.cpp @@ -11,7 +11,7 @@ LOG_CHANNEL(gui_log, "GUI"); -config_checker::config_checker(QWidget* parent, const QString& path, bool is_log) : QDialog(parent) +config_checker::config_checker(QWidget* parent, const QString& content, bool is_log) : QDialog(parent) { setObjectName("config_checker"); setAttribute(Qt::WA_DeleteOnClose); @@ -22,7 +22,7 @@ config_checker::config_checker(QWidget* parent, const QString& path, bool is_log QString result; - if (check_config(path, result, is_log)) + if (check_config(content, result, is_log)) { setWindowTitle(tr("Interesting!")); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index d66f2ac750..325cd40713 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -2379,13 +2379,23 @@ void main_window::CreateConnects() connect(ui->toolsCheckConfigAct, &QAction::triggered, this, [this] { const QString path_last_cfg = m_gui_settings->GetValue(gui::fd_cfg_check).toString(); - const QString file_path = QFileDialog::getOpenFileName(this, tr("Select rpcs3.log or config.yml"), path_last_cfg, tr("Log files (*.log);;Config Files (*.yml);;All files (*.*)")); + const QString file_path = QFileDialog::getOpenFileName(this, tr("Select rpcs3.log or config.yml"), path_last_cfg, tr("Log or Config files (*.log *.txt *.yml);;Log files (*.log);;Config Files (*.yml);;Text Files (*.txt);;All files (*.*)")); if (file_path.isEmpty()) { // Aborted return; } + const QFileInfo file_info(file_path); + + if (file_info.isExecutable() || !(file_path.endsWith(".log") || file_path.endsWith(".txt") || file_path.endsWith(".yml"))) + { + if (QMessageBox::question(this, tr("Weird file!"), tr("This file seems to have an unexpected type:\n%0\n\nCheck anyway?").arg(file_path)) != QMessageBox::Yes) + { + return; + } + } + QFile file(file_path); if (!file.exists() || !file.open(QIODevice::ReadOnly)) { @@ -2393,7 +2403,7 @@ void main_window::CreateConnects() return; } - m_gui_settings->SetValue(gui::fd_cfg_check, QFileInfo(file_path).path()); + m_gui_settings->SetValue(gui::fd_cfg_check, file_info.path()); config_checker* dlg = new config_checker(this, file.readAll(), file_path.endsWith(".log")); dlg->exec();