mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Improve Ux for the places panel's hidden items
Summary: BUG: 400860 FIXED-IN: 18.12.0 Clean up the context menu for the places panel. - Change Text "Show All Entries" -> "Show Hidden Places" - Use State dependent icon (like hidden files) - Disable instead of hide if not places are hidden. - Toggle to unchecked if last item of group is unhidden. Create a copy of this "Show Hidden Places" entry in the main dolphin menu View->Places. Test Plan: With Hidden Places {F6398756} {F6398759} Context Menu: {F6398762} {F6398761} Without Hidden Places. {F6414694} {F6414696} Reviewers: #dolphin, #vdg, elvisangelaccio, ngraham Reviewed By: #dolphin, #vdg, elvisangelaccio, ngraham Subscribers: cfeck, elvisangelaccio, veqz, davidc, ngraham, kfm-devel Tags: #dolphin Maniphest Tasks: T8349 Differential Revision: https://phabricator.kde.org/D16767
This commit is contained in:
parent
a4cddf7517
commit
c900f7d255
|
@ -1335,6 +1335,20 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
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);
|
||||
actionShowAllPlaces->setDisabled(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")));
|
||||
});
|
||||
|
||||
// Add actions into the "Panels" menu
|
||||
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
|
||||
actionCollection()->addAction(QStringLiteral("panels"), panelsMenu);
|
||||
|
@ -1347,7 +1361,12 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel")));
|
||||
panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel")));
|
||||
panelsMenu->addSeparator();
|
||||
panelsMenu->addAction(actionShowAllPlaces);
|
||||
panelsMenu->addAction(lockLayoutAction);
|
||||
|
||||
connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{
|
||||
actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount());
|
||||
});
|
||||
}
|
||||
|
||||
void DolphinMainWindow::updateEditActions()
|
||||
|
|
|
@ -258,6 +258,9 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
|
|||
m_model->deleteItem(index);
|
||||
} else if (action == hideAction) {
|
||||
item->setHidden(hideAction->isChecked());
|
||||
if (!m_model->hiddenCount()) {
|
||||
showHiddenEntries(false);
|
||||
}
|
||||
} else if (action == openInNewWindowAction) {
|
||||
Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this);
|
||||
} else if (action == openInNewTabAction) {
|
||||
|
@ -287,12 +290,11 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
|
|||
|
||||
QAction* addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry..."));
|
||||
|
||||
QAction* showAllAction = nullptr;
|
||||
if (m_model->hiddenCount() > 0) {
|
||||
showAllAction = menu.addAction(QIcon::fromTheme(QStringLiteral("visibility")), i18nc("@item:inmenu", "Show All Entries"));
|
||||
showAllAction->setCheckable(true);
|
||||
showAllAction->setChecked(m_model->hiddenItemsShown());
|
||||
}
|
||||
QAction* 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")));
|
||||
showAllAction->setEnabled(m_model->hiddenCount());
|
||||
|
||||
buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition());
|
||||
|
||||
|
@ -340,7 +342,7 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
|
|||
if (action == addAction) {
|
||||
addEntry();
|
||||
} else if (action == showAllAction) {
|
||||
m_model->setHiddenItemsShown(showAllAction->isChecked());
|
||||
showHiddenEntries(showAllAction->isChecked());
|
||||
} else if (iconSizeActionMap.contains(action)) {
|
||||
m_view->setIconSize(iconSizeActionMap.value(action));
|
||||
}
|
||||
|
@ -362,6 +364,9 @@ QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index)
|
|||
|
||||
connect(hideGroupAction, &QAction::triggered, this, [this, groupType, hideGroupAction]{
|
||||
m_model->setGroupHidden(groupType, hideGroupAction->isChecked());
|
||||
if (!m_model->hiddenCount()) {
|
||||
showHiddenEntries(false);
|
||||
}
|
||||
});
|
||||
|
||||
return hideGroupAction;
|
||||
|
@ -541,3 +546,17 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlacesPanel::showHiddenEntries(bool shown)
|
||||
{
|
||||
m_model->setHiddenItemsShown(shown);
|
||||
emit showHiddenEntriesChanged(shown);
|
||||
}
|
||||
|
||||
int PlacesPanel::hiddenListCount()
|
||||
{
|
||||
if(!m_model) {
|
||||
return 0;
|
||||
}
|
||||
return m_model->hiddenCount();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ signals:
|
|||
void errorMessage(const QString& error);
|
||||
void storageTearDownRequested(const QString& mountPath);
|
||||
void storageTearDownExternallyRequested(const QString& mountPath);
|
||||
void showHiddenEntriesChanged(bool shown);
|
||||
|
||||
protected:
|
||||
bool urlChanged() override;
|
||||
|
@ -56,6 +57,8 @@ protected:
|
|||
|
||||
public slots:
|
||||
void readSettings() override;
|
||||
void showHiddenEntries(bool shown);
|
||||
int hiddenListCount();
|
||||
|
||||
private slots:
|
||||
void slotItemActivated(int index);
|
||||
|
|
Loading…
Reference in a new issue