2 * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2006 Stefan Monov <logixoul@gmail.com>
4 * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0-or-later
9 #include "dolphinmainwindow.h"
11 #include "dolphinmainwindowadaptor.h"
12 #include "config-terminal.h"
14 #include "dolphinbookmarkhandler.h"
15 #include "dolphindockwidget.h"
16 #include "dolphincontextmenu.h"
17 #include "dolphinnavigatorswidgetaction.h"
18 #include "dolphinnewfilemenu.h"
19 #include "dolphinrecenttabsmenu.h"
20 #include "dolphinplacesmodelsingleton.h"
21 #include "dolphinurlnavigatorscontroller.h"
22 #include "dolphinviewcontainer.h"
23 #include "dolphintabpage.h"
24 #include "middleclickactioneventfilter.h"
25 #include "panels/folders/folderspanel.h"
26 #include "panels/places/placespanel.h"
27 #include "panels/terminal/terminalpanel.h"
28 #include "settings/dolphinsettingsdialog.h"
29 #include "statusbar/dolphinstatusbar.h"
30 #include "views/dolphinviewactionhandler.h"
31 #include "views/dolphinremoteencoding.h"
32 #include "views/draganddrophelper.h"
33 #include "views/viewproperties.h"
34 #include "views/dolphinnewfilemenuobserver.h"
35 #include "dolphin_generalsettings.h"
37 #include <KActionCollection>
38 #include <KActionMenu>
39 #include <KAuthorized>
42 #include <KDualAction>
43 #include <KFileItemListProperties>
45 #include <KIO/CommandLauncherJob>
46 #include <KIO/JobUiDelegate>
47 #include <KIO/OpenFileManagerWindowJob>
48 #include <KIO/OpenUrlJob>
49 #include <KJobWidgets>
50 #include <KLocalizedString>
51 #include <KMessageBox>
52 #include <KNS3/KMoreToolsMenuFactory>
53 #include <KProtocolInfo>
54 #include <KProtocolManager>
56 #include <KStandardAction>
57 #include <KStartupInfo>
59 #include <KTerminalLauncherJob>
60 #include <KToggleAction>
62 #include <KToolBarPopupAction>
63 #include <KUrlComboBox>
64 #include <KUrlNavigator>
65 #include <KWindowSystem>
66 #include <KXMLGUIFactory>
67 #include <kxmlgui_version.h>
69 #include <kio_version.h>
71 #include <QApplication>
73 #include <QCloseEvent>
74 #include <QDesktopServices>
76 #include <QDomDocument>
80 #include <QPushButton>
82 #include <QStandardPaths>
84 #include <QToolButton>
85 #include <QWhatsThisClickedEvent>
88 // Used for GeneralSettings::version() to determine whether
89 // an updated version of Dolphin is running.
90 const int CurrentDolphinVersion
= 201;
91 // The maximum number of entries in the back/forward popup menu
92 const int MaxNumberOfNavigationentries
= 12;
93 // The maximum number of "Activate Tab" shortcuts
94 const int MaxActivateTabShortcuts
= 9;
97 DolphinMainWindow::DolphinMainWindow() :
98 KXmlGuiWindow(nullptr),
99 m_newFileMenu(nullptr),
101 m_tabWidget(nullptr),
102 m_activeViewContainer(nullptr),
103 m_actionHandler(nullptr),
104 m_remoteEncoding(nullptr),
106 m_bookmarkHandler(nullptr),
107 m_controlButton(nullptr),
108 m_updateToolBarTimer(nullptr),
109 m_lastHandleUrlOpenJob(nullptr),
110 m_terminalPanel(nullptr),
111 m_placesPanel(nullptr),
112 m_tearDownFromPlacesRequested(false),
113 m_backAction(nullptr),
114 m_forwardAction(nullptr)
116 Q_INIT_RESOURCE(dolphin
);
118 new MainWindowAdaptor(this);
121 setWindowFlags(Qt::WindowContextHelpButtonHint
);
123 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
124 setObjectName(QStringLiteral("Dolphin#"));
126 #if KXMLGUI_VERSION >= QT_VERSION_CHECK(5, 88, 0)
127 setStateConfigGroup("State");
130 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
131 this, &DolphinMainWindow::showErrorMessage
);
133 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
134 undoManager
->setUiInterface(new UndoUiInterface());
136 connect(undoManager
, &KIO::FileUndoManager::undoAvailable
,
137 this, &DolphinMainWindow::slotUndoAvailable
);
138 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
139 this, &DolphinMainWindow::slotUndoTextChanged
);
140 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
141 this, &DolphinMainWindow::clearStatusBar
);
142 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
143 this, &DolphinMainWindow::showCommand
);
145 const bool firstRun
= (GeneralSettings::version() < 200);
147 GeneralSettings::setViewPropsTimestamp(QDateTime::currentDateTime());
150 setAcceptDrops(true);
152 auto *navigatorsWidgetAction
= new DolphinNavigatorsWidgetAction(this);
153 actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction
);
154 m_tabWidget
= new DolphinTabWidget(navigatorsWidgetAction
, this);
155 m_tabWidget
->setObjectName("tabWidget");
156 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
157 this, &DolphinMainWindow::activeViewChanged
);
158 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
159 this, &DolphinMainWindow::tabCountChanged
);
160 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
161 this, &DolphinMainWindow::updateWindowTitle
);
162 setCentralWidget(m_tabWidget
);
166 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
167 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
168 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
170 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
171 connect(this, &DolphinMainWindow::urlChanged
,
172 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
176 setupGUI(Keys
| Save
| Create
| ToolBar
);
177 stateChanged(QStringLiteral("new_file"));
179 QClipboard
* clipboard
= QApplication::clipboard();
180 connect(clipboard
, &QClipboard::dataChanged
,
181 this, &DolphinMainWindow::updatePasteAction
);
183 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
184 toggleFilterBarAction
->setChecked(GeneralSettings::filterBar());
187 menuBar()->setVisible(false);
190 const bool showMenu
= !menuBar()->isHidden();
191 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
192 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
194 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(actionCollection()->action(
195 KStandardAction::name(KStandardAction::HamburgerMenu
)));
196 hamburgerMenu
->setMenuBar(menuBar());
197 hamburgerMenu
->setShowMenuBarAction(showMenuBarAction
);
198 connect(hamburgerMenu
, &KHamburgerMenu::aboutToShowMenu
,
199 this, &DolphinMainWindow::updateHamburgerMenu
);
200 hamburgerMenu
->hideActionsOf(toolBar());
201 if (GeneralSettings::version() < 201 && !toolBar()->actions().contains(hamburgerMenu
)) {
202 addHamburgerMenuToToolbar();
205 updateAllowedToolbarAreas();
207 // enable middle-click on back/forward/up to open in a new tab
208 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
209 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
210 toolBar()->installEventFilter(middleClickEventFilter
);
214 connect(KSycoca::self(), &KSycoca::databaseChanged
, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
216 QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
218 m_fileItemActions
.setParentWidget(this);
219 connect(&m_fileItemActions
, &KFileItemActions::error
, this, [this](const QString
&errorMessage
) {
220 showErrorMessage(errorMessage
);
223 connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged
,
224 this, &DolphinMainWindow::slotSplitViewChanged
);
227 DolphinMainWindow::~DolphinMainWindow()
229 // This fixes a crash on Wayland when closing the mainwindow while another dialog is open.
230 disconnect(QGuiApplication::clipboard(), &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
233 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
235 QVector
<DolphinViewContainer
*> viewContainers
;
237 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
238 DolphinTabPage
*tabPage
= m_tabWidget
->tabPageAt(i
);
240 viewContainers
<< tabPage
->primaryViewContainer();
241 if (tabPage
->splitViewEnabled()) {
242 viewContainers
<< tabPage
->secondaryViewContainer();
245 return viewContainers
;
248 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
250 m_tabWidget
->openDirectories(dirs
, splitView
);
253 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
255 openDirectories(QUrl::fromStringList(dirs
), splitView
);
258 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
260 m_tabWidget
->openFiles(files
, splitView
);
263 bool DolphinMainWindow::isFoldersPanelEnabled() const
265 return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
268 bool DolphinMainWindow::isInformationPanelEnabled() const
271 return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
277 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
279 openFiles(QUrl::fromStringList(files
), splitView
);
282 void DolphinMainWindow::activateWindow()
284 window()->setAttribute(Qt::WA_NativeWindow
, true);
285 KStartupInfo::setNewStartupId(window()->windowHandle(), KStartupInfo::startupId());
286 KWindowSystem::activateWindow(window()->effectiveWinId());
289 void DolphinMainWindow::showCommand(CommandType command
)
291 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
293 case KIO::FileUndoManager::Copy
:
294 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
296 case KIO::FileUndoManager::Move
:
297 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
299 case KIO::FileUndoManager::Link
:
300 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
302 case KIO::FileUndoManager::Trash
:
303 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
305 case KIO::FileUndoManager::Rename
:
306 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
309 case KIO::FileUndoManager::Mkdir
:
310 statusBar
->setText(i18nc("@info:status", "Created folder."));
318 void DolphinMainWindow::pasteIntoFolder()
320 m_activeViewContainer
->view()->pasteIntoFolder();
323 void DolphinMainWindow::changeUrl(const QUrl
&url
)
325 if (!KProtocolManager::supportsListing(url
)) {
326 // The URL navigator only checks for validity, not
327 // if the URL can be listed. An error message is
328 // shown due to DolphinViewContainer::restoreView().
332 m_activeViewContainer
->setUrl(url
);
333 updateFileAndEditActions();
338 Q_EMIT
urlChanged(url
);
341 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
343 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
344 m_placesPanel
->proceedWithTearDown();
345 m_tearDownFromPlacesRequested
= false;
348 m_activeViewContainer
->setAutoGrabFocus(false);
350 m_activeViewContainer
->setAutoGrabFocus(true);
353 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
355 KToggleAction
* editableLocationAction
=
356 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
357 editableLocationAction
->setChecked(editable
);
360 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
362 updateFileAndEditActions();
364 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
366 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
367 if (selectedUrlsCount
== 2) {
368 compareFilesAction
->setEnabled(isKompareInstalled());
370 compareFilesAction
->setEnabled(false);
373 Q_EMIT
selectionChanged(selection
);
376 void DolphinMainWindow::updateHistory()
378 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
379 const int index
= urlNavigator
->historyIndex();
381 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
383 backAction
->setToolTip(i18nc("@info", "Go back"));
384 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
385 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
388 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
390 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
391 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
392 "This undoes a <interface>Go|Back</interface> action."));
393 forwardAction
->setEnabled(index
> 0);
397 void DolphinMainWindow::updateFilterBarAction(bool show
)
399 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
400 toggleFilterBarAction
->setChecked(show
);
403 void DolphinMainWindow::openNewMainWindow()
405 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
408 void DolphinMainWindow::openNewActivatedTab()
410 // keep browsers compatibility, new tab is always after last one
411 auto openNewTabAfterLastTabConfigured
= GeneralSettings::openNewTabAfterLastTab();
412 GeneralSettings::setOpenNewTabAfterLastTab(true);
413 m_tabWidget
->openNewActivatedTab();
414 GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured
);
417 void DolphinMainWindow::addToPlaces()
422 // If nothing is selected, act on the current dir
423 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
424 url
= m_activeViewContainer
->url();
425 name
= m_activeViewContainer
->placesText();
427 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
428 url
= dirToAdd
.url();
429 name
= dirToAdd
.name();
433 if (m_activeViewContainer
->isSearchModeEnabled()) {
434 icon
= QStringLiteral("folder-saved-search-symbolic");
436 icon
= KIO::iconNameForUrl(url
);
438 DolphinPlacesModelSingleton::instance().placesModel()->addPlace(name
, url
, icon
);
442 void DolphinMainWindow::openNewTab(const QUrl
& url
)
444 m_tabWidget
->openNewTab(url
, QUrl());
447 void DolphinMainWindow::openNewTabAndActivate(const QUrl
&url
)
449 m_tabWidget
->openNewActivatedTab(url
, QUrl());
452 void DolphinMainWindow::openNewWindow(const QUrl
&url
)
454 Dolphin::openNewWindow({url
}, this);
457 void DolphinMainWindow::slotSplitViewChanged()
459 m_tabWidget
->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation
);
463 void DolphinMainWindow::openInNewTab()
465 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
466 bool tabCreated
= false;
468 for (const KFileItem
& item
: list
) {
469 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
470 if (!url
.isEmpty()) {
476 // if no new tab has been created from the selection
477 // open the current directory in a new tab
479 openNewTab(m_activeViewContainer
->url());
483 void DolphinMainWindow::openInNewWindow()
487 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
488 if (list
.isEmpty()) {
489 newWindowUrl
= m_activeViewContainer
->url();
490 } else if (list
.count() == 1) {
491 const KFileItem
& item
= list
.first();
492 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
495 if (!newWindowUrl
.isEmpty()) {
496 Dolphin::openNewWindow({newWindowUrl
}, this);
500 void DolphinMainWindow::showTarget()
502 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
503 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
504 auto linkDestination
= link
.linkDest();
505 if (QFileInfo(linkDestination
).isRelative()) {
506 linkDestination
= linkLocationDir
.filePath(linkDestination
);
508 if (QFileInfo::exists(linkDestination
)) {
509 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
511 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
512 DolphinViewContainer::Warning
);
516 void DolphinMainWindow::showEvent(QShowEvent
* event
)
518 KXmlGuiWindow::showEvent(event
);
520 if (!event
->spontaneous()) {
521 m_activeViewContainer
->view()->setFocus();
525 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
527 // Find out if Dolphin is closed directly by the user or
528 // by the session manager because the session is closed
529 bool closedByUser
= true;
530 if (qApp
->isSavingSession()) {
531 closedByUser
= false;
534 if (m_tabWidget
->count() > 1
535 && GeneralSettings::confirmClosingMultipleTabs()
536 && !GeneralSettings::rememberOpenedTabs()
538 // Ask the user if he really wants to quit and close all tabs.
539 // Open a confirmation dialog with 3 buttons:
540 // QDialogButtonBox::Yes -> Quit
541 // QDialogButtonBox::No -> Close only the current tab
542 // QDialogButtonBox::Cancel -> do nothing
543 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
544 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
545 dialog
->setModal(true);
546 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
547 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
548 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
549 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
550 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
552 bool doNotAskAgainCheckboxResult
= false;
554 const auto result
= KMessageBox::createKMessageBox(dialog
,
556 QMessageBox::Warning
,
557 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
559 i18n("Do not ask again"),
560 &doNotAskAgainCheckboxResult
,
561 KMessageBox::Notify
);
563 if (doNotAskAgainCheckboxResult
) {
564 GeneralSettings::setConfirmClosingMultipleTabs(false);
568 case QDialogButtonBox::Yes
:
571 case QDialogButtonBox::No
:
572 // Close only the current tab
573 m_tabWidget
->closeTab();
581 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
582 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
583 // Open a confirmation dialog with 3 buttons:
584 // QDialogButtonBox::Yes -> Quit
585 // QDialogButtonBox::No -> Show Terminal Panel
586 // QDialogButtonBox::Cancel -> do nothing
587 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
588 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
589 dialog
->setModal(true);
590 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
591 if (!m_terminalPanel
->isVisible()) {
592 standardButtons
|= QDialogButtonBox::No
;
594 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
595 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
596 if (!m_terminalPanel
->isVisible()) {
598 buttons
->button(QDialogButtonBox::No
),
599 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
601 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
603 bool doNotAskAgainCheckboxResult
= false;
605 const auto result
= KMessageBox::createKMessageBox(
608 QMessageBox::Warning
,
609 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
611 i18n("Do not ask again"),
612 &doNotAskAgainCheckboxResult
,
613 KMessageBox::Dangerous
);
615 if (doNotAskAgainCheckboxResult
) {
616 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
620 case QDialogButtonBox::Yes
:
623 case QDialogButtonBox::No
:
624 actionCollection()->action("show_terminal_panel")->trigger();
625 // Do not quit, ignore quit event
633 if (GeneralSettings::rememberOpenedTabs()) {
634 KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin"));
635 KConfig
*config
= KConfigGui::sessionConfig();
636 saveGlobalProperties(config
);
637 savePropertiesInternal(config
, 1);
641 GeneralSettings::setVersion(CurrentDolphinVersion
);
642 GeneralSettings::self()->save();
644 KXmlGuiWindow::closeEvent(event
);
647 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
649 m_tabWidget
->saveProperties(group
);
652 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
654 m_tabWidget
->readProperties(group
);
657 void DolphinMainWindow::updateNewMenu()
659 m_newFileMenu
->checkUpToDate();
660 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << activeViewContainer()->url());
663 void DolphinMainWindow::createDirectory()
665 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << activeViewContainer()->url());
666 m_newFileMenu
->createDirectory();
669 void DolphinMainWindow::quit()
674 void DolphinMainWindow::showErrorMessage(const QString
& message
)
676 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
679 void DolphinMainWindow::slotUndoAvailable(bool available
)
681 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
683 undoAction
->setEnabled(available
);
687 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
689 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
691 undoAction
->setText(text
);
695 void DolphinMainWindow::undo()
698 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
699 KIO::FileUndoManager::self()->undo();
702 void DolphinMainWindow::cut()
704 m_activeViewContainer
->view()->cutSelectedItemsToClipboard();
707 void DolphinMainWindow::copy()
709 m_activeViewContainer
->view()->copySelectedItemsToClipboard();
712 void DolphinMainWindow::paste()
714 m_activeViewContainer
->view()->paste();
717 void DolphinMainWindow::find()
719 m_activeViewContainer
->setSearchModeEnabled(true);
722 void DolphinMainWindow::updateSearchAction()
724 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
725 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
728 void DolphinMainWindow::updatePasteAction()
730 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
731 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
732 pasteAction
->setEnabled(pasteInfo
.first
);
733 pasteAction
->setText(pasteInfo
.second
);
736 void DolphinMainWindow::slotDirectoryLoadingCompleted()
741 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
743 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
745 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
747 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
749 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
754 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
756 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
758 m_backAction
->menu()->clear();
759 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
760 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toDisplayString(QUrl::PreferLocalFile
), m_backAction
->menu());
762 m_backAction
->menu()->addAction(action
);
766 void DolphinMainWindow::slotGoBack(QAction
* action
)
768 int gotoIndex
= action
->data().value
<int>();
769 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
770 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
775 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
778 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
779 openNewTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
783 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
785 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
787 m_forwardAction
->menu()->clear();
788 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
789 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toDisplayString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
791 m_forwardAction
->menu()->addAction(action
);
795 void DolphinMainWindow::slotGoForward(QAction
* action
)
797 int gotoIndex
= action
->data().value
<int>();
798 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
799 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
804 void DolphinMainWindow::selectAll()
808 // if the URL navigator is editable and focused, select the whole
809 // URL instead of all items of the view
811 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
812 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
813 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
814 lineEdit
->hasFocus();
816 lineEdit
->selectAll();
818 m_activeViewContainer
->view()->selectAll();
822 void DolphinMainWindow::invertSelection()
825 m_activeViewContainer
->view()->invertSelection();
828 void DolphinMainWindow::toggleSplitView()
830 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
831 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled(), WithAnimation
);
836 void DolphinMainWindow::toggleSplitStash()
838 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
839 tabPage
->setSplitViewEnabled(false, WithAnimation
);
840 tabPage
->setSplitViewEnabled(true, WithAnimation
, QUrl("stash:/"));
843 void DolphinMainWindow::reloadView()
846 m_activeViewContainer
->reload();
847 m_activeViewContainer
->statusBar()->updateSpaceInfo();
850 void DolphinMainWindow::stopLoading()
852 m_activeViewContainer
->view()->stopLoading();
855 void DolphinMainWindow::enableStopAction()
857 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
860 void DolphinMainWindow::disableStopAction()
862 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
865 void DolphinMainWindow::showFilterBar()
867 m_activeViewContainer
->setFilterBarVisible(true);
870 void DolphinMainWindow::toggleFilterBar()
872 const bool checked
= !m_activeViewContainer
->isFilterBarVisible();
873 m_activeViewContainer
->setFilterBarVisible(checked
);
875 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
876 toggleFilterBarAction
->setChecked(checked
);
879 void DolphinMainWindow::toggleEditLocation()
883 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
884 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
885 urlNavigator
->setUrlEditable(action
->isChecked());
888 void DolphinMainWindow::replaceLocation()
890 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
891 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
893 // If the text field currently has focus and everything is selected,
894 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
895 if (navigator
->isUrlEditable()
896 && lineEdit
->hasFocus()
897 && lineEdit
->selectedText() == lineEdit
->text() ) {
898 navigator
->setUrlEditable(false);
900 navigator
->setUrlEditable(true);
901 navigator
->setFocus();
902 lineEdit
->selectAll();
906 void DolphinMainWindow::togglePanelLockState()
908 const bool newLockState
= !GeneralSettings::lockPanels();
909 const auto childrenObjects
= children();
910 for (QObject
* child
: childrenObjects
) {
911 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
913 dock
->setLocked(newLockState
);
917 GeneralSettings::setLockPanels(newLockState
);
920 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
922 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
923 m_activeViewContainer
->view()->setFocus();
927 void DolphinMainWindow::goBack()
929 DolphinUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
930 urlNavigator
->goBack();
932 if (urlNavigator
->locationState().isEmpty()) {
933 // An empty location state indicates a redirection URL,
934 // which must be skipped too
935 urlNavigator
->goBack();
939 void DolphinMainWindow::goForward()
941 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goForward();
944 void DolphinMainWindow::goUp()
946 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goUp();
949 void DolphinMainWindow::goHome()
951 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goHome();
954 void DolphinMainWindow::goBackInNewTab()
956 const KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
957 const int index
= urlNavigator
->historyIndex() + 1;
958 openNewTab(urlNavigator
->locationUrl(index
));
961 void DolphinMainWindow::goForwardInNewTab()
963 const KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
964 const int index
= urlNavigator
->historyIndex() - 1;
965 openNewTab(urlNavigator
->locationUrl(index
));
968 void DolphinMainWindow::goUpInNewTab()
970 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
971 openNewTab(KIO::upUrl(currentUrl
));
974 void DolphinMainWindow::goHomeInNewTab()
976 openNewTab(Dolphin::homeUrl());
979 void DolphinMainWindow::compareFiles()
981 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
982 if (items
.count() != 2) {
983 // The action is disabled in this case, but it could have been triggered
984 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
988 QUrl urlA
= items
.at(0).url();
989 QUrl urlB
= items
.at(1).url();
991 QString
command(QStringLiteral("kompare -c \""));
992 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
993 command
.append("\" \"");
994 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
995 command
.append('\"');
997 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(command
, this);
998 job
->setDesktopName(QStringLiteral("org.kde.kompare"));
1002 void DolphinMainWindow::toggleShowMenuBar()
1004 const bool visible
= menuBar()->isVisible();
1005 menuBar()->setVisible(!visible
);
1008 QPointer
<QAction
> DolphinMainWindow::preferredSearchTool()
1010 m_searchTools
.clear();
1011 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
1012 &m_searchTools
, { "files-find" }, m_activeViewContainer
->url()
1014 QList
<QAction
*> actions
= m_searchTools
.actions();
1015 if (actions
.isEmpty()) {
1018 QAction
* action
= actions
.first();
1019 if (action
->isSeparator()) {
1025 void DolphinMainWindow::updateOpenPreferredSearchToolAction()
1027 QAction
* openPreferredSearchTool
= actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
1028 if (!openPreferredSearchTool
) {
1031 QPointer
<QAction
> tool
= preferredSearchTool();
1033 openPreferredSearchTool
->setVisible(true);
1034 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open %1", tool
->text()));
1035 // Only override with the app icon if it is the default, i.e. the user hasn't configured one manually
1036 // https://bugs.kde.org/show_bug.cgi?id=442815
1037 if (openPreferredSearchTool
->icon().name() == QLatin1String("search")) {
1038 openPreferredSearchTool
->setIcon(tool
->icon());
1041 openPreferredSearchTool
->setVisible(false);
1042 // still visible in Shortcuts configuration window
1043 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1044 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1048 void DolphinMainWindow::openPreferredSearchTool()
1050 QPointer
<QAction
> tool
= preferredSearchTool();
1056 void DolphinMainWindow::openTerminal()
1058 const QUrl url
= m_activeViewContainer
->url();
1060 if (url
.isLocalFile()) {
1061 auto job
= new KTerminalLauncherJob(QString());
1062 job
->setWorkingDirectory(url
.toLocalFile());
1067 // Not a local file, with protocol Class ":local", try stat'ing
1068 if (KProtocolInfo::protocolClass(url
.scheme()) == QLatin1String(":local")) {
1069 KIO::StatJob
*job
= KIO::mostLocalUrl(url
);
1070 KJobWidgets::setWindow(job
, this);
1071 connect(job
, &KJob::result
, this, [job
]() {
1073 if (!job
->error()) {
1074 statUrl
= job
->mostLocalUrl();
1077 auto job
= new KTerminalLauncherJob(QString());
1078 job
->setWorkingDirectory(statUrl
.isLocalFile() ? statUrl
.toLocalFile() : QDir::homePath());
1085 // Nothing worked, just use $HOME
1086 auto job
= new KTerminalLauncherJob(QString());
1087 job
->setWorkingDirectory(QDir::homePath());
1091 void DolphinMainWindow::editSettings()
1093 if (!m_settingsDialog
) {
1094 DolphinViewContainer
* container
= activeViewContainer();
1095 container
->view()->writeSettings();
1097 const QUrl url
= container
->url();
1098 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this, actionCollection());
1099 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
1100 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
,
1101 &DolphinUrlNavigatorsController::slotReadSettings
);
1102 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
1103 settingsDialog
->show();
1104 m_settingsDialog
= settingsDialog
;
1106 m_settingsDialog
.data()->raise();
1110 void DolphinMainWindow::handleUrl(const QUrl
& url
)
1112 delete m_lastHandleUrlOpenJob
;
1113 m_lastHandleUrlOpenJob
= nullptr;
1115 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
1116 activeViewContainer()->setUrl(url
);
1118 m_lastHandleUrlOpenJob
= new KIO::OpenUrlJob(url
);
1119 m_lastHandleUrlOpenJob
->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
1120 m_lastHandleUrlOpenJob
->setShowOpenOrExecuteDialog(true);
1122 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::mimeTypeFound
, this,
1123 [this, url
](const QString
&mimetype
) {
1124 if (mimetype
== QLatin1String("inode/directory")) {
1125 // If it's a dir, we'll take it from here
1126 m_lastHandleUrlOpenJob
->kill();
1127 m_lastHandleUrlOpenJob
= nullptr;
1128 activeViewContainer()->setUrl(url
);
1132 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::result
, this, [this]() {
1133 m_lastHandleUrlOpenJob
= nullptr;
1136 m_lastHandleUrlOpenJob
->start();
1140 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1142 // trash:/ is writable but we don't want to create new items in it.
1143 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1144 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1147 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1148 const KFileItem
& item
,
1150 const QList
<QAction
*>& customActions
)
1152 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
, &m_fileItemActions
);
1153 contextMenu
.data()->setCustomActions(customActions
);
1154 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1157 case DolphinContextMenu::OpenParentFolder
:
1158 changeUrl(KIO::upUrl(item
.url()));
1159 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1160 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1163 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1164 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1167 case DolphinContextMenu::OpenParentFolderInNewTab
:
1168 openNewTab(KIO::upUrl(item
.url()));
1171 case DolphinContextMenu::None
:
1176 // Delete the menu, unless it has been deleted in its own nested event loop already.
1178 contextMenu
->deleteLater();
1182 void DolphinMainWindow::updateHamburgerMenu()
1184 KActionCollection
* ac
= actionCollection();
1185 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(
1186 ac
->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
1187 auto menu
= hamburgerMenu
->menu();
1189 menu
= new QMenu(this);
1190 hamburgerMenu
->setMenu(menu
);
1191 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("basic_actions"))->menu());
1192 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("zoom"))->menu());
1196 const QList
<QAction
*> toolbarActions
= toolBar()->actions();
1198 if (!toolBar()->isVisible()) {
1199 // If neither the menu bar nor the toolbar are visible, these actions should be available.
1200 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)));
1201 menu
->addAction(toolBarMenuAction());
1202 menu
->addSeparator();
1205 // This group of actions (until the next separator) contains all the most basic actions
1206 // necessary to use Dolphin effectively.
1207 menu
->addAction(ac
->action(QStringLiteral("go_back")));
1208 menu
->addAction(ac
->action(QStringLiteral("go_forward")));
1210 menu
->addMenu(m_newFileMenu
->menu());
1211 menu
->addAction(ac
->action(QStringLiteral("basic_actions")));
1212 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Undo
)));
1213 if (!toolBar()->isVisible()
1214 || (!toolbarActions
.contains(ac
->action(QStringLiteral("toggle_search")))
1215 && !toolbarActions
.contains(ac
->action(QStringLiteral("open_preferred_search_tool"))))
1217 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Find
)));
1218 // This way a search action will only be added if none of the three available
1219 // search actions is present on the toolbar.
1221 if (!toolBar()->isVisible()
1222 || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_filter")))
1224 menu
->addAction(ac
->action(QStringLiteral("show_filter_bar")));
1225 // This way a filter action will only be added if none of the two available
1226 // filter actions is present on the toolbar.
1228 menu
->addSeparator();
1230 // The second group of actions (up until the next separator) contains actions for opening
1231 // additional views to interact with the file system.
1232 menu
->addAction(ac
->action(QStringLiteral("file_new")));
1233 menu
->addAction(ac
->action(QStringLiteral("new_tab")));
1234 if (ac
->action(QStringLiteral("undo_close_tab"))->isEnabled()) {
1235 menu
->addAction(ac
->action(QStringLiteral("closed_tabs")));
1237 menu
->addAction(ac
->action(QStringLiteral("open_terminal")));
1238 menu
->addSeparator();
1240 // The third group contains actions to change what one sees in the view
1241 // and to change the more general UI.
1242 if (!toolBar()->isVisible()
1243 || (!toolbarActions
.contains(ac
->action(QStringLiteral("icons")))
1244 && !toolbarActions
.contains(ac
->action(QStringLiteral("compact")))
1245 && !toolbarActions
.contains(ac
->action(QStringLiteral("details")))
1246 && !toolbarActions
.contains(ac
->action(QStringLiteral("view_mode"))))
1248 menu
->addAction(ac
->action(QStringLiteral("view_mode")));
1250 menu
->addAction(ac
->action(QStringLiteral("show_hidden_files")));
1251 menu
->addAction(ac
->action(QStringLiteral("sort")));
1252 menu
->addAction(ac
->action(QStringLiteral("additional_info")));
1253 if (!GeneralSettings::showStatusBar() || !GeneralSettings::showZoomSlider()) {
1254 menu
->addAction(ac
->action(QStringLiteral("zoom")));
1256 menu
->addAction(ac
->action(QStringLiteral("panels")));
1258 // The "Configure" menu is not added to the actionCollection() because there is hardly
1259 // a good reason for users to put it on their toolbar.
1260 auto configureMenu
= menu
->addMenu(QIcon::fromTheme(QStringLiteral("configure")),
1261 i18nc("@action:inmenu menu for configure actions", "Configure"));
1262 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
)));
1263 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)));
1264 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)));
1265 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Preferences
)));
1266 hamburgerMenu
->hideActionsOf(configureMenu
);
1269 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1271 DolphinViewContainer
* view
= activeViewContainer();
1273 if (view
->url() == url
) {
1274 // We can end up here if the user clicked a device in the Places Panel
1275 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1278 view
->disableUrlNavigatorSelectionRequests();
1280 view
->enableUrlNavigatorSelectionRequests();
1284 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1286 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1289 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1291 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1292 Q_ASSERT(viewContainer
);
1294 m_activeViewContainer
= viewContainer
;
1296 if (oldViewContainer
) {
1297 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1298 toggleSearchAction
->disconnect(oldViewContainer
);
1300 // Disconnect all signals between the old view container (container,
1301 // view and url navigator) and main window.
1302 oldViewContainer
->disconnect(this);
1303 oldViewContainer
->view()->disconnect(this);
1304 oldViewContainer
->urlNavigatorInternalWithHistory()->disconnect(this);
1305 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
1306 (actionCollection()->action(QStringLiteral("url_navigators")));
1307 navigators
->primaryUrlNavigator()->disconnect(this);
1308 if (auto secondaryUrlNavigator
= navigators
->secondaryUrlNavigator()) {
1309 secondaryUrlNavigator
->disconnect(this);
1312 // except the requestItemInfo so that on hover the information panel can still be updated
1313 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1314 this, &DolphinMainWindow::requestItemInfo
);
1317 connectViewSignals(viewContainer
);
1319 m_actionHandler
->setCurrentView(viewContainer
->view());
1322 updateFileAndEditActions();
1323 updatePasteAction();
1324 updateViewActions();
1326 updateSearchAction();
1328 const QUrl url
= viewContainer
->url();
1329 Q_EMIT
urlChanged(url
);
1332 void DolphinMainWindow::tabCountChanged(int count
)
1334 const bool enableTabActions
= (count
> 1);
1335 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1336 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1338 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1339 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1340 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1343 void DolphinMainWindow::updateWindowTitle()
1345 const QString newTitle
= m_activeViewContainer
->captionWindowTitle();
1346 if (windowTitle() != newTitle
) {
1347 setWindowTitle(newTitle
);
1351 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1353 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1354 setViewsToHomeIfMountPathOpen(mountPath
);
1357 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1358 m_tearDownFromPlacesRequested
= true;
1359 m_terminalPanel
->goHome();
1360 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1362 m_placesPanel
->proceedWithTearDown();
1366 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1368 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1369 setViewsToHomeIfMountPathOpen(mountPath
);
1372 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1373 m_tearDownFromPlacesRequested
= false;
1374 m_terminalPanel
->goHome();
1378 void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString
& mountPath
)
1380 const QVector
<DolphinViewContainer
*> theViewContainers
= viewContainers();
1381 for (DolphinViewContainer
*viewContainer
: theViewContainers
) {
1382 if (viewContainer
&& viewContainer
->url().toLocalFile().startsWith(mountPath
)) {
1383 viewContainer
->setUrl(QUrl::fromLocalFile(QDir::homePath()));
1386 disconnect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, nullptr, nullptr);
1389 void DolphinMainWindow::setupActions()
1391 KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
1393 // setup 'File' menu
1394 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1395 QMenu
* menu
= m_newFileMenu
->menu();
1396 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1397 menu
->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
1398 m_newFileMenu
->setPopupMode(QToolButton::InstantPopup
);
1399 connect(menu
, &QMenu::aboutToShow
,
1400 this, &DolphinMainWindow::updateNewMenu
);
1402 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1403 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1404 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1405 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1406 "window just like this one with the current location and view."
1407 "<nl/>You can drag and drop items between windows."));
1408 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1410 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1411 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1412 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1413 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1414 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1415 "A tab is an additional view within this window. "
1416 "You can drag and drop items between tabs."));
1417 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
| Qt::Key_T
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_N
});
1418 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1420 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1421 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1422 addToPlaces
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1423 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1424 "to the Places panel."));
1425 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1427 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1428 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1429 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1430 "currently viewed tab. If no more tabs are left this window "
1431 "will close instead."));
1433 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1434 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1436 // setup 'Edit' menu
1437 KStandardAction::undo(this,
1438 &DolphinMainWindow::undo
,
1439 actionCollection());
1441 // i18n: This will be the last paragraph for the whatsthis for all three:
1442 // Cut, Copy and Paste
1443 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1444 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1445 "applications and are among the most used commands. That's why their "
1446 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1447 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1448 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1449 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1450 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1451 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1452 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1453 "the clipboard to a new location. The items will be removed from their "
1454 "initial location.") + cutCopyPastePara
);
1455 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1456 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1457 "items in your current selection to the <emphasis>clipboard</emphasis>."
1458 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1459 "from the clipboard to a new location.") + cutCopyPastePara
);
1460 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1461 // The text of the paste-action is modified dynamically by Dolphin
1462 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1463 // due to the long text, the text "Paste" is used:
1464 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1465 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1466 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1467 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1468 "action they are removed from their old location.") + cutCopyPastePara
);
1470 QAction
* copyToOtherViewAction
= actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
1471 copyToOtherViewAction
->setText(i18nc("@action:inmenu", "Copy to Inactive Split View"));
1472 copyToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from "
1473 "the <emphasis>active</emphasis> view to the inactive split view."));
1474 copyToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
1475 copyToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Copy to Inactive Split View"));
1476 actionCollection()->setDefaultShortcut(copyToOtherViewAction
, Qt::SHIFT
| Qt::Key_F5
);
1477 connect(copyToOtherViewAction
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::copyToInactiveSplitView
);
1479 QAction
* moveToOtherViewAction
= actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
1480 moveToOtherViewAction
->setText(i18nc("@action:inmenu", "Move to Inactive Split View"));
1481 moveToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from "
1482 "the <emphasis>active</emphasis> view to the inactive split view."));
1483 moveToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
1484 moveToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Move to Inactive Split View"));
1485 actionCollection()->setDefaultShortcut(moveToOtherViewAction
, Qt::SHIFT
| Qt::Key_F6
);
1486 connect(moveToOtherViewAction
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::moveToInactiveSplitView
);
1488 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1489 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Filter..."));
1490 showFilterBar
->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
1491 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1492 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1493 "There you can enter a text to filter the files and folders currently displayed. "
1494 "Only those that contain the text in their name will be kept in view."));
1495 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1496 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
| Qt::Key_I
, Qt::Key_Slash
});
1497 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1499 // toggle_filter acts as a copy of the main showFilterBar to be used mainly
1500 // in the toolbar, with no default shortcut attached, to avoid messing with
1501 // existing workflows (filter bar always open and Ctrl-I to focus)
1502 QAction
*toggleFilter
= actionCollection()->addAction(QStringLiteral("toggle_filter"));
1503 toggleFilter
->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
1504 toggleFilter
->setIconText(i18nc("@action:intoolbar", "Filter"));
1505 toggleFilter
->setIcon(showFilterBar
->icon());
1506 toggleFilter
->setToolTip(showFilterBar
->toolTip());
1507 toggleFilter
->setWhatsThis(showFilterBar
->whatsThis());
1508 toggleFilter
->setCheckable(true);
1509 connect(toggleFilter
, &QAction::triggered
, this, &DolphinMainWindow::toggleFilterBar
);
1511 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1512 searchAction
->setText(i18n("Search..."));
1513 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1514 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1515 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1516 "There you can enter search terms and specify settings to find the "
1517 "objects you are looking for.</para><para>Use this help again on "
1518 "the find bar so we can have a look at it while the settings are "
1519 "explained.</para>"));
1521 // toggle_search acts as a copy of the main searchAction to be used mainly
1522 // in the toolbar, with no default shortcut attached, to avoid messing with
1523 // existing workflows (search bar always open and Ctrl-F to focus)
1524 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1525 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1526 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1527 toggleSearchAction
->setIcon(searchAction
->icon());
1528 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1529 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1530 toggleSearchAction
->setCheckable(true);
1532 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1533 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1534 "files and folders in the current location."));
1536 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1537 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1538 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1539 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1540 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1541 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1542 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1544 // setup 'View' menu
1545 // (note that most of it is set up in DolphinViewActionHandler)
1547 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1548 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1549 "the folder view below into two autonomous views.</para><para>This "
1550 "way you can see two locations at once and move items between them "
1551 "quickly.</para>Click this again afterwards to recombine the views."));
1552 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1553 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1555 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1556 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
| Qt::Key_S
);
1557 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1558 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1559 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1560 stashSplit
->setCheckable(false);
1561 QDBusConnectionInterface
*sessionInterface
= QDBusConnection::sessionBus().interface();
1562 stashSplit
->setVisible(sessionInterface
&& sessionInterface
->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
1563 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1565 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1567 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1568 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1569 stop
->setToolTip(i18nc("@info", "Stop loading"));
1570 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1571 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1572 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1574 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1575 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1576 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1577 "This toggles the <emphasis>Location Bar</emphasis> to be "
1578 "editable so you can directly enter a location you want to go to.<nl/>"
1579 "You can also switch to editing by clicking to the right of the "
1580 "location and switch back by confirming the edited location."));
1581 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1582 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1584 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1585 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1586 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1587 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1588 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1589 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1590 "This switches to editing the location and selects it "
1591 "so you can quickly enter a different location."));
1592 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
| Qt::Key_L
);
1593 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1597 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1598 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1599 m_backAction
->setObjectName(backAction
->objectName());
1600 m_backAction
->setShortcuts(backAction
->shortcuts());
1602 m_backAction
->setPopupMode(QToolButton::DelayedPopup
);
1603 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1604 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1605 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1606 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1608 auto backShortcuts
= m_backAction
->shortcuts();
1609 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1610 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1612 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1613 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1614 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1615 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1616 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1617 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1618 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1619 this, &DolphinMainWindow::closedTabsCountChanged
);
1621 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1622 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1623 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1624 "This returns you to the previously closed tab."));
1625 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_T
);
1626 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1627 undoCloseTab
->setEnabled(false);
1628 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1630 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1631 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1632 "the last change you made to files or folders.<nl/>"
1633 "Such changes include <interface>creating, renaming</interface> "
1634 "and <interface>moving</interface> them to a different location "
1635 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1636 "be undone will ask for your confirmation."));
1637 undoAction
->setEnabled(false); // undo should be disabled by default
1640 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1641 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1642 m_forwardAction
->setObjectName(forwardAction
->objectName());
1643 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1645 m_forwardAction
->setPopupMode(QToolButton::DelayedPopup
);
1646 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1647 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1648 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1649 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1650 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1652 // enable middle-click to open in a new tab
1653 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1654 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1655 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1656 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1657 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1658 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1659 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1660 "<filename>Home</filename> folder.<nl/>Every user account "
1661 "has their own <filename>Home</filename> that contains their data "
1662 "including folders that contain personal application data."));
1664 // setup 'Tools' menu
1665 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1666 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1667 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1668 compareFiles
->setEnabled(false);
1669 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1671 QAction
* openPreferredSearchTool
= actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
1672 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1673 openPreferredSearchTool
->setWhatsThis(xi18nc("@info:whatsthis",
1674 "<para>This opens a preferred search tool for the viewed location.</para>"
1675 "<para>Use <emphasis>More Search Tools</emphasis> menu to configure it.</para>"));
1676 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1677 actionCollection()->setDefaultShortcut(openPreferredSearchTool
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F
);
1678 connect(openPreferredSearchTool
, &QAction::triggered
, this, &DolphinMainWindow::openPreferredSearchTool
);
1680 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1681 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1682 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1683 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1684 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1685 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1686 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
1687 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
| Qt::Key_F4
);
1688 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1690 #ifdef HAVE_TERMINAL
1691 QAction
* focusTerminalPanel
= actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
1692 focusTerminalPanel
->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
1693 focusTerminalPanel
->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
1694 actionCollection()->setDefaultShortcut(focusTerminalPanel
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F4
);
1695 connect(focusTerminalPanel
, &QAction::triggered
, this, &DolphinMainWindow::focusTerminalPanel
);
1699 // setup 'Bookmarks' menu
1700 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1701 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1702 // Make the toolbar button version work properly on click
1703 bookmarkMenu
->setPopupMode(QToolButton::InstantPopup
);
1704 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1705 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1707 // setup 'Settings' menu
1708 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1709 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1710 "This switches between having a <emphasis>Menubar</emphasis> "
1711 "and having a <interface>Control</interface> button. Both "
1712 "contain mostly the same commands and configuration options."));
1713 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1714 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1715 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1717 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1718 m_helpMenu
= new KHelpMenu(nullptr);
1719 m_helpMenu
->menu()->installEventFilter(this);
1720 // remove duplicate shortcuts
1721 auto removeHelpActionShortcut
= [this](KHelpMenu::MenuId menuId
) {
1722 if (auto *action
= m_helpMenu
->action(menuId
)) {
1723 action
->setShortcut(QKeySequence());
1726 removeHelpActionShortcut(KHelpMenu::menuHelpContents
);
1727 removeHelpActionShortcut(KHelpMenu::menuWhatsThis
);
1729 // not in menu actions
1730 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1731 nextTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::Key_Tab
));
1733 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1734 prevTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::SHIFT
| Qt::Key_Tab
));
1736 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1737 QAction
* activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
1738 activateTab
->setText(i18nc("@action:inmenu", "Activate Tab %1", i
+ 1));
1739 activateTab
->setEnabled(false);
1740 connect(activateTab
, &QAction::triggered
, this, [this, i
]() { m_tabWidget
->activateTab(i
); });
1742 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
1744 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
1748 QAction
* activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
1749 activateLastTab
->setText(i18nc("@action:inmenu", "Activate Last Tab"));
1750 activateLastTab
->setEnabled(false);
1751 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
1752 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
| Qt::Key_0
);
1754 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1755 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1756 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1757 activateNextTab
->setEnabled(false);
1758 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1759 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1761 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1762 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1763 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1764 activatePrevTab
->setEnabled(false);
1765 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1766 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1769 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1770 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1771 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1772 showTarget
->setEnabled(false);
1773 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1775 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1776 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1777 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1778 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1780 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1781 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1782 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1783 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1785 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1786 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1787 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1788 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1791 void DolphinMainWindow::setupDockWidgets()
1793 const bool lock
= GeneralSettings::lockPanels();
1795 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1796 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1797 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1798 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1799 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1800 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1801 "switches between having panels <emphasis>locked</emphasis> or "
1802 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1803 "dragged to the other side of the window and have a close "
1804 "button.<nl/>Locked panels are embedded more cleanly."));
1805 lockLayoutAction
->setActive(lock
);
1806 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1808 // Setup "Information"
1809 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1810 infoDock
->setLocked(lock
);
1811 infoDock
->setObjectName(QStringLiteral("infoDock"));
1812 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1815 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1816 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1817 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1818 infoDock
->setWidget(infoPanel
);
1820 QAction
* infoAction
= infoDock
->toggleViewAction();
1821 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1823 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1824 connect(this, &DolphinMainWindow::urlChanged
,
1825 infoPanel
, &InformationPanel::setUrl
);
1826 connect(this, &DolphinMainWindow::selectionChanged
,
1827 infoPanel
, &InformationPanel::setSelection
);
1828 connect(this, &DolphinMainWindow::requestItemInfo
,
1829 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1830 connect(this, &DolphinMainWindow::fileItemsChanged
,
1831 infoPanel
, &InformationPanel::slotFilesItemChanged
);
1834 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1835 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1836 "hide panels like this go to <interface>Control|Panels</interface> "
1837 "or <interface>View|Panels</interface>.</para>");
1839 actionCollection()->action(QStringLiteral("show_information_panel"))
1840 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1841 "<emphasis>information</emphasis> panel at the right side of the "
1842 "window.</para><para>The panel provides in-depth information "
1843 "about the items your mouse is hovering over or about the selected "
1844 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1845 "For single items a preview of their contents is provided.</para>"));
1847 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1848 "provides in-depth information about the items your mouse is "
1849 "hovering over or about the selected items. Otherwise it informs "
1850 "you about the currently viewed folder.<nl/>For single items a "
1851 "preview of their contents is provided.</para><para>You can configure "
1852 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1855 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1856 foldersDock
->setLocked(lock
);
1857 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1858 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1859 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1860 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1861 foldersDock
->setWidget(foldersPanel
);
1863 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1864 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1866 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1867 connect(this, &DolphinMainWindow::urlChanged
,
1868 foldersPanel
, &FoldersPanel::setUrl
);
1869 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1870 this, &DolphinMainWindow::changeUrl
);
1871 connect(foldersPanel
, &FoldersPanel::folderInNewTab
,
1872 this, &DolphinMainWindow::openNewTab
);
1873 connect(foldersPanel
, &FoldersPanel::folderInNewActiveTab
,
1874 this, &DolphinMainWindow::openNewTabAndActivate
);
1875 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1876 this, &DolphinMainWindow::showErrorMessage
);
1878 actionCollection()->action(QStringLiteral("show_folders_panel"))
1879 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1880 "<emphasis>folders</emphasis> panel at the left side of the window."
1881 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1882 "</emphasis> in a <emphasis>tree view</emphasis>."));
1883 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1884 "shows the folders of the <emphasis>file system</emphasis> in a "
1885 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1886 "there. Click the arrow to the left of a folder to see its subfolders. "
1887 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1890 #ifdef HAVE_TERMINAL
1891 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1892 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1893 terminalDock
->setLocked(lock
);
1894 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1895 m_terminalPanel
= new TerminalPanel(terminalDock
);
1896 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1897 terminalDock
->setWidget(m_terminalPanel
);
1899 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1900 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1901 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1902 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1903 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1904 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1906 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1907 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1909 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1910 connect(this, &DolphinMainWindow::urlChanged
,
1911 m_terminalPanel
, &TerminalPanel::setUrl
);
1913 if (GeneralSettings::version() < 200) {
1914 terminalDock
->hide();
1917 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1918 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1919 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1920 "<nl/>The location in the terminal will always match the folder "
1921 "view so you can navigate using either.</para><para>The terminal "
1922 "panel is not needed for basic computer usage but can be useful "
1923 "for advanced tasks. To learn more about terminals use the help "
1924 "in a standalone terminal application like Konsole.</para>"));
1925 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1926 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1927 "normal terminal but will match the location of the folder view "
1928 "so you can navigate using either.</para><para>The terminal panel "
1929 "is not needed for basic computer usage but can be useful for "
1930 "advanced tasks. To learn more about terminals use the help in a "
1931 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1935 if (GeneralSettings::version() < 200) {
1937 foldersDock
->hide();
1941 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1942 placesDock
->setLocked(lock
);
1943 placesDock
->setObjectName(QStringLiteral("placesDock"));
1944 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1946 m_placesPanel
= new PlacesPanel(placesDock
);
1947 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1948 placesDock
->setWidget(m_placesPanel
);
1950 QAction
*placesAction
= placesDock
->toggleViewAction();
1951 createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1953 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1954 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1955 this, &DolphinMainWindow::slotPlaceActivated
);
1956 connect(m_placesPanel
, &PlacesPanel::tabRequested
,
1957 this, &DolphinMainWindow::openNewTab
);
1958 connect(m_placesPanel
, &PlacesPanel::activeTabRequested
,
1959 this, &DolphinMainWindow::openNewTabAndActivate
);
1960 connect(m_placesPanel
, &PlacesPanel::newWindowRequested
, this, [this](const QUrl
&url
) {
1961 Dolphin::openNewWindow({url
}, this);
1963 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1964 this, &DolphinMainWindow::showErrorMessage
);
1965 connect(this, &DolphinMainWindow::urlChanged
,
1966 m_placesPanel
, &PlacesPanel::setUrl
);
1967 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1968 &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged
);
1969 connect(this, &DolphinMainWindow::settingsChanged
,
1970 m_placesPanel
, &PlacesPanel::readSettings
);
1971 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1972 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1973 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1974 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1975 DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1977 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1978 actionShowAllPlaces
->setCheckable(true);
1979 actionShowAllPlaces
->setDisabled(true);
1980 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1981 "all places in the places panel that have been hidden. They will "
1982 "appear semi-transparent unless you uncheck their hide property."));
1984 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1985 m_placesPanel
->setShowAll(checked
);
1987 connect(m_placesPanel
, &PlacesPanel::allPlacesShownChanged
, actionShowAllPlaces
, &QAction::setChecked
);
1989 actionCollection()->action(QStringLiteral("show_places_panel"))
1990 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1991 "<emphasis>places</emphasis> panel at the left side of the window."
1992 "</para><para>It allows you to go to locations you have "
1993 "bookmarked and to access disk or media attached to the computer "
1994 "or to the network. It also contains sections to find recently "
1995 "saved files or files of a certain type.</para>"));
1996 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1997 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1998 "you have bookmarked and to access disk or media attached to the "
1999 "computer or to the network. It also contains sections to find "
2000 "recently saved files or files of a certain type.</para><para>"
2001 "Click on an entry to go there. Click with the right mouse button "
2002 "instead to open any entry in a new tab or new window.</para>"
2003 "<para>New entries can be added by dragging folders onto this panel. "
2004 "Right-click any section or entry to hide it. Right-click an empty "
2005 "space on this panel and select <interface>Show Hidden Places"
2006 "</interface> to display it again.</para>") + panelWhatsThis
);
2008 // Add actions into the "Panels" menu
2009 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
2010 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
2011 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
2012 panelsMenu
->setPopupMode(QToolButton::InstantPopup
);
2013 const KActionCollection
* ac
= actionCollection();
2014 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
2016 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
2018 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
2019 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
2020 panelsMenu
->addSeparator();
2021 panelsMenu
->addAction(actionShowAllPlaces
);
2022 panelsMenu
->addAction(lockLayoutAction
);
2024 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
2025 actionShowAllPlaces
->setEnabled(DolphinPlacesModelSingleton::instance().placesModel()->hiddenCount());
2030 void DolphinMainWindow::updateFileAndEditActions()
2032 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
2033 const KActionCollection
* col
= actionCollection();
2034 KFileItemListProperties
capabilitiesSource(list
);
2036 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
2037 QAction
* copyToOtherViewAction
= col
->action(QStringLiteral("copy_to_inactive_split_view"));
2038 QAction
* moveToOtherViewAction
= col
->action(QStringLiteral("move_to_inactive_split_view"));
2039 QAction
* copyLocation
= col
->action(QString("copy_location"));
2041 if (list
.isEmpty()) {
2042 stateChanged(QStringLiteral("has_no_selection"));
2044 addToPlacesAction
->setEnabled(true);
2045 copyToOtherViewAction
->setEnabled(false);
2046 moveToOtherViewAction
->setEnabled(false);
2047 copyLocation
->setEnabled(false);
2049 stateChanged(QStringLiteral("has_selection"));
2051 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
2052 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
2053 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
2054 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
2055 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
2056 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
2057 QAction
* duplicateAction
= col
->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler
2059 if (list
.length() == 1 && list
.first().isDir()) {
2060 addToPlacesAction
->setEnabled(true);
2062 addToPlacesAction
->setEnabled(false);
2065 if (m_tabWidget
->currentTabPage()->splitViewEnabled()) {
2066 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2067 KFileItem capabilitiesDestination
;
2069 if (tabPage
->primaryViewActive()) {
2070 capabilitiesDestination
= tabPage
->secondaryViewContainer()->url();
2072 capabilitiesDestination
= tabPage
->primaryViewContainer()->url();
2075 copyToOtherViewAction
->setEnabled(capabilitiesDestination
.isWritable());
2076 moveToOtherViewAction
->setEnabled(capabilitiesSource
.supportsMoving() && capabilitiesDestination
.isWritable());
2078 copyToOtherViewAction
->setEnabled(false);
2079 moveToOtherViewAction
->setEnabled(false);
2082 const bool enableMoveToTrash
= capabilitiesSource
.isLocal() && capabilitiesSource
.supportsMoving();
2084 renameAction
->setEnabled(capabilitiesSource
.supportsMoving());
2085 moveToTrashAction
->setEnabled(enableMoveToTrash
);
2086 deleteAction
->setEnabled(capabilitiesSource
.supportsDeleting());
2087 deleteWithTrashShortcut
->setEnabled(capabilitiesSource
.supportsDeleting() && !enableMoveToTrash
);
2088 cutAction
->setEnabled(capabilitiesSource
.supportsMoving());
2089 copyLocation
->setEnabled(list
.length() == 1);
2090 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
2091 duplicateAction
->setEnabled(capabilitiesSource
.supportsWriting());
2095 void DolphinMainWindow::updateViewActions()
2097 m_actionHandler
->updateViewActions();
2099 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
2100 toggleFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
2102 updateSplitAction();
2105 void DolphinMainWindow::updateGoActions()
2107 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
2108 const QUrl currentUrl
= m_activeViewContainer
->url();
2109 // I think this is one of the best places to firstly be confronted
2110 // with a file system and its hierarchy. Talking about the root
2111 // directory might seem too much here but it is the question that
2112 // naturally arises in this context.
2113 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
2114 "the folder that contains the currently viewed one.</para>"
2115 "<para>All files and folders are organized in a hierarchical "
2116 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
2117 "a directory that contains all data connected to this computer"
2118 "—the <emphasis>root directory</emphasis>.</para>"));
2119 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
2122 void DolphinMainWindow::refreshViews()
2124 m_tabWidget
->refreshViews();
2126 if (GeneralSettings::modifiedStartupSettings()) {
2127 updateWindowTitle();
2130 Q_EMIT
settingsChanged();
2133 void DolphinMainWindow::clearStatusBar()
2135 m_activeViewContainer
->statusBar()->resetToDefaultText();
2138 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
2140 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
2141 this, &DolphinMainWindow::updateFilterBarAction
);
2142 connect(container
, &DolphinViewContainer::writeStateChanged
,
2143 this, &DolphinMainWindow::slotWriteStateChanged
);
2144 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
2145 this, &DolphinMainWindow::updateSearchAction
);
2146 connect(container
, &DolphinViewContainer::captionChanged
,
2147 this, &DolphinMainWindow::updateWindowTitle
);
2148 connect(container
, &DolphinViewContainer::tabRequested
,
2149 this, &DolphinMainWindow::openNewTab
);
2150 connect(container
, &DolphinViewContainer::activeTabRequested
,
2151 this, &DolphinMainWindow::openNewTabAndActivate
);
2153 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
2154 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
2156 const DolphinView
* view
= container
->view();
2157 connect(view
, &DolphinView::selectionChanged
,
2158 this, &DolphinMainWindow::slotSelectionChanged
);
2159 connect(view
, &DolphinView::requestItemInfo
,
2160 this, &DolphinMainWindow::requestItemInfo
);
2161 connect(view
, &DolphinView::fileItemsChanged
,
2162 this, &DolphinMainWindow::fileItemsChanged
);
2163 connect(view
, &DolphinView::tabRequested
,
2164 this, &DolphinMainWindow::openNewTab
);
2165 connect(view
, &DolphinView::activeTabRequested
,
2166 this, &DolphinMainWindow::openNewTabAndActivate
);
2167 connect(view
, &DolphinView::windowRequested
,
2168 this, &DolphinMainWindow::openNewWindow
);
2169 connect(view
, &DolphinView::requestContextMenu
,
2170 this, &DolphinMainWindow::openContextMenu
);
2171 connect(view
, &DolphinView::directoryLoadingStarted
,
2172 this, &DolphinMainWindow::enableStopAction
);
2173 connect(view
, &DolphinView::directoryLoadingCompleted
,
2174 this, &DolphinMainWindow::disableStopAction
);
2175 connect(view
, &DolphinView::directoryLoadingCompleted
,
2176 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
2177 connect(view
, &DolphinView::goBackRequested
,
2178 this, &DolphinMainWindow::goBack
);
2179 connect(view
, &DolphinView::goForwardRequested
,
2180 this, &DolphinMainWindow::goForward
);
2181 connect(view
, &DolphinView::urlActivated
,
2182 this, &DolphinMainWindow::handleUrl
);
2183 connect(view
, &DolphinView::goUpRequested
,
2184 this, &DolphinMainWindow::goUp
);
2186 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged
,
2187 this, &DolphinMainWindow::changeUrl
);
2188 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged
,
2189 this, &DolphinMainWindow::updateHistory
);
2191 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2192 (actionCollection()->action(QStringLiteral("url_navigators")));
2193 const KUrlNavigator
*navigator
= m_tabWidget
->currentTabPage()->primaryViewActive() ?
2194 navigators
->primaryUrlNavigator() :
2195 navigators
->secondaryUrlNavigator();
2197 QAction
*editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
2198 editableLocactionAction
->setChecked(navigator
->isUrlEditable());
2199 connect(navigator
, &KUrlNavigator::editableStateChanged
,
2200 this, &DolphinMainWindow::slotEditableStateChanged
);
2201 connect(navigator
, &KUrlNavigator::tabRequested
,
2202 this, &DolphinMainWindow::openNewTab
);
2203 connect(navigator
, &KUrlNavigator::activeTabRequested
,
2204 this, &DolphinMainWindow::openNewTabAndActivate
);
2205 connect(navigator
, &KUrlNavigator::newWindowRequested
,
2206 this, &DolphinMainWindow::openNewWindow
);
2210 void DolphinMainWindow::updateSplitAction()
2212 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
2213 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2214 if (tabPage
->splitViewEnabled()) {
2215 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2216 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2217 splitAction
->setToolTip(i18nc("@info", "Close left view"));
2218 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2220 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2221 splitAction
->setToolTip(i18nc("@info", "Close right view"));
2222 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2225 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2226 splitAction
->setToolTip(i18nc("@info", "Split view"));
2227 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2231 void DolphinMainWindow::updateAllowedToolbarAreas()
2233 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2234 (actionCollection()->action(QStringLiteral("url_navigators")));
2235 if (toolBar()->actions().contains(navigators
)) {
2236 toolBar()->setAllowedAreas(Qt::TopToolBarArea
| Qt::BottomToolBarArea
);
2237 if (toolBarArea(toolBar()) == Qt::LeftToolBarArea
||
2238 toolBarArea(toolBar()) == Qt::RightToolBarArea
) {
2239 addToolBar(Qt::TopToolBarArea
, toolBar());
2242 toolBar()->setAllowedAreas(Qt::AllToolBarAreas
);
2246 bool DolphinMainWindow::isKompareInstalled() const
2248 static bool initialized
= false;
2249 static bool installed
= false;
2251 // TODO: maybe replace this approach later by using a menu
2252 // plugin like kdiff3plugin.cpp
2253 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2259 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2260 const QKeySequence
& shortcut
,
2261 QAction
* dockAction
,
2262 const QString
& actionName
)
2264 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2265 panelAction
->setCheckable(true);
2266 panelAction
->setChecked(dockAction
->isChecked());
2267 panelAction
->setText(dockAction
->text());
2268 panelAction
->setIcon(icon
);
2269 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2271 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2272 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2275 void DolphinMainWindow::setupWhatsThis()
2278 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2279 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2280 "configuration options. Left-click on any of the menus on this "
2281 "bar to see its contents.</para><para>The Menubar can be hidden "
2282 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2283 "most of its contents become available through a <interface>Control"
2284 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2285 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2286 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2287 "frequently used actions.</para><para>It is highly customizable. "
2288 "All items you see in the <interface>Control</interface> menu or "
2289 "in the <interface>Menubar</interface> can be placed on the "
2290 "Toolbar. Just right-click on it and select <interface>Configure "
2291 "Toolbars…</interface> or find this action in the <interface>"
2292 "Control</interface> or <interface>Settings</interface> menu."
2293 "</para><para>The location of the bar and the style of its "
2294 "buttons can also be changed in the right-click menu. Right-click "
2295 "a button if you want to show or hide its text.</para>"));
2296 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2297 "<para>Here you can see the <emphasis>folders</emphasis> and "
2298 "<emphasis>files</emphasis> that are at the location described in "
2299 "the <interface>Location Bar</interface> above. This area is the "
2300 "central part of this application where you navigate to the files "
2301 "you want to use.</para><para>For an elaborate and general "
2302 "introduction to this application <link "
2303 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2304 "click here</link>. This will open an introductory article from "
2305 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2306 "explanations of all the features of this <emphasis>view</emphasis> "
2307 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2308 "instead. This will open a page from the <emphasis>Handbook"
2309 "</emphasis> that covers the basics.</para>"));
2312 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2313 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2314 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2315 "There you can set up key combinations to trigger an action when "
2316 "they are pressed simultaneously. All commands in this application can "
2317 "be triggered this way.</para>"));
2318 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2319 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2320 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2321 "<para>All items you see in the <interface>Control</interface> menu "
2322 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2323 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2324 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2325 "change a multitude of settings for this application. For an explanation "
2326 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2327 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2330 // The whatsthis has to be set for the m_helpMenu and for the
2331 // StandardAction separately because both are used in different locations.
2332 // m_helpMenu is only used for createControlButton() button.
2334 auto setStandardActionWhatsThis
= [this](KStandardAction::StandardAction actionId
,
2335 const QString
&whatsThis
) {
2336 if (auto *action
= actionCollection()->action(KStandardAction::name(actionId
))) {
2337 action
->setWhatsThis(whatsThis
);
2340 auto setHelpActionWhatsThis
= [this](KHelpMenu::MenuId menuId
, const QString
&whatsThis
) {
2341 if (auto *action
= m_helpMenu
->action(menuId
)) {
2342 action
->setWhatsThis(whatsThis
);
2346 // Links do not work within the Menubar so texts without links are provided there.
2348 // i18n: If the external link isn't available in your language you should
2349 // probably state the external link language at least in brackets to not
2350 // frustrate the user. If there are multiple languages that the user might
2351 // know with a reasonable chance you might want to have 2 external links.
2352 // The same is in my opinion true for every external link you translate.
2353 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2354 "<para>This opens the Handbook for this application. It provides "
2355 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2356 setStandardActionWhatsThis(KStandardAction::HelpContents
, whatsThisHelpContents
2357 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2358 "<para>If you want more elaborate introductions to the "
2359 "different features of <emphasis>Dolphin</emphasis> "
2360 "go to the KDE UserBase Wiki.</para>"));
2361 setHelpActionWhatsThis(KHelpMenu::menuHelpContents
, whatsThisHelpContents
2362 + xi18nc("@info:whatsthis second half of handbook text with link",
2363 "<para>If you want more elaborate introductions to the "
2364 "different features of <emphasis>Dolphin</emphasis> "
2365 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2366 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2368 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2369 "<para>This is the button that invokes the help feature you are "
2370 "using right now! Click it, then click any component of this "
2371 "application to ask \"What's this?\" about it. The mouse cursor "
2372 "will change appearance if no help is available for a spot.</para>");
2373 setStandardActionWhatsThis(KStandardAction::WhatsThis
, whatsThisWhatsThis
2374 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2375 "<para>There are two other ways to get help for this application: The "
2376 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2377 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2378 "article about <emphasis>File Management</emphasis> online."
2379 "</para><para>The \"What's this?\" help is "
2380 "missing in most other windows so don't get too used to this.</para>"));
2381 setHelpActionWhatsThis(KHelpMenu::menuWhatsThis
, whatsThisWhatsThis
2382 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2383 "<para>There are two other ways to get help: "
2384 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2385 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2386 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2387 "missing in most other windows so don't get too used to this.</para>"));
2389 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2390 "window that will guide you through reporting errors or flaws "
2391 "in this application or in other KDE software.</para>");
2392 setStandardActionWhatsThis(KStandardAction::ReportBug
, whatsThisReportBug
);
2393 setHelpActionWhatsThis(KHelpMenu::menuReportBug
, whatsThisReportBug
2394 + xi18nc("@info:whatsthis second half of reportbug text with link",
2395 "<para>High-quality bug reports are much appreciated. To learn "
2396 "how to make your bug report as effective as possible "
2397 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2398 "click here</link>.</para>"));
2400 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2401 "<emphasis>web page</emphasis> where you can donate to "
2402 "support the continued work on this application and many "
2403 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2404 "<para>Donating is the easiest and fastest way to efficiently "
2405 "support KDE and its projects. KDE projects are available for "
2406 "free therefore your donation is needed to cover things that "
2407 "require money like servers, contributor meetings, etc.</para>"
2408 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2409 "organization behind the KDE community.</para>");
2410 setStandardActionWhatsThis(KStandardAction::Donate
, whatsThisDonate
);
2411 setHelpActionWhatsThis(KHelpMenu::menuDonate
, whatsThisDonate
);
2413 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2414 "With this you can change the language this application uses."
2415 "<nl/>You can even set secondary languages which will be used "
2416 "if texts are not available in your preferred language.");
2417 setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage
,
2418 whatsThisSwitchLanguage
);
2419 setHelpActionWhatsThis(KHelpMenu::menuSwitchLanguage
, whatsThisSwitchLanguage
);
2421 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2422 "window that informs you about the version, license, "
2423 "used libraries and maintainers of this application.");
2424 setStandardActionWhatsThis(KStandardAction::AboutApp
, whatsThisAboutApp
);
2425 setHelpActionWhatsThis(KHelpMenu::menuAboutApp
, whatsThisAboutApp
);
2427 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2428 "window with information about <emphasis>KDE</emphasis>. "
2429 "The KDE community are the people behind this free software."
2430 "<nl/>If you like using this application but don't know "
2431 "about KDE or want to see a cute dragon have a look!");
2432 setStandardActionWhatsThis(KStandardAction::AboutKDE
, whatsThisAboutKDE
);
2433 setHelpActionWhatsThis(KHelpMenu::menuAboutKDE
, whatsThisAboutKDE
);
2436 bool DolphinMainWindow::addHamburgerMenuToToolbar()
2438 QDomDocument domDocument
= KXMLGUIClient::domDocument();
2439 if (domDocument
.isNull()) {
2442 QDomNode toolbar
= domDocument
.elementsByTagName(QStringLiteral("ToolBar")).at(0);
2443 if (toolbar
.isNull()) {
2447 QDomElement hamburgerMenuElement
= domDocument
.createElement(QStringLiteral("Action"));
2448 hamburgerMenuElement
.setAttribute(QStringLiteral("name"), QStringLiteral("hamburger_menu"));
2449 toolbar
.appendChild(hamburgerMenuElement
);
2451 KXMLGUIFactory::saveConfigFile(domDocument
, xmlFile());
2455 // Make sure to also remove the <KXMLGUIFactory> and <QDomDocument> include
2456 // whenever this method is removed (maybe in the year ~2026).
2459 bool DolphinMainWindow::event(QEvent
*event
)
2461 if (event
->type() == QEvent::WhatsThisClicked
) {
2463 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2464 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2467 return KXmlGuiWindow::event(event
);
2470 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2473 if (event
->type() == QEvent::WhatsThisClicked
) {
2475 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2476 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2482 // Set a sane initial window size
2483 QSize
DolphinMainWindow::sizeHint() const
2485 return KXmlGuiWindow::sizeHint().expandedTo(QSize(760, 550));
2488 void DolphinMainWindow::saveNewToolbarConfig()
2490 KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
2491 // because the rest of this method decides things
2492 // based on the new config.
2493 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2494 (actionCollection()->action(QStringLiteral("url_navigators")));
2495 if (!toolBar()->actions().contains(navigators
)) {
2496 m_tabWidget
->currentTabPage()->insertNavigatorsWidget(navigators
);
2498 updateAllowedToolbarAreas();
2499 (static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(
2500 KStandardAction::HamburgerMenu
))))->hideActionsOf(toolBar());
2503 void DolphinMainWindow::focusTerminalPanel()
2505 if (m_terminalPanel
->isVisible()) {
2506 if (m_terminalPanel
->terminalHasFocus()) {
2507 m_activeViewContainer
->view()->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2508 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2510 m_terminalPanel
->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2511 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2514 actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger();
2515 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2519 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2520 KIO::FileUndoManager::UiInterface()
2524 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2528 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2530 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2532 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2533 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2535 KIO::FileUndoManager::UiInterface::jobError(job
);
2539 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2541 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));