mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
Qt: unify some movie hover code and fix cellLeave
This commit is contained in:
parent
7bc673002f
commit
330dea181a
@ -564,6 +564,7 @@
|
|||||||
<ClCompile Include="rpcs3qt\debugger_list.cpp" />
|
<ClCompile Include="rpcs3qt\debugger_list.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\downloader.cpp" />
|
<ClCompile Include="rpcs3qt\downloader.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\fatal_error_dialog.cpp" />
|
<ClCompile Include="rpcs3qt\fatal_error_dialog.cpp" />
|
||||||
|
<ClCompile Include="rpcs3qt\game_list.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\gui_application.cpp" />
|
<ClCompile Include="rpcs3qt\gui_application.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\input_dialog.cpp" />
|
<ClCompile Include="rpcs3qt\input_dialog.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\localized.cpp" />
|
<ClCompile Include="rpcs3qt\localized.cpp" />
|
||||||
|
@ -744,6 +744,9 @@
|
|||||||
<ClCompile Include="Input\hid_pad_handler.cpp">
|
<ClCompile Include="Input\hid_pad_handler.cpp">
|
||||||
<Filter>Io</Filter>
|
<Filter>Io</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="rpcs3qt\game_list.cpp">
|
||||||
|
<Filter>Gui\game list</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Input\ds4_pad_handler.h">
|
<ClInclude Include="Input\ds4_pad_handler.h">
|
||||||
|
@ -21,6 +21,7 @@ set(SRC_FILES
|
|||||||
fatal_error_dialog.cpp
|
fatal_error_dialog.cpp
|
||||||
find_dialog.cpp
|
find_dialog.cpp
|
||||||
game_compatibility.cpp
|
game_compatibility.cpp
|
||||||
|
game_list.cpp
|
||||||
game_list_frame.cpp
|
game_list_frame.cpp
|
||||||
game_list_grid.cpp
|
game_list_grid.cpp
|
||||||
game_list_grid_delegate.cpp
|
game_list_grid_delegate.cpp
|
||||||
|
40
rpcs3/rpcs3qt/game_list.cpp
Normal file
40
rpcs3/rpcs3qt/game_list.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include "game_list.h"
|
||||||
|
#include "movie_item.h"
|
||||||
|
|
||||||
|
void game_list::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (!indexAt(event->pos()).isValid() || !itemAt(event->pos())->data(Qt::UserRole).isValid())
|
||||||
|
{
|
||||||
|
clearSelection();
|
||||||
|
setCurrentItem(nullptr); // Needed for currentItemChanged
|
||||||
|
}
|
||||||
|
QTableWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void game_list::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
movie_item* new_item = static_cast<movie_item*>(itemAt(event->pos()));
|
||||||
|
|
||||||
|
if (new_item != m_last_hover_item)
|
||||||
|
{
|
||||||
|
if (m_last_hover_item)
|
||||||
|
{
|
||||||
|
m_last_hover_item->set_active(false);
|
||||||
|
}
|
||||||
|
if (new_item)
|
||||||
|
{
|
||||||
|
new_item->set_active(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_last_hover_item = new_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void game_list::leaveEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if (m_last_hover_item)
|
||||||
|
{
|
||||||
|
m_last_hover_item->set_active(false);
|
||||||
|
m_last_hover_item = nullptr;
|
||||||
|
}
|
||||||
|
}
|
@ -23,24 +23,18 @@ struct gui_game_info
|
|||||||
typedef std::shared_ptr<gui_game_info> game_info;
|
typedef std::shared_ptr<gui_game_info> game_info;
|
||||||
Q_DECLARE_METATYPE(game_info)
|
Q_DECLARE_METATYPE(game_info)
|
||||||
|
|
||||||
|
class movie_item;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
class used in order to get deselection
|
class used in order to get deselection and hover change
|
||||||
if you know a simpler way, tell @Megamouse
|
if you know a simpler way, tell @Megamouse
|
||||||
*/
|
*/
|
||||||
class game_list : public QTableWidget
|
class game_list : public QTableWidget
|
||||||
{
|
{
|
||||||
public:
|
protected:
|
||||||
int m_last_entered_row = -1;
|
movie_item* m_last_hover_item = nullptr;
|
||||||
int m_last_entered_col = -1;
|
|
||||||
|
|
||||||
private:
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
void mousePressEvent(QMouseEvent *event) override
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
{
|
void leaveEvent(QEvent *event) override;
|
||||||
if (!indexAt(event->pos()).isValid() || !itemAt(event->pos())->data(Qt::UserRole).isValid())
|
|
||||||
{
|
|
||||||
clearSelection();
|
|
||||||
setCurrentItem(nullptr); // Needed for currentItemChanged
|
|
||||||
}
|
|
||||||
QTableWidget::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -133,19 +133,6 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> gui_settings, std
|
|||||||
connect(m_game_list, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
|
connect(m_game_list, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
|
||||||
connect(m_game_list, &QTableWidget::itemSelectionChanged, this, &game_list_frame::itemSelectionChangedSlot);
|
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, &QTableWidget::itemDoubleClicked, this, &game_list_frame::doubleClickedSlot);
|
||||||
connect(m_game_list, &QTableWidget::cellEntered, this, [this](int row, int column)
|
|
||||||
{
|
|
||||||
if (auto old_item = static_cast<movie_item*>(m_game_list->item(m_game_list->m_last_entered_row, m_game_list->m_last_entered_col)))
|
|
||||||
{
|
|
||||||
old_item->set_active(false);
|
|
||||||
}
|
|
||||||
if (auto new_item = static_cast<movie_item*>(m_game_list->item(row, column)))
|
|
||||||
{
|
|
||||||
new_item->set_active(true);
|
|
||||||
}
|
|
||||||
m_game_list->m_last_entered_row = row;
|
|
||||||
m_game_list->m_last_entered_col = column;
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_game_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnColClicked);
|
connect(m_game_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnColClicked);
|
||||||
connect(m_game_list->horizontalHeader(), &QHeaderView::customContextMenuRequested, [this](const QPoint& pos)
|
connect(m_game_list->horizontalHeader(), &QHeaderView::customContextMenuRequested, [this](const QPoint& pos)
|
||||||
|
@ -40,20 +40,6 @@ game_list_grid::game_list_grid(const QSize& icon_size, QColor icon_color, const
|
|||||||
horizontalHeader()->setVisible(false);
|
horizontalHeader()->setVisible(false);
|
||||||
setShowGrid(false);
|
setShowGrid(false);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
connect(this, &QTableWidget::cellEntered, this, [this](int row, int column)
|
|
||||||
{
|
|
||||||
if (auto old_item = dynamic_cast<movie_item*>(item(m_last_entered_row, m_last_entered_col)))
|
|
||||||
{
|
|
||||||
old_item->set_active(false);
|
|
||||||
}
|
|
||||||
if (auto new_item = dynamic_cast<movie_item*>(item(row, column)))
|
|
||||||
{
|
|
||||||
new_item->set_active(true);
|
|
||||||
}
|
|
||||||
m_last_entered_row = row;
|
|
||||||
m_last_entered_col = column;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_list_grid::enableText(const bool& enabled)
|
void game_list_grid::enableText(const bool& enabled)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user