[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    [Patch] Phonon: changing icons for volume and seek sliders
From:       Tanguy Krotoff <tkrotoff () gmail ! com>
Date:       2009-04-14 15:18:16
Message-ID: 129f18a00904140818r3e07c76ar42e8ad394e4f0b75 () mail ! gmail ! com
[Download RAW message or body]

Hello

"patch that allows to change the default icons for volume and seek
sliders inside Phonon"
The attached picture below is self-explanatory (taken under winxp)

I've submitted this patch a long time ago without replies.

So again, if nobody complains I can commit it using my KDE account tkrotoff...


---------- Forwarded message ----------
From: Tanguy Krotoff <tkrotoff@gmail.com>
Date: Wed, Sep 17, 2008 at 2:59 PM
Subject: [Patch] Phonon: changing icons for volume and seek sliders
To: phonon-backends@kde.org


Hello

Here is a small patch that allows to change the default icons for
volume and seek sliders inside Phonon.
Basically it adds these methods:

void SeekSlider::setIcon(const QIcon &icon)
void VolumeSlider::setVolumeIcon(const QIcon &icon);
void VolumeSlider::setMutedIcon(const QIcon &icon);

I've reworked the patch given Matthias suggestions (that's true that I
didn't really verify it at that time, I think it is OK now)

So if someone could simply tell me if it is OK or not and commit it (I
have a svn account: tkrotoff)

Thanks in advance

On Wed, Jun 4, 2008 at 5:18 PM, Matthias Kretz <kretz@kde.org> wrote:
> The patch is a good idea, but can only go into kdesupport/phonon, not
> branches/phonon/4.2. Calling d->_k_mutedChanged from
> setVolumeIcon/setMutedIcon looks wrong. Even if it does the right thing now,
> you probably better should use it there. Also for
> +    if (d->icon.isNull()) {
> +        d->iconLabel.setVisible(true);
> +    }
> Did you perhaps forget a "!"? Or you meant "setVisible(false)"? Setting a null
> icon should probably just get ignored. To hide the icon there's already a
> dedicated function.
>
> I'm just wondering since when QStyle has SP_MediaVolume(Muted) and why
> Trolltech didn't patch phonon to use those... Also we should check that
> KStyle implements them correctly. Oh, and the dox are wrong then, it should
> say "Default icon used is QStyle::standardIcon(QStyle::SP_MediaVolume)". Too
> bad SP_MediaTime wasn't added...
>
> --
> ________________________________________________________
> Matthias Kretz (Germany)                            <><
> http://Vir.homelinux.org/
> MatthiasKretz@gmx.net, kretz@kde.org,
> Matthias.Kretz@urz.uni-heidelberg.de
>

-- 
Tanguy Krotoff <tkrotoff@gmail.com>
+33 6 68 42 70 24

["sliders_icon.diff" (application/octet-stream)]

Index: seekslider.cpp
===================================================================
--- seekslider.cpp	(revision 953752)
+++ seekslider.cpp	(working copy)
@@ -252,6 +252,18 @@
     d->iconLabel.setPixmap(d->icon.pixmap(d->iconSize, d->slider.isEnabled() ? \
QIcon::Normal : QIcon::Disabled));  }
 
+QIcon SeekSlider::icon() const
+{
+    return k_ptr->icon;
+}
+
+void SeekSlider::setIcon(const QIcon &icon)
+{
+    K_D(SeekSlider);
+    d->icon = icon;
+    d->iconLabel.setPixmap(d->icon.pixmap(d->iconSize, d->slider.isEnabled() ? \
QIcon::Normal : QIcon::Disabled)); +}
+
 } // namespace Phonon
 
 #endif //QT_NO_PHONON_SEEKSLIDER
Index: seekslider.h
===================================================================
--- seekslider.h	(revision 953752)
+++ seekslider.h	(working copy)
@@ -95,12 +95,19 @@
     Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
 
     /**
-     * \brief the icon size used for the mute button/icon.
+     * The icon size used for the mute button/icon.
      *
      * The default size is defined by the GUI style.
      */
     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
 
