2007-04-01 18:36:23 +00:00
|
|
|
/***************************************************************************
|
2011-02-04 14:57:33 +00:00
|
|
|
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
2007-04-01 18:36:23 +00:00
|
|
|
* Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
|
|
|
|
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "dolphinmainwindow.h"
|
|
|
|
|
2015-10-10 13:09:48 +00:00
|
|
|
#include "global.h"
|
2010-12-31 10:59:46 +00:00
|
|
|
#include "dolphindockwidget.h"
|
2010-01-25 07:58:24 +00:00
|
|
|
#include "dolphincontextmenu.h"
|
2010-08-27 05:26:27 +00:00
|
|
|
#include "dolphinnewfilemenu.h"
|
2018-03-19 08:57:24 +00:00
|
|
|
#include "dolphinplacesmodelsingleton.h"
|
2014-06-19 20:04:36 +00:00
|
|
|
#include "dolphinrecenttabsmenu.h"
|
2014-08-10 16:52:06 +00:00
|
|
|
#include "dolphintabwidget.h"
|
2007-06-07 21:10:48 +00:00
|
|
|
#include "dolphinviewcontainer.h"
|
2014-07-02 13:30:37 +00:00
|
|
|
#include "dolphintabpage.h"
|
2017-08-24 13:45:28 +00:00
|
|
|
#include "middleclickactioneventfilter.h"
|
2009-01-14 20:14:36 +00:00
|
|
|
#include "panels/folders/folderspanel.h"
|
|
|
|
#include "panels/places/placespanel.h"
|
|
|
|
#include "panels/information/informationpanel.h"
|
2018-01-21 11:18:21 +00:00
|
|
|
#include "panels/terminal/terminalpanel.h"
|
2010-07-24 22:08:30 +00:00
|
|
|
#include "settings/dolphinsettingsdialog.h"
|
2009-08-01 20:01:51 +00:00
|
|
|
#include "statusbar/dolphinstatusbar.h"
|
2010-07-24 22:08:30 +00:00
|
|
|
#include "views/dolphinviewactionhandler.h"
|
|
|
|
#include "views/dolphinremoteencoding.h"
|
2012-01-27 20:52:29 +00:00
|
|
|
#include "views/draganddrophelper.h"
|
2010-07-24 22:08:30 +00:00
|
|
|
#include "views/viewproperties.h"
|
2013-08-28 16:46:45 +00:00
|
|
|
#include "views/dolphinnewfilemenuobserver.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "dolphin_generalsettings.h"
|
|
|
|
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KActionCollection>
|
|
|
|
#include <KActionMenu>
|
2016-05-18 01:06:49 +00:00
|
|
|
#include <KAuthorized>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KConfig>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KFileItemListProperties>
|
|
|
|
#include <KFilePlacesModel>
|
2017-08-03 14:48:02 +00:00
|
|
|
#include <KHelpMenu>
|
2012-04-17 20:19:18 +00:00
|
|
|
#include <KIO/JobUiDelegate>
|
2018-03-03 13:36:44 +00:00
|
|
|
#include <KIO/OpenFileManagerWindowJob>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KJobWidgets>
|
2014-10-18 12:42:41 +00:00
|
|
|
#include <KLocalizedString>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KMessageBox>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KProtocolInfo>
|
|
|
|
#include <KProtocolManager>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KRun>
|
|
|
|
#include <KShell>
|
|
|
|
#include <KStandardAction>
|
|
|
|
#include <KToggleAction>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KToolBar>
|
2011-02-04 19:42:42 +00:00
|
|
|
#include <KToolInvocation>
|
2014-10-18 13:00:17 +00:00
|
|
|
#include <KUrlComboBox>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KUrlNavigator>
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2015-02-04 09:22:03 +00:00
|
|
|
#include <QApplication>
|
2007-12-16 19:25:59 +00:00
|
|
|
#include <QClipboard>
|
2014-10-18 13:00:17 +00:00
|
|
|
#include <QCloseEvent>
|
2015-02-03 08:25:33 +00:00
|
|
|
#include <QDialog>
|
2018-03-03 13:36:44 +00:00
|
|
|
#include <QFileInfo>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <kdualaction.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2011-08-13 10:42:53 +00:00
|
|
|
namespace {
|
|
|
|
// Used for GeneralSettings::version() to determine whether
|
|
|
|
// an updated version of Dolphin is running.
|
2011-08-14 13:30:29 +00:00
|
|
|
const int CurrentDolphinVersion = 200;
|
2016-06-25 14:39:49 +00:00
|
|
|
}
|
2011-08-13 10:42:53 +00:00
|
|
|
|
2011-04-12 18:01:31 +00:00
|
|
|
DolphinMainWindow::DolphinMainWindow() :
|
2017-11-21 09:52:14 +00:00
|
|
|
KXmlGuiWindow(nullptr),
|
|
|
|
m_newFileMenu(nullptr),
|
|
|
|
m_tabWidget(nullptr),
|
|
|
|
m_activeViewContainer(nullptr),
|
|
|
|
m_actionHandler(nullptr),
|
|
|
|
m_remoteEncoding(nullptr),
|
2011-04-12 18:01:31 +00:00
|
|
|
m_settingsDialog(),
|
2017-11-21 09:52:14 +00:00
|
|
|
m_controlButton(nullptr),
|
|
|
|
m_updateToolBarTimer(nullptr),
|
|
|
|
m_lastHandleUrlStatJob(nullptr),
|
|
|
|
m_terminalPanel(nullptr),
|
|
|
|
m_placesPanel(nullptr),
|
2017-10-12 21:17:51 +00:00
|
|
|
m_tearDownFromPlacesRequested(false)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2017-07-28 11:35:50 +00:00
|
|
|
Q_INIT_RESOURCE(dolphin);
|
2018-04-29 15:07:18 +00:00
|
|
|
setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
|
2016-03-16 21:17:37 +00:00
|
|
|
setObjectName(QStringLiteral("Dolphin#"));
|
2008-04-12 15:09:46 +00:00
|
|
|
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
|
|
|
|
this, &DolphinMainWindow::showErrorMessage);
|
2013-08-28 16:46:45 +00:00
|
|
|
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
|
2008-04-20 22:07:44 +00:00
|
|
|
undoManager->setUiInterface(new UndoUiInterface());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(undoManager, static_cast<void(KIO::FileUndoManager::*)(bool)>(&KIO::FileUndoManager::undoAvailable),
|
|
|
|
this, &DolphinMainWindow::slotUndoAvailable);
|
|
|
|
connect(undoManager, &KIO::FileUndoManager::undoTextChanged,
|
|
|
|
this, &DolphinMainWindow::slotUndoTextChanged);
|
|
|
|
connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted,
|
|
|
|
this, &DolphinMainWindow::clearStatusBar);
|
|
|
|
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
|
|
|
|
this, &DolphinMainWindow::showCommand);
|
2011-04-12 18:01:31 +00:00
|
|
|
|
2011-11-06 08:53:03 +00:00
|
|
|
GeneralSettings* generalSettings = GeneralSettings::self();
|
2011-08-14 13:30:29 +00:00
|
|
|
const bool firstRun = (generalSettings->version() < 200);
|
2011-04-12 18:01:31 +00:00
|
|
|
if (firstRun) {
|
|
|
|
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget = new DolphinTabWidget(this);
|
2017-05-22 09:37:37 +00:00
|
|
|
m_tabWidget->setObjectName("tabWidget");
|
2016-03-16 21:17:37 +00:00
|
|
|
connect(m_tabWidget, &DolphinTabWidget::activeViewChanged,
|
|
|
|
this, &DolphinMainWindow::activeViewChanged);
|
|
|
|
connect(m_tabWidget, &DolphinTabWidget::tabCountChanged,
|
|
|
|
this, &DolphinMainWindow::tabCountChanged);
|
|
|
|
connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged,
|
|
|
|
this, &DolphinMainWindow::setUrlAsCaption);
|
2014-08-10 16:52:06 +00:00
|
|
|
setCentralWidget(m_tabWidget);
|
|
|
|
|
2011-04-12 18:01:31 +00:00
|
|
|
setupActions();
|
|
|
|
|
|
|
|
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
|
|
|
|
connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinMainWindow::createDirectory);
|
2011-04-12 18:01:31 +00:00
|
|
|
|
|
|
|
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(this, &DolphinMainWindow::urlChanged,
|
|
|
|
m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
|
2011-04-12 18:01:31 +00:00
|
|
|
|
|
|
|
setupDockWidgets();
|
|
|
|
|
|
|
|
setupGUI(Keys | Save | Create | ToolBar);
|
2016-03-16 21:17:37 +00:00
|
|
|
stateChanged(QStringLiteral("new_file"));
|
2011-04-12 18:01:31 +00:00
|
|
|
|
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(clipboard, &QClipboard::dataChanged,
|
|
|
|
this, &DolphinMainWindow::updatePasteAction);
|
2011-04-12 18:01:31 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
|
2011-04-12 18:01:31 +00:00
|
|
|
showFilterBarAction->setChecked(generalSettings->filterBar());
|
|
|
|
|
|
|
|
if (firstRun) {
|
|
|
|
menuBar()->setVisible(false);
|
|
|
|
// Assure a proper default size if Dolphin runs the first time
|
|
|
|
resize(750, 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool showMenu = !menuBar()->isHidden();
|
|
|
|
QAction* showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
|
|
|
|
showMenuBarAction->setChecked(showMenu); // workaround for bug #171080
|
|
|
|
if (!showMenu) {
|
2012-04-07 22:09:11 +00:00
|
|
|
createControlButton();
|
2011-04-12 18:01:31 +00:00
|
|
|
}
|
2017-08-24 13:45:28 +00:00
|
|
|
|
|
|
|
// enable middle-click on back/forward/up to open in a new tab
|
|
|
|
auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
|
|
|
|
connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked);
|
|
|
|
toolBar()->installEventFilter(middleClickEventFilter);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DolphinMainWindow::~DolphinMainWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-27 10:55:53 +00:00
|
|
|
void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView)
|
2009-12-17 21:07:18 +00:00
|
|
|
{
|
2015-04-27 10:55:53 +00:00
|
|
|
m_tabWidget->openDirectories(dirs, splitView);
|
2009-12-17 21:07:18 +00:00
|
|
|
}
|
|
|
|
|
2015-04-27 10:55:53 +00:00
|
|
|
void DolphinMainWindow::openFiles(const QList<QUrl>& files, bool splitView)
|
2009-12-17 21:07:18 +00:00
|
|
|
{
|
2015-04-27 10:55:53 +00:00
|
|
|
m_tabWidget->openFiles(files, splitView);
|
2009-12-17 21:07:18 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 21:39:35 +00:00
|
|
|
void DolphinMainWindow::showCommand(CommandType command)
|
2007-06-12 21:45:22 +00:00
|
|
|
{
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
|
|
|
|
switch (command) {
|
|
|
|
case KIO::FileUndoManager::Copy:
|
2012-04-12 21:57:51 +00:00
|
|
|
statusBar->setText(i18nc("@info:status", "Successfully copied."));
|
2008-10-01 21:39:35 +00:00
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Move:
|
2012-04-12 21:57:51 +00:00
|
|
|
statusBar->setText(i18nc("@info:status", "Successfully moved."));
|
2008-10-01 21:39:35 +00:00
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Link:
|
2012-04-12 21:57:51 +00:00
|
|
|
statusBar->setText(i18nc("@info:status", "Successfully linked."));
|
2008-10-01 21:39:35 +00:00
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Trash:
|
2012-04-12 21:57:51 +00:00
|
|
|
statusBar->setText(i18nc("@info:status", "Successfully moved to trash."));
|
2008-10-01 21:39:35 +00:00
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Rename:
|
2012-04-12 21:57:51 +00:00
|
|
|
statusBar->setText(i18nc("@info:status", "Successfully renamed."));
|
2008-10-01 21:39:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KIO::FileUndoManager::Mkdir:
|
2012-04-12 21:57:51 +00:00
|
|
|
statusBar->setText(i18nc("@info:status", "Created folder."));
|
2008-10-01 21:39:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-03-29 14:54:56 +00:00
|
|
|
void DolphinMainWindow::pasteIntoFolder()
|
|
|
|
{
|
|
|
|
m_activeViewContainer->view()->pasteIntoFolder();
|
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
void DolphinMainWindow::changeUrl(const QUrl &url)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2008-10-07 22:05:55 +00:00
|
|
|
if (!KProtocolManager::supportsListing(url)) {
|
2008-10-07 20:29:18 +00:00
|
|
|
// The URL navigator only checks for validity, not
|
|
|
|
// if the URL can be listed. An error message is
|
|
|
|
// shown due to DolphinViewContainer::restoreView().
|
|
|
|
return;
|
|
|
|
}
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
m_activeViewContainer->setUrl(url);
|
|
|
|
updateEditActions();
|
|
|
|
updatePasteAction();
|
|
|
|
updateViewActions();
|
|
|
|
updateGoActions();
|
|
|
|
|
|
|
|
emit urlChanged(url);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
|
2012-04-26 06:31:46 +00:00
|
|
|
{
|
2017-10-12 21:17:51 +00:00
|
|
|
if (m_tearDownFromPlacesRequested && url == QUrl::fromLocalFile(QDir::homePath())) {
|
|
|
|
m_placesPanel->proceedWithTearDown();
|
|
|
|
m_tearDownFromPlacesRequested = false;
|
|
|
|
}
|
|
|
|
|
2012-04-26 06:31:46 +00:00
|
|
|
m_activeViewContainer->setAutoGrabFocus(false);
|
|
|
|
changeUrl(url);
|
|
|
|
m_activeViewContainer->setAutoGrabFocus(true);
|
|
|
|
}
|
|
|
|
|
2008-02-07 07:27:06 +00:00
|
|
|
void DolphinMainWindow::slotEditableStateChanged(bool editable)
|
|
|
|
{
|
|
|
|
KToggleAction* editableLocationAction =
|
2016-03-16 21:17:37 +00:00
|
|
|
static_cast<KToggleAction*>(actionCollection()->action(QStringLiteral("editable_location")));
|
2008-02-07 07:27:06 +00:00
|
|
|
editableLocationAction->setChecked(editable);
|
|
|
|
}
|
|
|
|
|
2007-10-02 19:03:03 +00:00
|
|
|
void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
updateEditActions();
|
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* compareFilesAction = actionCollection()->action(QStringLiteral("compare_files"));
|
2007-12-18 15:08:59 +00:00
|
|
|
if (selectedUrlsCount == 2) {
|
2008-06-28 18:42:51 +00:00
|
|
|
compareFilesAction->setEnabled(isKompareInstalled());
|
2007-12-18 15:08:59 +00:00
|
|
|
} else {
|
|
|
|
compareFilesAction->setEnabled(false);
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
emit selectionChanged(selection);
|
|
|
|
}
|
|
|
|
|
2008-02-23 15:48:56 +00:00
|
|
|
void DolphinMainWindow::updateHistory()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2008-02-23 15:48:56 +00:00
|
|
|
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
const int index = urlNavigator->historyIndex();
|
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
QAction* backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (backAction) {
|
2011-10-09 09:12:22 +00:00
|
|
|
backAction->setToolTip(i18nc("@info", "Go back"));
|
2008-02-23 15:48:56 +00:00
|
|
|
backAction->setEnabled(index < urlNavigator->historySize() - 1);
|
|
|
|
}
|
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
QAction* forwardAction = actionCollection()->action(KStandardAction::name(KStandardAction::Forward));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (forwardAction) {
|
2011-10-09 09:12:22 +00:00
|
|
|
forwardAction->setToolTip(i18nc("@info", "Go forward"));
|
2008-02-23 15:48:56 +00:00
|
|
|
forwardAction->setEnabled(index > 0);
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateFilterBarAction(bool show)
|
|
|
|
{
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
|
2007-04-01 18:36:23 +00:00
|
|
|
showFilterBarAction->setChecked(show);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::openNewMainWindow()
|
|
|
|
{
|
2017-03-27 22:52:29 +00:00
|
|
|
Dolphin::openNewWindow({m_activeViewContainer->url()}, this);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
void DolphinMainWindow::openNewActivatedTab()
|
2008-04-12 15:09:46 +00:00
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget->openNewActivatedTab();
|
2008-04-12 15:09:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
void DolphinMainWindow::openNewTab(const QUrl& url)
|
2008-04-12 16:12:57 +00:00
|
|
|
{
|
2014-09-15 16:17:30 +00:00
|
|
|
m_tabWidget->openNewTab(url);
|
2008-04-12 16:12:57 +00:00
|
|
|
}
|
|
|
|
|
2008-10-25 10:32:55 +00:00
|
|
|
void DolphinMainWindow::openInNewTab()
|
|
|
|
{
|
2013-05-22 19:47:14 +00:00
|
|
|
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
|
2017-06-11 17:26:52 +00:00
|
|
|
bool tabCreated = false;
|
|
|
|
|
|
|
|
foreach (const KFileItem& item, list) {
|
|
|
|
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
|
|
|
|
if (!url.isEmpty()) {
|
|
|
|
openNewTab(url);
|
|
|
|
tabCreated = true;
|
2013-05-22 19:47:14 +00:00
|
|
|
}
|
2008-10-25 10:32:55 +00:00
|
|
|
}
|
2017-06-11 17:26:52 +00:00
|
|
|
|
|
|
|
// if no new tab has been created from the selection
|
|
|
|
// open the current directory in a new tab
|
|
|
|
if (!tabCreated) {
|
|
|
|
openNewTab(m_activeViewContainer->url());
|
|
|
|
}
|
2008-10-25 10:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::openInNewWindow()
|
|
|
|
{
|
2014-10-21 19:18:43 +00:00
|
|
|
QUrl newWindowUrl;
|
2010-10-06 15:04:37 +00:00
|
|
|
|
2008-10-25 10:32:55 +00:00
|
|
|
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
|
2010-10-06 15:04:37 +00:00
|
|
|
if (list.isEmpty()) {
|
|
|
|
newWindowUrl = m_activeViewContainer->url();
|
2013-05-28 15:31:14 +00:00
|
|
|
} else if (list.count() == 1) {
|
|
|
|
const KFileItem& item = list.first();
|
|
|
|
newWindowUrl = DolphinView::openItemAsFolderUrl(item);
|
2010-10-06 15:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!newWindowUrl.isEmpty()) {
|
2017-03-08 15:52:15 +00:00
|
|
|
Dolphin::openNewWindow({newWindowUrl}, this);
|
2008-10-25 10:32:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-18 10:55:24 +00:00
|
|
|
void DolphinMainWindow::showTarget()
|
|
|
|
{
|
|
|
|
const auto link = m_activeViewContainer->view()->selectedItems().at(0);
|
|
|
|
const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir();
|
|
|
|
auto linkDestination = link.linkDest();
|
|
|
|
if (QFileInfo(linkDestination).isRelative()) {
|
|
|
|
linkDestination = linkLocationDir.filePath(linkDestination);
|
|
|
|
}
|
|
|
|
if (QFileInfo::exists(linkDestination)) {
|
|
|
|
KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)});
|
|
|
|
} else {
|
|
|
|
m_activeViewContainer->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination),
|
|
|
|
DolphinViewContainer::Warning);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-11 09:21:16 +00:00
|
|
|
void DolphinMainWindow::showEvent(QShowEvent* event)
|
|
|
|
{
|
|
|
|
KXmlGuiWindow::showEvent(event);
|
2014-07-08 17:16:17 +00:00
|
|
|
|
2010-01-11 09:21:16 +00:00
|
|
|
if (!event->spontaneous()) {
|
|
|
|
m_activeViewContainer->view()->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
2009-08-13 18:54:16 +00:00
|
|
|
// Find out if Dolphin is closed directly by the user or
|
|
|
|
// by the session manager because the session is closed
|
|
|
|
bool closedByUser = true;
|
2016-01-28 20:03:14 +00:00
|
|
|
if (qApp->isSavingSession()) {
|
2009-08-13 18:54:16 +00:00
|
|
|
closedByUser = false;
|
|
|
|
}
|
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
|
2009-03-12 22:40:32 +00:00
|
|
|
// Ask the user if he really wants to quit and close all tabs.
|
|
|
|
// Open a confirmation dialog with 3 buttons:
|
2015-02-03 08:25:33 +00:00
|
|
|
// QDialogButtonBox::Yes -> Quit
|
|
|
|
// QDialogButtonBox::No -> Close only the current tab
|
|
|
|
// QDialogButtonBox::Cancel -> do nothing
|
2014-04-06 01:32:55 +00:00
|
|
|
QDialog *dialog = new QDialog(this, Qt::Dialog);
|
|
|
|
dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
|
2009-03-12 22:40:32 +00:00
|
|
|
dialog->setModal(true);
|
2014-04-06 01:32:55 +00:00
|
|
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel);
|
2018-04-29 15:13:18 +00:00
|
|
|
KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
|
2016-03-16 21:17:37 +00:00
|
|
|
KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
|
2014-04-06 01:32:55 +00:00
|
|
|
KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
|
|
|
|
buttons->button(QDialogButtonBox::Yes)->setDefault(true);
|
2009-03-12 22:40:32 +00:00
|
|
|
|
|
|
|
bool doNotAskAgainCheckboxResult = false;
|
|
|
|
|
2009-03-17 20:34:32 +00:00
|
|
|
const int result = KMessageBox::createKMessageBox(dialog,
|
2014-04-06 01:32:55 +00:00
|
|
|
buttons,
|
2009-03-12 22:40:32 +00:00
|
|
|
QMessageBox::Warning,
|
|
|
|
i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
|
|
|
|
QStringList(),
|
|
|
|
i18n("Do not ask again"),
|
|
|
|
&doNotAskAgainCheckboxResult,
|
|
|
|
KMessageBox::Notify);
|
|
|
|
|
|
|
|
if (doNotAskAgainCheckboxResult) {
|
2011-11-06 10:58:48 +00:00
|
|
|
GeneralSettings::setConfirmClosingMultipleTabs(false);
|
2009-03-12 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (result) {
|
2014-06-04 19:56:36 +00:00
|
|
|
case QDialogButtonBox::Yes:
|
2009-03-12 22:40:32 +00:00
|
|
|
// Quit
|
|
|
|
break;
|
2014-06-04 19:56:36 +00:00
|
|
|
case QDialogButtonBox::No:
|
2009-03-12 22:40:32 +00:00
|
|
|
// Close only the current tab
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget->closeTab();
|
2018-03-08 09:21:13 +00:00
|
|
|
Q_FALLTHROUGH();
|
2009-03-12 22:40:32 +00:00
|
|
|
default:
|
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-06 10:58:48 +00:00
|
|
|
GeneralSettings::setVersion(CurrentDolphinVersion);
|
2014-10-07 05:38:16 +00:00
|
|
|
GeneralSettings::self()->save();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-16 20:44:36 +00:00
|
|
|
KXmlGuiWindow::closeEvent(event);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-30 18:42:17 +00:00
|
|
|
void DolphinMainWindow::saveProperties(KConfigGroup& group)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget->saveProperties(group);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-30 18:42:17 +00:00
|
|
|
void DolphinMainWindow::readProperties(const KConfigGroup& group)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget->readProperties(group);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateNewMenu()
|
|
|
|
{
|
2011-07-30 18:13:09 +00:00
|
|
|
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->checkUpToDate();
|
|
|
|
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
|
2018-05-06 20:06:16 +00:00
|
|
|
|
|
|
|
// If we're in the trash, also disable all the 'create new' items
|
|
|
|
// TODO: remove this once https://phabricator.kde.org/T8234 is implemented
|
|
|
|
slotWriteStateChanged(m_activeViewContainer->view()->url().scheme() != QLatin1String("trash"));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 18:44:36 +00:00
|
|
|
void DolphinMainWindow::createDirectory()
|
|
|
|
{
|
2011-07-30 18:13:09 +00:00
|
|
|
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
|
|
|
|
m_newFileMenu->createDirectory();
|
2009-03-26 18:44:36 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::quit()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2008-11-08 16:22:30 +00:00
|
|
|
void DolphinMainWindow::showErrorMessage(const QString& message)
|
2007-06-15 00:52:25 +00:00
|
|
|
{
|
2012-04-12 21:57:51 +00:00
|
|
|
m_activeViewContainer->showMessage(message, DolphinViewContainer::Error);
|
2007-06-15 00:52:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::slotUndoAvailable(bool available)
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (undoAction) {
|
2007-04-01 18:36:23 +00:00
|
|
|
undoAction->setEnabled(available);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (undoAction) {
|
2007-04-01 18:36:23 +00:00
|
|
|
undoAction->setText(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::undo()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
|
|
|
|
KIO::FileUndoManager::self()->undo();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::cut()
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
m_activeViewContainer->view()->cutSelectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::copy()
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
m_activeViewContainer->view()->copySelectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::paste()
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
m_activeViewContainer->view()->paste();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
void DolphinMainWindow::find()
|
|
|
|
{
|
|
|
|
m_activeViewContainer->setSearchModeEnabled(true);
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::updatePasteAction()
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
2007-11-15 20:04:05 +00:00
|
|
|
QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
|
|
|
|
pasteAction->setEnabled(pasteInfo.first);
|
|
|
|
pasteAction->setText(pasteInfo.second);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2014-11-02 14:34:30 +00:00
|
|
|
void DolphinMainWindow::slotDirectoryLoadingCompleted()
|
|
|
|
{
|
|
|
|
updatePasteAction();
|
|
|
|
}
|
|
|
|
|
2017-08-24 13:45:28 +00:00
|
|
|
void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
|
|
|
|
{
|
2018-03-10 19:50:29 +00:00
|
|
|
if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Back))) {
|
2017-08-24 13:45:28 +00:00
|
|
|
goBackInNewTab();
|
2018-03-10 19:50:29 +00:00
|
|
|
} else if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Forward))) {
|
2017-08-24 13:45:28 +00:00
|
|
|
goForwardInNewTab();
|
|
|
|
} else if (action == actionCollection()->action(QStringLiteral("go_up"))) {
|
|
|
|
goUpInNewTab();
|
|
|
|
} else if (action == actionCollection()->action(QStringLiteral("go_home"))) {
|
|
|
|
goHomeInNewTab();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::selectAll()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-12-16 19:25:59 +00:00
|
|
|
|
|
|
|
// if the URL navigator is editable and focused, select the whole
|
|
|
|
// URL instead of all items of the view
|
|
|
|
|
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
2009-05-26 18:52:14 +00:00
|
|
|
QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses
|
2007-12-16 19:25:59 +00:00
|
|
|
const bool selectUrl = urlNavigator->isUrlEditable() &&
|
|
|
|
lineEdit->hasFocus();
|
|
|
|
if (selectUrl) {
|
|
|
|
lineEdit->selectAll();
|
|
|
|
} else {
|
|
|
|
m_activeViewContainer->view()->selectAll();
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::invertSelection()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->invertSelection();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleSplitView()
|
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
|
2014-07-02 13:30:37 +00:00
|
|
|
tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled());
|
2008-05-04 18:40:06 +00:00
|
|
|
|
2007-06-07 21:41:22 +00:00
|
|
|
updateViewActions();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2016-09-26 16:55:42 +00:00
|
|
|
void DolphinMainWindow::toggleSplitStash()
|
|
|
|
{
|
|
|
|
DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
|
2017-02-02 16:16:54 +00:00
|
|
|
tabPage->setSplitViewEnabled(false);
|
|
|
|
tabPage->setSplitViewEnabled(true, QUrl("stash:/"));
|
2016-09-26 16:55:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::reloadView()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2016-10-04 15:30:51 +00:00
|
|
|
m_activeViewContainer->reload();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::stopLoading()
|
2007-06-12 21:45:22 +00:00
|
|
|
{
|
2010-09-22 19:39:46 +00:00
|
|
|
m_activeViewContainer->view()->stopLoading();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::enableStopAction()
|
|
|
|
{
|
2016-03-16 21:17:37 +00:00
|
|
|
actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
|
2010-09-22 19:39:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::disableStopAction()
|
|
|
|
{
|
2016-03-16 21:17:37 +00:00
|
|
|
actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2017-03-11 17:33:41 +00:00
|
|
|
void DolphinMainWindow::showFilterBar()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2017-03-11 17:33:41 +00:00
|
|
|
m_activeViewContainer->setFilterBarVisible(true);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleEditLocation()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* action = actionCollection()->action(QStringLiteral("editable_location"));
|
2007-06-07 21:10:48 +00:00
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
2008-01-28 11:37:08 +00:00
|
|
|
urlNavigator->setUrlEditable(action->isChecked());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-10-25 09:41:39 +00:00
|
|
|
void DolphinMainWindow::replaceLocation()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2007-11-04 18:50:22 +00:00
|
|
|
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
|
|
|
|
navigator->setUrlEditable(true);
|
2011-01-17 17:39:36 +00:00
|
|
|
navigator->setFocus();
|
2008-02-16 22:05:34 +00:00
|
|
|
|
|
|
|
// select the whole text of the combo box editor
|
2009-05-26 18:52:14 +00:00
|
|
|
QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses
|
2011-01-16 21:18:18 +00:00
|
|
|
lineEdit->selectAll();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
void DolphinMainWindow::togglePanelLockState()
|
|
|
|
{
|
2011-11-06 10:58:48 +00:00
|
|
|
const bool newLockState = !GeneralSettings::lockPanels();
|
2010-12-31 10:59:46 +00:00
|
|
|
foreach (QObject* child, children()) {
|
|
|
|
DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
|
2011-02-09 18:21:58 +00:00
|
|
|
if (dock) {
|
2010-12-31 10:59:46 +00:00
|
|
|
dock->setLocked(newLockState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-06 10:58:48 +00:00
|
|
|
GeneralSettings::setLockPanels(newLockState);
|
2010-12-31 10:59:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 17:49:54 +00:00
|
|
|
void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
|
|
|
|
{
|
|
|
|
if (m_terminalPanel->isHiddenInVisibleWindow()) {
|
|
|
|
m_activeViewContainer->view()->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::goBack()
|
|
|
|
{
|
2010-07-08 19:46:56 +00:00
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
urlNavigator->goBack();
|
2010-11-05 17:02:58 +00:00
|
|
|
|
2010-07-08 19:46:56 +00:00
|
|
|
if (urlNavigator->locationState().isEmpty()) {
|
|
|
|
// An empty location state indicates a redirection URL,
|
|
|
|
// which must be skipped too
|
2010-11-05 17:02:58 +00:00
|
|
|
urlNavigator->goBack();
|
2010-07-08 19:46:56 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goForward()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->goForward();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goUp()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->goUp();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 16:35:50 +00:00
|
|
|
void DolphinMainWindow::goHome()
|
|
|
|
{
|
|
|
|
m_activeViewContainer->urlNavigator()->goHome();
|
|
|
|
}
|
|
|
|
|
2017-08-24 13:45:28 +00:00
|
|
|
void DolphinMainWindow::goBackInNewTab()
|
2009-11-09 17:50:21 +00:00
|
|
|
{
|
2017-08-24 13:45:28 +00:00
|
|
|
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
|
|
|
|
const int index = urlNavigator->historyIndex() + 1;
|
|
|
|
openNewTab(urlNavigator->locationUrl(index));
|
2009-11-09 17:50:21 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 13:45:28 +00:00
|
|
|
void DolphinMainWindow::goForwardInNewTab()
|
2009-11-09 17:50:21 +00:00
|
|
|
{
|
2017-08-24 13:45:28 +00:00
|
|
|
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
|
|
|
|
const int index = urlNavigator->historyIndex() - 1;
|
|
|
|
openNewTab(urlNavigator->locationUrl(index));
|
2009-11-09 17:50:21 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 13:45:28 +00:00
|
|
|
void DolphinMainWindow::goUpInNewTab()
|
2009-11-09 17:50:21 +00:00
|
|
|
{
|
2017-08-24 13:45:28 +00:00
|
|
|
const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl();
|
|
|
|
openNewTab(KIO::upUrl(currentUrl));
|
2009-11-09 17:50:21 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 13:45:28 +00:00
|
|
|
void DolphinMainWindow::goHomeInNewTab()
|
2012-01-09 05:54:57 +00:00
|
|
|
{
|
2017-08-24 13:45:28 +00:00
|
|
|
openNewTab(Dolphin::homeUrl());
|
2012-01-09 05:54:57 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::compareFiles()
|
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
const KFileItemList items = m_tabWidget->currentTabPage()->selectedItems();
|
2013-10-13 08:55:21 +00:00
|
|
|
if (items.count() != 2) {
|
|
|
|
// The action is disabled in this case, but it could have been triggered
|
|
|
|
// via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
|
|
|
|
return;
|
2007-04-09 19:12:54 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
QUrl urlA = items.at(0).url();
|
|
|
|
QUrl urlB = items.at(1).url();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QString command(QStringLiteral("kompare -c \""));
|
2014-10-21 19:18:43 +00:00
|
|
|
command.append(urlA.toDisplayString(QUrl::PreferLocalFile));
|
2007-04-01 18:36:23 +00:00
|
|
|
command.append("\" \"");
|
2014-10-21 19:18:43 +00:00
|
|
|
command.append(urlB.toDisplayString(QUrl::PreferLocalFile));
|
2007-04-01 18:36:23 +00:00
|
|
|
command.append('\"');
|
2016-03-16 21:17:37 +00:00
|
|
|
KRun::runCommand(command, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
void DolphinMainWindow::toggleShowMenuBar()
|
|
|
|
{
|
|
|
|
const bool visible = menuBar()->isVisible();
|
|
|
|
menuBar()->setVisible(!visible);
|
2011-03-26 22:22:21 +00:00
|
|
|
if (visible) {
|
2012-04-07 22:09:11 +00:00
|
|
|
createControlButton();
|
2011-03-26 22:22:21 +00:00
|
|
|
} else {
|
2012-04-07 22:09:11 +00:00
|
|
|
deleteControlButton();
|
2011-03-26 22:22:21 +00:00
|
|
|
}
|
2007-11-18 14:37:57 +00:00
|
|
|
}
|
|
|
|
|
2009-03-10 06:59:27 +00:00
|
|
|
void DolphinMainWindow::openTerminal()
|
|
|
|
{
|
2009-05-17 19:57:07 +00:00
|
|
|
QString dir(QDir::homePath());
|
|
|
|
|
|
|
|
// If the given directory is not local, it can still be the URL of an
|
|
|
|
// ioslave using UDS_LOCAL_PATH which to be converted first.
|
2015-02-26 16:40:06 +00:00
|
|
|
KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
|
|
|
|
KJobWidgets::setWindow(statJob, this);
|
|
|
|
statJob->exec();
|
|
|
|
QUrl url = statJob->mostLocalUrl();
|
2009-05-17 19:57:07 +00:00
|
|
|
|
|
|
|
//If the URL is local after the above conversion, set the directory.
|
|
|
|
if (url.isLocalFile()) {
|
|
|
|
dir = url.toLocalFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
KToolInvocation::invokeTerminal(QString(), dir);
|
2009-03-10 06:59:27 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::editSettings()
|
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!m_settingsDialog) {
|
2012-01-30 15:36:40 +00:00
|
|
|
DolphinViewContainer* container = activeViewContainer();
|
|
|
|
container->view()->writeSettings();
|
2012-02-23 16:26:51 +00:00
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl url = container->url();
|
2011-04-12 18:01:31 +00:00
|
|
|
DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
|
2011-04-12 18:01:31 +00:00
|
|
|
settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
settingsDialog->show();
|
|
|
|
m_settingsDialog = settingsDialog;
|
2009-01-13 18:06:15 +00:00
|
|
|
} else {
|
2011-04-12 18:01:31 +00:00
|
|
|
m_settingsDialog.data()->raise();
|
2009-01-13 18:06:15 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
void DolphinMainWindow::handleUrl(const QUrl& url)
|
2010-01-25 07:58:24 +00:00
|
|
|
{
|
2010-03-15 09:55:51 +00:00
|
|
|
delete m_lastHandleUrlStatJob;
|
2017-11-21 09:52:14 +00:00
|
|
|
m_lastHandleUrlStatJob = nullptr;
|
2010-03-15 09:55:51 +00:00
|
|
|
|
|
|
|
if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
|
|
|
|
activeViewContainer()->setUrl(url);
|
|
|
|
} else if (KProtocolManager::supportsListing(url)) {
|
|
|
|
// stat the URL to see if it is a dir or not
|
|
|
|
m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
|
2017-01-18 22:45:39 +00:00
|
|
|
if (m_lastHandleUrlStatJob->uiDelegate()) {
|
2014-04-06 01:32:55 +00:00
|
|
|
KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
|
2012-04-17 20:19:18 +00:00
|
|
|
}
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_lastHandleUrlStatJob, &KIO::Job::result,
|
|
|
|
this, &DolphinMainWindow::slotHandleUrlStatFinished);
|
2010-03-15 09:55:51 +00:00
|
|
|
|
|
|
|
} else {
|
2012-04-17 16:13:31 +00:00
|
|
|
new KRun(url, this); // Automatically deletes itself after being finished
|
2010-03-15 09:55:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
|
|
|
|
{
|
2017-11-21 09:52:14 +00:00
|
|
|
m_lastHandleUrlStatJob = nullptr;
|
2010-03-15 09:55:51 +00:00
|
|
|
const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl url = static_cast<KIO::StatJob*>(job)->url();
|
2010-10-27 18:31:39 +00:00
|
|
|
if (entry.isDir()) {
|
2010-01-25 07:58:24 +00:00
|
|
|
activeViewContainer()->setUrl(url);
|
|
|
|
} else {
|
2012-04-17 16:13:31 +00:00
|
|
|
new KRun(url, this); // Automatically deletes itself after being finished
|
2010-01-25 07:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
|
|
|
|
{
|
2018-05-06 20:06:16 +00:00
|
|
|
const auto actions = m_newFileMenu->menu()->actions();
|
|
|
|
for (auto menuItem : actions) {
|
|
|
|
menuItem->setEnabled(isFolderWritable);
|
|
|
|
}
|
2010-01-25 07:58:24 +00:00
|
|
|
}
|
|
|
|
|
2011-10-08 19:40:34 +00:00
|
|
|
void DolphinMainWindow::openContextMenu(const QPoint& pos,
|
|
|
|
const KFileItem& item,
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl& url,
|
2010-01-25 07:58:24 +00:00
|
|
|
const QList<QAction*>& customActions)
|
|
|
|
{
|
2015-01-29 12:45:14 +00:00
|
|
|
QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
|
2011-10-08 19:40:34 +00:00
|
|
|
contextMenu.data()->setCustomActions(customActions);
|
|
|
|
const DolphinContextMenu::Command command = contextMenu.data()->open();
|
2010-09-22 20:24:49 +00:00
|
|
|
|
|
|
|
switch (command) {
|
2014-09-09 13:31:55 +00:00
|
|
|
case DolphinContextMenu::OpenParentFolder:
|
|
|
|
changeUrl(KIO::upUrl(item.url()));
|
2018-03-26 00:06:46 +00:00
|
|
|
m_activeViewContainer->view()->markUrlsAsSelected({item.url()});
|
|
|
|
m_activeViewContainer->view()->markUrlAsCurrent(item.url());
|
2014-09-09 13:31:55 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-08 15:52:15 +00:00
|
|
|
case DolphinContextMenu::OpenParentFolderInNewWindow:
|
2018-03-26 00:06:46 +00:00
|
|
|
Dolphin::openNewWindow({item.url()}, this, Dolphin::OpenNewWindowFlag::Select);
|
2010-09-22 20:24:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DolphinContextMenu::OpenParentFolderInNewTab:
|
2014-04-06 01:32:55 +00:00
|
|
|
openNewTab(KIO::upUrl(item.url()));
|
2010-09-22 20:24:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DolphinContextMenu::None:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-01-29 12:45:14 +00:00
|
|
|
|
|
|
|
// Delete the menu, unless it has been deleted in its own nested event loop already.
|
|
|
|
if (contextMenu) {
|
|
|
|
contextMenu->deleteLater();
|
|
|
|
}
|
2010-01-25 07:58:24 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
void DolphinMainWindow::updateControlMenu()
|
2011-03-26 22:22:21 +00:00
|
|
|
{
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu* menu = qobject_cast<QMenu*>(sender());
|
2011-04-08 17:37:11 +00:00
|
|
|
Q_ASSERT(menu);
|
|
|
|
|
2016-01-10 10:18:30 +00:00
|
|
|
// All actions get cleared by QMenu::clear(). This includes the sub-menus
|
|
|
|
// because 'menu' is their parent.
|
2011-04-08 17:37:11 +00:00
|
|
|
menu->clear();
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
KActionCollection* ac = actionCollection();
|
|
|
|
|
|
|
|
// Add "Edit" actions
|
|
|
|
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
|
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) |
|
2018-03-10 19:50:29 +00:00
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
|
2016-03-16 21:17:37 +00:00
|
|
|
addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu);
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
if (added) {
|
|
|
|
menu->addSeparator();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add "View" actions
|
2011-11-06 10:58:48 +00:00
|
|
|
if (!GeneralSettings::showZoomSlider()) {
|
2011-03-26 22:22:21 +00:00
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
|
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
|
|
|
|
menu->addSeparator();
|
|
|
|
}
|
|
|
|
|
Add 'Sort By' and 'View Mode' into Dolphin file context menus
Summary: This adds the 'Sort By' and 'View Mode' options into the context menu of Dolphin within the file browser. I keep looking for these option (especially sort by) in the Context Menu, and keep forgetting to go to the menu. It also makes the order of "View Mode" and "Sort By" options consistent in the control menu
Test Plan: Made sure that the options appeared when right clicking on an empty space.
Reviewers: #dolphin, ngraham, elvisangelaccio
Reviewed By: #dolphin, ngraham, elvisangelaccio
Subscribers: question, markg, elvisangelaccio, mmustac, rkflx, ngraham, kfm-devel, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D12911
2018-06-02 14:38:01 +00:00
|
|
|
added = addActionToMenu(ac->action(QStringLiteral("sort")), menu) |
|
|
|
|
addActionToMenu(ac->action(QStringLiteral("view_mode")), menu) |
|
2016-03-16 21:17:37 +00:00
|
|
|
addActionToMenu(ac->action(QStringLiteral("additional_info")), menu) |
|
|
|
|
addActionToMenu(ac->action(QStringLiteral("show_preview")), menu) |
|
|
|
|
addActionToMenu(ac->action(QStringLiteral("show_in_groups")), menu) |
|
|
|
|
addActionToMenu(ac->action(QStringLiteral("show_hidden_files")), menu);
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
if (added) {
|
|
|
|
menu->addSeparator();
|
|
|
|
}
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
added = addActionToMenu(ac->action(QStringLiteral("split_view")), menu) |
|
2018-03-10 19:50:29 +00:00
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Redisplay)), menu) |
|
2016-03-16 21:17:37 +00:00
|
|
|
addActionToMenu(ac->action(QStringLiteral("view_properties")), menu);
|
2011-03-26 22:22:21 +00:00
|
|
|
if (added) {
|
|
|
|
menu->addSeparator();
|
|
|
|
}
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
addActionToMenu(ac->action(QStringLiteral("panels")), menu);
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu* locationBarMenu = new QMenu(i18nc("@action:inmenu", "Location Bar"), menu);
|
2016-03-16 21:17:37 +00:00
|
|
|
locationBarMenu->addAction(ac->action(QStringLiteral("editable_location")));
|
|
|
|
locationBarMenu->addAction(ac->action(QStringLiteral("replace_location")));
|
2011-03-26 22:22:21 +00:00
|
|
|
menu->addMenu(locationBarMenu);
|
|
|
|
|
|
|
|
menu->addSeparator();
|
|
|
|
|
|
|
|
// Add "Go" menu
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu* goMenu = new QMenu(i18nc("@action:inmenu", "Go"), menu);
|
2011-03-26 22:22:21 +00:00
|
|
|
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Back)));
|
|
|
|
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Forward)));
|
|
|
|
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Up)));
|
2011-03-29 16:35:50 +00:00
|
|
|
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Home)));
|
2016-03-16 21:17:37 +00:00
|
|
|
goMenu->addAction(ac->action(QStringLiteral("closed_tabs")));
|
2011-03-26 22:22:21 +00:00
|
|
|
menu->addMenu(goMenu);
|
|
|
|
|
|
|
|
// Add "Tool" menu
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu* toolsMenu = new QMenu(i18nc("@action:inmenu", "Tools"), menu);
|
2016-03-16 21:17:37 +00:00
|
|
|
toolsMenu->addAction(ac->action(QStringLiteral("show_filter_bar")));
|
|
|
|
toolsMenu->addAction(ac->action(QStringLiteral("compare_files")));
|
|
|
|
toolsMenu->addAction(ac->action(QStringLiteral("open_terminal")));
|
|
|
|
toolsMenu->addAction(ac->action(QStringLiteral("change_remote_encoding")));
|
2011-03-26 22:22:21 +00:00
|
|
|
menu->addMenu(toolsMenu);
|
|
|
|
|
2011-03-27 15:41:30 +00:00
|
|
|
// Add "Settings" menu entries
|
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::KeyBindings)), menu);
|
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ConfigureToolbars)), menu);
|
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Preferences)), menu);
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
// Add "Help" menu
|
2017-08-03 14:48:02 +00:00
|
|
|
auto helpMenu = new KHelpMenu(menu);
|
|
|
|
menu->addMenu(helpMenu->menu());
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
menu->addSeparator();
|
|
|
|
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ShowMenubar)), menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateToolBar()
|
|
|
|
{
|
|
|
|
if (!menuBar()->isVisible()) {
|
2012-04-07 22:09:11 +00:00
|
|
|
createControlButton();
|
2011-03-26 22:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
void DolphinMainWindow::slotControlButtonDeleted()
|
2011-03-26 22:22:21 +00:00
|
|
|
{
|
2017-11-21 09:52:14 +00:00
|
|
|
m_controlButton = nullptr;
|
2011-03-26 22:22:21 +00:00
|
|
|
m_updateToolBarTimer->start();
|
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
void DolphinMainWindow::slotPlaceActivated(const QUrl& url)
|
2013-10-26 07:24:04 +00:00
|
|
|
{
|
|
|
|
DolphinViewContainer* view = activeViewContainer();
|
|
|
|
|
|
|
|
if (view->url() == url) {
|
|
|
|
// We can end up here if the user clicked a device in the Places Panel
|
|
|
|
// which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
|
|
|
|
reloadView();
|
|
|
|
} else {
|
|
|
|
changeUrl(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-22 12:01:49 +00:00
|
|
|
void DolphinMainWindow::closedTabsCountChanged(unsigned int count)
|
|
|
|
{
|
2016-03-16 21:17:37 +00:00
|
|
|
actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count > 0);
|
2014-07-22 12:01:49 +00:00
|
|
|
}
|
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
|
2007-06-12 21:45:22 +00:00
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
DolphinViewContainer* oldViewContainer = m_activeViewContainer;
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(viewContainer);
|
2007-06-12 21:45:22 +00:00
|
|
|
|
2008-02-11 12:34:48 +00:00
|
|
|
m_activeViewContainer = viewContainer;
|
2014-08-10 16:52:06 +00:00
|
|
|
|
|
|
|
if (oldViewContainer) {
|
|
|
|
// Disconnect all signals between the old view container (container,
|
|
|
|
// view and url navigator) and main window.
|
|
|
|
oldViewContainer->disconnect(this);
|
|
|
|
oldViewContainer->view()->disconnect(this);
|
|
|
|
oldViewContainer->urlNavigator()->disconnect(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
connectViewSignals(viewContainer);
|
|
|
|
|
2008-03-12 16:58:11 +00:00
|
|
|
m_actionHandler->setCurrentView(viewContainer->view());
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
updateHistory();
|
|
|
|
updateEditActions();
|
2014-04-30 07:34:32 +00:00
|
|
|
updatePasteAction();
|
2007-06-12 21:45:22 +00:00
|
|
|
updateViewActions();
|
|
|
|
updateGoActions();
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl url = viewContainer->url();
|
2007-06-13 17:08:39 +00:00
|
|
|
emit urlChanged(url);
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-10 16:52:06 +00:00
|
|
|
void DolphinMainWindow::tabCountChanged(int count)
|
|
|
|
{
|
|
|
|
const bool enableTabActions = (count > 1);
|
2018-03-10 19:50:29 +00:00
|
|
|
actionCollection()->action(KStandardAction::name(KStandardAction::Close))->setEnabled(enableTabActions);
|
2016-03-16 21:17:37 +00:00
|
|
|
actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
|
|
|
|
actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
|
2014-08-10 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
|
2014-08-13 20:06:28 +00:00
|
|
|
{
|
2017-08-29 15:15:24 +00:00
|
|
|
QString schemePrefix;
|
2014-08-13 20:06:28 +00:00
|
|
|
if (!url.isLocalFile()) {
|
2017-08-29 15:15:24 +00:00
|
|
|
schemePrefix.append(url.scheme() + " - ");
|
2014-10-21 19:18:43 +00:00
|
|
|
if (!url.host().isEmpty()) {
|
2017-08-29 15:15:24 +00:00
|
|
|
schemePrefix.append(url.host() + " - ");
|
2014-08-13 20:06:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-14 12:26:14 +00:00
|
|
|
if (GeneralSettings::showFullPathInTitlebar()) {
|
|
|
|
const QString path = url.adjusted(QUrl::StripTrailingSlash).path();
|
2017-08-29 15:15:24 +00:00
|
|
|
setWindowTitle(schemePrefix + path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-19 08:57:24 +00:00
|
|
|
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
|
|
|
const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
|
2017-08-29 15:15:24 +00:00
|
|
|
|
|
|
|
if (!matchedPlaces.isEmpty()) {
|
2018-03-19 08:57:24 +00:00
|
|
|
setWindowTitle(placesModel->text(matchedPlaces.first()));
|
2017-08-29 15:15:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName();
|
|
|
|
if (fileName.isEmpty()) {
|
|
|
|
fileName = '/';
|
2014-12-01 12:01:39 +00:00
|
|
|
}
|
|
|
|
|
2017-12-03 14:58:02 +00:00
|
|
|
if (m_activeViewContainer->isSearchModeEnabled()) {
|
|
|
|
if(m_activeViewContainer->currentSearchText().isEmpty()){
|
2017-12-13 05:52:21 +00:00
|
|
|
setWindowTitle(i18n("Search"));
|
2017-12-03 14:58:02 +00:00
|
|
|
} else {
|
|
|
|
const auto searchText = i18n("Search for %1", m_activeViewContainer->currentSearchText());
|
|
|
|
setWindowTitle(searchText);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-29 15:15:24 +00:00
|
|
|
setWindowTitle(schemePrefix + fileName);
|
2014-08-13 20:06:28 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 21:17:51 +00:00
|
|
|
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
|
|
|
|
{
|
|
|
|
if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
|
|
|
|
m_tearDownFromPlacesRequested = true;
|
|
|
|
m_terminalPanel->goHome();
|
|
|
|
// m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
|
|
|
|
} else {
|
|
|
|
m_placesPanel->proceedWithTearDown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
|
|
|
|
{
|
|
|
|
if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
|
|
|
|
m_tearDownFromPlacesRequested = false;
|
|
|
|
m_terminalPanel->goHome();
|
|
|
|
}
|
2017-10-14 10:49:29 +00:00
|
|
|
}
|
2017-10-12 21:17:51 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::setupActions()
|
|
|
|
{
|
|
|
|
// setup 'File' menu
|
2013-08-16 18:22:33 +00:00
|
|
|
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
2014-04-06 01:32:55 +00:00
|
|
|
QMenu* menu = m_newFileMenu->menu();
|
2008-03-18 22:38:52 +00:00
|
|
|
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
|
2016-03-16 21:17:37 +00:00
|
|
|
menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
|
2013-01-14 09:42:03 +00:00
|
|
|
m_newFileMenu->setDelayed(false);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(menu, &QMenu::aboutToShow,
|
|
|
|
this, &DolphinMainWindow::updateNewMenu);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
|
2007-06-30 20:10:50 +00:00
|
|
|
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
|
|
|
|
newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
|
2008-04-12 15:09:46 +00:00
|
|
|
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
|
2018-03-10 19:50:29 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, QKeySequence::AddTab});
|
2014-08-22 21:17:02 +00:00
|
|
|
connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
|
2008-04-12 15:09:46 +00:00
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
QAction* closeTab = KStandardAction::close(
|
|
|
|
m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab), actionCollection());
|
2009-01-11 16:28:42 +00:00
|
|
|
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
|
2008-08-12 18:59:25 +00:00
|
|
|
closeTab->setEnabled(false);
|
2008-04-16 20:03:05 +00:00
|
|
|
|
2017-08-24 15:32:06 +00:00
|
|
|
KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
// setup 'Edit' menu
|
|
|
|
KStandardAction::undo(this,
|
2017-08-24 15:32:06 +00:00
|
|
|
&DolphinMainWindow::undo,
|
2007-04-01 18:36:23 +00:00
|
|
|
actionCollection());
|
|
|
|
|
2017-03-10 18:31:33 +00:00
|
|
|
|
2017-08-24 15:32:06 +00:00
|
|
|
KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection());
|
|
|
|
KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection());
|
|
|
|
QAction* paste = KStandardAction::paste(this, &DolphinMainWindow::paste, actionCollection());
|
2009-10-11 17:43:30 +00:00
|
|
|
// The text of the paste-action is modified dynamically by Dolphin
|
|
|
|
// (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
|
|
|
|
// due to the long text, the text "Paste" is used:
|
|
|
|
paste->setIconText(i18nc("@action:inmenu Edit", "Paste"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2017-08-24 15:32:06 +00:00
|
|
|
KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
|
2010-07-24 16:37:07 +00:00
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
|
2007-06-30 20:10:50 +00:00
|
|
|
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
|
2018-02-14 14:40:36 +00:00
|
|
|
invertSelection->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
|
2018-03-03 08:46:14 +00:00
|
|
|
actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL + Qt::SHIFT + Qt::Key_A);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
// setup 'View' menu
|
2008-02-13 20:52:21 +00:00
|
|
|
// (note that most of it is set up in DolphinViewActionHandler)
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* split = actionCollection()->addAction(QStringLiteral("split_view"));
|
2014-09-14 20:49:25 +00:00
|
|
|
actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-09-26 16:55:42 +00:00
|
|
|
QAction* stashSplit = actionCollection()->addAction(QStringLiteral("split_stash"));
|
2018-03-03 08:46:14 +00:00
|
|
|
actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL + Qt::Key_S);
|
2016-09-26 16:55:42 +00:00
|
|
|
stashSplit->setText(i18nc("@action:intoolbar Stash", "Stash"));
|
|
|
|
stashSplit->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
|
2017-11-08 14:06:46 +00:00
|
|
|
stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
|
2017-02-02 16:16:54 +00:00
|
|
|
stashSplit->setCheckable(false);
|
2017-02-13 10:09:01 +00:00
|
|
|
stashSplit->setVisible(KProtocolInfo::isKnownProtocol("stash"));
|
2016-09-26 16:55:42 +00:00
|
|
|
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
|
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* stop = actionCollection()->addAction(QStringLiteral("stop"));
|
2007-06-30 20:10:50 +00:00
|
|
|
stop->setText(i18nc("@action:inmenu View", "Stop"));
|
2009-11-06 18:02:55 +00:00
|
|
|
stop->setToolTip(i18nc("@info", "Stop loading"));
|
2016-03-16 21:17:37 +00:00
|
|
|
stop->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
KToggleAction* editableLocation = actionCollection()->add<KToggleAction>(QStringLiteral("editable_location"));
|
2011-03-26 22:22:21 +00:00
|
|
|
editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
|
2014-09-14 20:49:25 +00:00
|
|
|
actionCollection()->setDefaultShortcut(editableLocation, Qt::Key_F6);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(editableLocation, &KToggleAction::triggered, this, &DolphinMainWindow::toggleEditLocation);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* replaceLocation = actionCollection()->addAction(QStringLiteral("replace_location"));
|
2008-10-25 09:41:39 +00:00
|
|
|
replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
|
2018-03-03 08:46:14 +00:00
|
|
|
actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL + Qt::Key_L);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
// setup 'Go' menu
|
2017-08-24 15:32:06 +00:00
|
|
|
QAction* backAction = KStandardAction::back(this, &DolphinMainWindow::goBack, actionCollection());
|
2014-04-06 01:32:55 +00:00
|
|
|
auto backShortcuts = backAction->shortcuts();
|
|
|
|
backShortcuts.append(QKeySequence(Qt::Key_Backspace));
|
2014-09-14 20:45:10 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(backAction, backShortcuts);
|
2007-09-09 19:02:22 +00:00
|
|
|
|
2014-06-19 20:04:36 +00:00
|
|
|
DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this);
|
2016-03-16 21:17:37 +00:00
|
|
|
actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu);
|
|
|
|
connect(m_tabWidget, &DolphinTabWidget::rememberClosedTab,
|
|
|
|
recentTabsMenu, &DolphinRecentTabsMenu::rememberClosedTab);
|
|
|
|
connect(recentTabsMenu, &DolphinRecentTabsMenu::restoreClosedTab,
|
|
|
|
m_tabWidget, &DolphinTabWidget::restoreClosedTab);
|
|
|
|
connect(recentTabsMenu, &DolphinRecentTabsMenu::closedTabsCountChanged,
|
|
|
|
this, &DolphinMainWindow::closedTabsCountChanged);
|
|
|
|
|
|
|
|
QAction* undoCloseTab = actionCollection()->addAction(QStringLiteral("undo_close_tab"));
|
2014-07-22 12:01:49 +00:00
|
|
|
undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
|
2018-03-03 08:46:14 +00:00
|
|
|
actionCollection()->setDefaultShortcut(undoCloseTab, Qt::CTRL + Qt::SHIFT + Qt::Key_T);
|
2016-03-16 21:17:37 +00:00
|
|
|
undoCloseTab->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
|
2014-07-22 12:01:49 +00:00
|
|
|
undoCloseTab->setEnabled(false);
|
2016-03-16 21:17:37 +00:00
|
|
|
connect(undoCloseTab, &QAction::triggered, recentTabsMenu, &DolphinRecentTabsMenu::undoCloseTab);
|
2009-03-01 01:38:20 +00:00
|
|
|
|
2015-01-28 14:04:32 +00:00
|
|
|
auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
|
|
|
|
undoAction->setEnabled(false); // undo should be disabled by default
|
|
|
|
|
2017-08-24 15:32:06 +00:00
|
|
|
KStandardAction::forward(this, &DolphinMainWindow::goForward, actionCollection());
|
|
|
|
KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection());
|
|
|
|
KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection());
|
2011-03-29 16:35:50 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
// setup 'Tools' menu
|
2017-03-11 17:33:41 +00:00
|
|
|
QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
|
2007-06-30 20:10:50 +00:00
|
|
|
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
|
2016-03-16 21:17:37 +00:00
|
|
|
showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
|
2018-03-02 07:52:47 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash});
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* compareFiles = actionCollection()->addAction(QStringLiteral("compare_files"));
|
2007-06-30 20:10:50 +00:00
|
|
|
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
|
2016-03-16 21:17:37 +00:00
|
|
|
compareFiles->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
|
2007-04-01 18:36:23 +00:00
|
|
|
compareFiles->setEnabled(false);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2018-01-21 11:15:07 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2016-05-26 12:51:23 +00:00
|
|
|
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
|
2016-05-18 01:06:49 +00:00
|
|
|
QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
|
|
|
|
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
|
|
|
|
openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
|
2018-03-03 08:46:14 +00:00
|
|
|
actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
|
2016-05-18 01:06:49 +00:00
|
|
|
connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
|
|
|
|
}
|
2018-01-21 11:15:07 +00:00
|
|
|
#endif
|
2009-03-10 06:59:27 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
// setup 'Settings' menu
|
2017-11-21 09:52:14 +00:00
|
|
|
KToggleAction* showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822
|
|
|
|
this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
|
2018-02-03 19:30:37 +00:00
|
|
|
KStandardAction::preferences(this, &DolphinMainWindow::editSettings, actionCollection());
|
2008-10-25 09:00:28 +00:00
|
|
|
|
|
|
|
// not in menu actions
|
2014-11-03 23:00:04 +00:00
|
|
|
QList<QKeySequence> nextTabKeys = KStandardShortcut::tabNext();
|
2018-03-03 08:46:14 +00:00
|
|
|
nextTabKeys.append(QKeySequence(Qt::CTRL + Qt::Key_Tab));
|
2010-03-22 18:48:12 +00:00
|
|
|
|
2014-11-03 23:00:04 +00:00
|
|
|
QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
|
2018-03-03 08:46:14 +00:00
|
|
|
prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
|
2010-03-22 18:48:12 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab"));
|
2014-04-29 19:54:33 +00:00
|
|
|
activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
|
2008-10-25 09:21:20 +00:00
|
|
|
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
|
2014-04-26 10:28:42 +00:00
|
|
|
activateNextTab->setEnabled(false);
|
2014-08-22 21:17:02 +00:00
|
|
|
connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab);
|
2016-10-12 11:31:35 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(activateNextTab, nextTabKeys);
|
2008-10-25 09:00:28 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* activatePrevTab = actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
|
2014-04-29 19:54:33 +00:00
|
|
|
activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab"));
|
2008-10-25 09:21:20 +00:00
|
|
|
activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
|
2014-04-26 10:28:42 +00:00
|
|
|
activatePrevTab->setEnabled(false);
|
2014-08-22 21:17:02 +00:00
|
|
|
connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab);
|
2016-10-12 11:31:35 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys);
|
2008-10-25 10:32:55 +00:00
|
|
|
|
|
|
|
// for context menu
|
2018-03-18 10:55:24 +00:00
|
|
|
QAction* showTarget = actionCollection()->addAction(QStringLiteral("show_target"));
|
|
|
|
showTarget->setText(i18nc("@action:inmenu", "Show Target"));
|
|
|
|
showTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
|
|
|
|
showTarget->setEnabled(false);
|
|
|
|
connect(showTarget, &QAction::triggered, this, &DolphinMainWindow::showTarget);
|
2018-03-03 13:36:44 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* openInNewTab = actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
|
2008-10-25 10:32:55 +00:00
|
|
|
openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
|
2016-03-16 21:17:37 +00:00
|
|
|
openInNewTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
|
2013-05-22 19:47:14 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* openInNewTabs = actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
|
2013-05-22 19:47:14 +00:00
|
|
|
openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs"));
|
2016-03-16 21:17:37 +00:00
|
|
|
openInNewTabs->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(openInNewTabs, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* openInNewWindow = actionCollection()->addAction(QStringLiteral("open_in_new_window"));
|
2008-10-25 10:32:55 +00:00
|
|
|
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
|
2016-03-16 21:17:37 +00:00
|
|
|
openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::setupDockWidgets()
|
|
|
|
{
|
2011-11-06 10:58:48 +00:00
|
|
|
const bool lock = GeneralSettings::lockPanels();
|
2010-12-31 10:59:46 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>(QStringLiteral("lock_panels"));
|
2010-12-31 10:59:46 +00:00
|
|
|
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
|
2016-03-16 21:17:37 +00:00
|
|
|
lockLayoutAction->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
|
2010-12-31 10:59:46 +00:00
|
|
|
lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
|
2016-03-16 21:17:37 +00:00
|
|
|
lockLayoutAction->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
|
2010-12-31 10:59:46 +00:00
|
|
|
lockLayoutAction->setActive(lock);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState);
|
2010-12-31 10:59:46 +00:00
|
|
|
|
|
|
|
// Setup "Information"
|
|
|
|
DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
|
|
|
|
infoDock->setLocked(lock);
|
2016-03-16 21:17:37 +00:00
|
|
|
infoDock->setObjectName(QStringLiteral("infoDock"));
|
2007-04-01 18:36:23 +00:00
|
|
|
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
2018-08-13 21:36:35 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_BALOO
|
2014-04-10 14:53:41 +00:00
|
|
|
InformationPanel* infoPanel = new InformationPanel(infoDock);
|
2014-11-10 07:45:38 +00:00
|
|
|
infoPanel->setCustomContextMenuActions({lockLayoutAction});
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
|
2009-01-14 20:14:36 +00:00
|
|
|
infoDock->setWidget(infoPanel);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-05-03 17:46:34 +00:00
|
|
|
QAction* infoAction = infoDock->toggleViewAction();
|
2016-03-16 21:17:37 +00:00
|
|
|
createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoAction, QStringLiteral("show_information_panel"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, infoDock);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(this, &DolphinMainWindow::urlChanged,
|
|
|
|
infoPanel, &InformationPanel::setUrl);
|
|
|
|
connect(this, &DolphinMainWindow::selectionChanged,
|
|
|
|
infoPanel, &InformationPanel::setSelection);
|
|
|
|
connect(this, &DolphinMainWindow::requestItemInfo,
|
|
|
|
infoPanel, &InformationPanel::requestDelayedItemInfo);
|
2018-08-13 21:36:35 +00:00
|
|
|
#endif
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Setup "Folders"
|
|
|
|
DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
|
|
|
|
foldersDock->setLocked(lock);
|
2016-03-16 21:17:37 +00:00
|
|
|
foldersDock->setObjectName(QStringLiteral("foldersDock"));
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
|
|
|
FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
|
2014-11-10 07:45:38 +00:00
|
|
|
foldersPanel->setCustomContextMenuActions({lockLayoutAction});
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersDock->setWidget(foldersPanel);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-05-03 17:46:34 +00:00
|
|
|
QAction* foldersAction = foldersDock->toggleViewAction();
|
2016-03-16 21:17:37 +00:00
|
|
|
createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersAction, QStringLiteral("show_folders_panel"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2009-01-14 20:14:36 +00:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(this, &DolphinMainWindow::urlChanged,
|
|
|
|
foldersPanel, &FoldersPanel::setUrl);
|
|
|
|
connect(foldersPanel, &FoldersPanel::folderActivated,
|
|
|
|
this, &DolphinMainWindow::changeUrl);
|
2014-09-15 16:17:30 +00:00
|
|
|
connect(foldersPanel, &FoldersPanel::folderMiddleClicked,
|
|
|
|
this, &DolphinMainWindow::openNewTab);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(foldersPanel, &FoldersPanel::errorMessage,
|
2015-01-24 23:14:37 +00:00
|
|
|
this, &DolphinMainWindow::showErrorMessage);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Setup "Terminal"
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2016-05-26 12:51:23 +00:00
|
|
|
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
|
2016-05-18 01:06:49 +00:00
|
|
|
DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
|
|
|
|
terminalDock->setLocked(lock);
|
|
|
|
terminalDock->setObjectName(QStringLiteral("terminalDock"));
|
2017-10-12 21:17:51 +00:00
|
|
|
m_terminalPanel = new TerminalPanel(terminalDock);
|
|
|
|
m_terminalPanel->setCustomContextMenuActions({lockLayoutAction});
|
|
|
|
terminalDock->setWidget(m_terminalPanel);
|
2016-05-18 01:06:49 +00:00
|
|
|
|
2017-10-12 21:17:51 +00:00
|
|
|
connect(m_terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
|
|
|
|
connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
|
2016-05-18 01:06:49 +00:00
|
|
|
connect(terminalDock, &DolphinDockWidget::visibilityChanged,
|
2017-10-12 21:17:51 +00:00
|
|
|
m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
|
2018-01-18 17:49:54 +00:00
|
|
|
connect(terminalDock, &DolphinDockWidget::visibilityChanged,
|
|
|
|
this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
|
2016-05-18 01:06:49 +00:00
|
|
|
|
|
|
|
QAction* terminalAction = terminalDock->toggleViewAction();
|
|
|
|
createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
|
|
|
|
|
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
|
|
|
|
connect(this, &DolphinMainWindow::urlChanged,
|
2017-10-12 21:17:51 +00:00
|
|
|
m_terminalPanel, &TerminalPanel::setUrl);
|
2016-05-18 01:06:49 +00:00
|
|
|
|
|
|
|
if (GeneralSettings::version() < 200) {
|
|
|
|
terminalDock->hide();
|
|
|
|
}
|
|
|
|
}
|
2008-03-10 17:33:30 +00:00
|
|
|
#endif
|
2008-03-12 16:58:11 +00:00
|
|
|
|
2011-11-06 10:58:48 +00:00
|
|
|
if (GeneralSettings::version() < 200) {
|
2010-06-16 21:13:41 +00:00
|
|
|
infoDock->hide();
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersDock->hide();
|
2011-08-14 13:30:29 +00:00
|
|
|
}
|
2007-04-01 22:28:03 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Setup "Places"
|
|
|
|
DolphinDockWidget* placesDock = new DolphinDockWidget(i18nc("@title:window", "Places"));
|
|
|
|
placesDock->setLocked(lock);
|
2016-03-16 21:17:37 +00:00
|
|
|
placesDock->setObjectName(QStringLiteral("placesDock"));
|
2007-04-01 22:28:03 +00:00
|
|
|
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
2008-01-30 22:22:46 +00:00
|
|
|
|
2017-10-12 21:17:51 +00:00
|
|
|
m_placesPanel = new PlacesPanel(placesDock);
|
|
|
|
m_placesPanel->setCustomContextMenuActions({lockLayoutAction});
|
|
|
|
placesDock->setWidget(m_placesPanel);
|
2007-04-14 16:50:51 +00:00
|
|
|
|
2017-10-12 21:17:51 +00:00
|
|
|
QAction *placesAction = placesDock->toggleViewAction();
|
2016-03-16 21:17:37 +00:00
|
|
|
createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel"));
|
2007-04-14 16:50:51 +00:00
|
|
|
|
2007-04-01 22:28:03 +00:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
|
2017-10-12 21:17:51 +00:00
|
|
|
connect(m_placesPanel, &PlacesPanel::placeActivated,
|
2014-04-10 14:53:41 +00:00
|
|
|
this, &DolphinMainWindow::slotPlaceActivated);
|
2017-10-12 21:17:51 +00:00
|
|
|
connect(m_placesPanel, &PlacesPanel::placeMiddleClicked,
|
2016-03-16 21:17:37 +00:00
|
|
|
this, &DolphinMainWindow::openNewTab);
|
2017-10-12 21:17:51 +00:00
|
|
|
connect(m_placesPanel, &PlacesPanel::errorMessage,
|
2015-01-24 23:14:37 +00:00
|
|
|
this, &DolphinMainWindow::showErrorMessage);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(this, &DolphinMainWindow::urlChanged,
|
2017-10-12 21:17:51 +00:00
|
|
|
m_placesPanel, &PlacesPanel::setUrl);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(placesDock, &DolphinDockWidget::visibilityChanged,
|
2014-08-22 21:17:02 +00:00
|
|
|
m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(this, &DolphinMainWindow::settingsChanged,
|
2017-10-12 21:17:51 +00:00
|
|
|
m_placesPanel, &PlacesPanel::readSettings);
|
|
|
|
connect(m_placesPanel, &PlacesPanel::storageTearDownRequested,
|
|
|
|
this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested);
|
|
|
|
connect(m_placesPanel, &PlacesPanel::storageTearDownExternallyRequested,
|
|
|
|
this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
|
|
|
|
m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
|
2014-08-10 16:52:06 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Add actions into the "Panels" menu
|
2010-05-28 20:12:33 +00:00
|
|
|
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
|
2016-03-16 21:17:37 +00:00
|
|
|
actionCollection()->addAction(QStringLiteral("panels"), panelsMenu);
|
2010-05-03 15:40:24 +00:00
|
|
|
panelsMenu->setDelayed(false);
|
2011-11-21 10:04:45 +00:00
|
|
|
const KActionCollection* ac = actionCollection();
|
2016-03-16 21:17:37 +00:00
|
|
|
panelsMenu->addAction(ac->action(QStringLiteral("show_places_panel")));
|
|
|
|
panelsMenu->addAction(ac->action(QStringLiteral("show_information_panel")));
|
|
|
|
panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel")));
|
|
|
|
panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel")));
|
2010-12-31 10:59:46 +00:00
|
|
|
panelsMenu->addSeparator();
|
|
|
|
panelsMenu->addAction(lockLayoutAction);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateEditActions()
|
|
|
|
{
|
2007-10-02 19:03:03 +00:00
|
|
|
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
if (list.isEmpty()) {
|
2016-03-16 21:17:37 +00:00
|
|
|
stateChanged(QStringLiteral("has_no_selection"));
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2016-03-16 21:17:37 +00:00
|
|
|
stateChanged(QStringLiteral("has_selection"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-06-01 18:44:35 +00:00
|
|
|
KActionCollection* col = actionCollection();
|
2018-03-03 13:36:44 +00:00
|
|
|
QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile));
|
|
|
|
QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
|
|
|
|
QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
|
|
|
|
QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
|
2018-03-18 10:55:24 +00:00
|
|
|
QAction* showTarget = col->action(QStringLiteral("show_target"));
|
2008-06-01 18:44:35 +00:00
|
|
|
|
2009-04-01 23:34:33 +00:00
|
|
|
KFileItemListProperties capabilities(list);
|
2008-04-18 20:31:31 +00:00
|
|
|
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
|
2008-06-01 18:44:35 +00:00
|
|
|
|
|
|
|
renameAction->setEnabled(capabilities.supportsMoving());
|
|
|
|
moveToTrashAction->setEnabled(enableMoveToTrash);
|
|
|
|
deleteAction->setEnabled(capabilities.supportsDeleting());
|
2008-06-05 22:25:07 +00:00
|
|
|
deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
|
2008-06-01 18:44:35 +00:00
|
|
|
cutAction->setEnabled(capabilities.supportsMoving());
|
2018-03-18 10:55:24 +00:00
|
|
|
showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateViewActions()
|
|
|
|
{
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler->updateViewActions();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
|
2007-06-07 21:10:48 +00:00
|
|
|
showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-08-12 17:48:29 +00:00
|
|
|
updateSplitAction();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* editableLocactionAction = actionCollection()->action(QStringLiteral("editable_location"));
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateGoActions()
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl currentUrl = m_activeViewContainer->url();
|
|
|
|
goUpAction->setEnabled(KIO::upUrl(currentUrl) != currentUrl);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
void DolphinMainWindow::createControlButton()
|
2011-03-26 22:22:21 +00:00
|
|
|
{
|
2012-04-07 22:09:11 +00:00
|
|
|
if (m_controlButton) {
|
2011-03-26 22:22:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-04-07 22:09:11 +00:00
|
|
|
Q_ASSERT(!m_controlButton);
|
2011-03-26 22:22:21 +00:00
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
m_controlButton = new QToolButton(this);
|
2016-03-16 21:17:37 +00:00
|
|
|
m_controlButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
|
2012-04-07 22:09:11 +00:00
|
|
|
m_controlButton->setText(i18nc("@action", "Control"));
|
|
|
|
m_controlButton->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
|
2011-03-26 22:22:21 +00:00
|
|
|
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu* controlMenu = new QMenu(m_controlButton);
|
|
|
|
connect(controlMenu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu);
|
2011-04-08 17:37:11 +00:00
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
m_controlButton->setMenu(controlMenu);
|
2011-03-26 22:22:21 +00:00
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
toolBar()->addWidget(m_controlButton);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(toolBar(), &KToolBar::iconSizeChanged,
|
|
|
|
m_controlButton, &QToolButton::setIconSize);
|
|
|
|
connect(toolBar(), &KToolBar::toolButtonStyleChanged,
|
|
|
|
m_controlButton, &QToolButton::setToolButtonStyle);
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
// The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
|
|
|
|
// gets edited. In this case we must add them again. The adding is done asynchronously by
|
|
|
|
// m_updateToolBarTimer.
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted);
|
2011-03-26 22:22:21 +00:00
|
|
|
m_updateToolBarTimer = new QTimer(this);
|
|
|
|
m_updateToolBarTimer->setInterval(500);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar);
|
2011-03-26 22:22:21 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 22:09:11 +00:00
|
|
|
void DolphinMainWindow::deleteControlButton()
|
2011-03-26 22:22:21 +00:00
|
|
|
{
|
2012-04-07 22:09:11 +00:00
|
|
|
delete m_controlButton;
|
2017-11-21 09:52:14 +00:00
|
|
|
m_controlButton = nullptr;
|
2011-03-26 22:22:21 +00:00
|
|
|
|
|
|
|
delete m_updateToolBarTimer;
|
2017-11-21 09:52:14 +00:00
|
|
|
m_updateToolBarTimer = nullptr;
|
2011-03-26 22:22:21 +00:00
|
|
|
}
|
|
|
|
|
2014-10-10 21:36:36 +00:00
|
|
|
bool DolphinMainWindow::addActionToMenu(QAction* action, QMenu* menu)
|
2011-03-26 22:22:21 +00:00
|
|
|
{
|
|
|
|
Q_ASSERT(action);
|
|
|
|
Q_ASSERT(menu);
|
|
|
|
|
|
|
|
const KToolBar* toolBarWidget = toolBar();
|
|
|
|
foreach (const QWidget* widget, action->associatedWidgets()) {
|
|
|
|
if (widget == toolBarWidget) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu->addAction(action);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-15 18:52:27 +00:00
|
|
|
void DolphinMainWindow::refreshViews()
|
|
|
|
{
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget->refreshViews();
|
2011-04-15 18:52:27 +00:00
|
|
|
|
2011-11-06 10:58:48 +00:00
|
|
|
if (GeneralSettings::modifiedStartupSettings()) {
|
2011-04-15 18:52:27 +00:00
|
|
|
// The startup settings have been changed by the user (see bug #254947).
|
|
|
|
// Synchronize the split-view setting with the active view:
|
2011-11-06 10:58:48 +00:00
|
|
|
const bool splitView = GeneralSettings::splitView();
|
2014-08-10 16:52:06 +00:00
|
|
|
m_tabWidget->currentTabPage()->setSplitViewEnabled(splitView);
|
2014-07-02 13:30:37 +00:00
|
|
|
updateSplitAction();
|
2017-01-14 12:26:14 +00:00
|
|
|
setUrlAsCaption(activeViewContainer()->url());
|
2011-04-15 18:52:27 +00:00
|
|
|
}
|
2012-09-11 18:09:01 +00:00
|
|
|
|
|
|
|
emit settingsChanged();
|
2011-04-15 18:52:27 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::clearStatusBar()
|
|
|
|
{
|
2012-04-12 21:57:51 +00:00
|
|
|
m_activeViewContainer->statusBar()->resetToDefaultText();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(container, &DolphinViewContainer::showFilterBarChanged,
|
|
|
|
this, &DolphinMainWindow::updateFilterBarAction);
|
|
|
|
connect(container, &DolphinViewContainer::writeStateChanged,
|
|
|
|
this, &DolphinMainWindow::slotWriteStateChanged);
|
2011-04-20 18:03:51 +00:00
|
|
|
|
2014-07-02 13:30:37 +00:00
|
|
|
const DolphinView* view = container->view();
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(view, &DolphinView::selectionChanged,
|
|
|
|
this, &DolphinMainWindow::slotSelectionChanged);
|
|
|
|
connect(view, &DolphinView::requestItemInfo,
|
2015-01-24 23:42:43 +00:00
|
|
|
this, &DolphinMainWindow::requestItemInfo);
|
2014-09-15 16:17:30 +00:00
|
|
|
connect(view, &DolphinView::tabRequested,
|
|
|
|
this, &DolphinMainWindow::openNewTab);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(view, &DolphinView::requestContextMenu,
|
|
|
|
this, &DolphinMainWindow::openContextMenu);
|
|
|
|
connect(view, &DolphinView::directoryLoadingStarted,
|
|
|
|
this, &DolphinMainWindow::enableStopAction);
|
|
|
|
connect(view, &DolphinView::directoryLoadingCompleted,
|
|
|
|
this, &DolphinMainWindow::disableStopAction);
|
2014-11-02 14:34:30 +00:00
|
|
|
connect(view, &DolphinView::directoryLoadingCompleted,
|
|
|
|
this, &DolphinMainWindow::slotDirectoryLoadingCompleted);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(view, &DolphinView::goBackRequested,
|
|
|
|
this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goBack));
|
|
|
|
connect(view, &DolphinView::goForwardRequested,
|
|
|
|
this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goForward));
|
2017-04-29 16:47:13 +00:00
|
|
|
connect(view, &DolphinView::urlActivated,
|
|
|
|
this, &DolphinMainWindow::handleUrl);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrlNavigator* navigator = container->urlNavigator();
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(navigator, &KUrlNavigator::urlChanged,
|
|
|
|
this, &DolphinMainWindow::changeUrl);
|
|
|
|
connect(navigator, &KUrlNavigator::historyChanged,
|
|
|
|
this, &DolphinMainWindow::updateHistory);
|
|
|
|
connect(navigator, &KUrlNavigator::editableStateChanged,
|
|
|
|
this, &DolphinMainWindow::slotEditableStateChanged);
|
2014-09-15 16:17:30 +00:00
|
|
|
connect(navigator, &KUrlNavigator::tabRequested,
|
|
|
|
this, &DolphinMainWindow::openNewTab);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-04-12 17:37:53 +00:00
|
|
|
|
2007-08-12 17:48:29 +00:00
|
|
|
void DolphinMainWindow::updateSplitAction()
|
2007-06-03 14:07:45 +00:00
|
|
|
{
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* splitAction = actionCollection()->action(QStringLiteral("split_view"));
|
2014-08-10 16:52:06 +00:00
|
|
|
const DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
|
2014-07-02 13:30:37 +00:00
|
|
|
if (tabPage->splitViewEnabled()) {
|
|
|
|
if (tabPage->primaryViewActive()) {
|
2007-08-25 09:54:31 +00:00
|
|
|
splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
|
2009-11-06 18:02:55 +00:00
|
|
|
splitAction->setToolTip(i18nc("@info", "Close left view"));
|
2016-03-16 21:17:37 +00:00
|
|
|
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
|
2014-07-02 13:30:37 +00:00
|
|
|
} else {
|
|
|
|
splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
|
|
|
|
splitAction->setToolTip(i18nc("@info", "Close right view"));
|
2016-03-16 21:17:37 +00:00
|
|
|
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
|
2007-08-12 17:48:29 +00:00
|
|
|
}
|
2007-06-03 14:07:45 +00:00
|
|
|
} else {
|
2007-06-30 20:10:50 +00:00
|
|
|
splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
|
2009-11-06 18:02:55 +00:00
|
|
|
splitAction->setToolTip(i18nc("@info", "Split view"));
|
2016-03-16 21:17:37 +00:00
|
|
|
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
|
2007-06-03 14:07:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-28 18:42:51 +00:00
|
|
|
bool DolphinMainWindow::isKompareInstalled() const
|
|
|
|
{
|
|
|
|
static bool initialized = false;
|
|
|
|
static bool installed = false;
|
|
|
|
if (!initialized) {
|
|
|
|
// TODO: maybe replace this approach later by using a menu
|
|
|
|
// plugin like kdiff3plugin.cpp
|
2014-10-01 10:34:49 +00:00
|
|
|
installed = !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
|
2008-06-28 18:42:51 +00:00
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
return installed;
|
|
|
|
}
|
|
|
|
|
2014-04-10 22:48:52 +00:00
|
|
|
void DolphinMainWindow::createPanelAction(const QIcon& icon,
|
2011-10-10 20:05:32 +00:00
|
|
|
const QKeySequence& shortcut,
|
|
|
|
QAction* dockAction,
|
|
|
|
const QString& actionName)
|
2010-12-19 12:48:24 +00:00
|
|
|
{
|
2014-04-06 01:32:55 +00:00
|
|
|
QAction* panelAction = actionCollection()->addAction(actionName);
|
2011-11-21 10:04:45 +00:00
|
|
|
panelAction->setCheckable(true);
|
|
|
|
panelAction->setChecked(dockAction->isChecked());
|
2011-10-10 20:05:32 +00:00
|
|
|
panelAction->setText(dockAction->text());
|
|
|
|
panelAction->setIcon(icon);
|
2014-09-14 20:49:25 +00:00
|
|
|
actionCollection()->setDefaultShortcut(panelAction, shortcut);
|
2011-10-10 20:05:32 +00:00
|
|
|
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
|
|
|
|
connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked);
|
2010-12-19 12:48:24 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 22:07:44 +00:00
|
|
|
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager::UiInterface()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
|
2007-04-12 17:37:53 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
|
|
|
|
{
|
2008-04-20 22:07:44 +00:00
|
|
|
DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
|
|
|
|
if (mainWin) {
|
2012-04-12 21:57:51 +00:00
|
|
|
DolphinViewContainer* container = mainWin->activeViewContainer();
|
|
|
|
container->showMessage(job->errorString(), DolphinViewContainer::Error);
|
2008-04-20 22:07:44 +00:00
|
|
|
} else {
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager::UiInterface::jobError(job);
|
2008-04-20 22:07:44 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|