1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-22 08:52:12 +02:00

* Fixed TWK-212: Sliders should jump to the position they are clicked on.

This commit is contained in:
Christian Muehlhaeuser 2011-08-17 02:20:41 +02:00
parent 713243cc5d
commit c3419cb082
6 changed files with 100 additions and 30 deletions

@ -132,16 +132,6 @@ AudioControls::AudioControls( QWidget* parent )
"background-repeat: no-repeat;"
"}" );
/* m_playAction = new QAction( this );
m_pauseAction = new QAction( this );
m_prevAction = new QAction( this );
m_nextAction = new QAction( this );
connect( m_playAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( play() ) );
connect( m_pauseAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( pause() ) );
connect( m_prevAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( previous() ) );
connect( m_nextAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); */
connect( ui->seekSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( seek( int ) ) );
connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( setVolume( int ) ) );
connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) );
@ -180,7 +170,6 @@ AudioControls::AudioControls( QWidget* parent )
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
ui->buttonAreaLayout->setSpacing( 0 );
ui->stackedLayout->setSpacing( 0 );
ui->stackedLayout->setContentsMargins( 0, 0, 0, 0 );
@ -306,9 +295,6 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
ui->seekSlider->setValue( 0 );
ui->seekSlider->setVisible( true );
/* m_playAction->setEnabled( false );
m_pauseAction->setEnabled( true ); */
ui->stackedLayout->setCurrentWidget( ui->pauseButton );
ui->loveButton->setEnabled( true );
@ -344,18 +330,12 @@ AudioControls::socialActionsLoaded()
void
AudioControls::onPlaybackPaused()
{
/* m_pauseAction->setEnabled( false );
m_playAction->setEnabled( true ); */
ui->stackedLayout->setCurrentWidget( ui->playPauseButton );
}
void
AudioControls::onPlaybackResumed()
{
/* m_playAction->setEnabled( false );
m_pauseAction->setEnabled( true ); */
ui->stackedLayout->setCurrentWidget( ui->pauseButton );
ui->loveButton->setVisible( true );
}
@ -377,9 +357,6 @@ AudioControls::onPlaybackStopped()
ui->stackedLayout->setCurrentWidget( ui->playPauseButton );
ui->loveButton->setEnabled( false );
ui->loveButton->setVisible( false );
/* m_pauseAction->setEnabled( false );
m_playAction->setEnabled( true ); */
}

@ -82,11 +82,6 @@ private slots:
private:
Ui::AudioControls *ui;
QAction* m_playAction;
QAction* m_pauseAction;
QAction* m_prevAction;
QAction* m_nextAction;
QPixmap m_defaultCover;
Tomahawk::result_ptr m_currentTrack;

@ -337,7 +337,7 @@
</widget>
</item>
<item>
<widget class="QSlider" name="seekSlider">
<widget class="SeekSlider" name="seekSlider">
<property name="minimumSize">
<size>
<width>0</width>
@ -489,7 +489,7 @@
</widget>
</item>
<item>
<widget class="QSlider" name="volumeSlider">
<widget class="SeekSlider" name="volumeSlider">
<property name="minimumSize">
<size>
<width>0</width>
@ -529,6 +529,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SeekSlider</class>
<extends>QSlider</extends>
<header location="global">widgets/SeekSlider.h</header>
</customwidget>
<customwidget>
<class>ImageButton</class>
<extends>QPushButton</extends>

@ -177,6 +177,7 @@ set( libSources
widgets/newplaylistwidget.cpp
widgets/searchwidget.cpp
widgets/SeekSlider.cpp
widgets/playlisttypeselectordlg.cpp
widgets/welcomewidget.cpp
widgets/welcomeplaylistmodel.cpp
@ -356,6 +357,7 @@ set( libHeaders
widgets/newplaylistwidget.h
widgets/searchwidget.h
widgets/SeekSlider.h
widgets/playlisttypeselectordlg.h
widgets/welcomewidget.h
widgets/welcomeplaylistmodel.h

@ -0,0 +1,50 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SeekSlider.h"
#include <QMouseEvent>
#include <QTimer>
#include "utils/logger.h"
SeekSlider::SeekSlider( QWidget* parent )
: QSlider( parent )
, m_parent( parent )
{
setMouseTracking( true );
}
SeekSlider::~SeekSlider()
{
}
void
SeekSlider::mousePressEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton )
{
QMouseEvent eventSwap( QEvent::MouseButtonRelease, event->pos(), event->globalPos(), Qt::MidButton, Qt::MidButton, event->modifiers() );
QSlider::mousePressEvent( &eventSwap );
}
else
QSlider::mousePressEvent( event );
}

@ -0,0 +1,41 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEEKSLIDER_H
#define SEEKSLIDER_H
#include <QSlider>
#include "dllmacro.h"
class DLLEXPORT SeekSlider : public QSlider
{
Q_OBJECT
public:
SeekSlider( QWidget* parent = 0 );
~SeekSlider();
protected:
void mousePressEvent( QMouseEvent* event );
private:
QWidget* m_parent;
};
#endif // SEEKSLIDER_H