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 "dolphinurlnavigatorscontroller.h"
21 #include "dolphinviewcontainer.h"
22 #include "dolphintabpage.h"
23 #include "middleclickactioneventfilter.h"
24 #include "panels/folders/folderspanel.h"
25 #include "panels/places/placesitemmodel.h"
26 #include "panels/places/placespanel.h"
27 #include "panels/terminal/terminalpanel.h"
28 #include "settings/dolphinsettingsdialog.h"
29 #include "statusbar/dolphinstatusbar.h"
30 #include "views/dolphinviewactionhandler.h"
31 #include "views/dolphinremoteencoding.h"
32 #include "views/draganddrophelper.h"
33 #include "views/viewproperties.h"
34 #include "views/dolphinnewfilemenuobserver.h"
35 #include "dolphin_generalsettings.h"
37 #include <KActionCollection>
38 #include <KActionMenu>
39 #include <KAuthorized>
42 #include <KDualAction>
43 #include <KFileItemListProperties>
45 #include <KIO/CommandLauncherJob>
46 #include <KIO/JobUiDelegate>
47 #include <KIO/OpenFileManagerWindowJob>
48 #include <KIO/OpenUrlJob>
49 #include <KJobWidgets>
50 #include <KLocalizedString>
51 #include <KMessageBox>
52 #include <KNS3/KMoreToolsMenuFactory>
53 #include <KProtocolInfo>
54 #include <KProtocolManager>
56 #include <KStandardAction>
57 #include <KStartupInfo>
59 #include <KTerminalLauncherJob>
60 #include <KToggleAction>
62 #include <KToolBarPopupAction>
63 #include <KUrlComboBox>
64 #include <KUrlNavigator>
65 #include <KWindowSystem>
66 #include <KXMLGUIFactory>
67 #include <kxmlgui_version.h>
69 #include <kio_version.h>
71 #include <QApplication>
73 #include <QCloseEvent>
74 #include <QDesktopServices>
76 #include <QDomDocument>
80 #include <QPushButton>
82 #include <QStandardPaths>
84 #include <QToolButton>
85 #include <QWhatsThisClickedEvent>
88 // Used for GeneralSettings::version() to determine whether
89 // an updated version of Dolphin is running.
90 const int CurrentDolphinVersion
= 201;
91 // The maximum number of entries in the back/forward popup menu
92 const int MaxNumberOfNavigationentries
= 12;
93 // The maximum number of "Activate Tab" shortcuts
94 const int MaxActivateTabShortcuts
= 9;
97 DolphinMainWindow::DolphinMainWindow() :
98 KXmlGuiWindow(nullptr),
99 m_newFileMenu(nullptr),
101 m_tabWidget(nullptr),
102 m_activeViewContainer(nullptr),
103 m_actionHandler(nullptr),
104 m_remoteEncoding(nullptr),
106 m_bookmarkHandler(nullptr),
107 m_controlButton(nullptr),
108 m_updateToolBarTimer(nullptr),
109 m_lastHandleUrlOpenJob(nullptr),
110 m_terminalPanel(nullptr),
111 m_placesPanel(nullptr),
112 m_tearDownFromPlacesRequested(false),
113 m_backAction(nullptr),
114 m_forwardAction(nullptr)
116 Q_INIT_RESOURCE(dolphin
);
118 new MainWindowAdaptor(this);
121 setWindowFlags(Qt::WindowContextHelpButtonHint
);
123 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
124 setObjectName(QStringLiteral("Dolphin#"));
126 #if KXMLGUI_VERSION >= QT_VERSION_CHECK(5, 88, 0)
127 setStateConfigGroup("State");
130 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
131 this, &DolphinMainWindow::showErrorMessage
);
133 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
134 undoManager
->setUiInterface(new UndoUiInterface());
136 connect(undoManager
, &KIO::FileUndoManager::undoAvailable
,
137 this, &DolphinMainWindow::slotUndoAvailable
);
138 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
139 this, &DolphinMainWindow::slotUndoTextChanged
);
140 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
141 this, &DolphinMainWindow::clearStatusBar
);
142 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
143 this, &DolphinMainWindow::showCommand
);
145 const bool firstRun
= (GeneralSettings::version() < 200);
147 GeneralSettings::setViewPropsTimestamp(QDateTime::currentDateTime());
150 setAcceptDrops(true);
152 auto *navigatorsWidgetAction
= new DolphinNavigatorsWidgetAction(this);
153 actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction
);
154 m_tabWidget
= new DolphinTabWidget(navigatorsWidgetAction
, this);
155 m_tabWidget
->setObjectName("tabWidget");
156 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
157 this, &DolphinMainWindow::activeViewChanged
);
158 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
159 this, &DolphinMainWindow::tabCountChanged
);
160 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
161 this, &DolphinMainWindow::updateWindowTitle
);
162 setCentralWidget(m_tabWidget
);
166 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
167 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
168 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
170 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
171 connect(this, &DolphinMainWindow::urlChanged
,
172 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
176 setupGUI(Keys
| Save
| Create
| ToolBar
);
177 stateChanged(QStringLiteral("new_file"));
179 QClipboard
* clipboard
= QApplication::clipboard();
180 connect(clipboard
, &QClipboard::dataChanged
,
181 this, &DolphinMainWindow::updatePasteAction
);
183 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
184 toggleFilterBarAction
->setChecked(GeneralSettings::filterBar());
187 menuBar()->setVisible(false);
190 const bool showMenu
= !menuBar()->isHidden();
191 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
192 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
194 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(actionCollection()->action(
195 KStandardAction::name(KStandardAction::HamburgerMenu
)));
196 hamburgerMenu
->setMenuBar(menuBar());
197 hamburgerMenu
->setShowMenuBarAction(showMenuBarAction
);
198 connect(hamburgerMenu
, &KHamburgerMenu::aboutToShowMenu
,
199 this, &DolphinMainWindow::updateHamburgerMenu
);
200 hamburgerMenu
->hideActionsOf(toolBar());
201 if (GeneralSettings::version() < 201 && !toolBar()->actions().contains(hamburgerMenu
)) {
202 addHamburgerMenuToToolbar();
205 updateAllowedToolbarAreas();
207 // enable middle-click on back/forward/up to open in a new tab
208 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
209 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
210 toolBar()->installEventFilter(middleClickEventFilter
);
214 connect(KSycoca::self(), &KSycoca::databaseChanged
, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
216 QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction
);
218 m_fileItemActions
.setParentWidget(this);
219 connect(&m_fileItemActions
, &KFileItemActions::error
, this, [this](const QString
&errorMessage
) {
220 showErrorMessage(errorMessage
);
223 connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged
,
224 this, &DolphinMainWindow::slotSplitViewChanged
);
227 DolphinMainWindow::~DolphinMainWindow()
229 // This fixes a crash on Wayland when closing the mainwindow while another dialog is open.
230 disconnect(QGuiApplication::clipboard(), &QClipboard::dataChanged
, this, &DolphinMainWindow::updatePasteAction
);
233 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
235 QVector
<DolphinViewContainer
*> viewContainers
;
237 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
238 DolphinTabPage
*tabPage
= m_tabWidget
->tabPageAt(i
);
240 viewContainers
<< tabPage
->primaryViewContainer();
241 if (tabPage
->splitViewEnabled()) {
242 viewContainers
<< tabPage
->secondaryViewContainer();
245 return viewContainers
;
248 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
250 m_tabWidget
->openDirectories(dirs
, splitView
);
253 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
255 openDirectories(QUrl::fromStringList(dirs
), splitView
);
258 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
260 m_tabWidget
->openFiles(files
, splitView
);
263 bool DolphinMainWindow::isFoldersPanelEnabled() const
265 return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
268 bool DolphinMainWindow::isInformationPanelEnabled() const
271 return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
277 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
279 openFiles(QUrl::fromStringList(files
), splitView
);
282 void DolphinMainWindow::activateWindow()
284 window()->setAttribute(Qt::WA_NativeWindow
, true);
285 KStartupInfo::setNewStartupId(window()->windowHandle(), KStartupInfo::startupId());
286 KWindowSystem::activateWindow(window()->effectiveWinId());
289 void DolphinMainWindow::showCommand(CommandType command
)
291 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
293 case KIO::FileUndoManager::Copy
:
294 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
296 case KIO::FileUndoManager::Move
:
297 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
299 case KIO::FileUndoManager::Link
:
300 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
302 case KIO::FileUndoManager::Trash
:
303 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
305 case KIO::FileUndoManager::Rename
:
306 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
309 case KIO::FileUndoManager::Mkdir
:
310 statusBar
->setText(i18nc("@info:status", "Created folder."));
318 void DolphinMainWindow::pasteIntoFolder()
320 m_activeViewContainer
->view()->pasteIntoFolder();
323 void DolphinMainWindow::changeUrl(const QUrl
&url
)
325 if (!KProtocolManager::supportsListing(url
)) {
326 // The URL navigator only checks for validity, not
327 // if the URL can be listed. An error message is
328 // shown due to DolphinViewContainer::restoreView().
332 m_activeViewContainer
->setUrl(url
);
333 updateFileAndEditActions();
338 Q_EMIT
urlChanged(url
);
341 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
343 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
344 m_placesPanel
->proceedWithTearDown();
345 m_tearDownFromPlacesRequested
= false;
348 m_activeViewContainer
->setAutoGrabFocus(false);
350 m_activeViewContainer
->setAutoGrabFocus(true);
353 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
355 KToggleAction
* editableLocationAction
=
356 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
357 editableLocationAction
->setChecked(editable
);
360 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
362 updateFileAndEditActions();
364 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
366 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
367 if (selectedUrlsCount
== 2) {
368 compareFilesAction
->setEnabled(isKompareInstalled());
370 compareFilesAction
->setEnabled(false);
373 Q_EMIT
selectionChanged(selection
);
376 void DolphinMainWindow::updateHistory()
378 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
379 const int index
= urlNavigator
->historyIndex();
381 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
383 backAction
->setToolTip(i18nc("@info", "Go back"));
384 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
385 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
388 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
390 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
391 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
392 "This undoes a <interface>Go|Back</interface> action."));
393 forwardAction
->setEnabled(index
> 0);
397 void DolphinMainWindow::updateFilterBarAction(bool show
)
399 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
400 toggleFilterBarAction
->setChecked(show
);
403 void DolphinMainWindow::openNewMainWindow()
405 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
408 void DolphinMainWindow::openNewActivatedTab()
410 // keep browsers compatibility, new tab is always after last one
411 auto openNewTabAfterLastTabConfigured
= GeneralSettings::openNewTabAfterLastTab();
412 GeneralSettings::setOpenNewTabAfterLastTab(true);
413 m_tabWidget
->openNewActivatedTab();
414 GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured
);
417 void DolphinMainWindow::addToPlaces()
422 // If nothing is selected, act on the current dir
423 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
424 url
= m_activeViewContainer
->url();
425 name
= m_activeViewContainer
->placesText();
427 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
428 url
= dirToAdd
.url();
429 name
= dirToAdd
.name();
432 PlacesItemModel model
;
434 if (m_activeViewContainer
->isSearchModeEnabled()) {
435 icon
= QStringLiteral("folder-saved-search-symbolic");
437 icon
= KIO::iconNameForUrl(url
);
439 model
.createPlacesItem(name
, url
, icon
);
443 void DolphinMainWindow::openNewTab(const QUrl
& url
)
445 m_tabWidget
->openNewTab(url
, QUrl());
448 void DolphinMainWindow::openNewTabAndActivate(const QUrl
&url
)
450 m_tabWidget
->openNewActivatedTab(url
, QUrl());
453 void DolphinMainWindow::openNewWindow(const QUrl
&url
)
455 Dolphin::openNewWindow({url
}, this);
458 void DolphinMainWindow::slotSplitViewChanged()
460 m_tabWidget
->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation
);
464 void DolphinMainWindow::openInNewTab()
466 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
467 bool tabCreated
= false;
469 for (const KFileItem
& item
: list
) {
470 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
471 if (!url
.isEmpty()) {
477 // if no new tab has been created from the selection
478 // open the current directory in a new tab
480 openNewTab(m_activeViewContainer
->url());
484 void DolphinMainWindow::openInNewWindow()
488 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
489 if (list
.isEmpty()) {
490 newWindowUrl
= m_activeViewContainer
->url();
491 } else if (list
.count() == 1) {
492 const KFileItem
& item
= list
.first();
493 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
496 if (!newWindowUrl
.isEmpty()) {
497 Dolphin::openNewWindow({newWindowUrl
}, this);
501 void DolphinMainWindow::showTarget()
503 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
504 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
505 auto linkDestination
= link
.linkDest();
506 if (QFileInfo(linkDestination
).isRelative()) {
507 linkDestination
= linkLocationDir
.filePath(linkDestination
);
509 if (QFileInfo::exists(linkDestination
)) {
510 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
512 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
513 DolphinViewContainer::Warning
);
517 void DolphinMainWindow::showEvent(QShowEvent
* event
)
519 KXmlGuiWindow::showEvent(event
);
521 if (!event
->spontaneous()) {
522 m_activeViewContainer
->view()->setFocus();
526 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
528 // Find out if Dolphin is closed directly by the user or
529 // by the session manager because the session is closed
530 bool closedByUser
= true;
531 if (qApp
->isSavingSession()) {
532 closedByUser
= false;
535 if (m_tabWidget
->count() > 1
536 && GeneralSettings::confirmClosingMultipleTabs()
537 && !GeneralSettings::rememberOpenedTabs()
539 // Ask the user if he really wants to quit and close all tabs.
540 // Open a confirmation dialog with 3 buttons:
541 // QDialogButtonBox::Yes -> Quit
542 // QDialogButtonBox::No -> Close only the current tab
543 // QDialogButtonBox::Cancel -> do nothing
544 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
545 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
546 dialog
->setModal(true);
547 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
548 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
549 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
550 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
551 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
553 bool doNotAskAgainCheckboxResult
= false;
555 const auto result
= KMessageBox::createKMessageBox(dialog
,
557 QMessageBox::Warning
,
558 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
560 i18n("Do not ask again"),
561 &doNotAskAgainCheckboxResult
,
562 KMessageBox::Notify
);
564 if (doNotAskAgainCheckboxResult
) {
565 GeneralSettings::setConfirmClosingMultipleTabs(false);
569 case QDialogButtonBox::Yes
:
572 case QDialogButtonBox::No
:
573 // Close only the current tab
574 m_tabWidget
->closeTab();
582 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
583 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
584 // Open a confirmation dialog with 3 buttons:
585 // QDialogButtonBox::Yes -> Quit
586 // QDialogButtonBox::No -> Show Terminal Panel
587 // QDialogButtonBox::Cancel -> do nothing
588 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
589 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
590 dialog
->setModal(true);
591 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
592 if (!m_terminalPanel
->isVisible()) {
593 standardButtons
|= QDialogButtonBox::No
;
595 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
596 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
597 if (!m_terminalPanel
->isVisible()) {
599 buttons
->button(QDialogButtonBox::No
),
600 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
602 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
604 bool doNotAskAgainCheckboxResult
= false;
606 const auto result
= KMessageBox::createKMessageBox(
609 QMessageBox::Warning
,
610 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
612 i18n("Do not ask again"),
613 &doNotAskAgainCheckboxResult
,
614 KMessageBox::Dangerous
);
616 if (doNotAskAgainCheckboxResult
) {
617 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
621 case QDialogButtonBox::Yes
:
624 case QDialogButtonBox::No
:
625 actionCollection()->action("show_terminal_panel")->trigger();
626 // Do not quit, ignore quit event
634 if (GeneralSettings::rememberOpenedTabs()) {
635 KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin"));
636 KConfig
*config
= KConfigGui::sessionConfig();
637 saveGlobalProperties(config
);
638 savePropertiesInternal(config
, 1);
642 GeneralSettings::setVersion(CurrentDolphinVersion
);
643 GeneralSettings::self()->save();
645 KXmlGuiWindow::closeEvent(event
);
648 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
650 m_tabWidget
->saveProperties(group
);
653 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
655 m_tabWidget
->readProperties(group
);
658 void DolphinMainWindow::updateNewMenu()
660 m_newFileMenu
->checkUpToDate();
661 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << activeViewContainer()->url());
664 void DolphinMainWindow::createDirectory()
666 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << activeViewContainer()->url());
667 m_newFileMenu
->createDirectory();
670 void DolphinMainWindow::quit()
675 void DolphinMainWindow::showErrorMessage(const QString
& message
)
677 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
680 void DolphinMainWindow::slotUndoAvailable(bool available
)
682 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
684 undoAction
->setEnabled(available
);
688 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
690 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
692 undoAction
->setText(text
);
696 void DolphinMainWindow::undo()
699 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
700 KIO::FileUndoManager::self()->undo();
703 void DolphinMainWindow::cut()
705 m_activeViewContainer
->view()->cutSelectedItemsToClipboard();
708 void DolphinMainWindow::copy()
710 m_activeViewContainer
->view()->copySelectedItemsToClipboard();
713 void DolphinMainWindow::paste()
715 m_activeViewContainer
->view()->paste();
718 void DolphinMainWindow::find()
720 m_activeViewContainer
->setSearchModeEnabled(true);
723 void DolphinMainWindow::updateSearchAction()
725 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
726 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
729 void DolphinMainWindow::updatePasteAction()
731 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
732 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
733 pasteAction
->setEnabled(pasteInfo
.first
);
734 pasteAction
->setText(pasteInfo
.second
);
737 void DolphinMainWindow::slotDirectoryLoadingCompleted()
742 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
744 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
746 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
748 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
750 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
755 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
757 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
759 m_backAction
->menu()->clear();
760 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
761 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_backAction
->menu());
763 m_backAction
->menu()->addAction(action
);
767 void DolphinMainWindow::slotGoBack(QAction
* action
)
769 int gotoIndex
= action
->data().value
<int>();
770 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
771 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
776 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
779 const KUrlNavigator
*urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
780 openNewTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
784 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
786 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
788 m_forwardAction
->menu()->clear();
789 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
790 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
792 m_forwardAction
->menu()->addAction(action
);
796 void DolphinMainWindow::slotGoForward(QAction
* action
)
798 int gotoIndex
= action
->data().value
<int>();
799 const KUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
800 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
805 void DolphinMainWindow::selectAll()
809 // if the URL navigator is editable and focused, select the whole
810 // URL instead of all items of the view
812 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
813 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
814 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
815 lineEdit
->hasFocus();
817 lineEdit
->selectAll();
819 m_activeViewContainer
->view()->selectAll();
823 void DolphinMainWindow::invertSelection()
826 m_activeViewContainer
->view()->invertSelection();
829 void DolphinMainWindow::toggleSplitView()
831 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
832 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled(), WithAnimation
);
837 void DolphinMainWindow::toggleSplitStash()
839 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
840 tabPage
->setSplitViewEnabled(false, WithAnimation
);
841 tabPage
->setSplitViewEnabled(true, WithAnimation
, QUrl("stash:/"));
844 void DolphinMainWindow::reloadView()
847 m_activeViewContainer
->reload();
848 m_activeViewContainer
->statusBar()->updateSpaceInfo();
851 void DolphinMainWindow::stopLoading()
853 m_activeViewContainer
->view()->stopLoading();
856 void DolphinMainWindow::enableStopAction()
858 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
861 void DolphinMainWindow::disableStopAction()
863 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
866 void DolphinMainWindow::showFilterBar()
868 m_activeViewContainer
->setFilterBarVisible(true);
871 void DolphinMainWindow::toggleFilterBar()
873 const bool checked
= !m_activeViewContainer
->isFilterBarVisible();
874 m_activeViewContainer
->setFilterBarVisible(checked
);
876 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
877 toggleFilterBarAction
->setChecked(checked
);
880 void DolphinMainWindow::toggleEditLocation()
884 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
885 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
886 urlNavigator
->setUrlEditable(action
->isChecked());
889 void DolphinMainWindow::replaceLocation()
891 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
892 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
894 // If the text field currently has focus and everything is selected,
895 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
896 if (navigator
->isUrlEditable()
897 && lineEdit
->hasFocus()
898 && lineEdit
->selectedText() == lineEdit
->text() ) {
899 navigator
->setUrlEditable(false);
901 navigator
->setUrlEditable(true);
902 navigator
->setFocus();
903 lineEdit
->selectAll();
907 void DolphinMainWindow::togglePanelLockState()
909 const bool newLockState
= !GeneralSettings::lockPanels();
910 const auto childrenObjects
= children();
911 for (QObject
* child
: childrenObjects
) {
912 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
914 dock
->setLocked(newLockState
);
918 GeneralSettings::setLockPanels(newLockState
);
921 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
923 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
924 m_activeViewContainer
->view()->setFocus();
928 void DolphinMainWindow::goBack()
930 DolphinUrlNavigator
*urlNavigator
= m_activeViewContainer
->urlNavigatorInternalWithHistory();
931 urlNavigator
->goBack();
933 if (urlNavigator
->locationState().isEmpty()) {
934 // An empty location state indicates a redirection URL,
935 // which must be skipped too
936 urlNavigator
->goBack();
940 void DolphinMainWindow::goForward()
942 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goForward();
945 void DolphinMainWindow::goUp()
947 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goUp();
950 void DolphinMainWindow::goHome()
952 m_activeViewContainer
->urlNavigatorInternalWithHistory()->goHome();
955 void DolphinMainWindow::goBackInNewTab()
957 const KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
958 const int index
= urlNavigator
->historyIndex() + 1;
959 openNewTab(urlNavigator
->locationUrl(index
));
962 void DolphinMainWindow::goForwardInNewTab()
964 const KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigatorInternalWithHistory();
965 const int index
= urlNavigator
->historyIndex() - 1;
966 openNewTab(urlNavigator
->locationUrl(index
));
969 void DolphinMainWindow::goUpInNewTab()
971 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
972 openNewTab(KIO::upUrl(currentUrl
));
975 void DolphinMainWindow::goHomeInNewTab()
977 openNewTab(Dolphin::homeUrl());
980 void DolphinMainWindow::compareFiles()
982 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
983 if (items
.count() != 2) {
984 // The action is disabled in this case, but it could have been triggered
985 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
989 QUrl urlA
= items
.at(0).url();
990 QUrl urlB
= items
.at(1).url();
992 QString
command(QStringLiteral("kompare -c \""));
993 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
994 command
.append("\" \"");
995 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
996 command
.append('\"');
998 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(command
, this);
999 job
->setDesktopName(QStringLiteral("org.kde.kompare"));
1003 void DolphinMainWindow::toggleShowMenuBar()
1005 const bool visible
= menuBar()->isVisible();
1006 menuBar()->setVisible(!visible
);
1009 QPointer
<QAction
> DolphinMainWindow::preferredSearchTool()
1011 m_searchTools
.clear();
1012 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
1013 &m_searchTools
, { "files-find" }, m_activeViewContainer
->url()
1015 QList
<QAction
*> actions
= m_searchTools
.actions();
1016 if (actions
.isEmpty()) {
1019 QAction
* action
= actions
.first();
1020 if (action
->isSeparator()) {
1026 void DolphinMainWindow::updateOpenPreferredSearchToolAction()
1028 QAction
* openPreferredSearchTool
= actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
1029 if (!openPreferredSearchTool
) {
1032 QPointer
<QAction
> tool
= preferredSearchTool();
1034 openPreferredSearchTool
->setVisible(true);
1035 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open %1", tool
->text()));
1036 // Only override with the app icon if it is the default, i.e. the user hasn't configured one manually
1037 // https://bugs.kde.org/show_bug.cgi?id=442815
1038 if (openPreferredSearchTool
->icon().name() == QLatin1String("search")) {
1039 openPreferredSearchTool
->setIcon(tool
->icon());
1042 openPreferredSearchTool
->setVisible(false);
1043 // still visible in Shortcuts configuration window
1044 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1045 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1049 void DolphinMainWindow::openPreferredSearchTool()
1051 QPointer
<QAction
> tool
= preferredSearchTool();
1057 void DolphinMainWindow::openTerminal()
1059 const QUrl url
= m_activeViewContainer
->url();
1061 if (url
.isLocalFile()) {
1062 auto job
= new KTerminalLauncherJob(QString());
1063 job
->setWorkingDirectory(url
.toLocalFile());
1068 // Not a local file, with protocol Class ":local", try stat'ing
1069 if (KProtocolInfo::protocolClass(url
.scheme()) == QLatin1String(":local")) {
1070 KIO::StatJob
*job
= KIO::mostLocalUrl(url
);
1071 KJobWidgets::setWindow(job
, this);
1072 connect(job
, &KJob::result
, this, [job
]() {
1074 if (!job
->error()) {
1075 statUrl
= job
->mostLocalUrl();
1078 auto job
= new KTerminalLauncherJob(QString());
1079 job
->setWorkingDirectory(statUrl
.isLocalFile() ? statUrl
.toLocalFile() : QDir::homePath());
1086 // Nothing worked, just use $HOME
1087 auto job
= new KTerminalLauncherJob(QString());
1088 job
->setWorkingDirectory(QDir::homePath());
1092 void DolphinMainWindow::editSettings()
1094 if (!m_settingsDialog
) {
1095 DolphinViewContainer
* container
= activeViewContainer();
1096 container
->view()->writeSettings();
1098 const QUrl url
= container
->url();
1099 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this, actionCollection());
1100 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
1101 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
,
1102 &DolphinUrlNavigatorsController::slotReadSettings
);
1103 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
1104 settingsDialog
->show();
1105 m_settingsDialog
= settingsDialog
;
1107 m_settingsDialog
.data()->raise();
1111 void DolphinMainWindow::handleUrl(const QUrl
& url
)
1113 delete m_lastHandleUrlOpenJob
;
1114 m_lastHandleUrlOpenJob
= nullptr;
1116 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
1117 activeViewContainer()->setUrl(url
);
1119 m_lastHandleUrlOpenJob
= new KIO::OpenUrlJob(url
);
1120 m_lastHandleUrlOpenJob
->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, this));
1121 m_lastHandleUrlOpenJob
->setShowOpenOrExecuteDialog(true);
1123 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::mimeTypeFound
, this,
1124 [this, url
](const QString
&mimetype
) {
1125 if (mimetype
== QLatin1String("inode/directory")) {
1126 // If it's a dir, we'll take it from here
1127 m_lastHandleUrlOpenJob
->kill();
1128 m_lastHandleUrlOpenJob
= nullptr;
1129 activeViewContainer()->setUrl(url
);
1133 connect(m_lastHandleUrlOpenJob
, &KIO::OpenUrlJob::result
, this, [this]() {
1134 m_lastHandleUrlOpenJob
= nullptr;
1137 m_lastHandleUrlOpenJob
->start();
1141 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1143 // trash:/ is writable but we don't want to create new items in it.
1144 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1145 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1148 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1149 const KFileItem
& item
,
1151 const QList
<QAction
*>& customActions
)
1153 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
, &m_fileItemActions
);
1154 contextMenu
.data()->setCustomActions(customActions
);
1155 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1158 case DolphinContextMenu::OpenParentFolder
:
1159 changeUrl(KIO::upUrl(item
.url()));
1160 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1161 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1164 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1165 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1168 case DolphinContextMenu::OpenParentFolderInNewTab
:
1169 openNewTab(KIO::upUrl(item
.url()));
1172 case DolphinContextMenu::None
:
1177 // Delete the menu, unless it has been deleted in its own nested event loop already.
1179 contextMenu
->deleteLater();
1183 void DolphinMainWindow::updateHamburgerMenu()
1185 KActionCollection
* ac
= actionCollection();
1186 auto hamburgerMenu
= static_cast<KHamburgerMenu
*>(
1187 ac
->action(KStandardAction::name(KStandardAction::HamburgerMenu
)));
1188 auto menu
= hamburgerMenu
->menu();
1190 menu
= new QMenu(this);
1191 hamburgerMenu
->setMenu(menu
);
1192 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("basic_actions"))->menu());
1193 hamburgerMenu
->hideActionsOf(ac
->action(QStringLiteral("zoom"))->menu());
1197 const QList
<QAction
*> toolbarActions
= toolBar()->actions();
1199 if (!toolBar()->isVisible()) {
1200 // If neither the menu bar nor the toolbar are visible, these actions should be available.
1201 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)));
1202 menu
->addAction(toolBarMenuAction());
1203 menu
->addSeparator();
1206 // This group of actions (until the next separator) contains all the most basic actions
1207 // necessary to use Dolphin effectively.
1208 menu
->addAction(ac
->action(QStringLiteral("go_back")));
1209 menu
->addAction(ac
->action(QStringLiteral("go_forward")));
1211 menu
->addMenu(m_newFileMenu
->menu());
1212 menu
->addAction(ac
->action(QStringLiteral("basic_actions")));
1213 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Undo
)));
1214 if (!toolBar()->isVisible()
1215 || (!toolbarActions
.contains(ac
->action(QStringLiteral("toggle_search")))
1216 && !toolbarActions
.contains(ac
->action(QStringLiteral("open_preferred_search_tool"))))
1218 menu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Find
)));
1219 // This way a search action will only be added if none of the three available
1220 // search actions is present on the toolbar.
1222 if (!toolBar()->isVisible()
1223 || !toolbarActions
.contains(ac
->action(QStringLiteral("toggle_filter")))
1225 menu
->addAction(ac
->action(QStringLiteral("show_filter_bar")));
1226 // This way a filter action will only be added if none of the two available
1227 // filter actions is present on the toolbar.
1229 menu
->addSeparator();
1231 // The second group of actions (up until the next separator) contains actions for opening
1232 // additional views to interact with the file system.
1233 menu
->addAction(ac
->action(QStringLiteral("file_new")));
1234 menu
->addAction(ac
->action(QStringLiteral("new_tab")));
1235 if (ac
->action(QStringLiteral("undo_close_tab"))->isEnabled()) {
1236 menu
->addAction(ac
->action(QStringLiteral("closed_tabs")));
1238 menu
->addAction(ac
->action(QStringLiteral("open_terminal")));
1239 menu
->addSeparator();
1241 // The third group contains actions to change what one sees in the view
1242 // and to change the more general UI.
1243 if (!toolBar()->isVisible()
1244 || (!toolbarActions
.contains(ac
->action(QStringLiteral("icons")))
1245 && !toolbarActions
.contains(ac
->action(QStringLiteral("compact")))
1246 && !toolbarActions
.contains(ac
->action(QStringLiteral("details")))
1247 && !toolbarActions
.contains(ac
->action(QStringLiteral("view_mode"))))
1249 menu
->addAction(ac
->action(QStringLiteral("view_mode")));
1251 menu
->addAction(ac
->action(QStringLiteral("show_hidden_files")));
1252 menu
->addAction(ac
->action(QStringLiteral("sort")));
1253 menu
->addAction(ac
->action(QStringLiteral("additional_info")));
1254 if (!GeneralSettings::showStatusBar() || !GeneralSettings::showZoomSlider()) {
1255 menu
->addAction(ac
->action(QStringLiteral("zoom")));
1257 menu
->addAction(ac
->action(QStringLiteral("panels")));
1259 // The "Configure" menu is not added to the actionCollection() because there is hardly
1260 // a good reason for users to put it on their toolbar.
1261 auto configureMenu
= menu
->addMenu(QIcon::fromTheme(QStringLiteral("configure")),
1262 i18nc("@action:inmenu menu for configure actions", "Configure"));
1263 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
)));
1264 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)));
1265 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)));
1266 configureMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Preferences
)));
1267 hamburgerMenu
->hideActionsOf(configureMenu
);
1270 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1272 DolphinViewContainer
* view
= activeViewContainer();
1274 if (view
->url() == url
) {
1275 // We can end up here if the user clicked a device in the Places Panel
1276 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1279 view
->disableUrlNavigatorSelectionRequests();
1281 view
->enableUrlNavigatorSelectionRequests();
1285 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1287 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1290 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1292 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1293 Q_ASSERT(viewContainer
);
1295 m_activeViewContainer
= viewContainer
;
1297 if (oldViewContainer
) {
1298 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1299 toggleSearchAction
->disconnect(oldViewContainer
);
1301 // Disconnect all signals between the old view container (container,
1302 // view and url navigator) and main window.
1303 oldViewContainer
->disconnect(this);
1304 oldViewContainer
->view()->disconnect(this);
1305 oldViewContainer
->urlNavigatorInternalWithHistory()->disconnect(this);
1306 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
1307 (actionCollection()->action(QStringLiteral("url_navigators")));
1308 navigators
->primaryUrlNavigator()->disconnect(this);
1309 if (auto secondaryUrlNavigator
= navigators
->secondaryUrlNavigator()) {
1310 secondaryUrlNavigator
->disconnect(this);
1313 // except the requestItemInfo so that on hover the information panel can still be updated
1314 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1315 this, &DolphinMainWindow::requestItemInfo
);
1318 connectViewSignals(viewContainer
);
1320 m_actionHandler
->setCurrentView(viewContainer
->view());
1323 updateFileAndEditActions();
1324 updatePasteAction();
1325 updateViewActions();
1327 updateSearchAction();
1329 const QUrl url
= viewContainer
->url();
1330 Q_EMIT
urlChanged(url
);
1333 void DolphinMainWindow::tabCountChanged(int count
)
1335 const bool enableTabActions
= (count
> 1);
1336 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1337 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1339 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1340 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1341 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1344 void DolphinMainWindow::updateWindowTitle()
1346 const QString newTitle
= m_activeViewContainer
->captionWindowTitle();
1347 if (windowTitle() != newTitle
) {
1348 setWindowTitle(newTitle
);
1352 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1354 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1355 setViewsToHomeIfMountPathOpen(mountPath
);
1358 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1359 m_tearDownFromPlacesRequested
= true;
1360 m_terminalPanel
->goHome();
1361 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1363 m_placesPanel
->proceedWithTearDown();
1367 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1369 connect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, this, [this, mountPath
]() {
1370 setViewsToHomeIfMountPathOpen(mountPath
);
1373 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1374 m_tearDownFromPlacesRequested
= false;
1375 m_terminalPanel
->goHome();
1379 void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString
& mountPath
)
1381 const QVector
<DolphinViewContainer
*> theViewContainers
= viewContainers();
1382 for (DolphinViewContainer
*viewContainer
: theViewContainers
) {
1383 if (viewContainer
&& viewContainer
->url().toLocalFile().startsWith(mountPath
)) {
1384 viewContainer
->setUrl(QUrl::fromLocalFile(QDir::homePath()));
1387 disconnect(m_placesPanel
, &PlacesPanel::storageTearDownSuccessful
, nullptr, nullptr);
1390 void DolphinMainWindow::setupActions()
1392 KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
1394 // setup 'File' menu
1395 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1396 QMenu
* menu
= m_newFileMenu
->menu();
1397 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1398 menu
->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
1399 m_newFileMenu
->setPopupMode(QToolButton::InstantPopup
);
1400 connect(menu
, &QMenu::aboutToShow
,
1401 this, &DolphinMainWindow::updateNewMenu
);
1403 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1404 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1405 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1406 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1407 "window just like this one with the current location and view."
1408 "<nl/>You can drag and drop items between windows."));
1409 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1411 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1412 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1413 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1414 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1415 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1416 "A tab is an additional view within this window. "
1417 "You can drag and drop items between tabs."));
1418 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
| Qt::Key_T
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_N
});
1419 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1421 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1422 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1423 addToPlaces
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1424 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1425 "to the Places panel."));
1426 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1428 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1429 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1430 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1431 "currently viewed tab. If no more tabs are left this window "
1432 "will close instead."));
1434 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1435 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1437 // setup 'Edit' menu
1438 KStandardAction::undo(this,
1439 &DolphinMainWindow::undo
,
1440 actionCollection());
1442 // i18n: This will be the last paragraph for the whatsthis for all three:
1443 // Cut, Copy and Paste
1444 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1445 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1446 "applications and are among the most used commands. That's why their "
1447 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1448 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1449 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1450 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1451 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1452 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1453 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1454 "the clipboard to a new location. The items will be removed from their "
1455 "initial location.") + cutCopyPastePara
);
1456 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1457 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1458 "items in your current selection to the <emphasis>clipboard</emphasis>."
1459 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1460 "from the clipboard to a new location.") + cutCopyPastePara
);
1461 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1462 // The text of the paste-action is modified dynamically by Dolphin
1463 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1464 // due to the long text, the text "Paste" is used:
1465 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1466 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1467 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1468 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1469 "action they are removed from their old location.") + cutCopyPastePara
);
1471 QAction
* copyToOtherViewAction
= actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
1472 copyToOtherViewAction
->setText(i18nc("@action:inmenu", "Copy to Inactive Split View"));
1473 copyToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from "
1474 "the <emphasis>active</emphasis> view to the inactive split view."));
1475 copyToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
1476 copyToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Copy to Inactive Split View"));
1477 actionCollection()->setDefaultShortcut(copyToOtherViewAction
, Qt::SHIFT
| Qt::Key_F5
);
1478 connect(copyToOtherViewAction
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::copyToInactiveSplitView
);
1480 QAction
* moveToOtherViewAction
= actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
1481 moveToOtherViewAction
->setText(i18nc("@action:inmenu", "Move to Inactive Split View"));
1482 moveToOtherViewAction
->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from "
1483 "the <emphasis>active</emphasis> view to the inactive split view."));
1484 moveToOtherViewAction
->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
1485 moveToOtherViewAction
->setIconText(i18nc("@action:inmenu Edit", "Move to Inactive Split View"));
1486 actionCollection()->setDefaultShortcut(moveToOtherViewAction
, Qt::SHIFT
| Qt::Key_F6
);
1487 connect(moveToOtherViewAction
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::moveToInactiveSplitView
);
1489 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1490 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Filter..."));
1491 showFilterBar
->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
1492 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1493 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1494 "There you can enter a text to filter the files and folders currently displayed. "
1495 "Only those that contain the text in their name will be kept in view."));
1496 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1497 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
| Qt::Key_I
, Qt::Key_Slash
});
1498 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1500 // toggle_filter acts as a copy of the main showFilterBar to be used mainly
1501 // in the toolbar, with no default shortcut attached, to avoid messing with
1502 // existing workflows (filter bar always open and Ctrl-I to focus)
1503 QAction
*toggleFilter
= actionCollection()->addAction(QStringLiteral("toggle_filter"));
1504 toggleFilter
->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
1505 toggleFilter
->setIconText(i18nc("@action:intoolbar", "Filter"));
1506 toggleFilter
->setIcon(showFilterBar
->icon());
1507 toggleFilter
->setToolTip(showFilterBar
->toolTip());
1508 toggleFilter
->setWhatsThis(showFilterBar
->whatsThis());
1509 toggleFilter
->setCheckable(true);
1510 connect(toggleFilter
, &QAction::triggered
, this, &DolphinMainWindow::toggleFilterBar
);
1512 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1513 searchAction
->setText(i18n("Search..."));
1514 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1515 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1516 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1517 "There you can enter search terms and specify settings to find the "
1518 "objects you are looking for.</para><para>Use this help again on "
1519 "the find bar so we can have a look at it while the settings are "
1520 "explained.</para>"));
1522 // toggle_search acts as a copy of the main searchAction to be used mainly
1523 // in the toolbar, with no default shortcut attached, to avoid messing with
1524 // existing workflows (search bar always open and Ctrl-F to focus)
1525 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1526 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1527 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1528 toggleSearchAction
->setIcon(searchAction
->icon());
1529 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1530 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1531 toggleSearchAction
->setCheckable(true);
1533 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1534 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1535 "files and folders in the current location."));
1537 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1538 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1539 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1540 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1541 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1542 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1543 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1545 // setup 'View' menu
1546 // (note that most of it is set up in DolphinViewActionHandler)
1548 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1549 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1550 "the folder view below into two autonomous views.</para><para>This "
1551 "way you can see two locations at once and move items between them "
1552 "quickly.</para>Click this again afterwards to recombine the views."));
1553 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1554 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1556 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1557 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
| Qt::Key_S
);
1558 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1559 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1560 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1561 stashSplit
->setCheckable(false);
1562 QDBusConnectionInterface
*sessionInterface
= QDBusConnection::sessionBus().interface();
1563 stashSplit
->setVisible(sessionInterface
&& sessionInterface
->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
1564 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1566 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1568 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1569 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1570 stop
->setToolTip(i18nc("@info", "Stop loading"));
1571 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1572 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1573 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1575 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1576 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1577 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1578 "This toggles the <emphasis>Location Bar</emphasis> to be "
1579 "editable so you can directly enter a location you want to go to.<nl/>"
1580 "You can also switch to editing by clicking to the right of the "
1581 "location and switch back by confirming the edited location."));
1582 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1583 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1585 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1586 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1587 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1588 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1589 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1590 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1591 "This switches to editing the location and selects it "
1592 "so you can quickly enter a different location."));
1593 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
| Qt::Key_L
);
1594 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1598 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1599 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1600 m_backAction
->setObjectName(backAction
->objectName());
1601 m_backAction
->setShortcuts(backAction
->shortcuts());
1603 m_backAction
->setPopupMode(QToolButton::DelayedPopup
);
1604 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1605 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1606 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1607 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1609 auto backShortcuts
= m_backAction
->shortcuts();
1610 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1611 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1613 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1614 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1615 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1616 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1617 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1618 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1619 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1620 this, &DolphinMainWindow::closedTabsCountChanged
);
1622 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1623 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1624 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1625 "This returns you to the previously closed tab."));
1626 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_T
);
1627 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1628 undoCloseTab
->setEnabled(false);
1629 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1631 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1632 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1633 "the last change you made to files or folders.<nl/>"
1634 "Such changes include <interface>creating, renaming</interface> "
1635 "and <interface>moving</interface> them to a different location "
1636 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1637 "be undone will ask for your confirmation."));
1638 undoAction
->setEnabled(false); // undo should be disabled by default
1641 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1642 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1643 m_forwardAction
->setObjectName(forwardAction
->objectName());
1644 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1646 m_forwardAction
->setPopupMode(QToolButton::DelayedPopup
);
1647 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1648 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1649 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1650 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1651 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1653 // enable middle-click to open in a new tab
1654 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1655 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1656 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1657 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1658 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1659 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1660 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1661 "<filename>Home</filename> folder.<nl/>Every user account "
1662 "has their own <filename>Home</filename> that contains their data "
1663 "including folders that contain personal application data."));
1665 // setup 'Tools' menu
1666 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1667 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1668 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1669 compareFiles
->setEnabled(false);
1670 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1672 QAction
* openPreferredSearchTool
= actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
1673 openPreferredSearchTool
->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
1674 openPreferredSearchTool
->setWhatsThis(xi18nc("@info:whatsthis",
1675 "<para>This opens a preferred search tool for the viewed location.</para>"
1676 "<para>Use <emphasis>More Search Tools</emphasis> menu to configure it.</para>"));
1677 openPreferredSearchTool
->setIcon(QIcon::fromTheme(QStringLiteral("search")));
1678 actionCollection()->setDefaultShortcut(openPreferredSearchTool
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F
);
1679 connect(openPreferredSearchTool
, &QAction::triggered
, this, &DolphinMainWindow::openPreferredSearchTool
);
1681 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1682 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1683 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1684 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1685 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1686 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1687 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
1688 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
| Qt::Key_F4
);
1689 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1691 #ifdef HAVE_TERMINAL
1692 QAction
* focusTerminalPanel
= actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
1693 focusTerminalPanel
->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
1694 focusTerminalPanel
->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
1695 actionCollection()->setDefaultShortcut(focusTerminalPanel
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_F4
);
1696 connect(focusTerminalPanel
, &QAction::triggered
, this, &DolphinMainWindow::focusTerminalPanel
);
1700 // setup 'Bookmarks' menu
1701 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1702 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1703 // Make the toolbar button version work properly on click
1704 bookmarkMenu
->setPopupMode(QToolButton::InstantPopup
);
1705 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1706 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1708 // setup 'Settings' menu
1709 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1710 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1711 "This switches between having a <emphasis>Menubar</emphasis> "
1712 "and having a <interface>Control</interface> button. Both "
1713 "contain mostly the same commands and configuration options."));
1714 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1715 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1716 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1718 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1719 m_helpMenu
= new KHelpMenu(nullptr);
1720 m_helpMenu
->menu()->installEventFilter(this);
1721 // remove duplicate shortcuts
1722 auto removeHelpActionShortcut
= [this](KHelpMenu::MenuId menuId
) {
1723 if (auto *action
= m_helpMenu
->action(menuId
)) {
1724 action
->setShortcut(QKeySequence());
1727 removeHelpActionShortcut(KHelpMenu::menuHelpContents
);
1728 removeHelpActionShortcut(KHelpMenu::menuWhatsThis
);
1730 // not in menu actions
1731 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1732 nextTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::Key_Tab
));
1734 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1735 prevTabKeys
.append(QKeySequence(Qt::CTRL
| Qt::SHIFT
| Qt::Key_Tab
));
1737 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1738 QAction
* activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
1739 activateTab
->setText(i18nc("@action:inmenu", "Activate Tab %1", i
+ 1));
1740 activateTab
->setEnabled(false);
1741 connect(activateTab
, &QAction::triggered
, this, [this, i
]() { m_tabWidget
->activateTab(i
); });
1743 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
1745 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
1749 QAction
* activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
1750 activateLastTab
->setText(i18nc("@action:inmenu", "Activate Last Tab"));
1751 activateLastTab
->setEnabled(false);
1752 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
1753 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
| Qt::Key_0
);
1755 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1756 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1757 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1758 activateNextTab
->setEnabled(false);
1759 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1760 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1762 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1763 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1764 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1765 activatePrevTab
->setEnabled(false);
1766 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1767 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1770 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1771 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1772 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1773 showTarget
->setEnabled(false);
1774 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1776 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1777 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1778 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1779 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1781 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1782 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1783 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1784 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1786 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1787 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1788 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1789 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1792 void DolphinMainWindow::setupDockWidgets()
1794 const bool lock
= GeneralSettings::lockPanels();
1796 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1797 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1798 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1799 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1800 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1801 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1802 "switches between having panels <emphasis>locked</emphasis> or "
1803 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1804 "dragged to the other side of the window and have a close "
1805 "button.<nl/>Locked panels are embedded more cleanly."));
1806 lockLayoutAction
->setActive(lock
);
1807 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1809 // Setup "Information"
1810 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1811 infoDock
->setLocked(lock
);
1812 infoDock
->setObjectName(QStringLiteral("infoDock"));
1813 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1816 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1817 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1818 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1819 infoDock
->setWidget(infoPanel
);
1821 QAction
* infoAction
= infoDock
->toggleViewAction();
1822 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1824 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1825 connect(this, &DolphinMainWindow::urlChanged
,
1826 infoPanel
, &InformationPanel::setUrl
);
1827 connect(this, &DolphinMainWindow::selectionChanged
,
1828 infoPanel
, &InformationPanel::setSelection
);
1829 connect(this, &DolphinMainWindow::requestItemInfo
,
1830 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1831 connect(this, &DolphinMainWindow::fileItemsChanged
,
1832 infoPanel
, &InformationPanel::slotFilesItemChanged
);
1835 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1836 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1837 "hide panels like this go to <interface>Control|Panels</interface> "
1838 "or <interface>View|Panels</interface>.</para>");
1840 actionCollection()->action(QStringLiteral("show_information_panel"))
1841 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1842 "<emphasis>information</emphasis> panel at the right side of the "
1843 "window.</para><para>The panel provides in-depth information "
1844 "about the items your mouse is hovering over or about the selected "
1845 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1846 "For single items a preview of their contents is provided.</para>"));
1848 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1849 "provides in-depth information about the items your mouse is "
1850 "hovering over or about the selected items. Otherwise it informs "
1851 "you about the currently viewed folder.<nl/>For single items a "
1852 "preview of their contents is provided.</para><para>You can configure "
1853 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1856 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1857 foldersDock
->setLocked(lock
);
1858 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1859 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1860 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1861 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1862 foldersDock
->setWidget(foldersPanel
);
1864 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1865 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1867 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1868 connect(this, &DolphinMainWindow::urlChanged
,
1869 foldersPanel
, &FoldersPanel::setUrl
);
1870 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1871 this, &DolphinMainWindow::changeUrl
);
1872 connect(foldersPanel
, &FoldersPanel::folderInNewTab
,
1873 this, &DolphinMainWindow::openNewTab
);
1874 connect(foldersPanel
, &FoldersPanel::folderInNewActiveTab
,
1875 this, &DolphinMainWindow::openNewTabAndActivate
);
1876 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1877 this, &DolphinMainWindow::showErrorMessage
);
1879 actionCollection()->action(QStringLiteral("show_folders_panel"))
1880 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1881 "<emphasis>folders</emphasis> panel at the left side of the window."
1882 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1883 "</emphasis> in a <emphasis>tree view</emphasis>."));
1884 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1885 "shows the folders of the <emphasis>file system</emphasis> in a "
1886 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1887 "there. Click the arrow to the left of a folder to see its subfolders. "
1888 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1891 #ifdef HAVE_TERMINAL
1892 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1893 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1894 terminalDock
->setLocked(lock
);
1895 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1896 m_terminalPanel
= new TerminalPanel(terminalDock
);
1897 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1898 terminalDock
->setWidget(m_terminalPanel
);
1900 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1901 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1902 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1903 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1904 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1905 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1907 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1908 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1910 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1911 connect(this, &DolphinMainWindow::urlChanged
,
1912 m_terminalPanel
, &TerminalPanel::setUrl
);
1914 if (GeneralSettings::version() < 200) {
1915 terminalDock
->hide();
1918 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1919 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1920 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1921 "<nl/>The location in the terminal will always match the folder "
1922 "view so you can navigate using either.</para><para>The terminal "
1923 "panel is not needed for basic computer usage but can be useful "
1924 "for advanced tasks. To learn more about terminals use the help "
1925 "in a standalone terminal application like Konsole.</para>"));
1926 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1927 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1928 "normal terminal but will match the location of the folder view "
1929 "so you can navigate using either.</para><para>The terminal panel "
1930 "is not needed for basic computer usage but can be useful for "
1931 "advanced tasks. To learn more about terminals use the help in a "
1932 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1936 if (GeneralSettings::version() < 200) {
1938 foldersDock
->hide();
1942 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1943 placesDock
->setLocked(lock
);
1944 placesDock
->setObjectName(QStringLiteral("placesDock"));
1945 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1947 m_placesPanel
= new PlacesPanel(placesDock
);
1948 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1949 placesDock
->setWidget(m_placesPanel
);
1951 QAction
*placesAction
= placesDock
->toggleViewAction();
1952 createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1954 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1955 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1956 this, &DolphinMainWindow::slotPlaceActivated
);
1957 connect(m_placesPanel
, &PlacesPanel::placeActivatedInNewTab
,
1958 this, &DolphinMainWindow::openNewTab
);
1959 connect(m_placesPanel
, &PlacesPanel::placeActivatedInNewActiveTab
,
1960 this, &DolphinMainWindow::openNewTabAndActivate
);
1961 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1962 this, &DolphinMainWindow::showErrorMessage
);
1963 connect(this, &DolphinMainWindow::urlChanged
,
1964 m_placesPanel
, &PlacesPanel::setUrl
);
1965 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1966 &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged
);
1967 connect(this, &DolphinMainWindow::settingsChanged
,
1968 m_placesPanel
, &PlacesPanel::readSettings
);
1969 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1970 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1971 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1972 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1973 DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1975 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1976 actionShowAllPlaces
->setCheckable(true);
1977 actionShowAllPlaces
->setDisabled(true);
1978 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1979 "all places in the places panel that have been hidden. They will "
1980 "appear semi-transparent unless you uncheck their hide property."));
1982 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1983 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1984 m_placesPanel
->showHiddenEntries(checked
);
1987 connect(m_placesPanel
, &PlacesPanel::showHiddenEntriesChanged
, this, [actionShowAllPlaces
] (bool checked
){
1988 actionShowAllPlaces
->setChecked(checked
);
1989 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1992 actionCollection()->action(QStringLiteral("show_places_panel"))
1993 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1994 "<emphasis>places</emphasis> panel at the left side of the window."
1995 "</para><para>It allows you to go to locations you have "
1996 "bookmarked and to access disk or media attached to the computer "
1997 "or to the network. It also contains sections to find recently "
1998 "saved files or files of a certain type.</para>"));
1999 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2000 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
2001 "you have bookmarked and to access disk or media attached to the "
2002 "computer or to the network. It also contains sections to find "
2003 "recently saved files or files of a certain type.</para><para>"
2004 "Click on an entry to go there. Click with the right mouse button "
2005 "instead to open any entry in a new tab or new window.</para>"
2006 "<para>New entries can be added by dragging folders onto this panel. "
2007 "Right-click any section or entry to hide it. Right-click an empty "
2008 "space on this panel and select <interface>Show Hidden Places"
2009 "</interface> to display it again.</para>") + panelWhatsThis
);
2011 // Add actions into the "Panels" menu
2012 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
2013 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
2014 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
2015 panelsMenu
->setPopupMode(QToolButton::InstantPopup
);
2016 const KActionCollection
* ac
= actionCollection();
2017 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
2019 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
2021 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
2022 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
2023 panelsMenu
->addSeparator();
2024 panelsMenu
->addAction(actionShowAllPlaces
);
2025 panelsMenu
->addAction(lockLayoutAction
);
2027 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
2028 actionShowAllPlaces
->setEnabled(m_placesPanel
->hiddenListCount());
2033 void DolphinMainWindow::updateFileAndEditActions()
2035 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
2036 const KActionCollection
* col
= actionCollection();
2037 KFileItemListProperties
capabilitiesSource(list
);
2039 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
2040 QAction
* copyToOtherViewAction
= col
->action(QStringLiteral("copy_to_inactive_split_view"));
2041 QAction
* moveToOtherViewAction
= col
->action(QStringLiteral("move_to_inactive_split_view"));
2042 QAction
* copyLocation
= col
->action(QString("copy_location"));
2044 if (list
.isEmpty()) {
2045 stateChanged(QStringLiteral("has_no_selection"));
2047 addToPlacesAction
->setEnabled(true);
2048 copyToOtherViewAction
->setEnabled(false);
2049 moveToOtherViewAction
->setEnabled(false);
2050 copyLocation
->setEnabled(false);
2052 stateChanged(QStringLiteral("has_selection"));
2054 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
2055 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
2056 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
2057 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
2058 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
2059 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
2060 QAction
* duplicateAction
= col
->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler
2062 if (list
.length() == 1 && list
.first().isDir()) {
2063 addToPlacesAction
->setEnabled(true);
2065 addToPlacesAction
->setEnabled(false);
2068 if (m_tabWidget
->currentTabPage()->splitViewEnabled()) {
2069 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2070 KFileItem capabilitiesDestination
;
2072 if (tabPage
->primaryViewActive()) {
2073 capabilitiesDestination
= tabPage
->secondaryViewContainer()->url();
2075 capabilitiesDestination
= tabPage
->primaryViewContainer()->url();
2078 copyToOtherViewAction
->setEnabled(capabilitiesDestination
.isWritable());
2079 moveToOtherViewAction
->setEnabled(capabilitiesSource
.supportsMoving() && capabilitiesDestination
.isWritable());
2081 copyToOtherViewAction
->setEnabled(false);
2082 moveToOtherViewAction
->setEnabled(false);
2085 const bool enableMoveToTrash
= capabilitiesSource
.isLocal() && capabilitiesSource
.supportsMoving();
2087 renameAction
->setEnabled(capabilitiesSource
.supportsMoving());
2088 moveToTrashAction
->setEnabled(enableMoveToTrash
);
2089 deleteAction
->setEnabled(capabilitiesSource
.supportsDeleting());
2090 deleteWithTrashShortcut
->setEnabled(capabilitiesSource
.supportsDeleting() && !enableMoveToTrash
);
2091 cutAction
->setEnabled(capabilitiesSource
.supportsMoving());
2092 copyLocation
->setEnabled(list
.length() == 1);
2093 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
2094 duplicateAction
->setEnabled(capabilitiesSource
.supportsWriting());
2098 void DolphinMainWindow::updateViewActions()
2100 m_actionHandler
->updateViewActions();
2102 QAction
* toggleFilterBarAction
= actionCollection()->action(QStringLiteral("toggle_filter"));
2103 toggleFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
2105 updateSplitAction();
2108 void DolphinMainWindow::updateGoActions()
2110 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
2111 const QUrl currentUrl
= m_activeViewContainer
->url();
2112 // I think this is one of the best places to firstly be confronted
2113 // with a file system and its hierarchy. Talking about the root
2114 // directory might seem too much here but it is the question that
2115 // naturally arises in this context.
2116 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
2117 "the folder that contains the currently viewed one.</para>"
2118 "<para>All files and folders are organized in a hierarchical "
2119 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
2120 "a directory that contains all data connected to this computer"
2121 "—the <emphasis>root directory</emphasis>.</para>"));
2122 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
2125 void DolphinMainWindow::refreshViews()
2127 m_tabWidget
->refreshViews();
2129 if (GeneralSettings::modifiedStartupSettings()) {
2130 updateWindowTitle();
2133 Q_EMIT
settingsChanged();
2136 void DolphinMainWindow::clearStatusBar()
2138 m_activeViewContainer
->statusBar()->resetToDefaultText();
2141 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
2143 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
2144 this, &DolphinMainWindow::updateFilterBarAction
);
2145 connect(container
, &DolphinViewContainer::writeStateChanged
,
2146 this, &DolphinMainWindow::slotWriteStateChanged
);
2147 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
2148 this, &DolphinMainWindow::updateSearchAction
);
2149 connect(container
, &DolphinViewContainer::captionChanged
,
2150 this, &DolphinMainWindow::updateWindowTitle
);
2151 connect(container
, &DolphinViewContainer::tabRequested
,
2152 this, &DolphinMainWindow::openNewTab
);
2153 connect(container
, &DolphinViewContainer::activeTabRequested
,
2154 this, &DolphinMainWindow::openNewTabAndActivate
);
2156 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
2157 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
2159 const DolphinView
* view
= container
->view();
2160 connect(view
, &DolphinView::selectionChanged
,
2161 this, &DolphinMainWindow::slotSelectionChanged
);
2162 connect(view
, &DolphinView::requestItemInfo
,
2163 this, &DolphinMainWindow::requestItemInfo
);
2164 connect(view
, &DolphinView::fileItemsChanged
,
2165 this, &DolphinMainWindow::fileItemsChanged
);
2166 connect(view
, &DolphinView::tabRequested
,
2167 this, &DolphinMainWindow::openNewTab
);
2168 connect(view
, &DolphinView::activeTabRequested
,
2169 this, &DolphinMainWindow::openNewTabAndActivate
);
2170 connect(view
, &DolphinView::windowRequested
,
2171 this, &DolphinMainWindow::openNewWindow
);
2172 connect(view
, &DolphinView::requestContextMenu
,
2173 this, &DolphinMainWindow::openContextMenu
);
2174 connect(view
, &DolphinView::directoryLoadingStarted
,
2175 this, &DolphinMainWindow::enableStopAction
);
2176 connect(view
, &DolphinView::directoryLoadingCompleted
,
2177 this, &DolphinMainWindow::disableStopAction
);
2178 connect(view
, &DolphinView::directoryLoadingCompleted
,
2179 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
2180 connect(view
, &DolphinView::goBackRequested
,
2181 this, &DolphinMainWindow::goBack
);
2182 connect(view
, &DolphinView::goForwardRequested
,
2183 this, &DolphinMainWindow::goForward
);
2184 connect(view
, &DolphinView::urlActivated
,
2185 this, &DolphinMainWindow::handleUrl
);
2186 connect(view
, &DolphinView::goUpRequested
,
2187 this, &DolphinMainWindow::goUp
);
2189 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged
,
2190 this, &DolphinMainWindow::changeUrl
);
2191 connect(container
->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged
,
2192 this, &DolphinMainWindow::updateHistory
);
2194 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2195 (actionCollection()->action(QStringLiteral("url_navigators")));
2196 const KUrlNavigator
*navigator
= m_tabWidget
->currentTabPage()->primaryViewActive() ?
2197 navigators
->primaryUrlNavigator() :
2198 navigators
->secondaryUrlNavigator();
2200 QAction
*editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
2201 editableLocactionAction
->setChecked(navigator
->isUrlEditable());
2202 connect(navigator
, &KUrlNavigator::editableStateChanged
,
2203 this, &DolphinMainWindow::slotEditableStateChanged
);
2204 connect(navigator
, &KUrlNavigator::tabRequested
,
2205 this, &DolphinMainWindow::openNewTab
);
2206 connect(navigator
, &KUrlNavigator::activeTabRequested
,
2207 this, &DolphinMainWindow::openNewTabAndActivate
);
2208 connect(navigator
, &KUrlNavigator::newWindowRequested
,
2209 this, &DolphinMainWindow::openNewWindow
);
2213 void DolphinMainWindow::updateSplitAction()
2215 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
2216 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2217 if (tabPage
->splitViewEnabled()) {
2218 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2219 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2220 splitAction
->setToolTip(i18nc("@info", "Close left view"));
2221 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2223 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2224 splitAction
->setToolTip(i18nc("@info", "Close right view"));
2225 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2228 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2229 splitAction
->setToolTip(i18nc("@info", "Split view"));
2230 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2234 void DolphinMainWindow::updateAllowedToolbarAreas()
2236 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2237 (actionCollection()->action(QStringLiteral("url_navigators")));
2238 if (toolBar()->actions().contains(navigators
)) {
2239 toolBar()->setAllowedAreas(Qt::TopToolBarArea
| Qt::BottomToolBarArea
);
2240 if (toolBarArea(toolBar()) == Qt::LeftToolBarArea
||
2241 toolBarArea(toolBar()) == Qt::RightToolBarArea
) {
2242 addToolBar(Qt::TopToolBarArea
, toolBar());
2245 toolBar()->setAllowedAreas(Qt::AllToolBarAreas
);
2249 bool DolphinMainWindow::isKompareInstalled() const
2251 static bool initialized
= false;
2252 static bool installed
= false;
2254 // TODO: maybe replace this approach later by using a menu
2255 // plugin like kdiff3plugin.cpp
2256 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2262 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2263 const QKeySequence
& shortcut
,
2264 QAction
* dockAction
,
2265 const QString
& actionName
)
2267 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2268 panelAction
->setCheckable(true);
2269 panelAction
->setChecked(dockAction
->isChecked());
2270 panelAction
->setText(dockAction
->text());
2271 panelAction
->setIcon(icon
);
2272 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2274 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2275 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2278 void DolphinMainWindow::setupWhatsThis()
2281 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2282 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2283 "configuration options. Left-click on any of the menus on this "
2284 "bar to see its contents.</para><para>The Menubar can be hidden "
2285 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2286 "most of its contents become available through a <interface>Control"
2287 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2288 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2289 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2290 "frequently used actions.</para><para>It is highly customizable. "
2291 "All items you see in the <interface>Control</interface> menu or "
2292 "in the <interface>Menubar</interface> can be placed on the "
2293 "Toolbar. Just right-click on it and select <interface>Configure "
2294 "Toolbars…</interface> or find this action in the <interface>"
2295 "Control</interface> or <interface>Settings</interface> menu."
2296 "</para><para>The location of the bar and the style of its "
2297 "buttons can also be changed in the right-click menu. Right-click "
2298 "a button if you want to show or hide its text.</para>"));
2299 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2300 "<para>Here you can see the <emphasis>folders</emphasis> and "
2301 "<emphasis>files</emphasis> that are at the location described in "
2302 "the <interface>Location Bar</interface> above. This area is the "
2303 "central part of this application where you navigate to the files "
2304 "you want to use.</para><para>For an elaborate and general "
2305 "introduction to this application <link "
2306 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2307 "click here</link>. This will open an introductory article from "
2308 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2309 "explanations of all the features of this <emphasis>view</emphasis> "
2310 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2311 "instead. This will open a page from the <emphasis>Handbook"
2312 "</emphasis> that covers the basics.</para>"));
2315 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2316 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2317 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2318 "There you can set up key combinations to trigger an action when "
2319 "they are pressed simultaneously. All commands in this application can "
2320 "be triggered this way.</para>"));
2321 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2322 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2323 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2324 "<para>All items you see in the <interface>Control</interface> menu "
2325 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2326 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2327 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2328 "change a multitude of settings for this application. For an explanation "
2329 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2330 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2333 // The whatsthis has to be set for the m_helpMenu and for the
2334 // StandardAction separately because both are used in different locations.
2335 // m_helpMenu is only used for createControlButton() button.
2337 auto setStandardActionWhatsThis
= [this](KStandardAction::StandardAction actionId
,
2338 const QString
&whatsThis
) {
2339 if (auto *action
= actionCollection()->action(KStandardAction::name(actionId
))) {
2340 action
->setWhatsThis(whatsThis
);
2343 auto setHelpActionWhatsThis
= [this](KHelpMenu::MenuId menuId
, const QString
&whatsThis
) {
2344 if (auto *action
= m_helpMenu
->action(menuId
)) {
2345 action
->setWhatsThis(whatsThis
);
2349 // Links do not work within the Menubar so texts without links are provided there.
2351 // i18n: If the external link isn't available in your language you should
2352 // probably state the external link language at least in brackets to not
2353 // frustrate the user. If there are multiple languages that the user might
2354 // know with a reasonable chance you might want to have 2 external links.
2355 // The same is in my opinion true for every external link you translate.
2356 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2357 "<para>This opens the Handbook for this application. It provides "
2358 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2359 setStandardActionWhatsThis(KStandardAction::HelpContents
, whatsThisHelpContents
2360 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2361 "<para>If you want more elaborate introductions to the "
2362 "different features of <emphasis>Dolphin</emphasis> "
2363 "go to the KDE UserBase Wiki.</para>"));
2364 setHelpActionWhatsThis(KHelpMenu::menuHelpContents
, whatsThisHelpContents
2365 + xi18nc("@info:whatsthis second half of handbook text with link",
2366 "<para>If you want more elaborate introductions to the "
2367 "different features of <emphasis>Dolphin</emphasis> "
2368 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2369 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2371 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2372 "<para>This is the button that invokes the help feature you are "
2373 "using right now! Click it, then click any component of this "
2374 "application to ask \"What's this?\" about it. The mouse cursor "
2375 "will change appearance if no help is available for a spot.</para>");
2376 setStandardActionWhatsThis(KStandardAction::WhatsThis
, whatsThisWhatsThis
2377 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2378 "<para>There are two other ways to get help for this application: The "
2379 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2380 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2381 "article about <emphasis>File Management</emphasis> online."
2382 "</para><para>The \"What's this?\" help is "
2383 "missing in most other windows so don't get too used to this.</para>"));
2384 setHelpActionWhatsThis(KHelpMenu::menuWhatsThis
, whatsThisWhatsThis
2385 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2386 "<para>There are two other ways to get help: "
2387 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2388 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2389 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2390 "missing in most other windows so don't get too used to this.</para>"));
2392 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2393 "window that will guide you through reporting errors or flaws "
2394 "in this application or in other KDE software.</para>");
2395 setStandardActionWhatsThis(KStandardAction::ReportBug
, whatsThisReportBug
);
2396 setHelpActionWhatsThis(KHelpMenu::menuReportBug
, whatsThisReportBug
2397 + xi18nc("@info:whatsthis second half of reportbug text with link",
2398 "<para>High-quality bug reports are much appreciated. To learn "
2399 "how to make your bug report as effective as possible "
2400 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2401 "click here</link>.</para>"));
2403 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2404 "<emphasis>web page</emphasis> where you can donate to "
2405 "support the continued work on this application and many "
2406 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2407 "<para>Donating is the easiest and fastest way to efficiently "
2408 "support KDE and its projects. KDE projects are available for "
2409 "free therefore your donation is needed to cover things that "
2410 "require money like servers, contributor meetings, etc.</para>"
2411 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2412 "organization behind the KDE community.</para>");
2413 setStandardActionWhatsThis(KStandardAction::Donate
, whatsThisDonate
);
2414 setHelpActionWhatsThis(KHelpMenu::menuDonate
, whatsThisDonate
);
2416 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2417 "With this you can change the language this application uses."
2418 "<nl/>You can even set secondary languages which will be used "
2419 "if texts are not available in your preferred language.");
2420 setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage
,
2421 whatsThisSwitchLanguage
);
2422 setHelpActionWhatsThis(KHelpMenu::menuSwitchLanguage
, whatsThisSwitchLanguage
);
2424 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2425 "window that informs you about the version, license, "
2426 "used libraries and maintainers of this application.");
2427 setStandardActionWhatsThis(KStandardAction::AboutApp
, whatsThisAboutApp
);
2428 setHelpActionWhatsThis(KHelpMenu::menuAboutApp
, whatsThisAboutApp
);
2430 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2431 "window with information about <emphasis>KDE</emphasis>. "
2432 "The KDE community are the people behind this free software."
2433 "<nl/>If you like using this application but don't know "
2434 "about KDE or want to see a cute dragon have a look!");
2435 setStandardActionWhatsThis(KStandardAction::AboutKDE
, whatsThisAboutKDE
);
2436 setHelpActionWhatsThis(KHelpMenu::menuAboutKDE
, whatsThisAboutKDE
);
2439 bool DolphinMainWindow::addHamburgerMenuToToolbar()
2441 QDomDocument domDocument
= KXMLGUIClient::domDocument();
2442 if (domDocument
.isNull()) {
2445 QDomNode toolbar
= domDocument
.elementsByTagName(QStringLiteral("ToolBar")).at(0);
2446 if (toolbar
.isNull()) {
2450 QDomElement hamburgerMenuElement
= domDocument
.createElement(QStringLiteral("Action"));
2451 hamburgerMenuElement
.setAttribute(QStringLiteral("name"), QStringLiteral("hamburger_menu"));
2452 toolbar
.appendChild(hamburgerMenuElement
);
2454 KXMLGUIFactory::saveConfigFile(domDocument
, xmlFile());
2458 // Make sure to also remove the <KXMLGUIFactory> and <QDomDocument> include
2459 // whenever this method is removed (maybe in the year ~2026).
2462 bool DolphinMainWindow::event(QEvent
*event
)
2464 if (event
->type() == QEvent::WhatsThisClicked
) {
2466 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2467 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2470 return KXmlGuiWindow::event(event
);
2473 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2476 if (event
->type() == QEvent::WhatsThisClicked
) {
2478 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2479 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2485 // Set a sane initial window size
2486 QSize
DolphinMainWindow::sizeHint() const
2488 return KXmlGuiWindow::sizeHint().expandedTo(QSize(760, 550));
2491 void DolphinMainWindow::saveNewToolbarConfig()
2493 KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
2494 // because the rest of this method decides things
2495 // based on the new config.
2496 auto navigators
= static_cast<DolphinNavigatorsWidgetAction
*>
2497 (actionCollection()->action(QStringLiteral("url_navigators")));
2498 if (!toolBar()->actions().contains(navigators
)) {
2499 m_tabWidget
->currentTabPage()->insertNavigatorsWidget(navigators
);
2501 updateAllowedToolbarAreas();
2502 (static_cast<KHamburgerMenu
*>(actionCollection()->action(KStandardAction::name(
2503 KStandardAction::HamburgerMenu
))))->hideActionsOf(toolBar());
2506 void DolphinMainWindow::focusTerminalPanel()
2508 if (m_terminalPanel
->isVisible()) {
2509 if (m_terminalPanel
->terminalHasFocus()) {
2510 m_activeViewContainer
->view()->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2511 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
2513 m_terminalPanel
->setFocus(Qt::FocusReason::ShortcutFocusReason
);
2514 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2517 actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger();
2518 actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
2522 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2523 KIO::FileUndoManager::UiInterface()
2527 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2531 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2533 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2535 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2536 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2538 KIO::FileUndoManager::UiInterface::jobError(job
);
2542 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2544 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));