addd a cmake option to enable single account desktop client
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 6 Jun 2023 10:33:34 +0000 (12:33 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Fri, 9 Jun 2023 13:46:40 +0000 (15:46 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
NEXTCLOUD.cmake
config.h.in
src/gui/owncloudgui.cpp
src/gui/systray.cpp
src/gui/systray.h
src/gui/tray/Window.qml

index b48ba5291be44635c4d38bebdeee12dd99ec39de..1dd12d86b5073d612f37f131b7f25d19caf8f2a0 100644 (file)
@@ -44,6 +44,8 @@ option( WITH_PROVIDERS "Build with providers list" ON )
 
 option( ENFORCE_VIRTUAL_FILES_SYNC_FOLDER "Enforce use of virtual files sync folder when available" OFF )
 
+option(ENFORCE_SINGLE_ACCOUNT "Enforce use of a single account in desktop client" OFF)
+
 option( DO_NOT_USE_PROXY "Do not use system wide proxy, instead always do a direct connection to server" OFF )
 
 ## Theming options
index 5b91a83386476b9515d94f9d570619632c806ad0..27b98cbd3b98af96486a1c6a0a050365c53a1254 100644 (file)
@@ -36,6 +36,7 @@
 #define APPLICATION_URI_HANDLER_SCHEME "@APPLICATION_URI_HANDLER_SCHEME@"
 #cmakedefine01 ENFORCE_VIRTUAL_FILES_SYNC_FOLDER
 #cmakedefine DO_NOT_USE_PROXY "@DO_NOT_USE_PROXY@"
+#cmakedefine ENFORCE_SINGLE_ACCOUNT "@ENFORCE_SINGLE_ACCOUNT@"
 
 #cmakedefine ZLIB_FOUND @ZLIB_FOUND@
 
index 00a841bae2dc832546a32bbdec814dedc1745c7e..2ea72556493762c528f1fe3c103486720698ecb4 100644 (file)
@@ -554,6 +554,11 @@ void ownCloudGui::slotLogout()
 
 void ownCloudGui::slotNewAccountWizard()
 {
+#if defined ENFORCE_SINGLE_ACCOUNT
+    if (!AccountManager::instance()->accounts().isEmpty()) {
+        return;
+    }
+#endif
     OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)));
 }
 
index 08872c28925fcaca971ea5759440566d8ad63880..d2f40518987f736d596e65d778147d91ccff28ef 100644 (file)
@@ -490,6 +490,15 @@ bool Systray::isOpen() const
     return _isOpen;
 }
 
+bool Systray::enableAddAccount() const
+{
+#if defined ENFORCE_SINGLE_ACCOUNT
+    return AccountManager::instance()->accounts().isEmpty();
+#else
+    return true;
+#endif
+}
+
 void Systray::setIsOpen(const bool isOpen)
 {
     _isOpen = isOpen;
index 21607233e6ed33ece0f0036444c3d70dd2485b95..370bebc447923ea95b7302dc1402a59563246482 100644 (file)
@@ -69,6 +69,7 @@ class Systray
     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)
+    Q_PROPERTY(bool enableAddAccount READ enableAddAccount CONSTANT)
 
 public:
     static Systray *instance();
@@ -92,6 +93,8 @@ public:
     Q_REQUIRED_RESULT bool syncIsPaused() const;
     Q_REQUIRED_RESULT bool isOpen() const;
 
+    [[nodiscard]] bool enableAddAccount() const;
+
     bool raiseDialogs();
 
 signals:
index 7af3659701e356c0981a0c0ccb178daf32b39d5e..60ec7748eacd09abe60502a808d039d42f0c432c 100644 (file)
@@ -350,8 +350,9 @@ ApplicationWindow {
 \r
                         MenuItem {\r
                             id: addAccountButton\r
-                            height: Style.addAccountButtonHeight\r
+                            height: Systray.enableAddAccount ? Style.addAccountButtonHeight : 0\r
                             hoverEnabled: true\r
+                            visible: Systray.enableAddAccount\r
 \r
                             background: Item {\r
                                 height: parent.height\r