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  bool confirmTrash() const {
144  return confirmTrash_;
145  }
146 
147  void setConfirmTrash(bool value) {
148  confirmTrash_ = value;
149  }
150 
151 protected:
152  void createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd);
153 #ifdef CUSTOM_ACTIONS
154  void addCustomActionItem(QMenu* menu, struct _FmFileActionItem* item);
155 #endif
156  void openFilesWithApp(GAppInfo* app);
157 
158 protected Q_SLOTS:
159  void onOpenTriggered();
160  void onOpenWithTriggered();
161  void onFilePropertiesTriggered();
162  void onApplicationTriggered();
163 #ifdef CUSTOM_ACTIONS
164  void onCustomActionTrigerred();
165 #endif
166  void onCompress();
167  void onExtract();
168  void onExtractHere();
169 
170  void onCutTriggered();
171  void onCopyTriggered();
172  void onPasteTriggered();
173  void onRenameTriggered();
174  void onDeleteTriggered();
175  void onUnTrashTriggered();
176 
177 private:
178  FmFileInfoList* files_;
179  FmFileInfo* info_;
180  FmPath* cwd_;
181  bool useTrash_;
182  bool confirmDelete_;
183  bool confirmTrash_; // Confirm before moving files into "trash can"
184 
185  bool sameType_;
186  bool sameFilesystem_;
187  bool allVirtual_;
188  bool allTrash_;
189 
190  QAction* openAction_;
191  QAction* openWithMenuAction_;
192  QAction* openWithAction_;
193  QAction* separator1_;
194  QAction* cutAction_;
195  QAction* copyAction_;
196  QAction* pasteAction_;
197  QAction* deleteAction_;
198  QAction* unTrashAction_;
199  QAction* renameAction_;
200  QAction* separator2_;
201  QAction* propertiesAction_;
202 
203  FileLauncher* fileLauncher_;
204 };
205 
206 }
207 
208 #endif // FM_FILEMENU_H
Definition: appchoosercombobox.cpp:26
Definition: filemenu.h:37
Definition: filelauncher.h:30