Unbreak seeking
This commit is contained in:
parent
4c500bd768
commit
b74cb0102a
4 changed files with 53 additions and 15 deletions
48
Slider.cpp
48
Slider.cpp
|
@ -10,6 +10,38 @@ BarButton::BarButton (QWidget *parent, uint normal, uint pressed) : Button (pare
|
|||
m_slider = dynamic_cast<Slider *>(parent);
|
||||
setMinimumSize (29, 10);
|
||||
setMaximumSize (29, 10);
|
||||
m_moving = false;
|
||||
}
|
||||
|
||||
void
|
||||
BarButton::setPos (uint pos)
|
||||
{
|
||||
m_pos = pos;
|
||||
if (!m_moving) {
|
||||
move (pos, 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint
|
||||
BarButton::getPos (void)
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
void
|
||||
BarButton::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
m_moving = true;
|
||||
}
|
||||
|
||||
void
|
||||
BarButton::mouseReleaseEvent (QMouseEvent *event)
|
||||
{
|
||||
m_moving = false;
|
||||
|
||||
float value = pos().x() / (float)(m_slider->width() - width());
|
||||
|
||||
m_slider->requestPos (value);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -65,8 +97,6 @@ Slider::Slider (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vert
|
|||
m_pix = size().height()-m_button->size().height();
|
||||
}
|
||||
|
||||
m_pos = 0;
|
||||
|
||||
hideBar (true);
|
||||
|
||||
}
|
||||
|
@ -117,13 +147,21 @@ Slider::setPos (uint p)
|
|||
}
|
||||
|
||||
uint x = m_pix * p / m_max;
|
||||
if (x < m_pix - m_button->rect().width() && x != m_pos) {
|
||||
m_button->move (x , 0);
|
||||
m_pos = x;
|
||||
if (x < m_pix - m_button->rect().width() && x != m_button->getPos()) {
|
||||
m_button->setPos (x);
|
||||
update ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Slider::requestPos (float value)
|
||||
{
|
||||
XMMSHandler *xmmsh = XMMSHandler::getInstance();
|
||||
|
||||
uint new_pos = (uint)(m_max * value);
|
||||
xmmsh->setPlaytime (new_pos);
|
||||
}
|
||||
|
||||
void
|
||||
Slider::setPixmaps (Skin *skin)
|
||||
{
|
||||
|
|
11
Slider.h
11
Slider.h
|
@ -12,11 +12,16 @@ class BarButton : public Button
|
|||
BarButton (QWidget *, uint, uint);
|
||||
|
||||
void mouseMoveEvent (QMouseEvent *);
|
||||
void mousePressEvent (QMouseEvent *);
|
||||
void mouseReleaseEvent (QMouseEvent *);
|
||||
|
||||
void setPos (uint pos);
|
||||
uint getPos (void);
|
||||
|
||||
private:
|
||||
Slider *m_slider;
|
||||
|
||||
|
||||
bool m_moving;
|
||||
uint m_pos;
|
||||
};
|
||||
|
||||
class Slider : public PixWidget
|
||||
|
@ -30,6 +35,7 @@ class Slider : public PixWidget
|
|||
void setSize (uint, uint);
|
||||
uint getPos (void);
|
||||
void setPos (uint);
|
||||
void requestPos (float value);
|
||||
|
||||
void setMax (uint max) { m_max = max; }
|
||||
void hideBar (bool b);
|
||||
|
@ -43,7 +49,6 @@ class Slider : public PixWidget
|
|||
int m_bg;
|
||||
uint m_max;
|
||||
uint m_pix;
|
||||
uint m_pos;
|
||||
BarButton *m_button;
|
||||
|
||||
};
|
||||
|
|
|
@ -178,14 +178,9 @@ XMMSHandler::playback_current_id (XMMSResultValue<uint> *res)
|
|||
}
|
||||
|
||||
void
|
||||
XMMSHandler::setPlaytime (void)
|
||||
XMMSHandler::setPlaytime (uint pos)
|
||||
{
|
||||
/*
|
||||
uint pos = m_mw->getMD ()->m_slider->getPos();
|
||||
qDebug ("pos = %d", pos);
|
||||
delete m_xmmsc->playback_seek_ms (pos);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
QHash<QString, QString>
|
||||
|
|
|
@ -41,7 +41,7 @@ class XMMSHandler : public QObject, public sigc::trackable {
|
|||
void updateSettings (void) { emit settingsSaved (); }
|
||||
|
||||
public slots:
|
||||
void setPlaytime ();
|
||||
void setPlaytime (uint pos);
|
||||
|
||||
void play () { delete m_xmmsc->playback_start (); }
|
||||
void stop () { delete m_xmmsc->playback_stop (); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue