1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #include "dolphinmainwindow.h"
24 #include "config-terminal.h"
26 #include "dolphinbookmarkhandler.h"
27 #include "dolphindockwidget.h"
28 #include "dolphincontextmenu.h"
29 #include "dolphinnewfilemenu.h"
30 #include "dolphinrecenttabsmenu.h"
31 #include "dolphinviewcontainer.h"
32 #include "dolphintabpage.h"
33 #include "middleclickactioneventfilter.h"
34 #include "panels/folders/folderspanel.h"
35 #include "panels/places/placesitemmodel.h"
36 #include "panels/places/placespanel.h"
37 #include "panels/information/informationpanel.h"
38 #include "panels/terminal/terminalpanel.h"
39 #include "settings/dolphinsettingsdialog.h"
40 #include "statusbar/dolphinstatusbar.h"
41 #include "views/dolphinviewactionhandler.h"
42 #include "views/dolphinremoteencoding.h"
43 #include "views/draganddrophelper.h"
44 #include "views/viewproperties.h"
45 #include "views/dolphinnewfilemenuobserver.h"
46 #include "dolphin_generalsettings.h"
48 #include <KActionCollection>
49 #include <KActionMenu>
50 #include <KAuthorized>
52 #include <KDualAction>
53 #include <KFileItemListProperties>
55 #include <KIO/JobUiDelegate>
56 #include <KIO/OpenFileManagerWindowJob>
57 #include <KJobWidgets>
58 #include <KLocalizedString>
59 #include <KMessageBox>
60 #include <KProtocolInfo>
61 #include <KProtocolManager>
64 #include <KStandardAction>
65 #include <KStartupInfo>
66 #include <KToggleAction>
68 #include <KToolBarPopupAction>
69 #include <KToolInvocation>
70 #include <KUrlComboBox>
71 #include <KUrlNavigator>
72 #include <KWindowSystem>
74 #include <QApplication>
76 #include <QCloseEvent>
77 #include <QDesktopServices>
83 #include <QPushButton>
85 #include <QStandardPaths>
87 #include <QToolButton>
88 #include <QWhatsThisClickedEvent>
91 // Used for GeneralSettings::version() to determine whether
92 // an updated version of Dolphin is running.
93 const int CurrentDolphinVersion
= 200;
94 // The maximum number of entries in the back/forward popup menu
95 const int MaxNumberOfNavigationentries
= 12;
98 DolphinMainWindow::DolphinMainWindow() :
99 KXmlGuiWindow(nullptr, Qt::WindowContextHelpButtonHint
),
100 m_newFileMenu(nullptr),
102 m_tabWidget(nullptr),
103 m_activeViewContainer(nullptr),
104 m_actionHandler(nullptr),
105 m_remoteEncoding(nullptr),
107 m_bookmarkHandler(nullptr),
108 m_controlButton(nullptr),
109 m_updateToolBarTimer(nullptr),
110 m_lastHandleUrlStatJob(nullptr),
111 m_terminalPanel(nullptr),
112 m_placesPanel(nullptr),
113 m_tearDownFromPlacesRequested(false),
114 m_backAction(nullptr),
115 m_forwardAction(nullptr)
117 Q_INIT_RESOURCE(dolphin
);
118 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
119 setObjectName(QStringLiteral("Dolphin#"));
121 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
122 this, &DolphinMainWindow::showErrorMessage
);
124 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
125 undoManager
->setUiInterface(new UndoUiInterface());
127 connect(undoManager
, QOverload
<bool>::of(&KIO::FileUndoManager::undoAvailable
),
128 this, &DolphinMainWindow::slotUndoAvailable
);
129 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
130 this, &DolphinMainWindow::slotUndoTextChanged
);
131 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
132 this, &DolphinMainWindow::clearStatusBar
);
133 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
134 this, &DolphinMainWindow::showCommand
);
136 GeneralSettings
* generalSettings
= GeneralSettings::self();
137 const bool firstRun
= (generalSettings
->version() < 200);
139 generalSettings
->setViewPropsTimestamp(QDateTime::currentDateTime());
142 setAcceptDrops(true);
144 m_tabWidget
= new DolphinTabWidget(this);
145 m_tabWidget
->setObjectName("tabWidget");
146 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
147 this, &DolphinMainWindow::activeViewChanged
);
148 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
149 this, &DolphinMainWindow::tabCountChanged
);
150 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
151 this, &DolphinMainWindow::updateWindowTitle
);
152 setCentralWidget(m_tabWidget
);
156 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
157 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
158 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
160 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
161 connect(this, &DolphinMainWindow::urlChanged
,
162 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
166 setupGUI(Keys
| Save
| Create
| ToolBar
);
167 stateChanged(QStringLiteral("new_file"));
169 QClipboard
* clipboard
= QApplication::clipboard();
170 connect(clipboard
, &QClipboard::dataChanged
,
171 this, &DolphinMainWindow::updatePasteAction
);
173 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
174 showFilterBarAction
->setChecked(generalSettings
->filterBar());
177 menuBar()->setVisible(false);
178 // Assure a proper default size if Dolphin runs the first time
182 const bool showMenu
= !menuBar()->isHidden();
183 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
184 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
186 createControlButton();
189 // enable middle-click on back/forward/up to open in a new tab
190 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
191 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
192 toolBar()->installEventFilter(middleClickEventFilter
);
197 DolphinMainWindow::~DolphinMainWindow()
201 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
203 QVector
<DolphinViewContainer
*> viewContainers
;
204 viewContainers
.reserve(m_tabWidget
->count());
205 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
206 viewContainers
<< m_tabWidget
->tabPageAt(i
)->activeViewContainer();
208 return viewContainers
;
211 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
213 m_tabWidget
->openDirectories(dirs
, splitView
);
216 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
218 openDirectories(QUrl::fromStringList(dirs
), splitView
);
221 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
223 m_tabWidget
->openFiles(files
, splitView
);
226 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
228 openFiles(QUrl::fromStringList(files
), splitView
);
231 void DolphinMainWindow::activateWindow()
233 KStartupInfo::setNewStartupId(window(), KStartupInfo::startupId());
234 KWindowSystem::activateWindow(window()->effectiveWinId());
237 void DolphinMainWindow::showCommand(CommandType command
)
239 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
241 case KIO::FileUndoManager::Copy
:
242 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
244 case KIO::FileUndoManager::Move
:
245 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
247 case KIO::FileUndoManager::Link
:
248 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
250 case KIO::FileUndoManager::Trash
:
251 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
253 case KIO::FileUndoManager::Rename
:
254 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
257 case KIO::FileUndoManager::Mkdir
:
258 statusBar
->setText(i18nc("@info:status", "Created folder."));
266 void DolphinMainWindow::pasteIntoFolder()
268 m_activeViewContainer
->view()->pasteIntoFolder();
271 void DolphinMainWindow::changeUrl(const QUrl
&url
)
273 if (!KProtocolManager::supportsListing(url
)) {
274 // The URL navigator only checks for validity, not
275 // if the URL can be listed. An error message is
276 // shown due to DolphinViewContainer::restoreView().
280 m_activeViewContainer
->setUrl(url
);
281 updateFileAndEditActions();
286 emit
urlChanged(url
);
289 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
291 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
292 m_placesPanel
->proceedWithTearDown();
293 m_tearDownFromPlacesRequested
= false;
296 m_activeViewContainer
->setAutoGrabFocus(false);
298 m_activeViewContainer
->setAutoGrabFocus(true);
301 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
303 KToggleAction
* editableLocationAction
=
304 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
305 editableLocationAction
->setChecked(editable
);
308 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
310 updateFileAndEditActions();
312 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
314 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
315 if (selectedUrlsCount
== 2) {
316 compareFilesAction
->setEnabled(isKompareInstalled());
318 compareFilesAction
->setEnabled(false);
321 emit
selectionChanged(selection
);
324 void DolphinMainWindow::updateHistory()
326 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
327 const int index
= urlNavigator
->historyIndex();
329 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
331 backAction
->setToolTip(i18nc("@info", "Go back"));
332 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
333 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
336 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
338 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
339 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
340 "This undoes a <interface>Go|Back</interface> action."));
341 forwardAction
->setEnabled(index
> 0);
345 void DolphinMainWindow::updateFilterBarAction(bool show
)
347 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
348 showFilterBarAction
->setChecked(show
);
351 void DolphinMainWindow::openNewMainWindow()
353 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
356 void DolphinMainWindow::openNewActivatedTab()
358 m_tabWidget
->openNewActivatedTab();
361 void DolphinMainWindow::addToPlaces()
366 // If nothing is selected, act on the current dir
367 if (m_activeViewContainer
->view()->selectedItems().isEmpty()) {
368 url
= m_activeViewContainer
->url();
369 name
= m_activeViewContainer
->placesText();
371 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
372 url
= dirToAdd
.url();
373 name
= dirToAdd
.name();
376 PlacesItemModel model
;
378 if (m_activeViewContainer
->isSearchModeEnabled()) {
379 icon
= QStringLiteral("folder-saved-search-symbolic");
381 icon
= KIO::iconNameForUrl(url
);
383 model
.createPlacesItem(name
, url
, icon
);
387 void DolphinMainWindow::openNewTab(const QUrl
& url
, DolphinTabWidget::TabPlacement tabPlacement
)
389 m_tabWidget
->openNewTab(url
, QUrl(), tabPlacement
);
392 void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl
& url
)
394 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterCurrentTab
);
397 void DolphinMainWindow::openNewTabAfterLastTab(const QUrl
& url
)
399 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterLastTab
);
402 void DolphinMainWindow::openInNewTab()
404 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
405 bool tabCreated
= false;
407 foreach (const KFileItem
& item
, list
) {
408 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
409 if (!url
.isEmpty()) {
410 openNewTabAfterCurrentTab(url
);
415 // if no new tab has been created from the selection
416 // open the current directory in a new tab
418 openNewTabAfterCurrentTab(m_activeViewContainer
->url());
422 void DolphinMainWindow::openInNewWindow()
426 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
427 if (list
.isEmpty()) {
428 newWindowUrl
= m_activeViewContainer
->url();
429 } else if (list
.count() == 1) {
430 const KFileItem
& item
= list
.first();
431 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
434 if (!newWindowUrl
.isEmpty()) {
435 Dolphin::openNewWindow({newWindowUrl
}, this);
439 void DolphinMainWindow::showTarget()
441 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
442 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
443 auto linkDestination
= link
.linkDest();
444 if (QFileInfo(linkDestination
).isRelative()) {
445 linkDestination
= linkLocationDir
.filePath(linkDestination
);
447 if (QFileInfo::exists(linkDestination
)) {
448 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
450 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
451 DolphinViewContainer::Warning
);
455 void DolphinMainWindow::showEvent(QShowEvent
* event
)
457 KXmlGuiWindow::showEvent(event
);
459 if (!event
->spontaneous()) {
460 m_activeViewContainer
->view()->setFocus();
464 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
466 // Find out if Dolphin is closed directly by the user or
467 // by the session manager because the session is closed
468 bool closedByUser
= true;
469 if (qApp
->isSavingSession()) {
470 closedByUser
= false;
473 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser
) {
474 // Ask the user if he really wants to quit and close all tabs.
475 // Open a confirmation dialog with 3 buttons:
476 // QDialogButtonBox::Yes -> Quit
477 // QDialogButtonBox::No -> Close only the current tab
478 // QDialogButtonBox::Cancel -> do nothing
479 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
480 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
481 dialog
->setModal(true);
482 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
483 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
484 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
485 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
486 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
488 bool doNotAskAgainCheckboxResult
= false;
490 const auto result
= KMessageBox::createKMessageBox(dialog
,
492 QMessageBox::Warning
,
493 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
495 i18n("Do not ask again"),
496 &doNotAskAgainCheckboxResult
,
497 KMessageBox::Notify
);
499 if (doNotAskAgainCheckboxResult
) {
500 GeneralSettings::setConfirmClosingMultipleTabs(false);
504 case QDialogButtonBox::Yes
:
507 case QDialogButtonBox::No
:
508 // Close only the current tab
509 m_tabWidget
->closeTab();
517 if (m_terminalPanel
&& m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
518 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
519 // Open a confirmation dialog with 3 buttons:
520 // QDialogButtonBox::Yes -> Quit
521 // QDialogButtonBox::No -> Show Terminal Panel
522 // QDialogButtonBox::Cancel -> do nothing
523 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
524 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
525 dialog
->setModal(true);
526 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
527 if (!m_terminalPanel
->isVisible()) {
528 standardButtons
|= QDialogButtonBox::No
;
530 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
531 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
532 if (!m_terminalPanel
->isVisible()) {
534 buttons
->button(QDialogButtonBox::No
),
535 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
537 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
539 bool doNotAskAgainCheckboxResult
= false;
541 const auto result
= KMessageBox::createKMessageBox(
544 QMessageBox::Warning
,
545 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
547 i18n("Do not ask again"),
548 &doNotAskAgainCheckboxResult
,
549 KMessageBox::Dangerous
);
551 if (doNotAskAgainCheckboxResult
) {
552 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
556 case QDialogButtonBox::Yes
:
559 case QDialogButtonBox::No
:
560 actionCollection()->action("show_terminal_panel")->trigger();
561 // Do not quit, ignore quit event
569 GeneralSettings::setVersion(CurrentDolphinVersion
);
570 GeneralSettings::self()->save();
572 KXmlGuiWindow::closeEvent(event
);
575 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
577 m_tabWidget
->saveProperties(group
);
580 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
582 m_tabWidget
->readProperties(group
);
585 void DolphinMainWindow::updateNewMenu()
587 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
588 m_newFileMenu
->checkUpToDate();
589 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
592 void DolphinMainWindow::createDirectory()
594 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
595 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
596 m_newFileMenu
->createDirectory();
599 void DolphinMainWindow::quit()
604 void DolphinMainWindow::showErrorMessage(const QString
& message
)
606 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
609 void DolphinMainWindow::slotUndoAvailable(bool available
)
611 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
613 undoAction
->setEnabled(available
);
617 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
619 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
621 undoAction
->setText(text
);
625 void DolphinMainWindow::undo()
628 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
629 KIO::FileUndoManager::self()->undo();
632 void DolphinMainWindow::cut()
634 m_activeViewContainer
->view()->cutSelectedItems();
637 void DolphinMainWindow::copy()
639 m_activeViewContainer
->view()->copySelectedItems();
642 void DolphinMainWindow::paste()
644 m_activeViewContainer
->view()->paste();
647 void DolphinMainWindow::find()
649 m_activeViewContainer
->setSearchModeEnabled(true);
652 void DolphinMainWindow::updateSearchAction()
654 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
655 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
658 void DolphinMainWindow::updatePasteAction()
660 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
661 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
662 pasteAction
->setEnabled(pasteInfo
.first
);
663 pasteAction
->setText(pasteInfo
.second
);
666 void DolphinMainWindow::slotDirectoryLoadingCompleted()
671 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
673 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
675 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
677 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
679 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
684 void DolphinMainWindow::slotAboutToShowBackPopupMenu()
686 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
688 m_backAction
->menu()->clear();
689 for (int i
= urlNavigator
->historyIndex() + 1; i
< urlNavigator
->historySize() && entries
< MaxNumberOfNavigationentries
; ++i
, ++entries
) {
690 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_backAction
->menu());
692 m_backAction
->menu()->addAction(action
);
696 void DolphinMainWindow::slotGoBack(QAction
* action
)
698 int gotoIndex
= action
->data().value
<int>();
699 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
700 for (int i
= gotoIndex
- urlNavigator
->historyIndex(); i
> 0; --i
) {
705 void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction
* action
)
708 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
709 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(action
->data().value
<int>()));
713 void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
715 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
717 m_forwardAction
->menu()->clear();
718 for (int i
= urlNavigator
->historyIndex() - 1; i
>= 0 && entries
< MaxNumberOfNavigationentries
; --i
, ++entries
) {
719 QAction
* action
= new QAction(urlNavigator
->locationUrl(i
).toString(QUrl::PreferLocalFile
), m_forwardAction
->menu());
721 m_forwardAction
->menu()->addAction(action
);
725 void DolphinMainWindow::slotGoForward(QAction
* action
)
727 int gotoIndex
= action
->data().value
<int>();
728 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
729 for (int i
= urlNavigator
->historyIndex() - gotoIndex
; i
> 0; --i
) {
734 void DolphinMainWindow::selectAll()
738 // if the URL navigator is editable and focused, select the whole
739 // URL instead of all items of the view
741 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
742 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
743 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
744 lineEdit
->hasFocus();
746 lineEdit
->selectAll();
748 m_activeViewContainer
->view()->selectAll();
752 void DolphinMainWindow::invertSelection()
755 m_activeViewContainer
->view()->invertSelection();
758 void DolphinMainWindow::toggleSplitView()
760 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
761 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled());
766 void DolphinMainWindow::toggleSplitStash()
768 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
769 tabPage
->setSplitViewEnabled(false);
770 tabPage
->setSplitViewEnabled(true, QUrl("stash:/"));
773 void DolphinMainWindow::reloadView()
776 m_activeViewContainer
->reload();
777 m_activeViewContainer
->statusBar()->updateSpaceInfo();
780 void DolphinMainWindow::stopLoading()
782 m_activeViewContainer
->view()->stopLoading();
785 void DolphinMainWindow::enableStopAction()
787 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
790 void DolphinMainWindow::disableStopAction()
792 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
795 void DolphinMainWindow::showFilterBar()
797 m_activeViewContainer
->setFilterBarVisible(true);
800 void DolphinMainWindow::toggleEditLocation()
804 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
805 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
806 urlNavigator
->setUrlEditable(action
->isChecked());
809 void DolphinMainWindow::replaceLocation()
811 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
812 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
814 // If the text field currently has focus and everything is selected,
815 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
816 if (navigator
->isUrlEditable()
817 && lineEdit
->hasFocus()
818 && lineEdit
->selectedText() == lineEdit
->text() ) {
819 navigator
->setUrlEditable(false);
821 navigator
->setUrlEditable(true);
822 navigator
->setFocus();
823 lineEdit
->selectAll();
827 void DolphinMainWindow::togglePanelLockState()
829 const bool newLockState
= !GeneralSettings::lockPanels();
830 foreach (QObject
* child
, children()) {
831 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
833 dock
->setLocked(newLockState
);
837 GeneralSettings::setLockPanels(newLockState
);
840 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
842 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
843 m_activeViewContainer
->view()->setFocus();
847 void DolphinMainWindow::goBack()
849 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
850 urlNavigator
->goBack();
852 if (urlNavigator
->locationState().isEmpty()) {
853 // An empty location state indicates a redirection URL,
854 // which must be skipped too
855 urlNavigator
->goBack();
859 void DolphinMainWindow::goForward()
861 m_activeViewContainer
->urlNavigator()->goForward();
864 void DolphinMainWindow::goUp()
866 m_activeViewContainer
->urlNavigator()->goUp();
869 void DolphinMainWindow::goHome()
871 m_activeViewContainer
->urlNavigator()->goHome();
874 void DolphinMainWindow::goBackInNewTab()
876 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
877 const int index
= urlNavigator
->historyIndex() + 1;
878 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
881 void DolphinMainWindow::goForwardInNewTab()
883 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
884 const int index
= urlNavigator
->historyIndex() - 1;
885 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
888 void DolphinMainWindow::goUpInNewTab()
890 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
891 openNewTabAfterCurrentTab(KIO::upUrl(currentUrl
));
894 void DolphinMainWindow::goHomeInNewTab()
896 openNewTabAfterCurrentTab(Dolphin::homeUrl());
899 void DolphinMainWindow::compareFiles()
901 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
902 if (items
.count() != 2) {
903 // The action is disabled in this case, but it could have been triggered
904 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
908 QUrl urlA
= items
.at(0).url();
909 QUrl urlB
= items
.at(1).url();
911 QString
command(QStringLiteral("kompare -c \""));
912 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
913 command
.append("\" \"");
914 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
915 command
.append('\"');
916 KRun::runCommand(command
, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
919 void DolphinMainWindow::toggleShowMenuBar()
921 const bool visible
= menuBar()->isVisible();
922 menuBar()->setVisible(!visible
);
924 createControlButton();
926 deleteControlButton();
930 void DolphinMainWindow::openTerminal()
932 QString
dir(QDir::homePath());
934 // If the given directory is not local, it can still be the URL of an
935 // ioslave using UDS_LOCAL_PATH which to be converted first.
936 KIO::StatJob
* statJob
= KIO::mostLocalUrl(m_activeViewContainer
->url());
937 KJobWidgets::setWindow(statJob
, this);
939 QUrl url
= statJob
->mostLocalUrl();
941 //If the URL is local after the above conversion, set the directory.
942 if (url
.isLocalFile()) {
943 dir
= url
.toLocalFile();
946 KToolInvocation::invokeTerminal(QString(), dir
);
949 void DolphinMainWindow::editSettings()
951 if (!m_settingsDialog
) {
952 DolphinViewContainer
* container
= activeViewContainer();
953 container
->view()->writeSettings();
955 const QUrl url
= container
->url();
956 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this);
957 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
958 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
959 settingsDialog
->show();
960 m_settingsDialog
= settingsDialog
;
962 m_settingsDialog
.data()->raise();
966 void DolphinMainWindow::handleUrl(const QUrl
& url
)
968 delete m_lastHandleUrlStatJob
;
969 m_lastHandleUrlStatJob
= nullptr;
971 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
972 activeViewContainer()->setUrl(url
);
973 } else if (KProtocolManager::supportsListing(url
)) {
974 // stat the URL to see if it is a dir or not
975 m_lastHandleUrlStatJob
= KIO::stat(url
, KIO::HideProgressInfo
);
976 if (m_lastHandleUrlStatJob
->uiDelegate()) {
977 KJobWidgets::setWindow(m_lastHandleUrlStatJob
, this);
979 connect(m_lastHandleUrlStatJob
, &KIO::Job::result
,
980 this, &DolphinMainWindow::slotHandleUrlStatFinished
);
983 new KRun(url
, this); // Automatically deletes itself after being finished
987 void DolphinMainWindow::slotHandleUrlStatFinished(KJob
* job
)
989 m_lastHandleUrlStatJob
= nullptr;
990 const KIO::UDSEntry entry
= static_cast<KIO::StatJob
*>(job
)->statResult();
991 const QUrl url
= static_cast<KIO::StatJob
*>(job
)->url();
993 activeViewContainer()->setUrl(url
);
995 new KRun(url
, this); // Automatically deletes itself after being finished
999 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
1001 // trash:/ is writable but we don't want to create new items in it.
1002 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
1003 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
1006 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
1007 const KFileItem
& item
,
1009 const QList
<QAction
*>& customActions
)
1011 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
);
1012 contextMenu
.data()->setCustomActions(customActions
);
1013 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
1016 case DolphinContextMenu::OpenParentFolder
:
1017 changeUrl(KIO::upUrl(item
.url()));
1018 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
1019 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
1022 case DolphinContextMenu::OpenParentFolderInNewWindow
:
1023 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
1026 case DolphinContextMenu::OpenParentFolderInNewTab
:
1027 openNewTabAfterLastTab(KIO::upUrl(item
.url()));
1030 case DolphinContextMenu::None
:
1035 // Delete the menu, unless it has been deleted in its own nested event loop already.
1037 contextMenu
->deleteLater();
1041 void DolphinMainWindow::updateControlMenu()
1043 QMenu
* menu
= qobject_cast
<QMenu
*>(sender());
1046 // All actions get cleared by QMenu::clear(). This includes the sub-menus
1047 // because 'menu' is their parent.
1050 KActionCollection
* ac
= actionCollection();
1052 menu
->addMenu(m_newFileMenu
->menu());
1053 addActionToMenu(ac
->action(QStringLiteral("file_new")), menu
);
1054 addActionToMenu(ac
->action(QStringLiteral("new_tab")), menu
);
1055 addActionToMenu(ac
->action(QStringLiteral("closed_tabs")), menu
);
1057 menu
->addSeparator();
1059 // Add "Edit" actions
1060 bool added
= addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Undo
)), menu
) |
1061 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::SelectAll
)), menu
) |
1062 addActionToMenu(ac
->action(QStringLiteral("invert_selection")), menu
);
1065 menu
->addSeparator();
1068 // Add "View" actions
1069 if (!GeneralSettings::showZoomSlider()) {
1070 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomIn
)), menu
);
1071 addActionToMenu(ac
->action(QStringLiteral("view_zoom_reset")), menu
);
1072 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomOut
)), menu
);
1073 menu
->addSeparator();
1076 added
= addActionToMenu(ac
->action(QStringLiteral("show_preview")), menu
) |
1077 addActionToMenu(ac
->action(QStringLiteral("show_in_groups")), menu
) |
1078 addActionToMenu(ac
->action(QStringLiteral("show_hidden_files")), menu
) |
1079 addActionToMenu(ac
->action(QStringLiteral("additional_info")), menu
) |
1080 addActionToMenu(ac
->action(QStringLiteral("view_properties")), menu
);
1083 menu
->addSeparator();
1086 // Add a curated assortment of items from the "Tools" menu
1087 addActionToMenu(ac
->action(QStringLiteral("show_filter_bar")), menu
);
1088 addActionToMenu(ac
->action(QStringLiteral("open_terminal")), menu
);
1090 menu
->addSeparator();
1092 // Add "Show Panels" menu
1093 addActionToMenu(ac
->action(QStringLiteral("panels")), menu
);
1095 // Add "Settings" menu entries
1096 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)), menu
);
1097 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)), menu
);
1098 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Preferences
)), menu
);
1099 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)), menu
);
1102 auto helpMenu
= m_helpMenu
->menu();
1103 helpMenu
->setIcon(QIcon::fromTheme(QStringLiteral("system-help")));
1104 menu
->addMenu(helpMenu
);
1107 void DolphinMainWindow::updateToolBar()
1109 if (!menuBar()->isVisible()) {
1110 createControlButton();
1114 void DolphinMainWindow::slotControlButtonDeleted()
1116 m_controlButton
= nullptr;
1117 m_updateToolBarTimer
->start();
1120 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1122 DolphinViewContainer
* view
= activeViewContainer();
1124 if (view
->url() == url
) {
1125 // We can end up here if the user clicked a device in the Places Panel
1126 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1133 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1135 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1138 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1140 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1141 Q_ASSERT(viewContainer
);
1143 m_activeViewContainer
= viewContainer
;
1145 if (oldViewContainer
) {
1146 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1147 toggleSearchAction
->disconnect(oldViewContainer
);
1149 // Disconnect all signals between the old view container (container,
1150 // view and url navigator) and main window.
1151 oldViewContainer
->disconnect(this);
1152 oldViewContainer
->view()->disconnect(this);
1153 oldViewContainer
->urlNavigator()->disconnect(this);
1155 // except the requestItemInfo so that on hover the information panel can still be updated
1156 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1157 this, &DolphinMainWindow::requestItemInfo
);
1160 connectViewSignals(viewContainer
);
1162 m_actionHandler
->setCurrentView(viewContainer
->view());
1165 updateFileAndEditActions();
1166 updatePasteAction();
1167 updateViewActions();
1169 updateSearchAction();
1171 const QUrl url
= viewContainer
->url();
1172 emit
urlChanged(url
);
1175 void DolphinMainWindow::tabCountChanged(int count
)
1177 const bool enableTabActions
= (count
> 1);
1178 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1179 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1182 void DolphinMainWindow::updateWindowTitle()
1184 const QString newTitle
= m_activeViewContainer
->caption();
1185 if (windowTitle() != newTitle
) {
1186 setWindowTitle(newTitle
);
1190 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1192 if (m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1193 m_tearDownFromPlacesRequested
= true;
1194 m_terminalPanel
->goHome();
1195 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1197 m_placesPanel
->proceedWithTearDown();
1201 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1203 if (m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1204 m_tearDownFromPlacesRequested
= false;
1205 m_terminalPanel
->goHome();
1209 void DolphinMainWindow::setupActions()
1211 // setup 'File' menu
1212 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1213 QMenu
* menu
= m_newFileMenu
->menu();
1214 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1215 menu
->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
1216 m_newFileMenu
->setDelayed(false);
1217 connect(menu
, &QMenu::aboutToShow
,
1218 this, &DolphinMainWindow::updateNewMenu
);
1220 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1221 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1222 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1223 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1224 "window just like this one with the current location and view."
1225 "<nl/>You can drag and drop items between windows."));
1226 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1228 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1229 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1230 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1231 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1232 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1233 "A tab is an additional view within this window. "
1234 "You can drag and drop items between tabs."));
1235 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
+ Qt::Key_T
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_N
});
1236 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1238 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1239 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1240 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1241 "to the Places panel."));
1242 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1244 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1245 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1246 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1247 "currently viewed tab. If no more tabs are left this window "
1248 "will close instead."));
1250 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1251 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1253 // setup 'Edit' menu
1254 KStandardAction::undo(this,
1255 &DolphinMainWindow::undo
,
1256 actionCollection());
1258 // i18n: This will be the last paragraph for the whatsthis for all three:
1259 // Cut, Copy and Paste
1260 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1261 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1262 "applications and are among the most used commands. That's why their "
1263 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1264 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1265 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1266 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1267 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1268 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1269 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1270 "the clipboard to a new location. The items will be removed from their "
1271 "initial location.") + cutCopyPastePara
);
1272 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1273 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1274 "items in your current selection to the <emphasis>clipboard</emphasis>."
1275 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1276 "from the clipboard to a new location.") + cutCopyPastePara
);
1277 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1278 // The text of the paste-action is modified dynamically by Dolphin
1279 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1280 // due to the long text, the text "Paste" is used:
1281 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1282 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1283 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1284 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1285 "action they are removed from their old location.") + cutCopyPastePara
);
1287 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1288 searchAction
->setText(i18n("Search..."));
1289 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1290 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1291 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1292 "There you can enter search terms and specify settings to find the "
1293 "objects you are looking for.</para><para>Use this help again on "
1294 "the find bar so we can have a look at it while the settings are "
1295 "explained.</para>"));
1297 // toggle_search acts as a copy of the main searchAction to be used mainly
1298 // in the toolbar, with no default shortcut attached, to avoid messing with
1299 // existing workflows (search bar always open and Ctrl-F to focus)
1300 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1301 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1302 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1303 toggleSearchAction
->setIcon(searchAction
->icon());
1304 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1305 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1306 toggleSearchAction
->setCheckable(true);
1308 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1309 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1310 "files and folders in the current location."));
1312 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1313 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1314 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1315 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1316 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1317 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_A
);
1318 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1320 // setup 'View' menu
1321 // (note that most of it is set up in DolphinViewActionHandler)
1323 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1324 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1325 "the folder view below into two autonomous views.</para><para>This "
1326 "way you can see two locations at once and move items between them "
1327 "quickly.</para>Click this again afterwards to recombine the views."));
1328 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1329 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1331 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1332 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
+ Qt::Key_S
);
1333 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1334 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1335 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1336 stashSplit
->setCheckable(false);
1337 stashSplit
->setVisible(KProtocolInfo::isKnownProtocol("stash"));
1338 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1340 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1342 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1343 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1344 stop
->setToolTip(i18nc("@info", "Stop loading"));
1345 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1346 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1347 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1349 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1350 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1351 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1352 "This toggles the <emphasis>Location Bar</emphasis> to be "
1353 "editable so you can directly enter a location you want to go to.<nl/>"
1354 "You can also switch to editing by clicking to the right of the "
1355 "location and switch back by confirming the edited location."));
1356 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1357 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1359 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1360 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1361 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1362 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1363 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1364 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1365 "This switches to editing the location and selects it "
1366 "so you can quickly enter a different location."));
1367 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
+ Qt::Key_L
);
1368 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1372 QScopedPointer
<QAction
> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
1373 m_backAction
= new KToolBarPopupAction(backAction
->icon(), backAction
->text(), actionCollection());
1374 m_backAction
->setObjectName(backAction
->objectName());
1375 m_backAction
->setShortcuts(backAction
->shortcuts());
1377 m_backAction
->setDelayed(true);
1378 m_backAction
->setStickyMenu(false);
1379 connect(m_backAction
, &QAction::triggered
, this, &DolphinMainWindow::goBack
);
1380 connect(m_backAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu
);
1381 connect(m_backAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoBack
);
1382 actionCollection()->addAction(m_backAction
->objectName(), m_backAction
);
1384 auto backShortcuts
= m_backAction
->shortcuts();
1385 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1386 actionCollection()->setDefaultShortcuts(m_backAction
, backShortcuts
);
1388 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1389 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1390 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1391 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1392 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1393 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1394 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1395 this, &DolphinMainWindow::closedTabsCountChanged
);
1397 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1398 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1399 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1400 "This returns you to the previously closed tab."));
1401 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_T
);
1402 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1403 undoCloseTab
->setEnabled(false);
1404 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1406 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1407 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1408 "the last change you made to files or folders.<nl/>"
1409 "Such changes include <interface>creating, renaming</interface> "
1410 "and <interface>moving</interface> them to a different location "
1411 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1412 "be undone will ask for your confirmation."));
1413 undoAction
->setEnabled(false); // undo should be disabled by default
1416 QScopedPointer
<QAction
> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
1417 m_forwardAction
= new KToolBarPopupAction(forwardAction
->icon(), forwardAction
->text(), actionCollection());
1418 m_forwardAction
->setObjectName(forwardAction
->objectName());
1419 m_forwardAction
->setShortcuts(forwardAction
->shortcuts());
1421 m_forwardAction
->setDelayed(true);
1422 m_forwardAction
->setStickyMenu(false);
1423 connect(m_forwardAction
, &QAction::triggered
, this, &DolphinMainWindow::goForward
);
1424 connect(m_forwardAction
->menu(), &QMenu::aboutToShow
, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu
);
1425 connect(m_forwardAction
->menu(), &QMenu::triggered
, this, &DolphinMainWindow::slotGoForward
);
1426 actionCollection()->addAction(m_forwardAction
->objectName(), m_forwardAction
);
1427 // enable middle-click to open in a new tab
1428 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
1429 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked
);
1430 m_backAction
->menu()->installEventFilter(middleClickEventFilter
);
1431 m_forwardAction
->menu()->installEventFilter(middleClickEventFilter
);
1432 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1433 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1434 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1435 "<filename>Home</filename> folder.<nl/>Every user account "
1436 "has their own <filename>Home</filename> that contains their data "
1437 "including folders that contain personal application data."));
1439 // setup 'Tools' menu
1440 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1441 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1442 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1443 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1444 "There you can enter a text to filter the files and folders currently displayed. "
1445 "Only those that contain the text in their name will be kept in view."));
1446 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1447 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
+ Qt::Key_I
, Qt::Key_Slash
});
1448 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1450 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1451 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1452 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1453 compareFiles
->setEnabled(false);
1454 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1456 #ifdef HAVE_TERMINAL
1457 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1458 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1459 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1460 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1461 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1462 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1463 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
1464 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
+ Qt::Key_F4
);
1465 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1469 // setup 'Bookmarks' menu
1470 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1471 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1472 // Make the toolbar button version work properly on click
1473 bookmarkMenu
->setDelayed(false);
1474 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1475 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1477 // setup 'Settings' menu
1478 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1479 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1480 "This switches between having a <emphasis>Menubar</emphasis> "
1481 "and having a <interface>Control</interface> button. Both "
1482 "contain mostly the same commands and configuration options."));
1483 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1484 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1485 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1487 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1488 m_helpMenu
= new KHelpMenu(nullptr);
1489 m_helpMenu
->menu()->installEventFilter(this);
1490 // remove duplicate shortcuts
1491 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setShortcut(QKeySequence());
1492 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setShortcut(QKeySequence());
1494 // not in menu actions
1495 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1496 nextTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::Key_Tab
));
1498 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1499 prevTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_Tab
));
1501 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1502 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1503 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1504 activateNextTab
->setEnabled(false);
1505 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1506 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1508 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1509 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1510 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1511 activatePrevTab
->setEnabled(false);
1512 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1513 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1516 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1517 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1518 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1519 showTarget
->setEnabled(false);
1520 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1522 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1523 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1524 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1525 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1527 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1528 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1529 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1530 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1532 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1533 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1534 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1535 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1538 void DolphinMainWindow::setupDockWidgets()
1540 const bool lock
= GeneralSettings::lockPanels();
1542 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1543 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1544 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1545 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1546 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1547 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1548 "switches between having panels <emphasis>locked</emphasis> or "
1549 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1550 "dragged to the other side of the window and have a close "
1551 "button.<nl/>Locked panels are embedded more cleanly."));
1552 lockLayoutAction
->setActive(lock
);
1553 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1555 // Setup "Information"
1556 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1557 infoDock
->setLocked(lock
);
1558 infoDock
->setObjectName(QStringLiteral("infoDock"));
1559 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1562 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1563 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1564 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1565 infoDock
->setWidget(infoPanel
);
1567 QAction
* infoAction
= infoDock
->toggleViewAction();
1568 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1570 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1571 connect(this, &DolphinMainWindow::urlChanged
,
1572 infoPanel
, &InformationPanel::setUrl
);
1573 connect(this, &DolphinMainWindow::selectionChanged
,
1574 infoPanel
, &InformationPanel::setSelection
);
1575 connect(this, &DolphinMainWindow::requestItemInfo
,
1576 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1579 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1580 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1581 "hide panels like this go to <interface>Control|Panels</interface> "
1582 "or <interface>View|Panels</interface>.</para>");
1584 actionCollection()->action(QStringLiteral("show_information_panel"))
1585 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1586 "<emphasis>information</emphasis> panel at the right side of the "
1587 "window.</para><para>The panel provides in-depth information "
1588 "about the items your mouse is hovering over or about the selected "
1589 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1590 "For single items a preview of their contents is provided.</para>"));
1592 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1593 "provides in-depth information about the items your mouse is "
1594 "hovering over or about the selected items. Otherwise it informs "
1595 "you about the currently viewed folder.<nl/>For single items a "
1596 "preview of their contents is provided.</para><para>You can configure "
1597 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1600 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1601 foldersDock
->setLocked(lock
);
1602 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1603 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1604 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1605 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1606 foldersDock
->setWidget(foldersPanel
);
1608 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1609 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1611 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1612 connect(this, &DolphinMainWindow::urlChanged
,
1613 foldersPanel
, &FoldersPanel::setUrl
);
1614 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1615 this, &DolphinMainWindow::changeUrl
);
1616 connect(foldersPanel
, &FoldersPanel::folderMiddleClicked
,
1617 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1618 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1619 this, &DolphinMainWindow::showErrorMessage
);
1621 actionCollection()->action(QStringLiteral("show_folders_panel"))
1622 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1623 "<emphasis>folders</emphasis> panel at the left side of the window."
1624 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1625 "</emphasis> in a <emphasis>tree view</emphasis>."));
1626 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1627 "shows the folders of the <emphasis>file system</emphasis> in a "
1628 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1629 "there. Click the arrow to the left of a folder to see its subfolders. "
1630 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1633 #ifdef HAVE_TERMINAL
1634 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1635 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1636 terminalDock
->setLocked(lock
);
1637 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1638 m_terminalPanel
= new TerminalPanel(terminalDock
);
1639 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1640 terminalDock
->setWidget(m_terminalPanel
);
1642 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1643 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1644 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1645 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1646 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1647 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1649 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1650 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1652 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1653 connect(this, &DolphinMainWindow::urlChanged
,
1654 m_terminalPanel
, &TerminalPanel::setUrl
);
1656 if (GeneralSettings::version() < 200) {
1657 terminalDock
->hide();
1660 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1661 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1662 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1663 "<nl/>The location in the terminal will always match the folder "
1664 "view so you can navigate using either.</para><para>The terminal "
1665 "panel is not needed for basic computer usage but can be useful "
1666 "for advanced tasks. To learn more about terminals use the help "
1667 "in a standalone terminal application like Konsole.</para>"));
1668 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1669 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1670 "normal terminal but will match the location of the folder view "
1671 "so you can navigate using either.</para><para>The terminal panel "
1672 "is not needed for basic computer usage but can be useful for "
1673 "advanced tasks. To learn more about terminals use the help in a "
1674 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1678 if (GeneralSettings::version() < 200) {
1680 foldersDock
->hide();
1684 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1685 placesDock
->setLocked(lock
);
1686 placesDock
->setObjectName(QStringLiteral("placesDock"));
1687 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1689 m_placesPanel
= new PlacesPanel(placesDock
);
1690 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1691 placesDock
->setWidget(m_placesPanel
);
1693 QAction
*placesAction
= placesDock
->toggleViewAction();
1694 createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1696 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1697 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1698 this, &DolphinMainWindow::slotPlaceActivated
);
1699 connect(m_placesPanel
, &PlacesPanel::placeMiddleClicked
,
1700 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1701 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1702 this, &DolphinMainWindow::showErrorMessage
);
1703 connect(this, &DolphinMainWindow::urlChanged
,
1704 m_placesPanel
, &PlacesPanel::setUrl
);
1705 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1706 m_tabWidget
, &DolphinTabWidget::slotPlacesPanelVisibilityChanged
);
1707 connect(this, &DolphinMainWindow::settingsChanged
,
1708 m_placesPanel
, &PlacesPanel::readSettings
);
1709 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1710 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1711 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1712 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1713 m_tabWidget
->slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1715 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1716 actionShowAllPlaces
->setCheckable(true);
1717 actionShowAllPlaces
->setDisabled(true);
1718 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1719 "all places in the places panel that have been hidden. They will "
1720 "appear semi-transparent unless you uncheck their hide property."));
1722 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1723 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1724 m_placesPanel
->showHiddenEntries(checked
);
1727 connect(m_placesPanel
, &PlacesPanel::showHiddenEntriesChanged
, this, [actionShowAllPlaces
] (bool checked
){
1728 actionShowAllPlaces
->setChecked(checked
);
1729 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1732 actionCollection()->action(QStringLiteral("show_places_panel"))
1733 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1734 "<emphasis>places</emphasis> panel at the left side of the window."
1735 "</para><para>It allows you to go to locations you have "
1736 "bookmarked and to access disk or media attached to the computer "
1737 "or to the network. It also contains sections to find recently "
1738 "saved files or files of a certain type.</para>"));
1739 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1740 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1741 "you have bookmarked and to access disk or media attached to the "
1742 "computer or to the network. It also contains sections to find "
1743 "recently saved files or files of a certain type.</para><para>"
1744 "Click on an entry to go there. Click with the right mouse button "
1745 "instead to open any entry in a new tab or new window.</para>"
1746 "<para>New entries can be added by dragging folders onto this panel. "
1747 "Right-click any section or entry to hide it. Right-click an empty "
1748 "space on this panel and select <interface>Show Hidden Places"
1749 "</interface> to display it again.</para>") + panelWhatsThis
);
1751 // Add actions into the "Panels" menu
1752 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
1753 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
1754 panelsMenu
->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
1755 panelsMenu
->setDelayed(false);
1756 const KActionCollection
* ac
= actionCollection();
1757 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
1759 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
1761 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
1762 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
1763 panelsMenu
->addSeparator();
1764 panelsMenu
->addAction(actionShowAllPlaces
);
1765 panelsMenu
->addAction(lockLayoutAction
);
1767 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
1768 actionShowAllPlaces
->setEnabled(m_placesPanel
->hiddenListCount());
1773 void DolphinMainWindow::updateFileAndEditActions()
1775 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
1776 const KActionCollection
* col
= actionCollection();
1777 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
1779 if (list
.isEmpty()) {
1780 stateChanged(QStringLiteral("has_no_selection"));
1782 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer
->placesText()));
1784 stateChanged(QStringLiteral("has_selection"));
1786 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
1787 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
1788 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
1789 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
1790 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
1791 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
1793 if (list
.length() == 1 && list
.first().isDir()) {
1794 addToPlacesAction
->setEnabled(true);
1795 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list
.first().name()));
1797 addToPlacesAction
->setEnabled(false);
1798 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1801 KFileItemListProperties
capabilities(list
);
1802 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
1804 renameAction
->setEnabled(capabilities
.supportsMoving());
1805 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1806 deleteAction
->setEnabled(capabilities
.supportsDeleting());
1807 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
1808 cutAction
->setEnabled(capabilities
.supportsMoving());
1809 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
1813 void DolphinMainWindow::updateViewActions()
1815 m_actionHandler
->updateViewActions();
1817 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
1818 showFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
1820 updateSplitAction();
1822 QAction
* editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
1823 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
1824 editableLocactionAction
->setChecked(urlNavigator
->isUrlEditable());
1827 void DolphinMainWindow::updateGoActions()
1829 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
1830 const QUrl currentUrl
= m_activeViewContainer
->url();
1831 // I think this is one of the best places to firstly be confronted
1832 // with a file system and its hierarchy. Talking about the root
1833 // directory might seem too much here but it is the question that
1834 // naturally arises in this context.
1835 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
1836 "the folder that contains the currently viewed one.</para>"
1837 "<para>All files and folders are organized in a hierarchical "
1838 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
1839 "a directory that contains all data connected to this computer"
1840 "—the <emphasis>root directory</emphasis>.</para>"));
1841 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
1844 void DolphinMainWindow::createControlButton()
1846 if (m_controlButton
) {
1849 Q_ASSERT(!m_controlButton
);
1851 m_controlButton
= new QToolButton(this);
1852 m_controlButton
->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
1853 m_controlButton
->setToolTip(i18nc("@action", "Show menu"));
1854 m_controlButton
->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis
);
1855 m_controlButton
->setPopupMode(QToolButton::InstantPopup
);
1857 QMenu
* controlMenu
= new QMenu(m_controlButton
);
1858 connect(controlMenu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateControlMenu
);
1859 controlMenu
->installEventFilter(this);
1861 m_controlButton
->setMenu(controlMenu
);
1863 toolBar()->addWidget(m_controlButton
);
1864 connect(toolBar(), &KToolBar::iconSizeChanged
,
1865 m_controlButton
, &QToolButton::setIconSize
);
1867 // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
1868 // gets edited. In this case we must add them again. The adding is done asynchronously by
1869 // m_updateToolBarTimer.
1870 connect(m_controlButton
, &QToolButton::destroyed
, this, &DolphinMainWindow::slotControlButtonDeleted
);
1871 m_updateToolBarTimer
= new QTimer(this);
1872 m_updateToolBarTimer
->setInterval(500);
1873 connect(m_updateToolBarTimer
, &QTimer::timeout
, this, &DolphinMainWindow::updateToolBar
);
1876 void DolphinMainWindow::deleteControlButton()
1878 delete m_controlButton
;
1879 m_controlButton
= nullptr;
1881 delete m_updateToolBarTimer
;
1882 m_updateToolBarTimer
= nullptr;
1885 bool DolphinMainWindow::addActionToMenu(QAction
* action
, QMenu
* menu
)
1890 const KToolBar
* toolBarWidget
= toolBar();
1891 foreach (const QWidget
* widget
, action
->associatedWidgets()) {
1892 if (widget
== toolBarWidget
) {
1897 menu
->addAction(action
);
1901 void DolphinMainWindow::refreshViews()
1903 m_tabWidget
->refreshViews();
1905 if (GeneralSettings::modifiedStartupSettings()) {
1906 // The startup settings have been changed by the user (see bug #254947).
1907 // Synchronize the split-view setting with the active view:
1908 const bool splitView
= GeneralSettings::splitView();
1909 m_tabWidget
->currentTabPage()->setSplitViewEnabled(splitView
);
1910 updateSplitAction();
1911 updateWindowTitle();
1914 emit
settingsChanged();
1917 void DolphinMainWindow::clearStatusBar()
1919 m_activeViewContainer
->statusBar()->resetToDefaultText();
1922 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
1924 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
1925 this, &DolphinMainWindow::updateFilterBarAction
);
1926 connect(container
, &DolphinViewContainer::writeStateChanged
,
1927 this, &DolphinMainWindow::slotWriteStateChanged
);
1928 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
1929 this, &DolphinMainWindow::updateSearchAction
);
1931 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1932 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
1934 const DolphinView
* view
= container
->view();
1935 connect(view
, &DolphinView::selectionChanged
,
1936 this, &DolphinMainWindow::slotSelectionChanged
);
1937 connect(view
, &DolphinView::requestItemInfo
,
1938 this, &DolphinMainWindow::requestItemInfo
);
1939 connect(view
, &DolphinView::tabRequested
,
1940 this, &DolphinMainWindow::openNewTab
);
1941 connect(view
, &DolphinView::requestContextMenu
,
1942 this, &DolphinMainWindow::openContextMenu
);
1943 connect(view
, &DolphinView::directoryLoadingStarted
,
1944 this, &DolphinMainWindow::enableStopAction
);
1945 connect(view
, &DolphinView::directoryLoadingCompleted
,
1946 this, &DolphinMainWindow::disableStopAction
);
1947 connect(view
, &DolphinView::directoryLoadingCompleted
,
1948 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
1949 connect(view
, &DolphinView::goBackRequested
,
1950 this, &DolphinMainWindow::goBack
);
1951 connect(view
, &DolphinView::goForwardRequested
,
1952 this, &DolphinMainWindow::goForward
);
1953 connect(view
, &DolphinView::urlActivated
,
1954 this, &DolphinMainWindow::handleUrl
);
1956 const KUrlNavigator
* navigator
= container
->urlNavigator();
1957 connect(navigator
, &KUrlNavigator::urlChanged
,
1958 this, &DolphinMainWindow::changeUrl
);
1959 connect(navigator
, &KUrlNavigator::historyChanged
,
1960 this, &DolphinMainWindow::updateHistory
);
1961 connect(navigator
, &KUrlNavigator::editableStateChanged
,
1962 this, &DolphinMainWindow::slotEditableStateChanged
);
1963 connect(navigator
, &KUrlNavigator::tabRequested
,
1964 this, &DolphinMainWindow::openNewTabAfterLastTab
);
1967 void DolphinMainWindow::updateSplitAction()
1969 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
1970 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
1971 if (tabPage
->splitViewEnabled()) {
1972 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
1973 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
1974 splitAction
->setToolTip(i18nc("@info", "Close left view"));
1975 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
1977 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
1978 splitAction
->setToolTip(i18nc("@info", "Close right view"));
1979 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
1982 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
1983 splitAction
->setToolTip(i18nc("@info", "Split view"));
1984 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
1988 bool DolphinMainWindow::isKompareInstalled() const
1990 static bool initialized
= false;
1991 static bool installed
= false;
1993 // TODO: maybe replace this approach later by using a menu
1994 // plugin like kdiff3plugin.cpp
1995 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
2001 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
2002 const QKeySequence
& shortcut
,
2003 QAction
* dockAction
,
2004 const QString
& actionName
)
2006 QAction
* panelAction
= actionCollection()->addAction(actionName
);
2007 panelAction
->setCheckable(true);
2008 panelAction
->setChecked(dockAction
->isChecked());
2009 panelAction
->setText(dockAction
->text());
2010 panelAction
->setIcon(icon
);
2011 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
2013 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
2014 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
2017 void DolphinMainWindow::setupWhatsThis()
2020 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2021 "<emphasis>Menubar</emphasis>. It provides access to commands and "
2022 "configuration options. Left-click on any of the menus on this "
2023 "bar to see its contents.</para><para>The Menubar can be hidden "
2024 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
2025 "most of its contents become available through a <interface>Control"
2026 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
2027 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
2028 "<emphasis>Toolbar</emphasis>. It allows quick access to "
2029 "frequently used actions.</para><para>It is highly customizable. "
2030 "All items you see in the <interface>Control</interface> menu or "
2031 "in the <interface>Menubar</interface> can be placed on the "
2032 "Toolbar. Just right-click on it and select <interface>Configure "
2033 "Toolbars…</interface> or find this action in the <interface>"
2034 "Control</interface> or <interface>Settings</interface> menu."
2035 "</para><para>The location of the bar and the style of its "
2036 "buttons can also be changed in the right-click menu. Right-click "
2037 "a button if you want to show or hide its text.</para>"));
2038 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
2039 "<para>Here you can see the <emphasis>folders</emphasis> and "
2040 "<emphasis>files</emphasis> that are at the location described in "
2041 "the <interface>Location Bar</interface> above. This area is the "
2042 "central part of this application where you navigate to the files "
2043 "you want to use.</para><para>For an elaborate and general "
2044 "introduction to this application <link "
2045 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
2046 "click here</link>. This will open an introductory article from "
2047 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
2048 "explanations of all the features of this <emphasis>view</emphasis> "
2049 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
2050 "instead. This will open a page from the <emphasis>Handbook"
2051 "</emphasis> that covers the basics.</para>"));
2054 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2055 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2056 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2057 "There you can set up key combinations to trigger an action when "
2058 "they are pressed simultaneously. All commands in this application can "
2059 "be triggered this way.</para>"));
2060 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2061 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2062 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2063 "<para>All items you see in the <interface>Control</interface> menu "
2064 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2065 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2066 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2067 "change a multitude of settings for this application. For an explanation "
2068 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2069 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2072 // The whatsthis has to be set for the m_helpMenu and for the
2073 // StandardAction separately because both are used in different locations.
2074 // m_helpMenu is only used for createControlButton() button.
2076 // Links do not work within the Menubar so texts without links are provided there.
2078 // i18n: If the external link isn't available in your language you should
2079 // probably state the external link language at least in brackets to not
2080 // frustrate the user. If there are multiple languages that the user might
2081 // know with a reasonable chance you might want to have 2 external links.
2082 // The same is in my opinion true for every external link you translate.
2083 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2084 "<para>This opens the Handbook for this application. It provides "
2085 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2086 actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents
))
2087 ->setWhatsThis(whatsThisHelpContents
2088 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2089 "<para>If you want more elaborate introductions to the "
2090 "different features of <emphasis>Dolphin</emphasis> "
2091 "go to the KDE UserBase Wiki.</para>"));
2092 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setWhatsThis(whatsThisHelpContents
2093 + xi18nc("@info:whatsthis second half of handbook text with link",
2094 "<para>If you want more elaborate introductions to the "
2095 "different features of <emphasis>Dolphin</emphasis> "
2096 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2097 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2099 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2100 "<para>This is the button that invokes the help feature you are "
2101 "using right now! Click it, then click any component of this "
2102 "application to ask \"What's this?\" about it. The mouse cursor "
2103 "will change appearance if no help is available for a spot.</para>");
2104 actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis
))
2105 ->setWhatsThis(whatsThisWhatsThis
2106 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2107 "<para>There are two other ways to get help for this application: The "
2108 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2109 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2110 "article about <emphasis>File Management</emphasis> online."
2111 "</para><para>The \"What's this?\" help is "
2112 "missing in most other windows so don't get too used to this.</para>"));
2113 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setWhatsThis(whatsThisWhatsThis
2114 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2115 "<para>There are two other ways to get help: "
2116 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2117 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2118 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2119 "missing in most other windows so don't get too used to this.</para>"));
2121 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2122 "window that will guide you through reporting errors or flaws "
2123 "in this application or in other KDE software.</para>");
2124 actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug
))
2125 ->setWhatsThis(whatsThisReportBug
);
2126 m_helpMenu
->action(KHelpMenu::menuReportBug
)->setWhatsThis(whatsThisReportBug
2127 + xi18nc("@info:whatsthis second half of reportbug text with link",
2128 "<para>High-quality bug reports are much appreciated. To learn "
2129 "how to make your bug report as effective as possible "
2130 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2131 "click here</link>.</para>"));
2133 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2134 "<emphasis>web page</emphasis> where you can donate to "
2135 "support the continued work on this application and many "
2136 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2137 "<para>Donating is the easiest and fastest way to efficiently "
2138 "support KDE and its projects. KDE projects are available for "
2139 "free therefore your donation is needed to cover things that "
2140 "require money like servers, contributor meetings, etc.</para>"
2141 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2142 "organization behind the KDE community.</para>");
2143 actionCollection()->action(KStandardAction::name(KStandardAction::Donate
))
2144 ->setWhatsThis(whatsThisDonate
);
2145 m_helpMenu
->action(KHelpMenu::menuDonate
)->setWhatsThis(whatsThisDonate
);
2147 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2148 "With this you can change the language this application uses."
2149 "<nl/>You can even set secondary languages which will be used "
2150 "if texts are not available in your preferred language.");
2151 actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
))
2152 ->setWhatsThis(whatsThisSwitchLanguage
);
2153 m_helpMenu
->action(KHelpMenu::menuSwitchLanguage
)->setWhatsThis(whatsThisSwitchLanguage
);
2155 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2156 "window that informs you about the version, license, "
2157 "used libraries and maintainers of this application.");
2158 actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp
))
2159 ->setWhatsThis(whatsThisAboutApp
);
2160 m_helpMenu
->action(KHelpMenu::menuAboutApp
)->setWhatsThis(whatsThisAboutApp
);
2162 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2163 "window with information about <emphasis>KDE</emphasis>. "
2164 "The KDE community are the people behind this free software."
2165 "<nl/>If you like using this application but don't know "
2166 "about KDE or want to see a cute dragon have a look!");
2167 actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE
))
2168 ->setWhatsThis(whatsThisAboutKDE
);
2169 m_helpMenu
->action(KHelpMenu::menuAboutKDE
)->setWhatsThis(whatsThisAboutKDE
);
2172 bool DolphinMainWindow::event(QEvent
*event
)
2174 if (event
->type() == QEvent::WhatsThisClicked
) {
2176 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2177 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2180 return KXmlGuiWindow::event(event
);
2183 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2186 if (event
->type() == QEvent::WhatsThisClicked
) {
2188 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2189 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2195 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2196 KIO::FileUndoManager::UiInterface()
2200 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2204 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2206 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2208 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2209 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2211 KIO::FileUndoManager::UiInterface::jobError(job
);
2215 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2217 return m_tabWidget
->isUrlOpen(QUrl::fromUserInput((url
)));