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 MainWindow;
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  void connectToServer();
81 
82  bool desktopManagerEnabled() {
83  return enableDesktopManager_;
84  }
85 
86  void updateFromSettings();
87  void updateDesktopsFromSettings();
88 
89  void openFolderInTerminal(Fm::Path path);
90  void openFolders(Fm::FileInfoList files);
91 
92  QString profileName() {
93  return profileName_;
94  }
95 
96 protected Q_SLOTS:
97  void onAboutToQuit();
98  void onSigtermNotified();
99 
100  void onLastWindowClosed();
101  void onSaveStateRequest(QSessionManager & manager);
102  void onScreenResized(int num);
103  void onScreenCountChanged(int newCount);
104  void initVolumeManager();
105 
106  void onVirtualGeometryChanged(const QRect& rect);
107  void onScreenDestroyed(QObject* screenObj);
108  void onScreenAdded(QScreen* newScreen);
109  void reloadDesktopsAsNeeded();
110 
111  void onFindFileAccepted();
112  void onConnectToServerAccepted();
113 
114 protected:
115  virtual bool eventFilter(QObject* watched, QEvent* event);
116  bool parseCommandLineArgs();
117  DesktopWindow* createDesktopWindow(int screenNum);
118  bool autoMountVolume(GVolume* volume, bool interactive = true);
119 
120  static void onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis);
121 
122 private Q_SLOTS:
123  void onUserDirsChanged();
124 
125 private:
126  void initWatch();
127  void installSigtermHandler();
128 
129  bool isPrimaryInstance;
130  Fm::LibFmQt libFm_;
131  Settings settings_;
132  QString profileName_;
133  bool daemonMode_;
134  bool enableDesktopManager_;
135  QVector<DesktopWindow*> desktopWindows_;
136  QPointer<PreferencesDialog> preferencesDialog_;
137  QPointer<DesktopPreferencesDialog> desktopPreferencesDialog_;
138  QPointer<Fm::EditBookmarksDialog> editBookmarksialog_;
139  QTranslator translator;
140  QTranslator qtTranslator;
141  GVolumeMonitor* volumeMonitor_;
142 
143  QFileSystemWatcher *userDirsWatcher_;
144  QString userDirsFile_;
145  QString userDesktopFolder_;
146  bool lxqtRunning_;
147 
148  int argc_;
149  char** argv_;
150 };
151 
152 }
153 
154 #endif // PCMANFM_APPLICATION_H
Definition: application.h:53
Definition: settings.h:121
Definition: application.cpp:59
Definition: application.h:45
Definition: desktopwindow.h:43