diff --git a/Config/stylesheet.qss b/Config/stylesheet.qss index 2a091be0..9247c57b 100644 --- a/Config/stylesheet.qss +++ b/Config/stylesheet.qss @@ -3,7 +3,7 @@ QTableView { border: none; - color: #006600; + color: #0096d3; selection-color: #FFFFFF; - selection-background-color: #006600; + selection-background-color: #0096d3; } diff --git a/Source/RMG/CMakeLists.txt b/Source/RMG/CMakeLists.txt index d7cc9088..1d03b04a 100644 --- a/Source/RMG/CMakeLists.txt +++ b/Source/RMG/CMakeLists.txt @@ -11,6 +11,7 @@ pkg_check_modules(SDL2 REQUIRED sdl2) add_executable(RMG UserInterface/MainWindow.cpp UserInterface/RomBrowserWidget.cpp + UserInterface/NoFocusDelegate.cpp Thread/RomSearcherThread.cpp Thread/EmulationThread.cpp M64P/CoreApi.cpp diff --git a/Source/RMG/UserInterface/NoFocusDelegate.cpp b/Source/RMG/UserInterface/NoFocusDelegate.cpp new file mode 100644 index 00000000..e2618a6c --- /dev/null +++ b/Source/RMG/UserInterface/NoFocusDelegate.cpp @@ -0,0 +1,20 @@ +/* + * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG + * Copyright (C) 2020 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ +#include "NoFocusDelegate.hpp" + +using namespace UserInterface; + +void NoFocusDelegate::paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex &index) const +{ + QStyleOptionViewItem itemOption(option); + if (itemOption.state & QStyle::State_HasFocus) + itemOption.state = itemOption.state ^ QStyle::State_HasFocus; + QStyledItemDelegate::paint(painter, itemOption, index); +} diff --git a/Source/RMG/UserInterface/NoFocusDelegate.hpp b/Source/RMG/UserInterface/NoFocusDelegate.hpp new file mode 100644 index 00000000..1800276a --- /dev/null +++ b/Source/RMG/UserInterface/NoFocusDelegate.hpp @@ -0,0 +1,24 @@ +/* + * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG + * Copyright (C) 2020 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ +#ifndef NOFOCUSDELEGATE_HPP +#define NOFOCUSDELEGATE_HPP + +#include + +namespace UserInterface +{ + class NoFocusDelegate : public QStyledItemDelegate + { + protected: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + }; +} // namespace UserInterface + +#endif // NOFOCUSDELEGATE_HPP \ No newline at end of file diff --git a/Source/RMG/UserInterface/RomBrowserWidget.cpp b/Source/RMG/UserInterface/RomBrowserWidget.cpp index 1c2e7779..23f491cf 100644 --- a/Source/RMG/UserInterface/RomBrowserWidget.cpp +++ b/Source/RMG/UserInterface/RomBrowserWidget.cpp @@ -63,10 +63,15 @@ void RomBrowserWidget::model_LabelList_Setup(void) void RomBrowserWidget::widget_Init(void) { + this->widget_Delegate = new NoFocusDelegate(); + this->setModel(this->model_Model); + this->setItemDelegate(this->widget_Delegate); + this->setWordWrap(false); this->setShowGrid(false); - this->setSelectionBehavior(QTableView::SelectRows); this->setSortingEnabled(true); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + this->setSelectionBehavior(QTableView::SelectRows); this->verticalHeader()->hide(); @@ -75,14 +80,9 @@ void RomBrowserWidget::widget_Init(void) this->horizontalHeader()->setSortIndicatorShown(false); this->horizontalHeader()->setHighlightSections(false); - this->verticalHeader()->setSectionResizeMode(QHeaderView::Interactive); - this->verticalHeader()->setMaximumSectionSize(20); + this->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); this->column_SetSize(); - - QFont f = this->font(); - f.setPixelSize(11); - this->setFont(f); } void RomBrowserWidget::rom_Searcher_Init(void) diff --git a/Source/RMG/UserInterface/RomBrowserWidget.hpp b/Source/RMG/UserInterface/RomBrowserWidget.hpp index 52b244e0..f2efdeb6 100644 --- a/Source/RMG/UserInterface/RomBrowserWidget.hpp +++ b/Source/RMG/UserInterface/RomBrowserWidget.hpp @@ -10,6 +10,7 @@ #ifndef ROMBROWSERWIDGET_HPP #define ROMBROWSERWIDGET_HPP +#include "NoFocusDelegate.hpp" #include "../Thread/RomSearcherThread.hpp" #include "../Globals.hpp" @@ -40,6 +41,7 @@ namespace UserInterface void model_Setup(void); void model_LabelList_Setup(void); + NoFocusDelegate* widget_Delegate; void widget_Init(void); Thread::RomSearcherThread *rom_Searcher_Thread;