1999-05-12 02:26:56 +00:00
|
|
|
/* This file is part of the KDE project
|
2008-05-20 20:11:03 +00:00
|
|
|
Copyright (C) 1998-2008 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"
|
2008-05-20 20:47:26 +00:00
|
|
|
#include "konq_popupmenuplugin.h"
|
2008-05-19 17:34:10 +00:00
|
|
|
#include "konq_popupmenuinformation.h"
|
2008-04-02 11:42:08 +00:00
|
|
|
#include "konq_copytomenu.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
|
|
|
|
2008-05-20 20:11:03 +00:00
|
|
|
#include <QFileInfo>
|
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
|
2008-04-02 11:42:08 +00:00
|
|
|
folder on the desktop
|
|
|
|
trash link on the desktop
|
2004-09-07 16:30:13 +00:00
|
|
|
trashed file or directory
|
|
|
|
application .desktop file
|
2008-05-20 20:47:26 +00:00
|
|
|
Then the same after uninstalling kdeaddons/konq-plugins (arkplugin in particular)
|
2004-09-06 18:40:43 +00:00
|
|
|
*/
|
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_itemFlags(KParts::BrowserExtension::DefaultPopupItems),
|
|
|
|
m_actions(actions),
|
2008-05-19 17:34:10 +00:00
|
|
|
m_ownActions(static_cast<QWidget *>(0))
|
2007-10-01 17:06:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
void addNamedAction(const QString& name);
|
|
|
|
void addGroup(const QString& name);
|
|
|
|
void addPlugins();
|
2008-05-20 20:47:26 +00:00
|
|
|
void init(KonqPopupMenu::Flags kpf, KParts::BrowserExtension::PopupFlags itemFlags);
|
2007-10-01 17:06:34 +00:00
|
|
|
|
|
|
|
void slotPopupNewDir();
|
|
|
|
void slotPopupNewView();
|
|
|
|
void slotPopupEmptyTrashBin();
|
|
|
|
void slotPopupRestoreTrashedItems();
|
|
|
|
void slotPopupAddToBookmark();
|
|
|
|
void slotPopupMimeType();
|
|
|
|
void slotPopupProperties();
|
|
|
|
void slotOpenShareFileDialog();
|
|
|
|
|
|
|
|
KonqPopupMenu* q;
|
|
|
|
QString m_urlTitle;
|
|
|
|
KParts::BrowserExtension::PopupFlags m_itemFlags;
|
|
|
|
KNewMenu *m_pMenuNew;
|
|
|
|
KUrl m_sViewURL;
|
2008-05-20 20:47:26 +00:00
|
|
|
KonqPopupMenuInformation m_popupMenuInfo;
|
2007-10-07 21:12:46 +00:00
|
|
|
KonqMenuActions m_menuActions;
|
2008-04-02 11:42:08 +00:00
|
|
|
KonqCopyToMenu m_copyToMenu;
|
2007-10-01 17:06:34 +00:00
|
|
|
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
|
|
|
KParts::BrowserExtension::ActionGroupMap m_actionGroups;
|
2001-12-12 14:10:22 +00:00
|
|
|
};
|
2002-02-27 04:44:03 +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)
|
2008-05-20 20:11:03 +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_bookmarkManager = mgr;
|
2008-05-20 20:47:26 +00:00
|
|
|
d->m_popupMenuInfo.setItems(items);
|
|
|
|
d->m_popupMenuInfo.setParentWidget(parentWidget);
|
|
|
|
d->init(kpf, flags);
|
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
|
|
|
|
2008-05-20 20:47:26 +00:00
|
|
|
void KonqPopupMenuPrivate::init(KonqPopupMenu::Flags kpf, KParts::BrowserExtension::PopupFlags flags)
|
2002-11-20 11:35:24 +00:00
|
|
|
{
|
2008-05-20 20:11:03 +00:00
|
|
|
m_ownActions.setObjectName("KonqPopupMenu::m_ownActions");
|
|
|
|
m_itemFlags = flags;
|
|
|
|
q->setFont(KGlobalSettings::menuFont());
|
|
|
|
|
2008-05-20 20:47:26 +00:00
|
|
|
Q_ASSERT(m_popupMenuInfo.items().count() >= 1);
|
2003-08-05 15:04:54 +00:00
|
|
|
|
|
|
|
bool bTrashIncluded = false;
|
2008-05-22 03:07:08 +00:00
|
|
|
|
|
|
|
KFileItemList lstItems = m_popupMenuInfo.items();
|
|
|
|
KFileItemList::const_iterator it = lstItems.begin();
|
|
|
|
const KFileItemList::const_iterator kend = lstItems.end();
|
2006-01-10 08:57:20 +00:00
|
|
|
for ( ; it != kend; ++it )
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2008-06-02 14:30:26 +00:00
|
|
|
const KUrl url = (*it).url();
|
2005-06-03 23:18:33 +00:00
|
|
|
if ( !bTrashIncluded && (
|
2008-05-19 17:34:10 +00:00
|
|
|
( url.protocol() == "trash" && url.path().length() <= 1 ) ) ) {
|
2003-08-05 15:04:54 +00:00
|
|
|
bTrashIncluded = true;
|
2008-04-02 11:42:08 +00:00
|
|
|
}
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2008-05-19 17:34:10 +00:00
|
|
|
|
2008-05-20 20:47:26 +00:00
|
|
|
const bool isDirectory = m_popupMenuInfo.isDirectory();
|
2008-06-02 14:30:26 +00:00
|
|
|
const bool sReading = m_popupMenuInfo.capabilities().supportsReading();
|
|
|
|
bool sDeleting = (m_itemFlags & KParts::BrowserExtension::NoDeletion) == 0
|
|
|
|
&& m_popupMenuInfo.capabilities().supportsDeleting();
|
|
|
|
const bool sWriting = m_popupMenuInfo.capabilities().supportsWriting();
|
|
|
|
const bool sMoving = sDeleting && m_popupMenuInfo.capabilities().supportsMoving();
|
|
|
|
const bool isLocal = m_popupMenuInfo.capabilities().isLocal();
|
|
|
|
|
|
|
|
KUrl url = m_sViewURL;
|
2003-08-05 15:04:54 +00:00
|
|
|
url.cleanPath();
|
|
|
|
|
2008-06-02 14:30:26 +00:00
|
|
|
bool isTrashLink = false;
|
|
|
|
bool isCurrentTrash = false;
|
|
|
|
bool currentDir = false;
|
|
|
|
|
2003-08-05 15:04:54 +00:00
|
|
|
//check if url is current directory
|
2008-05-20 20:47:26 +00:00
|
|
|
if ( m_popupMenuInfo.items().count() == 1 )
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
KUrl firstPopupURL( m_popupMenuInfo.items().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 );
|
2008-05-20 20:47:26 +00:00
|
|
|
if ( isLocal && m_popupMenuInfo.mimeType() == "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
|
|
|
}
|
|
|
|
|
2008-06-02 14:30:26 +00:00
|
|
|
if (isTrashLink) {
|
2005-06-03 13:54:25 +00:00
|
|
|
sDeleting = false;
|
2005-01-18 10:10:23 +00:00
|
|
|
}
|
2008-06-02 14:30:26 +00:00
|
|
|
|
|
|
|
// isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
|
|
|
|
isCurrentTrash = (firstPopupURL.protocol() == "trash" && firstPopupURL.path().length() <= 1)
|
|
|
|
|| isTrashLink;
|
2003-08-05 15:04:54 +00:00
|
|
|
}
|
2005-01-18 10:10:23 +00:00
|
|
|
|
2008-06-02 14:30:26 +00:00
|
|
|
const bool isIntoTrash = (url.protocol() == "trash") && !isCurrentTrash; // trashed file, not trash:/ itself
|
|
|
|
|
|
|
|
const bool bIsLink = (m_itemFlags & KParts::BrowserExtension::IsLink);
|
2003-01-26 21:31:52 +00:00
|
|
|
|
2007-08-03 06:40:12 +00:00
|
|
|
//kDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded;
|
2008-04-02 11:42:08 +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-01-08 22:39:24 +00:00
|
|
|
QAction *actNewWindow = 0;
|
2003-07-04 04:27:59 +00:00
|
|
|
|
2008-06-02 13:40:52 +00:00
|
|
|
#if 0 // TODO in the desktop code itself.
|
2008-04-02 11:42:08 +00:00
|
|
|
if (( flags & KParts::BrowserExtension::ShowProperties ) && isOnDesktop &&
|
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)
|
2008-06-02 13:40:52 +00:00
|
|
|
// or we need to insert it ourselves (e.g. for the desktop).
|
|
|
|
// 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
|
|
|
{
|
2008-06-02 13:40:52 +00:00
|
|
|
const QString openStr = i18n("&Open");
|
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
|
|
|
|
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
|
|
|
{
|
2008-10-13 21:54:03 +00:00
|
|
|
const bool mkdirRequested = m_itemFlags & KParts::BrowserExtension::ShowCreateDirectory;
|
|
|
|
if ( (currentDir || mkdirRequested) && 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();
|
2008-05-20 20:47:26 +00:00
|
|
|
m_pMenuNew->setPopupFiles(m_popupMenuInfo.urlList());
|
2004-11-10 13:43:14 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
q->addAction( m_pMenuNew );
|
|
|
|
q->addSeparator();
|
2003-10-09 14:02:59 +00:00
|
|
|
}
|
2008-10-13 21:54:03 +00:00
|
|
|
else if (mkdirRequested)
|
2003-08-05 15:04:54 +00:00
|
|
|
{
|
2008-10-13 21:54:03 +00:00
|
|
|
KAction *actNewDir = m_ownActions.addAction( "newdir" );
|
|
|
|
actNewDir->setIcon( KIcon("folder-new") );
|
|
|
|
actNewDir->setText( i18n( "Create &Folder..." ) );
|
|
|
|
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
|
|
|
}
|
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" ) );
|
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-02-20 07:00:30 +00:00
|
|
|
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-11-22 17:36:56 +00:00
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
// This is used by KHTML, see khtml_popupmenu.rc (copy, selectAll, searchProvider etc.)
|
2007-11-22 17:36:56 +00:00
|
|
|
// and by DolphinPart (rename, trash, delete)
|
|
|
|
addGroup( "editactions" );
|
2007-10-01 17:06:34 +00:00
|
|
|
|
|
|
|
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()));
|
2008-05-20 20:47:26 +00:00
|
|
|
if (m_popupMenuInfo.items().count() > 1)
|
2003-09-11 20:24:01 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-05-19 17:34:10 +00:00
|
|
|
// "Open With" actions
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2008-05-20 20:47:26 +00:00
|
|
|
m_menuActions.setPopupMenuInfo(m_popupMenuInfo);
|
2003-08-05 15:04:54 +00:00
|
|
|
|
2008-05-19 17:34:10 +00:00
|
|
|
if ( sReading ) {
|
|
|
|
m_menuActions.addOpenWithActionsTo(q, "DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'");
|
2000-04-08 20:31:49 +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
|
2008-04-02 11:42:08 +00:00
|
|
|
m_menuActions.addActionsTo(q);
|
|
|
|
|
|
|
|
q->addSeparator();
|
|
|
|
|
|
|
|
// CopyTo/MoveTo menus
|
|
|
|
if (m_itemFlags & KParts::BrowserExtension::ShowUrlOperations) {
|
2008-05-20 20:47:26 +00:00
|
|
|
m_copyToMenu.setItems(m_popupMenuInfo.items());
|
2008-04-02 11:42:08 +00:00
|
|
|
m_copyToMenu.setReadOnly(sMoving == false);
|
|
|
|
m_copyToMenu.addActionsTo(q);
|
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
|
|
|
|
2008-04-02 11:42:08 +00:00
|
|
|
if ( !isCurrentTrash && !isIntoTrash && 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
|
|
|
|
2008-05-20 20:47:26 +00:00
|
|
|
if ( (m_itemFlags & KParts::BrowserExtension::ShowProperties) && KPropertiesDialog::canDisplay( m_popupMenuInfo.items() ) ) {
|
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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
KPropertiesDialog* dlg = new KPropertiesDialog( m_popupMenuInfo.items(), m_popupMenuInfo.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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
Q_FOREACH(const KUrl& url, m_popupMenuInfo.urlList()) {
|
|
|
|
(void) new KRun(url, m_popupMenuInfo.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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
if (m_popupMenuInfo.urlList().empty())
|
2003-08-30 16:40:14 +00:00
|
|
|
return;
|
2003-08-31 10:21:01 +00:00
|
|
|
|
2008-05-20 20:47:26 +00:00
|
|
|
KonqOperations::newDir(m_popupMenuInfo.parentWidget(), m_popupMenuInfo.urlList().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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
KonqOperations::emptyTrash(m_popupMenuInfo.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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
KonqOperations::restoreTrashedItems(m_popupMenuInfo.urlList(), m_popupMenuInfo.parentWidget());
|
2004-09-07 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:06:34 +00:00
|
|
|
void KonqPopupMenuPrivate::slotPopupAddToBookmark()
|
1999-04-27 09:04:36 +00:00
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
KBookmarkGroup root;
|
|
|
|
if (m_popupMenuInfo.urlList().count() == 1) {
|
|
|
|
const KUrl url = m_popupMenuInfo.urlList().first();
|
|
|
|
const QString title = m_urlTitle.isEmpty() ? url.prettyUrl() : m_urlTitle;
|
|
|
|
KBookmarkDialog dlg(m_bookmarkManager, m_popupMenuInfo.parentWidget());
|
|
|
|
dlg.addBookmark(title, url.url());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
root = m_bookmarkManager->root();
|
|
|
|
Q_FOREACH(const KUrl& url, m_popupMenuInfo.urlList()) {
|
|
|
|
root.addBookmark(url.prettyUrl(), url);
|
|
|
|
}
|
|
|
|
m_bookmarkManager->emitChanged(root);
|
|
|
|
}
|
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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
KonqOperations::editMimeType(m_popupMenuInfo.mimeType(), m_popupMenuInfo.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
|
|
|
{
|
2008-07-03 16:59:21 +00:00
|
|
|
KPropertiesDialog::showDialog(m_popupMenuInfo.items(), m_popupMenuInfo.parentWidget(), false);
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
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
|
|
|
{
|
2008-05-20 20:47:26 +00:00
|
|
|
const QString commonMimeType = m_popupMenuInfo.mimeType();
|
2008-06-05 22:22:34 +00:00
|
|
|
const KService::List plugin_offers = KMimeTypeTrader::self()->query(commonMimeType.isEmpty() ? QLatin1String("application/octet-stream") : commonMimeType, "KonqPopupMenu/Plugin", "exist Library");
|
2004-09-24 08:04:33 +00:00
|
|
|
|
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();
|
2008-05-20 20:47:26 +00:00
|
|
|
for(; iterator != end; ++iterator) {
|
|
|
|
//kDebug() << (*iterator)->name() << (*iterator)->library();
|
|
|
|
KonqPopupMenuPlugin *plugin = (*iterator)->createInstance<KonqPopupMenuPlugin>(q);
|
|
|
|
if (!plugin)
|
2004-09-24 08:04:33 +00:00
|
|
|
continue;
|
2008-05-20 20:47:26 +00:00
|
|
|
plugin->setup(&m_ownActions, m_popupMenuInfo, q);
|
2004-09-24 08:04:33 +00:00
|
|
|
}
|
2000-04-01 17:09:44 +00:00
|
|
|
}
|
2004-09-06 18:40:43 +00:00
|
|
|
|
2000-07-27 09:23:48 +00:00
|
|
|
#include "konq_popupmenu.moc"
|