diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-09-28 16:45:09 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-09-28 16:45:09 +0000 |
| commit | 01235bdb7777c63c2c65ee6dd00081e640ae7dbe (patch) | |
| tree | 66d5b8def8c1611fef1646035123ac52a6dae496 /src/ui | |
| parent | d26eba2fad30b2bf23135d0e9b203fdee2a935b5 (diff) | |
| download | qmmp-01235bdb7777c63c2c65ee6dd00081e640ae7dbe.tar.gz qmmp-01235bdb7777c63c2c65ee6dd00081e640ae7dbe.tar.bz2 qmmp-01235bdb7777c63c2c65ee6dd00081e640ae7dbe.zip | |
volume tracking
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@569 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/display.cpp | 83 | ||||
| -rw-r--r-- | src/ui/display.h | 3 | ||||
| -rw-r--r-- | src/ui/eqtitlebar.h | 2 | ||||
| -rw-r--r-- | src/ui/eqwidget.cpp | 11 | ||||
| -rw-r--r-- | src/ui/eqwidget.h | 8 | ||||
| -rw-r--r-- | src/ui/mainwindow.cpp | 118 | ||||
| -rw-r--r-- | src/ui/mainwindow.h | 3 |
7 files changed, 24 insertions, 204 deletions
diff --git a/src/ui/display.cpp b/src/ui/display.cpp index c338050bb..74c946fd3 100644 --- a/src/ui/display.cpp +++ b/src/ui/display.cpp @@ -138,6 +138,14 @@ MainDisplay::MainDisplay (QWidget *parent) m_timeIndicator = new TimeIndicator(this); m_timeIndicator->move(34,26); m_timeIndicator->show(); + + m_core = SoundCore::instance(); + connect(m_core, SIGNAL(elapsedChanged(qint64)), SLOT(setTime(qint64))); + connect(m_core, SIGNAL(bitrateChanged(int)), m_kbps, SLOT(display(int))); + connect(m_core, SIGNAL(frequencyChanged(int)), SLOT(setSampleRate(int))); + connect(m_core, SIGNAL(channelsChanged(int)), m_monoster, SLOT(setChannels(int))); + connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(setState(Qmmp::State))); + connect(m_core, SIGNAL(volumeChanged(int,int)), SLOT(setVolume(int, int))); } @@ -170,11 +178,6 @@ void MainDisplay::setState(Qmmp::State state) setDuration(m_core->length()); break; } - /*case OutputState::Buffering: - { - //ui.label->setText("Buffering"); - break; - }*/ case Qmmp::Paused: { m_playstatus->setStatus(PlayStatus::PAUSE); @@ -192,6 +195,14 @@ void MainDisplay::setState(Qmmp::State state) } } +void MainDisplay::setVolume(int left, int right) +{ + int maxVol = qMax(left, right); + m_volumeBar->setValue(maxVol); + if (maxVol && !m_volumeBar->isPressed()) + m_balanceBar->setValue((right - left) * 100/maxVol); +} + void MainDisplay::updateSkin() { setPixmap (m_skin->getMain()); @@ -218,68 +229,6 @@ void MainDisplay::setPL (QWidget* w) connect (m_playlist, SIGNAL (closed ()), m_plButton, SLOT (click())); } -/*void MainDisplay::setInfo(const OutputState &st) -{ - - - switch ((int) st.type()) - { - case OutputState::Info: - { - //if (seeking) - // break; - setTime (st.elapsedSeconds()); - m_kbps->display (st.bitrate()); - m_freq->display (st.frequency() /1000); - m_monoster->setChannels (st.channels()); - update(); - break; - } - case OutputState::Playing: - { - m_playstatus->setStatus(PlayStatus::PLAY); - m_timeIndicator->setNeedToShowTime(true); - break; - } - case OutputState::Buffering: - { - //ui.label->setText("Buffering"); - break; - } - case OutputState::Paused: - { - m_playstatus->setStatus(PlayStatus::PAUSE); - break; - } - case OutputState::Stopped: - { - m_playstatus->setStatus(PlayStatus::STOP); - m_monoster->setChannels (0); - //m_timeIndicator->setNeedToShowTime(false); - break; - } - case OutputState::Volume: - //qDebug("volume %d, %d", st.rightVolume(), st.leftVolume()); - int maxVol = qMax(st.leftVolume(),st.rightVolume()); - m_volumeBar->setValue(maxVol); - if (maxVol && !m_volumeBar->isPressed()) - m_balanceBar->setValue((st.rightVolume()-st.leftVolume())*100/maxVol); - break; - - } -}*/ - -void MainDisplay::setSoundCore(SoundCore *core) -{ - m_core = core; - connect(core, SIGNAL(elapsedChanged(qint64)), SLOT(setTime(qint64))); - //connect(core, SIGNAL(totalTimeChanged(qint64 time) - connect(core, SIGNAL(bitrateChanged(int)), m_kbps, SLOT(display(int))); - connect(core, SIGNAL(frequencyChanged(int)), SLOT(setSampleRate(int))); - connect(core, SIGNAL(channelsChanged(int)), m_monoster, SLOT(setChannels(int))); - connect(core, SIGNAL(stateChanged(Qmmp::State)), SLOT(setState(Qmmp::State))); -} - bool MainDisplay::isPlaylistVisible() const { return m_plButton->isChecked(); diff --git a/src/ui/display.h b/src/ui/display.h index 4e7623f2f..43ee35c5d 100644 --- a/src/ui/display.h +++ b/src/ui/display.h @@ -57,8 +57,6 @@ public: void setEQ(QWidget*); void setPL(QWidget*); - //void setInfo(const OutputState &st); - void setSoundCore(SoundCore *core); bool isEqualizerVisible()const; bool isPlaylistVisible()const; bool isRepeatable()const; @@ -84,6 +82,7 @@ private slots: void setSampleRate(int rate); void setTime(qint64); void setState(Qmmp::State state); + void setVolume(int left, int right); private: QWidget* m_equlizer; diff --git a/src/ui/eqtitlebar.h b/src/ui/eqtitlebar.h index 4dd1d64d1..70ef88fe4 100644 --- a/src/ui/eqtitlebar.h +++ b/src/ui/eqtitlebar.h @@ -42,6 +42,8 @@ public: ~EqTitleBar(); void setActive(bool); + +public slots: void setVolume(int left, int right); private slots: diff --git a/src/ui/eqwidget.cpp b/src/ui/eqwidget.cpp index b9c5ede33..8906389f1 100644 --- a/src/ui/eqwidget.cpp +++ b/src/ui/eqwidget.cpp @@ -23,6 +23,7 @@ #include <QInputDialog> #include <QCloseEvent> #include <qmmpui/filedialog.h> +#include <qmmp/soundcore.h> #include "skin.h" #include "eqslider.h" @@ -86,6 +87,7 @@ EqWidget::EqWidget (QWidget *parent) } readSettings(); createActions(); + connect(SoundCore::instance(), SIGNAL(volumeChanged(int, int)), m_titleBar, SLOT(setVolume(int, int))); } EqWidget::~EqWidget() @@ -364,15 +366,6 @@ void EqWidget::loadPreset(const QString &name) } } -/*void EqWidget::setInfo(const OutputState &st) -{ - if (st.type() == OutputState::Volume) - { - m_titleBar->setVolume(st.leftVolume(),st.rightVolume()); - - } -}*/ - EQPreset *EqWidget::findPreset(const QString &name) { foreach(EQPreset *preset, m_autoPresets) diff --git a/src/ui/eqwidget.h b/src/ui/eqwidget.h index 7b3680a45..7e30eec86 100644 --- a/src/ui/eqwidget.h +++ b/src/ui/eqwidget.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2006-2008 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -36,6 +36,7 @@ class EQGraph; class Button; class EQPreset; class PlayListItem; +class SoundCore; class EqWidget : public PixmapWidget { @@ -53,11 +54,6 @@ public: */ void loadPreset(const QString &name); - /*! - * shows output volume and balance. Necessare for the shaded mode - */ - //void setInfo(const OutputState &st); - signals: void valueChanged(); void closed(); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 22a975b69..0e2d1ade9 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -62,6 +62,7 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option m_paused = FALSE; m_elapsed = 0; m_option_manager = option_manager; + m_core = new SoundCore(this); setWindowIcon(QIcon(":/32x32/qmmp.png")); @@ -113,7 +114,6 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option createActions(); - m_core = new SoundCore(this); m_titlebar = new TitleBar(this); m_titlebar->move(0,0); m_titlebar->show(); @@ -124,25 +124,12 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option display->setEQ(m_equalizer); display->setPL(m_playlist); - display->setSoundCore(m_core); m_vis = MainVisual::getPointer(); - //m_core->addVisualization(m_vis); - //m_core->showVisualization(this); - - /*connect(m_core, SIGNAL(outputStateChanged(const OutputState&)), - SLOT(showOutputState(const OutputState&))); - connect(m_core, SIGNAL(decoderStateChanged(const DecoderState&)), - SLOT(showDecoderState(const DecoderState&))); - connect(m_core, SIGNAL(titleChanged(const QString&)), - SLOT(changeTitle(const QString&))); - */ Visual::initialize(this, m_visMenu, SLOT(updateActions())); Visual::add(m_vis); - - connect(m_core, SIGNAL(finished()), SLOT(next())); connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(showState(Qmmp::State))); connect(m_core, SIGNAL(elapsedChanged(qint64)),m_playlist, SLOT(setTime(qint64))); @@ -200,12 +187,7 @@ void MainWindow::play() if (s.isEmpty()) return; if (m_core->play(s)) - { - //display->setTime(0); - //qDebug("play"); m_generalHandler->setTime(0); - //display->setDuration(m_core->totalTime()); - } else { //find out the reason why playback failed @@ -358,104 +340,6 @@ void MainWindow::showState(Qmmp::State state) } } } - -/*void MainWindow::showOutputState(const OutputState &st) - -{ - if (seeking) - return; - - //display->setInfo(st); - //m_playlist->setInfo(st, m_core->length(), m_playListModel->totalLength()); - //m_titlebar->setInfo(st); - // m_equalizer->setInfo(st); - /*switch ((int) st.type()) - { - case OutputState::Playing: - { - m_generalHandler->setState(General::Playing); - if (m_playListModel->currentItem()) - { - SongInfo info = *m_playListModel->currentItem(); - if (info.isEmpty()) - info.setValue(SongInfo::TITLE, m_playlist->currentItem()->text()); - m_generalHandler->setSongInfo(info); - } - break; - } - case OutputState::Paused: - { - m_generalHandler->setState(General::Paused); - break; - } - case OutputState::Stopped: - { - m_generalHandler->setState(General::Stopped); - break; - } - case OutputState::Info: - { - m_generalHandler->setTime(st.elapsedSeconds()); - m_elapsed = st.elapsedSeconds(); - break; - } - case OutputState::Volume: - { - m_generalHandler->setVolume(st.leftVolume(), st.rightVolume()); - break; - } - case OutputState::VisualRemoved: - { - m_visMenu->updateActions(); - } - }*/ -//} -/*void MainWindow::showDecoderState(const DecoderState &st) -{ - switch ((int) st.type()) - { - case DecoderState::Finished: - { - next(); - break; - } - case DecoderState::Info: - { - qDebug("file info:"); - qDebug("ARTIST = %s", qPrintable(st.tag()->artist())); - qDebug("TITLE = %s", qPrintable(st.tag()->title())); - qDebug("ALBUM = %s", qPrintable(st.tag()->album())); - qDebug("COMMENT = %s", qPrintable(st.tag()->comment())); - qDebug("GENRE = %s", qPrintable(st.tag()->genre())); - qDebug("YEAR = %d", st.tag()->year()); - qDebug("TRACK = %d", st.tag()->track()); - qDebug("LENGTH = %d", st.tag()->length()); - if (m_playlist->currentItem()) - { - if (!st.tag()->isEmpty()) - { - SongInfo info; - info.setValue(SongInfo::TITLE, st.tag()->title()); - info.setValue(SongInfo::ARTIST, st.tag()->artist()); - info.setValue(SongInfo::ALBUM, st.tag()->album()); - info.setValue(SongInfo::COMMENT, st.tag()->comment()); - info.setValue(SongInfo::GENRE, st.tag()->genre()); - info.setValue(SongInfo::YEAR, st.tag()->year()); - info.setValue(SongInfo::TRACK, st.tag()->track()); - info.setValue(SongInfo::LENGTH, st.tag()->length()); - info.setValue(SongInfo::STREAM, - m_playlist->currentItem()->path().startsWith("http://")); - info.setValue(SongInfo::PATH, m_playlist->currentItem()->path()); - m_generalHandler->setSongInfo(info); - } - m_playlist->currentItem()->updateTags(st.tag()); - m_playlist->listWidget()->updateList(); - } - break; - } - } -}*/ - void MainWindow::showMetaData() { qDebug("===== metadata ======"); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 515ab685c..0f7890460 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -93,8 +93,6 @@ protected: virtual void keyPressEvent ( QKeyEvent* ); private slots: - //void showOutputState(const OutputState&); - //void showDecoderState(const DecoderState&); void showState(Qmmp::State state); void showMetaData(); void changeTitle(const QString&); @@ -105,7 +103,6 @@ private slots: void updateEQ(); void forward(); void backward(); - //void trayActivated(QSystemTrayIcon::ActivationReason); void about(); void handleCloseRequest(); |
