GUI: fix icon sizes and exterminate gamelist bug

recreate old icon size values
This commit is contained in:
Megamouse 2017-07-30 22:13:59 +02:00 committed by Ivan
parent 02845f546e
commit d51a986dd4
4 changed files with 30 additions and 9 deletions

View File

@ -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);

View File

@ -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:

View File

@ -35,11 +35,19 @@ typedef QList<q_size_pair> 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 );

View File

@ -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>());
QColor tbc = guiSettings->GetValue(GUI::mw_toolBarColor).value<QColor>();
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);