PCManFM-Qt
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 <QPointer>
25#include <QMainWindow>
26#include <QListView>
27#include <QSortFilterProxyModel>
28#include <QLineEdit>
29#include <QTabWidget>
30#include <QMessageBox>
31#include <QTabBar>
32#include <QStackedWidget>
33#include <QSplitter>
34#include <QProgressBar>
35#include <QToolButton>
36#include "launcher.h"
37#include "tabbar.h"
38#include <libfm-qt6/core/filepath.h>
39#include <libfm-qt6/core/bookmarks.h>
40
41namespace Fm {
42class PathEdit;
43class PathBar;
44}
45
46namespace PCManFM {
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
67private:
68 QWidget* topBar_;
69 TabBar* tabBar_;
70 QStackedWidget* stackedWidget_;
71};
72
73//======================================================================
74
75class TabPage;
76class Settings;
77
78class MainWindow : public QMainWindow {
79 Q_OBJECT
80public:
81 MainWindow(Fm::FilePath path = Fm::FilePath());
82 virtual ~MainWindow();
83
84 void chdir(Fm::FilePath path, ViewFrame* viewFrame);
85 void chdir(Fm::FilePath path) {
86 chdir(path, activeViewFrame_);
87 }
88
89 void addTab(Fm::FilePath path, ViewFrame* viewFrame);
90 void addTab(Fm::FilePath path);
91
92 TabPage* currentPage(ViewFrame* viewFrame) {
93 return reinterpret_cast<TabPage*>(viewFrame->getStackedWidget()->currentWidget());
94 }
95 TabPage* currentPage() {
96 return currentPage(activeViewFrame_);
97 }
98
99 void updateFromSettings(Settings& settings);
100
101 static MainWindow* lastActive() {
102 return lastActive_;
103 }
104
105 void openFolderAndSelectFiles(const Fm::FilePathList& files, bool inNewTab = true);
106
107protected Q_SLOTS:
108
109 void onPathEntryReturnPressed();
110 void onPathBarChdir(const Fm::FilePath& dirPath);
111 void onPathBarMiddleClickChdir(const Fm::FilePath &dirPath);
112
113 void on_actionNewTab_triggered();
114 void on_actionNewWin_triggered();
115 void on_actionNewFolder_triggered();
116 void on_actionNewBlankFile_triggered();
117 void on_actionCloseTab_triggered();
118 void on_actionCloseWindow_triggered();
119 void on_actionFileProperties_triggered();
120 void on_actionFolderProperties_triggered();
121
122 void on_actionCut_triggered();
123 void on_actionCopy_triggered();
124 void on_actionPaste_triggered();
125 void on_actionDelete_triggered();
126 void on_actionRename_triggered();
127 void on_actionBulkRename_triggered();
128 void on_actionSelectAll_triggered();
129 void on_actionDeselectAll_triggered();
130 void on_actionInvertSelection_triggered();
131 void on_actionPreferences_triggered();
132
133 void on_actionGoBack_triggered();
134 void on_actionGoForward_triggered();
135 void on_actionGoUp_triggered();
136 void on_actionHome_triggered();
137 void on_actionReload_triggered();
138 void on_actionConnectToServer_triggered();
139
140 void on_actionIconView_triggered();
141 void on_actionCompactView_triggered();
142 void on_actionDetailedList_triggered();
143 void on_actionThumbnailView_triggered();
144
145 void on_actionGo_triggered();
146 void on_actionShowHidden_triggered(bool check);
147 void on_actionShowThumbnails_triggered(bool check);
148 void on_actionSplitView_triggered(bool check);
149 void on_actionPreserveView_triggered(bool checked);
150 void on_actionPreserveViewRecursive_triggered(bool checked);
151 void on_actionGoToCustomizedViewSource_triggered();
152
153 void on_actionByFileName_triggered(bool checked);
154 void on_actionByMTime_triggered(bool checked);
155 void on_actionByCrTime_triggered(bool checked);
156 void on_actionByDTime_triggered(bool checked);
157 void on_actionByOwner_triggered(bool checked);
158 void on_actionByGroup_triggered(bool checked);
159 void on_actionByFileType_triggered(bool checked);
160 void on_actionByFileSize_triggered(bool checked);
161 void on_actionAscending_triggered(bool checked);
162 void on_actionDescending_triggered(bool checked);
163 void on_actionFolderFirst_triggered(bool checked);
164 void on_actionHiddenLast_triggered(bool checked);
165 void on_actionCaseSensitive_triggered(bool checked);
166 void on_actionFilter_triggered(bool checked);
167 void on_actionUnfilter_triggered();
168 void on_actionShowFilter_triggered();
169
170 void on_actionLocationBar_triggered(bool checked);
171 void on_actionPathButtons_triggered(bool checked);
172
173 void on_actionApplications_triggered();
174 void on_actionComputer_triggered();
175 void on_actionTrash_triggered();
176 void on_actionNetwork_triggered();
177 void on_actionDesktop_triggered();
178 void on_actionAddToBookmarks_triggered();
179 void on_actionEditBookmarks_triggered();
180
181 void on_actionOpenTerminal_triggered();
182 void on_actionCreateLauncher_triggered();
183 void on_actionOpenAsAdmin_triggered();
184 void on_actionOpenAsRoot_triggered();
185 void on_actionCopyFullPath_triggered();
186 void on_actionFindFiles_triggered();
187
188 void on_actionAbout_triggered();
189 void on_actionHiddenShortcuts_triggered();
190
191 void onBookmarkActionTriggered();
192
193 void onTabBarCloseRequested(int index);
194 void onTabBarCurrentChanged(int index);
195 void onTabBarTabMoved(int from, int to);
196
197 void onShortcutPrevTab();
198 void onShortcutNextTab();
199 void onShortcutJumpToTab();
200
201 void onStackedWidgetWidgetRemoved(int index);
202
203 void onTabPageTitleChanged();
204 void onTabPageStatusChanged(int type, QString statusText);
205 void onTabPageSearchingChanged(bool searching);
206 void onTabPageSortFilterChanged();
207
208 void onSidePaneChdirRequested(int type, const Fm::FilePath &path);
209 void onSidePaneOpenFolderInNewWindowRequested(const Fm::FilePath &path);
210 void onSidePaneOpenFolderInNewTabRequested(const Fm::FilePath &path);
211 void onSidePaneOpenFolderInTerminalRequested(const Fm::FilePath &path);
212 void onSidePaneCreateNewFolderRequested(const Fm::FilePath &path);
213 void onSidePaneModeChanged(Fm::SidePane::Mode mode);
214 void on_actionSidePane_triggered(bool check);
215 void onSplitterMoved(int pos, int index);
216 void onResetFocus();
217
218 void onBackForwardContextMenu(QPoint pos);
219
220 void onFolderUnmounted();
221
222 void tabContextMenu(const QPoint& pos);
223 void onTabBarClicked(int index);
224 void closeLeftTabs();
225 void closeRightTabs();
226 void closeOtherTabs() {
227 closeLeftTabs();
228 closeRightTabs();
229 }
230 void focusPathEntry();
231 void toggleMenuBar(bool checked);
232 void updateRecenMenu();
233 void clearRecentMenu();
234 void lanunchRecentFile();
235 void detachTab();
236
237 void onBookmarksChanged();
238
239 void onSettingHiddenPlace(const QString& str, bool hide);
240
241 void on_actionCleanPerFolderConfig_triggered();
242
243protected:
244 bool event(QEvent* event) override;
245 void changeEvent(QEvent* event) override;
246 void closeTab(int index, ViewFrame* viewFrame);
247 void closeTab(int index) {
248 closeTab(index, activeViewFrame_);
249 }
250 virtual void resizeEvent(QResizeEvent* event) override;
251 virtual void closeEvent(QCloseEvent* event) override;
252 virtual void dragEnterEvent(QDragEnterEvent* event) override;
253 virtual void dropEvent(QDropEvent* event) override;
254 virtual bool eventFilter(QObject* watched, QEvent* event) override;
255
256private:
257 void loadBookmarksMenu();
258 void updateUIForCurrentPage(bool setFocus = true);
259 void updateViewMenuForCurrentPage();
260 void updateSelectedActions();
261 void updateStatusBarForCurrentPage();
262 void setRTLIcons(bool isRTL);
263 void createPathBar(bool usePathButtons);
264 void addViewFrame(const Fm::FilePath& path);
265 ViewFrame* viewFrameForTabPage(TabPage* page);
266 int addTabWithPage(TabPage* page, ViewFrame* viewFrame, Fm::FilePath path = Fm::FilePath());
267 void dropTab(QObject* source);
268 void setTabIcon(TabPage* tabPage);
269
270private:
271 Ui::MainWindow ui;
272 Fm::PathEdit* pathEntry_;
273 Fm::PathBar* pathBar_;
274 QLabel* fsInfoLabel_;
275 QLabel* searchingLabel_;
276 QProgressBar* searchBusyIndicator_;
277 QToolButton* searchStopButton_;
278 std::shared_ptr<Fm::Bookmarks> bookmarks_;
279 Launcher fileLauncher_;
280 int rightClickIndex_;
281 bool updatingViewMenu_;
282 QAction* menuSep_;
283 QAction* menuSpacer_;
284
285 ViewFrame* activeViewFrame_;
286 // The split mode of this window is changed only from its settings,
287 // not from another window. So, we get the mode at the start and keep it.
288 bool splitView_;
289
290 int splitTabsNum_; // number of tabs to be restored from the first view frame of the last window
291
292 static QPointer<MainWindow> lastActive_;
293};
294
295}
296
297#endif // FM_MAIN_WINDOW_H
Definition launcher.h:30
Definition settings.h:154
Definition tabbar.h:30
Definition tabpage.h:112
Definition mainwindow.h:48