Qt: add setting for trophy manager icon background color

This commit is contained in:
Megamouse 2019-08-10 14:06:53 +02:00
parent 2f12226ff9
commit f051f53e15
6 changed files with 41 additions and 12 deletions

View file

@ -374,6 +374,9 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& path)
// save manager icon color // save manager icon color
"QLabel#save_manager_icon_background_color { color: rgba(240, 240, 240, 255); }" "QLabel#save_manager_icon_background_color { color: rgba(240, 240, 240, 255); }"
// trophy manager icon color
"QLabel#trophy_manager_icon_background_color { color: rgba(240, 240, 240, 255); }"
// tables // tables
"QTableWidget { alternate-background-color: #f2f2f2; background-color: #fff; border: none; }" "QTableWidget { alternate-background-color: #f2f2f2; background-color: #fff; border: none; }"
"QTableWidget#game_grid { alternate-background-color: #f2f2f2; background-color: #fff; font-weight: 600; font-size: 8pt; font-family: Lucida Grande; color: rgba(51, 51, 51, 255); border: 0em solid white; }" "QTableWidget#game_grid { alternate-background-color: #f2f2f2; background-color: #fff; font-weight: 600; font-size: 8pt; font-family: Lucida Grande; color: rgba(51, 51, 51, 255); border: 0em solid white; }"

View file

@ -211,6 +211,7 @@ namespace gui
const gui_save gs_width = gui_save(gs_frame, "width", 1280); const gui_save gs_width = gui_save(gs_frame, "width", 1280);
const gui_save gs_height = gui_save(gs_frame, "height", 720); const gui_save gs_height = gui_save(gs_frame, "height", 720);
const gui_save tr_icon_color = gui_save(trophy, "icon_color", gl_icon_color);
const gui_save tr_icon_height = gui_save(trophy, "icon_height", 75); const gui_save tr_icon_height = gui_save(trophy, "icon_height", 75);
const gui_save tr_game_iconSize = gui_save(trophy, "game_iconSize", 25); const gui_save tr_game_iconSize = gui_save(trophy, "game_iconSize", 25);
const gui_save tr_show_locked = gui_save(trophy, "show_locked", true); const gui_save tr_show_locked = gui_save(trophy, "show_locked", true);

View file

@ -1281,6 +1281,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
{ {
addColoredIcon(ui->pb_gl_icon_color, xgui_settings->GetValue(gui::gl_iconColor).value<QColor>()); addColoredIcon(ui->pb_gl_icon_color, xgui_settings->GetValue(gui::gl_iconColor).value<QColor>());
addColoredIcon(ui->pb_sd_icon_color, xgui_settings->GetValue(gui::sd_icon_color).value<QColor>()); addColoredIcon(ui->pb_sd_icon_color, xgui_settings->GetValue(gui::sd_icon_color).value<QColor>());
addColoredIcon(ui->pb_tr_icon_color, xgui_settings->GetValue(gui::tr_icon_color).value<QColor>());
}; };
AddColoredIcons(); AddColoredIcons();
@ -1294,6 +1295,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
ui->cb_custom_colors->setChecked(enableUIColors); ui->cb_custom_colors->setChecked(enableUIColors);
ui->pb_gl_icon_color->setEnabled(enableUIColors); ui->pb_gl_icon_color->setEnabled(enableUIColors);
ui->pb_sd_icon_color->setEnabled(enableUIColors); ui->pb_sd_icon_color->setEnabled(enableUIColors);
ui->pb_tr_icon_color->setEnabled(enableUIColors);
auto ApplyGuiOptions = [&](bool reset = false) auto ApplyGuiOptions = [&](bool reset = false)
{ {
@ -1370,6 +1372,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
xgui_settings->SetValue(gui::m_enableUIColors, val); xgui_settings->SetValue(gui::m_enableUIColors, val);
ui->pb_gl_icon_color->setEnabled(val); ui->pb_gl_icon_color->setEnabled(val);
ui->pb_sd_icon_color->setEnabled(val); ui->pb_sd_icon_color->setEnabled(val);
ui->pb_tr_icon_color->setEnabled(val);
Q_EMIT GuiRepaintRequest(); Q_EMIT GuiRepaintRequest();
}); });
auto colorDialog = [&](const gui_save& color, const QString& title, QPushButton *button) auto colorDialog = [&](const gui_save& color, const QString& title, QPushButton *button)
@ -1402,6 +1405,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
{ {
colorDialog(gui::sd_icon_color, tr("Choose save manager icon color"), ui->pb_sd_icon_color); colorDialog(gui::sd_icon_color, tr("Choose save manager icon color"), ui->pb_sd_icon_color);
}); });
connect(ui->pb_tr_icon_color, &QAbstractButton::clicked, [=]()
{
colorDialog(gui::tr_icon_color, tr("Choose trophy manager icon color"), ui->pb_tr_icon_color);
});
AddConfigs(); AddConfigs();
AddStylesheets(); AddStylesheets();

View file

@ -2055,6 +2055,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="pb_tr_icon_color">
<property name="text">
<string>Trophy manager icons</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_5"> <spacer name="verticalSpacer_5">
<property name="orientation"> <property name="orientation">

View file

