Replace unified search text field busy indicator with custom indicator
authorClaudio Cambra <claudio.cambra@gmail.com>
Mon, 18 Jul 2022 15:22:56 +0000 (17:22 +0200)
committerClaudio Cambra <claudio.cambra@gmail.com>
Tue, 2 Aug 2022 11:23:33 +0000 (13:23 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
resources.qrc
src/gui/tray/NCBusyIndicator.qml [new file with mode: 0644]
src/gui/tray/SyncStatus.qml
src/gui/tray/UnifiedSearchInputContainer.qml

index 870ea27c30ce104de46990d57ae6cedc5179ebf8..6aeb159b36535fb07e16a9190e878c8380bad962 100644 (file)
@@ -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>
diff --git a/src/gui/tray/NCBusyIndicator.qml b/src/gui/tray/NCBusyIndicator.qml
new file mode 100644 (file)
index 0000000..c489e5f
--- /dev/null
@@ -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
+        }
+    }
+}
index 5964c60db7198be46ae290fec56a3f89edf00ede..bae630a4db9d8156038850caa99135a1172f1f52 100644 (file)
@@ -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 {
index cb5687530826c2c3dc8644373d3a8ab3f8c602f7..6dc0e17a72d3d2f2c0258e038e5564fe526dcdd4 100644 (file)
@@ -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 {