Qt: only ignore highlights on specified tables

This commit is contained in:
Megamouse 2018-07-26 21:12:12 +02:00
parent f6a3659a14
commit b0b4998050
4 changed files with 11 additions and 8 deletions

View File

@ -52,7 +52,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
m_gameList = new game_list();
m_gameList->setShowGrid(false);
m_gameList->setItemDelegate(new table_item_delegate(this));
m_gameList->setItemDelegate(new table_item_delegate(this, true));
m_gameList->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_gameList->setSelectionBehavior(QAbstractItemView::SelectRows);
m_gameList->setSelectionMode(QAbstractItemView::SingleSelection);

View File

@ -91,7 +91,7 @@ rsx_debugger::rsx_debugger(std::shared_ptr<gui_settings> gui_settings, QWidget*
m_tw_rsx = new QTabWidget();
//adds a tab containing a list to the tabwidget
// adds a tab containing a list to the tabwidget
auto l_addRSXTab = [=](QTableWidget* table, const QString& tabname, int columns)
{
table = new QTableWidget();
@ -119,7 +119,7 @@ rsx_debugger::rsx_debugger(std::shared_ptr<gui_settings> gui_settings, QWidget*
m_list_texture = l_addRSXTab(m_list_texture, tr("Texture"), 9);
m_list_settings = l_addRSXTab(m_list_settings, tr("Settings"), 2);
//Tabs: List Columns
// Tabs: List Columns
m_list_commands->viewport()->installEventFilter(this);
m_list_commands->setHorizontalHeaderLabels(QStringList() << tr("Column") << tr("Value") << tr("Command") << tr("Count"));
m_list_commands->setColumnWidth(0, 70);
@ -149,7 +149,7 @@ rsx_debugger::rsx_debugger(std::shared_ptr<gui_settings> gui_settings, QWidget*
m_list_settings->setColumnWidth(0, 170);
m_list_settings->setColumnWidth(1, 270);
//Tools: Tools = Controls + Notebook Tabs
// Tools: Tools = Controls + Notebook Tabs
QVBoxLayout* vbox_tools = new QVBoxLayout();
vbox_tools->addLayout(hbox_controls);
vbox_tools->addWidget(m_tw_rsx);

View File

@ -6,15 +6,18 @@
/** This class is used to get rid of somewhat ugly item focus rectangles. You could change the rectangle instead of omiting it if you wanted */
class table_item_delegate : public QStyledItemDelegate
{
private:
bool m_has_icons;
public:
explicit table_item_delegate(QObject *parent = 0) : QStyledItemDelegate(parent) {}
explicit table_item_delegate(QObject *parent = 0, bool has_icons = false) : QStyledItemDelegate(parent), m_has_icons(has_icons) {}
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override
{
// Remove the focus frame around selected items
option->state &= ~QStyle::State_HasFocus;
if (index.column() == 0)
if (m_has_icons && index.column() == 0)
{
// Don't highlight icons
option->state &= ~QStyle::State_Selected;

View File

@ -76,7 +76,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
m_game_table->verticalScrollBar()->installEventFilter(this);
m_game_table->verticalScrollBar()->setSingleStep(20);
m_game_table->horizontalScrollBar()->setSingleStep(20);
m_game_table->setItemDelegate(new table_item_delegate(this));
m_game_table->setItemDelegate(new table_item_delegate(this, true));
m_game_table->setSelectionBehavior(QAbstractItemView::SelectRows);
m_game_table->setSelectionMode(QAbstractItemView::SingleSelection);
m_game_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
@ -98,7 +98,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
m_trophy_table->verticalScrollBar()->installEventFilter(this);
m_trophy_table->verticalScrollBar()->setSingleStep(20);
m_trophy_table->horizontalScrollBar()->setSingleStep(20);
m_trophy_table->setItemDelegate(new table_item_delegate(this));
m_trophy_table->setItemDelegate(new table_item_delegate(this, true));
m_trophy_table->setSelectionBehavior(QAbstractItemView::SelectRows);
m_trophy_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_trophy_table->setColumnCount(TrophyColumns::Count);