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>
68 #include <kio_version.h>
70 #include <QApplication>
72 #include <QCloseEvent>
73 #include <QDesktopServices>
75 #include <QDomDocument>
79 #include <QPushButton>
81 #include <QStandardPaths>
83 #include <QToolButton>
84 #include <QWhatsThisClickedEvent>
87 // Used for GeneralSettings::version() to determine whether
88 // an updated version of Dolphin is running.
89 const int CurrentDolphinVersion
= 201;
90 // The maximum number of entries in the back/forward popup menu
91 const int MaxNumberOfNavigationentries
= 12;
92 // The maximum number of "Activate Tab" shortcuts
93 const int MaxActivateTabShortcuts
= 9;
96 DolphinMainWindow::DolphinMainWindow() :
97 KXmlGuiWindow(nullptr),
98 m_newFileMenu(nullptr),
100 m_tabWidget(nullptr),
101 m_activeViewContainer(nullptr),
102 m_actionHandler(nullptr),
103 m_remoteEncoding(nullptr),
105 m_bookmarkHandler(nullptr),
106 m_controlButton(nullptr),
107 m_updateToolBarTimer(nullptr),
108 m_lastHandleUrlOpenJob(nullptr),
109 m_terminalPanel(nullptr),
110 m_placesPanel(nullptr),
111 m_tearDownFromPlacesRequested(false),
112 m_backAction(nullptr),
113 m_forwardAction(nullptr)
115 Q_INIT_RESOURCE(dolphin
);
117 new MainWindowAdaptor(this);
120 setWindowFlags(Qt::WindowContextHelpButtonHint
);
122 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
123 setObjectName(QStringLiteral("Dolphin#"));
125 setStateConfigGroup("State");
127 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
128 this, &DolphinMainWindow::showErrorMessage
);
130 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
131 undoManager
->setUiInterface(new UndoUiInterface());
133 connect(undoManager
, &KIO::FileUndoManager::undoAvailable
,
134 this, &DolphinMainWindow::slotUndoAvailable
);
135 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
136 this, &DolphinMainWindow::slotUndoTextChanged
);
137 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
138 this, &DolphinMainWindow::clearStatusBar
);
139 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
140 this, &DolphinMainWindow::showCommand
);
142 const bool firstRun
= (GeneralSettings::version() < 200);
144 GeneralSettings::setViewPropsTimestamp(QDateTime::currentDateTime());
147 setAcceptDrops(true);
149 auto *navigatorsWidgetAction
= new DolphinNavigatorsWidgetAction(this);
150 actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction
);
151 m_tabWidget
= new DolphinTabWidget(navigatorsWidgetAction
, this);
152 m_tabWidget
->setObjectName("tabWidget");
153 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
154 this, &DolphinMainWindow::activeViewChanged
);
155 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
156 this, &DolphinMainWindow::tabCountChanged
);
157 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
158 this, &DolphinMainWindow::updateWindowTitle
);
159 setCentralWidget(m_tabWidget
);
163 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
164 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
165 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
167 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
168 connect(this, &DolphinMainWindow::urlChanged
,
169 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
173 setupGUI(Keys
| Save
| Create
| ToolBar
);
174 stateChanged(QStringLiteral("new_file"));
176 QClipboard
* clipboard
= QApplication::clipboard();
177 connect(clipboard
, &QClipboard::dataChanged
,
178 this, &DolphinMainWindow::updatePasteAction
);
180 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
181 toggleFilterBarAction
->setChecked(GeneralSettings::filterBar());
184 menuBar()->setVisible(false);
187 const bool showMenu
= !menuBar()->isHidden();
188 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
189 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
191 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(actionCollection()->action(
192 KStandardAction::name(KStandardAction::HamburgerMenu
)));
193 hamburgerMenu
->setMenuBar(menuBar());
194 hamburgerMenu
->setShowMenuBarAction(showMenuBarAction
);
195 connect(hamburgerMenu
, &KHamburgerMenu::aboutToShowMenu
,
196 this, &DolphinMainWindow::updateHamburgerMenu
);
197 hamburgerMenu
->hideActionsOf(toolBar());
198 if (GeneralSettings::version() < 201 && !toolBar()->actions().contains(hamburgerMenu
)) {
199 addHamburgerMenuToToolbar();
202 updateAllowedToolbarAreas();
204 // enable middle-click on back/forward/up to open in a new tab
205 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
206 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
207 toolBar()->installEventFilter(middleClickEventFilter
);
211 connect(KSycoca::self(), &KSycoca::databaseChanged
, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
213 QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
215 m_fileItemActions
.setParentWidget(this);
216 connect(&m_fileItemActions
, &KFileItemActions::error
, this, [this](const QString
&errorMessage
) {
217 showErrorMessage(errorMessage
);
220 connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged
,
221 this, &DolphinMainWindow::slotSplitViewChanged
);
224 DolphinMainWindow::~DolphinMainWindow()
226 // This fixes a crash on Wayland when closing the mainwindow while another dialog is open.
227 disconnect(QGuiApplication::clipboard(), &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
230 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
232 QVector
<DolphinViewContainer
*> viewContainers
;
234 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
235 DolphinTabPage
*tabPage
= m_tabWidget
->tabPageAt(i
);
237 viewContainers
<< tabPage
->primaryViewContainer();
238 if (tabPage
->splitViewEnabled()) {
239 viewContainers
<< tabPage
->secondaryViewContainer();
242 return viewContainers
;
245 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
247 m_tabWidget
->openDirectories(dirs
, splitView
);
250 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
252 openDirectories(QUrl::fromStringList(dirs
), splitView
);
255 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
257 m_tabWidget
->openFiles(files
, splitView
);
260 bool DolphinMainWindow::isFoldersPanelEnabled() const
262 return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
265 bool DolphinMainWindow::isInformationPanelEnabled() const
268 return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
274 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
276 openFiles(QUrl::fromStringList(files
), splitView
);
279 void DolphinMainWindow::activateWindow()
281 window()->setAttribute(Qt::WA_NativeWindow
, true);
282 KStartupInfo::setNewStartupId(window()->windowHandle(), KStartupInfo::startupId());
283 KWindowSystem::activateWindow(window()->effectiveWinId());
286 void DolphinMainWindow::showCommand(CommandType command
)
288 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
290 case KIO::FileUndoManager::Copy
:
291 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
293 case KIO::FileUndoManager::Move
:
294 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
296 case KIO::FileUndoManager::Link
:
297 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
299 case KIO::FileUndoManager::Trash
:
300 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
302 case KIO::FileUndoManager::Rename
:
303 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
306 case KIO::FileUndoManager::Mkdir
:
307 statusBar
->setText(i18nc("@info:status", "Created folder."));
315 void DolphinMainWindow::pasteIntoFolder()
317 m_activeViewContainer
->view()->pasteIntoFolder();
320 void DolphinMainWindow::changeUrl(const QUrl
&url
)
322 if (!KProtocolManager::supportsListing(url
)) {
323 // The URL navigator only checks for validity, not
324 // if the URL can be listed. An error message is
325 // shown due to DolphinViewContainer::restoreView().
329 m_activeViewContainer
->setUrl(url
);
330 updateFileAndEditActions();
335 Q_EMIT
urlChanged(url
);
338 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
340 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
341 m_placesPanel
->proceedWithTearDown();
342 m_tearDownFromPlacesRequested
= false;
345 m_activeViewContainer
->setAutoGrabFocus(false);
347 m_activeViewContainer
->setAutoGrabFocus(true);
350 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
352 KToggleAction
* editableLocationAction
=
353 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
354 editableLocationAction
->setChecked(editable
);
357 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
359 updateFileAndEditActions();
361 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
363 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
364 if (selectedUrlsCount
== 2) {
365 compareFilesAction
->setEnabled(isKompareInstalled());
367 compareFilesAction
->setEnabled(false);
370 Q_EMIT
selectionChanged(selection
);
373 void DolphinMainWindow::updateHistory()
375 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
376 const int index
= urlNavigator
->historyIndex();
378 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
380 backAction
->setToolTip(i18nc("@info", "Go back"));
381 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
382 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
385 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
387 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
388 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
389 "This undoes a <interface>Go|Back</interface> action."));
390 forwardAction
->setEnabled(index
> 0);
394 void DolphinMainWindow::updateFilterBarAction(bool show
)
396 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
397 toggleFilterBarAction
->setChecked(show
);
400 void DolphinMainWindow::openNewMainWindow()
402 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
405 void DolphinMainWindow::openNewActivatedTab()
407 // keep browsers compatibility, new tab is always after last one
408 auto openNewTabAfterLastTabConfigured
= GeneralSettings::openNewTabAfterLastTab();
409 GeneralSettings::setOpenNewTabAfterLastTab(true);
410 m_tabWidget
->openNewActivatedTab();
411 GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured
);
414 void DolphinMainWindow::addToPlaces()
419 // If nothing is selected, act on the current dir
420 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
421 url
= m_activeViewContainer
->url();
422 name
= m_activeViewContainer
->placesText();
424 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
425 url
= dirToAdd
.url();
426 name
= dirToAdd
.name();
430 if (m_activeViewContainer
->isSearchModeEnabled()) {
431 icon
= QStringLiteral("folder-saved-search-symbolic");
433 icon
= KIO::iconNameForUrl(url
);
435 DolphinPlacesModelSingleton::instance().placesModel()->addPlace(name
, url
, icon
);
439 void DolphinMainWindow::openNewTab(const QUrl
& url
)
441 m_tabWidget
->openNewTab(url
, QUrl());
444 void DolphinMainWindow::openNewTabAndActivate(const QUrl
&url
)
446 m_tabWidget
->openNewActivatedTab(url
, QUrl());
449 void DolphinMainWindow::openNewWindow(const QUrl
&url
)
451 Dolphin::openNewWindow({url
}, this);
454 void DolphinMainWindow::slotSplitViewChanged()
456 m_tabWidget
->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation
);
460 void DolphinMainWindow::openInNewTab()
462 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
463 bool tabCreated
= false;
465 for (const KFileItem
& item
: list
) {
466 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
467 if (!url
.isEmpty()) {
473 // if no new tab has been created from the selection
474 // open the current directory in a new tab
476 openNewTab(m_activeViewContainer
->url());
480 void DolphinMainWindow::openInNewWindow()
484 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
485 if (list
.isEmpty()) {
486 newWindowUrl
= m_activeViewContainer
->url();
487 } else if (list
.count() == 1) {
488 const KFileItem
& item
= list
.first();
489 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
492 if (!newWindowUrl
.isEmpty()) {
493 Dolphin::openNewWindow({newWindowUrl
}, this);
497 void DolphinMainWindow::showTarget()
499 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
500 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
501 auto linkDestination
= link
.linkDest();
502 if (QFileInfo(linkDestination
).isRelative()) {
503 linkDestination
= linkLocationDir
.filePath(linkDestination
);
505 if (QFileInfo::exists(linkDestination
)) {
506 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
508 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
509 DolphinViewContainer::Warning
);
513 void DolphinMainWindow::showEvent(QShowEvent
* event
)
515 KXmlGuiWindow::showEvent(event
);
517 if (!event
->spontaneous()) {
518 m_activeViewContainer
->view()->setFocus();
522 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
524 // Find out if Dolphin is closed directly by the user or
525 // by the session manager because the session is closed
526 bool closedByUser
= true;
527 if (qApp
->isSavingSession()) {
528 closedByUser
= false;
531 if (m_tabWidget
->count() > 1
532 && GeneralSettings::confirmClosingMultipleTabs()
533 && !GeneralSettings::rememberOpenedTabs()
535 // Ask the user if he really wants to quit and close all tabs.
536 // Open a confirmation dialog with 3 buttons:
537 // QDialogButtonBox::Yes -> Quit
538 // QDialogButtonBox::No -> Close only the current tab
539 // QDialogButtonBox::Cancel -> do nothing
540 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
541 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
542 dialog
->setModal(true);
543 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
544 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
545 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
546 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
547 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
549 bool doNotAskAgainCheckboxResult
= false;
551 const auto result
= KMessageBox::createKMessageBox(dialog
,
553 QMessageBox::Warning
,
554 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
556 i18n("Do not ask again"),
557 &doNotAskAgainCheckboxResult
,
558 KMessageBox::Notify
);
560 if (doNotAskAgainCheckboxResult
) {
561 GeneralSettings::setConfirmClosingMultipleTabs(false);
565 case QDialogButtonBox::Yes
:
568 case QDialogButtonBox::No
:
569 // Close only the current tab
570 m_tabWidget
->closeTab();
578 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
579 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
580 // Open a confirmation dialog with 3 buttons:
581 // QDialogButtonBox::Yes -> Quit
582 // QDialogButtonBox::No -> Show Terminal Panel
583 // QDialogButtonBox::Cancel -> do nothing
584 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
585 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
586 dialog
->setModal(true);
587 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
588 if (!m_terminalPanel
->isVisible()) {
589 standardButtons
|= QDialogButtonBox::No
;
591 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
592 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
593 if (!m_terminalPanel
->isVisible()) {
595 buttons
->button(QDialogButtonBox::No
),
596 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
598 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
600 bool doNotAskAgainCheckboxResult
= false;
602 const auto result
= KMessageBox::createKMessageBox(
605 QMessageBox::Warning
,
606 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
608 i18n("Do not ask again"),
609 &doNotAskAgainCheckboxResult
,
610 KMessageBox::Dangerous
);
612 if (doNotAskAgainCheckboxResult
) {
613 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
617 case QDialogButtonBox::Yes
:
620 case QDialogButtonBox::No
:
621 actionCollection()->action("show_terminal_panel")->trigger();
622 // Do not quit, ignore quit event
630 if (GeneralSettings::rememberOpenedTabs()) {
631 KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin"));
632 KConfig
*config
= KConfigGui::sessionConfig();
633 saveGlobalProperties(config
);
634 savePropertiesInternal(config
, 1);
638 GeneralSettings::setVersion(CurrentDolphinVersion
);
639 GeneralSettings::self()->save();
641 KXmlGuiWindow::closeEvent(event
);
644 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
646 m_tabWidget
->saveProperties(group
);
649 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
651 m_tabWidget
->readProperties(group
);
654 void DolphinMainWindow::updateNewMenu()
656 m_newFileMenu
->checkUpToDate();
657 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << activeViewContainer()->url());
660 void DolphinMainWindow::createDirectory()
662 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << activeViewContainer()->url());
663 m_newFileMenu
->createDirectory();
666 void DolphinMainWindow::quit()
671 void DolphinMainWindow::showErrorMessage(const QString
& message
)
673 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
676 void DolphinMainWindow::slotUndoAvailable(bool available
)
678 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
680 undoAction
->setEnabled(available
);
684 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
686 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
688 undoAction
->setText(text
);
692 void DolphinMainWindow::undo()
695 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
696 KIO::FileUndoManager::self()->undo();
699 void DolphinMainWindow::cut()
701 m_activeViewContainer
->view()->cutSelectedItemsToClipboard();
704 void DolphinMainWindow::copy()
706 m_activeViewContainer
->view()->copySelectedItemsToClipboard();
709 void DolphinMainWindow::paste()
711 m_activeViewContainer
->view()->paste();
714 void DolphinMainWindow::find()
716 m_activeViewContainer
->setSearchModeEnabled(true);
719 void DolphinMainWindow::updateSearchAction()
721 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
722 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
725 void DolphinMainWindow::updatePasteAction()
727 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
728 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
729 pasteAction
->setEnabled(pasteInfo
.first
);
730 pasteAction
->setText(pasteInfo
.second
);
733 void DolphinMainWindow::slotDirectoryLoadingCompleted()
738 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
740 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
742 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
744 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
746 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
751 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
753 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
755 m_backAction
->menu()->clear();
756 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
757 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toDisplayString(QUrl::PreferLocalFile
), m_backAction
->menu());
759 m_backAction
->menu()->addAction(action
);
763 void DolphinMainWindow::slotGoBack(QAction
* action
)
765 int gotoIndex
= action
->data().value
<int>();
766 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
767 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
772 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
775 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
776 openNewTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
780 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
782 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
784 m_forwardAction
->menu()->clear();
785 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
786 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toDisplayString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
788 m_forwardAction
->menu()->addAction(action
);
792 void DolphinMainWindow::slotGoForward(QAction
* action
)
794 int gotoIndex
= action
->data().value
<int>();
795 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
796 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
801 void DolphinMainWindow::selectAll()
805 // if the URL navigator is editable and focused, select the whole
806 // URL instead of all items of the view
808 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
809 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
810 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
811 lineEdit
->hasFocus();
813 lineEdit
->selectAll();
815 m_activeViewContainer
->view()->selectAll();
819 void DolphinMainWindow::invertSelection()
822 m_activeViewContainer
->view()->invertSelection();
825 void DolphinMainWindow::toggleSplitView()
827 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
828 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled(), WithAnimation
);
833 void DolphinMainWindow::toggleSplitStash()
835 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
836 tabPage
->setSplitViewEnabled(false, WithAnimation
);
837 tabPage
->setSplitViewEnabled(true, WithAnimation
, QUrl("stash:/"));
840 void DolphinMainWindow::reloadView()
843 m_activeViewContainer
->reload();
844 m_activeViewContainer
->statusBar()->updateSpaceInfo();
847 void DolphinMainWindow::stopLoading()
849 m_activeViewContainer
->view()->stopLoading();
852 void DolphinMainWindow::enableStopAction()
854 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
857 void DolphinMainWindow::disableStopAction()
859 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
862 void DolphinMainWindow::showFilterBar()
864 m_activeViewContainer
->setFilterBarVisible(true);
867 void DolphinMainWindow::toggleFilterBar()
869 const bool checked
= !m_activeViewContainer
->isFilterBarVisible();
870 m_activeViewContainer
->setFilterBarVisible(checked
);
872 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
873 toggleFilterBarAction
->setChecked(checked
);
876 void DolphinMainWindow::toggleEditLocation()
880 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
881 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
882 urlNavigator
->setUrlEditable(action
->isChecked());
885 void DolphinMainWindow::replaceLocation()
887 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
888 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
890 // If the text field currently has focus and everything is selected,
891 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
892 if (navigator
->isUrlEditable()
893 && lineEdit
->hasFocus()
894 && lineEdit
->selectedText() == lineEdit
->text() ) {
895 navigator
->setUrlEditable(false);
897 navigator
->setUrlEditable(true);
898 navigator
->setFocus();
899 lineEdit
->selectAll();
903 void DolphinMainWindow::togglePanelLockState()
905 const bool newLockState
= !GeneralSettings::lockPanels();
906 const auto childrenObjects
= children();
907 for (QObject
* child
: childrenObjects
) {
908 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
910 dock
->setLocked(newLockState
);
914 GeneralSettings::setLockPanels(newLockState
);
917 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
919 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
920 m_activeViewContainer
->view()->setFocus();
924 void DolphinMainWindow::goBack()
926 DolphinUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
927 urlNavigator
->goBack();
929 if (urlNavigator
->locationState().isEmpty()) {
930 // An empty location state indicates a redirection URL,
931 // which must be skipped too
932 urlNavigator
->goBack();
936 void DolphinMainWindow::goForward()
938 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goForward();
941 void DolphinMainWindow::goUp()
943 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goUp();
946 void DolphinMainWindow::goHome()
948 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goHome();
951 void DolphinMainWindow::goBackInNewTab()
953 const KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
954 const int index
= urlNavigator
->historyIndex() + 1;
955 openNewTab(urlNavigator
->locationUrl(index
));
958 void DolphinMainWindow::goForwardInNewTab()
960 const KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
961 const int index
= urlNavigator
->historyIndex() - 1;
962 openNewTab(urlNavigator
->locationUrl(index
));
965 void DolphinMainWindow::goUpInNewTab()
967 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
968 openNewTab(KIO::upUrl(currentUrl
));
971 void DolphinMainWindow::goHomeInNewTab()
973 openNewTab(Dolphin::homeUrl());
976 void DolphinMainWindow::compareFiles()
978 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
979 if (items
.count() != 2) {
980 // The action is disabled in this case, but it could have been triggered
981 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
985 QUrl urlA
= items
.at(0).url();
986 QUrl urlB
= items
.at(1).url();
988 QString
command(QStringLiteral("kompare -c \""));
989 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
990 command
.append("\" \"");
991 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
992 command
.append('\"');
994 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(command
, this);
995 job
->setDesktopName(QStringLiteral("org.kde.kompare"));
999 void DolphinMainWindow::toggleShowMenuBar()
1001 const bool visible
= menuBar()->isVisible();
1002 menuBar()->setVisible(!visible
);
1005 QPointer
<QAction
> DolphinMainWindow::preferredSearchTool()
1007 m_searchTools
.clear();
1008 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
1009 &m_searchTools
, { "files-find" }, m_activeViewContainer
->url()
1011 QList
<QAction
*> actions
= m_searchTools
.actions();
1012 if (actions
.isEmpty()) {
1015 QAction
* action
= actions
.first();
1016 if (action
->isSeparator()) {
1022 void DolphinMainWindow::updateOpenPreferredSearchToolAction()
1024 QAction
* openPreferredSearchTool
= actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
1025 if (!openPreferredSearchTool
) {
1028 QPointer
<QAction
> tool
= preferredSearchTool();
1030 openPreferredSearchTool
->setVisible(true);
1031 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open %1", tool
->text()));
1032 // Only override with the app icon if it is the default, i.e. the user hasn't configured one manually
1033 // https://bugs.kde.org/show_bug.cgi?id=442815
1034 if (openPreferredSearchTool
->icon().name() == QLatin1String("search")) {
1035 openPreferredSearchTool
->setIcon(tool
->icon());
1038 openPreferredSearchTool
->setVisible(false);
1039 // still visible in Shortcuts configuration window
1040 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1041 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1045 void DolphinMainWindow::openPreferredSearchTool()
1047 QPointer
<QAction
> tool
= preferredSearchTool();
1053 void DolphinMainWindow::openTerminal()
1055 const QUrl url
= m_activeViewContainer
->url();
1057 if (url
.isLocalFile()) {
1058 auto job
= new KTerminalLauncherJob(QString());
1059 job
->setWorkingDirectory(url
.toLocalFile());
1064 // Not a local file, with protocol Class ":local", try stat'ing
1065 if (KProtocolInfo::protocolClass(url
.scheme()) == QLatin1String(":local")) {
1066 KIO::StatJob
*job
= KIO::mostLocalUrl(url
);
1067 KJobWidgets::setWindow(job
, this);
1068 connect(job
, &KJob::result
, this, [job
]() {
1070 if (!job
->error()) {
1071 statUrl
= job
->mostLocalUrl();
1074 auto job
= new KTerminalLauncherJob(QString());
1075 job
->setWorkingDirectory(statUrl
.isLocalFile() ? statUrl
.toLocalFile() : QDir::homePath());
1082 // Nothing worked, just use $HOME
1083 auto job
= new KTerminalLauncherJob(QString());
1084 job
->setWorkingDirectory(QDir::homePath());
1088 void DolphinMainWindow::editSettings()
1090 if (!m_settingsDialog
) {
1091 DolphinViewContainer
* container
= activeViewContainer();
1092 container
->view()->writeSettings();
1094 const QUrl url
= container
->url();
1095 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this, actionCollection());
1096 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
1097 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
,
1098 &DolphinUrlNavigatorsController::slotReadSettings
);
1099 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
1100 settingsDialog
->show();
1101 m_settingsDialog
= settingsDialog
;
1103 m_settingsDialog
.data()->raise();
1107 void DolphinMainWindow::handleUrl(const QUrl
& url
)
1109 delete m_lastHandleUrlOpenJob
;
1110 m_lastHandleUrlOpenJob
= nullptr;
1112 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
1113 activeViewContainer()->setUrl(url
);
1115 m_lastHandleUrlOpenJob
= new KIO::OpenUrlJob(url
);
1116 m_lastHandleUrlOpenJob
->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
1117 m_lastHandleUrlOpenJob
->setShowOpenOrExecuteDialog(true);
1119 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::mimeTypeFound
, this,
1120 [this, url
](const QString
&mimetype
) {
1121 if (mimetype
== QLatin1String("inode/directory")) {
1122 // If it's a dir, we'll take it from here
1123 m_lastHandleUrlOpenJob
->kill();
1124 m_lastHandleUrlOpenJob
= nullptr;
1125 activeViewContainer()->setUrl(url
);
1129 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::result
, this, [this]() {
1130 m_lastHandleUrlOpenJob
= nullptr;
1133 m_lastHandleUrlOpenJob
->start();
1137 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1139 // trash:/ is writable but we don't want to create new items in it.
1140 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1141 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1144 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1145 const KFileItem
& item
,
1147 const QList
<QAction
*>& customActions
)
1149 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
, &m_fileItemActions
);
1150 contextMenu
.data()->setCustomActions(customActions
);
1151 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1154 case DolphinContextMenu::OpenParentFolder
:
1155 changeUrl(KIO::upUrl(item
.url()));
1156 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1157 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1160 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1161 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1164 case DolphinContextMenu::OpenParentFolderInNewTab
:
1165 openNewTab(KIO::upUrl(item
.url()));
1168 case DolphinContextMenu::None
:
1173 // Delete the menu, unless it has been deleted in its own nested event loop already.
1175 contextMenu
->deleteLater();
1179 void DolphinMainWindow::updateHamburgerMenu()
1181 KActionCollection
* ac
= actionCollection();
1182 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(
1183 ac
->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
1184 auto menu
= hamburgerMenu
->menu();
1186 menu
= new QMenu(this);
1187 hamburgerMenu
->setMenu(menu
);
1188 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("basic_actions"))->menu());
1189 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("zoom"))->menu());
1193 const QList
<QAction
*> toolbarActions
= toolBar()->actions();
1195 if (!toolBar()->isVisible()) {
1196 // If neither the menu bar nor the toolbar are visible, these actions should be available.
1197 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)));
1198 menu
->addAction(toolBarMenuAction());
1199 menu
->addSeparator();
1202 // This group of actions (until the next separator) contains all the most basic actions
1203 // necessary to use Dolphin effectively.
1204 menu
->addAction(ac
->action(QStringLiteral("go_back")));
1205 menu
->addAction(ac
->action(QStringLiteral("go_forward")));
1207 menu
->addMenu(m_newFileMenu
->menu());
1208 menu
->addAction(ac
->action(QStringLiteral("basic_actions")));
1209 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Undo
)));
1210 if (!toolBar()->isVisible()
1211 || (!toolbarActions
.contains(ac
->action(QStringLiteral("toggle_search")))
1212 && !toolbarActions
.contains(ac
->action(QStringLiteral("open_preferred_search_tool"))))
1214 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Find
)));
1215 // This way a search action will only be added if none of the three available
1216 // search actions is present on the toolbar.
1218 if (!toolBar()->isVisible()
1219 || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_filter")))
1221 menu
->addAction(ac
->action(QStringLiteral("show_filter_bar")));
1222 // This way a filter action will only be added if none of the two available
1223 // filter actions is present on the toolbar.
1225 menu
->addSeparator();
1227 // The second group of actions (up until the next separator) contains actions for opening
1228 // additional views to interact with the file system.
1229 menu
->addAction(ac
->action(QStringLiteral("file_new")));
1230 menu
->addAction(ac
->action(QStringLiteral("new_tab")));
1231 if (ac
->action(QStringLiteral("undo_close_tab"))->isEnabled()) {
1232 menu
->addAction(ac
->action(QStringLiteral("closed_tabs")));
1234 menu
->addAction(ac
->action(QStringLiteral("open_terminal")));
1235 menu
->addSeparator();
1237 // The third group contains actions to change what one sees in the view
1238 // and to change the more general UI.
1239 if (!toolBar()->isVisible()
1240 || (!toolbarActions
.contains(ac
->action(QStringLiteral("icons")))
1241 && !toolbarActions
.contains(ac
->action(QStringLiteral("compact")))
1242 && !toolbarActions
.contains(ac
->action(QStringLiteral("details")))
1243 && !toolbarActions
.contains(ac
->action(QStringLiteral("view_mode"))))
1245 menu
->addAction(ac
->action(QStringLiteral("view_mode")));
1247 menu
->addAction(ac
->action(QStringLiteral("show_hidden_files")));
1248 menu
->addAction(ac
->action(QStringLiteral("sort")));
1249 menu
->addAction(ac
->action(QStringLiteral("additional_info")));
1250 if (!GeneralSettings::showStatusBar() || !GeneralSettings::showZoomSlider()) {
1251 menu
->addAction(ac
->action(QStringLiteral("zoom")));
1253 menu
->addAction(ac
->action(QStringLiteral("panels")));
1255 // The "Configure" menu is not added to the actionCollection() because there is hardly
1256 // a good reason for users to put it on their toolbar.
1257 auto configureMenu
= menu
->addMenu(QIcon::fromTheme(QStringLiteral("configure")),
1258 i18nc("@action:inmenu menu for configure actions", "Configure"));
1259 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
)));
1260 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)));
1261 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)));
1262 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Preferences
)));
1263 hamburgerMenu
->hideActionsOf(configureMenu
);
1266 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1268 DolphinViewContainer
* view
= activeViewContainer();
1270 if (view
->url() == url
) {
1271 // We can end up here if the user clicked a device in the Places Panel
1272 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1275 view
->disableUrlNavigatorSelectionRequests();
1277 view
->enableUrlNavigatorSelectionRequests();
1281 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1283 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1286 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1288 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1289 Q_ASSERT(viewContainer
);
1291 m_activeViewContainer
= viewContainer
;
1293 if (oldViewContainer
) {
1294 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1295 toggleSearchAction
->disconnect(oldViewContainer
);
1297 // Disconnect all signals between the old view container (container,
1298 // view and url navigator) and main window.
1299 oldViewContainer
->disconnect(this);
1300 oldViewContainer
->view()->disconnect(this);
1301 oldViewContainer
->urlNavigatorInternalWithHistory()->disconnect(this);
1302 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
1303 (actionCollection()->action(QStringLiteral("url_navigators")));
1304 navigators
->primaryUrlNavigator()->disconnect(this);
1305 if (auto secondaryUrlNavigator
= navigators
->secondaryUrlNavigator()) {
1306 secondaryUrlNavigator
->disconnect(this);
1309 // except the requestItemInfo so that on hover the information panel can still be updated
1310 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1311 this, &DolphinMainWindow::requestItemInfo
);
1314 connectViewSignals(viewContainer
);
1316 m_actionHandler
->setCurrentView(viewContainer
->view());
1319 updateFileAndEditActions();
1320 updatePasteAction();
1321 updateViewActions();
1323 updateSearchAction();
1325 const QUrl url
= viewContainer
->url();
1326 Q_EMIT
urlChanged(url
);
1329 void DolphinMainWindow::tabCountChanged(int count
)
1331 const bool enableTabActions
= (count
> 1);
1332 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1333 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1335 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1336 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1337 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1340 void DolphinMainWindow::updateWindowTitle()
1342 const QString newTitle
= m_activeViewContainer
->captionWindowTitle();
1343 if (windowTitle() != newTitle
) {
1344 setWindowTitle(newTitle
);
1348 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1350 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1351 setViewsToHomeIfMountPathOpen(mountPath
);
1354 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1355 m_tearDownFromPlacesRequested
= true;
1356 m_terminalPanel
->goHome();
1357 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1359 m_placesPanel
->proceedWithTearDown();
1363 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1365 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1366 setViewsToHomeIfMountPathOpen(mountPath
);
1369 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1370 m_tearDownFromPlacesRequested
= false;
1371 m_terminalPanel
->goHome();
1375 void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString
& mountPath
)
1377 const QVector
<DolphinViewContainer
*> theViewContainers
= viewContainers();
1378 for (DolphinViewContainer
*viewContainer
: theViewContainers
) {
1379 if (viewContainer
&& viewContainer
->url().toLocalFile().startsWith(mountPath
)) {
1380 viewContainer
->setUrl(QUrl::fromLocalFile(QDir::homePath()));
1383 disconnect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, nullptr, nullptr);
1386 void DolphinMainWindow::setupActions()
1388 KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
1390 // setup 'File' menu
1391 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1392 QMenu
* menu
= m_newFileMenu
->menu();
1393 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1394 menu
->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
1395 m_newFileMenu
->setPopupMode(QToolButton::InstantPopup
);
1396 connect(menu
, &QMenu::aboutToShow
,
1397 this, &DolphinMainWindow::updateNewMenu
);
1399 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1400 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1401 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1402 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1403 "window just like this one with the current location and view."
1404 "<nl/>You can drag and drop items between windows."));
1405 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1407 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1408 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1409 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1410 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1411 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1412 "A tab is an additional view within this window. "
1413 "You can drag and drop items between tabs."));
1414 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
| Qt::Key_T
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_N
});
1415 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1417 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1418 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1419 addToPlaces
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1420 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1421 "to the Places panel."));
1422 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1424 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1425 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1426 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1427 "currently viewed tab. If no more tabs are left this window "
1428 "will close instead."));
1430 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1431 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1433 // setup 'Edit' menu
1434 KStandardAction::undo(this,
1435 &DolphinMainWindow::undo
,
1436 actionCollection());
1438 // i18n: This will be the last paragraph for the whatsthis for all three:
1439 // Cut, Copy and Paste
1440 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1441 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1442 "applications and are among the most used commands. That's why their "
1443 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1444 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1445 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1446 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1447 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1448 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1449 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1450 "the clipboard to a new location. The items will be removed from their "
1451 "initial location.") + cutCopyPastePara
);
1452 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1453 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1454 "items in your current selection to the <emphasis>clipboard</emphasis>."
1455 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1456 "from the clipboard to a new location.") + cutCopyPastePara
);
1457 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1458 // The text of the paste-action is modified dynamically by Dolphin
1459 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1460 // due to the long text, the text "Paste" is used:
1461 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1462 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1463 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1464 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1465 "action they are removed from their old location.") + cutCopyPastePara
);
1467 QAction
* copyToOtherViewAction
= actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
1468 copyToOtherViewAction
->setText(i18nc("@action:inmenu", "Copy to Inactive Split View"));
1469 copyToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from "
1470 "the <emphasis>active</emphasis> view to the inactive split view."));
1471 copyToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
1472 copyToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Copy to Inactive Split View"));
1473 actionCollection()->setDefaultShortcut(copyToOtherViewAction
, Qt::SHIFT
| Qt::Key_F5
);
1474 connect(copyToOtherViewAction
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::copyToInactiveSplitView
);
1476 QAction
* moveToOtherViewAction
= actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
1477 moveToOtherViewAction
->setText(i18nc("@action:inmenu", "Move to Inactive Split View"));
1478 moveToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from "
1479 "the <emphasis>active</emphasis> view to the inactive split view."));
1480 moveToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
1481 moveToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Move to Inactive Split View"));
1482 actionCollection()->setDefaultShortcut(moveToOtherViewAction
, Qt::SHIFT
| Qt::Key_F6
);
1483 connect(moveToOtherViewAction
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::moveToInactiveSplitView
);
1485 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1486 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Filter..."));
1487 showFilterBar
->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
1488 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1489 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1490 "There you can enter a text to filter the files and folders currently displayed. "
1491 "Only those that contain the text in their name will be kept in view."));
1492 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1493 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
| Qt::Key_I
, Qt::Key_Slash
});
1494 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1496 // toggle_filter acts as a copy of the main showFilterBar to be used mainly
1497 // in the toolbar, with no default shortcut attached, to avoid messing with
1498 // existing workflows (filter bar always open and Ctrl-I to focus)
1499 QAction
*toggleFilter
= actionCollection()->addAction(QStringLiteral("toggle_filter"));
1500 toggleFilter
->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
1501 toggleFilter
->setIconText(i18nc("@action:intoolbar", "Filter"));
1502 toggleFilter
->setIcon(showFilterBar
->icon());
1503 toggleFilter
->setToolTip(showFilterBar
->toolTip());
1504 toggleFilter
->setWhatsThis(showFilterBar
->whatsThis());
1505 toggleFilter
->setCheckable(true);
1506 connect(toggleFilter
, &QAction::triggered
, this, &DolphinMainWindow::toggleFilterBar
);
1508 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1509 searchAction
->setText(i18n("Search..."));
1510 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1511 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1512 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1513 "There you can enter search terms and specify settings to find the "
1514 "objects you are looking for.</para><para>Use this help again on "
1515 "the find bar so we can have a look at it while the settings are "
1516 "explained.</para>"));
1518 // toggle_search acts as a copy of the main searchAction to be used mainly
1519 // in the toolbar, with no default shortcut attached, to avoid messing with
1520 // existing workflows (search bar always open and Ctrl-F to focus)
1521 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1522 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1523 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1524 toggleSearchAction
->setIcon(searchAction
->icon());
1525 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1526 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1527 toggleSearchAction
->setCheckable(true);
1529 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1530 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1531 "files and folders in the current location."));
1533 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1534 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1535 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1536 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1537 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1538 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1539 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1541 // setup 'View' menu
1542 // (note that most of it is set up in DolphinViewActionHandler)
1544 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1545 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1546 "the folder view below into two autonomous views.</para><para>This "
1547 "way you can see two locations at once and move items between them "
1548 "quickly.</para>Click this again afterwards to recombine the views."));
1549 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1550 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1552 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1553 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
| Qt::Key_S
);
1554 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1555 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1556 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1557 stashSplit
->setCheckable(false);
1558 QDBusConnectionInterface
*sessionInterface
= QDBusConnection::sessionBus().interface();
1559 stashSplit
->setVisible(sessionInterface
&& sessionInterface
->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
1560 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1562 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1564 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1565 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1566 stop
->setToolTip(i18nc("@info", "Stop loading"));
1567 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1568 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1569 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1571 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1572 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1573 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1574 "This toggles the <emphasis>Location Bar</emphasis> to be "
1575 "editable so you can directly enter a location you want to go to.<nl/>"
1576 "You can also switch to editing by clicking to the right of the "
1577 "location and switch back by confirming the edited location."));
1578 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1579 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1581 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1582 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1583 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1584 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1585 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1586 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1587 "This switches to editing the location and selects it "
1588 "so you can quickly enter a different location."));
1589 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
| Qt::Key_L
);
1590 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1594 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1595 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1596 m_backAction
->setObjectName(backAction
->objectName());
1597 m_backAction
->setShortcuts(backAction
->shortcuts());
1599 m_backAction
->setPopupMode(QToolButton::DelayedPopup
);
1600 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1601 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1602 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1603 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1605 auto backShortcuts
= m_backAction
->shortcuts();
1606 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1607 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1609 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1610 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1611 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1612 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1613 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1614 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1615 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1616 this, &DolphinMainWindow::closedTabsCountChanged
);
1618 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1619 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1620 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1621 "This returns you to the previously closed tab."));
1622 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_T
);
1623 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1624 undoCloseTab
->setEnabled(false);
1625 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1627 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1628 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1629 "the last change you made to files or folders.<nl/>"
1630 "Such changes include <interface>creating, renaming</interface> "
1631 "and <interface>moving</interface> them to a different location "
1632 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1633 "be undone will ask for your confirmation."));
1634 undoAction
->setEnabled(false); // undo should be disabled by default
1637 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1638 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1639 m_forwardAction
->setObjectName(forwardAction
->objectName());
1640 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1642 m_forwardAction
->setPopupMode(QToolButton::DelayedPopup
);
1643 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1644 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1645 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1646 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1647 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1649 // enable middle-click to open in a new tab
1650 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1651 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1652 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1653 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1654 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1655 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1656 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1657 "<filename>Home</filename> folder.<nl/>Every user account "
1658 "has their own <filename>Home</filename> that contains their data "
1659 "including folders that contain personal application data."));
1661 // setup 'Tools' menu
1662 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1663 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1664 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1665 compareFiles
->setEnabled(false);
1666 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1668 QAction
* openPreferredSearchTool
= actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
1669 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1670 openPreferredSearchTool
->setWhatsThis(xi18nc("@info:whatsthis",
1671 "<para>This opens a preferred search tool for the viewed location.</para>"
1672 "<para>Use <emphasis>More Search Tools</emphasis> menu to configure it.</para>"));
1673 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1674 actionCollection()->setDefaultShortcut(openPreferredSearchTool
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F
);
1675 connect(openPreferredSearchTool
, &QAction::triggered
, this, &DolphinMainWindow::openPreferredSearchTool
);
1677 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1678 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1679 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1680 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1681 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1682 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1683 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
1684 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
| Qt::Key_F4
);
1685 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1687 #ifdef HAVE_TERMINAL
1688 QAction
* focusTerminalPanel
= actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
1689 focusTerminalPanel
->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
1690 focusTerminalPanel
->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
1691 actionCollection()->setDefaultShortcut(focusTerminalPanel
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F4
);
1692 connect(focusTerminalPanel
, &QAction::triggered
, this, &DolphinMainWindow::focusTerminalPanel
);
1696 // setup 'Bookmarks' menu
1697 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1698 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1699 // Make the toolbar button version work properly on click
1700 bookmarkMenu
->setPopupMode(QToolButton::InstantPopup
);
1701 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1702 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1704 // setup 'Settings' menu
1705 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1706 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1707 "This switches between having a <emphasis>Menubar</emphasis> "
1708 "and having a <interface>Control</interface> button. Both "
1709 "contain mostly the same commands and configuration options."));
1710 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1711 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1712 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1714 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1715 m_helpMenu
= new KHelpMenu(nullptr);
1716 m_helpMenu
->menu()->installEventFilter(this);
1717 // remove duplicate shortcuts
1718 auto removeHelpActionShortcut
= [this](KHelpMenu::MenuId menuId
) {
1719 if (auto *action
= m_helpMenu
->action(menuId
)) {
1720 action
->setShortcut(QKeySequence());
1723 removeHelpActionShortcut(KHelpMenu::menuHelpContents
);
1724 removeHelpActionShortcut(KHelpMenu::menuWhatsThis
);
1726 // not in menu actions
1727 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1728 nextTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::Key_Tab
));
1730 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1731 prevTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::SHIFT
| Qt::Key_Tab
));
1733 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1734 QAction
* activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
1735 activateTab
->setText(i18nc("@action:inmenu", "Activate Tab %1", i
+ 1));
1736 activateTab
->setEnabled(false);
1737 connect(activateTab
, &QAction::triggered
, this, [this, i
]() { m_tabWidget
->activateTab(i
); });
1739 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
1741 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
1745 QAction
* activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
1746 activateLastTab
->setText(i18nc("@action:inmenu", "Activate Last Tab"));
1747 activateLastTab
->setEnabled(false);
1748 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
1749 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
| Qt::Key_0
);
1751 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1752 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1753 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1754 activateNextTab
->setEnabled(false);
1755 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1756 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1758 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1759 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1760 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1761 activatePrevTab
->setEnabled(false);
1762 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1763 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1766 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1767 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1768 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1769 showTarget
->setEnabled(false);
1770 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1772 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1773 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1774 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1775 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1777 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1778 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1779 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1780 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1782 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1783 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1784 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1785 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1788 void DolphinMainWindow::setupDockWidgets()
1790 const bool lock
= GeneralSettings::lockPanels();
1792 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1793 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1794 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1795 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1796 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1797 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1798 "switches between having panels <emphasis>locked</emphasis> or "
1799 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1800 "dragged to the other side of the window and have a close "
1801 "button.<nl/>Locked panels are embedded more cleanly."));
1802 lockLayoutAction
->setActive(lock
);
1803 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1805 // Setup "Information"
1806 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1807 infoDock
->setLocked(lock
);
1808 infoDock
->setObjectName(QStringLiteral("infoDock"));
1809 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1812 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1813 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1814 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1815 infoDock
->setWidget(infoPanel
);
1817 QAction
* infoAction
= infoDock
->toggleViewAction();
1818 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1820 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1821 connect(this, &DolphinMainWindow::urlChanged
,
1822 infoPanel
, &InformationPanel::setUrl
);
1823 connect(this, &DolphinMainWindow::selectionChanged
,
1824 infoPanel
, &InformationPanel::setSelection
);
1825 connect(this, &DolphinMainWindow::requestItemInfo
,
1826 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1827 connect(this, &DolphinMainWindow::fileItemsChanged
,
1828 infoPanel
, &InformationPanel::slotFilesItemChanged
);
1831 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1832 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1833 "hide panels like this go to <interface>Control|Panels</interface> "
1834 "or <interface>View|Panels</interface>.</para>");
1836 actionCollection()->action(QStringLiteral("show_information_panel"))
1837 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1838 "<emphasis>information</emphasis> panel at the right side of the "
1839 "window.</para><para>The panel provides in-depth information "
1840 "about the items your mouse is hovering over or about the selected "
1841 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1842 "For single items a preview of their contents is provided.</para>"));
1844 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1845 "provides in-depth information about the items your mouse is "
1846 "hovering over or about the selected items. Otherwise it informs "
1847 "you about the currently viewed folder.<nl/>For single items a "
1848 "preview of their contents is provided.</para><para>You can configure "
1849 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1852 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1853 foldersDock
->setLocked(lock
);
1854 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1855 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1856 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1857 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1858 foldersDock
->setWidget(foldersPanel
);
1860 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1861 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1863 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1864 connect(this, &DolphinMainWindow::urlChanged
,
1865 foldersPanel
, &FoldersPanel::setUrl
);
1866 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1867 this, &DolphinMainWindow::changeUrl
);
1868 connect(foldersPanel
, &FoldersPanel::folderInNewTab
,
1869 this, &DolphinMainWindow::openNewTab
);
1870 connect(foldersPanel
, &FoldersPanel::folderInNewActiveTab
,
1871 this, &DolphinMainWindow::openNewTabAndActivate
);
1872 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1873 this, &DolphinMainWindow::showErrorMessage
);
1875 actionCollection()->action(QStringLiteral("show_folders_panel"))
1876 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1877 "<emphasis>folders</emphasis> panel at the left side of the window."
1878 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1879 "</emphasis> in a <emphasis>tree view</emphasis>."));
1880 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1881 "shows the folders of the <emphasis>file system</emphasis> in a "
1882 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1883 "there. Click the arrow to the left of a folder to see its subfolders. "
1884 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1887 #ifdef HAVE_TERMINAL
1888 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1889 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1890 terminalDock
->setLocked(lock
);
1891 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1892 m_terminalPanel
= new TerminalPanel(terminalDock
);
1893 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1894 terminalDock
->setWidget(m_terminalPanel
);
1896 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1897 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1898 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1899 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1900 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1901 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1903 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1904 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1906 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1907 connect(this, &DolphinMainWindow::urlChanged
,
1908 m_terminalPanel
, &TerminalPanel::setUrl
);
1910 if (GeneralSettings::version() < 200) {
1911 terminalDock
->hide();
1914 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1915 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1916 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1917 "<nl/>The location in the terminal will always match the folder "
1918 "view so you can navigate using either.</para><para>The terminal "
1919 "panel is not needed for basic computer usage but can be useful "
1920 "for advanced tasks. To learn more about terminals use the help "
1921 "in a standalone terminal application like Konsole.</para>"));
1922 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1923 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1924 "normal terminal but will match the location of the folder view "
1925 "so you can navigate using either.</para><para>The terminal panel "
1926 "is not needed for basic computer usage but can be useful for "
1927 "advanced tasks. To learn more about terminals use the help in a "
1928 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1932 if (GeneralSettings::version() < 200) {
1934 foldersDock
->hide();
1938 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1939 placesDock
->setLocked(lock
);
1940 placesDock
->setObjectName(QStringLiteral("placesDock"));
1941 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1943 m_placesPanel
= new PlacesPanel(placesDock
);
1944 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1945 placesDock
->setWidget(m_placesPanel
);
1947 QAction
*placesAction
= placesDock
->toggleViewAction();
1948 createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1950 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1951 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1952 this, &DolphinMainWindow::slotPlaceActivated
);
1953 connect(m_placesPanel
, &PlacesPanel::tabRequested
,
1954 this, &DolphinMainWindow::openNewTab
);
1955 connect(m_placesPanel
, &PlacesPanel::activeTabRequested
,
1956 this, &DolphinMainWindow::openNewTabAndActivate
);
1957 connect(m_placesPanel
, &PlacesPanel::newWindowRequested
, this, [this](const QUrl
&url
) {
1958 Dolphin::openNewWindow({url
}, this);
1960 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1961 this, &DolphinMainWindow::showErrorMessage
);
1962 connect(this, &DolphinMainWindow::urlChanged
,
1963 m_placesPanel
, &PlacesPanel::setUrl
);
1964 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1965 &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged
);
1966 connect(this, &DolphinMainWindow::settingsChanged
,
1967 m_placesPanel
, &PlacesPanel::readSettings
);
1968 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1969 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1970 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1971 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1972 DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1974 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1975 actionShowAllPlaces
->setCheckable(true);
1976 actionShowAllPlaces
->setDisabled(true);
1977 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1978 "all places in the places panel that have been hidden. They will "
1979 "appear semi-transparent unless you uncheck their hide property."));
1981 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1982 m_placesPanel
->setShowAll(checked
);
1984 connect(m_placesPanel
, &PlacesPanel::allPlacesShownChanged
, actionShowAllPlaces
, &QAction::setChecked
);
1986 actionCollection()->action(QStringLiteral("show_places_panel"))
1987 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1988 "<emphasis>places</emphasis> panel at the left side of the window."
1989 "</para><para>It allows you to go to locations you have "
1990 "bookmarked and to access disk or media attached to the computer "
1991 "or to the network. It also contains sections to find recently "
1992 "saved files or files of a certain type.</para>"));
1993 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1994 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1995 "you have bookmarked and to access disk or media attached to the "
1996 "computer or to the network. It also contains sections to find "
1997 "recently saved files or files of a certain type.</para><para>"
1998 "Click on an entry to go there. Click with the right mouse button "
1999 "instead to open any entry in a new tab or new window.</para>"
2000 "<para>New entries can be added by dragging folders onto this panel. "
2001 "Right-click any section or entry to hide it. Right-click an empty "
2002 "space on this panel and select <interface>Show Hidden Places"
2003 "</interface> to display it again.</para>") + panelWhatsThis
);
2005 // Add actions into the "Panels" menu
2006 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
2007 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
2008 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
2009 panelsMenu
->setPopupMode(QToolButton::InstantPopup
);
2010 const KActionCollection
* ac
= actionCollection();
2011 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
2013 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
2015 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
2016 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
2017 panelsMenu
->addSeparator();
2018 panelsMenu
->addAction(actionShowAllPlaces
);
2019 panelsMenu
->addAction(lockLayoutAction
);
2021 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
2022 actionShowAllPlaces
->setEnabled(DolphinPlacesModelSingleton::instance().placesModel()->hiddenCount());
2027 void DolphinMainWindow::updateFileAndEditActions()
2029 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
2030 const KActionCollection
* col
= actionCollection();
2031 KFileItemListProperties
capabilitiesSource(list
);
2033 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
2034 QAction
* copyToOtherViewAction
= col
->action(QStringLiteral("copy_to_inactive_split_view"));
2035 QAction
* moveToOtherViewAction
= col
->action(QStringLiteral("move_to_inactive_split_view"));
2036 QAction
* copyLocation
= col
->action(QString("copy_location"));
2038 if (list
.isEmpty()) {
2039 stateChanged(QStringLiteral("has_no_selection"));
2041 addToPlacesAction
->setEnabled(true);
2042 copyToOtherViewAction
->setEnabled(false);
2043 moveToOtherViewAction
->setEnabled(false);
2044 copyLocation
->setEnabled(false);
2046 stateChanged(QStringLiteral("has_selection"));
2048 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
2049 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
2050 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
2051 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
2052 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
2053 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
2054 QAction
* duplicateAction
= col
->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler
2056 if (list
.length() == 1 && list
.first().isDir()) {
2057 addToPlacesAction
->setEnabled(true);
2059 addToPlacesAction
->setEnabled(false);
2062 if (m_tabWidget
->currentTabPage()->splitViewEnabled()) {
2063 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2064 KFileItem capabilitiesDestination
;
2066 if (tabPage
->primaryViewActive()) {
2067 capabilitiesDestination
= tabPage
->secondaryViewContainer()->url();
2069 capabilitiesDestination
= tabPage
->primaryViewContainer()->url();
2072 copyToOtherViewAction
->setEnabled(capabilitiesDestination
.isWritable());
2073 moveToOtherViewAction
->setEnabled(capabilitiesSource
.supportsMoving() && capabilitiesDestination
.isWritable());
2075 copyToOtherViewAction
->setEnabled(false);
2076 moveToOtherViewAction
->setEnabled(false);
2079 const bool enableMoveToTrash
= capabilitiesSource
.isLocal() && capabilitiesSource
.supportsMoving();
2081 renameAction
->setEnabled(capabilitiesSource
.supportsMoving());
2082 moveToTrashAction
->setEnabled(enableMoveToTrash
);
2083 deleteAction
->setEnabled(capabilitiesSource
.supportsDeleting());
2084 deleteWithTrashShortcut
->setEnabled(capabilitiesSource
.supportsDeleting() && !enableMoveToTrash
);
2085 cutAction
->setEnabled(capabilitiesSource
.supportsMoving());
2086 copyLocation
->setEnabled(list
.length() == 1);
2087 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
2088 duplicateAction
->setEnabled(capabilitiesSource
.supportsWriting());
2092 void DolphinMainWindow::updateViewActions()
2094 m_actionHandler
->updateViewActions();
2096 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
2097 toggleFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
2099 updateSplitAction();
2102 void DolphinMainWindow::updateGoActions()
2104 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
2105 const QUrl currentUrl
= m_activeViewContainer
->url();
2106 // I think this is one of the best places to firstly be confronted
2107 // with a file system and its hierarchy. Talking about the root
2108 // directory might seem too much here but it is the question that
2109 // naturally arises in this context.
2110 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
2111 "the folder that contains the currently viewed one.</para>"
2112 "<para>All files and folders are organized in a hierarchical "
2113 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
2114 "a directory that contains all data connected to this computer"
2115 "—the <emphasis>root directory</emphasis>.</para>"));
2116 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
2119 void DolphinMainWindow::refreshViews()
2121 m_tabWidget
->refreshViews();
2123 if (GeneralSettings::modifiedStartupSettings()) {
2124 updateWindowTitle();
2127 Q_EMIT
settingsChanged();
2130 void DolphinMainWindow::clearStatusBar()
2132 m_activeViewContainer
->statusBar()->resetToDefaultText();
2135 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
2137 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
2138 this, &DolphinMainWindow::updateFilterBarAction
);
2139 connect(container
, &DolphinViewContainer::writeStateChanged
,
2140 this, &DolphinMainWindow::slotWriteStateChanged
);
2141 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
2142 this, &DolphinMainWindow::updateSearchAction
);
2143 connect(container
, &DolphinViewContainer::captionChanged
,
2144 this, &DolphinMainWindow::updateWindowTitle
);
2145 connect(container
, &DolphinViewContainer::tabRequested
,
2146 this, &DolphinMainWindow::openNewTab
);
2147 connect(container
, &DolphinViewContainer::activeTabRequested
,
2148 this, &DolphinMainWindow::openNewTabAndActivate
);
2150 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
2151 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
2153 const DolphinView
* view
= container
->view();
2154 connect(view
, &DolphinView::selectionChanged
,
2155 this, &DolphinMainWindow::slotSelectionChanged
);
2156 connect(view
, &DolphinView::requestItemInfo
,
2157 this, &DolphinMainWindow::requestItemInfo
);
2158 connect(view
, &DolphinView::fileItemsChanged
,
2159 this, &DolphinMainWindow::fileItemsChanged
);
2160 connect(view
, &DolphinView::tabRequested
,
2161 this, &DolphinMainWindow::openNewTab
);
2162 connect(view
, &DolphinView::activeTabRequested
,
2163 this, &DolphinMainWindow::openNewTabAndActivate
);
2164 connect(view
, &DolphinView::windowRequested
,
2165 this, &DolphinMainWindow::openNewWindow
);
2166 connect(view
, &DolphinView::requestContextMenu
,
2167 this, &DolphinMainWindow::openContextMenu
);
2168 connect(view
, &DolphinView::directoryLoadingStarted
,
2169 this, &DolphinMainWindow::enableStopAction
);
2170 connect(view
, &DolphinView::directoryLoadingCompleted
,
2171 this, &DolphinMainWindow::disableStopAction
);
2172 connect(view
, &DolphinView::directoryLoadingCompleted
,
2173 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
2174 connect(view
, &DolphinView::goBackRequested
,
2175 this, &DolphinMainWindow::goBack
);
2176 connect(view
, &DolphinView::goForwardRequested
,
2177 this, &DolphinMainWindow::goForward
);
2178 connect(view
, &DolphinView::urlActivated
,
2179 this, &DolphinMainWindow::handleUrl
);
2180 connect(view
, &DolphinView::goUpRequested
,
2181 this, &DolphinMainWindow::goUp
);
2183 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged
,
2184 this, &DolphinMainWindow::changeUrl
);
2185 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged
,
2186 this, &DolphinMainWindow::updateHistory
);
2188 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2189 (actionCollection()->action(QStringLiteral("url_navigators")));
2190 const KUrlNavigator
*navigator
= m_tabWidget
->currentTabPage()->primaryViewActive() ?
2191 navigators
->primaryUrlNavigator() :
2192 navigators
->secondaryUrlNavigator();
2194 QAction
*editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
2195 editableLocactionAction
->setChecked(navigator
->isUrlEditable());
2196 connect(navigator
, &KUrlNavigator::editableStateChanged
,
2197 this, &DolphinMainWindow::slotEditableStateChanged
);
2198 connect(navigator
, &KUrlNavigator::tabRequested
,
2199 this, &DolphinMainWindow::openNewTab
);
2200 connect(navigator
, &KUrlNavigator::activeTabRequested
,
2201 this, &DolphinMainWindow::openNewTabAndActivate
);
2202 connect(navigator
, &KUrlNavigator::newWindowRequested
,
2203 this, &DolphinMainWindow::openNewWindow
);
2207 void DolphinMainWindow::updateSplitAction()
2209 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
2210 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2211 if (tabPage
->splitViewEnabled()) {
2212 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2213 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2214 splitAction
->setToolTip(i18nc("@info", "Close left view"));
2215 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2217 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2218 splitAction
->setToolTip(i18nc("@info", "Close right view"));
2219 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2222 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2223 splitAction
->setToolTip(i18nc("@info", "Split view"));
2224 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2228 void DolphinMainWindow::updateAllowedToolbarAreas()
2230 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2231 (actionCollection()->action(QStringLiteral("url_navigators")));
2232 if (toolBar()->actions().contains(navigators
)) {
2233 toolBar()->setAllowedAreas(Qt::TopToolBarArea
| Qt::BottomToolBarArea
);
2234 if (toolBarArea(toolBar()) == Qt::LeftToolBarArea
||
2235 toolBarArea(toolBar()) == Qt::RightToolBarArea
) {
2236 addToolBar(Qt::TopToolBarArea
, toolBar());
2239 toolBar()->setAllowedAreas(Qt::AllToolBarAreas
);
2243 bool DolphinMainWindow::isKompareInstalled() const
2245 static bool initialized
= false;
2246 static bool installed
= false;
2248 // TODO: maybe replace this approach later by using a menu
2249 // plugin like kdiff3plugin.cpp
2250 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2256 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2257 const QKeySequence
& shortcut
,
2258 QAction
* dockAction
,
2259 const QString
& actionName
)
2261 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2262 panelAction
->setCheckable(true);
2263 panelAction
->setChecked(dockAction
->isChecked());
2264 panelAction
->setText(dockAction
->text());
2265 panelAction
->setIcon(icon
);
2266 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2268 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2269 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2272 void DolphinMainWindow::setupWhatsThis()
2275 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2276 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2277 "configuration options. Left-click on any of the menus on this "
2278 "bar to see its contents.</para><para>The Menubar can be hidden "
2279 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2280 "most of its contents become available through a <interface>Control"
2281 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2282 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2283 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2284 "frequently used actions.</para><para>It is highly customizable. "
2285 "All items you see in the <interface>Control</interface> menu or "
2286 "in the <interface>Menubar</interface> can be placed on the "
2287 "Toolbar. Just right-click on it and select <interface>Configure "
2288 "Toolbars…</interface> or find this action in the <interface>"
2289 "Control</interface> or <interface>Settings</interface> menu."
2290 "</para><para>The location of the bar and the style of its "
2291 "buttons can also be changed in the right-click menu. Right-click "
2292 "a button if you want to show or hide its text.</para>"));
2293 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2294 "<para>Here you can see the <emphasis>folders</emphasis> and "
2295 "<emphasis>files</emphasis> that are at the location described in "
2296 "the <interface>Location Bar</interface> above. This area is the "
2297 "central part of this application where you navigate to the files "
2298 "you want to use.</para><para>For an elaborate and general "
2299 "introduction to this application <link "
2300 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2301 "click here</link>. This will open an introductory article from "
2302 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2303 "explanations of all the features of this <emphasis>view</emphasis> "
2304 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2305 "instead. This will open a page from the <emphasis>Handbook"
2306 "</emphasis> that covers the basics.</para>"));
2309 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2310 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2311 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2312 "There you can set up key combinations to trigger an action when "
2313 "they are pressed simultaneously. All commands in this application can "
2314 "be triggered this way.</para>"));
2315 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2316 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2317 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2318 "<para>All items you see in the <interface>Control</interface> menu "
2319 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2320 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2321 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2322 "change a multitude of settings for this application. For an explanation "
2323 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2324 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2327 // The whatsthis has to be set for the m_helpMenu and for the
2328 // StandardAction separately because both are used in different locations.
2329 // m_helpMenu is only used for createControlButton() button.
2331 auto setStandardActionWhatsThis
= [this](KStandardAction::StandardAction actionId
,
2332 const QString
&whatsThis
) {
2333 if (auto *action
= actionCollection()->action(KStandardAction::name(actionId
))) {
2334 action
->setWhatsThis(whatsThis
);
2337 auto setHelpActionWhatsThis
= [this](KHelpMenu::MenuId menuId
, const QString
&whatsThis
) {
2338 if (auto *action
= m_helpMenu
->action(menuId
)) {
2339 action
->setWhatsThis(whatsThis
);
2343 // Links do not work within the Menubar so texts without links are provided there.
2345 // i18n: If the external link isn't available in your language you should
2346 // probably state the external link language at least in brackets to not
2347 // frustrate the user. If there are multiple languages that the user might
2348 // know with a reasonable chance you might want to have 2 external links.
2349 // The same is in my opinion true for every external link you translate.
2350 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2351 "<para>This opens the Handbook for this application. It provides "
2352 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2353 setStandardActionWhatsThis(KStandardAction::HelpContents
, whatsThisHelpContents
2354 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2355 "<para>If you want more elaborate introductions to the "
2356 "different features of <emphasis>Dolphin</emphasis> "
2357 "go to the KDE UserBase Wiki.</para>"));
2358 setHelpActionWhatsThis(KHelpMenu::menuHelpContents
, whatsThisHelpContents
2359 + xi18nc("@info:whatsthis second half of handbook text with link",
2360 "<para>If you want more elaborate introductions to the "
2361 "different features of <emphasis>Dolphin</emphasis> "
2362 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2363 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2365 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2366 "<para>This is the button that invokes the help feature you are "
2367 "using right now! Click it, then click any component of this "
2368 "application to ask \"What's this?\" about it. The mouse cursor "
2369 "will change appearance if no help is available for a spot.</para>");
2370 setStandardActionWhatsThis(KStandardAction::WhatsThis
, whatsThisWhatsThis
2371 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2372 "<para>There are two other ways to get help for this application: The "
2373 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2374 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2375 "article about <emphasis>File Management</emphasis> online."
2376 "</para><para>The \"What's this?\" help is "
2377 "missing in most other windows so don't get too used to this.</para>"));
2378 setHelpActionWhatsThis(KHelpMenu::menuWhatsThis
, whatsThisWhatsThis
2379 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2380 "<para>There are two other ways to get help: "
2381 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2382 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2383 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2384 "missing in most other windows so don't get too used to this.</para>"));
2386 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2387 "window that will guide you through reporting errors or flaws "
2388 "in this application or in other KDE software.</para>");
2389 setStandardActionWhatsThis(KStandardAction::ReportBug
, whatsThisReportBug
);
2390 setHelpActionWhatsThis(KHelpMenu::menuReportBug
, whatsThisReportBug
2391 + xi18nc("@info:whatsthis second half of reportbug text with link",
2392 "<para>High-quality bug reports are much appreciated. To learn "
2393 "how to make your bug report as effective as possible "
2394 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2395 "click here</link>.</para>"));
2397 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2398 "<emphasis>web page</emphasis> where you can donate to "
2399 "support the continued work on this application and many "
2400 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2401 "<para>Donating is the easiest and fastest way to efficiently "
2402 "support KDE and its projects. KDE projects are available for "
2403 "free therefore your donation is needed to cover things that "
2404 "require money like servers, contributor meetings, etc.</para>"
2405 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2406 "organization behind the KDE community.</para>");
2407 setStandardActionWhatsThis(KStandardAction::Donate
, whatsThisDonate
);
2408 setHelpActionWhatsThis(KHelpMenu::menuDonate
, whatsThisDonate
);
2410 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2411 "With this you can change the language this application uses."
2412 "<nl/>You can even set secondary languages which will be used "
2413 "if texts are not available in your preferred language.");
2414 setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage
,
2415 whatsThisSwitchLanguage
);
2416 setHelpActionWhatsThis(KHelpMenu::menuSwitchLanguage
, whatsThisSwitchLanguage
);
2418 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2419 "window that informs you about the version, license, "
2420 "used libraries and maintainers of this application.");
2421 setStandardActionWhatsThis(KStandardAction::AboutApp
, whatsThisAboutApp
);
2422 setHelpActionWhatsThis(KHelpMenu::menuAboutApp
, whatsThisAboutApp
);
2424 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2425 "window with information about <emphasis>KDE</emphasis>. "
2426 "The KDE community are the people behind this free software."
2427 "<nl/>If you like using this application but don't know "
2428 "about KDE or want to see a cute dragon have a look!");
2429 setStandardActionWhatsThis(KStandardAction::AboutKDE
, whatsThisAboutKDE
);
2430 setHelpActionWhatsThis(KHelpMenu::menuAboutKDE
, whatsThisAboutKDE
);
2433 bool DolphinMainWindow::addHamburgerMenuToToolbar()
2435 QDomDocument domDocument
= KXMLGUIClient::domDocument();
2436 if (domDocument
.isNull()) {
2439 QDomNode toolbar
= domDocument
.elementsByTagName(QStringLiteral("ToolBar")).at(0);
2440 if (toolbar
.isNull()) {
2444 QDomElement hamburgerMenuElement
= domDocument
.createElement(QStringLiteral("Action"));
2445 hamburgerMenuElement
.setAttribute(QStringLiteral("name"), QStringLiteral("hamburger_menu"));
2446 toolbar
.appendChild(hamburgerMenuElement
);
2448 KXMLGUIFactory::saveConfigFile(domDocument
, xmlFile());
2452 // Make sure to also remove the <KXMLGUIFactory> and <QDomDocument> include
2453 // whenever this method is removed (maybe in the year ~2026).
2456 bool DolphinMainWindow::event(QEvent
*event
)
2458 if (event
->type() == QEvent::WhatsThisClicked
) {
2460 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2461 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2464 return KXmlGuiWindow::event(event
);
2467 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2470 if (event
->type() == QEvent::WhatsThisClicked
) {
2472 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2473 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2479 // Set a sane initial window size
2480 QSize
DolphinMainWindow::sizeHint() const
2482 return KXmlGuiWindow::sizeHint().expandedTo(QSize(760, 550));
2485 void DolphinMainWindow::saveNewToolbarConfig()
2487 KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
2488 // because the rest of this method decides things
2489 // based on the new config.
2490 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2491 (actionCollection()->action(QStringLiteral("url_navigators")));
2492 if (!toolBar()->actions().contains(navigators
)) {
2493 m_tabWidget
->currentTabPage()->insertNavigatorsWidget(navigators
);
2495 updateAllowedToolbarAreas();
2496 (static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(
2497 KStandardAction::HamburgerMenu
))))->hideActionsOf(toolBar());
2500 void DolphinMainWindow::focusTerminalPanel()
2502 if (m_terminalPanel
->isVisible()) {
2503 if (m_terminalPanel
->terminalHasFocus()) {
2504 m_activeViewContainer
->view()->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2505 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2507 m_terminalPanel
->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2508 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2511 actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger();
2512 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2516 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2517 KIO::FileUndoManager::UiInterface()
2521 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2525 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2527 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2529 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2530 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2532 KIO::FileUndoManager::UiInterface::jobError(job
);
2536 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2538 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));