]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincontextmenu.h
Step one for having DolphinParts for the icons and details view, which can be used...
[dolphin.git] / src / dolphincontextmenu.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program 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 *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef DOLPHINCONTEXTMENU_H
22 #define DOLPHINCONTEXTMENU_H
23
24 #include <QString>
25 #include <QVector>
26
27 #include <kservice.h>
28 #include <kpropertiesdialog.h>
29 #include <kdedesktopmimetype.h>
30
31 class KMenu;
32 class KFileItem;
33 class QPoint;
34 class QWidget;
35 class DolphinView;
36
37 /**
38 * @brief Represents the context menu which appears when doing a right
39 * click on an item or the viewport of the file manager.
40 *
41 * Beside static menu entries (e. g. 'Paste' or 'Properties') two
42 * dynamic sub menus are shown when opening a context menu above
43 * an item:
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
47 * given item.
48 *
49 * @author Peter Penz <peter.penz@gmx.at>
50 */
51 class DolphinContextMenu
52 {
53 public:
54 /**
55 * @parent Pointer to the dolphin view the context menu
56 * belongs to.
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 * @pos Position of the upper left edge of the context menu.
61 */
62 DolphinContextMenu(DolphinView* parent,
63 KFileItem* fileInfo,
64 const QPoint& pos);
65
66 virtual ~DolphinContextMenu();
67
68 /** Opens the context menu modal. */
69 void open();
70
71 private:
72 void openViewportContextMenu();
73 void openItemContextMenu();
74
75 /**
76 * Inserts the 'Open With...' submenu to \a popup.
77 * @param popup Menu where the 'Open With...' sub menu should
78 * be added.
79 * @param openWithVector Output parameter which contains all 'Open with...'
80 * services.
81 * @return Identifier of the first 'Open With...' entry.
82 * All succeeding identifiers have an increased value of 1
83 * to the predecessor.
84 */
85 QList<QAction*> insertOpenWithItems(KMenu* popup,
86 QVector<KService::Ptr>& openWithVector);
87
88 /**
89 * Inserts the 'Actions...' submenu to \a popup.
90 * @param popup Menu where the 'Actions...' sub menu should
91 * be added.
92 * @param openWithVector Output parameter which contains all 'Actions...'
93 * services.
94 */
95 QList<QAction*> insertActionItems(KMenu* popup,
96 QVector<KDEDesktopMimeType::Service>& actionsVector);
97
98 /**
99 * Returns true, if 'menu' contains already
100 * an entry with the name 'entryName'.
101 */
102 bool containsEntry(const KMenu* menu,
103 const QString& entryName) const;
104
105 DolphinView* m_dolphinView;
106 KFileItem* m_fileInfo;
107 QPoint m_pos;
108
109 struct Entry {
110 int type;
111 QString name;
112 QString filePath; // empty for separator
113 QString templatePath; // same as filePath for template
114 QString icon;
115 QString comment;
116 };
117 };
118
119 #endif