-/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
- * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
- * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Stefan Monov <logixoul@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#include "dolphinmainwindow.h"
#include "dolphinbookmarkhandler.h"
#include "dolphindockwidget.h"
#include "dolphincontextmenu.h"
+#include "dolphinnavigatorswidgetaction.h"
#include "dolphinnewfilemenu.h"
#include "dolphinrecenttabsmenu.h"
+#include "dolphinurlnavigatorscontroller.h"
#include "dolphinviewcontainer.h"
#include "dolphintabpage.h"
#include "middleclickactioneventfilter.h"
#include <KIO/CommandLauncherJob>
#include <KIO/JobUiDelegate>
#include <KIO/OpenFileManagerWindowJob>
+#include <KIO/OpenUrlJob>
#include <KJobWidgets>
#include <KLocalizedString>
#include <KMessageBox>
#include <KNS3/KMoreToolsMenuFactory>
#include <KProtocolInfo>
#include <KProtocolManager>
-#include <KRun>
#include <KShell>
#include <KStandardAction>
#include <KStartupInfo>
#include <QDialog>
#include <QFileInfo>
#include <QLineEdit>
-#include <QMenu>
#include <QMenuBar>
#include <QPushButton>
#include <QShowEvent>
m_bookmarkHandler(nullptr),
m_controlButton(nullptr),
m_updateToolBarTimer(nullptr),
- m_lastHandleUrlStatJob(nullptr),
+ m_lastHandleUrlOpenJob(nullptr),
m_terminalPanel(nullptr),
m_placesPanel(nullptr),
m_tearDownFromPlacesRequested(false),
setAcceptDrops(true);
- m_tabWidget = new DolphinTabWidget(this);
+ auto *navigatorsWidgetAction = new DolphinNavigatorsWidgetAction(this);
+ actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction);
+ m_tabWidget = new DolphinTabWidget(navigatorsWidgetAction, this);
m_tabWidget->setObjectName("tabWidget");
connect(m_tabWidget, &DolphinTabWidget::activeViewChanged,
this, &DolphinMainWindow::activeViewChanged);
connect(clipboard, &QClipboard::dataChanged,
this, &DolphinMainWindow::updatePasteAction);
- QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
- showFilterBarAction->setChecked(generalSettings->filterBar());
+ QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+ toggleFilterBarAction->setChecked(generalSettings->filterBar());
if (firstRun) {
menuBar()->setVisible(false);
createControlButton();
}
+ updateAllowedToolbarAreas();
+
// enable middle-click on back/forward/up to open in a new tab
auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked);
QVector<DolphinViewContainer*> DolphinMainWindow::viewContainers() const
{
QVector<DolphinViewContainer*> viewContainers;
- viewContainers.reserve(m_tabWidget->count());
+
for (int i = 0; i < m_tabWidget->count(); ++i) {
- viewContainers << m_tabWidget->tabPageAt(i)->activeViewContainer();
+ DolphinTabPage *tabPage = m_tabWidget->tabPageAt(i);
+
+ viewContainers << tabPage->primaryViewContainer();
+ if (tabPage->splitViewEnabled()) {
+ viewContainers << tabPage->secondaryViewContainer();
+ }
}
return viewContainers;
}
+void DolphinMainWindow::setViewsWithInvalidPathsToHome()
+{
+ const QVector<DolphinViewContainer*> theViewContainers = viewContainers();
+ for (DolphinViewContainer *viewContainer : theViewContainers) {
+
+ // Only consider local dirs, not remote locations and abstract protocols
+ if (viewContainer->url().isLocalFile()) {
+ if (!QFileInfo::exists(viewContainer->url().toLocalFile())) {
+ viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+ }
+ }
+ }
+}
+
void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView)
{
m_tabWidget->openDirectories(dirs, splitView);
m_tabWidget->openFiles(files, splitView);
}
+bool DolphinMainWindow::isFoldersPanelEnabled() const
+{
+ return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
+}
+
+bool DolphinMainWindow::isInformationPanelEnabled() const
+{
+ return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
+}
+
void DolphinMainWindow::openFiles(const QStringList& files, bool splitView)
{
openFiles(QUrl::fromStringList(files), splitView);
updateViewActions();
updateGoActions();
- emit urlChanged(url);
+ Q_EMIT urlChanged(url);
}
void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
compareFilesAction->setEnabled(false);
}
- emit selectionChanged(selection);
+ Q_EMIT selectionChanged(selection);
}
void DolphinMainWindow::updateHistory()
{
- const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+ const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
const int index = urlNavigator->historyIndex();
QAction* backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
void DolphinMainWindow::updateFilterBarAction(bool show)
{
- QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
- showFilterBarAction->setChecked(show);
+ QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+ toggleFilterBarAction->setChecked(show);
}
void DolphinMainWindow::openNewMainWindow()
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
bool tabCreated = false;
- foreach (const KFileItem& item, list) {
+ for (const KFileItem& item : list) {
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
if (!url.isEmpty()) {
openNewTabAfterCurrentTab(url);
closedByUser = false;
}
- if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
+ if (m_tabWidget->count() > 1
+ && GeneralSettings::confirmClosingMultipleTabs()
+ && !GeneralSettings::rememberOpenedTabs()
+ && closedByUser) {
// Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons:
// QDialogButtonBox::Yes -> Quit
void DolphinMainWindow::slotAboutToShowBackPopupMenu()
{
- KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+ const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
int entries = 0;
m_backAction->menu()->clear();
for (int i = urlNavigator->historyIndex() + 1; i < urlNavigator->historySize() && entries < MaxNumberOfNavigationentries; ++i, ++entries) {
void DolphinMainWindow::slotGoBack(QAction* action)
{
int gotoIndex = action->data().value<int>();
- KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+ const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
for (int i = gotoIndex - urlNavigator->historyIndex(); i > 0; --i) {
goBack();
}
void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction* action)
{
if (action) {
- KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+ const KUrlNavigator *urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
openNewTabAfterCurrentTab(urlNavigator->locationUrl(action->data().value<int>()));
}
}
void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
{
- KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+ const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
int entries = 0;
m_forwardAction->menu()->clear();
for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) {
void DolphinMainWindow::slotGoForward(QAction* action)
{
int gotoIndex = action->data().value<int>();
- KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+ const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
for (int i = urlNavigator->historyIndex() - gotoIndex; i > 0; --i) {
goForward();
}
m_activeViewContainer->setFilterBarVisible(true);
}
+void DolphinMainWindow::toggleFilterBar()
+{
+ bool checked = !m_activeViewContainer->isFilterBarVisible();
+ m_activeViewContainer->setFilterBarVisible(checked);
+
+ QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+ toggleFilterBarAction->setChecked(checked);
+}
+
void DolphinMainWindow::toggleEditLocation()
{
clearStatusBar();
void DolphinMainWindow::togglePanelLockState()
{
const bool newLockState = !GeneralSettings::lockPanels();
- foreach (QObject* child, children()) {
+ const auto childrenObjects = children();
+ for (QObject* child : childrenObjects) {
DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
if (dock) {
dock->setLocked(newLockState);
void DolphinMainWindow::goBack()
{
- KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+ DolphinUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
urlNavigator->goBack();
if (urlNavigator->locationState().isEmpty()) {
void DolphinMainWindow::goForward()
{
- m_activeViewContainer->urlNavigator()->goForward();
+ m_activeViewContainer->urlNavigatorInternalWithHistory()->goForward();
}
void DolphinMainWindow::goUp()
{
- m_activeViewContainer->urlNavigator()->goUp();
+ m_activeViewContainer->urlNavigatorInternalWithHistory()->goUp();
}
void DolphinMainWindow::goHome()
{
- m_activeViewContainer->urlNavigator()->goHome();
+ m_activeViewContainer->urlNavigatorInternalWithHistory()->goHome();
}
void DolphinMainWindow::goBackInNewTab()
{
- KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+ const KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
const int index = urlNavigator->historyIndex() + 1;
openNewTabAfterCurrentTab(urlNavigator->locationUrl(index));
}
void DolphinMainWindow::goForwardInNewTab()
{
- KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+ const KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
const int index = urlNavigator->historyIndex() - 1;
openNewTabAfterCurrentTab(urlNavigator->locationUrl(index));
}
}
}
-QString DolphinMainWindow::activeContainerLocalPath()
-{
- KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
- KJobWidgets::setWindow(statJob, this);
- statJob->exec();
- QUrl url = statJob->mostLocalUrl();
- if (url.isLocalFile()) {
- return url.toLocalFile();
- }
- return QDir::homePath();
-}
-
QPointer<QAction> DolphinMainWindow::preferredSearchTool()
{
m_searchTools.clear();
void DolphinMainWindow::openTerminal()
{
- KToolInvocation::invokeTerminal(QString(), activeContainerLocalPath());
+ const QUrl url = m_activeViewContainer->url();
+
+ if (url.isLocalFile()) {
+ KToolInvocation::invokeTerminal(QString(), url.toLocalFile());
+ return;
+ }
+
+ // Not a local file, with protocol Class ":local", try stat'ing
+ if (KProtocolInfo::protocolClass(url.scheme()) == QLatin1String(":local")) {
+ KIO::StatJob *job = KIO::mostLocalUrl(url);
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KJob::result, this, [job]() {
+ QUrl statUrl;
+ if (!job->error()) {
+ statUrl = job->mostLocalUrl();
+ }
+
+ KToolInvocation::invokeTerminal(QString(), statUrl.isLocalFile() ? statUrl.toLocalFile() : QDir::homePath());
+ });
+
+ return;
+ }
+
+ // Nothing worked, just use $HOME
+ KToolInvocation::invokeTerminal(QString(), QDir::homePath());
}
void DolphinMainWindow::editSettings()
const QUrl url = container->url();
DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
+ connect(settingsDialog, &DolphinSettingsDialog::settingsChanged,
+ &DolphinUrlNavigatorsController::slotReadSettings);
settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
settingsDialog->show();
m_settingsDialog = settingsDialog;
void DolphinMainWindow::handleUrl(const QUrl& url)
{
- delete m_lastHandleUrlStatJob;
- m_lastHandleUrlStatJob = nullptr;
+ delete m_lastHandleUrlOpenJob;
+ m_lastHandleUrlOpenJob = nullptr;
if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
activeViewContainer()->setUrl(url);
- } else if (KProtocolManager::supportsListing(url)) {
- // stat the URL to see if it is a dir or not
- m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
- if (m_lastHandleUrlStatJob->uiDelegate()) {
- KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
- }
- connect(m_lastHandleUrlStatJob, &KIO::Job::result,
- this, &DolphinMainWindow::slotHandleUrlStatFinished);
-
} else {
- new KRun(url, this); // Automatically deletes itself after being finished
- }
-}
+ m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url);
+ m_lastHandleUrlOpenJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+ m_lastHandleUrlOpenJob->setRunExecutables(true);
-void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
-{
- m_lastHandleUrlStatJob = nullptr;
- const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
- const QUrl url = static_cast<KIO::StatJob*>(job)->url();
- if (entry.isDir()) {
- activeViewContainer()->setUrl(url);
- } else {
- new KRun(url, this); // Automatically deletes itself after being finished
+ connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this,
+ [this, url](const QString &mimetype) {
+ if (mimetype == QLatin1String("inode/directory")) {
+ // If it's a dir, we'll take it from here
+ m_lastHandleUrlOpenJob->kill();
+ m_lastHandleUrlOpenJob = nullptr;
+ activeViewContainer()->setUrl(url);
+ }
+ });
+
+ connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::result, this, [this]() {
+ m_lastHandleUrlOpenJob = nullptr;
+ });
+
+ m_lastHandleUrlOpenJob->start();
}
}
// Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
+ addActionToMenu(ac->action(QString("copy_location")), menu) |
addActionToMenu(ac->action(QStringLiteral("copy_to_inactive_split_view")), menu) |
addActionToMenu(ac->action(QStringLiteral("move_to_inactive_split_view")), menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
// view and url navigator) and main window.
oldViewContainer->disconnect(this);
oldViewContainer->view()->disconnect(this);
- oldViewContainer->urlNavigator()->disconnect(this);
+ auto navigators = static_cast<DolphinNavigatorsWidgetAction *>
+ (actionCollection()->action(QStringLiteral("url_navigators")));
+ navigators->primaryUrlNavigator()->disconnect(this);
+ if (auto secondaryUrlNavigator = navigators->secondaryUrlNavigator()) {
+ secondaryUrlNavigator->disconnect(this);
+ }
// except the requestItemInfo so that on hover the information panel can still be updated
connect(oldViewContainer->view(), &DolphinView::requestItemInfo,
updateSearchAction();
const QUrl url = viewContainer->url();
- emit urlChanged(url);
+ Q_EMIT urlChanged(url);
}
void DolphinMainWindow::tabCountChanged(int count)
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
}
+void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString& mountPath)
+{
+ const QVector<DolphinViewContainer*> theViewContainers = viewContainers();
+ for (DolphinViewContainer *viewContainer : theViewContainers) {
+ if (viewContainer && viewContainer->url().toLocalFile().startsWith(mountPath)) {
+ viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+ }
+ }
+ disconnect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, nullptr, nullptr);
+}
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
"action they are removed from their old location.") + cutCopyPastePara);
QAction* copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
- copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to inactive split view"));
+ copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Inactive Split View"));
copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from "
"the <emphasis>active</emphasis> view to the inactive split view."));
copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
- copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to inactive split view"));
+ copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to Inactive Split View"));
actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT + Qt::Key_F5 );
connect(copyToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::copyToInactiveSplitView);
QAction* moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
- moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to inactive split view"));
+ moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Inactive Split View"));
moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from "
"the <emphasis>active</emphasis> view to the inactive split view."));
moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
- moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to inactive split view"));
+ moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to Inactive Split View"));
actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT + Qt::Key_F6 );
connect(moveToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::moveToInactiveSplitView);
+ QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
+ showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter..."));
+ showFilterBar->setToolTip(i18nc("@info:tooltip", "Toggle Filter Bar"));
+ showFilterBar->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
+ "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
+ "There you can enter a text to filter the files and folders currently displayed. "
+ "Only those that contain the text in their name will be kept in view."));
+ showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
+ actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash});
+ connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
+
+ // toggle_filter acts as a copy of the main showFilterBar to be used mainly
+ // in the toolbar, with no default shortcut attached, to avoid messing with
+ // existing workflows (filter bar always open and Ctrl-I to focus)
+ QAction *toggleFilter = actionCollection()->addAction(QStringLiteral("toggle_filter"));
+ toggleFilter->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
+ toggleFilter->setIconText(i18nc("@action:intoolbar", "Filter"));
+ toggleFilter->setIcon(showFilterBar->icon());
+ toggleFilter->setToolTip(showFilterBar->toolTip());
+ toggleFilter->setWhatsThis(showFilterBar->whatsThis());
+ toggleFilter->setCheckable(true);
+ connect(toggleFilter, &QAction::triggered, this, &DolphinMainWindow::toggleFilterBar);
+
QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
searchAction->setText(i18n("Search..."));
searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
"including folders that contain personal application data."));
// setup 'Tools' menu
- QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
- showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
- showFilterBar->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
- "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
- "There you can enter a text to filter the files and folders currently displayed. "
- "Only those that contain the text in their name will be kept in view."));
- showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
- actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash});
- connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
-
QAction* compareFiles = actionCollection()->addAction(QStringLiteral("compare_files"));
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
compareFiles->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
actionCollection()->setDefaultShortcut(openPreferredSearchTool, Qt::CTRL + Qt::SHIFT + Qt::Key_F);
connect(openPreferredSearchTool, &QAction::triggered, this, &DolphinMainWindow::openPreferredSearchTool);
-#ifdef HAVE_TERMINAL
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
openTerminal->setWhatsThis(xi18nc("@info:whatsthis",
"<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
"<para>To learn more about terminals use the help in the terminal application.</para>"));
- openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
+ openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
+#ifdef HAVE_TERMINAL
QAction* focusTerminalPanel = actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
focusTerminalPanel->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
focusTerminalPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
actionCollection()->setDefaultShortcut(focusTerminalPanel, Qt::CTRL + Qt::SHIFT + Qt::Key_F4);
connect(focusTerminalPanel, &QAction::triggered, this, &DolphinMainWindow::focusTerminalPanel);
- }
#endif
+ }
// setup 'Bookmarks' menu
KActionMenu *bookmarkMenu = new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
connect(this, &DolphinMainWindow::urlChanged,
m_placesPanel, &PlacesPanel::setUrl);
connect(placesDock, &DolphinDockWidget::visibilityChanged,
- m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
+ &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged);
connect(this, &DolphinMainWindow::settingsChanged,
m_placesPanel, &PlacesPanel::readSettings);
connect(m_placesPanel, &PlacesPanel::storageTearDownRequested,
this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested);
connect(m_placesPanel, &PlacesPanel::storageTearDownExternallyRequested,
this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
- m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
+ DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
actionShowAllPlaces->setCheckable(true);
QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places"));
QAction* copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view"));
QAction* moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_split_view"));
+ QAction* copyLocation = col->action(QString("copy_location"));
if (list.isEmpty()) {
stateChanged(QStringLiteral("has_no_selection"));
addToPlacesAction->setEnabled(true);
copyToOtherViewAction->setEnabled(false);
moveToOtherViewAction->setEnabled(false);
+ copyLocation->setEnabled(false);
} else {
stateChanged(QStringLiteral("has_selection"));
deleteAction->setEnabled(capabilitiesSource.supportsDeleting());
deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting() && !enableMoveToTrash);
cutAction->setEnabled(capabilitiesSource.supportsMoving());
+ copyLocation->setEnabled(list.length() == 1);
showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
}
{
m_actionHandler->updateViewActions();
- QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
- showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
+ QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+ toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
updateSplitAction();
-
- QAction* editableLocactionAction = actionCollection()->action(QStringLiteral("editable_location"));
- const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
- editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
}
void DolphinMainWindow::updateGoActions()
Q_ASSERT(menu);
const KToolBar* toolBarWidget = toolBar();
- foreach (const QWidget* widget, action->associatedWidgets()) {
+ const auto associatedWidgets = action->associatedWidgets();
+ for (const QWidget* widget : associatedWidgets) {
if (widget == toolBarWidget) {
return false;
}
updateWindowTitle();
}
- emit settingsChanged();
+ Q_EMIT settingsChanged();
}
void DolphinMainWindow::clearStatusBar()
this, &DolphinMainWindow::goForward);
connect(view, &DolphinView::urlActivated,
this, &DolphinMainWindow::handleUrl);
+ connect(view, &DolphinView::goUpRequested,
+ this, &DolphinMainWindow::goUp);
+
+ auto navigators = static_cast<DolphinNavigatorsWidgetAction *>
+ (actionCollection()->action(QStringLiteral("url_navigators")));
+
+ const KUrlNavigator *navigator = m_tabWidget->currentTabPage()->primaryViewActive() ?
+ navigators->primaryUrlNavigator() :
+ navigators->secondaryUrlNavigator();
- const KUrlNavigator* navigator = container->urlNavigator();
connect(navigator, &KUrlNavigator::urlChanged,
this, &DolphinMainWindow::changeUrl);
- connect(navigator, &KUrlNavigator::historyChanged,
- this, &DolphinMainWindow::updateHistory);
+ QAction *editableLocactionAction = actionCollection()->action(QStringLiteral("editable_location"));
+ editableLocactionAction->setChecked(navigator->isUrlEditable());
connect(navigator, &KUrlNavigator::editableStateChanged,
this, &DolphinMainWindow::slotEditableStateChanged);
connect(navigator, &KUrlNavigator::tabRequested,
this, &DolphinMainWindow::openNewTabAfterLastTab);
+
+ disconnect(m_updateHistoryConnection);
+ m_updateHistoryConnection = connect(
+ container->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged,
+ this, &DolphinMainWindow::updateHistory);
}
void DolphinMainWindow::updateSplitAction()
}
}
+void DolphinMainWindow::updateAllowedToolbarAreas()
+{
+ auto navigators = static_cast<DolphinNavigatorsWidgetAction *>
+ (actionCollection()->action(QStringLiteral("url_navigators")));
+ if (toolBar()->actions().contains(navigators)) {
+ toolBar()->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
+ if (toolBarArea(toolBar()) == Qt::LeftToolBarArea ||
+ toolBarArea(toolBar()) == Qt::RightToolBarArea) {
+ addToolBar(Qt::TopToolBarArea, toolBar());
+ }
+ } else {
+ toolBar()->setAllowedAreas(Qt::AllToolBarAreas);
+ }
+}
+
bool DolphinMainWindow::isKompareInstalled() const
{
static bool initialized = false;
return false;
}
+void DolphinMainWindow::saveNewToolbarConfig()
+{
+ KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
+ // because the rest of this method decides things
+ // based on the new config.
+ auto navigators = static_cast<DolphinNavigatorsWidgetAction *>
+ (actionCollection()->action(QStringLiteral("url_navigators")));
+ if (!toolBar()->actions().contains(navigators)) {
+ m_tabWidget->currentTabPage()->insertNavigatorsWidget(navigators);
+ }
+ updateAllowedToolbarAreas();
+}
+
void DolphinMainWindow::focusTerminalPanel()
{
if (m_terminalPanel->isVisible()) {