From 091dcc10525929a332875a7f3219629507e658f9 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 7 Mar 2020 19:47:00 +0100 Subject: [PATCH] Qt: fix play button state when booting rpcs3 for the first time --- rpcs3/rpcs3qt/game_list.h | 2 +- rpcs3/rpcs3qt/game_list_frame.cpp | 24 ++++++++++++++++-------- rpcs3/rpcs3qt/game_list_frame.h | 2 +- rpcs3/rpcs3qt/main_window.cpp | 19 ++++++++++++++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list.h b/rpcs3/rpcs3qt/game_list.h index 82bf11dca8..5ae2179f03 100644 --- a/rpcs3/rpcs3qt/game_list.h +++ b/rpcs3/rpcs3qt/game_list.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 8275919cf3..49231b3840 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -126,7 +126,7 @@ game_list_frame::game_list_frame(std::shared_ptr gui_settings, std // Events connect(m_game_list, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); - connect(m_game_list, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot); + connect(m_game_list, &QTableWidget::itemSelectionChanged, this, &game_list_frame::itemSelectionChangedSlot); connect(m_game_list, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot); connect(m_game_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnColClicked); @@ -138,7 +138,7 @@ game_list_frame::game_list_frame(std::shared_ptr gui_settings, std }); connect(m_game_grid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); - connect(m_game_grid, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot); + connect(m_game_grid, &QTableWidget::itemSelectionChanged, this, &game_list_frame::itemSelectionChangedSlot); connect(m_game_grid, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot); connect(m_game_compat.get(), &game_compatibility::DownloadStarted, [this]() @@ -815,7 +815,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) const int scroll_position = m_game_grid->verticalScrollBar()->value(); PopulateGameGrid(games_per_row, m_icon_size, m_icon_color); connect(m_game_grid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); - connect(m_game_grid, &QTableWidget::currentItemChanged, this, &game_list_frame::itemSelectedSlot); + connect(m_game_grid, &QTableWidget::itemSelectionChanged, this, &game_list_frame::itemSelectionChangedSlot); connect(m_game_grid, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot); m_central_widget->addWidget(m_game_grid); m_central_widget->setCurrentWidget(m_game_grid); @@ -894,16 +894,23 @@ void game_list_frame::doubleClickedSlot(QTableWidgetItem *item) Q_EMIT RequestBoot(game); } -void game_list_frame::itemSelectedSlot(QTableWidgetItem* current, QTableWidgetItem* /*previous*/) +void game_list_frame::itemSelectionChangedSlot() { - if (current) + game_info game = nullptr; + + if (m_is_list_layout) { - Q_EMIT NotifyGameSelection(GetGameInfoByMode(current)); + if (const auto item = m_game_list->item(m_game_list->currentRow(), gui::column_icon); item->isSelected()) + { + game = GetGameInfoByMode(item); + } } - else + else if (const auto item = m_game_grid->currentItem(); item->isSelected()) { - Q_EMIT NotifyGameSelection(nullptr); + game = GetGameInfoByMode(item); } + + Q_EMIT NotifyGameSelection(game); } void game_list_frame::ShowContextMenu(const QPoint &pos) @@ -1961,6 +1968,7 @@ void game_list_frame::PopulateGameList() std::string selected_item = CurrentSelectionIconPath(); + m_game_list->clearSelection(); m_game_list->clearContents(); m_game_list->setRowCount(m_game_data.size()); diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 5ae2780843..e6125ba30c 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -83,7 +83,7 @@ private Q_SLOTS: void OnColClicked(int col); void ShowContextMenu(const QPoint &pos); void doubleClickedSlot(QTableWidgetItem *item); - void itemSelectedSlot(QTableWidgetItem* current, QTableWidgetItem* previous); + void itemSelectionChangedSlot(); Q_SIGNALS: void GameListFrameClosed(); void NotifyGameSelection(const game_info& game); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 6d50f8a1a2..b8a1006202 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -132,13 +132,14 @@ void main_window::Init() if (enable_play_last) { - ui->sysPauseAct->setEnabled(true); ui->sysPauseAct->setText(tr("&Play last played game\tCtrl+E")); ui->sysPauseAct->setIcon(m_icon_play); ui->toolbar_start->setToolTip(start_toolip); - ui->toolbar_start->setEnabled(true); } + ui->sysPauseAct->setEnabled(enable_play_last); + ui->toolbar_start->setEnabled(enable_play_last); + // create tool buttons for the taskbar thumbnail #ifdef _WIN32 m_thumb_bar = new QWinThumbnailToolBar(this); @@ -1767,6 +1768,8 @@ void main_window::CreateDockWindows() { QString tooltip; + bool enable_play_buttons = true; + if (game) // A game was selected { const std::string title_and_title_id = game->info.name + " [" + game->info.serial + "]"; @@ -1807,9 +1810,19 @@ void main_window::CreateDockWindows() } else { - ui->toolbar_start->setEnabled(false); + enable_play_buttons = false; } } + else + { + enable_play_buttons = false; + } + + ui->toolbar_start->setEnabled(enable_play_buttons); + ui->sysPauseAct->setEnabled(enable_play_buttons); +#ifdef _WIN32 + m_thumb_playPause->setEnabled(enable_play_buttons); +#endif if (!tooltip.isEmpty()) {