Promoe kind of works.
This commit is contained in:
parent
9fb1376afe
commit
b8ec3a6cae
15 changed files with 183 additions and 65 deletions
41
Button.cpp
41
Button.cpp
|
@ -17,7 +17,6 @@ Button::setPixmaps(Skin *skin)
|
|||
m_pixmap_normal = skin->getItem (m_name_normal);
|
||||
m_pixmap_pressed = skin->getItem (m_name_pressed);
|
||||
m_pixmap = m_pixmap_normal;
|
||||
m_func = NULL;
|
||||
|
||||
setMinimumSize (m_pixmap.size ());
|
||||
setMaximumSize (m_pixmap.size ());
|
||||
|
@ -25,30 +24,22 @@ Button::setPixmaps(Skin *skin)
|
|||
update();
|
||||
}
|
||||
|
||||
void Button::mousePressEvent (QMouseEvent *event)
|
||||
void
|
||||
Button::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
((SkinDisplay *)parent ())->setNoDrag (true);
|
||||
m_pixmap = m_pixmap_pressed;
|
||||
update ();
|
||||
}
|
||||
|
||||
void Button::mouseReleaseEvent (QMouseEvent *event)
|
||||
void
|
||||
Button::mouseReleaseEvent (QMouseEvent *event)
|
||||
{
|
||||
((SkinDisplay *)parent())->setNoDrag (false);
|
||||
m_pixmap = m_pixmap_normal;
|
||||
update();
|
||||
emit clicked();
|
||||
|
||||
if (m_func) {
|
||||
m_func (m_userdata);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clicked (void *userdata)
|
||||
{
|
||||
ToggleButton *t = (ToggleButton *)userdata;
|
||||
t->toggleOn (!t->getOn());
|
||||
t->runFunc ();
|
||||
}
|
||||
|
||||
ToggleButton::ToggleButton (QWidget *parent, uint on_normal, uint on_pressed,
|
||||
|
@ -60,12 +51,11 @@ ToggleButton::ToggleButton (QWidget *parent, uint on_normal, uint on_pressed,
|
|||
m_name_on_pressed = on_pressed;
|
||||
m_name_off_normal = off_normal;
|
||||
m_name_off_pressed = off_pressed;
|
||||
m_toggled_on = true;
|
||||
|
||||
m_func = clicked;
|
||||
m_userdata = (void *)this;
|
||||
toggleOn ();
|
||||
|
||||
m_func2 = NULL;
|
||||
m_userdata2 = NULL;
|
||||
connect (this, SIGNAL(clicked()), this, SLOT (toggleOn()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,27 +67,16 @@ ToggleButton::setPixmaps(Skin *skin)
|
|||
m_pixmap_off_normal = skin->getItem(m_name_off_normal);
|
||||
m_pixmap_off_pressed = skin->getItem(m_name_off_pressed);
|
||||
|
||||
toggleOn(m_toggled_on);
|
||||
|
||||
setMinimumSize (m_pixmap.size ());
|
||||
setMaximumSize (m_pixmap.size ());
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ToggleButton::runFunc ()
|
||||
ToggleButton::toggleOn ()
|
||||
{
|
||||
if (m_func2) {
|
||||
m_func2 (m_userdata2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ToggleButton::toggleOn (bool t)
|
||||
{
|
||||
if (t) {
|
||||
if (!m_toggled_on) {
|
||||
m_pixmap_normal = m_pixmap_on_normal;
|
||||
m_pixmap_pressed = m_pixmap_on_pressed;
|
||||
m_toggled_on = true;
|
||||
|
|
14
Button.h
14
Button.h
|
@ -12,11 +12,13 @@ class Button : public PixWidget
|
|||
public:
|
||||
Button (QWidget *parent, uint btn1, uint btn2);
|
||||
~Button ();
|
||||
void setFunc (void (*func)(void *userdata), void *userdata) { m_func = func; m_userdata = userdata; }
|
||||
|
||||
public slots:
|
||||
void setPixmaps(Skin *skin);
|
||||
|
||||
signals:
|
||||
void clicked (void);
|
||||
|
||||
protected:
|
||||
void mousePressEvent (QMouseEvent *event);
|
||||
void mouseReleaseEvent (QMouseEvent *event);
|
||||
|
@ -26,8 +28,6 @@ class Button : public PixWidget
|
|||
|
||||
QPixmap m_pixmap_normal;
|
||||
QPixmap m_pixmap_pressed;
|
||||
void (*m_func)(void *userdata);
|
||||
void *m_userdata;
|
||||
};
|
||||
|
||||
class ToggleButton : public Button
|
||||
|
@ -37,19 +37,13 @@ class ToggleButton : public Button
|
|||
ToggleButton (QWidget *parent, uint, uint, uint, uint);
|
||||
~ToggleButton ();
|
||||
|
||||
void toggleOn (bool);
|
||||
void setFunc (void (*func)(void *userdata), void *userdata) { m_func2 = func; m_userdata2 = userdata; }
|
||||
|
||||
bool getOn () const { return m_toggled_on; }
|
||||
void runFunc ();
|
||||
|
||||
public slots:
|
||||
void setPixmaps(Skin *skin);
|
||||
void toggleOn ();
|
||||
|
||||
private:
|
||||
void (*m_func2)(void *userdata);
|
||||
void *m_userdata2;
|
||||
|
||||
uint m_name_on_normal;
|
||||
uint m_name_on_pressed;
|
||||
uint m_name_off_normal;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "Display.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Display.h"
|
||||
|
||||
SkinDisplay::SkinDisplay (QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#include "XMMSHandler.h"
|
||||
#include "MainDisplay.h"
|
||||
#include "TitleBar.h"
|
||||
#include "TextBar.h"
|
||||
|
||||
MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||
{
|
||||
m_mw = dynamic_cast<MainWindow*>(parent);
|
||||
|
||||
m_tbar = new TitleBar(this, false);
|
||||
m_tbar->move(0, 0);
|
||||
m_tbar->resize(275, 14);
|
||||
|
@ -61,14 +64,24 @@ MainDisplay::SetupPushButtons (void)
|
|||
/* Normal buttons */
|
||||
m_prev = new Button (this, Skin::BTN_PREV_0, Skin::BTN_PREV_1);
|
||||
m_prev->move(16, 88);
|
||||
connect (m_prev, SIGNAL(clicked()), m_mw->getHandler (), SLOT(prev()));
|
||||
|
||||
m_play = new Button (this, Skin::BTN_PLAY_0, Skin::BTN_PLAY_1);
|
||||
m_play->move(39, 88);
|
||||
connect (m_play, SIGNAL(clicked()), m_mw->getHandler (), SLOT(play()));
|
||||
|
||||
m_pause = new Button (this, Skin::BTN_PAUSE_0, Skin::BTN_PAUSE_1);
|
||||
m_pause->move(62, 88);
|
||||
connect (m_pause, SIGNAL(clicked()), m_mw->getHandler (), SLOT(pause()));
|
||||
|
||||
m_stop = new Button (this, Skin::BTN_STOP_0, Skin::BTN_STOP_1);
|
||||
m_stop->move(85, 88);
|
||||
connect (m_stop, SIGNAL(clicked()), m_mw->getHandler (), SLOT(stop()));
|
||||
|
||||
m_next = new Button (this, Skin::BTN_NEXT_0, Skin::BTN_NEXT_1);
|
||||
m_next->move(108, 88);
|
||||
connect (m_next, SIGNAL(clicked()), m_mw->getHandler (), SLOT(next()));
|
||||
|
||||
m_eject = new Button (this, Skin::BTN_EJECT_0, Skin::BTN_EJECT_1);
|
||||
m_eject->move(136, 89);
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef __MAINDISPLAY_H__
|
||||
#define __MAINDISPLAY_H__
|
||||
|
||||
class MainDisplay;
|
||||
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QPixmap>
|
||||
|
@ -25,12 +29,19 @@ class MainDisplay : public SkinDisplay
|
|||
public:
|
||||
MainDisplay (QWidget *parent);
|
||||
~MainDisplay ();
|
||||
|
||||
TextScroller *m_text;
|
||||
NumberDisplay *m_number;
|
||||
NumberDisplay *m_number2;
|
||||
|
||||
public slots:
|
||||
void setPixmaps(Skin *skin);
|
||||
protected:
|
||||
void SetupPushButtons (void);
|
||||
void MainDisplay::SetupToggleButtons (void);
|
||||
|
||||
MainWindow *m_mw;
|
||||
|
||||
Button *m_prev;
|
||||
Button *m_play;
|
||||
Button *m_pause;
|
||||
|
@ -47,10 +58,6 @@ class MainDisplay : public SkinDisplay
|
|||
ToggleButton *m_shuffle;
|
||||
ToggleButton *m_repeat;
|
||||
|
||||
TextScroller *m_text;
|
||||
|
||||
NumberDisplay *m_number;
|
||||
NumberDisplay *m_number2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "MainWindow.h"
|
||||
|
||||
MainWindow::MainWindow ()
|
||||
|
@ -5,12 +6,16 @@ MainWindow::MainWindow ()
|
|||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
setGeometry(100, 100, 275, 116);
|
||||
|
||||
m_handler = new XMMSHandler (this);
|
||||
|
||||
skin = new Skin("Debian");
|
||||
MainDisplay *display = new MainDisplay(this);
|
||||
setCentralWidget(display);
|
||||
m_display = new MainDisplay(this);
|
||||
|
||||
setCentralWidget(m_display);
|
||||
|
||||
skin->setSkin("./CleanAMP/");
|
||||
display->show();
|
||||
m_display->show();
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow ()
|
||||
|
@ -23,18 +28,13 @@ Skin *MainWindow::getSkin(void)
|
|||
return skin;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
/*
|
||||
xmmsc_connection_t *xmmsc = xmmsc_init ("coolness");
|
||||
xmmsc_connect (xmmsc, "unix:///tmp/xmms-ipc-nano");
|
||||
|
||||
XmmsQT4 *c = new XmmsQT4(xmmsc, &app);*/
|
||||
MainWindow *mw = new MainWindow();
|
||||
mw->show();
|
||||
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
11
MainWindow.h
11
MainWindow.h
|
@ -1,6 +1,10 @@
|
|||
#ifndef __MAINWINDOW_H__
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
class MainWindow;
|
||||
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QMainWindow>
|
||||
|
@ -9,13 +13,10 @@
|
|||
#include <QWidget>
|
||||
#include <QHash>
|
||||
|
||||
#include <xmmsclient/xmmsclient.h>
|
||||
|
||||
#include "Skin.h"
|
||||
#include "XmmsQT4.h"
|
||||
#include "MainDisplay.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
@ -25,8 +26,12 @@ class MainWindow : public QMainWindow
|
|||
MainWindow(void);
|
||||
~MainWindow(void);
|
||||
Skin *getSkin(void);
|
||||
XMMSHandler *getHandler () { return m_handler; }
|
||||
MainDisplay *getMD () { return m_display; }
|
||||
private:
|
||||
Skin *skin;
|
||||
XMMSHandler *m_handler;
|
||||
MainDisplay *m_display;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "NumberDisplay.h"
|
||||
#include "MainWindow.h"
|
||||
#include "NumberDisplay.h"
|
||||
|
||||
NumberDisplay::NumberDisplay (QWidget *parent, uint w, uint startpx) : PixWidget (parent)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "PixWidget.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include "PixWidget.h"
|
||||
|
||||
|
||||
PixWidget::PixWidget (QWidget *parent) : QWidget (parent)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,9 @@ void
|
|||
TextScroller::setText (const QString &text)
|
||||
{
|
||||
drawQtFont (text);
|
||||
m_x_off = 1;
|
||||
m_x2_off = 0;
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "TitleBar.h"
|
||||
#include "MainWindow.h"
|
||||
#include "TitleBar.h"
|
||||
#include "Display.h"
|
||||
|
||||
TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent)
|
||||
|
|
71
XMMSHandler.cpp
Normal file
71
XMMSHandler.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#include <xmmsclient/xmmsclient++.h>
|
||||
|
||||
#include "XmmsQT4.h"
|
||||
#include "MainDisplay.h"
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include <QErrorMessage>
|
||||
|
||||
XMMSHandler::XMMSHandler (MainWindow *mw) : sigc::trackable ()
|
||||
{
|
||||
m_mw = mw;
|
||||
|
||||
m_xmmsc = new XMMSClient ("promoe");
|
||||
|
||||
if (!m_xmmsc->connect (NULL)) {
|
||||
QErrorMessage *err = new QErrorMessage ();
|
||||
err->showMessage ("Couldn't connect to XMMS2, please try again.");
|
||||
err->exec ();
|
||||
exit (-1);
|
||||
}
|
||||
m_qt4 = new XmmsQT4 (m_xmmsc->getConn (), qApp);
|
||||
|
||||
XMMSResult *r = m_xmmsc->signal_playback_playtime ();
|
||||
r->connect (sigc::mem_fun (this, &XMMSHandler::playback_playtime));
|
||||
|
||||
r = m_xmmsc->broadcast_playback_current_id ();
|
||||
r->connect (sigc::mem_fun (this, &XMMSHandler::playback_current_id));
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::playback_playtime (XMMSResult *res)
|
||||
{
|
||||
uint i, sec, min;
|
||||
res->getValue (&i);
|
||||
|
||||
sec = (i / 1000) % 60;
|
||||
min = (i / 1000) / 60;
|
||||
m_mw->getMD ()->m_number->setNumber (min / 10, min % 10);
|
||||
m_mw->getMD ()->m_number2->setNumber (sec / 10, sec % 10);
|
||||
|
||||
res->restart ();
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::playback_current_id (XMMSResult *res)
|
||||
{
|
||||
uint i;
|
||||
res->getValue (&i);
|
||||
|
||||
qDebug ("current id = %d", i);
|
||||
|
||||
XMMSResult *r = m_xmmsc->medialib_get_info (i);
|
||||
r->connect (sigc::mem_fun (this, &XMMSHandler::medialib_info));
|
||||
}
|
||||
|
||||
void
|
||||
XMMSHandler::medialib_info (XMMSResult *res)
|
||||
{
|
||||
char str[4096];
|
||||
|
||||
res->entryFormat (str, 4096, "${artist} - ${album} - ${title}");
|
||||
qDebug ("%s", str);
|
||||
m_mw->getMD ()->m_text->setText (QString::fromUtf8 (str));
|
||||
|
||||
delete res;
|
||||
}
|
||||
|
||||
XMMSHandler::~XMMSHandler ()
|
||||
{
|
||||
}
|
||||
|
45
XMMSHandler.h
Normal file
45
XMMSHandler.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef __XMMS_HANDLER_H__
|
||||
#define __XMMS_HANDLER_H__
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
|
||||
class XMMSHandler;
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "XmmsQT4.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class XMMSHandler : public QObject, public sigc::trackable {
|
||||
Q_OBJECT
|
||||
public:
|
||||
XMMSHandler (MainWindow *mw);
|
||||
~XMMSHandler ();
|
||||
void playback_playtime (XMMSResult *res);
|
||||
void playback_current_id (XMMSResult *res);
|
||||
void medialib_info (XMMSResult *res);
|
||||
|
||||
const XMMSClient *getXMMS () { return m_xmmsc; }
|
||||
|
||||
public slots:
|
||||
void play () { delete m_xmmsc->playback_start (); }
|
||||
void stop () { delete m_xmmsc->playback_stop (); }
|
||||
void pause () { delete m_xmmsc->playback_pause (); }
|
||||
void next () {
|
||||
delete m_xmmsc->playlist_set_next_rel (1);
|
||||
delete m_xmmsc->playback_tickle ();
|
||||
}
|
||||
void prev () {
|
||||
delete m_xmmsc->playlist_set_next_rel (-1);
|
||||
delete m_xmmsc->playback_tickle ();
|
||||
}
|
||||
|
||||
private:
|
||||
MainWindow *m_mw;
|
||||
XmmsQT4 *m_qt4;
|
||||
XMMSClient *m_xmmsc;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -13,7 +13,7 @@ XmmsQT4::XmmsQT4 (xmmsc_connection_t *xmmsc, QObject *parent) : QObject (parent)
|
|||
|
||||
m_rsock = new QSocketNotifier (m_fd, QSocketNotifier::Read, this);
|
||||
connect (m_rsock, SIGNAL (activated (int)), SLOT (OnRead ()));
|
||||
m_rsock->setEnabled (false);
|
||||
m_rsock->setEnabled (true);
|
||||
|
||||
m_wsock = new QSocketNotifier (m_fd, QSocketNotifier::Write, this);
|
||||
connect (m_wsock, SIGNAL (activated (int)), SLOT (OnWrite ()));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SOURCES += XmmsQT4.cpp PixWidget.cpp Skin.cpp MainWindow.cpp Display.cpp MainDisplay.cpp TitleBar.cpp Button.cpp TextBar.cpp NumberDisplay.cpp
|
||||
HEADERS += XmmsQT4.h PixWidget.h Skin.h MainWindow.h Display.h MainDisplay.h TitleBar.h Button.h TextBar.h NumberDisplay.h
|
||||
SOURCES += XmmsQT4.cpp PixWidget.cpp Skin.cpp MainWindow.cpp Display.cpp MainDisplay.cpp TitleBar.cpp Button.cpp TextBar.cpp NumberDisplay.cpp XMMSHandler.cpp
|
||||
HEADERS += XmmsQT4.h PixWidget.h Skin.h MainWindow.h Display.h MainDisplay.h TitleBar.h Button.h TextBar.h NumberDisplay.h XMMSHandler.h
|
||||
CONFIG += link_pkgconfig
|
||||
CONFIG += debug
|
||||
QMAKE_CFLAGS_WARN_OFF += -Wno-unused-parameter
|
||||
PKGCONFIG += xmms2-client
|
||||
PKGCONFIG += xmms2-client-cpp sigc++-2.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue