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 <KToolInvocation>
69 #include <KUrlComboBox>
70 #include <KUrlNavigator>
71 #include <KWindowSystem>
73 #include <QApplication>
75 #include <QCloseEvent>
76 #include <QDesktopServices>
82 #include <QPushButton>
84 #include <QStandardPaths>
86 #include <QToolButton>
87 #include <QWhatsThisClickedEvent>
90 // Used for GeneralSettings::version() to determine whether
91 // an updated version of Dolphin is running.
92 const int CurrentDolphinVersion
= 200;
95 DolphinMainWindow::DolphinMainWindow() :
96 KXmlGuiWindow(nullptr, Qt::WindowContextHelpButtonHint
),
97 m_newFileMenu(nullptr),
100 m_activeViewContainer(nullptr),
101 m_actionHandler(nullptr),
102 m_remoteEncoding(nullptr),
104 m_bookmarkHandler(nullptr),
105 m_controlButton(nullptr),
106 m_updateToolBarTimer(nullptr),
107 m_lastHandleUrlStatJob(nullptr),
108 m_terminalPanel(nullptr),
109 m_placesPanel(nullptr),
110 m_tearDownFromPlacesRequested(false)
112 Q_INIT_RESOURCE(dolphin
);
113 setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
114 setObjectName(QStringLiteral("Dolphin#"));
116 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
,
117 this, &DolphinMainWindow::showErrorMessage
);
119 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
120 undoManager
->setUiInterface(new UndoUiInterface());
122 connect(undoManager
, QOverload
<bool>::of(&KIO::FileUndoManager::undoAvailable
),
123 this, &DolphinMainWindow::slotUndoAvailable
);
124 connect(undoManager
, &KIO::FileUndoManager::undoTextChanged
,
125 this, &DolphinMainWindow::slotUndoTextChanged
);
126 connect(undoManager
, &KIO::FileUndoManager::jobRecordingStarted
,
127 this, &DolphinMainWindow::clearStatusBar
);
128 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
129 this, &DolphinMainWindow::showCommand
);
131 GeneralSettings
* generalSettings
= GeneralSettings::self();
132 const bool firstRun
= (generalSettings
->version() < 200);
134 generalSettings
->setViewPropsTimestamp(QDateTime::currentDateTime());
137 setAcceptDrops(true);
139 m_tabWidget
= new DolphinTabWidget(this);
140 m_tabWidget
->setObjectName("tabWidget");
141 connect(m_tabWidget
, &DolphinTabWidget::activeViewChanged
,
142 this, &DolphinMainWindow::activeViewChanged
);
143 connect(m_tabWidget
, &DolphinTabWidget::tabCountChanged
,
144 this, &DolphinMainWindow::tabCountChanged
);
145 connect(m_tabWidget
, &DolphinTabWidget::currentUrlChanged
,
146 this, &DolphinMainWindow::updateWindowTitle
);
147 setCentralWidget(m_tabWidget
);
151 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
152 connect(m_actionHandler
, &DolphinViewActionHandler::actionBeingHandled
, this, &DolphinMainWindow::clearStatusBar
);
153 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinMainWindow::createDirectory
);
155 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
156 connect(this, &DolphinMainWindow::urlChanged
,
157 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
161 setupGUI(Keys
| Save
| Create
| ToolBar
);
162 stateChanged(QStringLiteral("new_file"));
164 QClipboard
* clipboard
= QApplication::clipboard();
165 connect(clipboard
, &QClipboard::dataChanged
,
166 this, &DolphinMainWindow::updatePasteAction
);
168 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
169 showFilterBarAction
->setChecked(generalSettings
->filterBar());
172 menuBar()->setVisible(false);
173 // Assure a proper default size if Dolphin runs the first time
177 const bool showMenu
= !menuBar()->isHidden();
178 QAction
* showMenuBarAction
= actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar
));
179 showMenuBarAction
->setChecked(showMenu
); // workaround for bug #171080
181 createControlButton();
184 // enable middle-click on back/forward/up to open in a new tab
185 auto *middleClickEventFilter
= new MiddleClickActionEventFilter(this);
186 connect(middleClickEventFilter
, &MiddleClickActionEventFilter::actionMiddleClicked
, this, &DolphinMainWindow::slotToolBarActionMiddleClicked
);
187 toolBar()->installEventFilter(middleClickEventFilter
);
192 DolphinMainWindow::~DolphinMainWindow()
196 QVector
<DolphinViewContainer
*> DolphinMainWindow::viewContainers() const
198 QVector
<DolphinViewContainer
*> viewContainers
;
199 viewContainers
.reserve(m_tabWidget
->count());
200 for (int i
= 0; i
< m_tabWidget
->count(); ++i
) {
201 viewContainers
<< m_tabWidget
->tabPageAt(i
)->activeViewContainer();
203 return viewContainers
;
206 void DolphinMainWindow::openDirectories(const QList
<QUrl
>& dirs
, bool splitView
)
208 m_tabWidget
->openDirectories(dirs
, splitView
);
211 void DolphinMainWindow::openDirectories(const QStringList
& dirs
, bool splitView
)
213 openDirectories(QUrl::fromStringList(dirs
), splitView
);
216 void DolphinMainWindow::openFiles(const QList
<QUrl
>& files
, bool splitView
)
218 m_tabWidget
->openFiles(files
, splitView
);
221 void DolphinMainWindow::openFiles(const QStringList
& files
, bool splitView
)
223 openFiles(QUrl::fromStringList(files
), splitView
);
226 void DolphinMainWindow::activateWindow()
228 KStartupInfo::setNewStartupId(window(), KStartupInfo::startupId());
229 KWindowSystem::activateWindow(window()->effectiveWinId());
232 void DolphinMainWindow::showCommand(CommandType command
)
234 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
236 case KIO::FileUndoManager::Copy
:
237 statusBar
->setText(i18nc("@info:status", "Successfully copied."));
239 case KIO::FileUndoManager::Move
:
240 statusBar
->setText(i18nc("@info:status", "Successfully moved."));
242 case KIO::FileUndoManager::Link
:
243 statusBar
->setText(i18nc("@info:status", "Successfully linked."));
245 case KIO::FileUndoManager::Trash
:
246 statusBar
->setText(i18nc("@info:status", "Successfully moved to trash."));
248 case KIO::FileUndoManager::Rename
:
249 statusBar
->setText(i18nc("@info:status", "Successfully renamed."));
252 case KIO::FileUndoManager::Mkdir
:
253 statusBar
->setText(i18nc("@info:status", "Created folder."));
261 void DolphinMainWindow::pasteIntoFolder()
263 m_activeViewContainer
->view()->pasteIntoFolder();
266 void DolphinMainWindow::changeUrl(const QUrl
&url
)
268 if (!KProtocolManager::supportsListing(url
)) {
269 // The URL navigator only checks for validity, not
270 // if the URL can be listed. An error message is
271 // shown due to DolphinViewContainer::restoreView().
275 m_activeViewContainer
->setUrl(url
);
276 updateFileAndEditActions();
281 emit
urlChanged(url
);
284 void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl
& url
)
286 if (m_tearDownFromPlacesRequested
&& url
== QUrl::fromLocalFile(QDir::homePath())) {
287 m_placesPanel
->proceedWithTearDown();
288 m_tearDownFromPlacesRequested
= false;
291 m_activeViewContainer
->setAutoGrabFocus(false);
293 m_activeViewContainer
->setAutoGrabFocus(true);
296 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
298 KToggleAction
* editableLocationAction
=
299 static_cast<KToggleAction
*>(actionCollection()->action(QStringLiteral("editable_location")));
300 editableLocationAction
->setChecked(editable
);
303 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
305 updateFileAndEditActions();
307 const int selectedUrlsCount
= m_tabWidget
->currentTabPage()->selectedItemsCount();
309 QAction
* compareFilesAction
= actionCollection()->action(QStringLiteral("compare_files"));
310 if (selectedUrlsCount
== 2) {
311 compareFilesAction
->setEnabled(isKompareInstalled());
313 compareFilesAction
->setEnabled(false);
316 emit
selectionChanged(selection
);
319 void DolphinMainWindow::updateHistory()
321 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
322 const int index
= urlNavigator
->historyIndex();
324 QAction
* backAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Back
));
326 backAction
->setToolTip(i18nc("@info", "Go back"));
327 backAction
->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
328 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
331 QAction
* forwardAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Forward
));
333 forwardAction
->setToolTip(i18nc("@info", "Go forward"));
334 forwardAction
->setWhatsThis(xi18nc("@info:whatsthis go forward",
335 "This undoes a <interface>Go|Back</interface> action."));
336 forwardAction
->setEnabled(index
> 0);
340 void DolphinMainWindow::updateFilterBarAction(bool show
)
342 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
343 showFilterBarAction
->setChecked(show
);
346 void DolphinMainWindow::openNewMainWindow()
348 Dolphin::openNewWindow({m_activeViewContainer
->url()}, this);
351 void DolphinMainWindow::openNewActivatedTab()
353 m_tabWidget
->openNewActivatedTab();
356 void DolphinMainWindow::addToPlaces()
361 // If nothing is selected, act on the current dir
362 if (m_activeViewContainer
->view()->selectedItems().count() == 0) {
363 url
= m_activeViewContainer
->url();
364 name
= m_activeViewContainer
->placesText();
366 const auto dirToAdd
= m_activeViewContainer
->view()->selectedItems().first();
367 url
= dirToAdd
.url();
368 name
= dirToAdd
.name();
371 PlacesItemModel model
;
373 if (m_activeViewContainer
->isSearchModeEnabled()) {
374 icon
= QStringLiteral("folder-saved-search-symbolic");
376 icon
= KIO::iconNameForUrl(url
);
378 model
.createPlacesItem(name
, url
, icon
);
382 void DolphinMainWindow::openNewTab(const QUrl
& url
, DolphinTabWidget::TabPlacement tabPlacement
)
384 m_tabWidget
->openNewTab(url
, QUrl(), tabPlacement
);
387 void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl
& url
)
389 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterCurrentTab
);
392 void DolphinMainWindow::openNewTabAfterLastTab(const QUrl
& url
)
394 m_tabWidget
->openNewTab(url
, QUrl(), DolphinTabWidget::AfterLastTab
);
397 void DolphinMainWindow::openInNewTab()
399 const KFileItemList
& list
= m_activeViewContainer
->view()->selectedItems();
400 bool tabCreated
= false;
402 foreach (const KFileItem
& item
, list
) {
403 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
);
404 if (!url
.isEmpty()) {
405 openNewTabAfterCurrentTab(url
);
410 // if no new tab has been created from the selection
411 // open the current directory in a new tab
413 openNewTabAfterCurrentTab(m_activeViewContainer
->url());
417 void DolphinMainWindow::openInNewWindow()
421 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
422 if (list
.isEmpty()) {
423 newWindowUrl
= m_activeViewContainer
->url();
424 } else if (list
.count() == 1) {
425 const KFileItem
& item
= list
.first();
426 newWindowUrl
= DolphinView::openItemAsFolderUrl(item
);
429 if (!newWindowUrl
.isEmpty()) {
430 Dolphin::openNewWindow({newWindowUrl
}, this);
434 void DolphinMainWindow::showTarget()
436 const auto link
= m_activeViewContainer
->view()->selectedItems().at(0);
437 const auto linkLocationDir
= QFileInfo(link
.localPath()).absoluteDir();
438 auto linkDestination
= link
.linkDest();
439 if (QFileInfo(linkDestination
).isRelative()) {
440 linkDestination
= linkLocationDir
.filePath(linkDestination
);
442 if (QFileInfo::exists(linkDestination
)) {
443 KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination
).adjusted(QUrl::StripTrailingSlash
)});
445 m_activeViewContainer
->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination
),
446 DolphinViewContainer::Warning
);
450 void DolphinMainWindow::showEvent(QShowEvent
* event
)
452 KXmlGuiWindow::showEvent(event
);
454 if (!event
->spontaneous()) {
455 m_activeViewContainer
->view()->setFocus();
459 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
461 // Find out if Dolphin is closed directly by the user or
462 // by the session manager because the session is closed
463 bool closedByUser
= true;
464 if (qApp
->isSavingSession()) {
465 closedByUser
= false;
468 if (m_tabWidget
->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser
) {
469 // Ask the user if he really wants to quit and close all tabs.
470 // Open a confirmation dialog with 3 buttons:
471 // QDialogButtonBox::Yes -> Quit
472 // QDialogButtonBox::No -> Close only the current tab
473 // QDialogButtonBox::Cancel -> do nothing
474 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
475 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
476 dialog
->setModal(true);
477 QDialogButtonBox
* buttons
= new QDialogButtonBox(QDialogButtonBox::Yes
| QDialogButtonBox::No
| QDialogButtonBox::Cancel
);
478 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
479 KGuiItem::assign(buttons
->button(QDialogButtonBox::No
), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
480 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
481 buttons
->button(QDialogButtonBox::Yes
)->setDefault(true);
483 bool doNotAskAgainCheckboxResult
= false;
485 const auto result
= KMessageBox::createKMessageBox(dialog
,
487 QMessageBox::Warning
,
488 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
490 i18n("Do not ask again"),
491 &doNotAskAgainCheckboxResult
,
492 KMessageBox::Notify
);
494 if (doNotAskAgainCheckboxResult
) {
495 GeneralSettings::setConfirmClosingMultipleTabs(false);
499 case QDialogButtonBox::Yes
:
502 case QDialogButtonBox::No
:
503 // Close only the current tab
504 m_tabWidget
->closeTab();
512 if (m_terminalPanel
->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser
) {
513 // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
514 // Open a confirmation dialog with 3 buttons:
515 // QDialogButtonBox::Yes -> Quit
516 // QDialogButtonBox::No -> Show Terminal Panel
517 // QDialogButtonBox::Cancel -> do nothing
518 QDialog
*dialog
= new QDialog(this, Qt::Dialog
);
519 dialog
->setWindowTitle(i18nc("@title:window", "Confirmation"));
520 dialog
->setModal(true);
521 auto standardButtons
= QDialogButtonBox::Yes
| QDialogButtonBox::Cancel
;
522 if (!m_terminalPanel
->isVisible()) {
523 standardButtons
|= QDialogButtonBox::No
;
525 QDialogButtonBox
*buttons
= new QDialogButtonBox(standardButtons
);
526 KGuiItem::assign(buttons
->button(QDialogButtonBox::Yes
), KStandardGuiItem::quit());
527 if (!m_terminalPanel
->isVisible()) {
529 buttons
->button(QDialogButtonBox::No
),
530 KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
532 KGuiItem::assign(buttons
->button(QDialogButtonBox::Cancel
), KStandardGuiItem::cancel());
534 bool doNotAskAgainCheckboxResult
= false;
536 const auto result
= KMessageBox::createKMessageBox(
539 QMessageBox::Warning
,
540 i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel
->runningProgramName()),
542 i18n("Do not ask again"),
543 &doNotAskAgainCheckboxResult
,
544 KMessageBox::Dangerous
);
546 if (doNotAskAgainCheckboxResult
) {
547 GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
551 case QDialogButtonBox::Yes
:
554 case QDialogButtonBox::No
:
555 actionCollection()->action("show_terminal_panel")->trigger();
556 // Do not quit, ignore quit event
564 GeneralSettings::setVersion(CurrentDolphinVersion
);
565 GeneralSettings::self()->save();
567 KXmlGuiWindow::closeEvent(event
);
570 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
572 m_tabWidget
->saveProperties(group
);
575 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
577 m_tabWidget
->readProperties(group
);
580 void DolphinMainWindow::updateNewMenu()
582 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
583 m_newFileMenu
->checkUpToDate();
584 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
587 void DolphinMainWindow::createDirectory()
589 m_newFileMenu
->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
590 m_newFileMenu
->setPopupFiles(activeViewContainer()->url());
591 m_newFileMenu
->createDirectory();
594 void DolphinMainWindow::quit()
599 void DolphinMainWindow::showErrorMessage(const QString
& message
)
601 m_activeViewContainer
->showMessage(message
, DolphinViewContainer::Error
);
604 void DolphinMainWindow::slotUndoAvailable(bool available
)
606 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
608 undoAction
->setEnabled(available
);
612 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
614 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
616 undoAction
->setText(text
);
620 void DolphinMainWindow::undo()
623 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
624 KIO::FileUndoManager::self()->undo();
627 void DolphinMainWindow::cut()
629 m_activeViewContainer
->view()->cutSelectedItems();
632 void DolphinMainWindow::copy()
634 m_activeViewContainer
->view()->copySelectedItems();
637 void DolphinMainWindow::paste()
639 m_activeViewContainer
->view()->paste();
642 void DolphinMainWindow::find()
644 m_activeViewContainer
->setSearchModeEnabled(true);
647 void DolphinMainWindow::updateSearchAction()
649 QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
650 toggleSearchAction
->setChecked(m_activeViewContainer
->isSearchModeEnabled());
653 void DolphinMainWindow::updatePasteAction()
655 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
656 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
657 pasteAction
->setEnabled(pasteInfo
.first
);
658 pasteAction
->setText(pasteInfo
.second
);
661 void DolphinMainWindow::slotDirectoryLoadingCompleted()
666 void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction
*action
)
668 if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Back
))) {
670 } else if (action
== actionCollection()->action(KStandardAction::name(KStandardAction::Forward
))) {
672 } else if (action
== actionCollection()->action(QStringLiteral("go_up"))) {
674 } else if (action
== actionCollection()->action(QStringLiteral("go_home"))) {
679 void DolphinMainWindow::selectAll()
683 // if the URL navigator is editable and focused, select the whole
684 // URL instead of all items of the view
686 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
687 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
688 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
689 lineEdit
->hasFocus();
691 lineEdit
->selectAll();
693 m_activeViewContainer
->view()->selectAll();
697 void DolphinMainWindow::invertSelection()
700 m_activeViewContainer
->view()->invertSelection();
703 void DolphinMainWindow::toggleSplitView()
705 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
706 tabPage
->setSplitViewEnabled(!tabPage
->splitViewEnabled());
711 void DolphinMainWindow::toggleSplitStash()
713 DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
714 tabPage
->setSplitViewEnabled(false);
715 tabPage
->setSplitViewEnabled(true, QUrl("stash:/"));
718 void DolphinMainWindow::reloadView()
721 m_activeViewContainer
->reload();
722 m_activeViewContainer
->statusBar()->updateSpaceInfo();
725 void DolphinMainWindow::stopLoading()
727 m_activeViewContainer
->view()->stopLoading();
730 void DolphinMainWindow::enableStopAction()
732 actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
735 void DolphinMainWindow::disableStopAction()
737 actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
740 void DolphinMainWindow::showFilterBar()
742 m_activeViewContainer
->setFilterBarVisible(true);
745 void DolphinMainWindow::toggleEditLocation()
749 QAction
* action
= actionCollection()->action(QStringLiteral("editable_location"));
750 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
751 urlNavigator
->setUrlEditable(action
->isChecked());
754 void DolphinMainWindow::replaceLocation()
756 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
757 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
759 // If the text field currently has focus and everything is selected,
760 // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
761 if (navigator
->isUrlEditable()
762 && lineEdit
->hasFocus()
763 && lineEdit
->selectedText() == lineEdit
->text() ) {
764 navigator
->setUrlEditable(false);
766 navigator
->setUrlEditable(true);
767 navigator
->setFocus();
768 lineEdit
->selectAll();
772 void DolphinMainWindow::togglePanelLockState()
774 const bool newLockState
= !GeneralSettings::lockPanels();
775 foreach (QObject
* child
, children()) {
776 DolphinDockWidget
* dock
= qobject_cast
<DolphinDockWidget
*>(child
);
778 dock
->setLocked(newLockState
);
782 GeneralSettings::setLockPanels(newLockState
);
785 void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
787 if (m_terminalPanel
->isHiddenInVisibleWindow() && m_activeViewContainer
) {
788 m_activeViewContainer
->view()->setFocus();
792 void DolphinMainWindow::goBack()
794 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
795 urlNavigator
->goBack();
797 if (urlNavigator
->locationState().isEmpty()) {
798 // An empty location state indicates a redirection URL,
799 // which must be skipped too
800 urlNavigator
->goBack();
804 void DolphinMainWindow::goForward()
806 m_activeViewContainer
->urlNavigator()->goForward();
809 void DolphinMainWindow::goUp()
811 m_activeViewContainer
->urlNavigator()->goUp();
814 void DolphinMainWindow::goHome()
816 m_activeViewContainer
->urlNavigator()->goHome();
819 void DolphinMainWindow::goBackInNewTab()
821 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
822 const int index
= urlNavigator
->historyIndex() + 1;
823 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
826 void DolphinMainWindow::goForwardInNewTab()
828 KUrlNavigator
* urlNavigator
= activeViewContainer()->urlNavigator();
829 const int index
= urlNavigator
->historyIndex() - 1;
830 openNewTabAfterCurrentTab(urlNavigator
->locationUrl(index
));
833 void DolphinMainWindow::goUpInNewTab()
835 const QUrl currentUrl
= activeViewContainer()->urlNavigator()->locationUrl();
836 openNewTabAfterCurrentTab(KIO::upUrl(currentUrl
));
839 void DolphinMainWindow::goHomeInNewTab()
841 openNewTabAfterCurrentTab(Dolphin::homeUrl());
844 void DolphinMainWindow::compareFiles()
846 const KFileItemList items
= m_tabWidget
->currentTabPage()->selectedItems();
847 if (items
.count() != 2) {
848 // The action is disabled in this case, but it could have been triggered
849 // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
853 QUrl urlA
= items
.at(0).url();
854 QUrl urlB
= items
.at(1).url();
856 QString
command(QStringLiteral("kompare -c \""));
857 command
.append(urlA
.toDisplayString(QUrl::PreferLocalFile
));
858 command
.append("\" \"");
859 command
.append(urlB
.toDisplayString(QUrl::PreferLocalFile
));
860 command
.append('\"');
861 KRun::runCommand(command
, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
864 void DolphinMainWindow::toggleShowMenuBar()
866 const bool visible
= menuBar()->isVisible();
867 menuBar()->setVisible(!visible
);
869 createControlButton();
871 deleteControlButton();
875 void DolphinMainWindow::openTerminal()
877 QString
dir(QDir::homePath());
879 // If the given directory is not local, it can still be the URL of an
880 // ioslave using UDS_LOCAL_PATH which to be converted first.
881 KIO::StatJob
* statJob
= KIO::mostLocalUrl(m_activeViewContainer
->url());
882 KJobWidgets::setWindow(statJob
, this);
884 QUrl url
= statJob
->mostLocalUrl();
886 //If the URL is local after the above conversion, set the directory.
887 if (url
.isLocalFile()) {
888 dir
= url
.toLocalFile();
891 KToolInvocation::invokeTerminal(QString(), dir
);
894 void DolphinMainWindow::editSettings()
896 if (!m_settingsDialog
) {
897 DolphinViewContainer
* container
= activeViewContainer();
898 container
->view()->writeSettings();
900 const QUrl url
= container
->url();
901 DolphinSettingsDialog
* settingsDialog
= new DolphinSettingsDialog(url
, this);
902 connect(settingsDialog
, &DolphinSettingsDialog::settingsChanged
, this, &DolphinMainWindow::refreshViews
);
903 settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
904 settingsDialog
->show();
905 m_settingsDialog
= settingsDialog
;
907 m_settingsDialog
.data()->raise();
911 void DolphinMainWindow::handleUrl(const QUrl
& url
)
913 delete m_lastHandleUrlStatJob
;
914 m_lastHandleUrlStatJob
= nullptr;
916 if (url
.isLocalFile() && QFileInfo(url
.toLocalFile()).isDir()) {
917 activeViewContainer()->setUrl(url
);
918 } else if (KProtocolManager::supportsListing(url
)) {
919 // stat the URL to see if it is a dir or not
920 m_lastHandleUrlStatJob
= KIO::stat(url
, KIO::HideProgressInfo
);
921 if (m_lastHandleUrlStatJob
->uiDelegate()) {
922 KJobWidgets::setWindow(m_lastHandleUrlStatJob
, this);
924 connect(m_lastHandleUrlStatJob
, &KIO::Job::result
,
925 this, &DolphinMainWindow::slotHandleUrlStatFinished
);
928 new KRun(url
, this); // Automatically deletes itself after being finished
932 void DolphinMainWindow::slotHandleUrlStatFinished(KJob
* job
)
934 m_lastHandleUrlStatJob
= nullptr;
935 const KIO::UDSEntry entry
= static_cast<KIO::StatJob
*>(job
)->statResult();
936 const QUrl url
= static_cast<KIO::StatJob
*>(job
)->url();
938 activeViewContainer()->setUrl(url
);
940 new KRun(url
, this); // Automatically deletes itself after being finished
944 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable
)
946 // trash:/ is writable but we don't want to create new items in it.
947 // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
948 newFileMenu()->setEnabled(isFolderWritable
&& m_activeViewContainer
->url().scheme() != QLatin1String("trash"));
951 void DolphinMainWindow::openContextMenu(const QPoint
& pos
,
952 const KFileItem
& item
,
954 const QList
<QAction
*>& customActions
)
956 QPointer
<DolphinContextMenu
> contextMenu
= new DolphinContextMenu(this, pos
, item
, url
);
957 contextMenu
.data()->setCustomActions(customActions
);
958 const DolphinContextMenu::Command command
= contextMenu
.data()->open();
961 case DolphinContextMenu::OpenParentFolder
:
962 changeUrl(KIO::upUrl(item
.url()));
963 m_activeViewContainer
->view()->markUrlsAsSelected({item
.url()});
964 m_activeViewContainer
->view()->markUrlAsCurrent(item
.url());
967 case DolphinContextMenu::OpenParentFolderInNewWindow
:
968 Dolphin::openNewWindow({item
.url()}, this, Dolphin::OpenNewWindowFlag::Select
);
971 case DolphinContextMenu::OpenParentFolderInNewTab
:
972 openNewTabAfterLastTab(KIO::upUrl(item
.url()));
975 case DolphinContextMenu::None
:
980 // Delete the menu, unless it has been deleted in its own nested event loop already.
982 contextMenu
->deleteLater();
986 void DolphinMainWindow::updateControlMenu()
988 QMenu
* menu
= qobject_cast
<QMenu
*>(sender());
991 // All actions get cleared by QMenu::clear(). This includes the sub-menus
992 // because 'menu' is their parent.
995 KActionCollection
* ac
= actionCollection();
997 // Add "Create New" menu
998 menu
->addMenu(m_newFileMenu
->menu());
1000 menu
->addSeparator();
1002 // Overwrite Find action to Search action
1003 QAction
*searchAction
= ac
->action(KStandardAction::name(KStandardAction::Find
));
1004 searchAction
->setText(i18n("Search..."));
1006 // Add "Edit" actions
1007 bool added
= addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Undo
)), menu
) |
1008 addActionToMenu(searchAction
, menu
) |
1009 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::SelectAll
)), menu
) |
1010 addActionToMenu(ac
->action(QStringLiteral("invert_selection")), menu
);
1013 menu
->addSeparator();
1016 // Add "View" actions
1017 if (!GeneralSettings::showZoomSlider()) {
1018 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomIn
)), menu
);
1019 addActionToMenu(ac
->action(QStringLiteral("view_zoom_reset")), menu
);
1020 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ZoomOut
)), menu
);
1021 menu
->addSeparator();
1024 added
= addActionToMenu(ac
->action(QStringLiteral("sort")), menu
) |
1025 addActionToMenu(ac
->action(QStringLiteral("view_mode")), menu
) |
1026 addActionToMenu(ac
->action(QStringLiteral("additional_info")), menu
) |
1027 addActionToMenu(ac
->action(QStringLiteral("show_preview")), menu
) |
1028 addActionToMenu(ac
->action(QStringLiteral("show_in_groups")), menu
) |
1029 addActionToMenu(ac
->action(QStringLiteral("show_hidden_files")), menu
);
1032 menu
->addSeparator();
1035 added
= addActionToMenu(ac
->action(QStringLiteral("split_view")), menu
) |
1036 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Redisplay
)), menu
) |
1037 addActionToMenu(ac
->action(QStringLiteral("view_properties")), menu
);
1039 menu
->addSeparator();
1042 addActionToMenu(ac
->action(QStringLiteral("panels")), menu
);
1043 QMenu
* locationBarMenu
= new QMenu(i18nc("@action:inmenu", "Location Bar"), menu
);
1044 locationBarMenu
->addAction(ac
->action(QStringLiteral("editable_location")));
1045 locationBarMenu
->addAction(ac
->action(QStringLiteral("replace_location")));
1046 menu
->addMenu(locationBarMenu
);
1048 menu
->addSeparator();
1051 QMenu
* goMenu
= new QMenu(i18nc("@action:inmenu", "Go"), menu
);
1052 goMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Back
)));
1053 goMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Forward
)));
1054 goMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Up
)));
1055 goMenu
->addAction(ac
->action(KStandardAction::name(KStandardAction::Home
)));
1056 goMenu
->addAction(ac
->action(QStringLiteral("closed_tabs")));
1057 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), goMenu
);
1058 m_bookmarkHandler
->fillControlMenu(bookmarkMenu
->menu(), ac
);
1059 goMenu
->addAction(bookmarkMenu
);
1060 menu
->addMenu(goMenu
);
1063 QMenu
* toolsMenu
= new QMenu(i18nc("@action:inmenu", "Tools"), menu
);
1064 toolsMenu
->addAction(ac
->action(QStringLiteral("show_filter_bar")));
1065 toolsMenu
->addAction(ac
->action(QStringLiteral("compare_files")));
1066 toolsMenu
->addAction(ac
->action(QStringLiteral("open_terminal")));
1067 toolsMenu
->addAction(ac
->action(QStringLiteral("change_remote_encoding")));
1068 menu
->addMenu(toolsMenu
);
1070 // Add "Settings" menu entries
1071 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::KeyBindings
)), menu
);
1072 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ConfigureToolbars
)), menu
);
1073 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::Preferences
)), menu
);
1076 menu
->addMenu(m_helpMenu
->menu());
1078 menu
->addSeparator();
1079 addActionToMenu(ac
->action(KStandardAction::name(KStandardAction::ShowMenubar
)), menu
);
1082 void DolphinMainWindow::updateToolBar()
1084 if (!menuBar()->isVisible()) {
1085 createControlButton();
1089 void DolphinMainWindow::slotControlButtonDeleted()
1091 m_controlButton
= nullptr;
1092 m_updateToolBarTimer
->start();
1095 void DolphinMainWindow::slotPlaceActivated(const QUrl
& url
)
1097 DolphinViewContainer
* view
= activeViewContainer();
1099 if (view
->url() == url
) {
1100 // We can end up here if the user clicked a device in the Places Panel
1101 // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
1108 void DolphinMainWindow::closedTabsCountChanged(unsigned int count
)
1110 actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count
> 0);
1113 void DolphinMainWindow::activeViewChanged(DolphinViewContainer
* viewContainer
)
1115 DolphinViewContainer
* oldViewContainer
= m_activeViewContainer
;
1116 Q_ASSERT(viewContainer
);
1118 m_activeViewContainer
= viewContainer
;
1120 if (oldViewContainer
) {
1121 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1122 toggleSearchAction
->disconnect(oldViewContainer
);
1124 // Disconnect all signals between the old view container (container,
1125 // view and url navigator) and main window.
1126 oldViewContainer
->disconnect(this);
1127 oldViewContainer
->view()->disconnect(this);
1128 oldViewContainer
->urlNavigator()->disconnect(this);
1130 // except the requestItemInfo so that on hover the information panel can still be updated
1131 connect(oldViewContainer
->view(), &DolphinView::requestItemInfo
,
1132 this, &DolphinMainWindow::requestItemInfo
);
1135 connectViewSignals(viewContainer
);
1137 m_actionHandler
->setCurrentView(viewContainer
->view());
1140 updateFileAndEditActions();
1141 updatePasteAction();
1142 updateViewActions();
1144 updateSearchAction();
1146 const QUrl url
= viewContainer
->url();
1147 emit
urlChanged(url
);
1150 void DolphinMainWindow::tabCountChanged(int count
)
1152 const bool enableTabActions
= (count
> 1);
1153 actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions
);
1154 actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions
);
1157 void DolphinMainWindow::updateWindowTitle()
1159 const QString newTitle
= m_activeViewContainer
->caption();
1160 if (windowTitle() != newTitle
) {
1161 setWindowTitle(newTitle
);
1165 void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString
& mountPath
)
1167 if (m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1168 m_tearDownFromPlacesRequested
= true;
1169 m_terminalPanel
->goHome();
1170 // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
1172 m_placesPanel
->proceedWithTearDown();
1176 void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString
& mountPath
)
1178 if (m_terminalPanel
->currentWorkingDirectory().startsWith(mountPath
)) {
1179 m_tearDownFromPlacesRequested
= false;
1180 m_terminalPanel
->goHome();
1184 void DolphinMainWindow::setupActions()
1186 // setup 'File' menu
1187 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
1188 QMenu
* menu
= m_newFileMenu
->menu();
1189 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1190 menu
->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
1191 m_newFileMenu
->setDelayed(false);
1192 connect(menu
, &QMenu::aboutToShow
,
1193 this, &DolphinMainWindow::updateNewMenu
);
1195 QAction
* newWindow
= KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow
, actionCollection());
1196 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
1197 newWindow
->setToolTip(i18nc("@info", "Open a new Dolphin window"));
1198 newWindow
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1199 "window just like this one with the current location and view."
1200 "<nl/>You can drag and drop items between windows."));
1201 newWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1203 QAction
* newTab
= actionCollection()->addAction(QStringLiteral("new_tab"));
1204 newTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1205 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
1206 newTab
->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new "
1207 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
1208 "A tab is an additional view within this window. "
1209 "You can drag and drop items between tabs."));
1210 actionCollection()->setDefaultShortcuts(newTab
, {Qt::CTRL
+ Qt::Key_T
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_N
});
1211 connect(newTab
, &QAction::triggered
, this, &DolphinMainWindow::openNewActivatedTab
);
1213 QAction
* addToPlaces
= actionCollection()->addAction(QStringLiteral("add_to_places"));
1214 addToPlaces
->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
1215 addToPlaces
->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
1216 "to the Places panel."));
1217 connect(addToPlaces
, &QAction::triggered
, this, &DolphinMainWindow::addToPlaces
);
1219 QAction
* closeTab
= KStandardAction::close(m_tabWidget
, QOverload
<>::of(&DolphinTabWidget::closeTab
), actionCollection());
1220 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
1221 closeTab
->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
1222 "currently viewed tab. If no more tabs are left this window "
1223 "will close instead."));
1225 QAction
* quitAction
= KStandardAction::quit(this, &DolphinMainWindow::quit
, actionCollection());
1226 quitAction
->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
1228 // setup 'Edit' menu
1229 KStandardAction::undo(this,
1230 &DolphinMainWindow::undo
,
1231 actionCollection());
1233 // i18n: This will be the last paragraph for the whatsthis for all three:
1234 // Cut, Copy and Paste
1235 const QString cutCopyPastePara
= xi18nc("@info:whatsthis", "<para><emphasis>Cut, "
1236 "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
1237 "applications and are among the most used commands. That's why their "
1238 "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
1239 "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
1240 "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
1241 QAction
* cutAction
= KStandardAction::cut(this, &DolphinMainWindow::cut
, actionCollection());
1242 cutAction
->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items "
1243 "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
1244 "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
1245 "the clipboard to a new location. The items will be removed from their "
1246 "initial location.") + cutCopyPastePara
);
1247 QAction
* copyAction
= KStandardAction::copy(this, &DolphinMainWindow::copy
, actionCollection());
1248 copyAction
->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the "
1249 "items in your current selection to the <emphasis>clipboard</emphasis>."
1250 "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
1251 "from the clipboard to a new location.") + cutCopyPastePara
);
1252 QAction
* paste
= KStandardAction::paste(this, &DolphinMainWindow::paste
, actionCollection());
1253 // The text of the paste-action is modified dynamically by Dolphin
1254 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1255 // due to the long text, the text "Paste" is used:
1256 paste
->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1257 paste
->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from "
1258 "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
1259 "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
1260 "action they are removed from their old location.") + cutCopyPastePara
);
1262 QAction
*searchAction
= KStandardAction::find(this, &DolphinMainWindow::find
, actionCollection());
1263 searchAction
->setText(i18n("Search..."));
1264 searchAction
->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
1265 searchAction
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This helps you "
1266 "find files and folders by opening a <emphasis>find bar</emphasis>. "
1267 "There you can enter search terms and specify settings to find the "
1268 "objects you are looking for.</para><para>Use this help again on "
1269 "the find bar so we can have a look at it while the settings are "
1270 "explained.</para>"));
1272 // toggle_search acts as a copy of the main searchAction to be used mainly
1273 // in the toolbar, with no default shortcut attached, to avoid messing with
1274 // existing workflows (search bar always open and Ctrl-F to focus)
1275 QAction
*toggleSearchAction
= actionCollection()->addAction(QStringLiteral("toggle_search"));
1276 toggleSearchAction
->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
1277 toggleSearchAction
->setIconText(i18nc("@action:intoolbar", "Search"));
1278 toggleSearchAction
->setIcon(searchAction
->icon());
1279 toggleSearchAction
->setToolTip(searchAction
->toolTip());
1280 toggleSearchAction
->setWhatsThis(searchAction
->whatsThis());
1281 toggleSearchAction
->setCheckable(true);
1283 QAction
* selectAllAction
= KStandardAction::selectAll(this, &DolphinMainWindow::selectAll
, actionCollection());
1284 selectAllAction
->setWhatsThis(xi18nc("@info:whatsthis", "This selects all "
1285 "files and folders in the current location."));
1287 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
1288 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1289 invertSelection
->setWhatsThis(xi18nc("@info:whatsthis invert", "This selects all "
1290 "objects that you have currently <emphasis>not</emphasis> selected instead."));
1291 invertSelection
->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
1292 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_A
);
1293 connect(invertSelection
, &QAction::triggered
, this, &DolphinMainWindow::invertSelection
);
1295 // setup 'View' menu
1296 // (note that most of it is set up in DolphinViewActionHandler)
1298 QAction
* split
= actionCollection()->addAction(QStringLiteral("split_view"));
1299 split
->setWhatsThis(xi18nc("@info:whatsthis find", "<para>This splits "
1300 "the folder view below into two autonomous views.</para><para>This "
1301 "way you can see two locations at once and move items between them "
1302 "quickly.</para>Click this again afterwards to recombine the views."));
1303 actionCollection()->setDefaultShortcut(split
, Qt::Key_F3
);
1304 connect(split
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitView
);
1306 QAction
* stashSplit
= actionCollection()->addAction(QStringLiteral("split_stash"));
1307 actionCollection()->setDefaultShortcut(stashSplit
, Qt::CTRL
+ Qt::Key_S
);
1308 stashSplit
->setText(i18nc("@action:intoolbar Stash", "Stash"));
1309 stashSplit
->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
1310 stashSplit
->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
1311 stashSplit
->setCheckable(false);
1312 stashSplit
->setVisible(KProtocolInfo::isKnownProtocol("stash"));
1313 connect(stashSplit
, &QAction::triggered
, this, &DolphinMainWindow::toggleSplitStash
);
1315 KStandardAction::redisplay(this, &DolphinMainWindow::reloadView
, actionCollection());
1317 QAction
* stop
= actionCollection()->addAction(QStringLiteral("stop"));
1318 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1319 stop
->setToolTip(i18nc("@info", "Stop loading"));
1320 stop
->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
1321 stop
->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
1322 connect(stop
, &QAction::triggered
, this, &DolphinMainWindow::stopLoading
);
1324 KToggleAction
* editableLocation
= actionCollection()->add
<KToggleAction
>(QStringLiteral("editable_location"));
1325 editableLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1326 editableLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1327 "This toggles the <emphasis>Location Bar</emphasis> to be "
1328 "editable so you can directly enter a location you want to go to.<nl/>"
1329 "You can also switch to editing by clicking to the right of the "
1330 "location and switch back by confirming the edited location."));
1331 actionCollection()->setDefaultShortcut(editableLocation
, Qt::Key_F6
);
1332 connect(editableLocation
, &KToggleAction::triggered
, this, &DolphinMainWindow::toggleEditLocation
);
1334 QAction
* replaceLocation
= actionCollection()->addAction(QStringLiteral("replace_location"));
1335 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1336 // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
1337 // Both meanings are useful but not necessary to understand the use of "Replace Location".
1338 // So you might want to be more verbose in your language to convey the meaning but it's up to you.
1339 replaceLocation
->setWhatsThis(xi18nc("@info:whatsthis",
1340 "This switches to editing the location and selects it "
1341 "so you can quickly enter a different location."));
1342 actionCollection()->setDefaultShortcut(replaceLocation
, Qt::CTRL
+ Qt::Key_L
);
1343 connect(replaceLocation
, &QAction::triggered
, this, &DolphinMainWindow::replaceLocation
);
1346 QAction
* backAction
= KStandardAction::back(this, &DolphinMainWindow::goBack
, actionCollection());
1347 auto backShortcuts
= backAction
->shortcuts();
1348 backShortcuts
.append(QKeySequence(Qt::Key_Backspace
));
1349 actionCollection()->setDefaultShortcuts(backAction
, backShortcuts
);
1351 DolphinRecentTabsMenu
* recentTabsMenu
= new DolphinRecentTabsMenu(this);
1352 actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu
);
1353 connect(m_tabWidget
, &DolphinTabWidget::rememberClosedTab
,
1354 recentTabsMenu
, &DolphinRecentTabsMenu::rememberClosedTab
);
1355 connect(recentTabsMenu
, &DolphinRecentTabsMenu::restoreClosedTab
,
1356 m_tabWidget
, &DolphinTabWidget::restoreClosedTab
);
1357 connect(recentTabsMenu
, &DolphinRecentTabsMenu::closedTabsCountChanged
,
1358 this, &DolphinMainWindow::closedTabsCountChanged
);
1360 QAction
* undoCloseTab
= actionCollection()->addAction(QStringLiteral("undo_close_tab"));
1361 undoCloseTab
->setText(i18nc("@action:inmenu File", "Undo close tab"));
1362 undoCloseTab
->setWhatsThis(i18nc("@info:whatsthis undo close tab",
1363 "This returns you to the previously closed tab."));
1364 actionCollection()->setDefaultShortcut(undoCloseTab
, Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_T
);
1365 undoCloseTab
->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
1366 undoCloseTab
->setEnabled(false);
1367 connect(undoCloseTab
, &QAction::triggered
, recentTabsMenu
, &DolphinRecentTabsMenu::undoCloseTab
);
1369 auto undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
1370 undoAction
->setWhatsThis(xi18nc("@info:whatsthis", "This undoes "
1371 "the last change you made to files or folders.<nl/>"
1372 "Such changes include <interface>creating, renaming</interface> "
1373 "and <interface>moving</interface> them to a different location "
1374 "or to the <filename>Trash</filename>. <nl/>Changes that can't "
1375 "be undone will ask for your confirmation."));
1376 undoAction
->setEnabled(false); // undo should be disabled by default
1378 KStandardAction::forward(this, &DolphinMainWindow::goForward
, actionCollection());
1379 KStandardAction::up(this, &DolphinMainWindow::goUp
, actionCollection());
1380 QAction
* homeAction
= KStandardAction::home(this, &DolphinMainWindow::goHome
, actionCollection());
1381 homeAction
->setWhatsThis(xi18nc("@info:whatsthis", "Go to your "
1382 "<filename>Home</filename> folder.<nl/>Every user account "
1383 "has their own <filename>Home</filename> that contains their data "
1384 "including folders that contain personal application data."));
1386 // setup 'Tools' menu
1387 QAction
* showFilterBar
= actionCollection()->addAction(QStringLiteral("show_filter_bar"));
1388 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1389 showFilterBar
->setWhatsThis(xi18nc("@info:whatsthis", "This opens the "
1390 "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
1391 "There you can enter a text to filter the files and folders currently displayed. "
1392 "Only those that contain the text in their name will be kept in view."));
1393 showFilterBar
->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
1394 actionCollection()->setDefaultShortcuts(showFilterBar
, {Qt::CTRL
+ Qt::Key_I
, Qt::Key_Slash
});
1395 connect(showFilterBar
, &QAction::triggered
, this, &DolphinMainWindow::showFilterBar
);
1397 QAction
* compareFiles
= actionCollection()->addAction(QStringLiteral("compare_files"));
1398 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1399 compareFiles
->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
1400 compareFiles
->setEnabled(false);
1401 connect(compareFiles
, &QAction::triggered
, this, &DolphinMainWindow::compareFiles
);
1403 #ifdef HAVE_TERMINAL
1404 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1405 QAction
* openTerminal
= actionCollection()->addAction(QStringLiteral("open_terminal"));
1406 openTerminal
->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1407 openTerminal
->setWhatsThis(xi18nc("@info:whatsthis",
1408 "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
1409 "<para>To learn more about terminals use the help in the terminal application.</para>"));
1410 openTerminal
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
1411 actionCollection()->setDefaultShortcut(openTerminal
, Qt::SHIFT
+ Qt::Key_F4
);
1412 connect(openTerminal
, &QAction::triggered
, this, &DolphinMainWindow::openTerminal
);
1416 // setup 'Bookmarks' menu
1417 KActionMenu
*bookmarkMenu
= new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
1418 bookmarkMenu
->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
1419 // Make the toolbar button version work properly on click
1420 bookmarkMenu
->setDelayed(false);
1421 m_bookmarkHandler
= new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu
->menu(), this);
1422 actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu
);
1424 // setup 'Settings' menu
1425 KToggleAction
* showMenuBar
= KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
1426 showMenuBar
->setWhatsThis(xi18nc("@info:whatsthis",
1427 "This switches between having a <emphasis>Menubar</emphasis> "
1428 "and having a <interface>Control</interface> button. Both "
1429 "contain mostly the same commands and configuration options."));
1430 connect(showMenuBar
, &KToggleAction::triggered
, // Fixes #286822
1431 this, &DolphinMainWindow::toggleShowMenuBar
, Qt::QueuedConnection
);
1432 KStandardAction::preferences(this, &DolphinMainWindow::editSettings
, actionCollection());
1434 // setup 'Help' menu for the m_controlButton. The other one is set up in the base class.
1435 m_helpMenu
= new KHelpMenu(nullptr);
1436 m_helpMenu
->menu()->installEventFilter(this);
1437 // remove duplicate shortcuts
1438 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setShortcut(QKeySequence());
1439 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setShortcut(QKeySequence());
1441 // not in menu actions
1442 QList
<QKeySequence
> nextTabKeys
= KStandardShortcut::tabNext();
1443 nextTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::Key_Tab
));
1445 QList
<QKeySequence
> prevTabKeys
= KStandardShortcut::tabPrev();
1446 prevTabKeys
.append(QKeySequence(Qt::CTRL
+ Qt::SHIFT
+ Qt::Key_Tab
));
1448 QAction
* activateNextTab
= actionCollection()->addAction(QStringLiteral("activate_next_tab"));
1449 activateNextTab
->setIconText(i18nc("@action:inmenu", "Next Tab"));
1450 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1451 activateNextTab
->setEnabled(false);
1452 connect(activateNextTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activateNextTab
);
1453 actionCollection()->setDefaultShortcuts(activateNextTab
, nextTabKeys
);
1455 QAction
* activatePrevTab
= actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
1456 activatePrevTab
->setIconText(i18nc("@action:inmenu", "Previous Tab"));
1457 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1458 activatePrevTab
->setEnabled(false);
1459 connect(activatePrevTab
, &QAction::triggered
, m_tabWidget
, &DolphinTabWidget::activatePrevTab
);
1460 actionCollection()->setDefaultShortcuts(activatePrevTab
, prevTabKeys
);
1463 QAction
* showTarget
= actionCollection()->addAction(QStringLiteral("show_target"));
1464 showTarget
->setText(i18nc("@action:inmenu", "Show Target"));
1465 showTarget
->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
1466 showTarget
->setEnabled(false);
1467 connect(showTarget
, &QAction::triggered
, this, &DolphinMainWindow::showTarget
);
1469 QAction
* openInNewTab
= actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
1470 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1471 openInNewTab
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1472 connect(openInNewTab
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1474 QAction
* openInNewTabs
= actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
1475 openInNewTabs
->setText(i18nc("@action:inmenu", "Open in New Tabs"));
1476 openInNewTabs
->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
1477 connect(openInNewTabs
, &QAction::triggered
, this, &DolphinMainWindow::openInNewTab
);
1479 QAction
* openInNewWindow
= actionCollection()->addAction(QStringLiteral("open_in_new_window"));
1480 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1481 openInNewWindow
->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
1482 connect(openInNewWindow
, &QAction::triggered
, this, &DolphinMainWindow::openInNewWindow
);
1485 void DolphinMainWindow::setupDockWidgets()
1487 const bool lock
= GeneralSettings::lockPanels();
1489 KDualAction
* lockLayoutAction
= actionCollection()->add
<KDualAction
>(QStringLiteral("lock_panels"));
1490 lockLayoutAction
->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
1491 lockLayoutAction
->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
1492 lockLayoutAction
->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
1493 lockLayoutAction
->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
1494 lockLayoutAction
->setWhatsThis(xi18nc("@info:whatsthis", "This "
1495 "switches between having panels <emphasis>locked</emphasis> or "
1496 "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
1497 "dragged to the other side of the window and have a close "
1498 "button.<nl/>Locked panels are embedded more cleanly."));
1499 lockLayoutAction
->setActive(lock
);
1500 connect(lockLayoutAction
, &KDualAction::triggered
, this, &DolphinMainWindow::togglePanelLockState
);
1502 // Setup "Information"
1503 DolphinDockWidget
* infoDock
= new DolphinDockWidget(i18nc("@title:window", "Information"));
1504 infoDock
->setLocked(lock
);
1505 infoDock
->setObjectName(QStringLiteral("infoDock"));
1506 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1509 InformationPanel
* infoPanel
= new InformationPanel(infoDock
);
1510 infoPanel
->setCustomContextMenuActions({lockLayoutAction
});
1511 connect(infoPanel
, &InformationPanel::urlActivated
, this, &DolphinMainWindow::handleUrl
);
1512 infoDock
->setWidget(infoPanel
);
1514 QAction
* infoAction
= infoDock
->toggleViewAction();
1515 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11
, infoAction
, QStringLiteral("show_information_panel"));
1517 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1518 connect(this, &DolphinMainWindow::urlChanged
,
1519 infoPanel
, &InformationPanel::setUrl
);
1520 connect(this, &DolphinMainWindow::selectionChanged
,
1521 infoPanel
, &InformationPanel::setSelection
);
1522 connect(this, &DolphinMainWindow::requestItemInfo
,
1523 infoPanel
, &InformationPanel::requestDelayedItemInfo
);
1526 // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
1527 const QString panelWhatsThis
= xi18nc("@info:whatsthis", "<para>To show or "
1528 "hide panels like this go to <interface>Control|Panels</interface> "
1529 "or <interface>View|Panels</interface>.</para>");
1531 actionCollection()->action(QStringLiteral("show_information_panel"))
1532 ->setWhatsThis(xi18nc("@info:whatsthis", "<para> This toggles the "
1533 "<emphasis>information</emphasis> panel at the right side of the "
1534 "window.</para><para>The panel provides in-depth information "
1535 "about the items your mouse is hovering over or about the selected "
1536 "items. Otherwise it informs you about the currently viewed folder.<nl/>"
1537 "For single items a preview of their contents is provided.</para>"));
1539 infoDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1540 "provides in-depth information about the items your mouse is "
1541 "hovering over or about the selected items. Otherwise it informs "
1542 "you about the currently viewed folder.<nl/>For single items a "
1543 "preview of their contents is provided.</para><para>You can configure "
1544 "which and how details are given here by right-clicking.</para>") + panelWhatsThis
);
1547 DolphinDockWidget
* foldersDock
= new DolphinDockWidget(i18nc("@title:window", "Folders"));
1548 foldersDock
->setLocked(lock
);
1549 foldersDock
->setObjectName(QStringLiteral("foldersDock"));
1550 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1551 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1552 foldersPanel
->setCustomContextMenuActions({lockLayoutAction
});
1553 foldersDock
->setWidget(foldersPanel
);
1555 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1556 createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7
, foldersAction
, QStringLiteral("show_folders_panel"));
1558 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1559 connect(this, &DolphinMainWindow::urlChanged
,
1560 foldersPanel
, &FoldersPanel::setUrl
);
1561 connect(foldersPanel
, &FoldersPanel::folderActivated
,
1562 this, &DolphinMainWindow::changeUrl
);
1563 connect(foldersPanel
, &FoldersPanel::folderMiddleClicked
,
1564 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1565 connect(foldersPanel
, &FoldersPanel::errorMessage
,
1566 this, &DolphinMainWindow::showErrorMessage
);
1568 actionCollection()->action(QStringLiteral("show_folders_panel"))
1569 ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the "
1570 "<emphasis>folders</emphasis> panel at the left side of the window."
1571 "<nl/><nl/>It shows the folders of the <emphasis>file system"
1572 "</emphasis> in a <emphasis>tree view</emphasis>."));
1573 foldersDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel "
1574 "shows the folders of the <emphasis>file system</emphasis> in a "
1575 "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
1576 "there. Click the arrow to the left of a folder to see its subfolders. "
1577 "This allows quick switching between any folders.</para>") + panelWhatsThis
);
1580 #ifdef HAVE_TERMINAL
1581 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
1582 DolphinDockWidget
* terminalDock
= new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1583 terminalDock
->setLocked(lock
);
1584 terminalDock
->setObjectName(QStringLiteral("terminalDock"));
1585 m_terminalPanel
= new TerminalPanel(terminalDock
);
1586 m_terminalPanel
->setCustomContextMenuActions({lockLayoutAction
});
1587 terminalDock
->setWidget(m_terminalPanel
);
1589 connect(m_terminalPanel
, &TerminalPanel::hideTerminalPanel
, terminalDock
, &DolphinDockWidget::hide
);
1590 connect(m_terminalPanel
, &TerminalPanel::changeUrl
, this, &DolphinMainWindow::slotTerminalDirectoryChanged
);
1591 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1592 m_terminalPanel
, &TerminalPanel::dockVisibilityChanged
);
1593 connect(terminalDock
, &DolphinDockWidget::visibilityChanged
,
1594 this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged
);
1596 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1597 createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4
, terminalAction
, QStringLiteral("show_terminal_panel"));
1599 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1600 connect(this, &DolphinMainWindow::urlChanged
,
1601 m_terminalPanel
, &TerminalPanel::setUrl
);
1603 if (GeneralSettings::version() < 200) {
1604 terminalDock
->hide();
1607 actionCollection()->action(QStringLiteral("show_terminal_panel"))
1608 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1609 "<emphasis>terminal</emphasis> panel at the bottom of the window."
1610 "<nl/>The location in the terminal will always match the folder "
1611 "view so you can navigate using either.</para><para>The terminal "
1612 "panel is not needed for basic computer usage but can be useful "
1613 "for advanced tasks. To learn more about terminals use the help "
1614 "in a standalone terminal application like Konsole.</para>"));
1615 terminalDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is "
1616 "the <emphasis>terminal</emphasis> panel. It behaves like a "
1617 "normal terminal but will match the location of the folder view "
1618 "so you can navigate using either.</para><para>The terminal panel "
1619 "is not needed for basic computer usage but can be useful for "
1620 "advanced tasks. To learn more about terminals use the help in a "
1621 "standalone terminal application like Konsole.</para>") + panelWhatsThis
);
1625 if (GeneralSettings::version() < 200) {
1627 foldersDock
->hide();
1631 DolphinDockWidget
* placesDock
= new DolphinDockWidget(i18nc("@title:window", "Places"));
1632 placesDock
->setLocked(lock
);
1633 placesDock
->setObjectName(QStringLiteral("placesDock"));
1634 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1636 m_placesPanel
= new PlacesPanel(placesDock
);
1637 m_placesPanel
->setCustomContextMenuActions({lockLayoutAction
});
1638 placesDock
->setWidget(m_placesPanel
);
1640 QAction
*placesAction
= placesDock
->toggleViewAction();
1641 createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9
, placesAction
, QStringLiteral("show_places_panel"));
1643 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1644 connect(m_placesPanel
, &PlacesPanel::placeActivated
,
1645 this, &DolphinMainWindow::slotPlaceActivated
);
1646 connect(m_placesPanel
, &PlacesPanel::placeMiddleClicked
,
1647 this, &DolphinMainWindow::openNewTabAfterCurrentTab
);
1648 connect(m_placesPanel
, &PlacesPanel::errorMessage
,
1649 this, &DolphinMainWindow::showErrorMessage
);
1650 connect(this, &DolphinMainWindow::urlChanged
,
1651 m_placesPanel
, &PlacesPanel::setUrl
);
1652 connect(placesDock
, &DolphinDockWidget::visibilityChanged
,
1653 m_tabWidget
, &DolphinTabWidget::slotPlacesPanelVisibilityChanged
);
1654 connect(this, &DolphinMainWindow::settingsChanged
,
1655 m_placesPanel
, &PlacesPanel::readSettings
);
1656 connect(m_placesPanel
, &PlacesPanel::storageTearDownRequested
,
1657 this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested
);
1658 connect(m_placesPanel
, &PlacesPanel::storageTearDownExternallyRequested
,
1659 this, &DolphinMainWindow::slotStorageTearDownExternallyRequested
);
1660 m_tabWidget
->slotPlacesPanelVisibilityChanged(m_placesPanel
->isVisible());
1662 auto actionShowAllPlaces
= new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
1663 actionShowAllPlaces
->setCheckable(true);
1664 actionShowAllPlaces
->setDisabled(true);
1665 actionShowAllPlaces
->setWhatsThis(i18nc("@info:whatsthis", "This displays "
1666 "all places in the places panel that have been hidden. They will "
1667 "appear semi-transparent unless you uncheck their hide property."));
1669 connect(actionShowAllPlaces
, &QAction::triggered
, this, [actionShowAllPlaces
, this](bool checked
){
1670 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1671 m_placesPanel
->showHiddenEntries(checked
);
1674 connect(m_placesPanel
, &PlacesPanel::showHiddenEntriesChanged
, this, [actionShowAllPlaces
] (bool checked
){
1675 actionShowAllPlaces
->setChecked(checked
);
1676 actionShowAllPlaces
->setIcon(QIcon::fromTheme(checked
? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
1679 actionCollection()->action(QStringLiteral("show_places_panel"))
1680 ->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles the "
1681 "<emphasis>places</emphasis> panel at the left side of the window."
1682 "</para><para>It allows you to go to locations you have "
1683 "bookmarked and to access disk or media attached to the computer "
1684 "or to the network. It also contains sections to find recently "
1685 "saved files or files of a certain type.</para>"));
1686 placesDock
->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1687 "<emphasis>Places</emphasis> panel. It allows you to go to locations "
1688 "you have bookmarked and to access disk or media attached to the "
1689 "computer or to the network. It also contains sections to find "
1690 "recently saved files or files of a certain type.</para><para>"
1691 "Click on an entry to go there. Click with the right mouse button "
1692 "instead to open any entry in a new tab or new window.</para>"
1693 "<para>New entries can be added by dragging folders onto this panel. "
1694 "Right-click any section or entry to hide it. Right-click an empty "
1695 "space on this panel and select <interface>Show Hidden Places"
1696 "</interface> to display it again.</para>") + panelWhatsThis
);
1698 // Add actions into the "Panels" menu
1699 KActionMenu
* panelsMenu
= new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
1700 actionCollection()->addAction(QStringLiteral("panels"), panelsMenu
);
1701 panelsMenu
->setDelayed(false);
1702 const KActionCollection
* ac
= actionCollection();
1703 panelsMenu
->addAction(ac
->action(QStringLiteral("show_places_panel")));
1705 panelsMenu
->addAction(ac
->action(QStringLiteral("show_information_panel")));
1707 panelsMenu
->addAction(ac
->action(QStringLiteral("show_folders_panel")));
1708 panelsMenu
->addAction(ac
->action(QStringLiteral("show_terminal_panel")));
1709 panelsMenu
->addSeparator();
1710 panelsMenu
->addAction(actionShowAllPlaces
);
1711 panelsMenu
->addAction(lockLayoutAction
);
1713 connect(panelsMenu
->menu(), &QMenu::aboutToShow
, this, [actionShowAllPlaces
, this]{
1714 actionShowAllPlaces
->setEnabled(m_placesPanel
->hiddenListCount());
1719 void DolphinMainWindow::updateFileAndEditActions()
1721 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
1722 const KActionCollection
* col
= actionCollection();
1723 QAction
* addToPlacesAction
= col
->action(QStringLiteral("add_to_places"));
1725 if (list
.isEmpty()) {
1726 stateChanged(QStringLiteral("has_no_selection"));
1728 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer
->placesText()));
1730 stateChanged(QStringLiteral("has_selection"));
1732 QAction
* renameAction
= col
->action(KStandardAction::name(KStandardAction::RenameFile
));
1733 QAction
* moveToTrashAction
= col
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
1734 QAction
* deleteAction
= col
->action(KStandardAction::name(KStandardAction::DeleteFile
));
1735 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
1736 QAction
* deleteWithTrashShortcut
= col
->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
1737 QAction
* showTarget
= col
->action(QStringLiteral("show_target"));
1739 if (list
.length() == 1 && list
.first().isDir()) {
1740 addToPlacesAction
->setEnabled(true);
1741 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list
.first().name()));
1743 addToPlacesAction
->setEnabled(false);
1744 addToPlacesAction
->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
1747 KFileItemListProperties
capabilities(list
);
1748 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
1750 renameAction
->setEnabled(capabilities
.supportsMoving());
1751 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1752 deleteAction
->setEnabled(capabilities
.supportsDeleting());
1753 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
1754 cutAction
->setEnabled(capabilities
.supportsMoving());
1755 showTarget
->setEnabled(list
.length() == 1 && list
.at(0).isLink());
1759 void DolphinMainWindow::updateViewActions()
1761 m_actionHandler
->updateViewActions();
1763 QAction
* showFilterBarAction
= actionCollection()->action(QStringLiteral("show_filter_bar"));
1764 showFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
1766 updateSplitAction();
1768 QAction
* editableLocactionAction
= actionCollection()->action(QStringLiteral("editable_location"));
1769 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
1770 editableLocactionAction
->setChecked(urlNavigator
->isUrlEditable());
1773 void DolphinMainWindow::updateGoActions()
1775 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
1776 const QUrl currentUrl
= m_activeViewContainer
->url();
1777 // I think this is one of the best places to firstly be confronted
1778 // with a file system and its hierarchy. Talking about the root
1779 // directory might seem too much here but it is the question that
1780 // naturally arises in this context.
1781 goUpAction
->setWhatsThis(xi18nc("@info:whatsthis", "<para>Go to "
1782 "the folder that contains the currently viewed one.</para>"
1783 "<para>All files and folders are organized in a hierarchical "
1784 "<emphasis>file system</emphasis>. At the top of this hierarchy is "
1785 "a directory that contains all data connected to this computer"
1786 "—the <emphasis>root directory</emphasis>.</para>"));
1787 goUpAction
->setEnabled(KIO::upUrl(currentUrl
) != currentUrl
);
1790 void DolphinMainWindow::createControlButton()
1792 if (m_controlButton
) {
1795 Q_ASSERT(!m_controlButton
);
1797 m_controlButton
= new QToolButton(this);
1798 m_controlButton
->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
1799 m_controlButton
->setToolTip(i18nc("@action", "Show menu"));
1800 m_controlButton
->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis
);
1801 m_controlButton
->setPopupMode(QToolButton::InstantPopup
);
1803 QMenu
* controlMenu
= new QMenu(m_controlButton
);
1804 connect(controlMenu
, &QMenu::aboutToShow
, this, &DolphinMainWindow::updateControlMenu
);
1805 controlMenu
->installEventFilter(this);
1807 m_controlButton
->setMenu(controlMenu
);
1809 toolBar()->addWidget(m_controlButton
);
1810 connect(toolBar(), &KToolBar::iconSizeChanged
,
1811 m_controlButton
, &QToolButton::setIconSize
);
1813 // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
1814 // gets edited. In this case we must add them again. The adding is done asynchronously by
1815 // m_updateToolBarTimer.
1816 connect(m_controlButton
, &QToolButton::destroyed
, this, &DolphinMainWindow::slotControlButtonDeleted
);
1817 m_updateToolBarTimer
= new QTimer(this);
1818 m_updateToolBarTimer
->setInterval(500);
1819 connect(m_updateToolBarTimer
, &QTimer::timeout
, this, &DolphinMainWindow::updateToolBar
);
1822 void DolphinMainWindow::deleteControlButton()
1824 delete m_controlButton
;
1825 m_controlButton
= nullptr;
1827 delete m_updateToolBarTimer
;
1828 m_updateToolBarTimer
= nullptr;
1831 bool DolphinMainWindow::addActionToMenu(QAction
* action
, QMenu
* menu
)
1836 const KToolBar
* toolBarWidget
= toolBar();
1837 foreach (const QWidget
* widget
, action
->associatedWidgets()) {
1838 if (widget
== toolBarWidget
) {
1843 menu
->addAction(action
);
1847 void DolphinMainWindow::refreshViews()
1849 m_tabWidget
->refreshViews();
1851 if (GeneralSettings::modifiedStartupSettings()) {
1852 // The startup settings have been changed by the user (see bug #254947).
1853 // Synchronize the split-view setting with the active view:
1854 const bool splitView
= GeneralSettings::splitView();
1855 m_tabWidget
->currentTabPage()->setSplitViewEnabled(splitView
);
1856 updateSplitAction();
1857 updateWindowTitle();
1860 emit
settingsChanged();
1863 void DolphinMainWindow::clearStatusBar()
1865 m_activeViewContainer
->statusBar()->resetToDefaultText();
1868 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
1870 connect(container
, &DolphinViewContainer::showFilterBarChanged
,
1871 this, &DolphinMainWindow::updateFilterBarAction
);
1872 connect(container
, &DolphinViewContainer::writeStateChanged
,
1873 this, &DolphinMainWindow::slotWriteStateChanged
);
1874 connect(container
, &DolphinViewContainer::searchModeEnabledChanged
,
1875 this, &DolphinMainWindow::updateSearchAction
);
1877 const QAction
* toggleSearchAction
= actionCollection()->action(QStringLiteral("toggle_search"));
1878 connect(toggleSearchAction
, &QAction::triggered
, container
, &DolphinViewContainer::setSearchModeEnabled
);
1880 const DolphinView
* view
= container
->view();
1881 connect(view
, &DolphinView::selectionChanged
,
1882 this, &DolphinMainWindow::slotSelectionChanged
);
1883 connect(view
, &DolphinView::requestItemInfo
,
1884 this, &DolphinMainWindow::requestItemInfo
);
1885 connect(view
, &DolphinView::tabRequested
,
1886 this, &DolphinMainWindow::openNewTab
);
1887 connect(view
, &DolphinView::requestContextMenu
,
1888 this, &DolphinMainWindow::openContextMenu
);
1889 connect(view
, &DolphinView::directoryLoadingStarted
,
1890 this, &DolphinMainWindow::enableStopAction
);
1891 connect(view
, &DolphinView::directoryLoadingCompleted
,
1892 this, &DolphinMainWindow::disableStopAction
);
1893 connect(view
, &DolphinView::directoryLoadingCompleted
,
1894 this, &DolphinMainWindow::slotDirectoryLoadingCompleted
);
1895 connect(view
, &DolphinView::goBackRequested
,
1896 this, &DolphinMainWindow::goBack
);
1897 connect(view
, &DolphinView::goForwardRequested
,
1898 this, &DolphinMainWindow::goForward
);
1899 connect(view
, &DolphinView::urlActivated
,
1900 this, &DolphinMainWindow::handleUrl
);
1902 const KUrlNavigator
* navigator
= container
->urlNavigator();
1903 connect(navigator
, &KUrlNavigator::urlChanged
,
1904 this, &DolphinMainWindow::changeUrl
);
1905 connect(navigator
, &KUrlNavigator::historyChanged
,
1906 this, &DolphinMainWindow::updateHistory
);
1907 connect(navigator
, &KUrlNavigator::editableStateChanged
,
1908 this, &DolphinMainWindow::slotEditableStateChanged
);
1909 connect(navigator
, &KUrlNavigator::tabRequested
,
1910 this, &DolphinMainWindow::openNewTabAfterLastTab
);
1913 void DolphinMainWindow::updateSplitAction()
1915 QAction
* splitAction
= actionCollection()->action(QStringLiteral("split_view"));
1916 const DolphinTabPage
* tabPage
= m_tabWidget
->currentTabPage();
1917 if (tabPage
->splitViewEnabled()) {
1918 if (GeneralSettings::closeActiveSplitView() ? tabPage
->primaryViewActive() : !tabPage
->primaryViewActive()) {
1919 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
1920 splitAction
->setToolTip(i18nc("@info", "Close left view"));
1921 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
1923 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
1924 splitAction
->setToolTip(i18nc("@info", "Close right view"));
1925 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
1928 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
1929 splitAction
->setToolTip(i18nc("@info", "Split view"));
1930 splitAction
->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
1934 bool DolphinMainWindow::isKompareInstalled() const
1936 static bool initialized
= false;
1937 static bool installed
= false;
1939 // TODO: maybe replace this approach later by using a menu
1940 // plugin like kdiff3plugin.cpp
1941 installed
= !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
1947 void DolphinMainWindow::createPanelAction(const QIcon
& icon
,
1948 const QKeySequence
& shortcut
,
1949 QAction
* dockAction
,
1950 const QString
& actionName
)
1952 QAction
* panelAction
= actionCollection()->addAction(actionName
);
1953 panelAction
->setCheckable(true);
1954 panelAction
->setChecked(dockAction
->isChecked());
1955 panelAction
->setText(dockAction
->text());
1956 panelAction
->setIcon(icon
);
1957 actionCollection()->setDefaultShortcut(panelAction
, shortcut
);
1959 connect(panelAction
, &QAction::triggered
, dockAction
, &QAction::trigger
);
1960 connect(dockAction
, &QAction::toggled
, panelAction
, &QAction::setChecked
);
1963 void DolphinMainWindow::setupWhatsThis()
1966 menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1967 "<emphasis>Menubar</emphasis>. It provides access to commands and "
1968 "configuration options. Left-click on any of the menus on this "
1969 "bar to see its contents.</para><para>The Menubar can be hidden "
1970 "by unchecking <interface>Settings|Show Menubar</interface>. Then "
1971 "most of its contents become available through a <interface>Control"
1972 "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
1973 toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
1974 "<emphasis>Toolbar</emphasis>. It allows quick access to "
1975 "frequently used actions.</para><para>It is highly customizable. "
1976 "All items you see in the <interface>Control</interface> menu or "
1977 "in the <interface>Menubar</interface> can be placed on the "
1978 "Toolbar. Just right-click on it and select <interface>Configure "
1979 "Toolbars…</interface> or find this action in the <interface>"
1980 "Control</interface> or <interface>Settings</interface> menu."
1981 "</para><para>The location of the bar and the style of its "
1982 "buttons can also be changed in the right-click menu. Right-click "
1983 "a button if you want to show or hide its text.</para>"));
1984 m_tabWidget
->setWhatsThis(xi18nc("@info:whatsthis main view",
1985 "<para>Here you can see the <emphasis>folders</emphasis> and "
1986 "<emphasis>files</emphasis> that are at the location described in "
1987 "the <interface>Location Bar</interface> above. This area is the "
1988 "central part of this application where you navigate to the files "
1989 "you want to use.</para><para>For an elaborate and general "
1990 "introduction to this application <link "
1991 "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
1992 "click here</link>. This will open an introductory article from "
1993 "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
1994 "explanations of all the features of this <emphasis>view</emphasis> "
1995 "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
1996 "instead. This will open a page from the <emphasis>Handbook"
1997 "</emphasis> that covers the basics.</para>"));
2000 actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings
))
2001 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
2002 "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
2003 "There you can set up key combinations to trigger an action when "
2004 "they are pressed simultaneously. All commands in this application can "
2005 "be triggered this way.</para>"));
2006 actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars
))
2007 ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
2008 "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
2009 "<para>All items you see in the <interface>Control</interface> menu "
2010 "or in the <interface>Menubar</interface> can also be placed on the Toolbar.</para>"));
2011 actionCollection()->action(KStandardAction::name(KStandardAction::Preferences
))
2012 ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
2013 "change a multitude of settings for this application. For an explanation "
2014 "of the various settings go to the chapter <emphasis>Configuring Dolphin"
2015 "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
2018 // The whatsthis has to be set for the m_helpMenu and for the
2019 // StandardAction separately because both are used in different locations.
2020 // m_helpMenu is only used for createControlButton() button.
2022 // Links do not work within the Menubar so texts without links are provided there.
2024 // i18n: If the external link isn't available in your language you should
2025 // probably state the external link language at least in brackets to not
2026 // frustrate the user. If there are multiple languages that the user might
2027 // know with a reasonable chance you might want to have 2 external links.
2028 // The same is in my opinion true for every external link you translate.
2029 const QString whatsThisHelpContents
= xi18nc("@info:whatsthis handbook",
2030 "<para>This opens the Handbook for this application. It provides "
2031 "explanations for every part of <emphasis>Dolphin</emphasis>.</para>");
2032 actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents
))
2033 ->setWhatsThis(whatsThisHelpContents
2034 + xi18nc("@info:whatsthis second half of handbook hb text without link",
2035 "<para>If you want more elaborate introductions to the "
2036 "different features of <emphasis>Dolphin</emphasis> "
2037 "go to the KDE UserBase Wiki.</para>"));
2038 m_helpMenu
->action(KHelpMenu::menuHelpContents
)->setWhatsThis(whatsThisHelpContents
2039 + xi18nc("@info:whatsthis second half of handbook text with link",
2040 "<para>If you want more elaborate introductions to the "
2041 "different features of <emphasis>Dolphin</emphasis> "
2042 "<link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. "
2043 "It will open the dedicated page in the KDE UserBase Wiki.</para>"));
2045 const QString whatsThisWhatsThis
= xi18nc("@info:whatsthis whatsthis button",
2046 "<para>This is the button that invokes the help feature you are "
2047 "using right now! Click it, then click any component of this "
2048 "application to ask \"What's this?\" about it. The mouse cursor "
2049 "will change appearance if no help is available for a spot.</para>");
2050 actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis
))
2051 ->setWhatsThis(whatsThisWhatsThis
2052 + xi18nc("@info:whatsthis second half of whatsthis button text without link",
2053 "<para>There are two other ways to get help for this application: The "
2054 "<interface>Dolphin Handbook</interface> in the <interface>Help"
2055 "</interface> menu and the <emphasis>KDE UserBase Wiki</emphasis> "
2056 "article about <emphasis>File Management</emphasis> online."
2057 "</para><para>The \"What's this?\" help is "
2058 "missing in most other windows so don't get too used to this.</para>"));
2059 m_helpMenu
->action(KHelpMenu::menuWhatsThis
)->setWhatsThis(whatsThisWhatsThis
2060 + xi18nc("@info:whatsthis second half of whatsthis button text with link",
2061 "<para>There are two other ways to get help: "
2062 "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
2063 "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
2064 "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
2065 "missing in most other windows so don't get too used to this.</para>"));
2067 const QString whatsThisReportBug
= xi18nc("@info:whatsthis","<para>This opens a "
2068 "window that will guide you through reporting errors or flaws "
2069 "in this application or in other KDE software.</para>");
2070 actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug
))
2071 ->setWhatsThis(whatsThisReportBug
);
2072 m_helpMenu
->action(KHelpMenu::menuReportBug
)->setWhatsThis(whatsThisReportBug
2073 + xi18nc("@info:whatsthis second half of reportbug text with link",
2074 "<para>High-quality bug reports are much appreciated. To learn "
2075 "how to make your bug report as effective as possible "
2076 "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
2077 "click here</link>.</para>"));
2079 const QString whatsThisDonate
= xi18nc("@info:whatsthis","<para>This opens a "
2080 "<emphasis>web page</emphasis> where you can donate to "
2081 "support the continued work on this application and many "
2082 "other projects by the <emphasis>KDE</emphasis> community.</para>"
2083 "<para>Donating is the easiest and fastest way to efficiently "
2084 "support KDE and its projects. KDE projects are available for "
2085 "free therefore your donation is needed to cover things that "
2086 "require money like servers, contributor meetings, etc.</para>"
2087 "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
2088 "organization behind the KDE community.</para>");
2089 actionCollection()->action(KStandardAction::name(KStandardAction::Donate
))
2090 ->setWhatsThis(whatsThisDonate
);
2091 m_helpMenu
->action(KHelpMenu::menuDonate
)->setWhatsThis(whatsThisDonate
);
2093 const QString whatsThisSwitchLanguage
= xi18nc("@info:whatsthis",
2094 "With this you can change the language this application uses."
2095 "<nl/>You can even set secondary languages which will be used "
2096 "if texts are not available in your preferred language.");
2097 actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage
))
2098 ->setWhatsThis(whatsThisSwitchLanguage
);
2099 m_helpMenu
->action(KHelpMenu::menuSwitchLanguage
)->setWhatsThis(whatsThisSwitchLanguage
);
2101 const QString whatsThisAboutApp
= xi18nc("@info:whatsthis","This opens a "
2102 "window that informs you about the version, license, "
2103 "used libraries and maintainers of this application.");
2104 actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp
))
2105 ->setWhatsThis(whatsThisAboutApp
);
2106 m_helpMenu
->action(KHelpMenu::menuAboutApp
)->setWhatsThis(whatsThisAboutApp
);
2108 const QString whatsThisAboutKDE
= xi18nc("@info:whatsthis","This opens a "
2109 "window with information about <emphasis>KDE</emphasis>. "
2110 "The KDE community are the people behind this free software."
2111 "<nl/>If you like using this application but don't know "
2112 "about KDE or want to see a cute dragon have a look!");
2113 actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE
))
2114 ->setWhatsThis(whatsThisAboutKDE
);
2115 m_helpMenu
->action(KHelpMenu::menuAboutKDE
)->setWhatsThis(whatsThisAboutKDE
);
2118 bool DolphinMainWindow::event(QEvent
*event
)
2120 if (event
->type() == QEvent::WhatsThisClicked
) {
2122 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2123 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2126 return KXmlGuiWindow::event(event
);
2129 bool DolphinMainWindow::eventFilter(QObject
* obj
, QEvent
* event
)
2132 if (event
->type() == QEvent::WhatsThisClicked
) {
2134 QWhatsThisClickedEvent
* whatsThisEvent
= dynamic_cast<QWhatsThisClickedEvent
*>(event
);
2135 QDesktopServices::openUrl(QUrl(whatsThisEvent
->href()));
2141 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
2142 KIO::FileUndoManager::UiInterface()
2146 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
2150 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
2152 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
2154 DolphinViewContainer
* container
= mainWin
->activeViewContainer();
2155 container
->showMessage(job
->errorString(), DolphinViewContainer::Error
);
2157 KIO::FileUndoManager::UiInterface::jobError(job
);
2161 bool DolphinMainWindow::isUrlOpen(const QString
& url
)
2163 if (m_tabWidget
->getIndexByUrl(QUrl::fromUserInput((url
))).first
>= 0) {