mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
gui: Expose if there are any configured sync folders in systray class to QML
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
8f878635b4
commit
5e71d6c026
@ -109,6 +109,9 @@ Systray::Systray()
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||
this, [this]{ showWindow(WindowPosition::Center); });
|
||||
#endif
|
||||
|
||||
connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &Systray::slotSyncFoldersChanged);
|
||||
slotSyncFoldersChanged(FolderMan::instance()->map());
|
||||
}
|
||||
|
||||
void Systray::create()
|
||||
@ -490,6 +493,14 @@ void Systray::slotPauseAllFolders()
|
||||
setPauseOnAllFoldersHelper(true);
|
||||
}
|
||||
|
||||
void Systray::slotSyncFoldersChanged(const OCC::Folder::Map &folderMap)
|
||||
{
|
||||
if (const auto currentAnySyncFolders = !folderMap.isEmpty(); currentAnySyncFolders != _anySyncFolders) {
|
||||
_anySyncFolders = currentAnySyncFolders;
|
||||
emit anySyncFoldersChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Systray::setPauseOnAllFoldersHelper(bool pause)
|
||||
{
|
||||
// For some reason we get the raw pointer from Folder::accountState()
|
||||
@ -610,6 +621,11 @@ void Systray::setSyncIsPaused(const bool syncIsPaused)
|
||||
emit syncIsPausedChanged();
|
||||
}
|
||||
|
||||
bool Systray::anySyncFolders() const
|
||||
{
|
||||
return _anySyncFolders;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
/* Helper functions for cross-platform tray icon position and taskbar orientation detection */
|
||||
/********************************************************************************************/
|
||||
|
||||
@ -69,6 +69,7 @@ class Systray : public QSystemTrayIcon
|
||||
Q_PROPERTY(QString windowTitle READ windowTitle CONSTANT)
|
||||
Q_PROPERTY(bool useNormalWindow READ useNormalWindow CONSTANT)
|
||||
Q_PROPERTY(bool syncIsPaused READ syncIsPaused WRITE setSyncIsPaused NOTIFY syncIsPausedChanged)
|
||||
Q_PROPERTY(bool anySyncFolders READ anySyncFolders NOTIFY anySyncFoldersChanged)
|
||||
Q_PROPERTY(bool isOpen READ isOpen WRITE setIsOpen NOTIFY isOpenChanged)
|
||||
Q_PROPERTY(bool enableAddAccount READ enableAddAccount CONSTANT)
|
||||
|
||||
@ -92,6 +93,7 @@ public:
|
||||
Q_REQUIRED_RESULT bool useNormalWindow() const;
|
||||
|
||||
Q_REQUIRED_RESULT bool syncIsPaused() const;
|
||||
Q_REQUIRED_RESULT bool anySyncFolders() const;
|
||||
Q_REQUIRED_RESULT bool isOpen() const;
|
||||
|
||||
[[nodiscard]] bool enableAddAccount() const;
|
||||
@ -113,6 +115,7 @@ signals:
|
||||
void showErrorMessageDialog(const QString &error);
|
||||
|
||||
void syncIsPausedChanged();
|
||||
void anySyncFoldersChanged();
|
||||
void isOpenChanged();
|
||||
|
||||
void hideSettingsDialog();
|
||||
@ -158,6 +161,7 @@ private slots:
|
||||
void slotUpdateSyncPausedState();
|
||||
void slotUnpauseAllFolders();
|
||||
void slotPauseAllFolders();
|
||||
void slotSyncFoldersChanged(const OCC::Folder::Map &foldeMap);
|
||||
|
||||
private:
|
||||
// Argument allows user to specify a specific dialog to be raised
|
||||
@ -183,6 +187,8 @@ private:
|
||||
|
||||
bool _isOpen = false;
|
||||
bool _syncIsPaused = true;
|
||||
bool _anySyncFolders = false;
|
||||
|
||||
std::unique_ptr<QQmlApplicationEngine> _trayEngine;
|
||||
QPointer<QMenu> _contextMenu;
|
||||
QSharedPointer<QQuickWindow> _trayWindow;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user