Bladeren bron

Replace unified search text field busy indicator with custom indicator

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Claudio Cambra 3 jaren geleden
bovenliggende
commit
b1deb6cd1d
4 gewijzigde bestanden met toevoegingen van 63 en 18 verwijderingen
  1. 1 0
      resources.qrc
  2. 50 0
      src/gui/tray/NCBusyIndicator.qml
  3. 5 14
      src/gui/tray/SyncStatus.qml
  4. 7 4
      src/gui/tray/UnifiedSearchInputContainer.qml

+ 1 - 0
resources.qrc

@@ -33,5 +33,6 @@
         <file>src/gui/tray/ActivityItemContent.qml</file>
         <file>src/gui/tray/TalkReplyTextField.qml</file>
         <file>src/gui/tray/CallNotificationDialog.qml</file>
+        <file>src/gui/tray/NCBusyIndicator.qml</file>
     </qresource>
 </RCC>

+ 50 - 0
src/gui/tray/NCBusyIndicator.qml

@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import Style 1.0
+
+BusyIndicator {
+    id: root
+
+    property color color: Style.ncSecondaryTextColor
+    property string imageSource: "image://svgimage-custom-color/change.svg/"
+
+    contentItem: Image {
+        id: contentImage
+
+        property bool colourableImage: root.color && root.imageSource.startsWith("image://svgimage-custom-color/")
+
+        horizontalAlignment: Image.AlignHCenter
+        verticalAlignment: Image.AlignVCenter
+
+        source: colourableImage ? root.imageSource + root.color : root.imageSource
+        sourceSize.width: 64
+        sourceSize.height: 64
+        fillMode: Image.PreserveAspectFit
+
+        mipmap: true
+
+        RotationAnimator {
+            target: contentImage
+            running: root.running
+            onRunningChanged: contentImage.rotation = 0
+            from: 0
+            to: 360
+            loops: Animation.Infinite
+            duration: 3000
+        }
+    }
+}

+ 5 - 14
src/gui/tray/SyncStatus.qml

@@ -17,7 +17,7 @@ RowLayout {
         id: syncStatus
     }
 
-    Image {
+    NCBusyIndicator {
         id: syncIcon
         property int size: Style.trayListItemIconSize * 0.6
         property int whiteSpace: (Style.trayListItemIconSize - size)
@@ -31,19 +31,10 @@ RowLayout {
         Layout.bottomMargin: 16
         Layout.leftMargin: Style.trayHorizontalMargin + (whiteSpace * (0.5 - Style.thumbnailImageSizeReduction))
 
-        source: syncStatus.syncIcon
-        sourceSize.width: 64
-        sourceSize.height: 64
-        rotation: syncStatus.syncing ? 0 : 0
-    }
- 
-    RotationAnimator {
-        target: syncIcon
-        running:  syncStatus.syncing
-        from: 0
-        to: 360
-        loops: Animation.Infinite
-        duration: 3000
+        padding: 0
+
+        imageSource: syncStatus.syncIcon
+        running: syncStatus.syncing
     }
 
     ColumnLayout {

+ 7 - 4
src/gui/tray/UnifiedSearchInputContainer.qml

@@ -58,10 +58,9 @@ TextField {
         sourceSize: Qt.size(parent.height * parent.textFieldIconsScaleFactor, parent.height * parent.textFieldIconsScaleFactor)
     }
 
-    BusyIndicator {
-        id: trayWindowUnifiedSearchTextFieldIconInProgress
-        running: visible
-        visible: trayWindowUnifiedSearchTextField.isSearchInProgress
+    NCBusyIndicator {
+        id: busyIndicator
+
         anchors {
             left: trayWindowUnifiedSearchTextField.left
             bottom: trayWindowUnifiedSearchTextField.bottom
@@ -70,7 +69,11 @@ TextField {
             bottomMargin: 4
             verticalCenter: trayWindowUnifiedSearchTextField.verticalCenter
         }
+
         width: height
+        color: trayWindowUnifiedSearchTextField.textFieldIconsColor
+        visible: trayWindowUnifiedSearchTextField.isSearchInProgress
+        running: visible
     }
 
     Image {