PCManFM-Qt
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 <libfm/fm.h>
30 #include <QMessageBox>
31 #include <QTabBar>
32 #include <QStackedWidget>
33 #include <QSplitter>
34 #include "launcher.h"
35 #include <libfm-qt/path.h>
36 #include <libfm-qt/core/filepath.h>
37 #include <libfm-qt/core/bookmarks.h>
38 
39 namespace Fm {
40 class PathEdit;
41 class PathBar;
42 }
43 
44 namespace PCManFM {
45 
46 class TabPage;
47 class Settings;
48 
49 class MainWindow : public QMainWindow {
50  Q_OBJECT
51 public:
52  MainWindow(Fm::FilePath path = Fm::FilePath());
53  virtual ~MainWindow();
54 
55  void chdir(Fm::FilePath path);
56  int addTab(Fm::FilePath path);
57 
58  TabPage* currentPage() {
59  return reinterpret_cast<TabPage*>(ui.stackedWidget->currentWidget());
60  }
61 
62  void updateFromSettings(Settings& settings);
63 
64  static MainWindow* lastActive() {
65  return lastActive_;
66  }
67 
68 protected Q_SLOTS:
69 
70  void onPathEntryReturnPressed();
71  void onPathBarChdir(const Fm::FilePath& dirPath);
72  void onPathBarMiddleClickChdir(const Fm::FilePath &dirPath);
73 
74  void on_actionNewTab_triggered();
75  void on_actionNewWin_triggered();
76  void on_actionNewFolder_triggered();
77  void on_actionNewBlankFile_triggered();
78  void on_actionCloseTab_triggered();
79  void on_actionCloseWindow_triggered();
80  void on_actionFileProperties_triggered();
81  void on_actionFolderProperties_triggered();
82 
83  void on_actionCut_triggered();
84  void on_actionCopy_triggered();
85  void on_actionPaste_triggered();
86  void on_actionDelete_triggered();
87  void on_actionRename_triggered();
88  void on_actionSelectAll_triggered();
89  void on_actionInvertSelection_triggered();
90  void on_actionPreferences_triggered();
91 
92  void on_actionGoBack_triggered();
93  void on_actionGoForward_triggered();
94  void on_actionGoUp_triggered();
95  void on_actionHome_triggered();
96  void on_actionReload_triggered();
97  void on_actionConnectToServer_triggered();
98 
99  void on_actionIconView_triggered();
100  void on_actionCompactView_triggered();
101  void on_actionDetailedList_triggered();
102  void on_actionThumbnailView_triggered();
103 
104  void on_actionGo_triggered();
105  void on_actionShowHidden_triggered(bool check);
106  void on_actionPreserveView_triggered(bool checked);
107 
108  void on_actionByFileName_triggered(bool checked);
109  void on_actionByMTime_triggered(bool checked);
110  void on_actionByOwner_triggered(bool checked);
111  void on_actionByFileType_triggered(bool checked);
112  void on_actionByFileSize_triggered(bool checked);
113  void on_actionAscending_triggered(bool checked);
114  void on_actionDescending_triggered(bool checked);
115  void on_actionFolderFirst_triggered(bool checked);
116  void on_actionCaseSensitive_triggered(bool checked);
117  void on_actionFilter_triggered(bool checked);
118 
119  void on_actionLocationBar_triggered(bool checked);
120  void on_actionPathButtons_triggered(bool checked);
121 
122  void on_actionApplications_triggered();
123  void on_actionComputer_triggered();
124  void on_actionTrash_triggered();
125  void on_actionNetwork_triggered();
126  void on_actionDesktop_triggered();
127  void on_actionAddToBookmarks_triggered();
128  void on_actionEditBookmarks_triggered();
129 
130  void on_actionOpenTerminal_triggered();
131  void on_actionOpenAsRoot_triggered();
132  void on_actionFindFiles_triggered();
133 
134  void on_actionAbout_triggered();
135 
136  void onBookmarkActionTriggered();
137 
138  void onTabBarCloseRequested(int index);
139  void onTabBarCurrentChanged(int index);
140  void onTabBarTabMoved(int from, int to);
141 
142  void focusFilterBar();
143  void onFilterStringChanged(QString str);
144 
145  void onShortcutPrevTab();
146  void onShortcutNextTab();
147  void onShortcutJumpToTab();
148 
149  void onStackedWidgetWidgetRemoved(int index);
150 
151  void onTabPageTitleChanged(QString title);
152  void onTabPageStatusChanged(int type, QString statusText);
153  void onTabPageOpenDirRequested(const Fm::FilePath &path, int target);
154  void onTabPageSortFilterChanged();
155 
156  void onSidePaneChdirRequested(int type, const Fm::FilePath &path);
157  void onSidePaneOpenFolderInNewWindowRequested(const Fm::FilePath &path);
158  void onSidePaneOpenFolderInNewTabRequested(const Fm::FilePath &path);
159  void onSidePaneOpenFolderInTerminalRequested(const Fm::FilePath &path);
160  void onSidePaneCreateNewFolderRequested(const Fm::FilePath &path);
161  void onSidePaneModeChanged(Fm::SidePane::Mode mode);
162  void onSplitterMoved(int pos, int index);
163  void onResetFocus();
164 
165  void onBackForwardContextMenu(QPoint pos);
166 
167  void tabContextMenu(const QPoint& pos);
168  void closeLeftTabs();
169  void closeRightTabs();
170  void closeOtherTabs() {
171  closeLeftTabs();
172  closeRightTabs();
173  }
174  void focusPathEntry();
175  void toggleMenuBar(bool checked);
176 
177  void onBookmarksChanged();
178 
179 protected:
180  bool event(QEvent* event) override;
181  void changeEvent(QEvent* event) override;
182  void closeTab(int index);
183  virtual void resizeEvent(QResizeEvent* event) override;
184  virtual void closeEvent(QCloseEvent* event) override;
185 
186 private:
187  void loadBookmarksMenu();
188  void updateUIForCurrentPage();
189  void updateViewMenuForCurrentPage();
190  void updateEditSelectedActions();
191  void updateStatusBarForCurrentPage();
192  void setRTLIcons(bool isRTL);
193  void createPathBar(bool usePathButtons);
194 
195 private:
196  Ui::MainWindow ui;
197  Fm::PathEdit* pathEntry_;
198  Fm::PathBar* pathBar_;
199  QLabel* fsInfoLabel_;
200  std::shared_ptr<Fm::Bookmarks> bookmarks_;
201  Launcher fileLauncher_;
202  int rightClickIndex_;
203  bool updatingViewMenu_;
204  QAction* menuSep_;
205 
206  static MainWindow* lastActive_;
207 };
208 
209 }
210 
211 #endif // FM_MAIN_WINDOW_H
Definition: desktopwindow.h:35
Definition: settings.h:121
Definition: tabpage.h:64
Definition: application.cpp:59
Definition: launcher.h:30
Definition: mainwindow.h:49