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
1 changed files with 17 additions and 17 deletions

View File

@ -169,26 +169,25 @@ void PlaylistListContainer::ReloadSettings() {
void PlaylistListContainer::showEvent(QShowEvent *e) {
// Loading icons is expensive so only do it when the view is first opened
if (!loaded_icons_) {
loaded_icons_ = true;
action_new_folder_->setIcon(IconLoader::Load("folder-new"));
action_remove_->setIcon(IconLoader::Load("edit-delete"));
action_save_playlist_->setIcon(IconLoader::Load("document-save"));
action_copy_to_device_->setIcon(IconLoader::Load("device"));
model_->SetIcons(IconLoader::Load("view-media-playlist"), IconLoader::Load("folder"));
// Apply these icons to items that have already been created.
RecursivelySetIcons(model_->invisibleRootItem());
}
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
if (loaded_icons_) {
QWidget::showEvent(e);
return;
}
loaded_icons_ = true;
action_new_folder_->setIcon(IconLoader::Load("folder-new"));
action_remove_->setIcon(IconLoader::Load("edit-delete"));
action_save_playlist_->setIcon(IconLoader::Load("document-save"));
action_copy_to_device_->setIcon(IconLoader::Load("device"));
model_->SetIcons(IconLoader::Load("view-media-playlist"), IconLoader::Load("folder"));
// Apply these icons to items that have already been created.
RecursivelySetIcons(model_->invisibleRootItem());
QWidget::showEvent(e);
}
@ -336,6 +335,7 @@ void PlaylistListContainer::PlaylistPathChanged(int id, const QString &new_path)
}
void PlaylistListContainer::ItemsSelectedChanged(const bool selected) {
qLog(Debug) << __PRETTY_FUNCTION__ << selected;
ui_->remove->setEnabled(selected);
ui_->save_playlist->setEnabled(selected);
}