+    /**
+     * The icon to be used instead of the default one for the mute button/icon.
+     *
+     * Default icon is "player-time".
+     */
+    Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
+
     public:
         /**
          * Constructs a seek slider widget with the given \p parent.
@@ -122,12 +129,14 @@
         Qt::Orientation orientation() const;
         bool isIconVisible() const;
         QSize iconSize() const;
+        QIcon icon() const;
         MediaObject *mediaObject() const;
 
     public Q_SLOTS:
         void setOrientation(Qt::Orientation);
         void setIconVisible(bool);
         void setIconSize(const QSize &size);
+        void setIcon(const QIcon &icon);
 
         /**
          * Sets the media object to be controlled by this slider.
Index: volumeslider.cpp
===================================================================
--- volumeslider.cpp	(revision 953752)
+++ volumeslider.cpp	(working copy)
@@ -104,6 +104,41 @@
     k_ptr->muteButton.setIconSize(iconSize);
 }
 
+QIcon VolumeSlider::volumeIcon() const
+{
+    return k_ptr->volumeIcon;
+}
+
+void VolumeSlider::setVolumeIcon(const QIcon &icon)
+{
+    K_D(VolumeSlider);
+    pDebug() << Q_FUNC_INFO << icon;
+    k_ptr->volumeIcon = icon;
+    d->updateIcon();
+}
+
+QIcon VolumeSlider::mutedIcon() const
+{
+    return k_ptr->mutedIcon;
+}
+
+void VolumeSlider::setMutedIcon(const QIcon &icon)
+{
+    K_D(VolumeSlider);
+    pDebug() << Q_FUNC_INFO << icon;
+    k_ptr->mutedIcon = icon;
+    d->updateIcon();
+}
+
+void VolumeSliderPrivate::updateIcon()
+{
+    if (output && output->isMuted()) {
+        muteButton.setIcon(mutedIcon);
+    } else {
+        muteButton.setIcon(volumeIcon);
+    }
+}
+
 qreal VolumeSlider::maximumVolume() const
 {
     return k_ptr->slider.maximum() * 0.01;
Index: volumeslider.h
===================================================================
--- volumeslider.h	(revision 953752)
+++ volumeslider.h	(working copy)
@@ -98,11 +98,26 @@
     Q_PROPERTY(bool muteVisible READ isMuteVisible WRITE setMuteVisible)
 
     /**
-     * \brief the icon size used for the mute button/icon.
+     * The icon size used for the mute button/icon.
      *
      * The default size is defined by the GUI style.
      */
     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+
+    /**
+     * The volume icon to be used instead of the default one.
+     *
+     * Default icon used is "player-volume".
+     */
+    Q_PROPERTY(QIcon volumeIcon READ volumeIcon WRITE setVolumeIcon)
+
+    /**
+     * The muted icon to be used instead of the default one.
+     *
+     * Default icon used is "player-volume-muted".
+     */
+    Q_PROPERTY(QIcon mutedIcon READ mutedIcon WRITE setMutedIcon)
+
     public:
         /**
          * Constructs a new volume slider with a \p parent.
@@ -119,6 +134,8 @@
         void setSingleStep(int milliseconds);
         bool isMuteVisible() const;
         QSize iconSize() const;
+        QIcon volumeIcon() const;
+        QIcon mutedIcon() const;
         qreal maximumVolume() const;
         Qt::Orientation orientation() const;
         AudioOutput *audioOutput() const;
@@ -128,6 +145,8 @@
         void setOrientation(Qt::Orientation);
         void setMuteVisible(bool);
         void setIconSize(const QSize &size);
+        void setVolumeIcon(const QIcon &icon);
+        void setMutedIcon(const QIcon &icon);
 
         /**
          * Sets the audio output object to be controlled by this slider.
Index: volumeslider_p.h
===================================================================
--- volumeslider_p.h	(revision 953752)
+++ volumeslider_p.h	(working copy)
@@ -76,6 +76,8 @@
 
         VolumeSlider *q_ptr;
 
+        void updateIcon();
+
         void _k_sliderChanged(int);
         void _k_volumeChanged(qreal);
         void _k_mutedChanged(bool);


["sliders_icon.png" (image/png)]

_______________________________________________
kde-multimedia mailing list
kde-multimedia@kde.org
https://mail.kde.org/mailman/listinfo/kde-multimedia


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic