Fwd: [Amarok] Make the tooltip shown when hovering the progress

Nikolaj Hald Nielsen nhnfreespirit at gmail.com
Tue Jan 19 14:02:33 CET 2010


commit 88f69ef6d548d7aac17e58ef98c4d8e193f20f0c
Author:     Nikolaj Hald Nielsen <nhn at kde.org>
AuthorDate: Tue Jan 19 13:38:06 2010 +0100
Commit:     Nikolaj Hald Nielsen <nhn at kde.org>
CommitDate: Tue Jan 19 13:43:20 2010 +0100

   Make the tooltip shown when hovering the progress slider (once
again) show the position in the track that the mouse is over.
   This makes finding a particular spot within a track without
skipping around in it much simpler.
   The tooltip text is hopefully better this time around as we are not
curently in string freeze as we was when I last attempted this
feature.

   The tooltip text "Track position under cursor: %1" might be too
long now though, so any suggestions for a better tooltip text would be
appreciated.

   CCMAIL: Amarok-devel at kde.org

diff --git a/src/widgets/SliderWidget.cpp b/src/widgets/SliderWidget.cpp
index 1b1417d..68e2ee1 100644
--- a/src/widgets/SliderWidget.cpp
+++ b/src/widgets/SliderWidget.cpp
@@ -462,9 +462,14 @@ bool Amarok::TimeSlider::event( QEvent * event )
        QHelpEvent * helpEvent = dynamic_cast<QHelpEvent *>( event );
        if( helpEvent )
        {
-            // Update tooltip to show the current track time position
-            const int trackPosition = The::engineController()->trackPosition();
-            setToolTip( i18n( "Time position: %1",
Meta::secToPrettyTime( trackPosition ) ) );
+
+            //figure out "percentage" of the track length that the
mouse is hovering over the slider
+            qreal percentage = (qreal) helpEvent->x() / (qreal) width();
+            long trackLength = The::engineController()->trackLength();
+            int trackPosition = trackLength * percentage;
+
+            // Update tooltip to show the track position under the cursor
+            setToolTip( i18nc( "Tooltip shown when the mouse is over
the progress slider, representing the position in the currently
playing track that amarok will seek to if you click the mouse. Keep it
short and consice.", "Track position under cursor: %1",
Meta::msToPrettyTime( trackPosition ) ) );
        }
    }


More information about the Amarok-devel mailing list