Qt: trophy repaint optimizations

This commit is contained in:
Megamouse 2018-07-08 11:48:38 +02:00 committed by Ivan
parent 0d72889c52
commit 1c9769670c
3 changed files with 18 additions and 5 deletions

View file

@ -1213,7 +1213,7 @@ void main_window::CreateConnects()
connect(ui->actionManage_Trophy_Data, &QAction::triggered, [=] connect(ui->actionManage_Trophy_Data, &QAction::triggered, [=]
{ {
trophy_manager_dialog* trop_manager = new trophy_manager_dialog(guiSettings); trophy_manager_dialog* trop_manager = new trophy_manager_dialog(guiSettings);
connect(this, &main_window::RequestTrophyManagerRepaint, trop_manager, &trophy_manager_dialog::RepaintUI); connect(this, &main_window::RequestTrophyManagerRepaint, trop_manager, &trophy_manager_dialog::HandleRepaintUiRequest);
trop_manager->show(); trop_manager->show();
}); });

View file

@ -43,6 +43,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
// Nonspecific widget settings // Nonspecific widget settings
setWindowTitle(tr("Trophy Manager")); setWindowTitle(tr("Trophy Manager"));
setObjectName("trophy_manager"); setObjectName("trophy_manager");
setAttribute(Qt::WA_DeleteOnClose);
m_game_icon_size_index = m_gui_settings->GetValue(gui::tr_game_iconSize).toInt(); m_game_icon_size_index = m_gui_settings->GetValue(gui::tr_game_iconSize).toInt();
m_icon_height = m_gui_settings->GetValue(gui::tr_icon_height).toInt(); m_icon_height = m_gui_settings->GetValue(gui::tr_icon_height).toInt();
@ -314,7 +315,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
m_game_combo->setCurrentText(m_game_table->item(m_game_table->currentRow(), GameColumns::GameName)->text()); m_game_combo->setCurrentText(m_game_table->item(m_game_table->currentRow(), GameColumns::GameName)->text());
}); });
RepaintUI(); RepaintUI(true);
} }
bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name) bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name)
@ -388,7 +389,7 @@ 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 refresh_trophies)
{ {
if (m_gui_settings->GetValue(gui::m_enableUIColors).toBool()) if (m_gui_settings->GetValue(gui::m_enableUIColors).toBool())
{ {
@ -399,7 +400,11 @@ void trophy_manager_dialog::RepaintUI()
m_game_icon_color = gui::utils::get_label_color("gamelist_icon_background_color"); m_game_icon_color = gui::utils::get_label_color("gamelist_icon_background_color");
} }
if (refresh_trophies)
{
PopulateTrophyDB(); PopulateTrophyDB();
}
PopulateGameTable(); PopulateGameTable();
if (!restoreGeometry(m_gui_settings->GetValue(gui::tr_geometry).toByteArray())) if (!restoreGeometry(m_gui_settings->GetValue(gui::tr_geometry).toByteArray()))
@ -440,6 +445,11 @@ void trophy_manager_dialog::RepaintUI()
ReadjustTrophyTable(); ReadjustTrophyTable();
} }
void trophy_manager_dialog::HandleRepaintUiRequest()
{
RepaintUI();
}
void trophy_manager_dialog::ResizeGameIcon(int index) void trophy_manager_dialog::ResizeGameIcon(int index)
{ {
QTableWidgetItem* item = m_game_table->item(index, GameColumns::GameIcon); QTableWidgetItem* item = m_game_table->item(index, GameColumns::GameIcon);
@ -567,6 +577,8 @@ void trophy_manager_dialog::ShowContextMenu(const QPoint& loc)
void trophy_manager_dialog::PopulateTrophyDB() void trophy_manager_dialog::PopulateTrophyDB()
{ {
m_trophies_db.clear();
QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)), QDir::Dirs | QDir::NoDotAndDotDot); QDirIterator dir_iter(qstr(vfs::get(m_TROPHY_DIR)), QDir::Dirs | QDir::NoDotAndDotDot);
while (dir_iter.hasNext()) while (dir_iter.hasNext())
{ {

View file

@ -53,9 +53,10 @@ 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);
void RepaintUI(bool refresh_trophies = false);
public Q_SLOTS: public Q_SLOTS:
void RepaintUI(); void HandleRepaintUiRequest();
private Q_SLOTS: private Q_SLOTS:
void ResizeGameIcon(int index); void ResizeGameIcon(int index);