Просмотр исходного кода

Merge pull request #5789 from nextcloud/backport/5773/stable-3.9

[stable-3.9] addd a cmake option to enable single account desktop client
Matthieu Gallien 2 лет назад
Родитель
Сommit
4e787f381a
6 измененных файлов с 22 добавлено и 1 удалено
  1. 2 0
      NEXTCLOUD.cmake
  2. 1 0
      config.h.in
  3. 5 0
      src/gui/owncloudgui.cpp
  4. 9 0
      src/gui/systray.cpp
  5. 3 0
      src/gui/systray.h
  6. 2 1
      src/gui/tray/Window.qml

+ 2 - 0
NEXTCLOUD.cmake

@@ -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

+ 1 - 0
config.h.in

@@ -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@
 

+ 5 - 0
src/gui/owncloudgui.cpp

@@ -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)));
 }
 

+ 9 - 0
src/gui/systray.cpp

@@ -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;

+ 3 - 0
src/gui/systray.h

@@ -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:

+ 2 - 1
src/gui/tray/Window.qml

@@ -350,8 +350,9 @@ ApplicationWindow {
 
                         MenuItem {
                             id: addAccountButton
-                            height: Style.addAccountButtonHeight
+                            height: Systray.enableAddAccount ? Style.addAccountButtonHeight : 0
                             hoverEnabled: true
+                            visible: Systray.enableAddAccount
 
                             background: Item {
                                 height: parent.height