PCManFM-Qt
 All Classes
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/bookmarks.h>
36 #include <libfm-qt/path.h>
37 
38 namespace Fm {
39  class PathEdit;
40  class PathBar;
41 }
42 
43 namespace PCManFM {
44 
45 class TabPage;
46 class Settings;
47 
48 class MainWindow : public QMainWindow {
49 Q_OBJECT
50 public:
51  MainWindow(Fm::Path path = Fm::Path());
52  virtual ~MainWindow();
53 
54  void chdir(Fm::Path path);
55  int addTab(Fm::Path path);
56 
57  TabPage* currentPage() {
58  return reinterpret_cast<TabPage*>(ui.stackedWidget->currentWidget());
59  }
60 
61  void updateFromSettings(Settings& settings);
62 
63  static MainWindow* lastActive() {
64  return lastActive_;
65  }
66 
67 protected Q_SLOTS:
68 
69  void onPathEntryReturnPressed();
70  void onPathEntryEdited(const QString& text);
71  void onPathBarChdir(FmPath* dirPath);
72  void onPathBarMiddleClickChdir(FmPath* 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(FmPath* path, int target);
154  void onTabPageSortFilterChanged();
155 
156  void onSidePaneChdirRequested(int type, FmPath* path);
157  void onSidePaneOpenFolderInNewWindowRequested(FmPath* path);
158  void onSidePaneOpenFolderInNewTabRequested(FmPath* path);
159  void onSidePaneOpenFolderInTerminalRequested(FmPath* path);
160  void onSidePaneCreateNewFolderRequested(FmPath* 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 protected:
178  bool event(QEvent* event) override;
179  void changeEvent(QEvent *event) override;
180  void closeTab(int index);
181  virtual void resizeEvent(QResizeEvent *event) override;
182  virtual void closeEvent(QCloseEvent *event) override;
183 
184 private:
185  static void onBookmarksChanged(FmBookmarks* bookmarks_, MainWindow* pThis);
186  void loadBookmarksMenu();
187  void updateUIForCurrentPage();
188  void updateViewMenuForCurrentPage();
189  void updateStatusBarForCurrentPage();
190  void setRTLIcons(bool isRTL);
191  void createPathBar(bool usePathButtons);
192 
193 private:
194  Ui::MainWindow ui;
195  Fm::PathEdit* pathEntry_;
196  Fm::PathBar* pathBar_;
197  QLabel* fsInfoLabel_;
198  Fm::Bookmarks bookmarks_;
199  Launcher fileLauncher_;
200  int rightClickIndex_;
201  bool updatingViewMenu_;
202  QAction* menuSep_;
203 
204  static MainWindow* lastActive_;
205 };
206 
207 }
208 
209 #endif // FM_MAIN_WINDOW_H
Definition: settings.h:121
Definition: tabpage.h:62
Definition: launcher.h:30
Definition: mainwindow.h:48