diff --git a/src/PixWidget.cpp b/src/PixWidget.cpp deleted file mode 100644 index c0d329c..0000000 --- a/src/PixWidget.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file is a part of Promoe, an XMMS2 Client. - * - * Copyright (C) 2005-2008 XMMS2 Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "Skin.h" -#include "PixWidget.h" - -#include -#include - -PixWidget::PixWidget (QWidget *parent) : QWidget (parent) -{ - Skin *skin = Skin::getInstance(); - m_pixmap = QPixmap(0,0); - - connect (skin, SIGNAL (skinChanged (Skin *)), - this, SLOT (setPixmaps(Skin *))); -} - - -PixWidget::~PixWidget () -{ -} - - -void -PixWidget::setPixmaps(Skin *skin) -{ -} - -/* - * Since almost every Widget I have here - * is done by drawing self.pixmap onto self - * we define this a generic PaintEvent handler - */ -void -PixWidget::paintEvent (QPaintEvent *event) -{ - if (m_pixmap.isNull ()) { - return; - } - - QPainter (paint); - paint.begin (this); - paint.drawPixmap (rect (), m_pixmap, m_pixmap.rect ()); - paint.end (); -} diff --git a/src/PixWidget.h b/src/PixWidget.h deleted file mode 100644 index a7067cb..0000000 --- a/src/PixWidget.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is a part of Promoe, an XMMS2 Client. - * - * Copyright (C) 2005-2008 XMMS2 Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __PIXWIDGET_H__ -#define __PIXWIDGET_H__ - -#include -class QPixmap; - -class Skin; - -class PixWidget : public QWidget -{ - Q_OBJECT - public: - PixWidget(QWidget *parent = 0); - ~PixWidget(); - void paintEvent (QPaintEvent *event); - public slots: - virtual void setPixmaps(Skin *skin); - protected: - QPixmap m_pixmap; -}; - -#endif diff --git a/src/mainwindow/clutterbar.cpp b/src/mainwindow/clutterbar.cpp index 00cea9c..26c68e1 100644 --- a/src/mainwindow/clutterbar.cpp +++ b/src/mainwindow/clutterbar.cpp @@ -16,8 +16,15 @@ #include "clutterbar.h" #include "Skin.h" -ClutterBar::ClutterBar (QWidget *parent) : PixWidget (parent) +#include +#include + +ClutterBar::ClutterBar (QWidget *parent) : QWidget (parent) { + Skin *skin = Skin::getInstance(); + + connect (skin, SIGNAL (skinChanged (Skin *)), + this, SLOT (setPixmaps(Skin *))); } ClutterBar::~ClutterBar () @@ -39,8 +46,7 @@ ClutterBar::setPixmaps(Skin *skin) m_pixmap = m_clutter_on; - setMinimumSize (m_clutter_on.size ()); - setMaximumSize (m_clutter_on.size ()); + setFixedSize (m_clutter_on.size ()); update(); } @@ -74,4 +80,13 @@ ClutterBar::mouseReleaseEvent (QMouseEvent *event) } +void +ClutterBar::paintEvent (QPaintEvent *event) +{ + if (m_pixmap.isNull ()) { + return; + } + QPainter p (this); + p.drawPixmap (rect (), m_pixmap, m_pixmap.rect ()); +} diff --git a/src/mainwindow/clutterbar.h b/src/mainwindow/clutterbar.h index f327512..7559f75 100644 --- a/src/mainwindow/clutterbar.h +++ b/src/mainwindow/clutterbar.h @@ -16,10 +16,13 @@ #ifndef __CLUTTERBAR_H__ #define __CLUTTERBAR_H__ -#include -#include "PixWidget.h" +#include "QWidget" +class QMouseEvent; +class QPaintEvent; -class ClutterBar : public PixWidget +class Skin; + +class ClutterBar : public QWidget { Q_OBJECT public: @@ -30,6 +33,8 @@ class ClutterBar : public PixWidget void setPixmaps(Skin *skin); protected: + void paintEvent (QPaintEvent *event); + void mousePressEvent (QMouseEvent *event); void mouseReleaseEvent (QMouseEvent *event); @@ -44,7 +49,7 @@ class ClutterBar : public PixWidget bool enabled; - int m_ypos; + QPixmap m_pixmap; }; diff --git a/src/mainwindow/stereomono.cpp b/src/mainwindow/stereomono.cpp index 8389d15..9b93116 100644 --- a/src/mainwindow/stereomono.cpp +++ b/src/mainwindow/stereomono.cpp @@ -18,12 +18,13 @@ #include -StereoMono::StereoMono (QWidget *parent) : PixWidget (parent) +StereoMono::StereoMono (QWidget *parent) : QWidget (parent) { - setMinimumSize (56, 12); - setMaximumSize (56, 12); + setFixedSize (56, 12); - m_pixmap = QPixmap (56, 12); + Skin *skin = Skin::getInstance(); + connect (skin, SIGNAL (skinChanged (Skin *)), + this, SLOT (setPixmaps (Skin *))); } void @@ -34,47 +35,27 @@ StereoMono::setPixmaps (Skin *skin) m_pixmap_mono_on = skin->getItem (Skin::MONO_1); m_pixmap_mono_off = skin->getItem (Skin::MONO_0); - setStereoMono (m_stereo, m_mono); + update (); } void -StereoMono::drawPixmaps () +StereoMono::paintEvent (QPaintEvent *event) { - QPainter paint; - paint.begin (&m_pixmap); + QPainter p (this); - paint.drawPixmap (QRect (0, 0, 27, 12), - m_pixmap_mono, - m_pixmap_mono.rect ()); - - paint.drawPixmap (QRect (27, 0, 29, 12), - m_pixmap_stereo, - m_pixmap_stereo.rect ()); - paint.end (); - - update(); + p.drawPixmap (0, 0, m_mono ? m_pixmap_mono_on : m_pixmap_mono_off); + p.drawPixmap (27, 0, m_stereo ? m_pixmap_stereo_on : m_pixmap_stereo_off); } void StereoMono::setStereoMono (bool stereo, bool mono) { - - if (stereo) { - m_pixmap_stereo = m_pixmap_stereo_on; - } else { - m_pixmap_stereo = m_pixmap_stereo_off; - } - - if (mono) { - m_pixmap_mono = m_pixmap_mono_on; - } else { - m_pixmap_mono = m_pixmap_mono_off; - } + // if nothing changes, just return + if ((m_stereo == stereo) && (m_mono == mono)) + return; m_stereo = stereo; m_mono = mono; - drawPixmaps (); - + update (); } - diff --git a/src/mainwindow/stereomono.h b/src/mainwindow/stereomono.h index 3aed2b5..69ab185 100644 --- a/src/mainwindow/stereomono.h +++ b/src/mainwindow/stereomono.h @@ -16,10 +16,14 @@ #ifndef __STEREOMONO_H__ #define __STEREOMONO_H__ -#include "PixWidget.h" +#include -class StereoMono : public PixWidget +class QPaintEvent; +class Skin; + +class StereoMono : public QWidget { + Q_OBJECT public: StereoMono (QWidget *parent); ~StereoMono () { } @@ -29,8 +33,10 @@ class StereoMono : public PixWidget public slots: void setPixmaps (Skin *skin); + protected slots: + void paintEvent (QPaintEvent *event); + private: - void drawPixmaps (); bool m_stereo; bool m_mono; @@ -38,9 +44,6 @@ class StereoMono : public PixWidget QPixmap m_pixmap_stereo_off; QPixmap m_pixmap_mono_on; QPixmap m_pixmap_mono_off; - - QPixmap m_pixmap_mono; - QPixmap m_pixmap_stereo; }; #endif diff --git a/src/mainwindow/titlebar.cpp b/src/mainwindow/titlebar.cpp index 3d983bc..02ca59a 100644 --- a/src/mainwindow/titlebar.cpp +++ b/src/mainwindow/titlebar.cpp @@ -26,8 +26,9 @@ #include "Skin.h" #include +#include -TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent) +TitleBar::TitleBar (QWidget *parent, bool shaded) : QWidget (parent) { MainWindow *mw = dynamic_cast(window ()); m_shaded = shaded; @@ -61,6 +62,9 @@ TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent) m_closebtn->move (skin->getPos (Skin::BUTTON_MW_CLOSE)); connect (m_closebtn, SIGNAL (clicked()), qApp, SLOT (quit ())); + m_pixmap = QPixmap(0,0); + connect (skin, SIGNAL (skinChanged (Skin *)), + this, SLOT (setPixmaps(Skin *))); } void @@ -71,30 +75,30 @@ TitleBar::showMenu (void) QAction *a; a = new QAction (tr ("Medialib browser"), this); - a->setShortcut (tr ("Alt+M")); +// a->setShortcut (tr ("Alt+M")); connect (a, SIGNAL (triggered ()), this, SLOT (showMlib ())); a->setEnabled(false); // FIXME: disabled for now, as Mlib-browser doesn't work qm.addAction (a); a = new QAction (tr ("Server-side browser"), this); - a->setShortcut (tr ("Alt+S")); +// a->setShortcut (tr ("Alt+S")); connect (a, SIGNAL (triggered ()), this, SLOT (showServerB ())); qm.addAction (a); qm.addSeparator (); a = new QAction (tr ("Theme settings"), this); - a->setShortcut (tr ("Alt+T")); +// a->setShortcut (tr ("Alt+T")); connect (a, SIGNAL (triggered ()), this, SLOT (showTheme ())); qm.addAction (a); a = new QAction (tr ("Application settings"), this); - a->setShortcut (tr ("Alt+A")); +// a->setShortcut (tr ("Alt+A")); connect (a, SIGNAL (triggered ()), this, SLOT (showSettings ())); qm.addAction (a); a = new QAction (tr ("Server settings"), this); - a->setShortcut (tr ("Alt+S")); +// a->setShortcut (tr ("Alt+S")); a->setEnabled(false); // FIXME: disabled for now, not yet implemented qm.addAction (a); qm.addSeparator (); a = new QAction (tr ("Quit"), this); - a->setShortcut (tr ("Ctrl+Q")); +// a->setShortcut (tr ("Ctrl+Q")); connect (a, SIGNAL (triggered ()), qApp, SLOT (quit ())); qm.addAction (a); @@ -177,6 +181,15 @@ TitleBar::setActive (bool active) } } +void +TitleBar::paintEvent (QPaintEvent *event) +{ + QPainter p; + p.begin (this); + p.drawPixmap (rect (), m_pixmap); + p.end (); +} + void TitleBar::mouseDoubleClickEvent (QMouseEvent *event) { diff --git a/src/mainwindow/titlebar.h b/src/mainwindow/titlebar.h index cdfa7e3..c8431ad 100644 --- a/src/mainwindow/titlebar.h +++ b/src/mainwindow/titlebar.h @@ -16,14 +16,13 @@ #ifndef __TITLEBAR_H__ #define __TITLEBAR_H__ -class TitleBar; - -#include "PixWidget.h" +#include "QWidget" +class QPaintEvent; class PixmapButton; class Skin; -class TitleBar : public PixWidget +class TitleBar : public QWidget { Q_OBJECT public: @@ -39,6 +38,9 @@ class TitleBar : public PixWidget void showMlib (void); void showSettings (void); + protected slots: + void paintEvent (QPaintEvent *event); + protected: void mouseDoubleClickEvent (QMouseEvent *event); @@ -52,6 +54,7 @@ class TitleBar : public PixWidget PixmapButton *m_minimize; bool m_shaded; + QPixmap m_pixmap; }; #endif diff --git a/src/playlist/playlistmenu.cpp b/src/playlist/playlistmenu.cpp index 1accdad..2d18924 100644 --- a/src/playlist/playlistmenu.cpp +++ b/src/playlist/playlistmenu.cpp @@ -21,6 +21,28 @@ #include #include + +PlaylistMenuBar::PlaylistMenuBar (QWidget *parent, uint id) : QWidget (parent) +{ + m_id = id; + + Skin *skin = Skin::getInstance (); + m_pixmap = QPixmap (0,0); + + connect (skin, SIGNAL (skinChanged (Skin *)), + this, SLOT (setPixmaps (Skin *))); +} + +void +PlaylistMenuBar::paintEvent (QPaintEvent *event) +{ + QPainter p; + p.begin (this); + p.drawPixmap (rect (), m_pixmap, m_pixmap.rect ()); + p.end (); +} + + PlaylistMenuButton::PlaylistMenuButton (PlaylistMenu *menu, uint pix1, uint pix2) : QWidget (menu) { @@ -59,7 +81,7 @@ PlaylistMenuButton::setPixmaps (Skin *skin) * PlaylistMenu */ PlaylistMenu::PlaylistMenu (QWidget *parent, uint pix, - uint decoration) : PixWidget (parent) + uint decoration) : QWidget (parent) { setFixedSize (25, 18); @@ -70,6 +92,21 @@ PlaylistMenu::PlaylistMenu (QWidget *parent, uint pix, m_decbar->move (0, 0); m_pixid = pix; + + Skin *skin = Skin::getInstance (); + m_pixmap = QPixmap (0,0); + + connect (skin, SIGNAL (skinChanged (Skin *)), + this, SLOT (setPixmaps (Skin *))); +} + +void +PlaylistMenu::paintEvent (QPaintEvent *event) +{ + QPainter p; + p.begin (this); + p.drawPixmap (rect (), m_pixmap, m_pixmap.rect ()); + p.end (); } void diff --git a/src/playlist/playlistmenu.h b/src/playlist/playlistmenu.h index 463c898..c6e7f95 100644 --- a/src/playlist/playlistmenu.h +++ b/src/playlist/playlistmenu.h @@ -16,26 +16,25 @@ #ifndef __PLAYLISTMENU_H__ #define __PLAYLISTMENU_H__ -class PlaylistMenu; - -//#include "XMMSHandler.h" -#include "PixWidget.h" +#include #include "Skin.h" -#include +class PlaylistMenu; -class PlaylistMenuBar : public PixWidget { +class PlaylistMenuBar : public QWidget { Q_OBJECT public: - PlaylistMenuBar (QWidget *parent, uint id) : PixWidget (parent) - { - m_id = id; - } + PlaylistMenuBar (QWidget *parent, uint id); + public slots: void setPixmaps (Skin *skin) { m_pixmap = skin->getPls (m_id); } + protected slots: + void paintEvent (QPaintEvent *event); + private: uint m_id; + QPixmap m_pixmap; }; class PlaylistMenuButton : public QWidget { @@ -65,7 +64,7 @@ class PlaylistMenuButton : public QWidget { QPixmap m_pixmap; }; -class PlaylistMenu : public PixWidget { +class PlaylistMenu : public QWidget { Q_OBJECT public: PlaylistMenu (QWidget *, uint, uint); @@ -81,6 +80,9 @@ class PlaylistMenu : public PixWidget { public slots: void setPixmaps (Skin *skin); + protected slots: + void paintEvent (QPaintEvent *event); + private: uint m_pixid; uint m_dec; @@ -90,6 +92,7 @@ class PlaylistMenu : public PixWidget { PlaylistMenuBar *m_decbar; + QPixmap m_pixmap; }; #endif diff --git a/src/src.pri b/src/src.pri index 991c576..fe70a3e 100644 --- a/src/src.pri +++ b/src/src.pri @@ -4,8 +4,7 @@ include($$PWD/playlist/playlist.pri) include($$PWD/equalizer/equalizer.pri) include($$PWD/dialogs/dialogs.pri) -HEADERS += PixWidget.h \ - Skin.h \ +HEADERS += Skin.h \ XMMSHandler.h \ SkinChooser.h \ settingsdialog.h \ @@ -15,7 +14,6 @@ HEADERS += PixWidget.h \ BrowseDialog.h SOURCES += main.cpp \ - PixWidget.cpp \ Skin.cpp \ XMMSHandler.cpp \ SkinChooser.cpp \