nextcloud-desktop/src/gui/owncloudgui.h
ckamm 98efb07535 Tray: Workaround collection (#5179)
Tray: Workaround collection

* QDBus workaround for Qt 5.5.0 only, there were reports of the tray
  working fine with 5.5.1. #5164
* OWNCLOUD_FORCE_QDBUS_TRAY_WORKAROUND to force the workaround on an off
* OWNCLOUD_TRAY_UPDATE_WHILE_VISIBLE to enable or disable updating of
  the menu while it's visible - disable by default due to problems on OSX and Xubuntu.
* Track the visibility of the tray menu with aboutToShow/aboutToHide
  only on OSX - the aboutToHide signal doesn't trigger reliably on linux
* Refactor such that setupContextMenu is different from updateContextMenu
* Don't use on-demand updating of the tray menu when the qdbus workaround
  is active, instead to occasional (30s) updates of the tray menu.
2016-09-23 10:44:54 +02:00

144 lines
4 KiB
C++

/*
* 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
* the Free Software Foundation; version 2 of the License.
*
* 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
#include "systray.h"
#include "connectionvalidator.h"
#include "progressdispatcher.h"
#include <QObject>
#include <QPointer>
#include <QAction>
#include <QMenu>
#include <QSignalMapper>
#include <QSize>
#include <QTimer>
namespace OCC {
class Folder;
class SettingsDialog;
class SettingsDialogMac;
class ShareDialog;
class Application;
class LogBrowser;
class AccountState;
/**
* @brief The ownCloudGui class
* @ingroup gui
*/
class ownCloudGui : public QObject
{
Q_OBJECT
public:
explicit ownCloudGui(Application *parent = 0);
bool checkAccountExists(bool openSettings);
static void raiseDialog(QWidget *raiseWidget);
static QSize settingsDialogSize() { return QSize(800, 500); }
void setupOverlayIcons();
/// Whether the tray menu is visible
bool contextMenuVisible() const;
signals:
void setupProxy();
public slots:
void setupContextMenu();
void updateContextMenu();
void updateContextMenuNeeded();
void slotContextMenuAboutToShow();
void slotContextMenuAboutToHide();
void slotComputeOverallSyncStatus();
void slotShowTrayMessage(const QString &title, const QString &msg);
void slotShowOptionalTrayMessage(const QString &title, const QString &msg);
void slotFolderOpenAction( const QString& alias );
void slotRebuildRecentMenus();
void slotUpdateProgress(const QString &folder, const ProgressInfo& progress);
void slotShowGuiMessage(const QString &title, const QString &message);
void slotFoldersChanged();
void slotShowSettings();
void slotShowSyncProtocol();
void slotShutdown();
void slotSyncStateChange(Folder*);
void slotTrayClicked( QSystemTrayIcon::ActivationReason reason );
void slotToggleLogBrowser();
void slotOpenOwnCloud();
void slotOpenSettingsDialog();
void slotHelp();
void slotOpenPath(const QString& path);
void slotAccountStateChanged();
void slotTrayMessageIfServerUnsupported(Account *account);
void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
void slotRemoveDestroyedShareDialogs();
private slots:
void slotDisplayIdle();
void slotLogin();
void slotLogout();
void slotUnpauseAllFolders();
void slotPauseAllFolders();
private:
void setPauseOnAllFoldersHelper(bool pause);
void setupActions();
void addAccountContextMenu(AccountStatePtr accountState, QMenu* menu, bool separateMenu);
QPointer<Systray> _tray;
#if defined(Q_OS_MAC)
QPointer<SettingsDialogMac> _settingsDialog;
#else
QPointer<SettingsDialog> _settingsDialog;
#endif
QPointer<LogBrowser>_logBrowser;
// tray's menu
QScopedPointer<QMenu> _contextMenu;
// Manually tracking whether the context menu is visible, but only works
// on OSX because aboutToHide is not reliable everywhere.
bool _contextMenuVisibleOsx;
QMenu *_recentActionsMenu;
QVector<QMenu*> _accountMenus;
bool _qdbusmenuWorkaround;
QTimer _workaroundBatchTrayUpdate;
QMap<QString, QPointer<ShareDialog> > _shareDialogs;
QAction *_actionLogin;
QAction *_actionLogout;
QAction *_actionSettings;
QAction *_actionStatus;
QAction *_actionEstimate;
QAction *_actionRecent;
QAction *_actionHelp;
QAction *_actionQuit;
QAction *_actionCrash;
QList<QAction*> _recentItemsActions;
QSignalMapper *_folderOpenActionMapper;
QSignalMapper *_recentItemsMapper;
Application *_app;
};
} // namespace OCC
#endif // OWNCLOUDGUI_H