1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #include "dolphinmainwindow.h"
24 #include "config-terminal.h"
26 #include "dolphinbookmarkhandler.h"
27 #include "dolphindockwidget.h"
28 #include "dolphincontextmenu.h"
29 #include "dolphinnewfilemenu.h"
30 #include "dolphinrecenttabsmenu.h"
31 #include "dolphinviewcontainer.h"
32 #include "dolphintabpage.h"
33 #include "middleclickactioneventfilter.h"
34 #include "panels/folders/folderspanel.h"
35 #include "panels/places/placesitemmodel.h"
36 #include "panels/places/placespanel.h"
37 #include "panels/information/informationpanel.h"
38 #include "panels/terminal/terminalpanel.h"
39 #include "settings/dolphinsettingsdialog.h"
40 #include "statusbar/dolphinstatusbar.h"
41 #include "views/dolphinviewactionhandler.h"
42 #include "views/dolphinremoteencoding.h"
43 #include "views/draganddrophelper.h"
44 #include "views/viewproperties.h"
45 #include "views/dolphinnewfilemenuobserver.h"
46 #include "dolphin_generalsettings.h"
48 #include <KActionCollection>
49 #include <KActionMenu>
50 #include <KAuthorized>
52 #include <KDualAction>
53 #include <KFileItemListProperties>
55 #include <KIO/JobUiDelegate>
56 #include <KIO/OpenFileManagerWindowJob>
57 #include <KJobWidgets>
58 #include <KLocalizedString>
59 #include <KMessageBox>
60 #include <KProtocolInfo>
61 #include <KProtocolManager>
64 #include <KStandardAction>
65 #include <KStartupInfo>
66 #include <KToggleAction>
68 #include <KToolBarPopupAction>
69 #include <KToolInvocation>
70 #include <KUrlComboBox>
71 #include <KUrlNavigator>
72 #include <KWindowSystem>
74 #include <QApplication>
76 #include <QCloseEvent>
77 #include <QDesktopServices>
83 #include <QPushButton>
85 #include <QStandardPaths>
87 #include <QToolButton>
88 #include <QWhatsThisClickedEvent>
91 // Used for GeneralSettings::version() to determine whether
92 // an updated version of Dolphin is running.
93 const int CurrentDolphinVersion
= 200;
94 // The maximum number of entries in the back/forward popup menu
95 const int MaxNumberOfNavigationentries
= 12;
98 DolphinMainWindow::DolphinMainWindow() :
99 KXmlGuiWindow(nullptr),
100 m_newFileMenu(nullptr),
102 m_tabWidget(nullptr),
103 m_activeViewContainer(nullptr),
104 m_actionHandler(nullptr),
105 m_remoteEncoding(nullptr),
107 m_bookmarkHandler(nullptr),
108 m_controlButton(nullptr),
109 m_updateToolBarTimer(nullptr),
110 m_lastHandleUrlStatJob(nullptr),
111 m_terminalPanel(nullptr),
112 m_placesPanel(nullptr),
113 m_tearDownFromPlacesRequested(false),
114 m_backAction(nullptr),
115 m_forwardAction(nullptr)
117 Q_INIT_RESOURCE(dolphin
);
119 setWindowFlags(Qt::WindowContextHelpButtonHint
);
121 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
122 setObjectName(QStringLiteral("Dolphin#"));
124 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
125 this, &DolphinMainWindow::showErrorMessage
);
127 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
128 undoManager
->setUiInterface(new UndoUiInterface());
130 connect(undoManager
, QOverload
<bool>::of(&KIO::FileUndoManager::undoAvailable
),
131 this, &DolphinMainWindow::slotUndoAvailable
);
132 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
133 this, &DolphinMainWindow::slotUndoTextChanged
);
134 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
135 this, &DolphinMainWindow::clearStatusBar
);
136 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
137 this, &DolphinMainWindow::showCommand
);
139 GeneralSettings
* generalSettings
= GeneralSettings::self();
140 const bool firstRun
= (generalSettings
->version() < 200);
142 generalSettings
->setViewPropsTimestamp(QDateTime::currentDateTime());
145 setAcceptDrops(true);
147 m_tabWidget
= new DolphinTabWidget(this);
148 m_tabWidget
->setObjectName("tabWidget");
149 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
150 this, &DolphinMainWindow::activeViewChanged
);
151 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
152 this, &DolphinMainWindow::tabCountChanged
);
153 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
154 this, &DolphinMainWindow::updateWindowTitle
);
155 setCentralWidget(m_tabWidget
);
159 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
160 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
161 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
163 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
164 connect(this, &DolphinMainWindow::urlChanged
,
165 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
169 setupGUI(Keys
| Save
| Create
| ToolBar
);
170 stateChanged(QStringLiteral("new_file"));
172 QClipboard
* clipboard
= QApplication::clipboard();
173 connect(clipboard
, &QClipboard::dataChanged
,
174 this, &DolphinMainWindow::updatePasteAction
);
176 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
177 showFilterBarAction
->setChecked(generalSettings
->filterBar());
180 menuBar()->setVisible(false);
181 // Assure a proper default size if Dolphin runs the first time
185 const bool showMenu
= !menuBar()->isHidden();
186 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
187 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
189 createControlButton();
192 // enable middle-click on back/forward/up to open in a new tab
193 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
194 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
195 toolBar()->installEventFilter(middleClickEventFilter
);
200 DolphinMainWindow::~DolphinMainWindow()
204 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
206 QVector
<DolphinViewContainer
*> viewContainers
;
207 viewContainers
.reserve(m_tabWidget
->count());
208 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
209 viewContainers
<< m_tabWidget
->tabPageAt(i
)->activeViewContainer();
211 return viewContainers
;
214 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
216 m_tabWidget
->openDirectories(dirs
, splitView
);
219 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
221 openDirectories(QUrl::fromStringList(dirs
), splitView
);
224 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
226 m_tabWidget
->openFiles(files
, splitView
);
229 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
231 openFiles(QUrl::fromStringList(files
), splitView
);
234 void DolphinMainWindow::activateWindow()
236 KStartupInfo::setNewStartupId(window(), KStartupInfo::startupId());
237 KWindowSystem::activateWindow(window()->effectiveWinId());
240 void DolphinMainWindow::showCommand(CommandType command
)
242 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
244 case KIO::FileUndoManager::Copy
:
245 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
247 case KIO::FileUndoManager::Move
:
248 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
250 case KIO::FileUndoManager::Link
:
251 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
253 case KIO::FileUndoManager::Trash
:
254 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
256 case KIO::FileUndoManager::Rename
:
257 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
260 case KIO::FileUndoManager::Mkdir
:
261 statusBar
->setText(i18nc("@info:status", "Created folder."));
269 void DolphinMainWindow::pasteIntoFolder()
271 m_activeViewContainer
->view()->pasteIntoFolder();
274 void DolphinMainWindow::changeUrl(const QUrl
&url
)
276 if (!KProtocolManager::supportsListing(url
)) {
277 // The URL navigator only checks for validity, not
278 // if the URL can be listed. An error message is
279 // shown due to DolphinViewContainer::restoreView().
283 m_activeViewContainer
->setUrl(url
);
284 updateFileAndEditActions();
289 emit
urlChanged(url
);
292 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
294 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
295 m_placesPanel
->proceedWithTearDown();
296 m_tearDownFromPlacesRequested
= false;
299 m_activeViewContainer
->setAutoGrabFocus(false);
301 m_activeViewContainer
->setAutoGrabFocus(true);
304 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
306 KToggleAction
* editableLocationAction
=
307 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
308 editableLocationAction
->setChecked(editable
);
311 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
313 updateFileAndEditActions();
315 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
317 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
318 if (selectedUrlsCount
== 2) {
319 compareFilesAction
->setEnabled(isKompareInstalled());
321 compareFilesAction
->setEnabled(false);
324 emit
selectionChanged(selection
);
327 void DolphinMainWindow::updateHistory()
329 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
330 const int index
= urlNavigator
->historyIndex();
332 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
334 backAction
->setToolTip(i18nc("@info", "Go back"));
335 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
336 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
339 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
341 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
342 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
343 "This undoes a <interface>Go|Back</interface> action."));
344 forwardAction
->setEnabled(index
> 0);
348 void DolphinMainWindow::updateFilterBarAction(bool show
)
350 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
351 showFilterBarAction
->setChecked(show
);
354 void DolphinMainWindow::openNewMainWindow()
356 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
359 void DolphinMainWindow::openNewActivatedTab()
361 m_tabWidget
->openNewActivatedTab();
364 void DolphinMainWindow::addToPlaces()
369 // If nothing is selected, act on the current dir
370 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
371 url
= m_activeViewContainer
->url();
372 name
= m_activeViewContainer
->placesText();
374 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
375 url
= dirToAdd
.url();
376 name
= dirToAdd
.name();
379 PlacesItemModel model
;
381 if (m_activeViewContainer
->isSearchModeEnabled()) {
382 icon
= QStringLiteral("folder-saved-search-symbolic");
384 icon
= KIO::iconNameForUrl(url
);
386 model
.createPlacesItem(name
, url
, icon
);
390 void DolphinMainWindow::openNewTab(const QUrl
& url
, DolphinTabWidget::TabPlacement tabPlacement
)
392 m_tabWidget
->openNewTab(url
, QUrl(), tabPlacement
);
395 void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl
& url
)
397 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterCurrentTab
);
400 void DolphinMainWindow::openNewTabAfterLastTab(const QUrl
& url
)
402 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterLastTab
);
405 void DolphinMainWindow::openInNewTab()
407 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
408 bool tabCreated
= false;
410 foreach (const KFileItem
& item
, list
) {
411 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
412 if (!url
.isEmpty()) {
413 openNewTabAfterCurrentTab(url
);
418 // if no new tab has been created from the selection
419 // open the current directory in a new tab
421 openNewTabAfterCurrentTab(m_activeViewContainer
->url());
425 void DolphinMainWindow::openInNewWindow()
429 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
430 if (list
.isEmpty()) {
431 newWindowUrl
= m_activeViewContainer
->url();
432 } else if (list
.count() == 1) {
433 const KFileItem
& item
= list
.first();
434 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
437 if (!newWindowUrl
.isEmpty()) {
438 Dolphin::openNewWindow({newWindowUrl
}, this);
442 void DolphinMainWindow::showTarget()
444 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
445 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
446 auto linkDestination
= link
.linkDest();
447 if (QFileInfo(linkDestination
).isRelative()) {
448 linkDestination
= linkLocationDir
.filePath(linkDestination
);
450 if (QFileInfo::exists(linkDestination
)) {
451 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
453 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
454 DolphinViewContainer::Warning
);
458 void DolphinMainWindow::showEvent(QShowEvent
* event
)
460 KXmlGuiWindow::showEvent(event
);
462 if (!event
->spontaneous()) {
463 m_activeViewContainer
->view()->setFocus();
467 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
469 // Find out if Dolphin is closed directly by the user or
470 // by the session manager because the session is closed
471 bool closedByUser
= true;
472 if (qApp
->isSavingSession()) {
473 closedByUser
= false;
476 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser
) {
477 // Ask the user if he really wants to quit and close all tabs.
478 // Open a confirmation dialog with 3 buttons:
479 // QDialogButtonBox::Yes -> Quit
480 // QDialogButtonBox::No -> Close only the current tab
481 // QDialogButtonBox::Cancel -> do nothing
482 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
483 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
484 dialog
->setModal(true);
485 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
486 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
487 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
488 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
489 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
491 bool doNotAskAgainCheckboxResult
= false;
493 const auto result
= KMessageBox::createKMessageBox(dialog
,
495 QMessageBox::Warning
,
496 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
498 i18n("Do not ask again"),
499 &doNotAskAgainCheckboxResult
,
500 KMessageBox::Notify
);
502 if (doNotAskAgainCheckboxResult
) {
503 GeneralSettings::setConfirmClosingMultipleTabs(false);
507 case QDialogButtonBox::Yes
:
510 case QDialogButtonBox::No
:
511 // Close only the current tab
512 m_tabWidget
->closeTab();
520 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
521 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
522 // Open a confirmation dialog with 3 buttons:
523 // QDialogButtonBox::Yes -> Quit
524 // QDialogButtonBox::No -> Show Terminal Panel
525 // QDialogButtonBox::Cancel -> do nothing
526 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
527 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
528 dialog
->setModal(true);
529 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
530 if (!m_terminalPanel
->isVisible()) {
531 standardButtons
|= QDialogButtonBox::No
;
533 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
534 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
535 if (!m_terminalPanel
->isVisible()) {
537 buttons
->button(QDialogButtonBox::No
),
538 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
540 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
542 bool doNotAskAgainCheckboxResult
= false;
544 const auto result
= KMessageBox::createKMessageBox(
547 QMessageBox::Warning
,
548 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
550 i18n("Do not ask again"),
551 &doNotAskAgainCheckboxResult
,
552 KMessageBox::Dangerous
);
554 if (doNotAskAgainCheckboxResult
) {
555 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
559 case QDialogButtonBox::Yes
:
562 case QDialogButtonBox::No
:
563 actionCollection()->action("show_terminal_panel")->trigger();
564 // Do not quit, ignore quit event
572 GeneralSettings::setVersion(CurrentDolphinVersion
);
573 GeneralSettings::self()->save();
575 KXmlGuiWindow::closeEvent(event
);
578 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
580 m_tabWidget
->saveProperties(group
);
583 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
585 m_tabWidget
->readProperties(group
);
588 void DolphinMainWindow::updateNewMenu()
590 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
591 m_newFileMenu
->checkUpToDate();
592 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
595 void DolphinMainWindow::createDirectory()
597 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
598 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
599 m_newFileMenu
->createDirectory();
602 void DolphinMainWindow::quit()
607 void DolphinMainWindow::showErrorMessage(const QString
& message
)
609 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
612 void DolphinMainWindow::slotUndoAvailable(bool available
)
614 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
616 undoAction
->setEnabled(available
);
620 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
622 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
624 undoAction
->setText(text
);
628 void DolphinMainWindow::undo()
631 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
632 KIO::FileUndoManager::self()->undo();
635 void DolphinMainWindow::cut()
637 m_activeViewContainer
->view()->cutSelectedItems();
640 void DolphinMainWindow::copy()
642 m_activeViewContainer
->view()->copySelectedItems();
645 void DolphinMainWindow::paste()
647 m_activeViewContainer
->view()->paste();
650 void DolphinMainWindow::find()
652 m_activeViewContainer
->setSearchModeEnabled(true);
655 void DolphinMainWindow::updateSearchAction()
657 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
658 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
661 void DolphinMainWindow::updatePasteAction()
663 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
664 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
665 pasteAction
->setEnabled(pasteInfo
.first
);
666 pasteAction
->setText(pasteInfo
.second
);
669 void DolphinMainWindow::slotDirectoryLoadingCompleted()
674 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
676 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
678 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
680 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
682 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
687 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
689 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
691 m_backAction
->menu()->clear();
692 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
693 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_backAction
->menu());
695 m_backAction
->menu()->addAction(action
);
699 void DolphinMainWindow::slotGoBack(QAction
* action
)
701 int gotoIndex
= action
->data().value
<int>();
702 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
703 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
708 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
711 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
712 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
716 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
718 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
720 m_forwardAction
->menu()->clear();
721 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
722 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
724 m_forwardAction
->menu()->addAction(action
);
728 void DolphinMainWindow::slotGoForward(QAction
* action
)
730 int gotoIndex
= action
->data().value
<int>();
731 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
732 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
737 void DolphinMainWindow::selectAll()
741 // if the URL navigator is editable and focused, select the whole
742 // URL instead of all items of the view
744 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
745 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
746 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
747 lineEdit
->hasFocus();
749 lineEdit
->selectAll();
751 m_activeViewContainer
->view()->selectAll();
755 void DolphinMainWindow::invertSelection()
758 m_activeViewContainer
->view()->invertSelection();
761 void DolphinMainWindow::toggleSplitView()
763 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
764 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled());
769 void DolphinMainWindow::toggleSplitStash()
771 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
772 tabPage
->setSplitViewEnabled(false);
773 tabPage
->setSplitViewEnabled(true, QUrl("stash:/"));
776 void DolphinMainWindow::reloadView()
779 m_activeViewContainer
->reload();
780 m_activeViewContainer
->statusBar()->updateSpaceInfo();
783 void DolphinMainWindow::stopLoading()
785 m_activeViewContainer
->view()->stopLoading();
788 void DolphinMainWindow::enableStopAction()
790 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
793 void DolphinMainWindow::disableStopAction()
795 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
798 void DolphinMainWindow::showFilterBar()
800 m_activeViewContainer
->setFilterBarVisible(true);
803 void DolphinMainWindow::toggleEditLocation()
807 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
808 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
809 urlNavigator
->setUrlEditable(action
->isChecked());
812 void DolphinMainWindow::replaceLocation()
814 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
815 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
817 // If the text field currently has focus and everything is selected,
818 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
819 if (navigator
->isUrlEditable()
820 && lineEdit
->hasFocus()
821 && lineEdit
->selectedText() == lineEdit
->text() ) {
822 navigator
->setUrlEditable(false);
824 navigator
->setUrlEditable(true);
825 navigator
->setFocus();
826 lineEdit
->selectAll();
830 void DolphinMainWindow::togglePanelLockState()
832 const bool newLockState
= !GeneralSettings::lockPanels();
833 foreach (QObject
* child
, children()) {
834 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
836 dock
->setLocked(newLockState
);
840 GeneralSettings::setLockPanels(newLockState
);
843 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
845 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
846 m_activeViewContainer
->view()->setFocus();
850 void DolphinMainWindow::goBack()
852 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
853 urlNavigator
->goBack();
855 if (urlNavigator
->locationState().isEmpty()) {
856 // An empty location state indicates a redirection URL,
857 // which must be skipped too
858 urlNavigator
->goBack();
862 void DolphinMainWindow::goForward()
864 m_activeViewContainer
->urlNavigator()->goForward();
867 void DolphinMainWindow::goUp()
869 m_activeViewContainer
->urlNavigator()->goUp();
872 void DolphinMainWindow::goHome()
874 m_activeViewContainer
->urlNavigator()->goHome();
877 void DolphinMainWindow::goBackInNewTab()
879 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
880 const int index
= urlNavigator
->historyIndex() + 1;
881 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
884 void DolphinMainWindow::goForwardInNewTab()
886 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
887 const int index
= urlNavigator
->historyIndex() - 1;
888 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
891 void DolphinMainWindow::goUpInNewTab()
893 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
894 openNewTabAfterCurrentTab(KIO::upUrl(currentUrl
));
897 void DolphinMainWindow::goHomeInNewTab()
899 openNewTabAfterCurrentTab(Dolphin::homeUrl());
902 void DolphinMainWindow::compareFiles()
904 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
905 if (items
.count() != 2) {
906 // The action is disabled in this case, but it could have been triggered
907 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
911 QUrl urlA
= items
.at(0).url();
912 QUrl urlB
= items
.at(1).url();
914 QString
command(QStringLiteral("kompare -c \""));
915 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
916 command
.append("\" \"");
917 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
918 command
.append('\"');
919 KRun::runCommand(command
, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
922 void DolphinMainWindow::toggleShowMenuBar()
924 const bool visible
= menuBar()->isVisible();
925 menuBar()->setVisible(!visible
);
927 createControlButton();
929 deleteControlButton();
933 void DolphinMainWindow::openTerminal()
935 QString
dir(QDir::homePath());
937 // If the given directory is not local, it can still be the URL of an
938 // ioslave using UDS_LOCAL_PATH which to be converted first.
939 KIO::StatJob
* statJob
= KIO::mostLocalUrl(m_activeViewContainer
->url());
940 KJobWidgets::setWindow(statJob
, this);
942 QUrl url
= statJob
->mostLocalUrl();
944 //If the URL is local after the above conversion, set the directory.
945 if (url
.isLocalFile()) {
946 dir
= url
.toLocalFile();
949 KToolInvocation::invokeTerminal(QString(), dir
);
952 void DolphinMainWindow::editSettings()
954 if (!m_settingsDialog
) {
955 DolphinViewContainer
* container
= activeViewContainer();
956 container
->view()->writeSettings();
958 const QUrl url
= container
->url();
959 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this);
960 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
961 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
962 settingsDialog
->show();
963 m_settingsDialog
= settingsDialog
;
965 m_settingsDialog
.data()->raise();
969 void DolphinMainWindow::handleUrl(const QUrl
& url
)
971 delete m_lastHandleUrlStatJob
;
972 m_lastHandleUrlStatJob
= nullptr;
974 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
975 activeViewContainer()->setUrl(url
);
976 } else if (KProtocolManager::supportsListing(url
)) {
977 // stat the URL to see if it is a dir or not
978 m_lastHandleUrlStatJob
= KIO::stat(url
, KIO::HideProgressInfo
);
979 if (m_lastHandleUrlStatJob
->uiDelegate()) {
980 KJobWidgets::setWindow(m_lastHandleUrlStatJob
, this);
982 connect(m_lastHandleUrlStatJob
, &KIO::Job::result
,
983 this, &DolphinMainWindow::slotHandleUrlStatFinished
);
986 new KRun(url
, this); // Automatically deletes itself after being finished
990 void DolphinMainWindow::slotHandleUrlStatFinished(KJob
* job
)
992 m_lastHandleUrlStatJob
= nullptr;
993 const KIO::UDSEntry entry
= static_cast<KIO::StatJob
*>(job
)->statResult();
994 const QUrl url
= static_cast<KIO::StatJob
*>(job
)->url();
996 activeViewContainer()->setUrl(url
);
998 new KRun(url
, this); // Automatically deletes itself after being finished
1002 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1004 // trash:/ is writable but we don't want to create new items in it.
1005 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1006 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1009 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1010 const KFileItem
& item
,
1012 const QList
<QAction
*>& customActions
)
1014 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
);
1015 contextMenu
.data()->setCustomActions(customActions
);
1016 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1019 case DolphinContextMenu::OpenParentFolder
:
1020 changeUrl(KIO::upUrl(item
.url()));
1021 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1022 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1025 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1026 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1029 case DolphinContextMenu::OpenParentFolderInNewTab
:
1030 openNewTabAfterLastTab(KIO::upUrl(item
.url()));
1033 case DolphinContextMenu::None
:
1038 // Delete the menu, unless it has been deleted in its own nested event loop already.
1040 contextMenu
->deleteLater();
1044 void DolphinMainWindow::updateControlMenu()
1046 QMenu
* menu
= qobject_cast
<QMenu
*>(sender());
1049 // All actions get cleared by QMenu::clear(). This includes the sub-menus
1050 // because 'menu' is their parent.
1053 KActionCollection
* ac
= actionCollection();
1055 menu
->addMenu(m_newFileMenu
->menu());
1056 addActionToMenu(ac
->action(QStringLiteral("file_new")), menu
);
1057 addActionToMenu(ac
->action(QStringLiteral("new_tab")), menu
);
1058 addActionToMenu(ac
->action(QStringLiteral("closed_tabs")), menu
);
1060 menu
->addSeparator();
1062 // Add "Edit" actions
1063 bool added
= addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Undo
)), menu
) |
1064 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::SelectAll
)), menu
) |
1065 addActionToMenu(ac
->action(QStringLiteral("invert_selection")), menu
);
1068 menu
->addSeparator();
1071 // Add "View" actions
1072 if (!GeneralSettings::showZoomSlider()) {
1073 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomIn
)), menu
);
1074 addActionToMenu(ac
->action(QStringLiteral("view_zoom_reset")), menu
);
1075 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomOut
)), menu
);
1076 menu
->addSeparator();
1079 added
= addActionToMenu(ac
->action(QStringLiteral("show_preview")), menu
) |
1080 addActionToMenu(ac
->action(QStringLiteral("show_in_groups")), menu
) |
1081 addActionToMenu(ac
->action(QStringLiteral("show_hidden_files")), menu
) |
1082 addActionToMenu(ac
->action(QStringLiteral("additional_info")), menu
) |
1083 addActionToMenu(ac
->action(QStringLiteral("view_properties")), menu
);
1086 menu
->addSeparator();
1089 // Add a curated assortment of items from the "Tools" menu
1090 addActionToMenu(ac
->action(QStringLiteral("show_filter_bar")), menu
);
1091 addActionToMenu(ac
->action(QStringLiteral("open_terminal")), menu
);
1093 menu
->addSeparator();
1095 // Add "Show Panels" menu
1096 addActionToMenu(ac
->action(QStringLiteral("panels")), menu
);
1098 // Add "Settings" menu entries
1099 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)), menu
);
1100 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)), menu
);
1101 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Preferences
)), menu
);
1102 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)), menu
);
1105 auto helpMenu
= m_helpMenu
->menu();
1106 helpMenu
->setIcon(QIcon::fromTheme(QStringLiteral("system-help")));
1107 menu
->addMenu(helpMenu
);
1110 void DolphinMainWindow::updateToolBar()
1112 if (!menuBar()->isVisible()) {
1113 createControlButton();
1117 void DolphinMainWindow::slotControlButtonDeleted()
1119 m_controlButton
= nullptr;
1120 m_updateToolBarTimer
->start();
1123 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1125 DolphinViewContainer
* view
= activeViewContainer();
1127 if (view
->url() == url
) {
1128 // We can end up here if the user clicked a device in the Places Panel
1129 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1136 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1138 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1141 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1143 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1144 Q_ASSERT(viewContainer
);
1146 m_activeViewContainer
= viewContainer
;
1148 if (oldViewContainer
) {
1149 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1150 toggleSearchAction
->disconnect(oldViewContainer
);
1152 // Disconnect all signals between the old view container (container,
1153 // view and url navigator) and main window.
1154 oldViewContainer
->disconnect(this);
1155 oldViewContainer
->view()->disconnect(this);
1156 oldViewContainer
->urlNavigator()->disconnect(this);
1158 // except the requestItemInfo so that on hover the information panel can still be updated
1159 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1160 this, &DolphinMainWindow::requestItemInfo
);
1163 connectViewSignals(viewContainer
);
1165 m_actionHandler
->setCurrentView(viewContainer
->view());
1168 updateFileAndEditActions();
1169 updatePasteAction();
1170 updateViewActions();
1172 updateSearchAction();
1174 const QUrl url
= viewContainer
->url();
1175 emit
urlChanged(url
);
1178 void DolphinMainWindow::tabCountChanged(int count
)
1180 const bool enableTabActions
= (count
> 1);
1181 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1182 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1185 void DolphinMainWindow::updateWindowTitle()
1187 const QString newTitle
= m_activeViewContainer
->caption();
1188 if (windowTitle() != newTitle
) {
1189 setWindowTitle(newTitle
);
1193 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1195 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1196 m_tearDownFromPlacesRequested
= true;
1197 m_terminalPanel
->goHome();
1198 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1200 m_placesPanel
->proceedWithTearDown();
1204 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1206 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1207 m_tearDownFromPlacesRequested
= false;
1208 m_terminalPanel
->goHome();
1212 void DolphinMainWindow::setupActions()
1214 // setup 'File' menu
1215 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1216 QMenu
* menu
= m_newFileMenu
->menu();
1217 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1218 menu
->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
1219 m_newFileMenu
->setDelayed(false);
1220 connect(menu
, &QMenu::aboutToShow
,
1221 this, &DolphinMainWindow::updateNewMenu
);
1223 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1224 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1225 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1226 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1227 "window just like this one with the current location and view."
1228 "<nl/>You can drag and drop items between windows."));
1229 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1231 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1232 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1233 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1234 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1235 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1236 "A tab is an additional view within this window. "
1237 "You can drag and drop items between tabs."));
1238 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
+ Qt::Key_T
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_N
});
1239 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1241 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1242 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1243 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1244 "to the Places panel."));
1245 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1247 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1248 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1249 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1250 "currently viewed tab. If no more tabs are left this window "
1251 "will close instead."));
1253 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1254 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1256 // setup 'Edit' menu
1257 KStandardAction::undo(this,
1258 &DolphinMainWindow::undo
,
1259 actionCollection());
1261 // i18n: This will be the last paragraph for the whatsthis for all three:
1262 // Cut, Copy and Paste
1263 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1264 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1265 "applications and are among the most used commands. That's why their "
1266 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1267 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1268 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1269 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1270 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1271 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1272 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1273 "the clipboard to a new location. The items will be removed from their "
1274 "initial location.") + cutCopyPastePara
);
1275 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1276 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1277 "items in your current selection to the <emphasis>clipboard</emphasis>."
1278 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1279 "from the clipboard to a new location.") + cutCopyPastePara
);
1280 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1281 // The text of the paste-action is modified dynamically by Dolphin
1282 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1283 // due to the long text, the text "Paste" is used:
1284 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1285 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1286 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1287 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1288 "action they are removed from their old location.") + cutCopyPastePara
);
1290 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1291 searchAction
->setText(i18n("Search..."));
1292 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1293 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1294 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1295 "There you can enter search terms and specify settings to find the "
1296 "objects you are looking for.</para><para>Use this help again on "
1297 "the find bar so we can have a look at it while the settings are "
1298 "explained.</para>"));
1300 // toggle_search acts as a copy of the main searchAction to be used mainly
1301 // in the toolbar, with no default shortcut attached, to avoid messing with
1302 // existing workflows (search bar always open and Ctrl-F to focus)
1303 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1304 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1305 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1306 toggleSearchAction
->setIcon(searchAction
->icon());
1307 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1308 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1309 toggleSearchAction
->setCheckable(true);
1311 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1312 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1313 "files and folders in the current location."));
1315 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1316 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1317 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1318 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1319 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1320 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_A
);
1321 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1323 // setup 'View' menu
1324 // (note that most of it is set up in DolphinViewActionHandler)
1326 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1327 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1328 "the folder view below into two autonomous views.</para><para>This "
1329 "way you can see two locations at once and move items between them "
1330 "quickly.</para>Click this again afterwards to recombine the views."));
1331 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1332 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1334 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1335 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
+ Qt::Key_S
);
1336 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1337 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1338 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1339 stashSplit
->setCheckable(false);
1340 stashSplit
->setVisible(KProtocolInfo::isKnownProtocol("stash"));
1341 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1343 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1345 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1346 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1347 stop
->setToolTip(i18nc("@info", "Stop loading"));
1348 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1349 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1350 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1352 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1353 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1354 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1355 "This toggles the <emphasis>Location Bar</emphasis> to be "
1356 "editable so you can directly enter a location you want to go to.<nl/>"
1357 "You can also switch to editing by clicking to the right of the "
1358 "location and switch back by confirming the edited location."));
1359 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1360 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1362 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1363 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1364 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1365 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1366 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1367 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1368 "This switches to editing the location and selects it "
1369 "so you can quickly enter a different location."));
1370 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
+ Qt::Key_L
);
1371 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1375 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1376 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1377 m_backAction
->setObjectName(backAction
->objectName());
1378 m_backAction
->setShortcuts(backAction
->shortcuts());
1380 m_backAction
->setDelayed(true);
1381 m_backAction
->setStickyMenu(false);
1382 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1383 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1384 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1385 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1387 auto backShortcuts
= m_backAction
->shortcuts();
1388 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1389 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1391 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1392 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1393 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1394 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1395 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1396 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1397 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1398 this, &DolphinMainWindow::closedTabsCountChanged
);
1400 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1401 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1402 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1403 "This returns you to the previously closed tab."));
1404 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_T
);
1405 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1406 undoCloseTab
->setEnabled(false);
1407 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1409 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1410 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1411 "the last change you made to files or folders.<nl/>"
1412 "Such changes include <interface>creating, renaming</interface> "
1413 "and <interface>moving</interface> them to a different location "
1414 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1415 "be undone will ask for your confirmation."));
1416 undoAction
->setEnabled(false); // undo should be disabled by default
1419 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1420 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1421 m_forwardAction
->setObjectName(forwardAction
->objectName());
1422 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1424 m_forwardAction
->setDelayed(true);
1425 m_forwardAction
->setStickyMenu(false);
1426 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1427 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1428 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1429 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1430 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1432 // enable middle-click to open in a new tab
1433 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1434 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1435 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1436 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1437 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1438 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1439 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1440 "<filename>Home</filename> folder.<nl/>Every user account "
1441 "has their own <filename>Home</filename> that contains their data "
1442 "including folders that contain personal application data."));
1444 // setup 'Tools' menu
1445 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1446 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1447 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1448 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1449 "There you can enter a text to filter the files and folders currently displayed. "
1450 "Only those that contain the text in their name will be kept in view."));
1451 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1452 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
+ Qt::Key_I
, Qt::Key_Slash
});
1453 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1455 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1456 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1457 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1458 compareFiles
->setEnabled(false);
1459 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1461 #ifdef HAVE_TERMINAL
1462 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1463 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1464 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1465 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1466 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1467 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1468 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
1469 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
+ Qt::Key_F4
);
1470 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1474 // setup 'Bookmarks' menu
1475 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1476 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1477 // Make the toolbar button version work properly on click
1478 bookmarkMenu
->setDelayed(false);
1479 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1480 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1482 // setup 'Settings' menu
1483 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1484 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1485 "This switches between having a <emphasis>Menubar</emphasis> "
1486 "and having a <interface>Control</interface> button. Both "
1487 "contain mostly the same commands and configuration options."));
1488 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1489 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1490 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1492 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1493 m_helpMenu
= new KHelpMenu(nullptr);
1494 m_helpMenu
->menu()->installEventFilter(this);
1495 // remove duplicate shortcuts
1496 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setShortcut(QKeySequence());
1497 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setShortcut(QKeySequence());
1499 // not in menu actions
1500 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1501 nextTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::Key_Tab
));
1503 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1504 prevTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_Tab
));
1506 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1507 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1508 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1509 activateNextTab
->setEnabled(false);
1510 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1511 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1513 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1514 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1515 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1516 activatePrevTab
->setEnabled(false);
1517 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1518 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1521 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1522 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1523 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1524 showTarget
->setEnabled(false);
1525 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1527 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1528 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1529 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1530 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1532 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1533 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1534 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1535 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1537 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1538 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1539 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1540 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1543 void DolphinMainWindow::setupDockWidgets()
1545 const bool lock
= GeneralSettings::lockPanels();
1547 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1548 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1549 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1550 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1551 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1552 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1553 "switches between having panels <emphasis>locked</emphasis> or "
1554 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1555 "dragged to the other side of the window and have a close "
1556 "button.<nl/>Locked panels are embedded more cleanly."));
1557 lockLayoutAction
->setActive(lock
);
1558 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1560 // Setup "Information"
1561 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1562 infoDock
->setLocked(lock
);
1563 infoDock
->setObjectName(QStringLiteral("infoDock"));
1564 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1567 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1568 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1569 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1570 infoDock
->setWidget(infoPanel
);
1572 QAction
* infoAction
= infoDock
->toggleViewAction();
1573 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1575 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1576 connect(this, &DolphinMainWindow::urlChanged
,
1577 infoPanel
, &InformationPanel::setUrl
);
1578 connect(this, &DolphinMainWindow::selectionChanged
,
1579 infoPanel
, &InformationPanel::setSelection
);
1580 connect(this, &DolphinMainWindow::requestItemInfo
,
1581 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1584 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1585 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1586 "hide panels like this go to <interface>Control|Panels</interface> "
1587 "or <interface>View|Panels</interface>.</para>");
1589 actionCollection()->action(QStringLiteral("show_information_panel"))
1590 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1591 "<emphasis>information</emphasis> panel at the right side of the "
1592 "window.</para><para>The panel provides in-depth information "
1593 "about the items your mouse is hovering over or about the selected "
1594 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1595 "For single items a preview of their contents is provided.</para>"));
1597 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1598 "provides in-depth information about the items your mouse is "
1599 "hovering over or about the selected items. Otherwise it informs "
1600 "you about the currently viewed folder.<nl/>For single items a "
1601 "preview of their contents is provided.</para><para>You can configure "
1602 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1605 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1606 foldersDock
->setLocked(lock
);
1607 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1608 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1609 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1610 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1611 foldersDock
->setWidget(foldersPanel
);
1613 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1614 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1616 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1617 connect(this, &DolphinMainWindow::urlChanged
,
1618 foldersPanel
, &FoldersPanel::setUrl
);
1619 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1620 this, &DolphinMainWindow::changeUrl
);
1621 connect(foldersPanel
, &FoldersPanel::folderMiddleClicked
,
1622 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1623 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1624 this, &DolphinMainWindow::showErrorMessage
);
1626 actionCollection()->action(QStringLiteral("show_folders_panel"))
1627 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1628 "<emphasis>folders</emphasis> panel at the left side of the window."
1629 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1630 "</emphasis> in a <emphasis>tree view</emphasis>."));
1631 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1632 "shows the folders of the <emphasis>file system</emphasis> in a "
1633 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1634 "there. Click the arrow to the left of a folder to see its subfolders. "
1635 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1638 #ifdef HAVE_TERMINAL
1639 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1640 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1641 terminalDock
->setLocked(lock
);
1642 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1643 m_terminalPanel
= new TerminalPanel(terminalDock
);
1644 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1645 terminalDock
->setWidget(m_terminalPanel
);
1647 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1648 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1649 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1650 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1651 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1652 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1654 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1655 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1657 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1658 connect(this, &DolphinMainWindow::urlChanged
,
1659 m_terminalPanel
, &TerminalPanel::setUrl
);
1661 if (GeneralSettings::version() < 200) {
1662 terminalDock
->hide();
1665 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1666 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1667 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1668 "<nl/>The location in the terminal will always match the folder "
1669 "view so you can navigate using either.</para><para>The terminal "
1670 "panel is not needed for basic computer usage but can be useful "
1671 "for advanced tasks. To learn more about terminals use the help "
1672 "in a standalone terminal application like Konsole.</para>"));
1673 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1674 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1675 "normal terminal but will match the location of the folder view "
1676 "so you can navigate using either.</para><para>The terminal panel "
1677 "is not needed for basic computer usage but can be useful for "
1678 "advanced tasks. To learn more about terminals use the help in a "
1679 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1683 if (GeneralSettings::version() < 200) {
1685 foldersDock
->hide();
1689 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1690 placesDock
->setLocked(lock
);
1691 placesDock
->setObjectName(QStringLiteral("placesDock"));
1692 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1694 m_placesPanel
= new PlacesPanel(placesDock
);
1695 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1696 placesDock
->setWidget(m_placesPanel
);
1698 QAction
*placesAction
= placesDock
->toggleViewAction();
1699 createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1701 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1702 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1703 this, &DolphinMainWindow::slotPlaceActivated
);
1704 connect(m_placesPanel
, &PlacesPanel::placeMiddleClicked
,
1705 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1706 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1707 this, &DolphinMainWindow::showErrorMessage
);
1708 connect(this, &DolphinMainWindow::urlChanged
,
1709 m_placesPanel
, &PlacesPanel::setUrl
);
1710 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1711 m_tabWidget
, &DolphinTabWidget::slotPlacesPanelVisibilityChanged
);
1712 connect(this, &DolphinMainWindow::settingsChanged
,
1713 m_placesPanel
, &PlacesPanel::readSettings
);
1714 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1715 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1716 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1717 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1718 m_tabWidget
->slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1720 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1721 actionShowAllPlaces
->setCheckable(true);
1722 actionShowAllPlaces
->setDisabled(true);
1723 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1724 "all places in the places panel that have been hidden. They will "
1725 "appear semi-transparent unless you uncheck their hide property."));
1727 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1728 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1729 m_placesPanel
->showHiddenEntries(checked
);
1732 connect(m_placesPanel
, &PlacesPanel::showHiddenEntriesChanged
, this, [actionShowAllPlaces
] (bool checked
){
1733 actionShowAllPlaces
->setChecked(checked
);
1734 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1737 actionCollection()->action(QStringLiteral("show_places_panel"))
1738 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1739 "<emphasis>places</emphasis> panel at the left side of the window."
1740 "</para><para>It allows you to go to locations you have "
1741 "bookmarked and to access disk or media attached to the computer "
1742 "or to the network. It also contains sections to find recently "
1743 "saved files or files of a certain type.</para>"));
1744 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1745 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1746 "you have bookmarked and to access disk or media attached to the "
1747 "computer or to the network. It also contains sections to find "
1748 "recently saved files or files of a certain type.</para><para>"
1749 "Click on an entry to go there. Click with the right mouse button "
1750 "instead to open any entry in a new tab or new window.</para>"
1751 "<para>New entries can be added by dragging folders onto this panel. "
1752 "Right-click any section or entry to hide it. Right-click an empty "
1753 "space on this panel and select <interface>Show Hidden Places"
1754 "</interface> to display it again.</para>") + panelWhatsThis
);
1756 // Add actions into the "Panels" menu
1757 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
1758 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
1759 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
1760 panelsMenu
->setDelayed(false);
1761 const KActionCollection
* ac
= actionCollection();
1762 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
1764 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
1766 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
1767 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
1768 panelsMenu
->addSeparator();
1769 panelsMenu
->addAction(actionShowAllPlaces
);
1770 panelsMenu
->addAction(lockLayoutAction
);
1772 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
1773 actionShowAllPlaces
->setEnabled(m_placesPanel
->hiddenListCount());
1778 void DolphinMainWindow::updateFileAndEditActions()
1780 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
1781 const KActionCollection
* col
= actionCollection();
1782 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
1784 if (list
.isEmpty()) {
1785 stateChanged(QStringLiteral("has_no_selection"));
1787 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer
->placesText()));
1789 stateChanged(QStringLiteral("has_selection"));
1791 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
1792 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
1793 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
1794 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
1795 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
1796 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
1798 if (list
.length() == 1 && list
.first().isDir()) {
1799 addToPlacesAction
->setEnabled(true);
1800 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list
.first().name()));
1802 addToPlacesAction
->setEnabled(false);
1803 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1806 KFileItemListProperties
capabilities(list
);
1807 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
1809 renameAction
->setEnabled(capabilities
.supportsMoving());
1810 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1811 deleteAction
->setEnabled(capabilities
.supportsDeleting());
1812 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
1813 cutAction
->setEnabled(capabilities
.supportsMoving());
1814 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
1818 void DolphinMainWindow::updateViewActions()
1820 m_actionHandler
->updateViewActions();
1822 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
1823 showFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
1825 updateSplitAction();
1827 QAction
* editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
1828 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
1829 editableLocactionAction
->setChecked(urlNavigator
->isUrlEditable());
1832 void DolphinMainWindow::updateGoActions()
1834 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
1835 const QUrl currentUrl
= m_activeViewContainer
->url();
1836 // I think this is one of the best places to firstly be confronted
1837 // with a file system and its hierarchy. Talking about the root
1838 // directory might seem too much here but it is the question that
1839 // naturally arises in this context.
1840 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
1841 "the folder that contains the currently viewed one.</para>"
1842 "<para>All files and folders are organized in a hierarchical "
1843 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
1844 "a directory that contains all data connected to this computer"
1845 "—the <emphasis>root directory</emphasis>.</para>"));
1846 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
1849 void DolphinMainWindow::createControlButton()
1851 if (m_controlButton
) {
1854 Q_ASSERT(!m_controlButton
);
1856 m_controlButton
= new QToolButton(this);
1857 m_controlButton
->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
1858 m_controlButton
->setToolTip(i18nc("@action", "Show menu"));
1859 m_controlButton
->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis
);
1860 m_controlButton
->setPopupMode(QToolButton::InstantPopup
);
1862 QMenu
* controlMenu
= new QMenu(m_controlButton
);
1863 connect(controlMenu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateControlMenu
);
1864 controlMenu
->installEventFilter(this);
1866 m_controlButton
->setMenu(controlMenu
);
1868 toolBar()->addWidget(m_controlButton
);
1869 connect(toolBar(), &KToolBar::iconSizeChanged
,
1870 m_controlButton
, &QToolButton::setIconSize
);
1872 // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
1873 // gets edited. In this case we must add them again. The adding is done asynchronously by
1874 // m_updateToolBarTimer.
1875 connect(m_controlButton
, &QToolButton::destroyed
, this, &DolphinMainWindow::slotControlButtonDeleted
);
1876 m_updateToolBarTimer
= new QTimer(this);
1877 m_updateToolBarTimer
->setInterval(500);
1878 connect(m_updateToolBarTimer
, &QTimer::timeout
, this, &DolphinMainWindow::updateToolBar
);
1881 void DolphinMainWindow::deleteControlButton()
1883 delete m_controlButton
;
1884 m_controlButton
= nullptr;
1886 delete m_updateToolBarTimer
;
1887 m_updateToolBarTimer
= nullptr;
1890 bool DolphinMainWindow::addActionToMenu(QAction
* action
, QMenu
* menu
)
1895 const KToolBar
* toolBarWidget
= toolBar();
1896 foreach (const QWidget
* widget
, action
->associatedWidgets()) {
1897 if (widget
== toolBarWidget
) {
1902 menu
->addAction(action
);
1906 void DolphinMainWindow::refreshViews()
1908 m_tabWidget
->refreshViews();
1910 if (GeneralSettings::modifiedStartupSettings()) {
1911 // The startup settings have been changed by the user (see bug #254947).
1912 // Synchronize the split-view setting with the active view:
1913 const bool splitView
= GeneralSettings::splitView();
1914 m_tabWidget
->currentTabPage()->setSplitViewEnabled(splitView
);
1915 updateSplitAction();
1916 updateWindowTitle();
1919 emit
settingsChanged();
1922 void DolphinMainWindow::clearStatusBar()
1924 m_activeViewContainer
->statusBar()->resetToDefaultText();
1927 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
1929 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
1930 this, &DolphinMainWindow::updateFilterBarAction
);
1931 connect(container
, &DolphinViewContainer::writeStateChanged
,
1932 this, &DolphinMainWindow::slotWriteStateChanged
);
1933 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
1934 this, &DolphinMainWindow::updateSearchAction
);
1936 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1937 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
1939 const DolphinView
* view
= container
->view();
1940 connect(view
, &DolphinView::selectionChanged
,
1941 this, &DolphinMainWindow::slotSelectionChanged
);
1942 connect(view
, &DolphinView::requestItemInfo
,
1943 this, &DolphinMainWindow::requestItemInfo
);
1944 connect(view
, &DolphinView::tabRequested
,
1945 this, &DolphinMainWindow::openNewTab
);
1946 connect(view
, &DolphinView::requestContextMenu
,
1947 this, &DolphinMainWindow::openContextMenu
);
1948 connect(view
, &DolphinView::directoryLoadingStarted
,
1949 this, &DolphinMainWindow::enableStopAction
);
1950 connect(view
, &DolphinView::directoryLoadingCompleted
,
1951 this, &DolphinMainWindow::disableStopAction
);
1952 connect(view
, &DolphinView::directoryLoadingCompleted
,
1953 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
1954 connect(view
, &DolphinView::goBackRequested
,
1955 this, &DolphinMainWindow::goBack
);
1956 connect(view
, &DolphinView::goForwardRequested
,
1957 this, &DolphinMainWindow::goForward
);
1958 connect(view
, &DolphinView::urlActivated
,
1959 this, &DolphinMainWindow::handleUrl
);
1961 const KUrlNavigator
* navigator
= container
->urlNavigator();
1962 connect(navigator
, &KUrlNavigator::urlChanged
,
1963 this, &DolphinMainWindow::changeUrl
);
1964 connect(navigator
, &KUrlNavigator::historyChanged
,
1965 this, &DolphinMainWindow::updateHistory
);
1966 connect(navigator
, &KUrlNavigator::editableStateChanged
,
1967 this, &DolphinMainWindow::slotEditableStateChanged
);
1968 connect(navigator
, &KUrlNavigator::tabRequested
,
1969 this, &DolphinMainWindow::openNewTabAfterLastTab
);
1972 void DolphinMainWindow::updateSplitAction()
1974 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
1975 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
1976 if (tabPage
->splitViewEnabled()) {
1977 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
1978 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
1979 splitAction
->setToolTip(i18nc("@info", "Close left view"));
1980 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
1982 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
1983 splitAction
->setToolTip(i18nc("@info", "Close right view"));
1984 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
1987 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
1988 splitAction
->setToolTip(i18nc("@info", "Split view"));
1989 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
1993 bool DolphinMainWindow::isKompareInstalled() const
1995 static bool initialized
= false;
1996 static bool installed
= false;
1998 // TODO: maybe replace this approach later by using a menu
1999 // plugin like kdiff3plugin.cpp
2000 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2006 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2007 const QKeySequence
& shortcut
,
2008 QAction
* dockAction
,
2009 const QString
& actionName
)
2011 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2012 panelAction
->setCheckable(true);
2013 panelAction
->setChecked(dockAction
->isChecked());
2014 panelAction
->setText(dockAction
->text());
2015 panelAction
->setIcon(icon
);
2016 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2018 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2019 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2022 void DolphinMainWindow::setupWhatsThis()
2025 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2026 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2027 "configuration options. Left-click on any of the menus on this "
2028 "bar to see its contents.</para><para>The Menubar can be hidden "
2029 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2030 "most of its contents become available through a <interface>Control"
2031 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2032 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2033 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2034 "frequently used actions.</para><para>It is highly customizable. "
2035 "All items you see in the <interface>Control</interface> menu or "
2036 "in the <interface>Menubar</interface> can be placed on the "
2037 "Toolbar. Just right-click on it and select <interface>Configure "
2038 "Toolbars…</interface> or find this action in the <interface>"
2039 "Control</interface> or <interface>Settings</interface> menu."
2040 "</para><para>The location of the bar and the style of its "
2041 "buttons can also be changed in the right-click menu. Right-click "
2042 "a button if you want to show or hide its text.</para>"));
2043 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2044 "<para>Here you can see the <emphasis>folders</emphasis> and "
2045 "<emphasis>files</emphasis> that are at the location described in "
2046 "the <interface>Location Bar</interface> above. This area is the "
2047 "central part of this application where you navigate to the files "
2048 "you want to use.</para><para>For an elaborate and general "
2049 "introduction to this application <link "
2050 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2051 "click here</link>. This will open an introductory article from "
2052 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2053 "explanations of all the features of this <emphasis>view</emphasis> "
2054 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2055 "instead. This will open a page from the <emphasis>Handbook"
2056 "</emphasis> that covers the basics.</para>"));
2059 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2060 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2061 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2062 "There you can set up key combinations to trigger an action when "
2063 "they are pressed simultaneously. All commands in this application can "
2064 "be triggered this way.</para>"));
2065 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2066 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2067 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2068 "<para>All items you see in the <interface>Control</interface> menu "
2069 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2070 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2071 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2072 "change a multitude of settings for this application. For an explanation "
2073 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2074 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2077 // The whatsthis has to be set for the m_helpMenu and for the
2078 // StandardAction separately because both are used in different locations.
2079 // m_helpMenu is only used for createControlButton() button.
2081 // Links do not work within the Menubar so texts without links are provided there.
2083 // i18n: If the external link isn't available in your language you should
2084 // probably state the external link language at least in brackets to not
2085 // frustrate the user. If there are multiple languages that the user might
2086 // know with a reasonable chance you might want to have 2 external links.
2087 // The same is in my opinion true for every external link you translate.
2088 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2089 "<para>This opens the Handbook for this application. It provides "
2090 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2091 actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents
))
2092 ->setWhatsThis(whatsThisHelpContents
2093 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2094 "<para>If you want more elaborate introductions to the "
2095 "different features of <emphasis>Dolphin</emphasis> "
2096 "go to the KDE UserBase Wiki.</para>"));
2097 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setWhatsThis(whatsThisHelpContents
2098 + xi18nc("@info:whatsthis second half of handbook text with link",
2099 "<para>If you want more elaborate introductions to the "
2100 "different features of <emphasis>Dolphin</emphasis> "
2101 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2102 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2104 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2105 "<para>This is the button that invokes the help feature you are "
2106 "using right now! Click it, then click any component of this "
2107 "application to ask \"What's this?\" about it. The mouse cursor "
2108 "will change appearance if no help is available for a spot.</para>");
2109 actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis
))
2110 ->setWhatsThis(whatsThisWhatsThis
2111 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2112 "<para>There are two other ways to get help for this application: The "
2113 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2114 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2115 "article about <emphasis>File Management</emphasis> online."
2116 "</para><para>The \"What's this?\" help is "
2117 "missing in most other windows so don't get too used to this.</para>"));
2118 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setWhatsThis(whatsThisWhatsThis
2119 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2120 "<para>There are two other ways to get help: "
2121 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2122 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2123 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2124 "missing in most other windows so don't get too used to this.</para>"));
2126 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2127 "window that will guide you through reporting errors or flaws "
2128 "in this application or in other KDE software.</para>");
2129 actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug
))
2130 ->setWhatsThis(whatsThisReportBug
);
2131 m_helpMenu
->action(KHelpMenu::menuReportBug
)->setWhatsThis(whatsThisReportBug
2132 + xi18nc("@info:whatsthis second half of reportbug text with link",
2133 "<para>High-quality bug reports are much appreciated. To learn "
2134 "how to make your bug report as effective as possible "
2135 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2136 "click here</link>.</para>"));
2138 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2139 "<emphasis>web page</emphasis> where you can donate to "
2140 "support the continued work on this application and many "
2141 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2142 "<para>Donating is the easiest and fastest way to efficiently "
2143 "support KDE and its projects. KDE projects are available for "
2144 "free therefore your donation is needed to cover things that "
2145 "require money like servers, contributor meetings, etc.</para>"
2146 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2147 "organization behind the KDE community.</para>");
2148 actionCollection()->action(KStandardAction::name(KStandardAction::Donate
))
2149 ->setWhatsThis(whatsThisDonate
);
2150 m_helpMenu
->action(KHelpMenu::menuDonate
)->setWhatsThis(whatsThisDonate
);
2152 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2153 "With this you can change the language this application uses."
2154 "<nl/>You can even set secondary languages which will be used "
2155 "if texts are not available in your preferred language.");
2156 actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
))
2157 ->setWhatsThis(whatsThisSwitchLanguage
);
2158 m_helpMenu
->action(KHelpMenu::menuSwitchLanguage
)->setWhatsThis(whatsThisSwitchLanguage
);
2160 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2161 "window that informs you about the version, license, "
2162 "used libraries and maintainers of this application.");
2163 actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp
))
2164 ->setWhatsThis(whatsThisAboutApp
);
2165 m_helpMenu
->action(KHelpMenu::menuAboutApp
)->setWhatsThis(whatsThisAboutApp
);
2167 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2168 "window with information about <emphasis>KDE</emphasis>. "
2169 "The KDE community are the people behind this free software."
2170 "<nl/>If you like using this application but don't know "
2171 "about KDE or want to see a cute dragon have a look!");
2172 actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE
))
2173 ->setWhatsThis(whatsThisAboutKDE
);
2174 m_helpMenu
->action(KHelpMenu::menuAboutKDE
)->setWhatsThis(whatsThisAboutKDE
);
2177 bool DolphinMainWindow::event(QEvent
*event
)
2179 if (event
->type() == QEvent::WhatsThisClicked
) {
2181 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2182 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2185 return KXmlGuiWindow::event(event
);
2188 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2191 if (event
->type() == QEvent::WhatsThisClicked
) {
2193 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2194 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2200 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2201 KIO::FileUndoManager::UiInterface()
2205 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2209 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2211 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2213 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2214 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2216 KIO::FileUndoManager::UiInterface::jobError(job
);
2220 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2222 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));