2 // C++ Implementation: mainwindow
4 // Author: Oliver Groß <z.o.gross@gmx.de>, (C) 2008
6 // Copyright: See COPYING file that comes with this distribution
8 #include "mainwindow.h"
10 #include "playlistmodel.h"
13 CMainWindow::CMainWindow(QWidget
* parent
) : QMainWindow(parent
),
14 m_Client(UI_CLIENT_NAME
, this), m_CurrentTitle('-') {
18 m_PlaylistModel
= new CPlaylistModel(m_Client
.playlist(), this);
19 ui
.playlistView
->setModel(m_PlaylistModel
);
21 /* connect(m_Client.playlist(), SIGNAL(entryAppended(quint32)), this, SLOT(handleEntryAdded(quint32)));
22 connect(m_Client.playlist(), SIGNAL(entryInserted(quint32, quint32)), this, SLOT(handleEntryAdded(quint32)));
23 connect(m_Client.playlist(), SIGNAL(entryRemoved(quint32)), this, SLOT(removeTitle(quint32)));*/
25 connect(m_Client
.playback(), SIGNAL(playTimeChanged(quint32
)), this, SLOT(updatePlaytime(quint32
)));
26 connect(m_Client
.playback(), SIGNAL(volumeChanged()), this, SLOT(updateVolume()));
27 connect(m_Client
.playback(), SIGNAL(statusChanged(xmms_playback_status_t
)), this, SLOT(updateStatus(xmms_playback_status_t
)));
28 connect(m_Client
.playback(), SIGNAL(idChanged(quint32
)), this, SLOT(updateCurrentId(quint32
)));
30 m_Client
.connectToServer();
33 CMainWindow::~CMainWindow() {
36 inline void CMainWindow::setupToolbars() {
37 m_VolumeLabel
= new QLabel(this);
38 m_VolumeLabel
->setText(tr("Volume"));
40 m_VolumeSlider
= new QSlider(this);
41 m_VolumeSlider
->setMaximum(100);
43 m_CurrentLabel
= new QLabel(this);
44 m_CurrentLabel
->setText("[disconnected]");
46 m_TimeLabel
= newQLabel(this);
47 m_TimeLabel
->setText("--:--");
49 ui
.volumeBar
->addWidget(m_VolumeLabel
);
50 ui
.volumeBar
->addWidget(m_VolumeSlider
);
52 ui
.currentBar
->addWidget(m_CurrentLabel
);
53 ui
.currentBar
->addWidget(m_TimeLabel
);
56 void CMainWindow::updatePlaytime(quint32 time
) {
57 //TODO: check this (could be too much overhead if nothing visible changed)
58 m_TimeLabel
->setText(formatedTime(time
));
61 /* void CMainWindow::updateVolume() {
65 void CMainWindow::updateStatus(xmms_playback_status_t status
) {
66 m_CurrentLabel
->setText(toStringFormated(status
).arg(m_CurrentTitle
));
67 if (status
== XMMS_PLAYBACK_STOP
)
68 m_TimeLabel
->setText("--:--");
71 void CMainWindow::updateCurrentId(quint32 id
) {
72 if (m_Titles
.contains(id
))
73 m_CurrentTitle
= m_Titles
[id
];
75 m_CurrentTitle
= tr("loading title... (id: %1)").arg(id
);
78 updateStatus(m_Client
.playback()->status());