@ -327,7 +327,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
m_game_combo->setCurrentText(item->text()); m_game_combo->setCurrentText(item->text());
}); });
RepaintUI(); RepaintUI(true);
StartTrophyLoadThread(); StartTrophyLoadThread();
} }
@ -416,25 +416,25 @@ bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name)
return true; return true;
} }
void trophy_manager_dialog::RepaintUI() void trophy_manager_dialog::RepaintUI(bool restore_layout)
{ {
if (m_gui_settings->GetValue(gui::m_enableUIColors).toBool()) if (m_gui_settings->GetValue(gui::m_enableUIColors).toBool())
{ {
m_game_icon_color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>(); m_game_icon_color = m_gui_settings->GetValue(gui::tr_icon_color).value<QColor>();
} }
else else
{ {
m_game_icon_color = gui::utils::get_label_color("gamelist_icon_background_color"); m_game_icon_color = gui::utils::get_label_color("trophy_manager_icon_background_color");
} }
PopulateGameTable(); PopulateGameTable();
if (!restoreGeometry(m_gui_settings->GetValue(gui::tr_geometry).toByteArray())) if (restore_layout && !restoreGeometry(m_gui_settings->GetValue(gui::tr_geometry).toByteArray()))
{ {
resize(QDesktopWidget().availableGeometry().size() * 0.7); resize(QDesktopWidget().availableGeometry().size() * 0.7);
} }
if (!m_splitter->restoreState(m_gui_settings->GetValue(gui::tr_splitterState).toByteArray())) if (restore_layout && !m_splitter->restoreState(m_gui_settings->GetValue(gui::tr_splitterState).toByteArray()))
{ {
const int width_left = m_splitter->width() * 0.4; const int width_left = m_splitter->width() * 0.4;
const int width_right = m_splitter->width() - width_left; const int width_right = m_splitter->width() - width_left;
@ -444,7 +444,7 @@ void trophy_manager_dialog::RepaintUI()
PopulateTrophyTable(); PopulateTrophyTable();
QByteArray game_table_state = m_gui_settings->GetValue(gui::tr_games_state).toByteArray(); QByteArray game_table_state = m_gui_settings->GetValue(gui::tr_games_state).toByteArray();
if (!m_game_table->horizontalHeader()->restoreState(game_table_state) && m_game_table->rowCount()) if (restore_layout && !m_game_table->horizontalHeader()->restoreState(game_table_state) && m_game_table->rowCount())
{ {
// If no settings exist, resize to contents. (disabled) // If no settings exist, resize to contents. (disabled)
//m_game_table->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); //m_game_table->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
@ -452,7 +452,7 @@ void trophy_manager_dialog::RepaintUI()
} }
QByteArray trophy_table_state = m_gui_settings->GetValue(gui::tr_trophy_state).toByteArray(); QByteArray trophy_table_state = m_gui_settings->GetValue(gui::tr_trophy_state).toByteArray();
if (!m_trophy_table->horizontalHeader()->restoreState(trophy_table_state) && m_trophy_table->rowCount()) if (restore_layout && !m_trophy_table->horizontalHeader()->restoreState(trophy_table_state) && m_trophy_table->rowCount())
{ {
// If no settings exist, resize to contents. (disabled) // If no settings exist, resize to contents. (disabled)
//m_trophy_table->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); //m_trophy_table->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
@ -469,7 +469,18 @@ void trophy_manager_dialog::RepaintUI()
void trophy_manager_dialog::HandleRepaintUiRequest() void trophy_manager_dialog::HandleRepaintUiRequest()
{ {
RepaintUI(); const QSize window_size = size();
const QByteArray splitter_state = m_splitter->saveState();
const QByteArray game_table_state = m_game_table->horizontalHeader()->saveState();
const QByteArray trophy_table_state = m_trophy_table->horizontalHeader()->saveState();
RepaintUI(false);
m_splitter->restoreState(splitter_state);
m_game_table->horizontalHeader()->restoreState(game_table_state);
m_trophy_table->horizontalHeader()->restoreState(trophy_table_state);
resize(window_size);
} }
void trophy_manager_dialog::ResizeGameIcon(int index) void trophy_manager_dialog::ResizeGameIcon(int index)
@ -649,7 +660,7 @@ void trophy_manager_dialog::StartTrophyLoadThread()
connect(trophyThread, &QThread::finished, progressDialog, &QProgressDialog::deleteLater); connect(trophyThread, &QThread::finished, progressDialog, &QProgressDialog::deleteLater);
connect(trophyThread, &trophy_manager_dialog::trophy_load_thread::TotalCountChanged, progressDialog, &QProgressDialog::setMaximum); connect(trophyThread, &trophy_manager_dialog::trophy_load_thread::TotalCountChanged, progressDialog, &QProgressDialog::setMaximum);
connect(trophyThread, &trophy_manager_dialog::trophy_load_thread::ProcessedCountChanged, progressDialog, &QProgressDialog::setValue); connect(trophyThread, &trophy_manager_dialog::trophy_load_thread::ProcessedCountChanged, progressDialog, &QProgressDialog::setValue);
connect(trophyThread, &trophy_manager_dialog::trophy_load_thread::FinishedSuccessfully, this, &trophy_manager_dialog::HandleRepaintUiRequest); connect(trophyThread, &trophy_manager_dialog::trophy_load_thread::FinishedSuccessfully, [this]() { RepaintUI(true); });
m_thread_state = TrophyThreadState::RUNNING; m_thread_state = TrophyThreadState::RUNNING;
trophyThread->start(); trophyThread->start();
} }

View file

@ -1,4 +1,4 @@
#pragma once #pragma once
#include "stdafx.h" #include "stdafx.h"
#include "rpcs3/Loader/TROPUSR.h" #include "rpcs3/Loader/TROPUSR.h"
@ -64,7 +64,7 @@ class trophy_manager_dialog : public QWidget
public: public:
explicit trophy_manager_dialog(std::shared_ptr<gui_settings> gui_settings); explicit trophy_manager_dialog(std::shared_ptr<gui_settings> gui_settings);
~trophy_manager_dialog() override; ~trophy_manager_dialog() override;
void RepaintUI(); void RepaintUI(bool restore_layout = true);
public Q_SLOTS: public Q_SLOTS:
void HandleRepaintUiRequest(); void HandleRepaintUiRequest();