NDE-FileMAN
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 NDEFILEMAN_APPLICATION_H
22#define NDEFILEMAN_APPLICATION_H
23
24#include <QApplication>
25#include "settings.h"
26#include <libfm-qt-nde/libfmqt.h>
27#include <libfm-qt-nde/editbookmarksdialog.h>
28#include <QVector>
29#include <QPointer>
30#include <QProxyStyle>
31#include <QTranslator>
32#include <gio/gio.h>
33
34#include <libfm-qt-nde/core/filepath.h>
35#include <libfm-qt-nde/core/fileinfo.h>
36
37class QScreen;
38
39class QFileSystemWatcher;
40
41namespace NDEFileMAN {
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 = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) 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 // public interface exported via dbus
76 void launchFiles(QString cwd, QStringList paths, bool inNewWindow);
77 void setWallpaper(QString path, QString modeString);
78 void preferences(QString page);
79 void desktopPrefrences(QString page);
80 void editBookmarks();
81 void desktopManager(bool enabled);
82 void findFiles(QStringList paths = QStringList());
83 void connectToServer();
84
85 bool desktopManagerEnabled() {
86 return enableDesktopManager_;
87 }
88
89 void updateFromSettings();
90 void updateDesktopsFromSettings(bool changeSlide = true);
91
92 void openFolderInTerminal(Fm::FilePath path);
93 void openFolders(Fm::FileInfoList files);
94
95 QString profileName() {
96 return profileName_;
97 }
98
99protected Q_SLOTS:
100 void onAboutToQuit();
101 void onSigtermNotified();
102
103 void onLastWindowClosed();
104 void onSaveStateRequest(QSessionManager& manager);
105 void initVolumeManager();
106
107 void onVirtualGeometryChanged(const QRect& rect);
108 void onAvailableGeometryChanged(const QRect& rect);
109 void onScreenDestroyed(QObject* screenObj);
110 void onScreenAdded(QScreen* newScreen);
111 void onScreenRemoved(QScreen* oldScreen);
112 void reloadDesktopsAsNeeded();
113
114 void onFindFileAccepted();
115 void onConnectToServerAccepted();
116
117protected:
118 //virtual bool eventFilter(QObject* watched, QEvent* event);
119 bool parseCommandLineArgs();
120 DesktopWindow* createDesktopWindow(int screenNum);
121 bool autoMountVolume(GVolume* volume, bool interactive = true);
122
123 static void onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis);
124
125private Q_SLOTS:
126 void onUserDirsChanged();
127
128private:
129 void initWatch();
130 void installSigtermHandler();
131
132 bool isPrimaryInstance;
133 Fm::LibFmQt libFm_;
134 Settings settings_;
135 QString profileName_;
136 bool daemonMode_;
137 bool enableDesktopManager_;
138 QVector<DesktopWindow*> desktopWindows_;
139 QPointer<PreferencesDialog> preferencesDialog_;
140 QPointer<DesktopPreferencesDialog> desktopPreferencesDialog_;
141 QPointer<Fm::EditBookmarksDialog> editBookmarksialog_;
142 QTranslator translator;
143 QTranslator qtTranslator;
144 GVolumeMonitor* volumeMonitor_;
145
146 QFileSystemWatcher* userDirsWatcher_;
147 QString userDirsFile_;
148 QString userDesktopFolder_;
149 bool ndeRunning_;
150
151 int argc_;
152 char** argv_;
153};
154
155}
156
157#endif // NDEFILEMAN_APPLICATION_H
Definition application.h:56
Definition desktopwindow.h:48
Definition application.h:48
Definition settings.h:170