1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 12:42:41 +01:00

game_list: enable stepless icon sizes

This commit is contained in:
Megamouse 2017-07-25 16:46:18 +02:00 committed by Ivan
parent d260ccfc96
commit 9f3f07f3ae
4 changed files with 41 additions and 61 deletions

View File

@ -26,12 +26,13 @@
static const std::string m_class_name = "GameViewer";
inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); }
inline QSize sizeFromSlider(const int& pos) { return GUI::gl_icon_size_min + (GUI::gl_icon_size_max - GUI::gl_icon_size_min) * (pos / (float)GUI::gl_max_slider_pos); }
game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, const Render_Creator& r_Creator, QWidget *parent)
: QDockWidget(tr("Game List"), parent), xgui_settings(settings), m_Render_Creator(r_Creator)
{
m_isListLayout = xgui_settings->GetValue(GUI::gl_listMode).toBool();
m_Icon_Size_Str = xgui_settings->GetValue(GUI::gl_iconSize).toString();
m_icon_size_index = xgui_settings->GetValue(GUI::gl_iconSize).toInt();
m_Margin_Factor = xgui_settings->GetValue(GUI::gl_marginFactor).toReal();
m_Text_Factor = xgui_settings->GetValue(GUI::gl_textFactor).toReal();
m_showToolBar = xgui_settings->GetValue(GUI::gl_toolBarVisible).toBool();
@ -39,18 +40,6 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, const R
m_oldLayoutIsList = m_isListLayout;
// get icon size from list
int icon_size_index = 0;
for (int i = 0; i < GUI::gl_icon_size.count(); i++)
{
if (GUI::gl_icon_size.at(i).first == m_Icon_Size_Str)
{
m_Icon_Size = GUI::gl_icon_size.at(i).second;
icon_size_index = i;
break;
}
}
// Save factors for first setup
xgui_settings->SetValue(GUI::gl_iconColor, m_Icon_Color);
xgui_settings->SetValue(GUI::gl_marginFactor, m_Margin_Factor);
@ -123,8 +112,8 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, const R
// Icon Size Slider
m_Slider_Size = new QSlider(Qt::Horizontal , m_Tool_Bar);
m_Slider_Size->setRange(0, GUI::gl_icon_size.size() - 1);
m_Slider_Size->setSliderPosition(icon_size_index);
m_Slider_Size->setRange(0, GUI::gl_max_slider_pos);
m_Slider_Size->setSliderPosition(m_icon_size_index);
m_Slider_Size->setFixedWidth(m_Tool_Bar->height() * 3);
m_Tool_Bar->addWidget(m_Search_Bar);
@ -148,7 +137,8 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, const R
RepaintToolBarIcons();
bool showText = (m_Icon_Size_Str != GUI::gl_icon_key_small && m_Icon_Size_Str != GUI::gl_icon_key_tiny);
bool showText = m_icon_size_index < GUI::gl_max_slider_pos;
m_Icon_Size = sizeFromSlider(m_icon_size_index);
m_xgrid = new game_list_grid(m_Icon_Size, m_Icon_Color, m_Margin_Factor, m_Text_Factor, showText);
gameList = new game_list();
@ -730,17 +720,17 @@ void game_list_frame::RemoveCustomConfiguration(int row)
}
}
void game_list_frame::ResizeIcons(const QString& sizeStr, const QSize& size, const int& index)
void game_list_frame::ResizeIcons(const int& sliderPos)
{
m_Icon_Size_Str = sizeStr;
m_Icon_Size = size;
m_icon_size_index = sliderPos;
m_Icon_Size = sizeFromSlider(sliderPos);
if (m_Slider_Size->value() != index)
if (m_Slider_Size->value() != sliderPos)
{
m_Slider_Size->setSliderPosition(index);
m_Slider_Size->setSliderPosition(sliderPos);
}
xgui_settings->SetValue(GUI::gl_iconSize, m_Icon_Size_Str);
xgui_settings->SetValue(GUI::gl_iconSize, sliderPos);
for (size_t i = 0; i < m_game_data.size(); i++)
{
@ -894,9 +884,9 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co
m_xgrid->deleteLater();
bool showText = m_Icon_Size_Str != GUI::gl_icon_key_small && m_Icon_Size_Str != GUI::gl_icon_key_tiny;
bool showText = m_icon_size_index > GUI::gl_max_slider_pos * 2 / 5;
if (m_Icon_Size_Str == GUI::gl_icon_key_medium)
if (m_icon_size_index < GUI::gl_max_slider_pos * 2 / 3)
{
m_xgrid = new game_list_grid(image_size, image_color, m_Margin_Factor, m_Text_Factor * 2, showText);
}

View File

@ -187,8 +187,8 @@ public:
/** Saves settings. Public so that main frame can save this when a caching of column widths is needed for settings backup */
void SaveSettings();
/** Resize Gamelist Icons to size */
void ResizeIcons(const QString& sizeStr, const QSize& size, const int& index);
/** Resize Gamelist Icons to size given by slider position */
void ResizeIcons(const int& sliderPos);
public Q_SLOTS:
void SetListMode(const bool& isList);
@ -278,7 +278,7 @@ private:
bool m_showToolBar = true;
std::vector<GUI_GameInfo> m_game_data;
QSize m_Icon_Size;
QString m_Icon_Size_Str;
int m_icon_size_index;
QColor m_Icon_Color;
qreal m_Margin_Factor;
qreal m_Text_Factor;

View File

@ -35,17 +35,10 @@ typedef QList<q_size_pair> q_size_list;
namespace GUI
{
const QString gl_icon_key_tiny = "tiny";
const QString gl_icon_key_small = "small";
const QString gl_icon_key_medium = "medium";
const QString gl_icon_key_large = "large";
const QSize gl_icon_size_min = QSize(40, 22);
const QSize gl_icon_size_max = QSize(320, 176);
const q_size_list gl_icon_size = {
{ gl_icon_key_tiny, QSize(40, 22) },
{ gl_icon_key_small, QSize(80, 44) },
{ gl_icon_key_medium, QSize(160, 88) },
{ gl_icon_key_large, QSize(320, 176) }
};
const int gl_max_slider_pos = 100;
const QString main_window = "main_window";
const QString game_list = "GameList";
@ -95,7 +88,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_icon_key_small );
const GUI_SAVE gl_iconSize = GUI_SAVE( game_list, "iconSize", gl_max_slider_pos / 2);
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

@ -75,19 +75,8 @@ void main_window::Init()
appIcon = QIcon(":/rpcs3.ico");
// add toolbar widgets (crappy Qt designer is not able to)
ui->sizeSlider->setRange(0, GUI::gl_icon_size.size() - 1);
// get icon size from list
int icon_size_index = 0;
QString icon_Size_Str = guiSettings->GetValue(GUI::gl_iconSize).toString();
for (int i = 0; i < GUI::gl_icon_size.count(); i++)
{
if (GUI::gl_icon_size.at(i).first == icon_Size_Str)
{
icon_size_index = i;
break;
}
}
ui->sizeSlider->setSliderPosition(icon_size_index);
ui->sizeSlider->setRange(0, GUI::gl_max_slider_pos);
ui->sizeSlider->setSliderPosition(guiSettings->GetValue(GUI::gl_iconSize).toInt());
ui->toolBar->addWidget(ui->sizeSliderContainer);
ui->toolBar->addSeparator();
ui->toolBar->addWidget(ui->searchBar);
@ -1162,22 +1151,29 @@ void main_window::CreateConnects()
{
ui->sizeSlider->setSliderPosition(index);
}
gameListFrame->ResizeIcons(GUI::gl_icon_size.at(index).first, GUI::gl_icon_size.at(index).second, index);
gameListFrame->ResizeIcons(index);
};
connect(iconSizeActGroup, &QActionGroup::triggered, [=](QAction* act)
{
int index;
if (act == ui->setIconSizeTinyAct) index = 0;
else if (act == ui->setIconSizeSmallAct) index = 1;
else if (act == ui->setIconSizeMediumAct) index = 2;
else index = 3;
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 index = GUI::gl_max_slider_pos;
resizeIcons(index);
});
connect (gameListFrame, &game_list_frame::RequestIconSizeActSet, [=](const int& idx)
{
iconSizeActGroup->actions().at(idx)->trigger();
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);
else ui->setIconSizeLargeAct->setChecked(true);
resizeIcons(idx);
});
connect(gameListFrame, &game_list_frame::RequestListModeActSet, [=](const bool& isList)
{
@ -1339,11 +1335,12 @@ void main_window::ConfigureGuiFromSettings(bool configureAll)
ui->showCatUnknownAct->setChecked(guiSettings->GetCategoryVisibility(Category::Unknown_Cat));
ui->showCatOtherAct->setChecked(guiSettings->GetCategoryVisibility(Category::Others));
QString key = guiSettings->GetValue(GUI::gl_iconSize).toString();
if (key == GUI::gl_icon_key_large) ui->setIconSizeLargeAct->setChecked(true);
else if (key == GUI::gl_icon_key_medium) ui->setIconSizeMediumAct->setChecked(true);
else if (key == GUI::gl_icon_key_small) ui->setIconSizeSmallAct->setChecked(true);
else ui->setIconSizeTinyAct->setChecked(true);
int idx = guiSettings->GetValue(GUI::gl_iconSize).toInt();
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);
else ui->setIconSizeLargeAct->setChecked(true);
bool isListMode = guiSettings->GetValue(GUI::gl_listMode).toBool();
if (isListMode) ui->setlistModeListAct->setChecked(true);