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 = nullptr, const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) 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(const QString& cwd, const QStringList& paths, bool inNewWindow, bool reopenLastTabs);
81  void setWallpaper(const QString& path, const QString& modeString);
82  void preferences(const QString& page);
83  void desktopPrefrences(const QString& page);
84  void editBookmarks();
85  void desktopManager(bool enabled);
86  void findFiles(QStringList paths = QStringList());
87  void ShowFolders(const QStringList& uriList, const QString& startupId);
88  void ShowItems(const QStringList& uriList, const QString& startupId);
89  void ShowItemProperties(const QStringList& uriList, const QString& startupId);
90  void connectToServer();
91 
92  bool desktopManagerEnabled() {
93  return enableDesktopManager_;
94  }
95 
96  void updateFromSettings();
97  void updateDesktopsFromSettings(bool changeSlide = true);
98 
99  void openFolderInTerminal(Fm::FilePath path);
100  void openFolders(Fm::FileInfoList files);
101 
102  QString profileName() {
103  return profileName_;
104  }
105 
106  void cleanPerFolderConfig();
107 
108 protected Q_SLOTS:
109  void onAboutToQuit();
110  void onSigtermNotified();
111 
112  void onLastWindowClosed();
113  void onSaveStateRequest(QSessionManager& manager);
114  void initVolumeManager();
115 
116  void onVirtualGeometryChanged(const QRect& rect);
117  void onAvailableGeometryChanged(const QRect& rect);
118  void onScreenDestroyed(QObject* screenObj);
119  void onScreenAdded(QScreen* newScreen);
120  void onScreenRemoved(QScreen* oldScreen);
121  void reloadDesktopsAsNeeded();
122 
123  void onFindFileAccepted();
124  void onConnectToServerAccepted();
125 
126 protected:
127  //virtual bool eventFilter(QObject* watched, QEvent* event);
128  bool parseCommandLineArgs();
129  DesktopWindow* createDesktopWindow(int screenNum);
130  bool autoMountVolume(GVolume* volume, bool interactive = true);
131 
132  static void onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis);
133 
134 private Q_SLOTS:
135  void onUserDirsChanged();
136  void onPropJobFinished();
137 
138 private:
139  void initWatch();
140  void installSigtermHandler();
141 
142  bool isPrimaryInstance;
143  Fm::LibFmQt libFm_;
144  Settings settings_;
145  QString profileName_;
146  bool daemonMode_;
147  bool enableDesktopManager_;
148  QVector<DesktopWindow*> desktopWindows_;
149  QPointer<PreferencesDialog> preferencesDialog_;
150  QPointer<DesktopPreferencesDialog> desktopPreferencesDialog_;
151  QPointer<Fm::EditBookmarksDialog> editBookmarksialog_;
152  QTranslator translator;
153  QTranslator qtTranslator;
154  GVolumeMonitor* volumeMonitor_;
155 
156  QFileSystemWatcher* userDirsWatcher_;
157  QString userDirsFile_;
158  QString userDesktopFolder_;
159  bool lxqtRunning_;
160 
161  bool isX11_;
162 
163  int argc_;
164  char** argv_;
165 };
166 
167 }
168 
169 #endif // PCMANFM_APPLICATION_H
Definition: application.h:56
Definition: desktopwindow.h:46
Definition: application.h:48
Definition: settings.h:154