1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef DOLPHINCONTEXTMENU_H
21 #define DOLPHINCONTEXTMENU_H
23 #include <kdesktopfileactions.h>
24 #include <kfileitem.h>
28 #include <QtCore/QObject>
30 #include <QtCore/QVector>
35 class DolphinMainWindow
;
38 * @brief Represents the context menu which appears when doing a right
39 * click on an item or the viewport of the file manager.
41 * Beside static menu entries (e. g. 'Paste' or 'Properties') two
42 * dynamic sub menus are shown when opening a context menu above
44 * - 'Open With': Contains all applications which are registered to
45 * open items of the given MIME type.
46 * - 'Actions': Contains all actions which can be applied to the
49 class DolphinContextMenu
: public QObject
55 * @parent Pointer to the main window the context menu
57 * @fileInfo Pointer to the file item the context menu
58 * is applied. If 0 is passed, the context menu
59 * is above the viewport.
60 * @baseUrl Base URL of the viewport where the context menu
63 DolphinContextMenu(DolphinMainWindow
* parent
,
64 const KFileItem
& fileInfo
,
67 virtual ~DolphinContextMenu();
69 /** Opens the context menu model. */
73 void openTrashContextMenu();
74 void openTrashItemContextMenu();
75 void openItemContextMenu();
76 void openViewportContextMenu();
78 void insertDefaultItemActions(KMenu
* popup
);
81 * Inserts the 'Open With...' submenu to \a popup.
82 * @param popup Menu where the 'Open With...' sub menu should
84 * @param openWithVector Output parameter which contains all 'Open with...'
86 * @return Identifier of the first 'Open With...' entry.
87 * All succeeding identifiers have an increased value of 1
90 QList
<QAction
*> insertOpenWithItems(KMenu
* popup
,
91 QVector
<KService::Ptr
>& openWithVector
);
94 * Returns true, if 'menu' contains already
95 * an entry with the name 'entryName'.
97 bool containsEntry(const KMenu
* menu
,
98 const QString
& entryName
) const;
101 * Adds the "Show menubar" action to the menu if the
104 void addShowMenubarAction(KMenu
* menu
);
107 * Returns a name for adding the URL \a url to the Places panel.
109 QString
placesName(const KUrl
& url
) const;
116 QString filePath
; // empty for separator
117 QString templatePath
; // same as filePath for template
129 DolphinMainWindow
* m_mainWindow
;
130 KFileItem m_fileInfo
;
132 KFileItemList m_selectedItems
;
133 KUrl::List m_selectedUrls
;