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