diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1335,6 +1335,22 @@ this, &DolphinMainWindow::slotStorageTearDownExternallyRequested); m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible()); + auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Show Hidden Places"), this); + actionShowAllPlaces->setCheckable(true); + connect(actionShowAllPlaces, &QAction::triggered, this, [actionShowAllPlaces, this](bool checked){ + actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint"))); + m_placesPanel->showHiddenEntries(checked); + }); + + connect(m_placesPanel, &PlacesPanel::showHiddenEntriesChanged, this, [actionShowAllPlaces] (bool checked){ + actionShowAllPlaces->setChecked(checked); + actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint"))); + }); + + connect(m_placesPanel, &PlacesPanel::hiddenListChanged, this, [actionShowAllPlaces](bool show){ + actionShowAllPlaces->setVisible(show); + }); + // Add actions into the "Panels" menu KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this); actionCollection()->addAction(QStringLiteral("panels"), panelsMenu); @@ -1347,6 +1363,7 @@ panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel"))); panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel"))); panelsMenu->addSeparator(); + panelsMenu->addAction(actionShowAllPlaces); panelsMenu->addAction(lockLayoutAction); } diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -49,13 +49,16 @@ void errorMessage(const QString& error); void storageTearDownRequested(const QString& mountPath); void storageTearDownExternallyRequested(const QString& mountPath); + void showHiddenEntriesChanged(bool shown); + void hiddenListChanged(bool empty); protected: bool urlChanged() override; void showEvent(QShowEvent* event) override; public slots: void readSettings() override; + void showHiddenEntries(bool shown); private slots: void slotItemActivated(int index); diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -144,7 +144,7 @@ selectClosestItem(); } - + emit hiddenListChanged(m_model->hiddenCount()); Panel::showEvent(event); } @@ -258,6 +258,7 @@ m_model->deleteItem(index); } else if (action == hideAction) { item->setHidden(hideAction->isChecked()); + emit hiddenListChanged(m_model->hiddenCount()); } else if (action == openInNewWindowAction) { Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this); } else if (action == openInNewTabAction) { @@ -289,9 +290,10 @@ QAction* showAllAction = nullptr; if (m_model->hiddenCount() > 0) { - showAllAction = menu.addAction(QIcon::fromTheme(QStringLiteral("visibility")), i18nc("@item:inmenu", "Show All Entries")); + showAllAction = menu.addAction(i18nc("@item:inmenu", "Show Hidden Places")); showAllAction->setCheckable(true); showAllAction->setChecked(m_model->hiddenItemsShown()); + showAllAction->setIcon(QIcon::fromTheme(m_model->hiddenItemsShown() ? QStringLiteral("visibility") : QStringLiteral("hint"))); } buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition()); @@ -341,6 +343,7 @@ addEntry(); } else if (action == showAllAction) { m_model->setHiddenItemsShown(showAllAction->isChecked()); + emit showHiddenEntriesChanged(showAllAction->isChecked()); } else if (iconSizeActionMap.contains(action)) { m_view->setIconSize(iconSizeActionMap.value(action)); } @@ -362,6 +365,7 @@ connect(hideGroupAction, &QAction::triggered, this, [this, groupType, hideGroupAction]{ m_model->setGroupHidden(groupType, hideGroupAction->isChecked()); + emit hiddenListChanged(m_model->hiddenCount()); }); return hideGroupAction; @@ -541,3 +545,8 @@ } } } + +void PlacesPanel::showHiddenEntries(bool shown) +{ + m_model->setHiddenItemsShown(shown); +}