diff --git a/rpcs3/game_list.h b/rpcs3/game_list.h new file mode 100644 index 0000000000..5e7bfe37ae --- /dev/null +++ b/rpcs3/game_list.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +/* + class used in order to get deselection + if you know a simpler way, tell @Megamouse +*/ +class game_list : public QTableWidget { +private: + void mousePressEvent(QMouseEvent *event) + { + if (!indexAt(event->pos()).isValid()) + { + clearSelection(); + } + QTableWidget::mousePressEvent(event); + } +}; diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index e3f8f54f88..3e99f4a358 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -924,6 +924,7 @@ $(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing gs_frame.h... diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 362a81bf06..f803443027 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -514,6 +514,9 @@ Generated Files + + Gui + diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 8b4d68cb73..3367d86ce4 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -155,7 +155,7 @@ game_list_frame::game_list_frame(std::shared_ptr settings, const R bool showText = (m_Icon_Size_Str != GUI::gl_icon_key_small && m_Icon_Size_Str != GUI::gl_icon_key_tiny); m_xgrid = new game_list_grid(m_Icon_Size, m_Icon_Color, m_Margin_Factor, m_Text_Factor, showText); - gameList = new QTableWidget(); + gameList = new game_list(); gameList->setShowGrid(false); gameList->setItemDelegate(new table_item_delegate(this)); gameList->setSelectionBehavior(QAbstractItemView::SelectRows); @@ -965,11 +965,11 @@ std::string game_list_frame::CurrentSelectionIconPath() std::string selection = ""; // The index can be more than the size of m_game_data if you use the VFS to load a directory which has less games. - if (m_oldLayoutIsList && gameList->currentRow() >= 0 && gameList->currentRow() < m_game_data.size()) + if (m_oldLayoutIsList && gameList->selectedItems().count() && gameList->currentRow() < m_game_data.size()) { selection = m_game_data.at(gameList->item(gameList->currentRow(), 0)->data(Qt::UserRole).toInt()).info.icon_path; } - else if (!m_oldLayoutIsList && m_xgrid->currentItem() != nullptr) + else if (!m_oldLayoutIsList && m_xgrid->selectedItems().count()) { int ind = m_xgrid->currentItem()->data(Qt::UserRole).toInt(); if (ind < m_game_data.size()) diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index f03ae473ad..e8be51bc80 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -3,6 +3,7 @@ #include "stdafx.h" #include "Emu/GameInfo.h" +#include "game_list.h" #include "game_list_grid.h" #include "gui_settings.h" #include "emu_settings.h" @@ -231,7 +232,7 @@ private: QToolBar* m_Tool_Bar; QLineEdit* m_Search_Bar; QSlider* m_Slider_Size; - QTableWidget *gameList; + game_list* gameList; game_list_grid* m_xgrid; // Actions regarding showing/hiding columns diff --git a/rpcs3/rpcs3qt/game_list_grid.cpp b/rpcs3/rpcs3qt/game_list_grid.cpp index 04a9cc5064..2dd3b021f9 100644 --- a/rpcs3/rpcs3qt/game_list_grid.cpp +++ b/rpcs3/rpcs3qt/game_list_grid.cpp @@ -4,7 +4,7 @@ #include game_list_grid::game_list_grid(const QSize& icon_size, const QColor& icon_color, const qreal& margin_factor, const qreal& text_factor, const bool& showText) - : QTableWidget(), m_icon_size(icon_size), m_icon_color(icon_color), m_margin_factor(margin_factor), m_text_factor(text_factor), m_text_enabled(showText) + : game_list(), m_icon_size(icon_size), m_icon_color(icon_color), m_margin_factor(margin_factor), m_text_factor(text_factor), m_text_enabled(showText) { QSize item_size; if (m_text_enabled) diff --git a/rpcs3/rpcs3qt/game_list_grid.h b/rpcs3/rpcs3qt/game_list_grid.h index 4d1e1f37cc..c4f0da0aeb 100644 --- a/rpcs3/rpcs3qt/game_list_grid.h +++ b/rpcs3/rpcs3qt/game_list_grid.h @@ -1,5 +1,6 @@ #pragma once +#include "game_list.h" #include "game_list_grid_delegate.h" #include @@ -9,7 +10,7 @@ #include #include -class game_list_grid : public QTableWidget +class game_list_grid : public game_list { Q_OBJECT