aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorvovanec <vovanec@90c681e8-e032-0410-971d-27865f9a5e38>2007-07-29 09:19:41 +0000
committervovanec <vovanec@90c681e8-e032-0410-971d-27865f9a5e38>2007-07-29 09:19:41 +0000
commit080507d3a2bc4c1679d1a2cd639e532fb4adbd31 (patch)
tree7ac58e4cea61a0f836c326af448eaaa334ecb54e /src/mainwindow.cpp
parent8a503d69ecb35d2e9c95885e4d1247011d788442 (diff)
downloadqmmp-080507d3a2bc4c1679d1a2cd639e532fb4adbd31.tar.gz
qmmp-080507d3a2bc4c1679d1a2cd639e532fb4adbd31.tar.bz2
qmmp-080507d3a2bc4c1679d1a2cd639e532fb4adbd31.zip
added song position navigation, context menu over main display
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@45 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp73
1 files changed, 51 insertions, 22 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b6243fb71..3abcdbfe1 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -45,6 +45,8 @@
#include <addurldialog.h>
#include "filedialog.h"
+#define KEY_OFFSET 10
+
MainWindow::MainWindow(const QStringList& args, QWidget *parent)
: QMainWindow(parent)
{
@@ -52,6 +54,7 @@ MainWindow::MainWindow(const QStringList& args, QWidget *parent)
seeking = FALSE;
m_update = FALSE;
m_paused = FALSE;
+ m_elapsed = 0;
setWindowIcon( QIcon(":/qmmp.xpm") );
@@ -212,7 +215,19 @@ void MainWindow::replay()
void MainWindow::seek(int pos)
{
- m_core->seek(pos);
+ if(!seeking)
+ m_core->seek(pos);
+}
+
+
+void MainWindow::forward()
+{
+ seek(m_elapsed + KEY_OFFSET);
+}
+
+void MainWindow::backward()
+{
+ seek(m_elapsed - KEY_OFFSET);
}
void MainWindow::setVolume(int volume, int balance)
@@ -247,6 +262,7 @@ void MainWindow::next()
if (m_core->isInitialized())
{
stop();
+ m_elapsed = 0;
play();
}
else
@@ -295,27 +311,31 @@ void MainWindow::showOutputState(const OutputState &st)
m_playlist->setInfo(st, m_core->length(), m_playListModel->totalLength());
switch ((int) st.type())
{
- case OutputState::Playing:
- {
- m_tray->setIcon ( QIcon(":/play.png") );
- if (m_showMessage && m_playListModel->currentItem())
- m_tray->showMessage ( tr("Now Playing"),
- m_playListModel->currentItem()->title(),
- QSystemTrayIcon::Information, m_messageDelay );
- if (m_showToolTip && m_playListModel->currentItem())
- m_tray->setToolTip (m_playListModel->currentItem()->title());
- break;
- }
- case OutputState::Paused:
- {
- m_tray->setIcon ( QIcon(":/pause.png") );
- break;
- }
- case OutputState::Stopped:
- {
- m_tray->setIcon ( QIcon(":/stop.png") );
- break;
- }
+ case OutputState::Playing:
+ {
+ m_tray->setIcon ( QIcon(":/play.png") );
+ if (m_showMessage && m_playListModel->currentItem())
+ m_tray->showMessage ( tr("Now Playing"),
+ m_playListModel->currentItem()->title(),
+ QSystemTrayIcon::Information, m_messageDelay );
+ if (m_showToolTip && m_playListModel->currentItem())
+ m_tray->setToolTip (m_playListModel->currentItem()->title());
+ break;
+ }
+ case OutputState::Paused:
+ {
+ m_tray->setIcon ( QIcon(":/pause.png") );
+ break;
+ }
+ case OutputState::Stopped:
+ {
+ m_tray->setIcon ( QIcon(":/stop.png") );
+ break;
+ }
+ case OutputState::Info:
+ {
+ m_elapsed = st.elapsedSeconds();
+ }
}
}
@@ -556,6 +576,15 @@ void MainWindow::createActions()
Dock::getPointer()->addActions(m_mainMenu->actions());
m_mainMenu->addSeparator();
m_mainMenu->addAction(tr("&Exit"),this, SLOT(close ()), tr("Ctrl+Q"));
+
+ QAction* forward = new QAction(this);
+ forward->setShortcut(QKeySequence(Qt::Key_Right));
+ connect(forward,SIGNAL(triggered(bool)),this,SLOT(forward()));
+ QAction* backward = new QAction(this);
+ backward->setShortcut(QKeySequence(Qt::Key_Left));
+ connect(backward,SIGNAL(triggered(bool)),this,SLOT(backward()));
+
+ Dock::getPointer()->addActions( QList<QAction*>() << forward << backward );
Dock::getPointer()->addActions(m_mainMenu->actions());
}