2013-10-01 15:52:07 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2013-10-01 15:52:07 +04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OWNCLOUDGUI_H
|
|
|
|
#define OWNCLOUDGUI_H
|
|
|
|
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "systray.h"
|
|
|
|
#include "connectionvalidator.h"
|
|
|
|
#include "progressdispatcher.h"
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QMenu>
|
2015-07-20 19:15:45 +03:00
|
|
|
#include <QSize>
|
2016-09-23 11:44:54 +03:00
|
|
|
#include <QTimer>
|
2017-12-15 11:45:28 +03:00
|
|
|
#ifdef WITH_LIBCLOUDPROVIDERS
|
2017-07-23 21:58:00 +03:00
|
|
|
#include <QDBusConnection>
|
2017-12-15 11:45:28 +03:00
|
|
|
#endif
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2015-04-28 16:13:39 +03:00
|
|
|
class Folder;
|
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
class SettingsDialog;
|
2014-02-14 06:02:59 +04:00
|
|
|
class SettingsDialogMac;
|
2016-01-20 15:17:54 +03:00
|
|
|
class ShareDialog;
|
2013-10-01 15:52:07 +04:00
|
|
|
class Application;
|
2013-10-02 17:28:33 +04:00
|
|
|
class LogBrowser;
|
2015-07-03 11:59:44 +03:00
|
|
|
class AccountState;
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The ownCloudGui class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2013-10-01 15:52:07 +04:00
|
|
|
class ownCloudGui : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ownCloudGui(Application *parent = 0);
|
|
|
|
|
2013-11-04 19:36:23 +04:00
|
|
|
bool checkAccountExists(bool openSettings);
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2014-07-07 17:20:37 +04:00
|
|
|
static void raiseDialog(QWidget *raiseWidget);
|
2015-07-20 19:15:45 +03:00
|
|
|
static QSize settingsDialogSize() { return QSize(800, 500); }
|
2014-08-01 16:28:34 +04:00
|
|
|
void setupOverlayIcons();
|
2017-07-23 21:58:00 +03:00
|
|
|
#ifdef WITH_LIBCLOUDPROVIDERS
|
|
|
|
void setupCloudProviders();
|
|
|
|
bool cloudProviderApiAvailable();
|
|
|
|
#endif
|
2014-07-07 17:20:37 +04:00
|
|
|
|
2016-09-23 11:44:54 +03:00
|
|
|
/// Whether the tray menu is visible
|
|
|
|
bool contextMenuVisible() const;
|
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
signals:
|
2013-10-02 17:28:33 +04:00
|
|
|
void setupProxy();
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
public slots:
|
2015-07-03 12:13:19 +03:00
|
|
|
void setupContextMenu();
|
2016-09-23 11:44:54 +03:00
|
|
|
void updateContextMenu();
|
|
|
|
void updateContextMenuNeeded();
|
2016-09-13 15:34:22 +03:00
|
|
|
void slotContextMenuAboutToShow();
|
|
|
|
void slotContextMenuAboutToHide();
|
2013-10-02 17:28:33 +04:00
|
|
|
void slotComputeOverallSyncStatus();
|
2013-10-01 15:52:07 +04:00
|
|
|
void slotShowTrayMessage(const QString &title, const QString &msg);
|
|
|
|
void slotShowOptionalTrayMessage(const QString &title, const QString &msg);
|
|
|
|
void slotFolderOpenAction(const QString &alias);
|
2013-10-02 17:28:33 +04:00
|
|
|
void slotRebuildRecentMenus();
|
2015-01-30 15:36:20 +03:00
|
|
|
void slotUpdateProgress(const QString &folder, const ProgressInfo &progress);
|
2013-10-01 15:52:07 +04:00
|
|
|
void slotShowGuiMessage(const QString &title, const QString &message);
|
|
|
|
void slotFoldersChanged();
|
2013-11-26 06:15:03 +04:00
|
|
|
void slotShowSettings();
|
2013-11-29 14:18:59 +04:00
|
|
|
void slotShowSyncProtocol();
|
2013-10-02 17:28:33 +04:00
|
|
|
void slotShutdown();
|
2015-04-28 16:13:39 +03:00
|
|
|
void slotSyncStateChange(Folder *);
|
2013-10-01 15:52:07 +04:00
|
|
|
void slotTrayClicked(QSystemTrayIcon::ActivationReason reason);
|
2013-10-02 17:28:33 +04:00
|
|
|
void slotToggleLogBrowser();
|
|
|
|
void slotOpenOwnCloud();
|
2015-09-02 12:10:01 +03:00
|
|
|
void slotOpenSettingsDialog();
|
2013-10-02 17:28:33 +04:00
|
|
|
void slotHelp();
|
2013-10-02 20:16:24 +04:00
|
|
|
void slotOpenPath(const QString &path);
|
2013-11-25 18:33:35 +04:00
|
|
|
void slotAccountStateChanged();
|
2016-03-02 13:59:36 +03:00
|
|
|
void slotTrayMessageIfServerUnsupported(Account *account);
|
2017-05-10 10:37:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a share dialog for a file or folder.
|
|
|
|
*
|
|
|
|
* sharePath is the full remote path to the item,
|
|
|
|
* localPath is the absolute local path to it (so not relative
|
|
|
|
* to the folder).
|
|
|
|
*/
|
|
|
|
void slotShowShareDialog(const QString &sharePath, const QString &localPath);
|
|
|
|
|
2016-01-20 15:17:54 +03:00
|
|
|
void slotRemoveDestroyedShareDialogs();
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
private slots:
|
2015-07-03 11:59:44 +03:00
|
|
|
void slotLogin();
|
|
|
|
void slotLogout();
|
2016-03-01 18:07:11 +03:00
|
|
|
void slotUnpauseAllFolders();
|
|
|
|
void slotPauseAllFolders();
|
2016-11-18 14:17:05 +03:00
|
|
|
void slotNewAccountWizard();
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
private:
|
2016-03-01 18:07:11 +03:00
|
|
|
void setPauseOnAllFoldersHelper(bool pause);
|
2013-10-01 15:52:07 +04:00
|
|
|
void setupActions();
|
2015-07-03 11:59:44 +03:00
|
|
|
void addAccountContextMenu(AccountStatePtr accountState, QMenu *menu, bool separateMenu);
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
QPointer<Systray> _tray;
|
2014-02-14 06:02:59 +04:00
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
QPointer<SettingsDialogMac> _settingsDialog;
|
|
|
|
#else
|
2013-10-01 15:52:07 +04:00
|
|
|
QPointer<SettingsDialog> _settingsDialog;
|
2014-02-14 06:02:59 +04:00
|
|
|
#endif
|
2013-10-02 17:28:33 +04:00
|
|
|
QPointer<LogBrowser> _logBrowser;
|
|
|
|
// tray's menu
|
2014-10-15 20:11:18 +04:00
|
|
|
QScopedPointer<QMenu> _contextMenu;
|
2016-09-23 11:44:54 +03:00
|
|
|
|
|
|
|
// Manually tracking whether the context menu is visible, but only works
|
|
|
|
// on OSX because aboutToHide is not reliable everywhere.
|
|
|
|
bool _contextMenuVisibleOsx;
|
2016-09-13 15:34:22 +03:00
|
|
|
|
2017-12-15 11:45:28 +03:00
|
|
|
#ifdef WITH_LIBCLOUDPROVIDERS
|
2017-07-23 21:58:00 +03:00
|
|
|
QDBusConnection _bus;
|
2017-12-15 11:45:28 +03:00
|
|
|
#endif
|
2017-07-23 21:58:00 +03:00
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
QMenu *_recentActionsMenu;
|
2015-07-03 11:59:44 +03:00
|
|
|
QVector<QMenu *> _accountMenus;
|
2015-09-04 12:58:50 +03:00
|
|
|
bool _qdbusmenuWorkaround;
|
2016-09-23 11:44:54 +03:00
|
|
|
QTimer _workaroundBatchTrayUpdate;
|
2016-01-20 15:17:54 +03:00
|
|
|
QMap<QString, QPointer<ShareDialog>> _shareDialogs;
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2013-11-23 03:14:02 +04:00
|
|
|
QAction *_actionLogin;
|
|
|
|
QAction *_actionLogout;
|
|
|
|
|
2016-11-18 14:17:05 +03:00
|
|
|
QAction *_actionNewAccountWizard;
|
2013-10-01 15:52:07 +04:00
|
|
|
QAction *_actionSettings;
|
|
|
|
QAction *_actionStatus;
|
2014-04-29 03:31:27 +04:00
|
|
|
QAction *_actionEstimate;
|
2013-10-01 15:52:07 +04:00
|
|
|
QAction *_actionRecent;
|
|
|
|
QAction *_actionHelp;
|
|
|
|
QAction *_actionQuit;
|
2014-08-26 17:46:24 +04:00
|
|
|
QAction *_actionCrash;
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2014-03-20 17:43:10 +04:00
|
|
|
QList<QAction *> _recentItemsActions;
|
2013-10-02 20:16:24 +04:00
|
|
|
Application *_app;
|
2013-10-01 15:52:07 +04:00
|
|
|
};
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
} // namespace OCC
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
#endif // OWNCLOUDGUI_H
|