2006-11-21 06:02:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and *
|
|
|
|
* Cvetoslav Ludmiloff *
|
|
|
|
* *
|
|
|
|
* 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., *
|
2006-12-08 21:24:08 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
2006-11-21 06:02:05 +00:00
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "dolphincontextmenu.h"
|
|
|
|
|
2007-01-21 21:20:37 +00:00
|
|
|
#include "dolphinmainwindow.h"
|
|
|
|
#include "dolphinsettings.h"
|
|
|
|
#include "dolphinview.h"
|
2007-06-07 21:10:48 +00:00
|
|
|
#include "dolphinviewcontainer.h"
|
2008-04-02 19:49:04 +00:00
|
|
|
#include "dolphin_generalsettings.h"
|
2007-01-21 21:20:37 +00:00
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
#include <kactioncollection.h>
|
2007-04-09 09:16:39 +00:00
|
|
|
#include <kfileplacesmodel.h>
|
2007-01-21 21:20:37 +00:00
|
|
|
#include <kdesktopfile.h>
|
2006-11-21 06:02:05 +00:00
|
|
|
#include <kglobal.h>
|
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <kio/netaccess.h>
|
2006-11-22 08:22:45 +00:00
|
|
|
#include <kmenu.h>
|
2007-11-18 14:37:57 +00:00
|
|
|
#include <kmenubar.h>
|
2007-03-15 21:24:41 +00:00
|
|
|
#include <kmessagebox.h>
|
2007-01-21 21:20:37 +00:00
|
|
|
#include <kmimetypetrader.h>
|
2007-01-25 16:56:52 +00:00
|
|
|
#include <knewmenu.h>
|
2007-03-17 21:10:50 +00:00
|
|
|
#include <konqmimedata.h>
|
2008-06-02 10:07:13 +00:00
|
|
|
#include <konq_fileitemcapabilities.h>
|
2007-03-15 21:24:41 +00:00
|
|
|
#include <konq_operations.h>
|
2007-10-07 21:12:46 +00:00
|
|
|
#include <konq_menuactions.h>
|
2008-05-19 18:35:31 +00:00
|
|
|
#include <konq_popupmenuinformation.h>
|
2007-01-21 21:20:37 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
#include <kpropertiesdialog.h>
|
|
|
|
#include <krun.h>
|
2006-12-19 02:26:06 +00:00
|
|
|
#include <kstandardaction.h>
|
2007-01-21 21:20:37 +00:00
|
|
|
#include <kstandarddirs.h>
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-05-09 22:23:52 +00:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QClipboard>
|
|
|
|
#include <QtCore/QDir>
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
|
2007-08-13 21:57:20 +00:00
|
|
|
const KFileItem& fileInfo,
|
2007-03-25 06:44:28 +00:00
|
|
|
const KUrl& baseUrl) :
|
2007-05-06 17:41:49 +00:00
|
|
|
m_mainWindow(parent),
|
2008-04-18 19:43:16 +00:00
|
|
|
m_capabilities(0),
|
2007-05-06 17:41:49 +00:00
|
|
|
m_fileInfo(fileInfo),
|
|
|
|
m_baseUrl(baseUrl),
|
|
|
|
m_context(NoContext)
|
2006-11-21 06:02:05 +00:00
|
|
|
{
|
2007-03-25 06:44:28 +00:00
|
|
|
// The context menu either accesses the URLs of the selected items
|
|
|
|
// or the items itself. To increase the performance both lists are cached.
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
2007-03-25 06:44:28 +00:00
|
|
|
m_selectedUrls = view->selectedUrls();
|
|
|
|
m_selectedItems = view->selectedItems();
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 20:42:26 +00:00
|
|
|
DolphinContextMenu::~DolphinContextMenu()
|
2007-06-20 20:44:18 +00:00
|
|
|
{
|
2008-04-18 19:43:16 +00:00
|
|
|
delete m_capabilities;
|
|
|
|
m_capabilities = 0;
|
2007-06-20 20:44:18 +00:00
|
|
|
}
|
2007-03-17 20:42:26 +00:00
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
void DolphinContextMenu::open()
|
|
|
|
{
|
2007-03-15 21:24:41 +00:00
|
|
|
// get the context information
|
2007-03-15 22:42:21 +00:00
|
|
|
if (m_baseUrl.protocol() == "trash") {
|
2007-03-15 21:24:41 +00:00
|
|
|
m_context |= TrashContext;
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2007-11-19 19:58:00 +00:00
|
|
|
if (!m_fileInfo.isNull() && (m_selectedItems.count() > 0)) {
|
2007-03-15 21:24:41 +00:00
|
|
|
m_context |= ItemContext;
|
|
|
|
// TODO: handle other use cases like devices + desktop files
|
2007-04-09 19:12:54 +00:00
|
|
|
}
|
2007-03-15 21:24:41 +00:00
|
|
|
|
|
|
|
// open the corresponding popup for the context
|
|
|
|
if (m_context & TrashContext) {
|
|
|
|
if (m_context & ItemContext) {
|
|
|
|
openTrashItemContextMenu();
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-03-15 21:24:41 +00:00
|
|
|
openTrashContextMenu();
|
|
|
|
}
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (m_context & ItemContext) {
|
2006-11-21 06:02:05 +00:00
|
|
|
openItemContextMenu();
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-03-15 21:24:41 +00:00
|
|
|
Q_ASSERT(m_context == NoContext);
|
|
|
|
openViewportContextMenu();
|
|
|
|
}
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2007-03-15 21:24:41 +00:00
|
|
|
void DolphinContextMenu::openTrashContextMenu()
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_context & TrashContext);
|
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
KMenu* popup = new KMenu(m_mainWindow);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
addShowMenubarAction(popup);
|
|
|
|
|
2007-10-22 15:58:52 +00:00
|
|
|
QAction* emptyTrashAction = new QAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), popup);
|
KConfig* API overhaul. only cosmetics, so don't panic.
KConfigBase:
- remove separator argument from list entry reading/writing functions
- introduce {read,write}XdgListEntry()
- kill readPathListEntry(), add readPathEntry() overload
instead. the default value is not optional any more, as it defines the
return type. this is consistent with the readEntry() functions.
- rename clean() => markAsClean(), remove rollback()
- rename ConfigState => AccessMode, getConfigState() => accessMode()
- rename {entry,group}IsImmutable() => is{Entry,Group}Immutable()
- remove NLS alias to Localized
KConfig:
- remove setGroup() & group()
- reshuffle OpenFlag enum, introduce NoCascade for symmetry
- remove setExtraConfigFiles() alias to addConfigSources()
KConfigGroup:
- inherit KConfigBase::deleteGroup() overloads
- make convertToQVariant() private, it will probably change somehow
- KConfig & KConfigGroup: deprecate entryMap()
- remove bogus declarations: KConfigGroup::setReadDefaults(),
KConfig::readEntryUntranslated()
- apidox
- reshuffle the declarations in the headers
svn path=/trunk/KDE/kdebase/apps/; revision=728852
2007-10-24 13:08:37 +00:00
|
|
|
KConfig trashConfig("trashrc", KConfig::SimpleConfig);
|
2007-03-15 21:24:41 +00:00
|
|
|
emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
|
|
|
|
popup->addAction(emptyTrashAction);
|
|
|
|
|
2007-12-10 22:00:48 +00:00
|
|
|
QAction* addToPlacesAction = popup->addAction(KIcon("bookmark-new"),
|
2007-11-06 17:09:00 +00:00
|
|
|
i18nc("@action:inmenu Add current folder to places", "Add to Places"));
|
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties");
|
2007-03-15 21:24:41 +00:00
|
|
|
popup->addAction(propertiesAction);
|
|
|
|
|
2007-11-06 17:09:00 +00:00
|
|
|
QAction *action = popup->exec(QCursor::pos());
|
|
|
|
if (action == emptyTrashAction) {
|
2008-04-01 23:32:40 +00:00
|
|
|
const QString text(i18nc("@info", "Do you really want to empty the Trash? All items will be deleted."));
|
2007-03-15 22:42:21 +00:00
|
|
|
const bool del = KMessageBox::warningContinueCancel(m_mainWindow,
|
2007-06-20 20:44:18 +00:00
|
|
|
text,
|
|
|
|
QString(),
|
2007-07-09 17:51:39 +00:00
|
|
|
KGuiItem(i18nc("@action:button", "Empty Trash"),
|
|
|
|
KIcon("user-trash"))
|
2007-04-09 19:12:54 +00:00
|
|
|
) == KMessageBox::Continue;
|
2007-03-15 21:24:41 +00:00
|
|
|
if (del) {
|
2007-03-15 22:42:21 +00:00
|
|
|
KonqOperations::emptyTrash(m_mainWindow);
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
2007-11-06 17:09:00 +00:00
|
|
|
} else if (action == addToPlacesAction) {
|
|
|
|
const KUrl& url = m_mainWindow->activeViewContainer()->url();
|
|
|
|
if (url.isValid()) {
|
2008-03-18 22:38:52 +00:00
|
|
|
DolphinSettings::instance().placesModel()->addPlace(i18nc("@label", "Trash"), url);
|
2007-11-06 17:09:00 +00:00
|
|
|
}
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
popup->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinContextMenu::openTrashItemContextMenu()
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_context & TrashContext);
|
|
|
|
Q_ASSERT(m_context & ItemContext);
|
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
KMenu* popup = new KMenu(m_mainWindow);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
addShowMenubarAction(popup);
|
|
|
|
|
2007-07-09 17:51:39 +00:00
|
|
|
QAction* restoreAction = new QAction(i18nc("@action:inmenu", "Restore"), m_mainWindow);
|
2007-03-15 21:24:41 +00:00
|
|
|
popup->addAction(restoreAction);
|
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
QAction* deleteAction = m_mainWindow->actionCollection()->action("delete");
|
2007-03-15 21:24:41 +00:00
|
|
|
popup->addAction(deleteAction);
|
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties");
|
2007-03-15 21:24:41 +00:00
|
|
|
popup->addAction(propertiesAction);
|
|
|
|
|
|
|
|
if (popup->exec(QCursor::pos()) == restoreAction) {
|
2007-03-15 22:42:21 +00:00
|
|
|
KonqOperations::restoreTrashedItems(m_selectedUrls, m_mainWindow);
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
popup->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinContextMenu::openItemContextMenu()
|
|
|
|
{
|
2007-08-13 21:57:20 +00:00
|
|
|
Q_ASSERT(!m_fileInfo.isNull());
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
KMenu* popup = new KMenu(m_mainWindow);
|
2007-11-18 14:37:57 +00:00
|
|
|
addShowMenubarAction(popup);
|
2007-03-17 20:42:26 +00:00
|
|
|
insertDefaultItemActions(popup);
|
2007-03-16 00:24:56 +00:00
|
|
|
|
|
|
|
popup->addSeparator();
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2007-04-04 21:11:21 +00:00
|
|
|
// insert 'Bookmark This Folder' entry if exactly one item is selected
|
2007-08-25 10:42:10 +00:00
|
|
|
QAction* addToPlacesAction = 0;
|
2007-08-13 21:57:20 +00:00
|
|
|
if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1)) {
|
2007-12-10 22:00:48 +00:00
|
|
|
addToPlacesAction = popup->addAction(KIcon("bookmark-new"),
|
2007-08-25 10:42:10 +00:00
|
|
|
i18nc("@action:inmenu Add selected folder to places", "Add to Places"));
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
|
2008-05-19 19:44:42 +00:00
|
|
|
KonqPopupMenuInformation popupInfo;
|
|
|
|
popupInfo.setItems(m_selectedItems);
|
|
|
|
popupInfo.setParentWidget(m_mainWindow);
|
2007-10-07 21:12:46 +00:00
|
|
|
KonqMenuActions menuActions;
|
2008-05-19 19:44:42 +00:00
|
|
|
menuActions.setPopupMenuInfo(popupInfo);
|
2008-06-02 16:36:29 +00:00
|
|
|
|
|
|
|
// Insert 'Open With...' action or sub menu
|
|
|
|
menuActions.addOpenWithActionsTo(popup, "DesktopEntryName != 'dolphin'");
|
|
|
|
|
|
|
|
// Insert 'Actions' sub menu
|
2008-04-02 19:49:04 +00:00
|
|
|
if (menuActions.addActionsTo(popup)) {
|
2007-10-07 21:12:46 +00:00
|
|
|
popup->addSeparator();
|
2008-04-02 19:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Insert 'Copy To' and 'Move To' sub menus
|
|
|
|
if (DolphinSettings::instance().generalSettings()->showCopyMoveMenu()) {
|
|
|
|
m_copyToMenu.setItems(m_selectedItems);
|
2008-05-19 19:44:42 +00:00
|
|
|
m_copyToMenu.setReadOnly(!capabilities().supportsWriting());
|
2008-04-02 19:49:04 +00:00
|
|
|
m_copyToMenu.addActionsTo(popup);
|
|
|
|
popup->addSeparator();
|
|
|
|
}
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2007-03-17 20:42:26 +00:00
|
|
|
// insert 'Properties...' entry
|
2007-03-25 06:44:28 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties");
|
2007-03-17 20:42:26 +00:00
|
|
|
popup->addAction(propertiesAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
|
|
|
QAction* activatedAction = popup->exec(QCursor::pos());
|
|
|
|
|
2007-08-25 10:42:10 +00:00
|
|
|
if ((addToPlacesAction != 0) && (activatedAction == addToPlacesAction)) {
|
2007-08-13 21:57:20 +00:00
|
|
|
const KUrl selectedUrl(m_fileInfo.url());
|
2007-04-09 09:16:39 +00:00
|
|
|
if (selectedUrl.isValid()) {
|
2008-01-25 19:14:12 +00:00
|
|
|
DolphinSettings::instance().placesModel()->addPlace(placesName(selectedUrl),
|
2007-06-20 20:44:18 +00:00
|
|
|
selectedUrl);
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
popup->deleteLater();
|
|
|
|
}
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
void DolphinContextMenu::openViewportContextMenu()
|
|
|
|
{
|
2007-03-15 22:42:21 +00:00
|
|
|
KMenu* popup = new KMenu(m_mainWindow);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
addShowMenubarAction(popup);
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
// setup 'Create New' menu
|
2007-03-15 22:42:21 +00:00
|
|
|
KNewMenu* newMenu = m_mainWindow->newMenu();
|
2007-01-25 16:56:52 +00:00
|
|
|
newMenu->slotCheckUpToDate();
|
2007-03-15 22:42:21 +00:00
|
|
|
newMenu->setPopupFiles(m_baseUrl);
|
2007-01-25 16:56:52 +00:00
|
|
|
popup->addMenu(newMenu->menu());
|
2007-01-21 22:12:49 +00:00
|
|
|
popup->addSeparator();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2008-03-29 07:44:03 +00:00
|
|
|
QAction* pasteAction = createPasteAction();
|
2006-12-04 21:51:17 +00:00
|
|
|
popup->addAction(pasteAction);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
// setup 'View Mode' menu
|
2007-07-09 17:51:39 +00:00
|
|
|
KMenu* viewModeMenu = new KMenu(i18nc("@title:menu", "View Mode"));
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
QAction* iconsMode = m_mainWindow->actionCollection()->action("icons");
|
2006-12-04 21:51:17 +00:00
|
|
|
viewModeMenu->addAction(iconsMode);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
QAction* detailsMode = m_mainWindow->actionCollection()->action("details");
|
2006-12-04 21:51:17 +00:00
|
|
|
viewModeMenu->addAction(detailsMode);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-04-16 20:01:19 +00:00
|
|
|
QAction* columnsMode = m_mainWindow->actionCollection()->action("columns");
|
|
|
|
viewModeMenu->addAction(columnsMode);
|
|
|
|
|
2007-01-21 21:20:37 +00:00
|
|
|
popup->addMenu(viewModeMenu);
|
2007-06-12 21:45:22 +00:00
|
|
|
|
2007-01-21 22:12:49 +00:00
|
|
|
popup->addSeparator();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-12-10 22:00:48 +00:00
|
|
|
QAction* addToPlacesAction = popup->addAction(KIcon("bookmark-new"),
|
2007-08-25 10:42:10 +00:00
|
|
|
i18nc("@action:inmenu Add current folder to places", "Add to Places"));
|
2007-01-21 22:12:49 +00:00
|
|
|
popup->addSeparator();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-07-09 17:51:39 +00:00
|
|
|
QAction* propertiesAction = popup->addAction(i18nc("@action:inmenu", "Properties"));
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
QAction* action = popup->exec(QCursor::pos());
|
|
|
|
if (action == propertiesAction) {
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl& url = m_mainWindow->activeViewContainer()->url();
|
2008-08-12 18:46:35 +00:00
|
|
|
|
|
|
|
KPropertiesDialog* dialog = new KPropertiesDialog(url, m_mainWindow);
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
dialog->show();
|
|
|
|
dialog->raise();
|
|
|
|
dialog->activateWindow();
|
2007-08-25 10:42:10 +00:00
|
|
|
} else if (action == addToPlacesAction) {
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl& url = m_mainWindow->activeViewContainer()->url();
|
2007-04-09 09:16:39 +00:00
|
|
|
if (url.isValid()) {
|
2008-01-25 19:14:12 +00:00
|
|
|
DolphinSettings::instance().placesModel()->addPlace(placesName(url), url);
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
popup->deleteLater();
|
|
|
|
}
|
|
|
|
|
2007-03-15 21:24:41 +00:00
|
|
|
void DolphinContextMenu::insertDefaultItemActions(KMenu* popup)
|
2006-11-21 06:02:05 +00:00
|
|
|
{
|
2007-03-15 21:24:41 +00:00
|
|
|
Q_ASSERT(popup != 0);
|
2007-03-17 20:42:26 +00:00
|
|
|
const KActionCollection* collection = m_mainWindow->actionCollection();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
// insert 'Cut', 'Copy' and 'Paste'
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* cutAction = collection->action(KStandardAction::name(KStandardAction::Cut));
|
|
|
|
QAction* copyAction = collection->action(KStandardAction::name(KStandardAction::Copy));
|
2008-03-29 07:44:03 +00:00
|
|
|
QAction* pasteAction = createPasteAction();
|
2007-03-17 20:42:26 +00:00
|
|
|
|
2007-03-16 00:24:56 +00:00
|
|
|
popup->addAction(cutAction);
|
|
|
|
popup->addAction(copyAction);
|
|
|
|
popup->addAction(pasteAction);
|
2007-01-21 22:12:49 +00:00
|
|
|
popup->addSeparator();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
// insert 'Rename'
|
2007-03-25 06:44:28 +00:00
|
|
|
QAction* renameAction = collection->action("rename");
|
2006-12-04 21:51:17 +00:00
|
|
|
popup->addAction(renameAction);
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-02-25 20:51:05 +00:00
|
|
|
// insert 'Move to Trash' and (optionally) 'Delete'
|
2008-08-07 21:44:35 +00:00
|
|
|
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
|
|
|
|
KConfigGroup configGroup(globalConfig, "KDE");
|
|
|
|
bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl& url = m_mainWindow->activeViewContainer()->url();
|
2006-11-21 06:02:05 +00:00
|
|
|
if (url.isLocalFile()) {
|
2007-03-25 06:44:28 +00:00
|
|
|
QAction* moveToTrashAction = collection->action("move_to_trash");
|
2006-12-04 21:51:17 +00:00
|
|
|
popup->addAction(moveToTrashAction);
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-02-25 20:51:05 +00:00
|
|
|
showDeleteCommand = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (showDeleteCommand) {
|
2007-03-25 06:44:28 +00:00
|
|
|
QAction* deleteAction = collection->action("delete");
|
2006-12-04 21:51:17 +00:00
|
|
|
popup->addAction(deleteAction);
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
void DolphinContextMenu::addShowMenubarAction(KMenu* menu)
|
|
|
|
{
|
|
|
|
KAction* showMenuBar = m_mainWindow->showMenuBarAction();
|
|
|
|
if (!m_mainWindow->menuBar()->isVisible()) {
|
|
|
|
menu->addAction(showMenuBar);
|
|
|
|
menu->addSeparator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-25 19:14:12 +00:00
|
|
|
QString DolphinContextMenu::placesName(const KUrl& url) const
|
|
|
|
{
|
|
|
|
QString name = url.fileName();
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
name = url.host();
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2008-03-29 07:44:03 +00:00
|
|
|
QAction* DolphinContextMenu::createPasteAction()
|
|
|
|
{
|
|
|
|
QAction* action = 0;
|
2008-06-18 19:34:03 +00:00
|
|
|
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
|
|
|
if (isDir && (m_selectedItems.count() == 1)) {
|
2008-03-29 07:44:03 +00:00
|
|
|
action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
|
|
|
|
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
|
|
|
|
const KUrl::List pasteData = KUrl::List::fromMimeData(mimeData);
|
2008-04-18 19:43:16 +00:00
|
|
|
action->setEnabled(!pasteData.isEmpty() && capabilities().supportsWriting());
|
2008-03-29 14:54:56 +00:00
|
|
|
connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
|
2008-03-29 07:44:03 +00:00
|
|
|
} else {
|
|
|
|
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
|
|
|
}
|
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2008-06-02 10:07:13 +00:00
|
|
|
KonqFileItemCapabilities& DolphinContextMenu::capabilities()
|
2008-04-18 19:43:16 +00:00
|
|
|
{
|
|
|
|
if (m_capabilities == 0) {
|
2008-06-02 10:07:13 +00:00
|
|
|
m_capabilities = new KonqFileItemCapabilities(m_selectedItems);
|
2008-04-18 19:43:16 +00:00
|
|
|
}
|
|
|
|
return *m_capabilities;
|
|
|
|
}
|
|
|
|
|
2007-03-17 20:42:26 +00:00
|
|
|
#include "dolphincontextmenu.moc"
|