Left clicking on the track slider will now jump to the absolute position in the track. Fixes issue #172
This commit is contained in:
parent
025bafab76
commit
c92d6f1852
|
@ -71,6 +71,7 @@ set(CLEMENTINE-SOURCES
|
|||
groupbydialog.cpp
|
||||
equalizer.cpp
|
||||
equalizerslider.cpp
|
||||
tracksliderslider.cpp
|
||||
)
|
||||
|
||||
# Header files that have Q_OBJECT in
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slider">
|
||||
<widget class="TrackSliderSlider" name="slider">
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -49,6 +49,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TrackSliderSlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header>tracksliderslider.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* This file is part of Clementine.
|
||||
|
||||
Clementine 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.
|
||||
|
||||
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tracksliderslider.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QStyle>
|
||||
#include <QtDebug>
|
||||
|
||||
TrackSliderSlider::TrackSliderSlider(QWidget* parent)
|
||||
: QSlider(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TrackSliderSlider::mousePressEvent(QMouseEvent* e) {
|
||||
// QSlider asks QStyle which mouse button should do what (absolute move or
|
||||
// page step). We force our own behaviour here because it makes more sense
|
||||
// for a music player IMO.
|
||||
|
||||
Qt::MouseButton new_button = e->button();
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
int abs_buttons = style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons);
|
||||
if (abs_buttons & Qt::LeftButton)
|
||||
new_button = Qt::LeftButton;
|
||||
else if (abs_buttons & Qt::MidButton)
|
||||
new_button = Qt::MidButton;
|
||||
else if (abs_buttons & Qt::RightButton)
|
||||
new_button = Qt::RightButton;
|
||||
}
|
||||
|
||||
QMouseEvent new_event(e->type(), e->pos(), new_button, new_button, e->modifiers());
|
||||
QSlider::mousePressEvent(&new_event);
|
||||
|
||||
if (new_event.isAccepted())
|
||||
e->accept();
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/* This file is part of Clementine.
|
||||
|
||||
Clementine 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.
|
||||
|
||||
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TRACKSLIDERSLIDER_H
|
||||
#define TRACKSLIDERSLIDER_H
|
||||
|
||||
#include <QSlider>
|
||||
|
||||
// It's the slider inside the TrackSliderSlider
|
||||
|
||||
class TrackSliderSlider : public QSlider {
|
||||
public:
|
||||
TrackSliderSlider(QWidget* parent = 0);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
};
|
||||
|
||||
#endif // TRACKSLIDERSLIDER_H
|
Loading…
Reference in New Issue