1 /* This file is part of the KDE project
2 Copyright (C) 1998, 1999 David Faure <faure@kde.org>
3 Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef __konqpopupmenu_h
22 #define __konqpopupmenu_h
24 #include <sys/types.h>
26 #include <QtCore/QMap>
27 #include <QtGui/QMenu>
30 #include <kactioncollection.h>
31 #include <kfileitem.h>
32 #include <kparts/browserextension.h>
35 #include <libkonq_export.h>
38 //class KonqPopupMenuPlugin;
39 class KBookmarkManager
;
40 class KonqPopupMenuPrivate
;
43 * This class implements the popup menu for URLs in konqueror and kdesktop
44 * It's usage is very simple : on right click, create the KonqPopupMenu instance
45 * with the correct arguments, then exec() to make it appear, then destroy it.
47 * Users of KonqPopupMenu include: konqueror, the media applet, the trash applet
48 * (and the desktop icons, in kde3)
50 class LIBKONQ_EXPORT KonqPopupMenu
: public QMenu
56 * Flags set by the calling application (konqueror/kdesktop), unlike
57 * KParts::BrowserExtension::PopupFlags, which are set by the calling part
62 // WARNING: bitfield. Next item is 2
66 * @param manager the bookmark manager for the "add to bookmark" action
67 * Only used if KParts::BrowserExtension::ShowBookmark is set
68 * @param items the list of file items the popupmenu should be shown for
69 * @param viewURL the URL shown in the view, to test for RMB click on view background
70 * @param actions list of actions the caller wants to see in the menu
71 * @param newMenu "New" menu, shared with the File menu, in konqueror
72 * @param parentWidget the widget we're showing this popup for. Helps destroying
73 * the popup if the widget is destroyed before the popup.
74 * @param appFlags flags from the KonqPopupMenu::Flags enum, set by the calling application
75 * @param partFlags flags from the BrowserExtension enum, set by the calling part
77 * The actions to pass in include :
78 * showmenubar, go_back, go_forward, go_up, cut, copy, paste, pasteto
79 * The others items are automatically inserted.
81 * @todo that list is probably not be up-to-date
83 KonqPopupMenu( const KFileItemList
&items
,
85 KActionCollection
& actions
,
88 KParts::BrowserExtension::PopupFlags partFlags
/*= KParts::BrowserExtension::DefaultPopupItems*/,
89 QWidget
* parentWidget
,
90 KBookmarkManager
*manager
= 0,
91 const KParts::BrowserExtension::ActionGroupMap
& actionGroups
= KParts::BrowserExtension::ActionGroupMap()
95 * Don't forget to destroy the object
100 * Set the title of the URL, when the popupmenu is opened for a single URL.
101 * This is used if the user chooses to add a bookmark for this URL.
103 void setURLTitle( const QString
& urlTitle
);
105 #if 0 // was only used by plugins
106 class LIBKONQ_EXPORT ProtocolInfo
{
109 bool supportsReading() const;
110 bool supportsWriting() const;
111 bool supportsDeleting() const;
112 bool supportsMoving() const;
113 bool trashIncluded() const;
115 friend class KonqPopupMenuPrivate
;
120 bool m_TrashIncluded
:1;
124 KActionCollection
*actionCollection() const;
125 QString
mimeType( ) const;
127 KFileItemList
fileItemList() const;
128 KUrl::List
popupURLList( ) const;
129 //ProtocolInfo protocolInfo() const;
132 Q_PRIVATE_SLOT(d
, void slotPopupNewDir())
133 Q_PRIVATE_SLOT(d
, void slotPopupNewView())
134 Q_PRIVATE_SLOT(d
, void slotPopupEmptyTrashBin())
135 Q_PRIVATE_SLOT(d
, void slotPopupRestoreTrashedItems())
136 Q_PRIVATE_SLOT(d
, void slotPopupOpenWith())
137 Q_PRIVATE_SLOT(d
, void slotPopupAddToBookmark())
138 Q_PRIVATE_SLOT(d
, void slotRunService(QAction
*))
139 Q_PRIVATE_SLOT(d
, void slotPopupMimeType())
140 Q_PRIVATE_SLOT(d
, void slotPopupProperties())
141 Q_PRIVATE_SLOT(d
, void slotOpenShareFileDialog())
144 void init (QWidget
* parentWidget
, Flags kpf
, KParts::BrowserExtension::PopupFlags itemFlags
);
146 KonqPopupMenuPrivate
*d
;
150 class LIBKONQ_EXPORT KonqPopupMenuPlugin
: public QObject
{
155 * If you want to insert a dynamic item or menu to konqpopupmenu
156 * this class is the right choice.
157 * Create a KAction and use _popup->addAction(new KAction );
158 * If you want to create a submenu use _popup->addGroup( );
160 KonqPopupMenuPlugin( KonqPopupMenu
*_popup
); // this should also be the parent
161 virtual ~KonqPopupMenuPlugin ( );