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;
96 // The maximum number of "Activate Tab" shortcuts
97 const int MaxActivateTabShortcuts
= 9;
100 DolphinMainWindow::DolphinMainWindow() :
101 KXmlGuiWindow(nullptr),
102 m_newFileMenu(nullptr),
104 m_tabWidget(nullptr),
105 m_activeViewContainer(nullptr),
106 m_actionHandler(nullptr),
107 m_remoteEncoding(nullptr),
109 m_bookmarkHandler(nullptr),
110 m_controlButton(nullptr),
111 m_updateToolBarTimer(nullptr),
112 m_lastHandleUrlStatJob(nullptr),
113 m_terminalPanel(nullptr),
114 m_placesPanel(nullptr),
115 m_tearDownFromPlacesRequested(false),
116 m_backAction(nullptr),
117 m_forwardAction(nullptr)
119 Q_INIT_RESOURCE(dolphin
);
121 setWindowFlags(Qt::WindowContextHelpButtonHint
);
123 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
124 setObjectName(QStringLiteral("Dolphin#"));
126 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
127 this, &DolphinMainWindow::showErrorMessage
);
129 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
130 undoManager
->setUiInterface(new UndoUiInterface());
132 connect(undoManager
, QOverload
<bool>::of(&KIO::FileUndoManager::undoAvailable
),
133 this, &DolphinMainWindow::slotUndoAvailable
);
134 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
135 this, &DolphinMainWindow::slotUndoTextChanged
);
136 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
137 this, &DolphinMainWindow::clearStatusBar
);
138 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
139 this, &DolphinMainWindow::showCommand
);
141 GeneralSettings
* generalSettings
= GeneralSettings::self();
142 const bool firstRun
= (generalSettings
->version() < 200);
144 generalSettings
->setViewPropsTimestamp(QDateTime::currentDateTime());
147 setAcceptDrops(true);
149 m_tabWidget
= new DolphinTabWidget(this);
150 m_tabWidget
->setObjectName("tabWidget");
151 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
152 this, &DolphinMainWindow::activeViewChanged
);
153 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
154 this, &DolphinMainWindow::tabCountChanged
);
155 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
156 this, &DolphinMainWindow::updateWindowTitle
);
157 setCentralWidget(m_tabWidget
);
161 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
162 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
163 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
165 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
166 connect(this, &DolphinMainWindow::urlChanged
,
167 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
171 setupGUI(Keys
| Save
| Create
| ToolBar
);
172 stateChanged(QStringLiteral("new_file"));
174 QClipboard
* clipboard
= QApplication::clipboard();
175 connect(clipboard
, &QClipboard::dataChanged
,
176 this, &DolphinMainWindow::updatePasteAction
);
178 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
179 showFilterBarAction
->setChecked(generalSettings
->filterBar());
182 menuBar()->setVisible(false);
183 // Assure a proper default size if Dolphin runs the first time
187 const bool showMenu
= !menuBar()->isHidden();
188 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
189 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
191 createControlButton();
194 // enable middle-click on back/forward/up to open in a new tab
195 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
196 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
197 toolBar()->installEventFilter(middleClickEventFilter
);
202 DolphinMainWindow::~DolphinMainWindow()
206 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
208 QVector
<DolphinViewContainer
*> viewContainers
;
209 viewContainers
.reserve(m_tabWidget
->count());
210 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
211 viewContainers
<< m_tabWidget
->tabPageAt(i
)->activeViewContainer();
213 return viewContainers
;
216 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
218 m_tabWidget
->openDirectories(dirs
, splitView
);
221 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
223 openDirectories(QUrl::fromStringList(dirs
), splitView
);
226 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
228 m_tabWidget
->openFiles(files
, splitView
);
231 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
233 openFiles(QUrl::fromStringList(files
), splitView
);
236 void DolphinMainWindow::activateWindow()
238 window()->setAttribute(Qt::WA_NativeWindow
, true);
239 KStartupInfo::setNewStartupId(window()->windowHandle(), KStartupInfo::startupId());
240 KWindowSystem::activateWindow(window()->effectiveWinId());
243 void DolphinMainWindow::showCommand(CommandType command
)
245 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
247 case KIO::FileUndoManager::Copy
:
248 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
250 case KIO::FileUndoManager::Move
:
251 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
253 case KIO::FileUndoManager::Link
:
254 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
256 case KIO::FileUndoManager::Trash
:
257 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
259 case KIO::FileUndoManager::Rename
:
260 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
263 case KIO::FileUndoManager::Mkdir
:
264 statusBar
->setText(i18nc("@info:status", "Created folder."));
272 void DolphinMainWindow::pasteIntoFolder()
274 m_activeViewContainer
->view()->pasteIntoFolder();
277 void DolphinMainWindow::changeUrl(const QUrl
&url
)
279 if (!KProtocolManager::supportsListing(url
)) {
280 // The URL navigator only checks for validity, not
281 // if the URL can be listed. An error message is
282 // shown due to DolphinViewContainer::restoreView().
286 m_activeViewContainer
->setUrl(url
);
287 updateFileAndEditActions();
292 emit
urlChanged(url
);
295 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
297 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
298 m_placesPanel
->proceedWithTearDown();
299 m_tearDownFromPlacesRequested
= false;
302 m_activeViewContainer
->setAutoGrabFocus(false);
304 m_activeViewContainer
->setAutoGrabFocus(true);
307 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
309 KToggleAction
* editableLocationAction
=
310 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
311 editableLocationAction
->setChecked(editable
);
314 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
316 updateFileAndEditActions();
318 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
320 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
321 if (selectedUrlsCount
== 2) {
322 compareFilesAction
->setEnabled(isKompareInstalled());
324 compareFilesAction
->setEnabled(false);
327 emit
selectionChanged(selection
);
330 void DolphinMainWindow::updateHistory()
332 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
333 const int index
= urlNavigator
->historyIndex();
335 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
337 backAction
->setToolTip(i18nc("@info", "Go back"));
338 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
339 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
342 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
344 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
345 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
346 "This undoes a <interface>Go|Back</interface> action."));
347 forwardAction
->setEnabled(index
> 0);
351 void DolphinMainWindow::updateFilterBarAction(bool show
)
353 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
354 showFilterBarAction
->setChecked(show
);
357 void DolphinMainWindow::openNewMainWindow()
359 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
362 void DolphinMainWindow::openNewActivatedTab()
364 m_tabWidget
->openNewActivatedTab();
367 void DolphinMainWindow::addToPlaces()
372 // If nothing is selected, act on the current dir
373 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
374 url
= m_activeViewContainer
->url();
375 name
= m_activeViewContainer
->placesText();
377 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
378 url
= dirToAdd
.url();
379 name
= dirToAdd
.name();
382 PlacesItemModel model
;
384 if (m_activeViewContainer
->isSearchModeEnabled()) {
385 icon
= QStringLiteral("folder-saved-search-symbolic");
387 icon
= KIO::iconNameForUrl(url
);
389 model
.createPlacesItem(name
, url
, icon
);
393 void DolphinMainWindow::openNewTab(const QUrl
& url
, DolphinTabWidget::TabPlacement tabPlacement
)
395 m_tabWidget
->openNewTab(url
, QUrl(), tabPlacement
);
398 void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl
& url
)
400 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterCurrentTab
);
403 void DolphinMainWindow::openNewTabAfterLastTab(const QUrl
& url
)
405 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterLastTab
);
408 void DolphinMainWindow::openInNewTab()
410 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
411 bool tabCreated
= false;
413 foreach (const KFileItem
& item
, list
) {
414 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
415 if (!url
.isEmpty()) {
416 openNewTabAfterCurrentTab(url
);
421 // if no new tab has been created from the selection
422 // open the current directory in a new tab
424 openNewTabAfterCurrentTab(m_activeViewContainer
->url());
428 void DolphinMainWindow::openInNewWindow()
432 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
433 if (list
.isEmpty()) {
434 newWindowUrl
= m_activeViewContainer
->url();
435 } else if (list
.count() == 1) {
436 const KFileItem
& item
= list
.first();
437 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
440 if (!newWindowUrl
.isEmpty()) {
441 Dolphin::openNewWindow({newWindowUrl
}, this);
445 void DolphinMainWindow::showTarget()
447 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
448 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
449 auto linkDestination
= link
.linkDest();
450 if (QFileInfo(linkDestination
).isRelative()) {
451 linkDestination
= linkLocationDir
.filePath(linkDestination
);
453 if (QFileInfo::exists(linkDestination
)) {
454 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
456 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
457 DolphinViewContainer::Warning
);
461 void DolphinMainWindow::showEvent(QShowEvent
* event
)
463 KXmlGuiWindow::showEvent(event
);
465 if (!event
->spontaneous()) {
466 m_activeViewContainer
->view()->setFocus();
470 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
472 // Find out if Dolphin is closed directly by the user or
473 // by the session manager because the session is closed
474 bool closedByUser
= true;
475 if (qApp
->isSavingSession()) {
476 closedByUser
= false;
479 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser
) {
480 // Ask the user if he really wants to quit and close all tabs.
481 // Open a confirmation dialog with 3 buttons:
482 // QDialogButtonBox::Yes -> Quit
483 // QDialogButtonBox::No -> Close only the current tab
484 // QDialogButtonBox::Cancel -> do nothing
485 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
486 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
487 dialog
->setModal(true);
488 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
489 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
490 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
491 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
492 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
494 bool doNotAskAgainCheckboxResult
= false;
496 const auto result
= KMessageBox::createKMessageBox(dialog
,
498 QMessageBox::Warning
,
499 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
501 i18n("Do not ask again"),
502 &doNotAskAgainCheckboxResult
,
503 KMessageBox::Notify
);
505 if (doNotAskAgainCheckboxResult
) {
506 GeneralSettings::setConfirmClosingMultipleTabs(false);
510 case QDialogButtonBox::Yes
:
513 case QDialogButtonBox::No
:
514 // Close only the current tab
515 m_tabWidget
->closeTab();
523 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
524 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
525 // Open a confirmation dialog with 3 buttons:
526 // QDialogButtonBox::Yes -> Quit
527 // QDialogButtonBox::No -> Show Terminal Panel
528 // QDialogButtonBox::Cancel -> do nothing
529 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
530 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
531 dialog
->setModal(true);
532 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
533 if (!m_terminalPanel
->isVisible()) {
534 standardButtons
|= QDialogButtonBox::No
;
536 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
537 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
538 if (!m_terminalPanel
->isVisible()) {
540 buttons
->button(QDialogButtonBox::No
),
541 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
543 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
545 bool doNotAskAgainCheckboxResult
= false;
547 const auto result
= KMessageBox::createKMessageBox(
550 QMessageBox::Warning
,
551 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
553 i18n("Do not ask again"),
554 &doNotAskAgainCheckboxResult
,
555 KMessageBox::Dangerous
);
557 if (doNotAskAgainCheckboxResult
) {
558 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
562 case QDialogButtonBox::Yes
:
565 case QDialogButtonBox::No
:
566 actionCollection()->action("show_terminal_panel")->trigger();
567 // Do not quit, ignore quit event
575 GeneralSettings::setVersion(CurrentDolphinVersion
);
576 GeneralSettings::self()->save();
578 KXmlGuiWindow::closeEvent(event
);
581 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
583 m_tabWidget
->saveProperties(group
);
586 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
588 m_tabWidget
->readProperties(group
);
591 void DolphinMainWindow::updateNewMenu()
593 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
594 m_newFileMenu
->checkUpToDate();
595 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
598 void DolphinMainWindow::createDirectory()
600 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
601 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
602 m_newFileMenu
->createDirectory();
605 void DolphinMainWindow::quit()
610 void DolphinMainWindow::showErrorMessage(const QString
& message
)
612 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
615 void DolphinMainWindow::slotUndoAvailable(bool available
)
617 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
619 undoAction
->setEnabled(available
);
623 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
625 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
627 undoAction
->setText(text
);
631 void DolphinMainWindow::undo()
634 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
635 KIO::FileUndoManager::self()->undo();
638 void DolphinMainWindow::cut()
640 m_activeViewContainer
->view()->cutSelectedItems();
643 void DolphinMainWindow::copy()
645 m_activeViewContainer
->view()->copySelectedItems();
648 void DolphinMainWindow::paste()
650 m_activeViewContainer
->view()->paste();
653 void DolphinMainWindow::find()
655 m_activeViewContainer
->setSearchModeEnabled(true);
658 void DolphinMainWindow::updateSearchAction()
660 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
661 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
664 void DolphinMainWindow::updatePasteAction()
666 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
667 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
668 pasteAction
->setEnabled(pasteInfo
.first
);
669 pasteAction
->setText(pasteInfo
.second
);
672 void DolphinMainWindow::slotDirectoryLoadingCompleted()
677 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
679 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
681 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
683 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
685 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
690 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
692 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
694 m_backAction
->menu()->clear();
695 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
696 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_backAction
->menu());
698 m_backAction
->menu()->addAction(action
);
702 void DolphinMainWindow::slotGoBack(QAction
* action
)
704 int gotoIndex
= action
->data().value
<int>();
705 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
706 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
711 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
714 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
715 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
719 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
721 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
723 m_forwardAction
->menu()->clear();
724 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
725 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
727 m_forwardAction
->menu()->addAction(action
);
731 void DolphinMainWindow::slotGoForward(QAction
* action
)
733 int gotoIndex
= action
->data().value
<int>();
734 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
735 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
740 void DolphinMainWindow::selectAll()
744 // if the URL navigator is editable and focused, select the whole
745 // URL instead of all items of the view
747 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
748 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
749 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
750 lineEdit
->hasFocus();
752 lineEdit
->selectAll();
754 m_activeViewContainer
->view()->selectAll();
758 void DolphinMainWindow::invertSelection()
761 m_activeViewContainer
->view()->invertSelection();
764 void DolphinMainWindow::toggleSplitView()
766 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
767 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled());
772 void DolphinMainWindow::toggleSplitStash()
774 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
775 tabPage
->setSplitViewEnabled(false);
776 tabPage
->setSplitViewEnabled(true, QUrl("stash:/"));
779 void DolphinMainWindow::reloadView()
782 m_activeViewContainer
->reload();
783 m_activeViewContainer
->statusBar()->updateSpaceInfo();
786 void DolphinMainWindow::stopLoading()
788 m_activeViewContainer
->view()->stopLoading();
791 void DolphinMainWindow::enableStopAction()
793 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
796 void DolphinMainWindow::disableStopAction()
798 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
801 void DolphinMainWindow::showFilterBar()
803 m_activeViewContainer
->setFilterBarVisible(true);
806 void DolphinMainWindow::toggleEditLocation()
810 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
811 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
812 urlNavigator
->setUrlEditable(action
->isChecked());
815 void DolphinMainWindow::replaceLocation()
817 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
818 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
820 // If the text field currently has focus and everything is selected,
821 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
822 if (navigator
->isUrlEditable()
823 && lineEdit
->hasFocus()
824 && lineEdit
->selectedText() == lineEdit
->text() ) {
825 navigator
->setUrlEditable(false);
827 navigator
->setUrlEditable(true);
828 navigator
->setFocus();
829 lineEdit
->selectAll();
833 void DolphinMainWindow::togglePanelLockState()
835 const bool newLockState
= !GeneralSettings::lockPanels();
836 foreach (QObject
* child
, children()) {
837 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
839 dock
->setLocked(newLockState
);
843 GeneralSettings::setLockPanels(newLockState
);
846 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
848 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
849 m_activeViewContainer
->view()->setFocus();
853 void DolphinMainWindow::goBack()
855 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
856 urlNavigator
->goBack();
858 if (urlNavigator
->locationState().isEmpty()) {
859 // An empty location state indicates a redirection URL,
860 // which must be skipped too
861 urlNavigator
->goBack();
865 void DolphinMainWindow::goForward()
867 m_activeViewContainer
->urlNavigator()->goForward();
870 void DolphinMainWindow::goUp()
872 m_activeViewContainer
->urlNavigator()->goUp();
875 void DolphinMainWindow::goHome()
877 m_activeViewContainer
->urlNavigator()->goHome();
880 void DolphinMainWindow::goBackInNewTab()
882 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
883 const int index
= urlNavigator
->historyIndex() + 1;
884 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
887 void DolphinMainWindow::goForwardInNewTab()
889 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
890 const int index
= urlNavigator
->historyIndex() - 1;
891 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
894 void DolphinMainWindow::goUpInNewTab()
896 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
897 openNewTabAfterCurrentTab(KIO::upUrl(currentUrl
));
900 void DolphinMainWindow::goHomeInNewTab()
902 openNewTabAfterCurrentTab(Dolphin::homeUrl());
905 void DolphinMainWindow::compareFiles()
907 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
908 if (items
.count() != 2) {
909 // The action is disabled in this case, but it could have been triggered
910 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
914 QUrl urlA
= items
.at(0).url();
915 QUrl urlB
= items
.at(1).url();
917 QString
command(QStringLiteral("kompare -c \""));
918 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
919 command
.append("\" \"");
920 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
921 command
.append('\"');
922 KRun::runCommand(command
, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
925 void DolphinMainWindow::toggleShowMenuBar()
927 const bool visible
= menuBar()->isVisible();
928 menuBar()->setVisible(!visible
);
930 createControlButton();
932 deleteControlButton();
936 void DolphinMainWindow::openTerminal()
938 QString
dir(QDir::homePath());
940 // If the given directory is not local, it can still be the URL of an
941 // ioslave using UDS_LOCAL_PATH which to be converted first.
942 KIO::StatJob
* statJob
= KIO::mostLocalUrl(m_activeViewContainer
->url());
943 KJobWidgets::setWindow(statJob
, this);
945 QUrl url
= statJob
->mostLocalUrl();
947 //If the URL is local after the above conversion, set the directory.
948 if (url
.isLocalFile()) {
949 dir
= url
.toLocalFile();
952 KToolInvocation::invokeTerminal(QString(), dir
);
955 void DolphinMainWindow::editSettings()
957 if (!m_settingsDialog
) {
958 DolphinViewContainer
* container
= activeViewContainer();
959 container
->view()->writeSettings();
961 const QUrl url
= container
->url();
962 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this);
963 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
964 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
965 settingsDialog
->show();
966 m_settingsDialog
= settingsDialog
;
968 m_settingsDialog
.data()->raise();
972 void DolphinMainWindow::handleUrl(const QUrl
& url
)
974 delete m_lastHandleUrlStatJob
;
975 m_lastHandleUrlStatJob
= nullptr;
977 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
978 activeViewContainer()->setUrl(url
);
979 } else if (KProtocolManager::supportsListing(url
)) {
980 // stat the URL to see if it is a dir or not
981 m_lastHandleUrlStatJob
= KIO::stat(url
, KIO::HideProgressInfo
);
982 if (m_lastHandleUrlStatJob
->uiDelegate()) {
983 KJobWidgets::setWindow(m_lastHandleUrlStatJob
, this);
985 connect(m_lastHandleUrlStatJob
, &KIO::Job::result
,
986 this, &DolphinMainWindow::slotHandleUrlStatFinished
);
989 new KRun(url
, this); // Automatically deletes itself after being finished
993 void DolphinMainWindow::slotHandleUrlStatFinished(KJob
* job
)
995 m_lastHandleUrlStatJob
= nullptr;
996 const KIO::UDSEntry entry
= static_cast<KIO::StatJob
*>(job
)->statResult();
997 const QUrl url
= static_cast<KIO::StatJob
*>(job
)->url();
999 activeViewContainer()->setUrl(url
);
1001 new KRun(url
, this); // Automatically deletes itself after being finished
1005 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1007 // trash:/ is writable but we don't want to create new items in it.
1008 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1009 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1012 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1013 const KFileItem
& item
,
1015 const QList
<QAction
*>& customActions
)
1017 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
);
1018 contextMenu
.data()->setCustomActions(customActions
);
1019 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1022 case DolphinContextMenu::OpenParentFolder
:
1023 changeUrl(KIO::upUrl(item
.url()));
1024 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1025 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1028 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1029 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1032 case DolphinContextMenu::OpenParentFolderInNewTab
:
1033 openNewTabAfterLastTab(KIO::upUrl(item
.url()));
1036 case DolphinContextMenu::None
:
1041 // Delete the menu, unless it has been deleted in its own nested event loop already.
1043 contextMenu
->deleteLater();
1047 void DolphinMainWindow::updateControlMenu()
1049 QMenu
* menu
= qobject_cast
<QMenu
*>(sender());
1052 // All actions get cleared by QMenu::clear(). This includes the sub-menus
1053 // because 'menu' is their parent.
1056 KActionCollection
* ac
= actionCollection();
1058 menu
->addMenu(m_newFileMenu
->menu());
1059 addActionToMenu(ac
->action(QStringLiteral("file_new")), menu
);
1060 addActionToMenu(ac
->action(QStringLiteral("new_tab")), menu
);
1061 addActionToMenu(ac
->action(QStringLiteral("closed_tabs")), menu
);
1063 menu
->addSeparator();
1065 // Add "Edit" actions
1066 bool added
= addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Undo
)), menu
) |
1067 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::SelectAll
)), menu
) |
1068 addActionToMenu(ac
->action(QStringLiteral("invert_selection")), menu
);
1071 menu
->addSeparator();
1074 // Add "View" actions
1075 if (!GeneralSettings::showZoomSlider()) {
1076 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomIn
)), menu
);
1077 addActionToMenu(ac
->action(QStringLiteral("view_zoom_reset")), menu
);
1078 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomOut
)), menu
);
1079 menu
->addSeparator();
1082 added
= addActionToMenu(ac
->action(QStringLiteral("show_preview")), menu
) |
1083 addActionToMenu(ac
->action(QStringLiteral("show_in_groups")), menu
) |
1084 addActionToMenu(ac
->action(QStringLiteral("show_hidden_files")), menu
) |
1085 addActionToMenu(ac
->action(QStringLiteral("additional_info")), menu
) |
1086 addActionToMenu(ac
->action(QStringLiteral("view_properties")), menu
);
1089 menu
->addSeparator();
1092 // Add a curated assortment of items from the "Tools" menu
1093 addActionToMenu(ac
->action(QStringLiteral("show_filter_bar")), menu
);
1094 addActionToMenu(ac
->action(QStringLiteral("open_terminal")), menu
);
1096 menu
->addSeparator();
1098 // Add "Show Panels" menu
1099 addActionToMenu(ac
->action(QStringLiteral("panels")), menu
);
1101 // Add "Settings" menu entries
1102 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)), menu
);
1103 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)), menu
);
1104 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Preferences
)), menu
);
1105 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)), menu
);
1108 auto helpMenu
= m_helpMenu
->menu();
1109 helpMenu
->setIcon(QIcon::fromTheme(QStringLiteral("system-help")));
1110 menu
->addMenu(helpMenu
);
1113 void DolphinMainWindow::updateToolBar()
1115 if (!menuBar()->isVisible()) {
1116 createControlButton();
1120 void DolphinMainWindow::slotControlButtonDeleted()
1122 m_controlButton
= nullptr;
1123 m_updateToolBarTimer
->start();
1126 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1128 DolphinViewContainer
* view
= activeViewContainer();
1130 if (view
->url() == url
) {
1131 // We can end up here if the user clicked a device in the Places Panel
1132 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1139 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1141 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1144 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1146 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1147 Q_ASSERT(viewContainer
);
1149 m_activeViewContainer
= viewContainer
;
1151 if (oldViewContainer
) {
1152 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1153 toggleSearchAction
->disconnect(oldViewContainer
);
1155 // Disconnect all signals between the old view container (container,
1156 // view and url navigator) and main window.
1157 oldViewContainer
->disconnect(this);
1158 oldViewContainer
->view()->disconnect(this);
1159 oldViewContainer
->urlNavigator()->disconnect(this);
1161 // except the requestItemInfo so that on hover the information panel can still be updated
1162 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1163 this, &DolphinMainWindow::requestItemInfo
);
1166 connectViewSignals(viewContainer
);
1168 m_actionHandler
->setCurrentView(viewContainer
->view());
1171 updateFileAndEditActions();
1172 updatePasteAction();
1173 updateViewActions();
1175 updateSearchAction();
1177 const QUrl url
= viewContainer
->url();
1178 emit
urlChanged(url
);
1181 void DolphinMainWindow::tabCountChanged(int count
)
1183 const bool enableTabActions
= (count
> 1);
1184 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1185 actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i
))->setEnabled(enableTabActions
);
1187 actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions
);
1188 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1189 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1192 void DolphinMainWindow::updateWindowTitle()
1194 const QString newTitle
= m_activeViewContainer
->caption();
1195 if (windowTitle() != newTitle
) {
1196 setWindowTitle(newTitle
);
1200 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1202 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1203 m_tearDownFromPlacesRequested
= true;
1204 m_terminalPanel
->goHome();
1205 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1207 m_placesPanel
->proceedWithTearDown();
1211 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1213 if (m_terminalPanel
&& m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1214 m_tearDownFromPlacesRequested
= false;
1215 m_terminalPanel
->goHome();
1219 void DolphinMainWindow::setupActions()
1221 // setup 'File' menu
1222 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1223 QMenu
* menu
= m_newFileMenu
->menu();
1224 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1225 menu
->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
1226 m_newFileMenu
->setDelayed(false);
1227 connect(menu
, &QMenu::aboutToShow
,
1228 this, &DolphinMainWindow::updateNewMenu
);
1230 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1231 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1232 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1233 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1234 "window just like this one with the current location and view."
1235 "<nl/>You can drag and drop items between windows."));
1236 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1238 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1239 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1240 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1241 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1242 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1243 "A tab is an additional view within this window. "
1244 "You can drag and drop items between tabs."));
1245 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
+ Qt::Key_T
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_N
});
1246 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1248 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1249 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1250 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1251 "to the Places panel."));
1252 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1254 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1255 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1256 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1257 "currently viewed tab. If no more tabs are left this window "
1258 "will close instead."));
1260 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1261 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1263 // setup 'Edit' menu
1264 KStandardAction::undo(this,
1265 &DolphinMainWindow::undo
,
1266 actionCollection());
1268 // i18n: This will be the last paragraph for the whatsthis for all three:
1269 // Cut, Copy and Paste
1270 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1271 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1272 "applications and are among the most used commands. That's why their "
1273 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1274 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1275 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1276 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1277 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1278 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1279 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1280 "the clipboard to a new location. The items will be removed from their "
1281 "initial location.") + cutCopyPastePara
);
1282 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1283 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1284 "items in your current selection to the <emphasis>clipboard</emphasis>."
1285 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1286 "from the clipboard to a new location.") + cutCopyPastePara
);
1287 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1288 // The text of the paste-action is modified dynamically by Dolphin
1289 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1290 // due to the long text, the text "Paste" is used:
1291 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1292 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1293 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1294 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1295 "action they are removed from their old location.") + cutCopyPastePara
);
1297 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1298 searchAction
->setText(i18n("Search..."));
1299 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1300 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1301 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1302 "There you can enter search terms and specify settings to find the "
1303 "objects you are looking for.</para><para>Use this help again on "
1304 "the find bar so we can have a look at it while the settings are "
1305 "explained.</para>"));
1307 // toggle_search acts as a copy of the main searchAction to be used mainly
1308 // in the toolbar, with no default shortcut attached, to avoid messing with
1309 // existing workflows (search bar always open and Ctrl-F to focus)
1310 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1311 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1312 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1313 toggleSearchAction
->setIcon(searchAction
->icon());
1314 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1315 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1316 toggleSearchAction
->setCheckable(true);
1318 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1319 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1320 "files and folders in the current location."));
1322 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1323 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1324 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1325 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1326 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1327 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_A
);
1328 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1330 // setup 'View' menu
1331 // (note that most of it is set up in DolphinViewActionHandler)
1333 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1334 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1335 "the folder view below into two autonomous views.</para><para>This "
1336 "way you can see two locations at once and move items between them "
1337 "quickly.</para>Click this again afterwards to recombine the views."));
1338 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1339 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1341 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1342 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
+ Qt::Key_S
);
1343 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1344 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1345 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1346 stashSplit
->setCheckable(false);
1347 stashSplit
->setVisible(KProtocolInfo::isKnownProtocol("stash"));
1348 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1350 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1352 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1353 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1354 stop
->setToolTip(i18nc("@info", "Stop loading"));
1355 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1356 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1357 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1359 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1360 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1361 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1362 "This toggles the <emphasis>Location Bar</emphasis> to be "
1363 "editable so you can directly enter a location you want to go to.<nl/>"
1364 "You can also switch to editing by clicking to the right of the "
1365 "location and switch back by confirming the edited location."));
1366 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1367 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1369 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1370 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1371 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1372 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1373 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1374 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1375 "This switches to editing the location and selects it "
1376 "so you can quickly enter a different location."));
1377 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
+ Qt::Key_L
);
1378 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1382 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1383 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1384 m_backAction
->setObjectName(backAction
->objectName());
1385 m_backAction
->setShortcuts(backAction
->shortcuts());
1387 m_backAction
->setDelayed(true);
1388 m_backAction
->setStickyMenu(false);
1389 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1390 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1391 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1392 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1394 auto backShortcuts
= m_backAction
->shortcuts();
1395 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1396 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1398 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1399 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1400 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1401 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1402 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1403 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1404 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1405 this, &DolphinMainWindow::closedTabsCountChanged
);
1407 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1408 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1409 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1410 "This returns you to the previously closed tab."));
1411 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_T
);
1412 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1413 undoCloseTab
->setEnabled(false);
1414 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1416 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1417 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1418 "the last change you made to files or folders.<nl/>"
1419 "Such changes include <interface>creating, renaming</interface> "
1420 "and <interface>moving</interface> them to a different location "
1421 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1422 "be undone will ask for your confirmation."));
1423 undoAction
->setEnabled(false); // undo should be disabled by default
1426 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1427 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1428 m_forwardAction
->setObjectName(forwardAction
->objectName());
1429 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1431 m_forwardAction
->setDelayed(true);
1432 m_forwardAction
->setStickyMenu(false);
1433 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1434 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1435 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1436 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1437 actionCollection()->setDefaultShortcuts(m_forwardAction
, m_forwardAction
->shortcuts());
1439 // enable middle-click to open in a new tab
1440 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1441 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1442 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1443 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1444 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1445 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1446 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1447 "<filename>Home</filename> folder.<nl/>Every user account "
1448 "has their own <filename>Home</filename> that contains their data "
1449 "including folders that contain personal application data."));
1451 // setup 'Tools' menu
1452 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1453 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1454 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1455 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1456 "There you can enter a text to filter the files and folders currently displayed. "
1457 "Only those that contain the text in their name will be kept in view."));
1458 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1459 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
+ Qt::Key_I
, Qt::Key_Slash
});
1460 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1462 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1463 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1464 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1465 compareFiles
->setEnabled(false);
1466 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1468 #ifdef HAVE_TERMINAL
1469 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1470 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1471 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1472 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1473 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1474 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1475 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
1476 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
+ Qt::Key_F4
);
1477 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1481 // setup 'Bookmarks' menu
1482 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1483 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1484 // Make the toolbar button version work properly on click
1485 bookmarkMenu
->setDelayed(false);
1486 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1487 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1489 // setup 'Settings' menu
1490 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1491 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1492 "This switches between having a <emphasis>Menubar</emphasis> "
1493 "and having a <interface>Control</interface> button. Both "
1494 "contain mostly the same commands and configuration options."));
1495 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1496 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1497 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1499 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1500 m_helpMenu
= new KHelpMenu(nullptr);
1501 m_helpMenu
->menu()->installEventFilter(this);
1502 // remove duplicate shortcuts
1503 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setShortcut(QKeySequence());
1504 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setShortcut(QKeySequence());
1506 // not in menu actions
1507 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1508 nextTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::Key_Tab
));
1510 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1511 prevTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_Tab
));
1513 for (int i
= 0; i
< MaxActivateTabShortcuts
; ++i
) {
1514 QAction
* activateTab
= actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i
));
1515 activateTab
->setText(i18nc("@action:inmenu", "Activate Tab %1", i
+ 1));
1516 activateTab
->setEnabled(false);
1517 connect(activateTab
, &QAction::triggered
, this, [this, i
]() { m_tabWidget
->activateTab(i
); });
1519 // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
1521 actionCollection()->setDefaultShortcut(activateTab
, QStringLiteral("Alt+%1").arg(i
+ 1));
1525 QAction
* activateLastTab
= actionCollection()->addAction(QStringLiteral("activate_last_tab"));
1526 activateLastTab
->setText(i18nc("@action:inmenu", "Activate Last Tab"));
1527 activateLastTab
->setEnabled(false);
1528 connect(activateLastTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateLastTab
);
1529 actionCollection()->setDefaultShortcut(activateLastTab
, Qt::ALT
+ Qt::Key_0
);
1531 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1532 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1533 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1534 activateNextTab
->setEnabled(false);
1535 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1536 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1538 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1539 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1540 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1541 activatePrevTab
->setEnabled(false);
1542 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1543 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1546 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1547 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1548 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1549 showTarget
->setEnabled(false);
1550 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1552 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1553 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1554 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1555 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1557 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1558 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1559 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1560 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1562 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1563 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1564 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1565 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1568 void DolphinMainWindow::setupDockWidgets()
1570 const bool lock
= GeneralSettings::lockPanels();
1572 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1573 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1574 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1575 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1576 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1577 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1578 "switches between having panels <emphasis>locked</emphasis> or "
1579 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1580 "dragged to the other side of the window and have a close "
1581 "button.<nl/>Locked panels are embedded more cleanly."));
1582 lockLayoutAction
->setActive(lock
);
1583 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1585 // Setup "Information"
1586 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1587 infoDock
->setLocked(lock
);
1588 infoDock
->setObjectName(QStringLiteral("infoDock"));
1589 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1592 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1593 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1594 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1595 infoDock
->setWidget(infoPanel
);
1597 QAction
* infoAction
= infoDock
->toggleViewAction();
1598 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1600 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1601 connect(this, &DolphinMainWindow::urlChanged
,
1602 infoPanel
, &InformationPanel::setUrl
);
1603 connect(this, &DolphinMainWindow::selectionChanged
,
1604 infoPanel
, &InformationPanel::setSelection
);
1605 connect(this, &DolphinMainWindow::requestItemInfo
,
1606 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1609 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1610 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1611 "hide panels like this go to <interface>Control|Panels</interface> "
1612 "or <interface>View|Panels</interface>.</para>");
1614 actionCollection()->action(QStringLiteral("show_information_panel"))
1615 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1616 "<emphasis>information</emphasis> panel at the right side of the "
1617 "window.</para><para>The panel provides in-depth information "
1618 "about the items your mouse is hovering over or about the selected "
1619 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1620 "For single items a preview of their contents is provided.</para>"));
1622 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1623 "provides in-depth information about the items your mouse is "
1624 "hovering over or about the selected items. Otherwise it informs "
1625 "you about the currently viewed folder.<nl/>For single items a "
1626 "preview of their contents is provided.</para><para>You can configure "
1627 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1630 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1631 foldersDock
->setLocked(lock
);
1632 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1633 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1634 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1635 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1636 foldersDock
->setWidget(foldersPanel
);
1638 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1639 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1641 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1642 connect(this, &DolphinMainWindow::urlChanged
,
1643 foldersPanel
, &FoldersPanel::setUrl
);
1644 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1645 this, &DolphinMainWindow::changeUrl
);
1646 connect(foldersPanel
, &FoldersPanel::folderMiddleClicked
,
1647 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1648 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1649 this, &DolphinMainWindow::showErrorMessage
);
1651 actionCollection()->action(QStringLiteral("show_folders_panel"))
1652 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1653 "<emphasis>folders</emphasis> panel at the left side of the window."
1654 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1655 "</emphasis> in a <emphasis>tree view</emphasis>."));
1656 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1657 "shows the folders of the <emphasis>file system</emphasis> in a "
1658 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1659 "there. Click the arrow to the left of a folder to see its subfolders. "
1660 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1663 #ifdef HAVE_TERMINAL
1664 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1665 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1666 terminalDock
->setLocked(lock
);
1667 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1668 m_terminalPanel
= new TerminalPanel(terminalDock
);
1669 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1670 terminalDock
->setWidget(m_terminalPanel
);
1672 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1673 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1674 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1675 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1676 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1677 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1679 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1680 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1682 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1683 connect(this, &DolphinMainWindow::urlChanged
,
1684 m_terminalPanel
, &TerminalPanel::setUrl
);
1686 if (GeneralSettings::version() < 200) {
1687 terminalDock
->hide();
1690 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1691 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1692 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1693 "<nl/>The location in the terminal will always match the folder "
1694 "view so you can navigate using either.</para><para>The terminal "
1695 "panel is not needed for basic computer usage but can be useful "
1696 "for advanced tasks. To learn more about terminals use the help "
1697 "in a standalone terminal application like Konsole.</para>"));
1698 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1699 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1700 "normal terminal but will match the location of the folder view "
1701 "so you can navigate using either.</para><para>The terminal panel "
1702 "is not needed for basic computer usage but can be useful for "
1703 "advanced tasks. To learn more about terminals use the help in a "
1704 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1708 if (GeneralSettings::version() < 200) {
1710 foldersDock
->hide();
1714 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1715 placesDock
->setLocked(lock
);
1716 placesDock
->setObjectName(QStringLiteral("placesDock"));
1717 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1719 m_placesPanel
= new PlacesPanel(placesDock
);
1720 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1721 placesDock
->setWidget(m_placesPanel
);
1723 QAction
*placesAction
= placesDock
->toggleViewAction();
1724 createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1726 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1727 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1728 this, &DolphinMainWindow::slotPlaceActivated
);
1729 connect(m_placesPanel
, &PlacesPanel::placeMiddleClicked
,
1730 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1731 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1732 this, &DolphinMainWindow::showErrorMessage
);
1733 connect(this, &DolphinMainWindow::urlChanged
,
1734 m_placesPanel
, &PlacesPanel::setUrl
);
1735 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1736 m_tabWidget
, &DolphinTabWidget::slotPlacesPanelVisibilityChanged
);
1737 connect(this, &DolphinMainWindow::settingsChanged
,
1738 m_placesPanel
, &PlacesPanel::readSettings
);
1739 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1740 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1741 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1742 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1743 m_tabWidget
->slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1745 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1746 actionShowAllPlaces
->setCheckable(true);
1747 actionShowAllPlaces
->setDisabled(true);
1748 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1749 "all places in the places panel that have been hidden. They will "
1750 "appear semi-transparent unless you uncheck their hide property."));
1752 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1753 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1754 m_placesPanel
->showHiddenEntries(checked
);
1757 connect(m_placesPanel
, &PlacesPanel::showHiddenEntriesChanged
, this, [actionShowAllPlaces
] (bool checked
){
1758 actionShowAllPlaces
->setChecked(checked
);
1759 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1762 actionCollection()->action(QStringLiteral("show_places_panel"))
1763 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1764 "<emphasis>places</emphasis> panel at the left side of the window."
1765 "</para><para>It allows you to go to locations you have "
1766 "bookmarked and to access disk or media attached to the computer "
1767 "or to the network. It also contains sections to find recently "
1768 "saved files or files of a certain type.</para>"));
1769 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1770 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1771 "you have bookmarked and to access disk or media attached to the "
1772 "computer or to the network. It also contains sections to find "
1773 "recently saved files or files of a certain type.</para><para>"
1774 "Click on an entry to go there. Click with the right mouse button "
1775 "instead to open any entry in a new tab or new window.</para>"
1776 "<para>New entries can be added by dragging folders onto this panel. "
1777 "Right-click any section or entry to hide it. Right-click an empty "
1778 "space on this panel and select <interface>Show Hidden Places"
1779 "</interface> to display it again.</para>") + panelWhatsThis
);
1781 // Add actions into the "Panels" menu
1782 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
1783 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
1784 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
1785 panelsMenu
->setDelayed(false);
1786 const KActionCollection
* ac
= actionCollection();
1787 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
1789 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
1791 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
1792 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
1793 panelsMenu
->addSeparator();
1794 panelsMenu
->addAction(actionShowAllPlaces
);
1795 panelsMenu
->addAction(lockLayoutAction
);
1797 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
1798 actionShowAllPlaces
->setEnabled(m_placesPanel
->hiddenListCount());
1803 void DolphinMainWindow::updateFileAndEditActions()
1805 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
1806 const KActionCollection
* col
= actionCollection();
1807 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
1809 if (list
.isEmpty()) {
1810 stateChanged(QStringLiteral("has_no_selection"));
1812 addToPlacesAction
->setEnabled(true);
1813 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer
->placesText()));
1815 stateChanged(QStringLiteral("has_selection"));
1817 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
1818 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
1819 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
1820 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
1821 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
1822 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
1824 if (list
.length() == 1 && list
.first().isDir()) {
1825 addToPlacesAction
->setEnabled(true);
1826 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list
.first().name()));
1828 addToPlacesAction
->setEnabled(false);
1829 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1832 KFileItemListProperties
capabilities(list
);
1833 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
1835 renameAction
->setEnabled(capabilities
.supportsMoving());
1836 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1837 deleteAction
->setEnabled(capabilities
.supportsDeleting());
1838 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
1839 cutAction
->setEnabled(capabilities
.supportsMoving());
1840 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
1844 void DolphinMainWindow::updateViewActions()
1846 m_actionHandler
->updateViewActions();
1848 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
1849 showFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
1851 updateSplitAction();
1853 QAction
* editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
1854 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
1855 editableLocactionAction
->setChecked(urlNavigator
->isUrlEditable());
1858 void DolphinMainWindow::updateGoActions()
1860 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
1861 const QUrl currentUrl
= m_activeViewContainer
->url();
1862 // I think this is one of the best places to firstly be confronted
1863 // with a file system and its hierarchy. Talking about the root
1864 // directory might seem too much here but it is the question that
1865 // naturally arises in this context.
1866 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
1867 "the folder that contains the currently viewed one.</para>"
1868 "<para>All files and folders are organized in a hierarchical "
1869 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
1870 "a directory that contains all data connected to this computer"
1871 "—the <emphasis>root directory</emphasis>.</para>"));
1872 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
1875 void DolphinMainWindow::createControlButton()
1877 if (m_controlButton
) {
1880 Q_ASSERT(!m_controlButton
);
1882 m_controlButton
= new QToolButton(this);
1883 m_controlButton
->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
1884 m_controlButton
->setToolTip(i18nc("@action", "Show menu"));
1885 m_controlButton
->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis
);
1886 m_controlButton
->setPopupMode(QToolButton::InstantPopup
);
1888 QMenu
* controlMenu
= new QMenu(m_controlButton
);
1889 connect(controlMenu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateControlMenu
);
1890 controlMenu
->installEventFilter(this);
1892 m_controlButton
->setMenu(controlMenu
);
1894 toolBar()->addWidget(m_controlButton
);
1895 connect(toolBar(), &KToolBar::iconSizeChanged
,
1896 m_controlButton
, &QToolButton::setIconSize
);
1898 // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
1899 // gets edited. In this case we must add them again. The adding is done asynchronously by
1900 // m_updateToolBarTimer.
1901 connect(m_controlButton
, &QToolButton::destroyed
, this, &DolphinMainWindow::slotControlButtonDeleted
);
1902 m_updateToolBarTimer
= new QTimer(this);
1903 m_updateToolBarTimer
->setInterval(500);
1904 connect(m_updateToolBarTimer
, &QTimer::timeout
, this, &DolphinMainWindow::updateToolBar
);
1907 void DolphinMainWindow::deleteControlButton()
1909 delete m_controlButton
;
1910 m_controlButton
= nullptr;
1912 delete m_updateToolBarTimer
;
1913 m_updateToolBarTimer
= nullptr;
1916 bool DolphinMainWindow::addActionToMenu(QAction
* action
, QMenu
* menu
)
1921 const KToolBar
* toolBarWidget
= toolBar();
1922 foreach (const QWidget
* widget
, action
->associatedWidgets()) {
1923 if (widget
== toolBarWidget
) {
1928 menu
->addAction(action
);
1932 void DolphinMainWindow::refreshViews()
1934 m_tabWidget
->refreshViews();
1936 if (GeneralSettings::modifiedStartupSettings()) {
1937 // The startup settings have been changed by the user (see bug #254947).
1938 // Synchronize the split-view setting with the active view:
1939 const bool splitView
= GeneralSettings::splitView();
1940 m_tabWidget
->currentTabPage()->setSplitViewEnabled(splitView
);
1941 updateSplitAction();
1942 updateWindowTitle();
1945 emit
settingsChanged();
1948 void DolphinMainWindow::clearStatusBar()
1950 m_activeViewContainer
->statusBar()->resetToDefaultText();
1953 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
1955 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
1956 this, &DolphinMainWindow::updateFilterBarAction
);
1957 connect(container
, &DolphinViewContainer::writeStateChanged
,
1958 this, &DolphinMainWindow::slotWriteStateChanged
);
1959 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
1960 this, &DolphinMainWindow::updateSearchAction
);
1962 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1963 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
1965 const DolphinView
* view
= container
->view();
1966 connect(view
, &DolphinView::selectionChanged
,
1967 this, &DolphinMainWindow::slotSelectionChanged
);
1968 connect(view
, &DolphinView::requestItemInfo
,
1969 this, &DolphinMainWindow::requestItemInfo
);
1970 connect(view
, &DolphinView::tabRequested
,
1971 this, &DolphinMainWindow::openNewTab
);
1972 connect(view
, &DolphinView::requestContextMenu
,
1973 this, &DolphinMainWindow::openContextMenu
);
1974 connect(view
, &DolphinView::directoryLoadingStarted
,
1975 this, &DolphinMainWindow::enableStopAction
);
1976 connect(view
, &DolphinView::directoryLoadingCompleted
,
1977 this, &DolphinMainWindow::disableStopAction
);
1978 connect(view
, &DolphinView::directoryLoadingCompleted
,
1979 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
1980 connect(view
, &DolphinView::goBackRequested
,
1981 this, &DolphinMainWindow::goBack
);
1982 connect(view
, &DolphinView::goForwardRequested
,
1983 this, &DolphinMainWindow::goForward
);
1984 connect(view
, &DolphinView::urlActivated
,
1985 this, &DolphinMainWindow::handleUrl
);
1987 const KUrlNavigator
* navigator
= container
->urlNavigator();
1988 connect(navigator
, &KUrlNavigator::urlChanged
,
1989 this, &DolphinMainWindow::changeUrl
);
1990 connect(navigator
, &KUrlNavigator::historyChanged
,
1991 this, &DolphinMainWindow::updateHistory
);
1992 connect(navigator
, &KUrlNavigator::editableStateChanged
,
1993 this, &DolphinMainWindow::slotEditableStateChanged
);
1994 connect(navigator
, &KUrlNavigator::tabRequested
,
1995 this, &DolphinMainWindow::openNewTabAfterLastTab
);
1998 void DolphinMainWindow::updateSplitAction()
2000 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
2001 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
2002 if (tabPage
->splitViewEnabled()) {
2003 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
2004 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
2005 splitAction
->setToolTip(i18nc("@info", "Close left view"));
2006 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
2008 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
2009 splitAction
->setToolTip(i18nc("@info", "Close right view"));
2010 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
2013 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
2014 splitAction
->setToolTip(i18nc("@info", "Split view"));
2015 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
2019 bool DolphinMainWindow::isKompareInstalled() const
2021 static bool initialized
= false;
2022 static bool installed
= false;
2024 // TODO: maybe replace this approach later by using a menu
2025 // plugin like kdiff3plugin.cpp
2026 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2032 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2033 const QKeySequence
& shortcut
,
2034 QAction
* dockAction
,
2035 const QString
& actionName
)
2037 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2038 panelAction
->setCheckable(true);
2039 panelAction
->setChecked(dockAction
->isChecked());
2040 panelAction
->setText(dockAction
->text());
2041 panelAction
->setIcon(icon
);
2042 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2044 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2045 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2048 void DolphinMainWindow::setupWhatsThis()
2051 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2052 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2053 "configuration options. Left-click on any of the menus on this "
2054 "bar to see its contents.</para><para>The Menubar can be hidden "
2055 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2056 "most of its contents become available through a <interface>Control"
2057 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2058 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2059 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2060 "frequently used actions.</para><para>It is highly customizable. "
2061 "All items you see in the <interface>Control</interface> menu or "
2062 "in the <interface>Menubar</interface> can be placed on the "
2063 "Toolbar. Just right-click on it and select <interface>Configure "
2064 "Toolbars…</interface> or find this action in the <interface>"
2065 "Control</interface> or <interface>Settings</interface> menu."
2066 "</para><para>The location of the bar and the style of its "
2067 "buttons can also be changed in the right-click menu. Right-click "
2068 "a button if you want to show or hide its text.</para>"));
2069 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2070 "<para>Here you can see the <emphasis>folders</emphasis> and "
2071 "<emphasis>files</emphasis> that are at the location described in "
2072 "the <interface>Location Bar</interface> above. This area is the "
2073 "central part of this application where you navigate to the files "
2074 "you want to use.</para><para>For an elaborate and general "
2075 "introduction to this application <link "
2076 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2077 "click here</link>. This will open an introductory article from "
2078 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2079 "explanations of all the features of this <emphasis>view</emphasis> "
2080 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2081 "instead. This will open a page from the <emphasis>Handbook"
2082 "</emphasis> that covers the basics.</para>"));
2085 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2086 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2087 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2088 "There you can set up key combinations to trigger an action when "
2089 "they are pressed simultaneously. All commands in this application can "
2090 "be triggered this way.</para>"));
2091 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2092 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2093 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2094 "<para>All items you see in the <interface>Control</interface> menu "
2095 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2096 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2097 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2098 "change a multitude of settings for this application. For an explanation "
2099 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2100 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2103 // The whatsthis has to be set for the m_helpMenu and for the
2104 // StandardAction separately because both are used in different locations.
2105 // m_helpMenu is only used for createControlButton() button.
2107 // Links do not work within the Menubar so texts without links are provided there.
2109 // i18n: If the external link isn't available in your language you should
2110 // probably state the external link language at least in brackets to not
2111 // frustrate the user. If there are multiple languages that the user might
2112 // know with a reasonable chance you might want to have 2 external links.
2113 // The same is in my opinion true for every external link you translate.
2114 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2115 "<para>This opens the Handbook for this application. It provides "
2116 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2117 actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents
))
2118 ->setWhatsThis(whatsThisHelpContents
2119 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2120 "<para>If you want more elaborate introductions to the "
2121 "different features of <emphasis>Dolphin</emphasis> "
2122 "go to the KDE UserBase Wiki.</para>"));
2123 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setWhatsThis(whatsThisHelpContents
2124 + xi18nc("@info:whatsthis second half of handbook text with link",
2125 "<para>If you want more elaborate introductions to the "
2126 "different features of <emphasis>Dolphin</emphasis> "
2127 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2128 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2130 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2131 "<para>This is the button that invokes the help feature you are "
2132 "using right now! Click it, then click any component of this "
2133 "application to ask \"What's this?\" about it. The mouse cursor "
2134 "will change appearance if no help is available for a spot.</para>");
2135 actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis
))
2136 ->setWhatsThis(whatsThisWhatsThis
2137 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2138 "<para>There are two other ways to get help for this application: The "
2139 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2140 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2141 "article about <emphasis>File Management</emphasis> online."
2142 "</para><para>The \"What's this?\" help is "
2143 "missing in most other windows so don't get too used to this.</para>"));
2144 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setWhatsThis(whatsThisWhatsThis
2145 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2146 "<para>There are two other ways to get help: "
2147 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2148 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2149 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2150 "missing in most other windows so don't get too used to this.</para>"));
2152 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2153 "window that will guide you through reporting errors or flaws "
2154 "in this application or in other KDE software.</para>");
2155 actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug
))
2156 ->setWhatsThis(whatsThisReportBug
);
2157 m_helpMenu
->action(KHelpMenu::menuReportBug
)->setWhatsThis(whatsThisReportBug
2158 + xi18nc("@info:whatsthis second half of reportbug text with link",
2159 "<para>High-quality bug reports are much appreciated. To learn "
2160 "how to make your bug report as effective as possible "
2161 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2162 "click here</link>.</para>"));
2164 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2165 "<emphasis>web page</emphasis> where you can donate to "
2166 "support the continued work on this application and many "
2167 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2168 "<para>Donating is the easiest and fastest way to efficiently "
2169 "support KDE and its projects. KDE projects are available for "
2170 "free therefore your donation is needed to cover things that "
2171 "require money like servers, contributor meetings, etc.</para>"
2172 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2173 "organization behind the KDE community.</para>");
2174 actionCollection()->action(KStandardAction::name(KStandardAction::Donate
))
2175 ->setWhatsThis(whatsThisDonate
);
2176 m_helpMenu
->action(KHelpMenu::menuDonate
)->setWhatsThis(whatsThisDonate
);
2178 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2179 "With this you can change the language this application uses."
2180 "<nl/>You can even set secondary languages which will be used "
2181 "if texts are not available in your preferred language.");
2182 actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
))
2183 ->setWhatsThis(whatsThisSwitchLanguage
);
2184 m_helpMenu
->action(KHelpMenu::menuSwitchLanguage
)->setWhatsThis(whatsThisSwitchLanguage
);
2186 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2187 "window that informs you about the version, license, "
2188 "used libraries and maintainers of this application.");
2189 actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp
))
2190 ->setWhatsThis(whatsThisAboutApp
);
2191 m_helpMenu
->action(KHelpMenu::menuAboutApp
)->setWhatsThis(whatsThisAboutApp
);
2193 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2194 "window with information about <emphasis>KDE</emphasis>. "
2195 "The KDE community are the people behind this free software."
2196 "<nl/>If you like using this application but don't know "
2197 "about KDE or want to see a cute dragon have a look!");
2198 actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE
))
2199 ->setWhatsThis(whatsThisAboutKDE
);
2200 m_helpMenu
->action(KHelpMenu::menuAboutKDE
)->setWhatsThis(whatsThisAboutKDE
);
2203 bool DolphinMainWindow::event(QEvent
*event
)
2205 if (event
->type() == QEvent::WhatsThisClicked
) {
2207 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2208 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2211 return KXmlGuiWindow::event(event
);
2214 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2217 if (event
->type() == QEvent::WhatsThisClicked
) {
2219 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2220 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2226 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2227 KIO::FileUndoManager::UiInterface()
2231 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2235 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2237 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2239 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2240 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2242 KIO::FileUndoManager::UiInterface::jobError(job
);
2246 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2248 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));