PCManFM-Qt
application.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 
21 #ifndef PCMANFM_APPLICATION_H
22 #define PCMANFM_APPLICATION_H
23 
24 #include <QApplication>
25 #include "settings.h"
26 #include <libfm-qt/libfmqt.h>
27 #include <libfm-qt/editbookmarksdialog.h>
28 #include <QVector>
29 #include <QPointer>
30 #include <QProxyStyle>
31 #include <QTranslator>
32 #include <gio/gio.h>
33 
34 #include <libfm-qt/core/filepath.h>
35 #include <libfm-qt/core/fileinfo.h>
36 
37 class QScreen;
38 
39 class QFileSystemWatcher;
40 
41 namespace PCManFM {
42 
43 class MainWindow;
44 class DesktopWindow;
45 class PreferencesDialog;
46 class DesktopPreferencesDialog;
47 
48 class ProxyStyle: public QProxyStyle {
49  Q_OBJECT
50 public:
51  ProxyStyle() : QProxyStyle() {}
52  virtual ~ProxyStyle() {}
53  virtual int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
54 };
55 
56 class Application : public QApplication {
57  Q_OBJECT
58  Q_PROPERTY(bool desktopManagerEnabled READ desktopManagerEnabled)
59 
60 public:
61  Application(int& argc, char** argv);
62  virtual ~Application();
63 
64  void init();
65  int exec();
66 
67  Settings& settings() {
68  return settings_;
69  }
70 
71  Fm::LibFmQt& libFm() {
72  return libFm_;
73  }
74 
75  bool isX11() const {
76  return isX11_;
77  }
78 
79  // public interface exported via dbus
80  void launchFiles(QString cwd, QStringList paths, bool inNewWindow, bool reopenLastTabs);
81  void setWallpaper(QString path, QString modeString);
82  void preferences(QString page);
83  void desktopPrefrences(QString page);
84  void editBookmarks();
85  void desktopManager(bool enabled);
86  void findFiles(QStringList paths = QStringList());
87  void connectToServer();
88 
89  bool desktopManagerEnabled() {
90  return enableDesktopManager_;
91  }
92 
93  void updateFromSettings();
94  void updateDesktopsFromSettings(bool changeSlide = true);
95 
96  void openFolderInTerminal(Fm::FilePath path);
97  void openFolders(Fm::FileInfoList files);
98 
99  QString profileName() {
100  return profileName_;
101  }
102 
103  void cleanPerFolderConfig();
104 
105 protected Q_SLOTS:
106  void onAboutToQuit();
107  void onSigtermNotified();
108 
109  void onLastWindowClosed();
110  void onSaveStateRequest(QSessionManager& manager);
111  void initVolumeManager();
112 
113  void onVirtualGeometryChanged(const QRect& rect);
114  void onAvailableGeometryChanged(const QRect& rect);
115  void onScreenDestroyed(QObject* screenObj);
116  void onScreenAdded(QScreen* newScreen);
117  void onScreenRemoved(QScreen* oldScreen);
118  void reloadDesktopsAsNeeded();
119 
120  void onFindFileAccepted();
121  void onConnectToServerAccepted();
122 
123 protected:
124  //virtual bool eventFilter(QObject* watched, QEvent* event);
125  bool parseCommandLineArgs();
126  DesktopWindow* createDesktopWindow(int screenNum);
127  bool autoMountVolume(GVolume* volume, bool interactive = true);
128 
129  static void onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis);
130 
131 private Q_SLOTS:
132  void onUserDirsChanged();
133 
134 private:
135  void initWatch();
136  void installSigtermHandler();
137 
138  bool isPrimaryInstance;
139  Fm::LibFmQt libFm_;
140  Settings settings_;
141  QString profileName_;
142  bool daemonMode_;
143  bool enableDesktopManager_;
144  QVector<DesktopWindow*> desktopWindows_;
145  QPointer<PreferencesDialog> preferencesDialog_;
146  QPointer<DesktopPreferencesDialog> desktopPreferencesDialog_;
147  QPointer<Fm::EditBookmarksDialog> editBookmarksialog_;
148  QTranslator translator;
149  QTranslator qtTranslator;
150  GVolumeMonitor* volumeMonitor_;
151 
152  QFileSystemWatcher* userDirsWatcher_;
153  QString userDirsFile_;
154  QString userDesktopFolder_;
155  bool lxqtRunning_;
156 
157  bool isX11_;
158 
159  int argc_;
160  char** argv_;
161 };
162 
163 }
164 
165 #endif // PCMANFM_APPLICATION_H
Definition: application.h:56
Definition: desktopwindow.h:46
Definition: application.h:48
Definition: settings.h:154