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