From 2fc45c60627b401ecd296a1eff86e1f396a7fb5a Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Fri, 6 Aug 2021 11:45:01 +0200
Subject: [PATCH] UI: Use play/pause icons for MPV controls

---
 rsc/VivyRessources.qrc                         |  6 ++++++
 rsc/icons/breeze-dark/media-playback-pause.svg | 18 ++++++++++++++++++
 rsc/icons/breeze-dark/media-playback-start.svg | 18 ++++++++++++++++++
 rsc/icons/breeze-dark/media-playback-stop.svg  | 18 ++++++++++++++++++
 .../breeze-light/media-playback-pause.svg      | 18 ++++++++++++++++++
 .../breeze-light/media-playback-start.svg      | 18 ++++++++++++++++++
 rsc/icons/breeze-light/media-playback-stop.svg | 18 ++++++++++++++++++
 src/UI/DocumentViews/MpvControls.cc            |  5 ++---
 src/UI/DocumentViews/MpvControls.hh            |  5 +++++
 src/VivyApplication.hh                         |  3 +++
 10 files changed, 124 insertions(+), 3 deletions(-)
 create mode 100644 rsc/icons/breeze-dark/media-playback-pause.svg
 create mode 100644 rsc/icons/breeze-dark/media-playback-start.svg
 create mode 100644 rsc/icons/breeze-dark/media-playback-stop.svg
 create mode 100644 rsc/icons/breeze-light/media-playback-pause.svg
 create mode 100644 rsc/icons/breeze-light/media-playback-start.svg
 create mode 100644 rsc/icons/breeze-light/media-playback-stop.svg

diff --git a/rsc/VivyRessources.qrc b/rsc/VivyRessources.qrc
index b27b8c63..542123ec 100644
--- a/rsc/VivyRessources.qrc
+++ b/rsc/VivyRessources.qrc
@@ -35,6 +35,9 @@
     <file alias="folder.svg">icons/breeze-dark/folder.svg</file>
     <file alias="text-x-generic.svg">icons/breeze-dark/text-x-generic.svg</file>
     <file alias="help-about.svg">icons/breeze-dark/help-about.svg</file>
+    <file alias="media-pause.svg">icons/breeze-dark/media-playback-pause.svg</file>
+    <file alias="media-play.svg">icons/breeze-dark/media-playback-start.svg</file>
+    <file alias="media-stop.svg">icons/breeze-dark/media-playback-stop.svg</file>
 </qresource>
 <qresource prefix="icons/light">
     <file alias="document-new.svg">icons/breeze-light/document-new.svg</file>
@@ -44,6 +47,9 @@
     <file alias="folder.svg">icons/breeze-light/folder.svg</file>
     <file alias="text-x-generic.svg">icons/breeze-light/text-x-generic.svg</file>
     <file alias="help-about.svg">icons/breeze-light/help-about.svg</file>
+    <file alias="media-pause.svg">icons/breeze-light/media-playback-pause.svg</file>
+    <file alias="media-play.svg">icons/breeze-light/media-playback-start.svg</file>
+    <file alias="media-stop.svg">icons/breeze-light/media-playback-stop.svg</file>
 </qresource>
 
 <!-- QDarkStyle style sheet, MIT Licence -->
