diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-02-18 21:44:39 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-02-18 21:44:39 +0000 |
| commit | 09d1eb079182e06e01cc9bea8bf9410e40a189c2 (patch) | |
| tree | ba6228fb3e81cd38e41fcc32e0d89246b357c5f8 /src/ui | |
| parent | 390cf22010e4f10be06010bbaff1dcf388f88c3c (diff) | |
| download | qmmp-09d1eb079182e06e01cc9bea8bf9410e40a189c2.tar.gz qmmp-09d1eb079182e06e01cc9bea8bf9410e40a189c2.tar.bz2 qmmp-09d1eb079182e06e01cc9bea8bf9410e40a189c2.zip | |
improved text scroller, added numerical values for balance and volume
(Closes issue 415)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2057 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/balancebar.cpp | 9 | ||||
| -rw-r--r-- | src/ui/balancebar.h | 6 | ||||
| -rw-r--r-- | src/ui/display.cpp | 23 | ||||
| -rw-r--r-- | src/ui/display.h | 2 | ||||
| -rw-r--r-- | src/ui/mainwindow.cpp | 6 | ||||
| -rw-r--r-- | src/ui/textscroller.cpp | 321 | ||||
| -rw-r--r-- | src/ui/textscroller.h | 66 | ||||
| -rw-r--r-- | src/ui/volumebar.cpp | 8 | ||||
| -rw-r--r-- | src/ui/volumebar.h | 4 |
9 files changed, 253 insertions, 192 deletions
diff --git a/src/ui/balancebar.cpp b/src/ui/balancebar.cpp index a14f73acc..07a56ce7a 100644 --- a/src/ui/balancebar.cpp +++ b/src/ui/balancebar.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -50,20 +50,22 @@ void BalanceBar::mousePressEvent(QMouseEvent *e) if(e->button() == Qt::MidButton) { m_value = 0; + emit sliderPressed(); emit sliderMoved(m_value); } else if(m_pos<e->x() && e->x()<m_pos+11*m_skin->ratio()) { press_pos = e->x()-m_pos; + emit sliderPressed(); } else { m_value = convert(qMax(qMin(width()-18*m_skin->ratio(),e->x()-6*m_skin->ratio()),0)); press_pos = 6*m_skin->ratio(); - if (m_value!=m_old) + emit sliderPressed(); + if (m_value != m_old) { emit sliderMoved(m_value); - } } draw(); @@ -90,6 +92,7 @@ void BalanceBar::mouseReleaseEvent(QMouseEvent*) m_moving = false; draw(false); m_old = m_value; + emit sliderReleased(); } void BalanceBar::setValue(int v) diff --git a/src/ui/balancebar.h b/src/ui/balancebar.h index 4e8af0b5e..68e967568 100644 --- a/src/ui/balancebar.h +++ b/src/ui/balancebar.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -25,7 +25,7 @@ class Skin; /** - @author Ilya Kotov <forkotov02@hotmail.ru> + @author Ilya Kotov <forkotov02@hotmail.ru> */ class BalanceBar : public PixmapWidget { @@ -43,6 +43,8 @@ public slots: signals: void sliderMoved (int); + void sliderPressed(); + void sliderReleased(); private slots: void updateSkin(); diff --git a/src/ui/display.cpp b/src/ui/display.cpp index d8897d0a4..9598262b2 100644 --- a/src/ui/display.cpp +++ b/src/ui/display.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2010 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -99,12 +99,17 @@ MainDisplay::MainDisplay (QWidget *parent) m_playstatus = new PlayStatus(this); m_volumeBar = new VolumeBar(this); - connect(m_volumeBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); m_volumeBar->setToolTip(tr("Volume")); + connect(m_volumeBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); + connect(m_volumeBar, SIGNAL(sliderPressed()),SLOT(updateVolume())); + connect(m_volumeBar, SIGNAL(sliderReleased()),m_text,SLOT(clear())); m_balanceBar = new BalanceBar(this); - connect(m_balanceBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); m_balanceBar->setToolTip(tr("Balance")); + connect(m_balanceBar, SIGNAL(sliderMoved(int)),SLOT(updateVolume())); + connect(m_balanceBar, SIGNAL(sliderPressed()),SLOT(updateVolume())); + connect(m_balanceBar, SIGNAL(sliderReleased()),m_text,SLOT(clear())); + m_timeIndicator = new TimeIndicator(this); m_aboutWidget = new QWidget(this); m_core = SoundCore::instance(); @@ -122,7 +127,6 @@ MainDisplay::MainDisplay (QWidget *parent) updateMask(); } - MainDisplay::~MainDisplay() { QSettings settings (Qmmp::configFile(), QSettings::IniFormat); @@ -284,6 +288,17 @@ bool MainDisplay::isEqualizerVisible() const void MainDisplay::updateVolume() { + if(sender() == m_volumeBar) + m_text->setText(tr("Volume: %1%").arg(m_volumeBar->value())); + if(sender() == m_balanceBar) + { + if(m_balanceBar->value() > 0) + m_text->setText(tr("Balance: %1% right").arg(m_balanceBar->value())); + else if(m_balanceBar->value() < 0) + m_text->setText(tr("Balance: %1% left").arg(-m_balanceBar->value())); + else + m_text->setText(tr("Balance: center")); + } m_mw->setVolume(m_volumeBar->value(), m_balanceBar->value()); } diff --git a/src/ui/display.h b/src/ui/display.h index 67c472048..0a213432e 100644 --- a/src/ui/display.h +++ b/src/ui/display.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2010 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 36f9999a4..d2d68f943 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -35,7 +35,6 @@ #include <qmmpui/playlistmodel.h> #include <qmmpui/playlistmanager.h> #include <qmmpui/mediaplayer.h> -#include "textscroller.h" #include "mainwindow.h" #include "skin.h" #include "playlist.h" @@ -120,7 +119,6 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(showState(Qmmp::State))); connect(m_core, SIGNAL(elapsedChanged(qint64)),m_playlist, SLOT(setTime(qint64))); connect(m_core, SIGNAL(metaDataChanged()),SLOT(showMetaData())); - connect(m_core, SIGNAL(bufferingProgress(int)), TextScroller::getPointer(), SLOT(setProgress(int))); connect(m_generalHandler, SIGNAL(toggleVisibilityCalled()), SLOT(toggleVisibility())); connect(m_generalHandler, SIGNAL(exitCalled()), SLOT(close())); @@ -203,8 +201,6 @@ void MainWindow::showState(Qmmp::State state) case Qmmp::Playing: if (m_pl_manager->currentPlayList()->currentItem()) m_equalizer->loadPreset(m_pl_manager->currentPlayList()->currentItem()->url().section("/",-1)); - if (m_playlist->listWidget()) - m_playlist->listWidget()->updateList(); //removes progress message from TextScroller break; case Qmmp::Paused: break; @@ -235,7 +231,6 @@ void MainWindow::showMetaData() { m_playlist->currentItem()->updateMetaData(m_core->metaData()); m_playlist->updateList(); - TextScroller::getPointer()->setText(m_playlist->currentItem()->text()); setWindowTitle(m_playlist->currentItem()->text()); } } @@ -496,7 +491,6 @@ void MainWindow::updateSettings() { readSettings(); m_playlist->readSettings(); - TextScroller::getPointer()->readSettings(); m_visMenu->updateActions(); m_skin->reloadSkin(); Dock::instance()->updateDock(); diff --git a/src/ui/textscroller.cpp b/src/ui/textscroller.cpp index 22b823350..008e5b3a9 100644 --- a/src/ui/textscroller.cpp +++ b/src/ui/textscroller.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -25,92 +25,72 @@ #include <QMouseEvent> #include <QSettings> #include <qmmp/qmmp.h> - +#include <qmmp/soundcore.h> +#include <qmmpui/metadataformatter.h> #include "skin.h" #include "textscroller.h" -#define SCROLL_SEP "*** " - -TextScroller *TextScroller::pointer = 0; +#define SCROLL_SEP " *** " +#define TITLE_FORMAT "%if(%p&%t,%p - %t,%p%t)%if(%p&%t,,%f)%if(%l, - %l,)" -TextScroller *TextScroller::getPointer() +TextScroller::TextScroller (QWidget *parent) + : QWidget (parent) { - return pointer; -} - - -TextScroller::TextScroller ( QWidget *parent ) - : QWidget ( parent ) -{ - pointer = this; - m_skin = Skin::instance(); - m_pixmap = QPixmap ( 150,15 ); - resize(150,15); - x = 0; - m_offset = 0; - m_progress = -1; + m_pressed = false; + m_press_pos = 0; m_metrics = 0; - m_text = "Qt-based Multimedia Player (Qmmp " + Qmmp::strVersion() + ")"; - m_update = false; - readSettings(); - m_timer = new QTimer ( this ); - connect (m_timer, SIGNAL (timeout()), SLOT (addOffset())); + m_defautText = QString("Qmmp ") + Qmmp::strVersion(); + m_core = SoundCore::instance(); + m_skin = Skin::instance(); + + m_timer = new QTimer (this); m_timer->setInterval(50); m_timer->start(); - updateSkin(); - connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - m_autoscroll = true; + m_menu = new QMenu(this); - QAction *autoscrollAction = new QAction(tr("Autoscroll Songname"), m_menu); - autoscrollAction->setCheckable (true); - connect(autoscrollAction, SIGNAL(toggled(bool)), SLOT(setAutoscroll(bool))); - m_menu->addAction(autoscrollAction); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - autoscrollAction->setChecked(settings.value("TextScroller/autoscroll", true).toBool()); - setAutoscroll(autoscrollAction->isChecked()); + m_scrollAction = m_menu->addAction(tr("Autoscroll Songname")); + m_scrollAction->setCheckable(true); + connect(m_scrollAction, SIGNAL(toggled(bool)), SLOT(setAutoscroll(bool))); + readSettings(); + connect(m_timer, SIGNAL (timeout()), SLOT (addOffset())); + connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin())); + connect(m_scrollAction, SIGNAL(toggled(bool)), SLOT(updateText())); + connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(processState(Qmmp::State))); + connect(m_core, SIGNAL(metaDataChanged()), SLOT(processMetaData())); } - TextScroller::~TextScroller() { QSettings settings(Qmmp::configFile(), QSettings::IniFormat); - settings.setValue("TextScroller/autoscroll", m_autoscroll); + settings.setValue("TextScroller/autoscroll", m_scrollAction->isChecked()); if(m_metrics) delete m_metrics; } -void TextScroller::addOffset() +void TextScroller::setText(const QString &text) { - x--; - if(m_bitmap) - { - if (154 + x < - m_scrollText.size() * 5 - 15 + 1) - x = -154; - } - else - { - if (154 + x < - m_metrics->width (m_scrollText) - 15 + 1) - x = -154; - } - update(); + m_sliderText = text; + updateText(); } -void TextScroller::setText(const QString& text) +void TextScroller::clear() { - m_progress = -1; - if (isVisible() && m_autoscroll) - m_timer->start(); - if (m_text != text) + setText(QString()); +} + +void TextScroller::addOffset() +{ + if(!m_scroll) { - m_text = text; - m_scrollText = "*** " + text; - x = m_autoscroll ? -50 : -150; - m_bitmap = m_bitmapConf && (m_text.toLatin1() == m_text.toLocal8Bit()); + m_timer->stop(); + return; } - if(m_bitmap) - m_offset = m_scrollText.size() * 5 + 15; - else - m_offset = m_metrics->width (m_scrollText) + 15; + m_x1--; + m_x2--; + if(m_x1 < - m_pixmap.width()) + m_x1 = m_pixmap.width(); + if(m_x2 < - m_pixmap.width()) + m_x2 = m_pixmap.width(); update(); } @@ -118,52 +98,28 @@ void TextScroller::updateSkin() { m_color.setNamedColor(m_skin->getPLValue("mbfg")); setCursor(m_skin->getCursor(Skin::CUR_SONGNAME)); -} - - -void TextScroller::setAutoscroll(bool enabled) -{ - m_autoscroll = enabled; - x = -150; - if (m_autoscroll) - { - if (isVisible()) - m_timer->start(); - } - else - { - m_timer->stop(); - update(); - } + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + m_bitmap = settings.value("MainWindow/bitmap_font", false).toBool(); + updateText(); } void TextScroller::readSettings() { QSettings settings(Qmmp::configFile(), QSettings::IniFormat); QString fontname = settings.value("MainWindow/Font","").toString(); - m_bitmapConf = settings.value("MainWindow/bitmap_font", false).toBool(); m_font.fromString(fontname); - - if (m_update) - { + if (m_metrics) delete m_metrics; - m_bitmap = m_bitmapConf && (m_text.toLatin1() == m_text.toLocal8Bit()); - } else - { - m_update = true; - m_bitmap = false; - - } + m_scrollAction->setChecked(settings.value("TextScroller/autoscroll", true).toBool()); m_metrics = new QFontMetrics(m_font); - setText(m_text); + updateSkin(); } void TextScroller::setProgress(int progress) { - m_timer->stop(); - m_progress = progress; - update(); + m_bufferText = tr("Buffering: %1%").arg(progress); + updateText(); } void TextScroller::hideEvent (QHideEvent *) @@ -173,7 +129,7 @@ void TextScroller::hideEvent (QHideEvent *) void TextScroller::showEvent (QShowEvent *) { - if (m_autoscroll) + if (m_scroll) m_timer->start(); } @@ -196,47 +152,25 @@ inline void drawBitmapText(int x, int y, const QString &text, QPainter *paint, S void TextScroller::paintEvent (QPaintEvent *) { - QPainter paint (this); - paint.setPen(m_color); - paint.setFont(m_font); - if (m_progress < 0) + QPainter paint(this); + if(m_scroll) { - if(m_bitmap) - { - if (m_autoscroll) - { - drawBitmapText (154 + x + m_offset * 2, 12, m_scrollText, &paint, m_skin); - drawBitmapText (154 + x + m_offset, 12, m_scrollText, &paint, m_skin); - drawBitmapText (154 + x, 12, m_scrollText, &paint, m_skin); - } - else - drawBitmapText (154 + x,12, m_text, &paint, m_skin); - } - else - { - if (m_autoscroll) - { - paint.drawText (154 + x + m_offset * 2, 12, m_scrollText); - paint.drawText (154 + x + m_offset, 12, m_scrollText); - paint.drawText (154 + x, 12, m_scrollText); - } - else - paint.drawText (154 + x,12, m_text); - } + paint.drawPixmap(m_x1,0, m_pixmap); + paint.drawPixmap(m_x2,0, m_pixmap); } else - paint.drawText (4,12, tr("Buffering:") + QString(" %1\%").arg(m_progress)); + paint.drawPixmap(4,0, m_pixmap); } void TextScroller::mousePressEvent (QMouseEvent *e) { if (e->button() == Qt::RightButton) m_menu->exec(e->globalPos()); - else if (e->button() == Qt::LeftButton && m_autoscroll) + else if (e->button() == Qt::LeftButton && m_scroll) { m_timer->stop(); - press_pos = e->x() - (x + 154); - m_pressing = true; + m_press_pos = e->x() - m_x1; + m_pressed = true; } else QWidget::mousePressEvent(e); @@ -244,28 +178,141 @@ void TextScroller::mousePressEvent (QMouseEvent *e) void TextScroller::mouseReleaseEvent (QMouseEvent *e) { - if (e->button() == Qt::RightButton) + if(e->button() == Qt::RightButton) m_menu->exec(e->globalPos()); - else if (e->button() == Qt::LeftButton && m_autoscroll) - { + else if (e->button() == Qt::LeftButton && m_scroll) m_timer->start(); - m_pressing = false; - } else QWidget::mouseReleaseEvent(e); + m_pressed = false; } void TextScroller::mouseMoveEvent (QMouseEvent *e) { - if (m_pressing) + if (m_pressed) { - int bound = m_metrics->width (m_scrollText) + 15 - 1; - x = (e->x() - press_pos) % bound; - if (x < 0) - x += bound; - x = x - bound - 154; + int bound = m_pixmap.width(); + m_x1 = (e->x() - m_press_pos) % bound; + if (m_x1 > 0) + m_x1 -= bound; + m_x2 = m_x1 + m_pixmap.width(); update(); } else QWidget::mouseMoveEvent(e); } + +void TextScroller::processState(Qmmp::State state) +{ + switch(state) + { + case Qmmp::Buffering: + { + connect(m_core, SIGNAL(bufferingProgress(int)), SLOT(setProgress(int))); + break; + } + case Qmmp::Playing: + { + disconnect(m_core, SIGNAL(bufferingProgress(int)), this, 0); + m_bufferText.clear(); + updateText(); + break; + } + case Qmmp::Paused: + { + break; + } + case Qmmp::Stopped: + { + m_bufferText.clear(); + m_titleText.clear(); + updateText(); + break; + } + default: + break; + } +} + +void TextScroller::processMetaData() +{ + MetaDataFormatter formater(TITLE_FORMAT); + if(m_core->state() == Qmmp::Playing) + { + m_titleText = formater.parse(m_core->metaData(), m_core->totalTime()/1000); + updateText(); + } +} + +void TextScroller::preparePixmap(const QString &text, bool scrollable) +{ + m_scroll = scrollable; + bool bitmap = m_bitmap && (text.toLatin1() == text.toLocal8Bit()); //use bitmap font if possible + if(scrollable) + { + int textWidth = m_bitmap ? QString(text + SCROLL_SEP).size() * 5 + : m_metrics->width(text + SCROLL_SEP); + int count = 150 / textWidth + 1; + int width = count * textWidth; + QString fullText; + for(int i = 0; i < count; ++i) + { + fullText.append(text + SCROLL_SEP); + } + m_pixmap = QPixmap(width,15); + m_pixmap.fill(Qt::transparent); + QPainter painter(&m_pixmap); + painter.setPen(m_color); + painter.setFont(m_font); + if(m_bitmap) + drawBitmapText (0,12, fullText, &painter, m_skin); + else + painter.drawText (0,12, fullText); + m_x1 = 0; + m_x2 = m_pixmap.width(); + } + else + { + m_pixmap = QPixmap(150,15); + m_pixmap.fill(Qt::transparent); + QPainter painter(&m_pixmap); + painter.setPen(m_color); + painter.setFont(m_font); + if(bitmap) + drawBitmapText (0,12, text, &painter, m_skin); + else + painter.drawText (0,12, text); + } +} + +void TextScroller::updateText() //draw text according priority +{ + if(!m_sliderText.isEmpty()) + { + preparePixmap(m_sliderText); + m_timer->stop(); + } + else if(!m_bufferText.isEmpty()) + { + preparePixmap(m_bufferText); + m_timer->stop(); + } + else if (!m_titleText.isEmpty()) + { + preparePixmap(m_titleText, m_scrollAction->isChecked()); + m_timer->start(); + } + else if(!m_defautText.isEmpty()) + { + preparePixmap(m_defautText); + m_timer->stop(); + } + else + { + m_timer->stop(); + m_pixmap = QPixmap (150,15); + m_pixmap.fill(Qt::transparent); + m_scroll = false; + } + update(); +} diff --git a/src/ui/textscroller.h b/src/ui/textscroller.h index bf4a0185d..b4c5909db 100644 --- a/src/ui/textscroller.h +++ b/src/ui/textscroller.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -21,65 +21,63 @@ #define TEXTSCROLLER_H #include <QWidget> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ +#include <qmmp/qmmp.h> class QTimer; class QMenu; - +class QAction; class Skin; +class SoundCore; +/** + @author Ilya Kotov <forkotov02@hotmail.ru> +*/ class TextScroller : public QWidget { Q_OBJECT public: TextScroller(QWidget *parent = 0); + virtual ~TextScroller(); - ~TextScroller(); - - static TextScroller *getPointer(); - void setText(const QString&); - void readSettings(); - + void setText(const QString &text); public slots: - void setProgress(int); + void clear(); private slots: + void setProgress(int); void addOffset(); void updateSkin(); - void setAutoscroll(bool); - -protected: - void hideEvent (QHideEvent *); - void showEvent (QShowEvent *); - void paintEvent (QPaintEvent *); - void mousePressEvent (QMouseEvent *); - void mouseReleaseEvent (QMouseEvent *); - void mouseMoveEvent (QMouseEvent *); + void processState(Qmmp::State state); + void processMetaData(); + void updateText(); private: - bool m_pressing; - int press_pos; - bool m_update; - static TextScroller *pointer; + void hideEvent(QHideEvent *); + void showEvent(QShowEvent *); + void paintEvent(QPaintEvent *); + void mousePressEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void readSettings(); + void preparePixmap(const QString &text, bool scrollable = false); + QString m_defautText; + QString m_bufferText; + QString m_sliderText; + QString m_titleText; + QPixmap m_pixmap; - int x; + int m_x1, m_x2; + bool m_scroll, m_bitmap, m_pressed; + int m_press_pos; QFont m_font; QFontMetrics *m_metrics; - QString m_text; - QString m_scrollText; Skin *m_skin; QColor m_color; QTimer *m_timer; - int m_progress; - bool m_autoscroll; - bool m_bitmapConf; - bool m_bitmap; QMenu *m_menu; - int m_offset; + QAction *m_scrollAction; + SoundCore *m_core; }; #endif diff --git a/src/ui/volumebar.cpp b/src/ui/volumebar.cpp index 6a4169dae..e0829e659 100644 --- a/src/ui/volumebar.cpp +++ b/src/ui/volumebar.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -21,11 +21,9 @@ #include <QMouseEvent> #include <QPainter> #include <math.h> - #include "skin.h" #include "button.h" #include "mainwindow.h" - #include "volumebar.h" @@ -42,7 +40,6 @@ VolumeBar::VolumeBar(QWidget *parent) : PixmapWidget(parent) draw(false); } - VolumeBar::~VolumeBar() {} @@ -53,11 +50,13 @@ void VolumeBar::mousePressEvent(QMouseEvent *e) if(m_pos<e->x() && e->x()<m_pos+11*m_skin->ratio()) { press_pos = e->x()-m_pos; + emit sliderPressed(); } else { m_value = convert(qMax(qMin(width()-18*m_skin->ratio(),e->x()-6*m_skin->ratio()),0)); press_pos = 6*m_skin->ratio(); + emit sliderPressed(); if (m_value != m_old) emit sliderMoved(m_value); } @@ -85,6 +84,7 @@ void VolumeBar::mouseReleaseEvent(QMouseEvent*) m_moving = false; draw(false); m_old = m_value; + emit sliderReleased(); } void VolumeBar::setValue(int v) diff --git a/src/ui/volumebar.h b/src/ui/volumebar.h index 44ff6ac17..47d4dcb0d 100644 --- a/src/ui/volumebar.h +++ b/src/ui/volumebar.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -51,6 +51,8 @@ public slots: signals: void sliderMoved (int); + void sliderPressed(); + void sliderReleased(); private slots: void updateSkin(); |
