NDE-FileMAN
Loading...
Searching...
No Matches
mainwindow.h
1/*
2
3 Copyright (C) 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
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 along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#ifndef FM_MAIN_WINDOW_H
21#define FM_MAIN_WINDOW_H
22
23#include "ui_main-win.h"
24#include <QMainWindow>
25#include <QListView>
26#include <QSortFilterProxyModel>
27#include <QLineEdit>
28#include <QTabWidget>
29#include <QMessageBox>
30#include <QTabBar>
31#include <QStackedWidget>
32#include <QSplitter>
33#include "launcher.h"
34#include "tabbar.h"
35#include <libfm-qt-nde/core/filepath.h>
36#include <libfm-qt-nde/core/bookmarks.h>
37#include <libfm-qt-nde/folderview.h>
38
39namespace Fm {
40class PathEdit;
41class PathBar;
42}
43
44namespace NDEFileMAN {
45
46class FilterBar;
47
48class ViewFrame : public QFrame {
49 Q_OBJECT
50public:
51 ViewFrame(QWidget* parent = nullptr);
52 ~ViewFrame() {};
53
54 void createTopBar(bool usePathButtons);
55 void removeTopBar();
56
57 QWidget* getTopBar() const {
58 return topBar_;
59 }
60 TabBar* getTabBar() const {
61 return tabBar_;
62 }
63 QStackedWidget* getStackedWidget() const {
64 return stackedWidget_;
65 }
66
67 QPushButton * getTabAddButton() {
68 return tabAddBtn_;
69 }
70
71private:
72 QWidget* topBar_;
73 TabBar* tabBar_;
74 QStackedWidget* stackedWidget_;
75 QPushButton *tabAddBtn_;
76};
77
78//======================================================================
79
80class TabPage;
81class Settings;
82
83class MainWindow : public QMainWindow {
84 Q_OBJECT
85public:
86 MainWindow(Fm::FilePath path = Fm::FilePath());
87 virtual ~MainWindow();
88
89 void chdir(Fm::FilePath path, ViewFrame* viewFrame);
90 void chdir(Fm::FilePath path) {
91 chdir(path, activeViewFrame_);
92 }
93
94 int addTab(Fm::FilePath path, ViewFrame* viewFrame);
95 int addTab(Fm::FilePath path) {
96 return addTab(path, activeViewFrame_);
97 }
98
99 TabPage* currentPage(ViewFrame* viewFrame) {
100 return reinterpret_cast<TabPage*>(viewFrame->getStackedWidget()->currentWidget());
101 }
102 TabPage* currentPage() {
103 return currentPage(activeViewFrame_);
104 }
105
106 void updateFromSettings(Settings& settings);
107
108 static MainWindow* lastActive() {
109 return lastActive_;
110 }
111
112protected Q_SLOTS:
113
114 void onPathEntryReturnPressed();
115 void onPathBarChdir(const Fm::FilePath& dirPath);
116 void onPathBarMiddleClickChdir(const Fm::FilePath &dirPath);
117
118 void on_actionNewTab_triggered();
119 void on_actionNewWin_triggered();
120 void on_actionNewFolder_triggered();
121 void on_actionNewBlankFile_triggered();
122 void on_actionCloseTab_triggered();
123 void on_actionCloseWindow_triggered();
124 void on_actionFileProperties_triggered();
125 void on_actionFolderProperties_triggered();
126
127 void on_actionCut_triggered();
128 void on_actionCopy_triggered();
129 void on_actionPaste_triggered();
130 void on_actionDelete_triggered();
131 void on_actionRename_triggered();
132 void on_actionBulkRename_triggered();
133 void on_actionSelectAll_triggered();
134 void on_actionInvertSelection_triggered();
135 void on_actionPreferences_triggered();
136
137 void on_actionGoBack_triggered();
138 void on_actionGoForward_triggered();
139 void on_actionGoUp_triggered();
140 void on_actionHome_triggered();
141 void on_actionReload_triggered();
142 void on_actionConnectToServer_triggered();
143
144 void on_actionIconView_triggered();
145 void on_actionCompactView_triggered();
146 void on_actionDetailedList_triggered();
147 void on_actionThumbnailView_triggered();
148
149 void on_actionGo_triggered();
150 void on_actionShowHidden_triggered(bool check);
151 void on_actionSplitView_triggered(bool check);
152 void on_actionPreserveView_triggered(bool checked);
153
154 void on_actionByFileName_triggered(bool checked);
155 void on_actionByMTime_triggered(bool checked);
156 void on_actionByOwner_triggered(bool checked);
157 void on_actionByGroup_triggered(bool checked);
158 void on_actionByFileType_triggered(bool checked);
159 void on_actionByFileSize_triggered(bool checked);
160 void on_actionAscending_triggered(bool checked);
161 void on_actionDescending_triggered(bool checked);
162 void on_actionFolderFirst_triggered(bool checked);
163 void on_actionCaseSensitive_triggered(bool checked);
164 void on_actionFilter_triggered(bool checked);
165 void on_actionUnfilter_triggered();
166 void on_actionShowFilter_triggered();
167
168 void on_actionLocationBar_triggered(bool checked);
169 void on_actionPathButtons_triggered(bool checked);
170
171 void on_actionApplications_triggered();
172 void on_actionComputer_triggered();
173 void on_actionTrash_triggered();
174 void on_actionNetwork_triggered();
175 void on_actionDesktop_triggered();
176 void on_actionAddToBookmarks_triggered();
177 void on_actionEditBookmarks_triggered();
178
179 void on_actionOpenTerminal_triggered();
180 void on_actionOpenAsRoot_triggered();
181 void on_actionCopyFullPath_triggered();
182 void on_actionFindFiles_triggered();
183
184 void on_actionAbout_triggered();
185
186 void onBookmarkActionTriggered();
187
188 void onTabBarCloseRequested(int index);
189 void onTabBarCurrentChanged(int index);
190 void onTabBarTabMoved(int from, int to);
191
192 void onShortcutPrevTab();
193 void onShortcutNextTab();
194 void onShortcutJumpToTab();
195
196 void onStackedWidgetWidgetRemoved(int index);
197
198 void onTabPageTitleChanged(QString title);
199 void onTabPagesearchChanged();
200 void onTabPageStatusChanged(int type, QString statusText);
201 void onTabPageOpenDirRequested(const Fm::FilePath &path, int target);
202 void onTabPageSortFilterChanged();
203
204 void onSidePaneChdirRequested(int type, const Fm::FilePath &path);
205 void onSidePaneOpenFolderInNewWindowRequested(const Fm::FilePath &path);
206 void onSidePaneOpenFolderInNewTabRequested(const Fm::FilePath &path);
207 void onSidePaneOpenFolderInTerminalRequested(const Fm::FilePath &path);
208 void onSidePaneCreateNewFolderRequested(const Fm::FilePath &path);
209 void onSidePaneModeChanged(Fm::SidePane::Mode mode);
210 void onSplitterMoved(int pos, int index);
211 void onResetFocus();
212
213 void onBackForwardContextMenu(QPoint pos);
214
215 void onFolderUnmounted();
216
217 void tabContextMenu(const QPoint& pos);
218 void onTabBarClicked(int index);
219 void closeLeftTabs();
220 void closeRightTabs();
221 void closeOtherTabs() {
222 closeLeftTabs();
223 closeRightTabs();
224 }
225 void createNewTab(); // 新建选中的标签页
226 void closeSeleteTab(); // 关闭选中的标签页
227 void focusPathEntry();
228 void toggleMenuBar(bool checked);
229 void detachTab();
230 void onFolderViewMode(Fm::FolderView::ViewMode mode);
231
232 void onSettingHiddenPlace(const QString& str, bool hide);
233 void onClickAddNewTab();
234
235protected:
236 bool event(QEvent* event) override;
237 void changeEvent(QEvent* event) override;
238 void closeTab(int index, ViewFrame* viewFrame);
239 void closeTab(int index) {
240 closeTab(index, activeViewFrame_);
241 }
242 virtual void resizeEvent(QResizeEvent* event) override;
243 virtual void closeEvent(QCloseEvent* event) override;
244 virtual void dragEnterEvent(QDragEnterEvent* event) override;
245 virtual void dropEvent(QDropEvent* event) override;
246 virtual bool eventFilter(QObject* watched, QEvent* event);
247
248private Q_SLOTS:
249 void on_actionbookmark_triggered();
250 void open();
251
252private:
253 void updateUIForCurrentPage(bool setFocus = true);
254 void updateViewMenuForCurrentPage();
255 void updateEditSelectedActions();
256 void updateStatusBarForCurrentPage();
257 void setRTLIcons(bool isRTL);
258 void createPathBar(bool usePathButtons);
259 void addViewFrame(const Fm::FilePath& path);
260 ViewFrame* viewFrameForTabPage(TabPage* page);
261 int addTabWithPage(TabPage* page, ViewFrame* viewFrame, Fm::FilePath path = Fm::FilePath());
262 void dropTab();
263 void chbookmarkdir();
264
265private:
266 Ui::MainWindow ui;
267 Fm::PathEdit* pathEntry_;
268 Fm::PathBar* pathBar_;
269 QLabel* fsInfoLabel_;
270 std::shared_ptr<Fm::Bookmarks> bookmarks_;
271 Launcher fileLauncher_;
272 int rightClickIndex_;
273 bool updatingViewMenu_;
274 QAction* menuSep_;
275 QAction* menuSpacer_;
276 FilterBar * filter_;
277 ViewFrame* activeViewFrame_;
278 // The split mode of this window is changed only from its settings,
279 // not from another window. So, we get the mode at the start and keep it.
280 bool splitView_;
281 Fm::FilePath currentPath_;
282
283 static MainWindow* lastActive_;
284
285 Fm::FilePath bookmarkpath_;
286
287 std::vector<QString> hislist;
288};
289
290}
291
292#endif // FM_MAIN_WINDOW_H
Definition tabpage.h:84
Definition launcher.h:30
Definition mainwindow.h:83
Definition settings.h:170
Definition tabbar.h:30
Definition tabpage.h:118
Definition mainwindow.h:48