PCManFM-Qt
filemenu.h
1 /*
2  <one line to give the library's name and an idea of what it does.>
3  Copyright (C) 2012 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
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  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 
21 #ifndef FM_FILEMENU_H
22 #define FM_FILEMENU_H
23 
24 #include "libfmqtglobals.h"
25 #include <QMenu>
26 #include <qabstractitemmodel.h>
27 #include <libfm/fm.h>
28 
29 class QAction;
30 
31 struct _FmFileActionItem;
32 
33 namespace Fm {
34 
35 class FileLauncher;
36 
37 class LIBFM_QT_API FileMenu : public QMenu {
38 Q_OBJECT
39 
40 public:
41  explicit FileMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd, QWidget* parent = 0);
42  explicit FileMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd, const QString& title, QWidget* parent = 0);
43  ~FileMenu();
44 
45  bool useTrash() {
46  return useTrash_;
47  }
48 
49  void setUseTrash(bool trash);
50 
51  bool confirmDelete() {
52  return confirmDelete_;
53  }
54 
55  void setConfirmDelete(bool confirm) {
56  confirmDelete_ = confirm;
57  }
58 
59  QAction* openAction() {
60  return openAction_;
61  }
62 
63  QAction* openWithMenuAction() {
64  return openWithMenuAction_;
65  }
66 
67  QAction* openWithAction() {
68  return openWithAction_;
69  }
70 
71  QAction* separator1() {
72  return separator1_;
73  }
74 
75  QAction* cutAction() {
76  return cutAction_;
77  }
78 
79  QAction* copyAction() {
80  return copyAction_;
81  }
82 
83  QAction* pasteAction() {
84  return pasteAction_;
85  }
86 
87  QAction* deleteAction() {
88  return deleteAction_;
89  }
90 
91  QAction* unTrashAction() {
92  return unTrashAction_;
93  }
94 
95  QAction* renameAction() {
96  return renameAction_;
97  }
98 
99  QAction* separator2() {
100  return separator2_;
101  }
102 
103  QAction* propertiesAction() {
104  return propertiesAction_;
105  }
106 
107  FmFileInfoList* files() {
108  return files_;
109  }
110 
111  FmFileInfo* firstFile() {
112  return info_;
113  }
114 
115  FmPath* cwd() {
116  return cwd_;
117  }
118 
119  void setFileLauncher(FileLauncher* launcher) {
120  fileLauncher_ = launcher;
121  }
122 
123  FileLauncher* fileLauncher() {
124  return fileLauncher_;
125  }
126 
127  bool sameType() const {
128  return sameType_;
129  }
130 
131  bool sameFilesystem() const {
132  return sameFilesystem_;
133  }
134 
135  bool allVirtual() const {
136  return allVirtual_;
137  }
138 
139  bool allTrash() const {
140  return allTrash_;
141  }
142 
143 protected:
144  void createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd);
145 #ifdef CUSTOM_ACTIONS
146  void addCustomActionItem(QMenu* menu, struct _FmFileActionItem* item);
147 #endif
148  void openFilesWithApp(GAppInfo* app);
149 
150 protected Q_SLOTS:
151  void onOpenTriggered();
152  void onOpenWithTriggered();
153  void onFilePropertiesTriggered();
154  void onApplicationTriggered();
155 #ifdef CUSTOM_ACTIONS
156  void onCustomActionTrigerred();
157 #endif
158  void onCompress();
159  void onExtract();
160  void onExtractHere();
161 
162  void onCutTriggered();
163  void onCopyTriggered();
164  void onPasteTriggered();
165  void onRenameTriggered();
166  void onDeleteTriggered();
167  void onUnTrashTriggered();
168 
169 private:
170  FmFileInfoList* files_;
171  FmFileInfo* info_;
172  FmPath* cwd_;
173  bool useTrash_;
174  bool confirmDelete_;
175  bool sameType_;
176  bool sameFilesystem_;
177  bool allVirtual_;
178  bool allTrash_;
179 
180  QAction* openAction_;
181  QAction* openWithMenuAction_;
182  QAction* openWithAction_;
183  QAction* separator1_;
184  QAction* cutAction_;
185  QAction* copyAction_;
186  QAction* pasteAction_;
187  QAction* deleteAction_;
188  QAction* unTrashAction_;
189  QAction* renameAction_;
190  QAction* separator2_;
191  QAction* propertiesAction_;
192 
193  FileLauncher* fileLauncher_;
194 };
195 
196 }
197 
198 #endif // FM_FILEMENU_H
Definition: appchoosercombobox.cpp:26
Definition: filemenu.h:37
Definition: filelauncher.h:30