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