1 /*
2  * Copyright (C) 2012 - 2015  Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  */
19 
20 
21 #ifndef FM_FOLDERMENU_H
22 #define FM_FOLDERMENU_H
23 
24 #include "libfmqtglobals.h"
25 #include <QMenu>
26 #include "foldermodel.h"
27 
28 class QAction;
29 
30 namespace Fm {
31 
32 class FolderView;
33 class FileActionItem;
34 
35 class LIBFM_QT_API FolderMenu : public QMenu {
36     Q_OBJECT
37 
38 public:
39     explicit FolderMenu(FolderView* view, QWidget* parent = nullptr);
40     ~FolderMenu() override;
41 
createAction()42     QAction* createAction() {
43         return createAction_;
44     }
45 
separator1()46     QAction* separator1() {
47         return separator1_;
48     }
49 
pasteAction()50     QAction* pasteAction() {
51         return pasteAction_;
52     }
53 
separator2()54     QAction* separator2() {
55         return separator2_;
56     }
57 
selectAllAction()58     QAction* selectAllAction() {
59         return selectAllAction_;
60     }
61 
invertSelectionAction()62     QAction* invertSelectionAction() {
63         return invertSelectionAction_;
64     }
65 
separator3()66     QAction* separator3() {
67         return separator3_;
68     }
69 
sortAction()70     QAction* sortAction() {
71         return sortAction_;
72     }
73 
showHiddenAction()74     QAction* showHiddenAction() {
75         return showHiddenAction_;
76     }
77 
separator4()78     QAction* separator4() {
79         return separator4_;
80     }
81 
propertiesAction()82     QAction* propertiesAction() {
83         return propertiesAction_;
84     }
85 
view()86     FolderView* view() {
87         return view_;
88     }
89 
90 protected:
91     void addCustomActionItem(QMenu* menu, std::shared_ptr<const FileActionItem> item);
92 
93 protected Q_SLOTS:
94     void onPasteActionTriggered();
95     void onSelectAllActionTriggered();
96     void onInvertSelectionActionTriggered();
97     void onSortActionTriggered(bool checked);
98     void onSortOrderActionTriggered(bool checked);
99     void onShowHiddenActionTriggered(bool checked);
100     void onCaseSensitiveActionTriggered(bool checked);
101     void onFolderFirstActionTriggered(bool checked);
102     void onHiddenLastActionTriggered(bool checked);
103     void onPropertiesActionTriggered();
104     void onCustomActionTrigerred();
105 
106 private:
107     void createSortMenu();
108     void addSortMenuItem(const QString &title, int id);
109 
110 private:
111     FolderView* view_;
112     QAction* createAction_;
113     QAction* separator1_;
114     QAction* pasteAction_;
115     QAction* separator2_;
116     QAction* selectAllAction_;
117     QAction* invertSelectionAction_;
118     QAction* separator3_;
119     QAction* sortAction_;
120     QActionGroup* sortActionGroup_;
121     QMenu* sortMenu_;
122     QAction* actionAscending_;
123     QAction* actionDescending_;
124     QAction* showHiddenAction_;
125     QAction* separator4_;
126     QAction* propertiesAction_;
127 };
128 
129 }
130 
131 #endif // FM_FOLDERMENU_H
132