-/***************************************************************************
- * Copyright (C) 2006-2010 by Peter Penz <peter.penz19@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 *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2006-2010 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#include "treeviewcontextmenu.h"
-#include <KFileItem>
+#include "folderspanel.h"
+#include "global.h"
+
+#include <KConfigGroup>
+#include <KFileItemListProperties>
#include <KIO/CopyJob>
#include <KIO/DeleteJob>
+#include <KIO/FileUndoManager>
#include <KIO/JobUiDelegate>
-#include <QMenu>
-#include <QIcon>
+#include <KIO/Paste>
+#include <KIO/PasteJob>
#include <KJobWidgets>
-#include <KSharedConfig>
-#include <KConfigGroup>
-#include <KUrlMimeData>
-#include <KFileItemListProperties>
#include <KLocalizedString>
-#include <KIO/PasteJob>
-#include <KIO/Paste>
-#include <KIO/FileUndoManager>
#include <KPropertiesDialog>
-
-#include "folderspanel.h"
+#include <KSharedConfig>
+#include <KUrlMimeData>
#include <QApplication>
#include <QClipboard>
+#include <QMenu>
#include <QMimeData>
#include <QPointer>
-#include "global.h"
TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent,
const KFileItem& fileInfo) :
{
}
-void TreeViewContextMenu::open()
+void TreeViewContextMenu::open(const QPoint& pos)
{
QMenu* popup = new QMenu(m_parent);
popup->addAction(showHiddenFilesAction);
connect(showHiddenFilesAction, &QAction::toggled, this, &TreeViewContextMenu::setShowHiddenFiles);
- // insert 'Limit to Home Directory'
- const QUrl url = m_fileItem.url();
- const bool showLimitToHomeDirectory = url.isLocalFile() && (Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url));
- if (showLimitToHomeDirectory) {
+ if (!m_fileItem.isNull()) {
+ // insert 'Limit to Home Directory'
+ const QUrl url = m_fileItem.url();
+ const bool enableLimitToHomeDirectory = url.isLocalFile();
QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this);
limitFoldersPanelToHomeAction->setCheckable(true);
+ limitFoldersPanelToHomeAction->setEnabled(enableLimitToHomeDirectory);
limitFoldersPanelToHomeAction->setChecked(m_parent->limitFoldersPanelToHome());
popup->addAction(limitFoldersPanelToHomeAction);
connect(limitFoldersPanelToHomeAction, &QAction::toggled, this, &TreeViewContextMenu::setLimitFoldersPanelToHome);
popup->addAction(propertiesAction);
}
- QList<QAction*> customActions = m_parent->customContextMenuActions();
+ const QList<QAction*> customActions = m_parent->customContextMenuActions();
if (!customActions.isEmpty()) {
popup->addSeparator();
- foreach (QAction* action, customActions) {
+ for (QAction* action : customActions) {
popup->addAction(action);
}
}
QPointer<QMenu> popupPtr = popup;
- popup->exec(QCursor::pos());
+ popup->exec(pos);
if (popupPtr.data()) {
popupPtr.data()->deleteLater();
}
kdeUrls.append(m_fileItem.url());
QList<QUrl> mostLocalUrls;
bool dummy;
- mostLocalUrls.append(m_fileItem.mostLocalUrl(dummy));
+ mostLocalUrls.append(m_fileItem.mostLocalUrl(&dummy));
KIO::setClipboardDataCut(mimeData, cut);
+ KUrlMimeData::exportUrlsToPortal(mimeData);
KUrlMimeData::setUrls(kdeUrls, mostLocalUrls, mimeData);
}