From d51a986dd45e3ef565d573b5c4a0265b861935fe Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 30 Jul 2017 22:13:59 +0200 Subject: [PATCH] GUI: fix icon sizes and exterminate gamelist bug recreate old icon size values --- rpcs3/rpcs3qt/game_list_frame.cpp | 10 ++++++++++ rpcs3/rpcs3qt/game_list_frame.h | 3 +++ rpcs3/rpcs3qt/gui_settings.h | 14 +++++++++++--- rpcs3/rpcs3qt/main_window.cpp | 12 ++++++------ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index d877d03101..54e33dd41f 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -749,6 +749,16 @@ void game_list_frame::ResizeIcons(const int& sliderPos) m_Slider_Size->setSliderPosition(sliderPos); } + RepaintIcons(); +} + +void game_list_frame::RepaintIcons(const QColor& color) +{ + if (color.isValid()) + { + m_Icon_Color = color; + } + for (auto& game : m_game_data) { game.pxmap = PaintedPixmap(game.icon, game.hasCustomConfig); diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index f4e2167f20..6f372fd77e 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -192,6 +192,9 @@ public: /** Resize Gamelist Icons to size given by slider position */ void ResizeIcons(const int& sliderPos); + /** Repaint Gamelist Icons with new background color */ + void RepaintIcons(const QColor& color = QColor()); + int GetSliderValue(); public Q_SLOTS: diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index d6376d8ef9..6dcb13a197 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -35,11 +35,19 @@ typedef QList q_size_list; namespace GUI { - const QSize gl_icon_size_min = QSize(40, 22); - const QSize gl_icon_size_max = QSize(320, 176); + const QSize gl_icon_size_min = QSize(40, 22); + const QSize gl_icon_size_small = QSize(80, 44); + const QSize gl_icon_size_medium = QSize(160, 88); + const QSize gl_icon_size_max = QSize(320, 176); const int gl_max_slider_pos = 100; + inline int get_Index(const QSize& current) { + int size_delta = gl_icon_size_max.width() - gl_icon_size_min.width(); + int current_delta = current.width() - gl_icon_size_min.width(); + return gl_max_slider_pos * current_delta / size_delta; + }; + const QString main_window = "main_window"; const QString game_list = "GameList"; const QString logger = "Logger"; @@ -88,7 +96,7 @@ namespace GUI const GUI_SAVE gl_sortAsc = GUI_SAVE( game_list, "sortAsc", true ); const GUI_SAVE gl_sortCol = GUI_SAVE( game_list, "sortCol", 1 ); const GUI_SAVE gl_state = GUI_SAVE( game_list, "state", QByteArray() ); - const GUI_SAVE gl_iconSize = GUI_SAVE( game_list, "iconSize", gl_max_slider_pos / 2); + const GUI_SAVE gl_iconSize = GUI_SAVE( game_list, "iconSize", get_Index(gl_icon_size_small)); const GUI_SAVE gl_iconColor = GUI_SAVE( game_list, "iconColor", gl_icon_color); const GUI_SAVE gl_listMode = GUI_SAVE( game_list, "listMode", true ); const GUI_SAVE gl_textFactor = GUI_SAVE( game_list, "textFactor", (qreal) 2.0 ); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 8078dc7bb3..0b1514e4e6 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1044,7 +1044,7 @@ void main_window::CreateConnects() connect(&dlg, &settings_dialog::ToolBarRepaintRequest, this, &main_window::RepaintToolBarIcons); connect(&dlg, &settings_dialog::ToolBarRepaintRequest, gameListFrame, &game_list_frame::RepaintToolBarIcons); connect(&dlg, &settings_dialog::accepted, [this](){ - gameListFrame->LoadSettings(); + gameListFrame->RepaintIcons(guiSettings->GetValue(GUI::gl_iconColor).value()); QColor tbc = guiSettings->GetValue(GUI::mw_toolBarColor).value(); ui->toolBar->setStyleSheet(QString( "QToolBar { background-color: rgba(%1, %2, %3, %4); }" @@ -1167,8 +1167,8 @@ void main_window::CreateConnects() int index; if (act == ui->setIconSizeTinyAct) index = 0; - else if (act == ui->setIconSizeSmallAct) index = GUI::gl_max_slider_pos / 3; - else if (act == ui->setIconSizeMediumAct) index = GUI::gl_max_slider_pos * 2 / 3; + else if (act == ui->setIconSizeSmallAct) index = GUI::get_Index(GUI::gl_icon_size_small); + else if (act == ui->setIconSizeMediumAct) index = GUI::get_Index(GUI::gl_icon_size_medium); else index = GUI::gl_max_slider_pos; resizeIcons(index); @@ -1177,9 +1177,9 @@ void main_window::CreateConnects() { int index = GUI::gl_max_slider_pos / 4; - if (idx < index) ui->setIconSizeTinyAct->setChecked(true); - else if (idx < index * 2) ui->setIconSizeSmallAct->setChecked(true); - else if (idx < index * 3) ui->setIconSizeMediumAct->setChecked(true); + if (idx < GUI::get_Index((GUI::gl_icon_size_small + GUI::gl_icon_size_min) / 2)) ui->setIconSizeTinyAct->setChecked(true); + else if (idx < GUI::get_Index((GUI::gl_icon_size_medium + GUI::gl_icon_size_small) / 2)) ui->setIconSizeSmallAct->setChecked(true); + else if (idx < GUI::get_Index((GUI::gl_icon_size_max + GUI::gl_icon_size_medium) / 2)) ui->setIconSizeMediumAct->setChecked(true); else ui->setIconSizeLargeAct->setChecked(true); resizeIcons(idx);