1999-05-12 02:26:56 +00:00
|
|
|
/* This file is part of the KDE project
|
2006-01-10 08:57:20 +00:00
|
|
|
Copyright (C) 1998-2006 David Faure <faure@kde.org>
|
2001-10-30 18:09:01 +00:00
|
|
|
Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>
|
1999-12-18 20:30:37 +00:00
|
|
|
|
1999-05-12 02:26:56 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1999-12-18 20:30:37 +00:00
|
|
|
|
1999-05-12 02:26:56 +00:00
|
|
|
This library 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
|
|
|
|
Library General Public License for more details.
|
1999-12-18 20:30:37 +00:00
|
|
|
|
1999-05-12 02:26:56 +00:00
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
2005-10-05 08:44:32 +00:00
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2005-07-04 19:02:09 +00:00
|
|
|
Boston, MA 02110-1301, USA.
|
1999-12-18 20:30:37 +00:00
|
|
|
*/
|
1999-05-12 02:26:56 +00:00
|
|
|
|
2006-05-02 15:52:32 +00:00
|
|
|
#include "konq_popupmenu.h"
|
2007-10-07 21:12:46 +00:00
|
|
|
#include "konq_menuactions.h"
|
2006-05-02 15:52:32 +00:00
|
|
|
#include "kpropertiesdialog.h"
|
|
|
|
#include "knewmenu.h"
|
|
|
|
#include "konq_operations.h"
|
|
|
|
|
2000-08-24 02:56:03 +00:00
|
|
|
#include <klocale.h>
|
2000-10-26 03:50:30 +00:00
|
|
|
#include <kbookmarkmanager.h>
|
2007-09-03 07:53:52 +00:00
|
|
|
#include <kbookmarkdialog.h>
|
1999-05-24 20:04:01 +00:00
|
|
|
#include <kdebug.h>
|
2002-01-11 18:21:23 +00:00
|
|
|
#include <krun.h>
|
2006-05-22 07:59:05 +00:00
|
|
|
#include <kprotocolmanager.h>
|
2006-08-04 15:10:05 +00:00
|
|
|
#include <kicon.h>
|
2001-10-12 10:15:14 +00:00
|
|
|
#include <kiconloader.h>
|
2003-06-08 14:44:34 +00:00
|
|
|
#include <kinputdialog.h>
|
2000-03-17 16:35:18 +00:00
|
|
|
#include <kglobalsettings.h>
|
2007-08-31 22:52:52 +00:00
|
|
|
#include <kmimetypetrader.h>
|
2001-10-12 10:15:14 +00:00
|
|
|
#include <kstandarddirs.h>
|
2007-02-20 07:00:30 +00:00
|
|
|
#include <kconfiggroup.h>
|
|
|
|
#include <kdesktopfile.h>
|
2002-04-16 17:06:27 +00:00
|
|
|
#include <kfileshare.h>
|
2005-10-03 10:21:33 +00:00
|
|
|
#include <kauthorized.h>
|
2005-11-08 10:20:07 +00:00
|
|
|
#include <kglobal.h>
|
2007-02-20 07:00:30 +00:00
|
|
|
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QDir>
|
2007-10-01 17:06:34 +00:00
|
|
|
#include <QApplication>
|
2006-05-02 15:52:32 +00:00
|
|
|
#include <QPixmap>
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2004-09-06 18:40:43 +00:00
|
|
|
/*
|
|
|
|
Test cases:
|
2004-09-24 07:56:05 +00:00
|
|
|
iconview file: background
|
|
|
|
iconview file: file (with and without servicemenus)
|
|
|
|
iconview file: directory
|
|
|
|
iconview remote protocol (e.g. ftp: or fish:)
|
2004-09-24 09:20:59 +00:00
|
|
|
iconview trash:/
|
2004-09-06 18:40:43 +00:00
|
|
|
sidebar directory tree
|
2004-09-24 09:20:59 +00:00
|
|
|
sidebar Devices / Hard Disc
|
2004-09-06 18:40:43 +00:00
|
|
|
khtml background
|
|
|
|
khtml link
|
|
|
|
khtml image (www.kde.org RMB on K logo)
|
|
|
|
khtmlimage (same as above, then choose View image, then RMB)
|
|
|
|
selected text in khtml
|
|
|
|
embedded katepart
|
|
|
|
kdesktop folder
|
2004-09-07 16:30:13 +00:00
|
|
|
trash link on desktop
|
|
|
|
trashed file or directory
|
|
|
|
application .desktop file
|
2004-09-06 18:40:43 +00:00
|
|
|
Then the same after uninstalling kdeaddons/konq-plugins (kuick and arkplugin in particular)
|
|
|
|
*/
|
2003-05-19 17:24:46 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
class KonqPopupMenuPrivate
|
2000-04-01 17:09:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-10-01 17:06:34 +00:00
|
|
|
KonqPopupMenuPrivate(KonqPopupMenu* qq, KActionCollection & actions)
|
|
|
|
: q(qq),
|
|
|
|
m_parentWidget(0),
|
|
|
|
m_itemFlags(KParts::BrowserExtension::DefaultPopupItems),
|
|
|
|
m_actions(actions),
|
|
|
|
m_ownActions(static_cast<QWidget *>(0)),
|
|
|
|
m_runServiceActionGroup(q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void addNamedAction(const QString& name);
|
|
|
|
void addGroup(const QString& name);
|
|
|
|
void addPlugins();
|
|
|
|
void setup(KonqPopupMenu::Flags kpf);
|
|
|
|
|
|
|
|
void slotPopupNewDir();
|
|
|
|
void slotPopupNewView();
|
|
|
|
void slotPopupEmptyTrashBin();
|
|
|
|
void slotPopupRestoreTrashedItems();
|
|
|
|
void slotPopupOpenWith();
|
|
|
|
void slotPopupAddToBookmark();
|
|
|
|
void slotRunService(QAction*);
|
|
|
|
void slotPopupMimeType();
|
|
|
|
void slotPopupProperties();
|
|
|
|
void slotOpenShareFileDialog();
|
|
|
|
|
|
|
|
KonqPopupMenu* q;
|
|
|
|
QString m_urlTitle;
|
|
|
|
QWidget *m_parentWidget;
|
|
|
|
KParts::BrowserExtension::PopupFlags m_itemFlags;
|
|
|
|
KNewMenu *m_pMenuNew;
|
|
|
|
KUrl m_sViewURL;
|
|
|
|
QString m_sMimeType;
|
|
|
|
KFileItemList m_lstItems;
|
|
|
|
KUrl::List m_lstPopupURLs;
|
2007-10-07 21:12:46 +00:00
|
|
|
QMap<QAction*,KService::Ptr> m_mapPopup;
|
|
|
|
KonqMenuActions m_menuActions;
|
2007-10-01 17:06:34 +00:00
|
|
|
bool m_bHandleEditOperations;
|
|
|
|
QString m_attrName;
|
|
|
|
// KonqPopupMenu::ProtocolInfo m_info;
|
|
|
|
KBookmarkManager* m_bookmarkManager;
|
|
|
|
KActionCollection &m_actions;
|
2007-10-07 21:12:46 +00:00
|
|
|
KActionCollection m_ownActions; // TODO connect to statusbar for help on actions
|
2007-10-01 17:06:34 +00:00
|
|
|
QActionGroup m_runServiceActionGroup;
|
|
|
|
KParts::BrowserExtension::ActionGroupMap m_actionGroups;
|
2001-12-12 14:10:22 +00:00
|
|
|
};
|
2002-02-27 04:44:03 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
#if 0
|
2004-09-24 08:04:33 +00:00
|
|
|
KonqPopupMenu::ProtocolInfo::ProtocolInfo()
|
2002-01-21 20:46:23 +00:00
|
|
|
{
|
|
|
|
m_Reading = false;
|
|
|
|
m_Writing = false;
|
|
|
|
m_Deleting = false;
|
|
|
|
m_Moving = false;
|
|
|
|
m_TrashIncluded = false;
|
|
|
|
}
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2002-01-21 20:46:23 +00:00
|
|
|
bool KonqPopupMenu::ProtocolInfo::supportsReading() const
|
|
|
|
{
|
|
|
|
return m_Reading;
|
|
|
|
}
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2002-01-21 20:46:23 +00:00
|
|
|
bool KonqPopupMenu::ProtocolInfo::supportsWriting() const
|
|
|
|
{
|
|
|
|
return m_Writing;
|
|
|
|
}
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2002-01-21 20:46:23 +00:00
|
|
|
bool KonqPopupMenu::ProtocolInfo::supportsDeleting() const
|
|
|
|
{
|
|
|
|
return m_Deleting;
|
|
|
|
}
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2002-01-21 20:46:23 +00:00
|
|
|
bool KonqPopupMenu::ProtocolInfo::supportsMoving() const
|
|
|
|
{
|
|
|
|
return m_Moving;
|
|
|
|
}
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2002-01-21 20:46:23 +00:00
|
|
|
bool KonqPopupMenu::ProtocolInfo::trashIncluded() const
|
|
|
|
{
|
|
|
|
return m_TrashIncluded;
|
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
#endif
|
2001-12-12 14:10:22 +00:00
|
|
|
|
2004-09-24 08:04:33 +00:00
|
|
|
//////////////////
|
2004-09-06 22:22:05 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
KonqPopupMenu::KonqPopupMenu(const KFileItemList &items,
|
|
|
|
const KUrl& viewURL,
|
|
|
|
KActionCollection & actions,
|
|
|
|
KNewMenu * newMenu,
|
|
|
|
Flags kpf,
|
|
|
|
KParts::BrowserExtension::PopupFlags flags,
|
|
|
|
QWidget * parentWidget,
|
|
|
|
KBookmarkManager *mgr,
|
|
|
|
const KParts::BrowserExtension::ActionGroupMap& actionGroups)
|
2006-05-02 15:52:32 +00:00
|
|
|
: QMenu( parentWidget ),
|
2007-10-01 17:06:34 +00:00
|
|
|
d(new KonqPopupMenuPrivate(this, actions))
|
2003-06-18 16:48:39 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
d->m_actionGroups = actionGroups;
|
|
|
|
d->m_pMenuNew = newMenu;
|
|
|
|
d->m_sViewURL = viewURL;
|
|
|
|
d->m_lstItems = items;
|
|
|
|
d->m_bookmarkManager = mgr;
|
2004-09-24 08:04:33 +00:00
|
|
|
init(parentWidget, kpf, flags);
|
2003-06-18 16:48:39 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenu::init (QWidget * parentWidget, Flags kpf, KParts::BrowserExtension::PopupFlags flags)
|
2002-11-20 11:35:24 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
d->m_ownActions.setObjectName("KonqPopupMenu::m_ownActions");
|
2004-09-24 08:04:33 +00:00
|
|
|
d->m_parentWidget = parentWidget;
|
|
|
|
d->m_itemFlags = flags;
|
2007-10-01 17:06:34 +00:00
|
|
|
setFont(KGlobalSettings::menuFont());
|
2007-10-07 21:12:46 +00:00
|
|
|
QObject::connect(&d->m_runServiceActionGroup, SIGNAL(triggered(QAction*)),
|
|
|
|
this, SLOT(slotRunService(QAction*)));
|
2007-10-01 17:06:34 +00:00
|
|
|
d->setup(kpf);
|
2002-11-20 11:35:24 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::addNamedAction(const QString& name)
|
|
|
|
{
|
|
|
|
QAction* act = m_actions.action(name);
|
|
|
|
if (act)
|
|
|
|
q->addAction(act);
|
|
|
|
}
|
2003-07-28 22:06:29 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::setup(KonqPopupMenu::Flags kpf)
|
2002-11-20 11:35:24 +00:00
|
|
|
{
|
2006-05-02 15:52:32 +00:00
|
|
|
Q_ASSERT( m_lstItems.count() >= 1 );
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
const bool bIsLink = (m_itemFlags & KParts::BrowserExtension::IsLink);
|
2003-08-05 15:04:54 +00:00
|
|
|
bool currentDir = false;
|
|
|
|
bool sReading = true;
|
2007-10-01 17:06:34 +00:00
|
|
|
bool sDeleting = (m_itemFlags & KParts::BrowserExtension::NoDeletion) == 0;
|
2004-10-19 20:37:45 +00:00
|
|
|
bool sMoving = sDeleting;
|
2007-10-01 08:00:48 +00:00
|
|
|
bool sWriting = sDeleting && m_lstItems.first().isWritable();
|
|
|
|
m_sMimeType = m_lstItems.first().mimetype();
|
2006-03-23 17:19:24 +00:00
|
|
|
QString mimeGroup = m_sMimeType.left(m_sMimeType.indexOf('/'));
|
2007-10-01 08:00:48 +00:00
|
|
|
mode_t mode = m_lstItems.first().mode();
|
2003-08-05 15:04:54 +00:00
|
|
|
bool bTrashIncluded = false;
|
2005-01-18 10:10:23 +00:00
|
|
|
bool mediaFiles = false;
|
2007-10-01 08:00:48 +00:00
|
|
|
bool isLocal = m_lstItems.first().isLocalFile()
|
|
|
|
|| m_lstItems.first().url().protocol()=="media"
|
|
|
|
|| m_lstItems.first().url().protocol()=="system";
|
2005-01-18 10:10:23 +00:00
|
|
|
bool isTrashLink = false;
|
2003-08-05 15:04:54 +00:00
|
|
|
m_lstPopupURLs.clear();
|
|
|
|
int id = 0;
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
m_attrName = QLatin1String( "name" );
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2006-01-24 08:32:09 +00:00
|
|
|
KUrl url;
|
2006-01-10 08:57:20 +00:00
|
|
|
KFileItemList::const_iterator it = m_lstItems.begin();
|
|
|
|
const KFileItemList::const_iterator kend = m_lstItems.end();
|
2004-12-10 21:35:06 +00:00
|
|
|
QStringList mimeTypeList;
|
2006-01-10 08:57:20 +00:00
|
|
|
for ( ; it != kend; ++it )
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2007-10-01 08:00:48 +00:00
|
|
|
url = (*it).url();
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
// Build the list of URLs
|
|
|
|
m_lstPopupURLs.append( url );
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
// Determine if common mode among all URLs
|
2007-10-01 08:00:48 +00:00
|
|
|
if ( mode != (*it).mode() )
|
2003-08-05 15:04:54 +00:00
|
|
|
mode = 0; // modes are different => reset to 0
|
1999-08-04 10:50:58 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
// Determine if common mimetype among all URLs
|
2007-10-01 08:00:48 +00:00
|
|
|
if ( m_sMimeType != (*it).mimetype() )
|
2004-04-20 23:07:20 +00:00
|
|
|
{
|
2006-01-02 16:09:13 +00:00
|
|
|
m_sMimeType.clear(); // mimetypes are different => null
|
1999-08-04 10:50:58 +00:00
|
|
|
|
2007-10-01 08:00:48 +00:00
|
|
|
if ( mimeGroup != (*it).mimetype().left((*it).mimetype().indexOf('/')))
|
2006-01-02 16:09:13 +00:00
|
|
|
mimeGroup.clear(); // mimetype groups are different as well!
|
2004-04-20 23:07:20 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 08:00:48 +00:00
|
|
|
if ( mimeTypeList.indexOf( (*it).mimetype() ) == -1 )
|
|
|
|
mimeTypeList << (*it).mimetype();
|
2004-12-10 21:35:06 +00:00
|
|
|
|
2005-06-03 16:55:19 +00:00
|
|
|
if ( isLocal && !url.isLocalFile() && url.protocol() != "media" && url.protocol() != "system" )
|
2004-09-24 09:20:59 +00:00
|
|
|
isLocal = false;
|
|
|
|
|
2005-06-03 23:18:33 +00:00
|
|
|
if ( !bTrashIncluded && (
|
|
|
|
( url.protocol() == "trash" && url.path().length() <= 1 )
|
|
|
|
|| url.url() == "system:/trash" || url.url() == "system:/trash/" ) ) {
|
2003-08-05 15:04:54 +00:00
|
|
|
bTrashIncluded = true;
|
2005-06-03 16:55:19 +00:00
|
|
|
isLocal = false;
|
|
|
|
}
|
2000-08-07 18:34:11 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
if ( sReading )
|
2006-05-22 07:59:05 +00:00
|
|
|
sReading = KProtocolManager::supportsReading( url );
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
if ( sWriting )
|
2007-10-01 08:00:48 +00:00
|
|
|
sWriting = KProtocolManager::supportsWriting( url ) && (*it).isWritable();
|
1999-12-18 20:30:37 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
if ( sDeleting )
|
2006-05-22 07:59:05 +00:00
|
|
|
sDeleting = KProtocolManager::supportsDeleting( url );
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
if ( sMoving )
|
2006-05-22 07:59:05 +00:00
|
|
|
sMoving = KProtocolManager::supportsMoving( url );
|
2007-10-01 08:00:48 +00:00
|
|
|
if ( (*it).mimetype().startsWith("media/") )
|
2004-11-02 12:45:38 +00:00
|
|
|
mediaFiles = true;
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2007-10-07 21:12:46 +00:00
|
|
|
const bool isDirectory = S_ISDIR(mode);
|
2003-08-05 15:04:54 +00:00
|
|
|
url = m_sViewURL;
|
|
|
|
url.cleanPath();
|
|
|
|
|
|
|
|
//check if url is current directory
|
|
|
|
if ( m_lstItems.count() == 1 )
|
|
|
|
{
|
2007-10-01 08:00:48 +00:00
|
|
|
KUrl firstPopupURL( m_lstItems.first().url() );
|
2003-08-05 15:04:54 +00:00
|
|
|
firstPopupURL.cleanPath();
|
2007-08-03 06:40:12 +00:00
|
|
|
//kDebug(1203) << "View path is " << url.url();
|
|
|
|
//kDebug(1203) << "First popup path is " << firstPopupURL.url();
|
2006-05-08 13:33:51 +00:00
|
|
|
currentDir = firstPopupURL.equals( url, KUrl::CompareWithoutTrailingSlash );
|
2005-01-18 10:10:23 +00:00
|
|
|
if ( isLocal && m_sMimeType == "application/x-desktop" ) {
|
2007-02-20 07:00:30 +00:00
|
|
|
KDesktopFile desktopFile( firstPopupURL.path() );
|
|
|
|
const KConfigGroup cfg = desktopFile.desktopGroup();
|
2005-01-18 10:10:23 +00:00
|
|
|
isTrashLink = ( cfg.readEntry("Type") == "Link" && cfg.readEntry("URL") == "trash:/" );
|
2005-06-03 13:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( isTrashLink ) {
|
|
|
|
sDeleting = false;
|
2005-01-18 10:10:23 +00:00
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2005-01-18 10:10:23 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
#if 0
|
2005-01-18 10:10:23 +00:00
|
|
|
m_info.m_Reading = sReading;
|
|
|
|
m_info.m_Writing = sWriting;
|
|
|
|
m_info.m_Deleting = sDeleting;
|
2005-06-03 23:18:33 +00:00
|
|
|
m_info.m_Moving = sMoving;
|
2005-01-18 10:10:23 +00:00
|
|
|
m_info.m_TrashIncluded = bTrashIncluded;
|
2007-10-01 17:06:34 +00:00
|
|
|
#endif
|
2003-01-26 21:31:52 +00:00
|
|
|
|
2005-01-18 10:10:23 +00:00
|
|
|
// isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
|
|
|
|
bool isCurrentTrash = ( m_lstItems.count() == 1 && bTrashIncluded ) || isTrashLink;
|
2005-06-03 23:18:33 +00:00
|
|
|
bool isIntoTrash = ( url.protocol() == "trash" || url.url().startsWith( "system:/trash" ) ) && !isCurrentTrash; // trashed file, not trash:/ itself
|
2007-08-03 06:40:12 +00:00
|
|
|
//kDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded;
|
2004-11-02 12:45:38 +00:00
|
|
|
bool isSingleMedium = m_lstItems.count() == 1 && mediaFiles;
|
1999-09-28 00:27:57 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
addGroup( "topactions" ); // used e.g. for ShowMenuBar. includes a separator at the end
|
2000-04-01 17:09:44 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
QAction * act;
|
2003-07-04 04:27:59 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
bool isKDesktop = false; //QByteArray( kapp->objectName().toUtf8() ) == "kdesktop";
|
2007-01-08 22:39:24 +00:00
|
|
|
QAction *actNewWindow = 0;
|
2003-07-04 04:27:59 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
#if 0
|
|
|
|
if (( flags & KParts::BrowserExtension::ShowProperties ) && isKDesktop &&
|
2005-10-03 10:50:16 +00:00
|
|
|
!KAuthorized::authorizeKAction("editable_desktop_icons"))
|
2003-08-29 11:57:06 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
flags &= ~KParts::BrowserExtension::ShowProperties; // remove flag
|
2003-08-29 11:57:06 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
#endif
|
2003-08-29 11:57:06 +00:00
|
|
|
|
2003-10-09 14:02:59 +00:00
|
|
|
// Either 'newview' is in the actions we're given (probably in the tabhandling group)
|
|
|
|
// or we need to insert it ourselves (e.g. for kdesktop). In the first case, actNewWindow must remain 0.
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( ((kpf & KonqPopupMenu::ShowNewWindow) != 0) && sReading )
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2003-10-09 14:02:59 +00:00
|
|
|
QString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" );
|
2007-01-08 22:39:24 +00:00
|
|
|
actNewWindow = m_ownActions.addAction( "newview" );
|
2007-03-08 19:32:19 +00:00
|
|
|
actNewWindow->setIcon( KIcon("window-new") );
|
2007-01-08 22:39:24 +00:00
|
|
|
actNewWindow->setText( openStr );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(actNewWindow, SIGNAL(triggered()), q, SLOT(slotPopupNewView()));
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2000-03-18 15:19:43 +00:00
|
|
|
|
2003-10-09 14:02:59 +00:00
|
|
|
if ( actNewWindow && !isKDesktop )
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
|
|
|
if (isCurrentTrash)
|
2004-12-20 18:11:51 +00:00
|
|
|
actNewWindow->setToolTip( i18n( "Open the trash in a new window" ) );
|
2004-11-02 12:45:38 +00:00
|
|
|
else if (isSingleMedium)
|
2004-12-20 18:11:51 +00:00
|
|
|
actNewWindow->setToolTip( i18n( "Open the medium in a new window") );
|
2003-08-05 15:04:54 +00:00
|
|
|
else
|
2004-12-20 18:11:51 +00:00
|
|
|
actNewWindow->setToolTip( i18n( "Open the document in a new window" ) );
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2000-04-01 17:09:44 +00:00
|
|
|
|
2007-10-07 21:12:46 +00:00
|
|
|
if ( isDirectory && sWriting && !isCurrentTrash ) // A dir, and we can create things into it
|
2003-01-26 21:31:52 +00:00
|
|
|
{
|
2004-11-10 13:43:14 +00:00
|
|
|
if ( currentDir && m_pMenuNew ) // Current dir -> add the "new" menu
|
2003-10-09 14:02:59 +00:00
|
|
|
{
|
2004-11-10 13:43:14 +00:00
|
|
|
// As requested by KNewMenu :
|
|
|
|
m_pMenuNew->slotCheckUpToDate();
|
|
|
|
m_pMenuNew->setPopupFiles( m_lstPopupURLs );
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
q->addAction( m_pMenuNew );
|
|
|
|
q->addSeparator();
|
2003-10-09 14:02:59 +00:00
|
|
|
}
|
2004-11-10 13:43:14 +00:00
|
|
|
else
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowCreateDirectory)
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2007-01-08 22:39:24 +00:00
|
|
|
QAction *actNewDir = m_ownActions.addAction( "newdir" );
|
2007-03-08 19:32:19 +00:00
|
|
|
actNewDir->setIcon( KIcon("folder-new") );
|
2007-01-08 22:39:24 +00:00
|
|
|
actNewDir->setText( i18n( "Create &Folder..." ) );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(actNewDir, SIGNAL(triggered()), q, SLOT(slotPopupNewDir()));
|
|
|
|
q->addAction( actNewDir );
|
|
|
|
q->addSeparator();
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-10 13:43:14 +00:00
|
|
|
} else if ( isIntoTrash ) {
|
|
|
|
// Trashed item, offer restoring
|
2007-01-08 22:39:24 +00:00
|
|
|
act = m_ownActions.addAction( "restore" );
|
|
|
|
act->setText( i18n( "&Restore" ) );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupRestoreTrashedItems()));
|
|
|
|
q->addAction(act);
|
2004-11-10 13:43:14 +00:00
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowNavigationItems)
|
2004-11-10 13:43:14 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowUp)
|
2007-10-16 18:55:44 +00:00
|
|
|
addNamedAction( "go_up" );
|
|
|
|
addNamedAction( "go_back" );
|
|
|
|
addNamedAction( "go_forward" );
|
2007-10-01 17:06:34 +00:00
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowReload)
|
|
|
|
addNamedAction( "reload" );
|
|
|
|
q->addSeparator();
|
2004-11-10 13:43:14 +00:00
|
|
|
}
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2004-11-10 13:43:14 +00:00
|
|
|
// "open in new window" is either provided by us, or by the tabhandling group
|
2007-10-01 17:06:34 +00:00
|
|
|
if (actNewWindow) {
|
|
|
|
q->addAction(actNewWindow);
|
|
|
|
q->addSeparator();
|
2004-11-10 13:43:14 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
addGroup( "tabhandling" ); // includes a separator at the end
|
2001-12-11 17:40:02 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowUrlOperations) {
|
2004-11-10 13:43:14 +00:00
|
|
|
if ( !currentDir && sReading ) {
|
|
|
|
if ( sDeleting ) {
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "cut" );
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "copy" );
|
2004-11-10 13:43:14 +00:00
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2007-10-07 21:12:46 +00:00
|
|
|
if ( isDirectory && sWriting ) {
|
2004-11-10 13:43:14 +00:00
|
|
|
if ( currentDir )
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "paste" );
|
2004-11-10 13:43:14 +00:00
|
|
|
else
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "pasteto" );
|
2004-11-10 13:43:14 +00:00
|
|
|
}
|
|
|
|
if ( !currentDir )
|
|
|
|
{
|
2005-01-18 10:10:23 +00:00
|
|
|
if ( m_lstItems.count() == 1 && sMoving )
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "rename" );
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2005-04-05 15:14:14 +00:00
|
|
|
bool addTrash = false;
|
|
|
|
bool addDel = false;
|
|
|
|
|
2005-01-18 10:10:23 +00:00
|
|
|
if ( sMoving && !isIntoTrash && !isTrashLink )
|
2005-04-05 15:14:14 +00:00
|
|
|
addTrash = true;
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2004-11-10 13:43:14 +00:00
|
|
|
if ( sDeleting ) {
|
2005-01-23 09:31:31 +00:00
|
|
|
if ( !isLocal )
|
2005-04-05 15:14:14 +00:00
|
|
|
addDel = true;
|
2005-10-21 14:36:26 +00:00
|
|
|
else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
|
2005-04-05 15:14:14 +00:00
|
|
|
addTrash = false;
|
|
|
|
addDel = true;
|
|
|
|
}
|
2005-01-23 09:31:31 +00:00
|
|
|
else {
|
2005-11-08 10:20:07 +00:00
|
|
|
KConfigGroup configGroup( KGlobal::config(), "KDE" );
|
2007-02-09 16:55:14 +00:00
|
|
|
if ( configGroup.readEntry( "ShowDeleteCommand", false) )
|
2005-04-05 15:14:14 +00:00
|
|
|
addDel = true;
|
2005-01-23 09:31:31 +00:00
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2005-04-05 15:14:14 +00:00
|
|
|
|
|
|
|
if ( addTrash )
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "trash" );
|
2005-04-05 15:14:14 +00:00
|
|
|
if ( addDel )
|
2007-10-01 17:06:34 +00:00
|
|
|
addNamedAction( "del" );
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-10 13:43:14 +00:00
|
|
|
if ( isCurrentTrash )
|
|
|
|
{
|
2007-01-08 22:39:24 +00:00
|
|
|
act = m_ownActions.addAction( "emptytrash" );
|
2007-10-22 15:58:52 +00:00
|
|
|
act->setIcon( KIcon("trash-empty") );
|
2007-01-08 22:39:24 +00:00
|
|
|
act->setText( i18n( "&Empty Trash Bin" ) );
|
2007-02-20 07:00:30 +00:00
|
|
|
KConfig trashConfig( "trashrc", KConfig::OnlyLocal);
|
|
|
|
act->setEnabled( !trashConfig.group("Status").readEntry( "Empty", true ) );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupEmptyTrashBin()));
|
|
|
|
q->addAction(act);
|
2004-11-10 13:43:14 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
// This is used by KHTML, see khtml_popupmenu.rc (copy, selectAll, searchProvider etc.)
|
|
|
|
// TODO: move cut/copy/paste/etc. to konqueror or dolphinpart, as "editactions" too...
|
|
|
|
// Ideally in dolphinpart but the popupmenu code is in konq...
|
|
|
|
// Then we can remove ShowUrlOperations from PopupFlag
|
|
|
|
// We need a BrowserExtension::setActions(const QString& group, QList<QAction *> actions)?
|
|
|
|
addGroup( "editactions" ); // see khtml
|
|
|
|
|
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowTextSelectionItems) {
|
|
|
|
// OK, we have to stop here.
|
|
|
|
|
|
|
|
// Anything else that is provided by the part
|
|
|
|
addGroup( "partactions" );
|
|
|
|
return;
|
2004-03-30 15:58:57 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( !isCurrentTrash && !isIntoTrash && (m_itemFlags & KParts::BrowserExtension::ShowBookmark))
|
2001-12-11 17:40:02 +00:00
|
|
|
{
|
2003-09-11 20:24:01 +00:00
|
|
|
QString caption;
|
|
|
|
if (currentDir)
|
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
const bool httpPage = m_sViewURL.protocol().startsWith("http", Qt::CaseInsensitive);
|
2003-09-11 20:24:01 +00:00
|
|
|
if (httpPage)
|
|
|
|
caption = i18n("&Bookmark This Page");
|
|
|
|
else
|
|
|
|
caption = i18n("&Bookmark This Location");
|
|
|
|
}
|
2007-10-07 21:12:46 +00:00
|
|
|
else if (isDirectory)
|
2003-10-21 23:11:41 +00:00
|
|
|
caption = i18n("&Bookmark This Folder");
|
2003-09-12 16:25:11 +00:00
|
|
|
else if (bIsLink)
|
2003-09-11 20:24:01 +00:00
|
|
|
caption = i18n("&Bookmark This Link");
|
2003-09-12 16:25:11 +00:00
|
|
|
else
|
|
|
|
caption = i18n("&Bookmark This File");
|
2003-09-26 07:53:17 +00:00
|
|
|
|
2007-01-08 22:39:24 +00:00
|
|
|
act = m_ownActions.addAction( "bookmark_add" );
|
2007-03-08 19:32:19 +00:00
|
|
|
act->setIcon( KIcon("bookmark-new") );
|
2007-01-08 22:39:24 +00:00
|
|
|
act->setText( caption );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupAddToBookmark()));
|
2003-09-11 20:24:01 +00:00
|
|
|
if (m_lstItems.count() > 1)
|
|
|
|
act->setEnabled(false);
|
2005-10-03 10:21:33 +00:00
|
|
|
if (KAuthorized::authorizeKAction("bookmarks"))
|
2007-10-01 17:06:34 +00:00
|
|
|
q->addAction( act );
|
2003-09-12 16:25:11 +00:00
|
|
|
if (bIsLink)
|
2007-10-01 17:06:34 +00:00
|
|
|
addGroup( "linkactions" ); // see khtml
|
1999-10-17 15:19:54 +00:00
|
|
|
}
|
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
//////////////////////////////////////////////////////
|
2002-03-07 13:00:03 +00:00
|
|
|
|
2007-10-07 21:12:46 +00:00
|
|
|
if ( sReading ) {
|
2006-05-22 07:59:05 +00:00
|
|
|
KService::List offers;
|
2007-10-01 17:06:34 +00:00
|
|
|
if (KAuthorized::authorizeKAction("openwith")) {
|
2006-09-15 04:09:35 +00:00
|
|
|
QString constraint = "DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'";
|
2005-01-26 23:57:41 +00:00
|
|
|
QString subConstraint = " and '%1' in ServiceTypes";
|
|
|
|
|
|
|
|
QStringList::ConstIterator it = mimeTypeList.begin();
|
|
|
|
QStringList::ConstIterator end = mimeTypeList.end();
|
|
|
|
Q_ASSERT( it != end );
|
|
|
|
QString first = *it;
|
|
|
|
++it;
|
|
|
|
while ( it != end ) {
|
|
|
|
constraint += subConstraint.arg( *it );
|
|
|
|
++it;
|
|
|
|
}
|
2004-12-10 21:35:06 +00:00
|
|
|
|
2006-09-15 04:09:35 +00:00
|
|
|
offers = KMimeTypeTrader::self()->query( first, "Application", constraint );
|
2003-07-28 22:06:29 +00:00
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
|
|
|
|
//// Ok, we have everything, now insert
|
|
|
|
|
|
|
|
m_mapPopup.clear();
|
2004-09-24 09:20:59 +00:00
|
|
|
// "Open With..." for folders is really not very useful, especially for remote folders.
|
2004-11-02 12:45:38 +00:00
|
|
|
// (media:/something, or trash:/, or ftp://...)
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( !isDirectory || isLocal ) {
|
|
|
|
if ( !q->actions().isEmpty() )
|
|
|
|
q->addSeparator();
|
2004-09-06 18:40:43 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( !offers.isEmpty() ) {
|
2003-08-31 13:38:31 +00:00
|
|
|
// First block, app and preview offers
|
|
|
|
id = 1;
|
1999-12-18 20:30:37 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
QMenu* menu = q;
|
2003-01-12 16:30:51 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( offers.count() > 1 ) { // submenu 'open with'
|
|
|
|
menu = new QMenu(i18n("&Open With"), q);
|
|
|
|
menu->menuAction()->setObjectName("openWith_submenu"); // for the unittest
|
|
|
|
q->addMenu(menu);
|
2003-08-31 13:38:31 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
kDebug() << offers.count() << "offers" << q << menu;
|
1999-04-27 09:04:36 +00:00
|
|
|
|
2006-05-22 07:59:05 +00:00
|
|
|
KService::List::ConstIterator it = offers.begin();
|
2007-10-01 17:06:34 +00:00
|
|
|
for( ; it != offers.end(); it++ ) {
|
2006-06-13 18:15:17 +00:00
|
|
|
KService::Ptr service = (*it);
|
2006-10-10 11:14:59 +00:00
|
|
|
|
|
|
|
// Skip OnlyShowIn=Foo and NotShowIn=KDE entries,
|
|
|
|
// but still offer NoDisplay=true entries, that's the
|
|
|
|
// whole point of such desktop files. This is why we don't
|
|
|
|
// use service->noDisplay() here.
|
|
|
|
const QString onlyShowIn = service->property("OnlyShowIn", QVariant::String).toString();
|
|
|
|
if ( !onlyShowIn.isEmpty() ) {
|
2007-04-05 14:23:22 +00:00
|
|
|
const QStringList aList = onlyShowIn.split(';', QString::SkipEmptyParts);
|
2006-10-10 11:14:59 +00:00
|
|
|
if (!aList.contains("KDE"))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const QString notShowIn = service->property("NotShowIn", QVariant::String).toString();
|
|
|
|
if ( !notShowIn.isEmpty() ) {
|
2007-04-05 14:23:22 +00:00
|
|
|
const QStringList aList = notShowIn.split(';', QString::SkipEmptyParts);
|
2006-10-10 11:14:59 +00:00
|
|
|
if (aList.contains("KDE"))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
QString actionName( service->name().replace( '&', "&&" ) );
|
|
|
|
if ( menu == q ) // no submenu -> prefix single offer
|
|
|
|
actionName = i18n( "Open with %1", actionName );
|
2005-06-06 17:33:25 +00:00
|
|
|
|
2007-10-07 21:12:46 +00:00
|
|
|
act = new QAction(&m_ownActions);
|
2007-01-08 22:39:24 +00:00
|
|
|
act->setIcon( KIcon( service->icon() ) );
|
|
|
|
act->setText( actionName );
|
2007-10-01 17:06:34 +00:00
|
|
|
m_runServiceActionGroup.addAction(act);
|
|
|
|
menu->addAction(act);
|
2000-04-01 17:09:44 +00:00
|
|
|
|
2007-10-07 21:12:46 +00:00
|
|
|
m_mapPopup.insert(act, *it);
|
2003-08-31 13:38:31 +00:00
|
|
|
}
|
2000-03-19 00:44:31 +00:00
|
|
|
|
2005-06-06 20:14:34 +00:00
|
|
|
QString openWithActionName;
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( menu != q ) { // submenu
|
|
|
|
menu->addSeparator();
|
2005-06-06 20:14:34 +00:00
|
|
|
openWithActionName = i18n( "&Other..." );
|
2007-10-01 17:06:34 +00:00
|
|
|
} else {
|
2005-06-06 20:14:34 +00:00
|
|
|
openWithActionName = i18n( "&Open With..." );
|
2003-08-31 13:38:31 +00:00
|
|
|
}
|
2007-01-08 22:39:24 +00:00
|
|
|
QAction *openWithAct = m_ownActions.addAction( "openwith" );
|
|
|
|
openWithAct->setText( openWithActionName );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(openWithAct, SIGNAL(triggered()), q, SLOT(slotPopupOpenWith()));
|
|
|
|
menu->addAction(openWithAct);
|
2003-08-31 13:38:31 +00:00
|
|
|
}
|
|
|
|
else // no app offers -> Open With...
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2007-01-08 22:39:24 +00:00
|
|
|
act = m_ownActions.addAction( "openwith" );
|
|
|
|
act->setText( i18n( "&Open With..." ) );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupOpenWith()));
|
|
|
|
q->addAction(act);
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2000-04-08 20:31:49 +00:00
|
|
|
|
2003-08-31 13:38:31 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
QList<QAction *> previewActions = m_actionGroups.value("preview");
|
|
|
|
if (!previewActions.isEmpty()) {
|
|
|
|
if (previewActions.count() == 1) {
|
|
|
|
q->addAction(previewActions.first());
|
|
|
|
} else {
|
|
|
|
QMenu* subMenu = new QMenu(i18n("Preview In"), q);
|
|
|
|
subMenu->menuAction()->setObjectName("preview_submenu"); // for the unittest
|
|
|
|
q->addMenu(subMenu);
|
|
|
|
subMenu->addActions(previewActions);
|
|
|
|
}
|
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2003-12-21 10:01:10 +00:00
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
// Second block, builtin + user
|
2007-10-07 21:12:46 +00:00
|
|
|
m_menuActions.setItems(m_lstItems);
|
|
|
|
if ( m_menuActions.addActionsTo(q) > 0 ) {
|
2007-10-01 17:06:34 +00:00
|
|
|
q->addSeparator();
|
2003-12-21 10:01:10 +00:00
|
|
|
}
|
2003-05-19 17:24:46 +00:00
|
|
|
|
2004-11-02 12:45:38 +00:00
|
|
|
if ( !isCurrentTrash && !isIntoTrash && !mediaFiles && sReading )
|
2004-09-24 08:04:33 +00:00
|
|
|
addPlugins(); // now it's time to add plugins
|
1999-12-18 20:30:37 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( (m_itemFlags & KParts::BrowserExtension::ShowProperties) && KPropertiesDialog::canDisplay( m_lstItems ) ) {
|
2007-01-08 22:39:24 +00:00
|
|
|
act = m_ownActions.addAction( "properties" );
|
|
|
|
act->setText( i18n( "&Properties" ) );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupProperties()));
|
|
|
|
q->addAction(act);
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2000-04-01 17:09:44 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
while ( !q->actions().isEmpty() &&
|
|
|
|
q->actions().last()->isSeparator() )
|
|
|
|
delete q->actions().last();
|
2000-07-13 11:11:35 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
if ( isDirectory && isLocal ) {
|
|
|
|
if ( KFileShare::authorization() == KFileShare::Authorized ) {
|
|
|
|
q->addSeparator();
|
2007-01-08 22:39:24 +00:00
|
|
|
act = m_ownActions.addAction( "sharefile" );
|
|
|
|
act->setText( i18n("Share") );
|
2007-10-01 17:06:34 +00:00
|
|
|
QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotOpenShareFileDialog()));
|
|
|
|
q->addAction(act);
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-16 17:06:27 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
// Anything else that is provided by the part
|
|
|
|
addGroup( "partactions" );
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotOpenShareFileDialog()
|
2002-04-16 17:06:27 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KPropertiesDialog* dlg = new KPropertiesDialog( m_lstItems, m_parentWidget );
|
2002-06-17 10:52:42 +00:00
|
|
|
dlg->showFileSharingPage();
|
2006-12-26 10:27:29 +00:00
|
|
|
dlg->exec();
|
2002-04-16 17:06:27 +00:00
|
|
|
}
|
|
|
|
|
1999-04-27 09:04:36 +00:00
|
|
|
KonqPopupMenu::~KonqPopupMenu()
|
|
|
|
{
|
2001-12-12 14:10:22 +00:00
|
|
|
delete d;
|
2007-08-03 06:40:12 +00:00
|
|
|
//kDebug(1203) << "~KonqPopupMenu leave";
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
|
2002-02-27 04:44:03 +00:00
|
|
|
void KonqPopupMenu::setURLTitle( const QString& urlTitle )
|
|
|
|
{
|
|
|
|
d->m_urlTitle = urlTitle;
|
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupNewView()
|
1999-04-27 09:04:36 +00:00
|
|
|
{
|
2006-01-24 08:32:09 +00:00
|
|
|
KUrl::List::ConstIterator it = m_lstPopupURLs.begin();
|
1999-04-27 09:04:36 +00:00
|
|
|
for ( ; it != m_lstPopupURLs.end(); it++ )
|
2007-10-01 17:06:34 +00:00
|
|
|
(void) new KRun(*it, m_parentWidget);
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupNewDir()
|
2001-12-12 14:10:22 +00:00
|
|
|
{
|
2003-08-30 16:40:14 +00:00
|
|
|
if (m_lstPopupURLs.empty())
|
|
|
|
return;
|
2003-08-31 10:21:01 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
KonqOperations::newDir(m_parentWidget, m_lstPopupURLs.first());
|
2001-12-12 14:10:22 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupEmptyTrashBin()
|
1999-04-27 09:04:36 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KonqOperations::emptyTrash( m_parentWidget );
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupRestoreTrashedItems()
|
2004-09-07 18:25:28 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KonqOperations::restoreTrashedItems( m_lstPopupURLs, m_parentWidget );
|
2004-09-07 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupOpenWith()
|
1999-04-27 09:04:36 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KRun::displayOpenWithDialog( m_lstPopupURLs, m_parentWidget );
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupAddToBookmark()
|
1999-04-27 09:04:36 +00:00
|
|
|
{
|
2004-09-13 09:15:09 +00:00
|
|
|
KBookmarkGroup root;
|
2002-02-27 04:44:03 +00:00
|
|
|
if ( m_lstPopupURLs.count() == 1 ) {
|
2006-01-24 08:32:09 +00:00
|
|
|
KUrl url = m_lstPopupURLs.first();
|
2007-10-01 17:06:34 +00:00
|
|
|
QString title = m_urlTitle.isEmpty() ? url.prettyUrl() : m_urlTitle;
|
|
|
|
KBookmarkDialog dlg(m_bookmarkManager, m_parentWidget);
|
|
|
|
dlg.addBookmark(title, url.url());
|
2002-02-27 04:44:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
root = m_bookmarkManager->root();
|
2006-01-24 08:32:09 +00:00
|
|
|
KUrl::List::ConstIterator it = m_lstPopupURLs.begin();
|
2002-02-27 04:44:03 +00:00
|
|
|
for ( ; it != m_lstPopupURLs.end(); it++ )
|
2007-08-13 09:27:01 +00:00
|
|
|
root.addBookmark( (*it).prettyUrl(), (*it) );
|
2007-10-01 17:06:34 +00:00
|
|
|
m_bookmarkManager->emitChanged( root );
|
2002-02-27 04:44:03 +00:00
|
|
|
}
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotRunService(QAction* act)
|
1999-04-27 09:04:36 +00:00
|
|
|
{
|
2000-03-19 00:44:31 +00:00
|
|
|
// Is it a usual service (application)
|
2007-10-07 21:12:46 +00:00
|
|
|
QMap<QAction*,KService::Ptr>::Iterator it = m_mapPopup.find(act);
|
|
|
|
if (it != m_mapPopup.end()) {
|
|
|
|
KRun::run(**it, m_lstPopupURLs, m_parentWidget);
|
1999-04-27 09:04:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupMimeType()
|
1999-09-24 22:47:25 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KonqOperations::editMimeType( m_sMimeType, m_parentWidget );
|
1999-09-24 22:47:25 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupProperties()
|
2004-09-24 07:56:05 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KPropertiesDialog::showDialog( m_lstItems, m_parentWidget );
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
QString KonqPopupMenu::mimeType() const
|
2001-05-01 10:04:44 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
return d->m_sMimeType;
|
2001-05-01 10:04:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
#if 0
|
|
|
|
KonqPopupMenu::ProtocolInfo KonqPopupMenu::protocolInfo() const
|
2004-09-24 08:04:33 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
return d->m_info;
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
#endif
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::addGroup(const QString& name)
|
2002-01-21 20:46:23 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
QList<QAction *> actions = m_actionGroups.value(name);
|
|
|
|
q->addActions(actions);
|
2002-01-21 20:46:23 +00:00
|
|
|
}
|
2000-04-01 17:09:44 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::addPlugins()
|
2004-09-24 08:04:33 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
#if 0
|
2004-09-24 08:04:33 +00:00
|
|
|
//search for a plugin with the right protocol
|
2006-05-22 07:59:05 +00:00
|
|
|
KService::List plugin_offers;
|
2004-09-24 08:04:33 +00:00
|
|
|
unsigned int pluginCount = 0;
|
2006-07-16 14:13:23 +00:00
|
|
|
plugin_offers = KMimeTypeTrader::self()->query( m_sMimeType.isNull() ? QLatin1String( "all/all" ) : m_sMimeType, "KonqPopupMenu/Plugin" );
|
2004-09-24 08:04:33 +00:00
|
|
|
if ( plugin_offers.isEmpty() )
|
|
|
|
return; // no plugins installed do not bother about it
|
|
|
|
|
2006-05-22 07:59:05 +00:00
|
|
|
KService::List::ConstIterator iterator = plugin_offers.begin();
|
2007-10-01 17:06:34 +00:00
|
|
|
const KService::List::ConstIterator end = plugin_offers.end();
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
//addGroup( "plugins" );
|
2004-09-24 08:04:33 +00:00
|
|
|
// travers the offerlist
|
|
|
|
for(; iterator != end; ++iterator, ++pluginCount ) {
|
2007-08-03 06:40:12 +00:00
|
|
|
//kDebug() << (*iterator)->library();
|
2004-09-24 08:04:33 +00:00
|
|
|
KonqPopupMenuPlugin *plugin =
|
2005-10-04 08:49:51 +00:00
|
|
|
KLibLoader::createInstance<KonqPopupMenuPlugin>( QFile::encodeName( (*iterator)->library() ),
|
2007-10-01 17:06:34 +00:00
|
|
|
q );
|
2004-09-24 08:04:33 +00:00
|
|
|
if ( !plugin )
|
|
|
|
continue;
|
2006-05-11 19:40:14 +00:00
|
|
|
plugin->setObjectName( (*iterator)->name() );
|
2007-10-01 17:06:34 +00:00
|
|
|
// This made the kuick plugin insert its items at the right place
|
|
|
|
// ### TODO replace with new mechanism (e.g. addAction(QAction *) in the plugin code),
|
|
|
|
// if plugins are kept
|
2004-09-24 08:04:33 +00:00
|
|
|
QString pluginClientName = QString::fromLatin1( "Plugin%1" ).arg( pluginCount );
|
|
|
|
addMerge( pluginClientName );
|
|
|
|
plugin->domDocument().documentElement().setAttribute( "name", pluginClientName );
|
|
|
|
insertChildClient( plugin );
|
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
#endif
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
2004-09-06 18:40:43 +00:00
|
|
|
|
2006-01-24 08:32:09 +00:00
|
|
|
KUrl KonqPopupMenu::url() const // ### should be viewURL()
|
2004-09-24 08:04:33 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
return d->m_sViewURL;
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
2004-09-06 18:40:43 +00:00
|
|
|
|
2004-09-24 08:04:33 +00:00
|
|
|
KFileItemList KonqPopupMenu::fileItemList() const
|
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
return d->m_lstItems;
|
2000-04-04 22:24:42 +00:00
|
|
|
}
|
2004-09-06 18:40:43 +00:00
|
|
|
|
2006-01-24 08:32:09 +00:00
|
|
|
KUrl::List KonqPopupMenu::popupURLList() const
|
2004-09-24 08:04:33 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
return d->m_lstPopupURLs;
|
2000-04-09 09:41:40 +00:00
|
|
|
}
|
2004-09-06 18:40:43 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
#if 0
|
2001-10-30 18:09:01 +00:00
|
|
|
/**
|
2004-04-20 23:07:20 +00:00
|
|
|
Plugin
|
2001-10-30 18:09:01 +00:00
|
|
|
*/
|
2000-04-08 20:31:49 +00:00
|
|
|
|
2006-05-16 15:53:02 +00:00
|
|
|
KonqPopupMenuPlugin::KonqPopupMenuPlugin( KonqPopupMenu *parent )
|
2006-04-02 06:34:44 +00:00
|
|
|
: QObject( parent )
|
2004-09-24 08:04:33 +00:00
|
|
|
{
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
|
|
|
|
2004-09-24 08:04:33 +00:00
|
|
|
KonqPopupMenuPlugin::~KonqPopupMenuPlugin()
|
|
|
|
{
|
2001-10-30 18:09:01 +00:00
|
|
|
}
|
2007-10-01 17:06:34 +00:00
|
|
|
#endif
|
2004-09-24 08:04:33 +00:00
|
|
|
|
2000-07-27 09:23:48 +00:00
|
|
|
#include "konq_popupmenu.moc"
|