Load icons for buttons before setting enabled/disabled

Fixes #500
This commit is contained in:
Jonas Kvinge
2020-08-30 01:57:21 +02:00
parent c7146ef138
commit 841065fb91

View File

@@ -169,14 +169,8 @@ void PlaylistListContainer::ReloadSettings() {
void PlaylistListContainer::showEvent(QShowEvent *e) { void PlaylistListContainer::showEvent(QShowEvent *e) {
ui_->remove->setEnabled(ui_->tree->ItemsSelected());
ui_->save_playlist->setEnabled(ui_->tree->ItemsSelected());
// Loading icons is expensive so only do it when the view is first opened // Loading icons is expensive so only do it when the view is first opened
if (loaded_icons_) { if (!loaded_icons_) {
QWidget::showEvent(e);
return;
}
loaded_icons_ = true; loaded_icons_ = true;
action_new_folder_->setIcon(IconLoader::Load("folder-new")); action_new_folder_->setIcon(IconLoader::Load("folder-new"));
@@ -189,6 +183,11 @@ void PlaylistListContainer::showEvent(QShowEvent *e) {
// Apply these icons to items that have already been created. // Apply these icons to items that have already been created.
RecursivelySetIcons(model_->invisibleRootItem()); RecursivelySetIcons(model_->invisibleRootItem());
}
ui_->remove->setEnabled(ui_->tree->ItemsSelected());
ui_->save_playlist->setEnabled(ui_->tree->ItemsSelected());
QWidget::showEvent(e); QWidget::showEvent(e);
} }
@@ -336,6 +335,7 @@ void PlaylistListContainer::PlaylistPathChanged(int id, const QString &new_path)
} }
void PlaylistListContainer::ItemsSelectedChanged(const bool selected) { void PlaylistListContainer::ItemsSelectedChanged(const bool selected) {
qLog(Debug) << __PRETTY_FUNCTION__ << selected;
ui_->remove->setEnabled(selected); ui_->remove->setEnabled(selected);
ui_->save_playlist->setEnabled(selected); ui_->save_playlist->setEnabled(selected);
} }