#include "dolphinmainwindow.h"
-#include "dolphinapplication.h"
+#include "global.h"
#include "dolphindockwidget.h"
#include "dolphincontextmenu.h"
#include "dolphinnewfilemenu.h"
#include <KActionCollection>
#include <KActionMenu>
#include <KConfig>
-#include <kdeversion.h>
#include <kdualaction.h>
-#include <KDialog>
#include <KJobWidgets>
-#include <KLineEdit>
+#include <QLineEdit>
#include <KToolBar>
-#include <KIO/NetAccess>
#include <KIO/JobUiDelegate>
#include <KLocalizedString>
#include <KProtocolManager>
#include <KToolInvocation>
#include <KUrlComboBox>
+#include <QApplication>
#include <QMenuBar>
#include <QClipboard>
#include <QToolButton>
#include <QPushButton>
#include <QCloseEvent>
#include <QShowEvent>
+#include <QDialog>
namespace {
// Used for GeneralSettings::version() to determine whether
{
}
-void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs)
+void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView)
{
- m_tabWidget->openDirectories(dirs);
+ m_tabWidget->openDirectories(dirs, splitView);
}
-void DolphinMainWindow::openFiles(const QList<QUrl>& files)
+void DolphinMainWindow::openFiles(const QList<QUrl>& files, bool splitView)
{
- m_tabWidget->openFiles(files);
+ m_tabWidget->openFiles(files, splitView);
}
void DolphinMainWindow::showCommand(CommandType command)
emit selectionChanged(selection);
}
-void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
-{
- emit requestItemInfo(item);
-}
-
void DolphinMainWindow::updateHistory()
{
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
m_tabWidget->openNewTab(url);
}
-void DolphinMainWindow::openNewActivatedTab(const QUrl& url)
-{
- m_tabWidget->openNewActivatedTab(url);
-}
-
void DolphinMainWindow::openInNewTab()
{
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
}
if (!newWindowUrl.isEmpty()) {
- KRun::run("dolphin %u", QList<QUrl>() << newWindowUrl, this);
+ KRun::run("dolphin %u", {newWindowUrl}, this);
}
}
// Find out if Dolphin is closed directly by the user or
// by the session manager because the session is closed
bool closedByUser = true;
- DolphinApplication *application = qobject_cast<DolphinApplication*>(qApp);
- if (application && application->sessionSaving()) {
+ if (qApp->isSessionRestored()) {
closedByUser = false;
}
if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
// Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons:
- // KDialog::Yes -> Quit
- // KDialog::No -> Close only the current tab
- // KDialog::Cancel -> do nothing
+ // QDialogButtonBox::Yes -> Quit
+ // QDialogButtonBox::No -> Close only the current tab
+ // QDialogButtonBox::Cancel -> do nothing
QDialog *dialog = new QDialog(this, Qt::Dialog);
dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true);
{
// The default case (left button pressed) is handled in goHome().
if (buttons == Qt::MiddleButton) {
- openNewTab(GeneralSettings::self()->homeUrl());
+ openNewTab(Dolphin::homeUrl());
}
}
// 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.
- QUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
+ KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
+ KJobWidgets::setWindow(statJob, this);
+ statJob->exec();
+ QUrl url = statJob->mostLocalUrl();
//If the URL is local after the above conversion, set the directory.
if (url.isLocalFile()) {
const QUrl& url,
const QList<QAction*>& customActions)
{
- QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
+ QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
contextMenu.data()->setCustomActions(customActions);
const DolphinContextMenu::Command command = contextMenu.data()->open();
case DolphinContextMenu::OpenParentFolderInNewWindow: {
- KRun::run("dolphin %u", QList<QUrl>() << KIO::upUrl(item.url()), this);
+ KRun::run("dolphin %u", {KIO::upUrl(item.url())}, this);
break;
}
break;
}
- delete contextMenu.data();
+ // Delete the menu, unless it has been deleted in its own nested event loop already.
+ if (contextMenu) {
+ contextMenu->deleteLater();
+ }
}
void DolphinMainWindow::updateControlMenu()
m_updateToolBarTimer->start();
}
-void DolphinMainWindow::slotPanelErrorMessage(const QString& error)
-{
- activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
-}
-
void DolphinMainWindow::slotPlaceActivated(const QUrl& url)
{
DolphinViewContainer* view = activeViewContainer();
}
}
- const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
+ QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName();
+ if (fileName.isEmpty()) {
+ fileName = '/';
+ }
+
caption.append(fileName);
- setCaption(caption);
+ setWindowTitle(caption);
}
void DolphinMainWindow::setupActions()
QAction* newTab = actionCollection()->addAction("new_tab");
newTab->setIcon(QIcon::fromTheme("tab-new"));
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
- actionCollection()->setDefaultShortcuts(newTab, QList<QKeySequence>() << QKeySequence(Qt::CTRL | Qt::Key_T) << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_N));
+ actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N});
connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
QAction* closeTab = actionCollection()->addAction("close_tab");
undoCloseTab->setEnabled(false);
connect(undoCloseTab, SIGNAL(triggered()), recentTabsMenu, SLOT(undoCloseTab()));
+ auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+ undoAction->setEnabled(false); // undo should be disabled by default
+
KStandardAction::forward(this, SLOT(goForward()), actionCollection());
KStandardAction::up(this, SLOT(goUp()), actionCollection());
KStandardAction::home(this, SLOT(goHome()), actionCollection());
infoDock->setObjectName("infoDock");
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
InformationPanel* infoPanel = new InformationPanel(infoDock);
- infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ infoPanel->setCustomContextMenuActions({lockLayoutAction});
connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
infoDock->setWidget(infoPanel);
foldersDock->setObjectName("foldersDock");
foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
- foldersPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ foldersPanel->setCustomContextMenuActions({lockLayoutAction});
foldersDock->setWidget(foldersPanel);
QAction* foldersAction = foldersDock->toggleViewAction();
connect(foldersPanel, &FoldersPanel::folderMiddleClicked,
this, &DolphinMainWindow::openNewTab);
connect(foldersPanel, &FoldersPanel::errorMessage,
- this, &DolphinMainWindow::slotPanelErrorMessage);
+ this, &DolphinMainWindow::showErrorMessage);
// Setup "Terminal"
#ifndef Q_OS_WIN
terminalDock->setObjectName("terminalDock");
terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
TerminalPanel* terminalPanel = new TerminalPanel(terminalDock);
- terminalPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ terminalPanel->setCustomContextMenuActions({lockLayoutAction});
terminalDock->setWidget(terminalPanel);
connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
PlacesPanel* placesPanel = new PlacesPanel(placesDock);
- placesPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ placesPanel->setCustomContextMenuActions({lockLayoutAction});
placesDock->setWidget(placesPanel);
QAction* placesAction = placesDock->toggleViewAction();
connect(placesPanel, SIGNAL(placeMiddleClicked(QUrl)),
this, SLOT(openNewTab(QUrl)));
connect(placesPanel, &PlacesPanel::errorMessage,
- this, &DolphinMainWindow::slotPanelErrorMessage);
+ this, &DolphinMainWindow::showErrorMessage);
connect(this, &DolphinMainWindow::urlChanged,
placesPanel, &PlacesPanel::setUrl);
connect(placesDock, &DolphinDockWidget::visibilityChanged,
Q_ASSERT(!m_controlButton);
m_controlButton = new QToolButton(this);
- m_controlButton->setIcon(QIcon::fromTheme("applications-system"));
+ m_controlButton->setIcon(QIcon::fromTheme("application-menu"));
m_controlButton->setText(i18nc("@action", "Control"));
m_controlButton->setPopupMode(QToolButton::InstantPopup);
m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
connect(view, &DolphinView::selectionChanged,
this, &DolphinMainWindow::slotSelectionChanged);
connect(view, &DolphinView::requestItemInfo,
- this, &DolphinMainWindow::slotRequestItemInfo);
+ this, &DolphinMainWindow::requestItemInfo);
connect(view, &DolphinView::tabRequested,
this, &DolphinMainWindow::openNewTab);
connect(view, &DolphinView::requestContextMenu,