Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Cambra <claudio.cambra@gmail.com>2022-06-30 17:20:13 +0300
committerClaudio Cambra <claudio.cambra@gmail.com>2022-06-30 17:20:13 +0300
commit2758a1d8cf2887d8fea56e6b21e24d234a95d79f (patch)
tree32d52e1d77d30372817b8c5d58e70615454f53b3
parent277aefc24e45f2a738fd897a422e37537653a7cd (diff)
Clean up systray methods, make more QML-friendlywork/systray-cleanup
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
-rw-r--r--src/gui/systray.cpp25
-rw-r--r--src/gui/systray.h25
-rw-r--r--src/gui/tray/Window.qml16
3 files changed, 33 insertions, 33 deletions
diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp
index 128937cde..276e53a1b 100644
--- a/src/gui/systray.cpp
+++ b/src/gui/systray.cpp
@@ -267,11 +267,6 @@ void Systray::setPauseOnAllFoldersHelper(bool pause)
}
}
-bool Systray::isOpen()
-{
- return _isOpen;
-}
-
QString Systray::windowTitle() const
{
return Theme::instance()->appNameGUI();
@@ -287,14 +282,15 @@ bool Systray::useNormalWindow() const
return cfg.showMainDialogAsNormalWindow();
}
-Q_INVOKABLE void Systray::setOpened()
+bool Systray::isOpen() const
{
- _isOpen = true;
+ return _isOpen;
}
-Q_INVOKABLE void Systray::setClosed()
+void Systray::setIsOpen(const bool isOpen)
{
- _isOpen = false;
+ _isOpen = isOpen;
+ Q_EMIT isOpenChanged();
}
void Systray::showMessage(const QString &title, const QString &message, MessageIcon icon)
@@ -334,19 +330,18 @@ void Systray::setToolTip(const QString &tip)
QSystemTrayIcon::setToolTip(tr("%1: %2").arg(Theme::instance()->appNameGUI(), tip));
}
-bool Systray::syncIsPaused()
+bool Systray::syncIsPaused() const
{
return _syncIsPaused;
}
-void Systray::pauseResumeSync()
+void Systray::setSyncIsPaused(const bool syncIsPaused)
{
+ _syncIsPaused = syncIsPaused;
if (_syncIsPaused) {
- _syncIsPaused = false;
- slotUnpauseAllFolders();
- } else {
- _syncIsPaused = true;
slotPauseAllFolders();
+ } else {
+ slotUnpauseAllFolders();
}
}
diff --git a/src/gui/systray.h b/src/gui/systray.h
index 18f01cd93..c8e6490ef 100644
--- a/src/gui/systray.h
+++ b/src/gui/systray.h
@@ -66,6 +66,8 @@ class Systray
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 isOpen READ isOpen WRITE setIsOpen NOTIFY isOpenChanged)
public:
static Systray *instance();
@@ -82,18 +84,13 @@ public:
void showMessage(const QString &title, const QString &message, MessageIcon icon = Information);
void showUpdateMessage(const QString &title, const QString &message, const QUrl &webUrl);
void setToolTip(const QString &tip);
- bool isOpen();
+
QString windowTitle() const;
bool useNormalWindow() const;
- void createCallDialog(const Activity &callNotification);
+ bool syncIsPaused() const;
+ bool isOpen() const;
- Q_INVOKABLE void pauseResumeSync();
- Q_INVOKABLE bool syncIsPaused();
- Q_INVOKABLE void setOpened();
- Q_INVOKABLE void setClosed();
- Q_INVOKABLE void positionWindow(QQuickWindow *window) const;
- Q_INVOKABLE void forceWindowInit(QQuickWindow *window) const;
- Q_INVOKABLE void positionNotificationWindow(QQuickWindow *window) const;
+ void createCallDialog(const Activity &callNotification);
signals:
void currentUserChanged();
@@ -110,9 +107,19 @@ signals:
void sendChatMessage(const QString &token, const QString &message, const QString &replyTo);
void showErrorMessageDialog(const QString &error);
+ void syncIsPausedChanged();
+ void isOpenChanged();
+
public slots:
void slotNewUserSelected();
+ void setSyncIsPaused(const bool syncIsPaused);
+ void setIsOpen(const bool isOpen);
+
+ void positionWindow(QQuickWindow *window) const;
+ void forceWindowInit(QQuickWindow *window) const;
+ void positionNotificationWindow(QQuickWindow *window) const;
+
private slots:
void slotUnpauseAllFolders();
void slotPauseAllFolders();
diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml
index 3b5d80ff3..9a5a8ed32 100644
--- a/src/gui/tray/Window.qml
+++ b/src/gui/tray/Window.qml
@@ -39,13 +39,11 @@ Window {
onActiveChanged: {
if (!Systray.useNormalWindow && !active) {
hide();
- Systray.setClosed();
+ Systray.isOpen = false;
}
}
- onClosing: {
- Systray.setClosed()
- }
+ onClosing: Systray.isOpen = false
onVisibleChanged: {
// HACK: reload account Instantiator immediately by restting it - could be done better I guess
@@ -87,12 +85,12 @@ Window {
trayWindow.raise();
trayWindow.requestActivate();
- Systray.setOpened();
+ Systray.isOpen = true;
UserModel.fetchCurrentActivityModel();
}
function onHideWindow() {
trayWindow.hide();
- Systray.setClosed();
+ Systray.isOpen = false;
}
function onShowFileActivityDialog(objectName, objectId) {
@@ -167,7 +165,7 @@ Window {
// We call open() instead of popup() because we want to position it
// exactly below the dropdown button, not the mouse
onClicked: {
- syncPauseButton.text = Systray.syncIsPaused() ? qsTr("Resume sync for all") : qsTr("Pause sync for all")
+ syncPauseButton.text = Systray.syncIsPaused ? qsTr("Resume sync for all") : qsTr("Pause sync for all")
if (accountMenu.visible) {
accountMenu.close()
} else {
@@ -311,7 +309,7 @@ Window {
font.pixelSize: Style.topLinePixelSize
palette.windowText: Style.ncTextColor
hoverEnabled: true
- onClicked: Systray.pauseResumeSync()
+ onClicked: Systray.syncIsPaused = !Systray.syncIsPaused
background: Item {
height: parent.height
@@ -324,7 +322,7 @@ Window {
}
Accessible.role: Accessible.MenuItem
- Accessible.name: Systray.syncIsPaused() ? qsTr("Resume sync for all") : qsTr("Pause sync for all")
+ Accessible.name: Systray.syncIsPaused ? qsTr("Resume sync for all") : qsTr("Pause sync for all")
Accessible.onPressAction: syncPauseButton.clicked()
}