From a51c700f59fae573a325814b7d87a7b03e0d88d0 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Wed, 8 Aug 2018 16:55:23 +0800 Subject: [PATCH] Port "qt/main: Collapse if statement in UpdateRecentFiles()" from yuzu --- src/citra_qt/main.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index e1d08eb335..694c7442a0 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -109,6 +109,8 @@ void GMainWindow::ShowCallouts() { ShowCalloutMessage(telemetry_message, CalloutFlag::Telemetry); } +const int GMainWindow::max_recent_files_item; + GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { Log::Filter log_filter; log_filter.ParseFilterString(Settings::values.log_filter); @@ -797,11 +799,11 @@ void GMainWindow::StoreRecentFile(const QString& filename) { } void GMainWindow::UpdateRecentFiles() { - unsigned int num_recent_files = - std::min(UISettings::values.recent_files.size(), static_cast(max_recent_files_item)); + const int num_recent_files = + std::min(UISettings::values.recent_files.size(), max_recent_files_item); - for (unsigned int i = 0; i < num_recent_files; i++) { - QString text = QString("&%1. %2").arg(i + 1).arg( + for (int i = 0; i < num_recent_files; i++) { + const QString text = QString("&%1. %2").arg(i + 1).arg( QFileInfo(UISettings::values.recent_files[i]).fileName()); actions_recent_files[i]->setText(text); actions_recent_files[i]->setData(UISettings::values.recent_files[i]); @@ -813,12 +815,8 @@ void GMainWindow::UpdateRecentFiles() { actions_recent_files[j]->setVisible(false); } - // Grey out the recent files menu if the list is empty - if (num_recent_files == 0) { - ui.menu_recent_files->setEnabled(false); - } else { - ui.menu_recent_files->setEnabled(true); - } + // Enable the recent files menu if the list isn't empty + ui.menu_recent_files->setEnabled(num_recent_files != 0); } void GMainWindow::OnGameListLoadFile(QString game_path) {