1 | /* |
2 | * Copyright (C) by Klaas Freitag <freitag@owncloud.com> |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, but |
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 | * for more details. |
13 | */ |
14 | |
15 | #ifndef OWNCLOUDGUI_H |
16 | #define OWNCLOUDGUI_H |
17 | |
18 | #include "systray.h" |
19 | #include "connectionvalidator.h" |
20 | #include "progressdispatcher.h" |
21 | |
22 | #include <QObject> |
23 | #include <QPointer> |
24 | #include <QAction> |
25 | #include <QMenu> |
26 | #include <QSize> |
27 | #include <QTimer> |
28 | |
29 | namespace OCC { |
30 | |
31 | class Folder; |
32 | |
33 | class SettingsDialog; |
34 | class SettingsDialogMac; |
35 | class ShareDialog; |
36 | class Application; |
37 | class LogBrowser; |
38 | class AccountState; |
39 | |
40 | enum class ShareDialogStartPage { |
41 | UsersAndGroups, |
42 | PublicLinks, |
43 | }; |
44 | |
45 | /** |
46 | * @brief The ownCloudGui class |
47 | * @ingroup gui |
48 | */ |
49 | class ownCloudGui : public QObject |
50 | { |
51 | Q_OBJECT |
52 | public: |
53 | explicit ownCloudGui(Application *parent = 0); |
54 | |
55 | bool checkAccountExists(bool openSettings); |
56 | |
57 | static void raiseDialog(QWidget *raiseWidget); |
58 | static QSize settingsDialogSize() { return QSize(800, 500); } |
59 | void setupOverlayIcons(); |
60 | |
61 | /// Whether the tray menu is visible |
62 | bool () const; |
63 | |
64 | signals: |
65 | void setupProxy(); |
66 | |
67 | public slots: |
68 | void (); |
69 | void (); |
70 | void (); |
71 | void (); |
72 | void (); |
73 | void slotComputeOverallSyncStatus(); |
74 | void slotShowTrayMessage(const QString &title, const QString &msg); |
75 | void slotShowOptionalTrayMessage(const QString &title, const QString &msg); |
76 | void slotFolderOpenAction(const QString &alias); |
77 | void (); |
78 | void slotUpdateProgress(const QString &folder, const ProgressInfo &progress); |
79 | void slotShowGuiMessage(const QString &title, const QString &message); |
80 | void slotFoldersChanged(); |
81 | void slotShowSettings(); |
82 | void slotShowSyncProtocol(); |
83 | void slotShutdown(); |
84 | void slotSyncStateChange(Folder *); |
85 | void slotTrayClicked(QSystemTrayIcon::ActivationReason reason); |
86 | void slotToggleLogBrowser(); |
87 | void slotOpenOwnCloud(); |
88 | void slotOpenSettingsDialog(); |
89 | void slotHelp(); |
90 | void slotOpenPath(const QString &path); |
91 | void slotAccountStateChanged(); |
92 | void slotTrayMessageIfServerUnsupported(Account *account); |
93 | |
94 | /** |
95 | * Open a share dialog for a file or folder. |
96 | * |
97 | * sharePath is the full remote path to the item, |
98 | * localPath is the absolute local path to it (so not relative |
99 | * to the folder). |
100 | */ |
101 | void slotShowShareDialog(const QString &sharePath, const QString &localPath, ShareDialogStartPage startPage); |
102 | |
103 | void slotRemoveDestroyedShareDialogs(); |
104 | |
105 | private slots: |
106 | void slotLogin(); |
107 | void slotLogout(); |
108 | void slotUnpauseAllFolders(); |
109 | void slotPauseAllFolders(); |
110 | void slotNewAccountWizard(); |
111 | void slotAbout(); |
112 | |
113 | private: |
114 | void setPauseOnAllFoldersHelper(bool pause); |
115 | void setupActions(); |
116 | void (AccountStatePtr accountState, QMenu *, bool ); |
117 | |
118 | QPointer<Systray> _tray; |
119 | #if defined(Q_OS_MAC) |
120 | QPointer<SettingsDialogMac> _settingsDialog; |
121 | #else |
122 | QPointer<SettingsDialog> _settingsDialog; |
123 | #endif |
124 | QPointer<LogBrowser> _logBrowser; |
125 | // tray's menu |
126 | QScopedPointer<QMenu> ; |
127 | |
128 | // Manually tracking whether the context menu is visible via aboutToShow |
129 | // and aboutToHide. Unfortunately aboutToHide isn't reliable everywhere |
130 | // so this only gets used with _workaroundManualVisibility (when the tray's |
131 | // isVisible() is unreliable) |
132 | bool = false; |
133 | |
134 | QMenu *; |
135 | QVector<QMenu *> ; |
136 | bool _workaroundShowAndHideTray = false; |
137 | bool _workaroundNoAboutToShowUpdate = false; |
138 | bool _workaroundFakeDoubleClick = false; |
139 | bool _workaroundManualVisibility = false; |
140 | QTimer _delayedTrayUpdateTimer; |
141 | QMap<QString, QPointer<ShareDialog>> _shareDialogs; |
142 | |
143 | QAction *_actionLogin; |
144 | QAction *_actionLogout; |
145 | |
146 | QAction *_actionNewAccountWizard; |
147 | QAction *_actionSettings; |
148 | QAction *_actionStatus; |
149 | QAction *_actionEstimate; |
150 | QAction *_actionRecent; |
151 | QAction *_actionHelp; |
152 | QAction *_actionAbout; |
153 | QAction *_actionQuit; |
154 | QAction *_actionCrash; |
155 | |
156 | QList<QAction *> _recentItemsActions; |
157 | Application *_app; |
158 | }; |
159 | |
160 | } // namespace OCC |
161 | |
162 | #endif // OWNCLOUDGUI_H |
163 | |