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