diff --git a/rsc/icons/breeze-dark/media-playback-pause.svg b/rsc/icons/breeze-dark/media-playback-pause.svg
new file mode 100644
index 00000000..6d62eb8d
--- /dev/null
+++ b/rsc/icons/breeze-dark/media-playback-pause.svg
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#eff0f1;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 6 6 0 20 8 0 0 -20 z m 12 0 0 20 8 0 0 -20 z"
+     id="path8"
+     class="ColorScheme-Text"
+     />
+</svg>
diff --git a/rsc/icons/breeze-dark/media-playback-start.svg b/rsc/icons/breeze-dark/media-playback-start.svg
new file mode 100644
index 00000000..2014d770
--- /dev/null
+++ b/rsc/icons/breeze-dark/media-playback-start.svg
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#eff0f1;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 6 6 0 20 20 -10 z"
+     id="path105"
+     class="ColorScheme-Text"
+      />
+</svg>
diff --git a/rsc/icons/breeze-dark/media-playback-stop.svg b/rsc/icons/breeze-dark/media-playback-stop.svg
new file mode 100644
index 00000000..3660cf8b
--- /dev/null
+++ b/rsc/icons/breeze-dark/media-playback-stop.svg
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#eff0f1;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 6 6 0 20 20 0 0 -20 z"
+     id="path91"
+     class="ColorScheme-Text"
+     />
+</svg>
diff --git a/rsc/icons/breeze-light/media-playback-pause.svg b/rsc/icons/breeze-light/media-playback-pause.svg
new file mode 100644
index 00000000..ece18388
--- /dev/null
+++ b/rsc/icons/breeze-light/media-playback-pause.svg
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#232629;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 6 6 0 20 8 0 0 -20 z m 12 0 0 20 8 0 0 -20 z"
+     id="path8"
+     class="ColorScheme-Text"
+     />
+</svg>
diff --git a/rsc/icons/breeze-light/media-playback-start.svg b/rsc/icons/breeze-light/media-playback-start.svg
new file mode 100644
index 00000000..28f7c9b3
--- /dev/null
+++ b/rsc/icons/breeze-light/media-playback-start.svg
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#232629;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 6 6 0 20 20 -10 z"
+     id="path105"
+     class="ColorScheme-Text"
+      />
+</svg>
diff --git a/rsc/icons/breeze-light/media-playback-stop.svg b/rsc/icons/breeze-light/media-playback-stop.svg
new file mode 100644
index 00000000..2aa152a2
--- /dev/null
+++ b/rsc/icons/breeze-light/media-playback-stop.svg
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#232629;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 6 6 0 20 20 0 0 -20 z"
+     id="path91"
+     class="ColorScheme-Text"
+     />
+</svg>
diff --git a/src/UI/DocumentViews/MpvControls.cc b/src/UI/DocumentViews/MpvControls.cc
index 36971ccb..eee42cad 100644
--- a/src/UI/DocumentViews/MpvControls.cc
+++ b/src/UI/DocumentViews/MpvControls.cc
@@ -44,11 +44,10 @@ MpvControls::MpvControls(MpvContainer *passedContainer, QWidget *parent) noexcep
 
     connect(togglePlaybackButton, &QAbstractButton::clicked, mpv, &MpvContainer::mpvTogglePlayback);
     connect(mpv, &MpvContainer::mpvPlaybackToggled, this,
-            [togglePlaybackButton](bool isPlay) noexcept -> void {
+            [this, togglePlaybackButton](bool isPlay) noexcept -> void {
                 qDebug() << "Got playback update to"
                          << (isPlay ? QStringLiteral("Play") : QStringLiteral("Pause"));
-                togglePlaybackButton->setText(isPlay ? QStringLiteral("Pause")
-                                                     : QStringLiteral("Play"));
+                togglePlaybackButton->setIcon(isPlay ? pauseIcon : playIcon);
             });
 
     auto *centralLayout = new QHBoxLayout(this);
diff --git a/src/UI/DocumentViews/MpvControls.hh b/src/UI/DocumentViews/MpvControls.hh
index 4f25db87..db00d590 100644
--- a/src/UI/DocumentViews/MpvControls.hh
+++ b/src/UI/DocumentViews/MpvControls.hh
@@ -5,6 +5,8 @@
 #endif
 
 #include "../../Lib/Utils.hh"
+#include "../../VivyApplication.hh"
+#include <QIcon>
 
 namespace Vivy
 {
@@ -20,6 +22,9 @@ private:
     chrono::seconds timePosition;
     int askedSliderPosition{ 0 };
 
+    const QIcon playIcon{ VIVY_ICON_PLAY };
+    const QIcon pauseIcon{ VIVY_ICON_PAUSE };
+
 public:
     explicit MpvControls(MpvContainer *mpv, QWidget *parent) noexcept;
 };
diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh
index 4b0b82b9..a13719cd 100644
--- a/src/VivyApplication.hh
+++ b/src/VivyApplication.hh
@@ -16,6 +16,9 @@
 #define VIVY_ICON_ABOUT   ":icons/dark/help-about.svg"
 #define VIVY_ICON_FILE    ":icons/dark/text-x-generic.svg"
 #define VIVY_ICON_FOLDER  ":icons/dark/folder.svg"
+#define VIVY_ICON_PLAY    ":icons/dark/media-play.svg"
+#define VIVY_ICON_PAUSE   ":icons/dark/media-pause.svg"
+#define VIVY_ICON_STOP    ":icons/dark/media-stop.svg"
 
 #include <QApplication>
 #include <QPixmap>
-- 
GitLab