]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Merge branch 'Applications/18.12'
[dolphin.git] / src / dolphinmainwindow.cpp
index b14f5289cd0c31344d1aa10329e0f74f6586b530..dcf22e455fc0c72d793c92b698fb4a6e4dc7b1a1 100644 (file)
@@ -551,7 +551,7 @@ void DolphinMainWindow::selectAll()
     // URL instead of all items of the view
 
     KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
-    QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses
+    QLineEdit* lineEdit = urlNavigator->editor()->lineEdit();
     const bool selectUrl = urlNavigator->isUrlEditable() &&
                            lineEdit->hasFocus();
     if (selectUrl) {
@@ -621,12 +621,19 @@ void DolphinMainWindow::toggleEditLocation()
 void DolphinMainWindow::replaceLocation()
 {
     KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
-    navigator->setUrlEditable(true);
-    navigator->setFocus();
-
-    // select the whole text of the combo box editor
-    QLineEdit* lineEdit = navigator->editor()->lineEdit();  // krazy:exclude=qclasses
-    lineEdit->selectAll();
+    QLineEdit* lineEdit = navigator->editor()->lineEdit();
+
+    // If the text field currently has focus and everything is selected,
+    // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
+    if (navigator->isUrlEditable()
+        && lineEdit->hasFocus()
+        && lineEdit->selectedText() == lineEdit->text() ) {
+        navigator->setUrlEditable(false);
+    } else {
+        navigator->setUrlEditable(true);
+        navigator->setFocus();
+        lineEdit->selectAll();
+    }
 }
 
 void DolphinMainWindow::togglePanelLockState()
@@ -1037,6 +1044,7 @@ void DolphinMainWindow::setupActions()
 
     QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
     newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
+    newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
 
     QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
     newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
@@ -1335,6 +1343,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 +1369,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()