OTHER: Replace QIcon in PixmapButton with own class
This should allow to add pixmaps for disabled buttons in a sane way without Qt beeing too 'intelligent'
This commit is contained in:
parent
353b7314e6
commit
81d24d1c3f
10 changed files with 262 additions and 150 deletions
|
@ -92,15 +92,11 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
|||
m_auto->move (skin->getPos (Skin::BUTTON_EQ_AUTO));
|
||||
m_auto->setEnabled(false); // FIXME: needs to be implemented
|
||||
|
||||
connect (m_auto, SIGNAL(clicked()), parent, SLOT(setEnabled()));
|
||||
|
||||
m_preset = new PixmapButton (this);
|
||||
m_preset->resize (skin->getSize (Skin::BUTTON_EQ_PRESET));
|
||||
m_preset->move (skin->getPos (Skin::BUTTON_EQ_PRESET));
|
||||
m_preset->setEnabled(false); // FIXME: needs to be implemented
|
||||
|
||||
connect(m_preset, SIGNAL(clicked()), parent, SLOT(setEnabled()));
|
||||
|
||||
m_preamp = new EqualizerSlider(this, -1);
|
||||
m_preamp->resize (skin->getSize (Skin::SLIDER_EQUALIZER_BGS));
|
||||
m_preamp->move(21, 38);
|
||||
|
@ -140,11 +136,11 @@ EqualizerWidget::setPixmaps (Skin *skin)
|
|||
setMaximumSize (m_pixmap.size ());
|
||||
|
||||
/* Updade Buttons */
|
||||
m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_EQ_CLOSE));
|
||||
m_shadebtn->setIcon (skin->getIcon (Skin::BUTTON_EQ_SHADE));
|
||||
m_enable->setIcon (skin->getIcon (Skin::BUTTON_EQ_ACTIVE));
|
||||
m_auto->setIcon (skin->getIcon (Skin::BUTTON_EQ_AUTO));
|
||||
m_preset->setIcon (skin->getIcon (Skin::BUTTON_EQ_PRESET));
|
||||
m_closebtn->setPixmaps (skin->getButton (Skin::BUTTON_EQ_CLOSE));
|
||||
m_shadebtn->setPixmaps (skin->getButton (Skin::BUTTON_EQ_SHADE));
|
||||
m_enable->setPixmaps (skin->getButton (Skin::BUTTON_EQ_ACTIVE));
|
||||
m_auto->setPixmaps (skin->getButton (Skin::BUTTON_EQ_AUTO));
|
||||
m_preset->setPixmaps (skin->getButton (Skin::BUTTON_EQ_PRESET));
|
||||
|
||||
/* Update Sliders */
|
||||
QPixmap normal = skin->getItem (Skin::EQ_WIN_BAR_BTN_0);
|
||||
|
@ -161,7 +157,7 @@ EqualizerWidget::setPixmaps (Skin *skin)
|
|||
|
||||
setActive (m_active);
|
||||
|
||||
update();
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -170,6 +166,14 @@ EqualizerWidget::setActive (bool active)
|
|||
Skin *skin = SkinManager::instance ()->activeSkin ();
|
||||
|
||||
m_active = active;
|
||||
|
||||
if (active) {
|
||||
m_title = skin->getItem (Skin::EQ_WIN_TITLE_ACTIVE);
|
||||
} else {
|
||||
m_title = skin->getItem (Skin::EQ_WIN_TITLE_INACTIVE);
|
||||
}
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -183,7 +187,8 @@ EqualizerWidget::paintEvent (QPaintEvent *event)
|
|||
|
||||
paint.begin(this);
|
||||
|
||||
paint.drawPixmap(rect(), m_pixmap, m_pixmap.rect());
|
||||
paint.drawPixmap(rect (), m_pixmap, m_pixmap.rect ());
|
||||
paint.drawPixmap(QPoint (0, 0), m_title, m_title.rect ());
|
||||
// r.setRect(86, 17, 113, 19);
|
||||
if (m_graph.height () > 0 ) {
|
||||
r.setRect(86, 17, m_graph.width (), m_graph.height ());
|
||||
|
|
|
@ -73,6 +73,7 @@ class EqualizerWidget : public QWidget
|
|||
bool m_active;
|
||||
XConfig *m_xconfig;
|
||||
QPixmap m_pixmap;
|
||||
QPixmap m_title;
|
||||
QPixmap m_graph;
|
||||
PixmapButton *m_closebtn;
|
||||
PixmapButton *m_shadebtn;
|
||||
|
|
|
@ -151,16 +151,16 @@ MainDisplay::setPixmaps (Skin *skin)
|
|||
setFixedSize(QSize(275, 116));
|
||||
|
||||
/* update buttons*/
|
||||
m_prev->setIcon (skin->getIcon (Skin::BUTTON_MW_PREV));
|
||||
m_play->setIcon (skin->getIcon (Skin::BUTTON_MW_PLAY));
|
||||
m_pause->setIcon (skin->getIcon (Skin::BUTTON_MW_PAUSE));
|
||||
m_stop->setIcon (skin->getIcon (Skin::BUTTON_MW_STOP));
|
||||
m_next->setIcon (skin->getIcon (Skin::BUTTON_MW_NEXT));
|
||||
m_eject->setIcon (skin->getIcon (Skin::BUTTON_MW_EJECT));
|
||||
m_eq->setIcon (skin->getIcon (Skin::BUTTON_MW_EQ));
|
||||
m_pls->setIcon (skin->getIcon (Skin::BUTTON_MW_PLS));
|
||||
m_shuffle->setIcon (skin->getIcon (Skin::BUTTON_MW_SHUFFLE));
|
||||
m_repeat->setIcon (skin->getIcon (Skin::BUTTON_MW_REPEAT));
|
||||
m_prev->setPixmaps (skin->getButton (Skin::BUTTON_MW_PREV));
|
||||
m_play->setPixmaps (skin->getButton (Skin::BUTTON_MW_PLAY));
|
||||
m_pause->setPixmaps (skin->getButton (Skin::BUTTON_MW_PAUSE));
|
||||
m_stop->setPixmaps (skin->getButton (Skin::BUTTON_MW_STOP));
|
||||
m_next->setPixmaps (skin->getButton (Skin::BUTTON_MW_NEXT));
|
||||
m_eject->setPixmaps (skin->getButton (Skin::BUTTON_MW_EJECT));
|
||||
m_eq->setPixmaps (skin->getButton (Skin::BUTTON_MW_EQ));
|
||||
m_pls->setPixmaps (skin->getButton (Skin::BUTTON_MW_PLS));
|
||||
m_shuffle->setPixmaps (skin->getButton (Skin::BUTTON_MW_SHUFFLE));
|
||||
m_repeat->setPixmaps (skin->getButton (Skin::BUTTON_MW_REPEAT));
|
||||
|
||||
/* update Sliders */
|
||||
m_vslider->setBackground (skin->getBackgrounds (Skin::SLIDER_VOLUMEBAR_BGS));
|
||||
|
|
|
@ -153,14 +153,14 @@ TitleBar::setPixmaps (Skin *skin)
|
|||
m_pixmap = m_pixmap_inactive;
|
||||
}
|
||||
|
||||
m_menubtn->setIcon (skin->getIcon (Skin::BUTTON_MW_MENU));
|
||||
m_minimize->setIcon (skin->getIcon (Skin::BUTTON_MW_MINIMIZE));
|
||||
m_menubtn->setPixmaps (skin->getButton (Skin::BUTTON_MW_MENU));
|
||||
m_minimize->setPixmaps (skin->getButton (Skin::BUTTON_MW_MINIMIZE));
|
||||
if (m_shaded) {
|
||||
m_shadebtn->setIcon (skin->getIcon (Skin::BUTTON_MW_SHADED_UNSHADE));
|
||||
m_shadebtn->setPixmaps (skin->getButton (Skin::BUTTON_MW_SHADED_UNSHADE));
|
||||
} else {
|
||||
m_shadebtn->setIcon (skin->getIcon (Skin::BUTTON_MW_SHADE));
|
||||
m_shadebtn->setPixmaps (skin->getButton (Skin::BUTTON_MW_SHADE));
|
||||
}
|
||||
m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_MW_CLOSE));
|
||||
m_closebtn->setPixmaps (skin->getButton (Skin::BUTTON_MW_CLOSE));
|
||||
|
||||
update ();
|
||||
}
|
||||
|
|
|
@ -103,8 +103,8 @@ PlaylistShade::setPixmaps (Skin *skin)
|
|||
{
|
||||
QSettings s;
|
||||
|
||||
m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_CLOSE));
|
||||
m_unshadebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_SHADED_UNSHADE));
|
||||
m_closebtn->setPixmaps (skin->getButton (Skin::BUTTON_PLS_CLOSE));
|
||||
m_unshadebtn->setPixmaps (skin->getButton (Skin::BUTTON_PLS_SHADED_UNSHADE));
|
||||
|
||||
m_pixmap_le = skin->getPls (Skin::PLS_WS_LE_0);
|
||||
m_pixmap_re_0 = skin->getPls (Skin::PLS_WS_RE_0);
|
||||
|
|
|
@ -451,8 +451,8 @@ PlaylistWidget::resizeEvent (QResizeEvent *event)
|
|||
void
|
||||
PlaylistWidget::setPixmaps (Skin *skin)
|
||||
{
|
||||
m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_CLOSE));
|
||||
m_shadebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_SHADE));
|
||||
m_closebtn->setPixmaps (skin->getButton (Skin::BUTTON_PLS_CLOSE));
|
||||
m_shadebtn->setPixmaps (skin->getButton (Skin::BUTTON_PLS_SHADE));
|
||||
|
||||
m_controls->setNumbers (skin->getSmallNumbers ());
|
||||
m_controls->setPixmapFont (skin->getPixmapFont ());
|
||||
|
|
|
@ -80,32 +80,32 @@ Skin::handle_titlebar (const QPixmap &img)
|
|||
if (img.isNull ())
|
||||
return false;
|
||||
|
||||
QIcon icon;
|
||||
PBPixmaps button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (0, 0, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (0, 9, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_MENU] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (0, 0, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (0, 9, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_MENU] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (9, 0, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (9, 9, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_MINIMIZE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (9, 0, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (9, 9, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_MINIMIZE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (18, 0, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (18, 9, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_CLOSE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (18, 0, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (18, 9, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_CLOSE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (0, 18, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (9, 18, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_SHADE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (0, 18, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (9, 18, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_SHADE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (0, 27, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (9, 27, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_SHADED_UNSHADE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (0, 27, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (9, 27, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_SHADED_UNSHADE] = button;
|
||||
|
||||
m_items[TITLEBAR_0] = img.copy(27, 0, 275, 14);
|
||||
m_items[TITLEBAR_1] = img.copy(27, 15, 275, 14);
|
||||
|
@ -197,37 +197,37 @@ Skin::handle_cbuttons (const QPixmap &img)
|
|||
if (img.isNull ())
|
||||
return false;
|
||||
|
||||
QIcon icon;
|
||||
PBPixmaps button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (0, 0, 23, 18), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (0, 18, 23, 18), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_PREV] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (0, 0, 23, 18), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (0, 18, 23, 18), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_PREV] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (23, 0, 23, 18), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (23, 18, 23, 18), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_PLAY] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (23, 0, 23, 18), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (23, 18, 23, 18), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_PLAY] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (46, 0, 23, 18), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (46, 18, 23, 18), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_PAUSE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (46, 0, 23, 18), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (46, 18, 23, 18), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_PAUSE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (69, 0, 23, 18), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (69, 18, 23, 18), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_STOP] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (69, 0, 23, 18), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (69, 18, 23, 18), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_STOP] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (92, 0, 22, 18), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (92, 18, 22, 18), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_NEXT] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (92, 0, 22, 18), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (92, 18, 22, 18), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_NEXT] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (114, 0, 22, 16), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (114, 16, 22, 16), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_MW_EJECT] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (114, 0, 22, 16), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (114, 16, 22, 16), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_MW_EJECT] = button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -286,35 +286,43 @@ Skin::handle_shufrep (const QPixmap &img)
|
|||
if (img.isNull ())
|
||||
return false;
|
||||
|
||||
QIcon icon;
|
||||
PBPixmaps button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy ( 0, 61, 23, 12), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (46, 61, 23, 12), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap (img.copy ( 0, 73, 23, 12), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap (img.copy (46, 73, 23, 12), QIcon::Active, QIcon::On);
|
||||
m_icons[BUTTON_MW_EQ] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy ( 0, 61, 23, 12), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (46, 61, 23, 12), PBPixmaps::Pressed);
|
||||
button.addPixmap (img.copy ( 0, 73, 23, 12), PBPixmaps::Normal,
|
||||
PBPixmaps::Checked);
|
||||
button.addPixmap (img.copy (46, 73, 23, 12), PBPixmaps::Pressed,
|
||||
PBPixmaps::Checked);
|
||||
m_buttons[BUTTON_MW_EQ] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (23, 61, 23, 12), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (69, 61, 23, 12), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap (img.copy (23, 73, 23, 12), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap (img.copy (69, 73, 23, 12), QIcon::Active, QIcon::On);
|
||||
m_icons[BUTTON_MW_PLS] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (23, 61, 23, 12), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (69, 61, 23, 12), PBPixmaps::Pressed);
|
||||
button.addPixmap (img.copy (23, 73, 23, 12), PBPixmaps::Normal,
|
||||
PBPixmaps::Checked);
|
||||
button.addPixmap (img.copy (69, 73, 23, 12), PBPixmaps::Pressed,
|
||||
PBPixmaps::Checked);
|
||||
m_buttons[BUTTON_MW_PLS] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (28, 0, 46, 15), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (28, 15, 46, 15), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap (img.copy (28, 30, 46, 15), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap (img.copy (28, 45, 46, 15), QIcon::Active, QIcon::On);
|
||||
m_icons[BUTTON_MW_SHUFFLE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (28, 0, 46, 15), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (28, 15, 46, 15), PBPixmaps::Pressed);
|
||||
button.addPixmap (img.copy (28, 30, 46, 15), PBPixmaps::Normal,
|
||||
PBPixmaps::Checked);
|
||||
button.addPixmap (img.copy (28, 45, 46, 15), PBPixmaps::Pressed,
|
||||
PBPixmaps::Checked);
|
||||
m_buttons[BUTTON_MW_SHUFFLE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (0, 0, 28, 15), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (0, 15, 28, 15), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap (img.copy (0, 30, 28, 15), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap (img.copy (0, 45, 28, 15), QIcon::Active, QIcon::On);
|
||||
m_icons[BUTTON_MW_REPEAT] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (0, 0, 28, 15), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (0, 15, 28, 15), PBPixmaps::Pressed);
|
||||
button.addPixmap (img.copy (0, 30, 28, 15), PBPixmaps::Normal,
|
||||
PBPixmaps::Checked);
|
||||
button.addPixmap (img.copy (0, 45, 28, 15), PBPixmaps::Pressed,
|
||||
PBPixmaps::Checked);
|
||||
m_buttons[BUTTON_MW_REPEAT] = button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -421,6 +429,8 @@ Skin::handle_eqmain (const QPixmap &img)
|
|||
return false;
|
||||
|
||||
m_items[EQ_WIN_BG] = img.copy (0, 0, 275, 116);
|
||||
m_items[EQ_WIN_TITLE_ACTIVE] = img.copy (0, 134, 275, 14);
|
||||
m_items[EQ_WIN_TITLE_INACTIVE] = img.copy (0, 149, 275, 14);
|
||||
|
||||
if (img.height () > 294) {
|
||||
m_items[EQ_WIN_GRAPH_BG] =
|
||||
|
@ -429,35 +439,39 @@ Skin::handle_eqmain (const QPixmap &img)
|
|||
m_items[EQ_WIN_GRAPH_BG] = QPixmap ();
|
||||
}
|
||||
|
||||
QIcon icon;
|
||||
PBPixmaps button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy ( 0, 116, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy ( 0, 125, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_EQ_CLOSE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy ( 0, 116, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy ( 0, 125, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_EQ_CLOSE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy ( 10, 119, 25, 12), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (128, 119, 25, 12), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap (img.copy ( 69, 119, 25, 12), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap (img.copy (187, 119, 25, 12), QIcon::Active, QIcon::On);
|
||||
m_icons[BUTTON_EQ_ACTIVE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy ( 10, 119, 25, 12), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (128, 119, 25, 12), PBPixmaps::Pressed);
|
||||
button.addPixmap (img.copy ( 69, 119, 25, 12), PBPixmaps::Normal,
|
||||
PBPixmaps::Checked);
|
||||
button.addPixmap (img.copy (187, 119, 25, 12), PBPixmaps::Pressed,
|
||||
PBPixmaps::Checked);
|
||||
m_buttons[BUTTON_EQ_ACTIVE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy ( 35, 119, 33, 12), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (153, 119, 33, 12), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap (img.copy ( 94, 119, 33, 12), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap (img.copy (212, 119, 33, 12), QIcon::Active, QIcon::On);
|
||||
m_icons[BUTTON_EQ_AUTO] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy ( 35, 119, 33, 12), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (153, 119, 33, 12), PBPixmaps::Pressed);
|
||||
button.addPixmap (img.copy ( 94, 119, 33, 12), PBPixmaps::Normal,
|
||||
PBPixmaps::Checked);
|
||||
button.addPixmap (img.copy (212, 119, 33, 12), PBPixmaps::Pressed,
|
||||
PBPixmaps::Checked);
|
||||
m_buttons[BUTTON_EQ_AUTO] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (224, 164, 44, 12), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (224, 176, 44, 12), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_EQ_PRESET] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (224, 164, 44, 12), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (224, 176, 44, 12), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_EQ_PRESET] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (254, 3, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
m_icons[BUTTON_EQ_SHADE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (254, 3, 9, 9), PBPixmaps::Normal);
|
||||
m_buttons[BUTTON_EQ_SHADE] = button;
|
||||
|
||||
QPixmapList list;
|
||||
for (int i = 0; i < 14; i++) {
|
||||
|
@ -481,8 +495,8 @@ Skin::handle_eq_ex (const QPixmap &img)
|
|||
if (img.isNull ())
|
||||
return false;
|
||||
|
||||
m_icons[BUTTON_EQ_SHADE].addPixmap (img.copy ( 1, 38, 9, 9),
|
||||
QIcon::Active, QIcon::Off);
|
||||
m_buttons[BUTTON_EQ_SHADE].addPixmap (img.copy ( 1, 38, 9, 9),
|
||||
PBPixmaps::Pressed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -493,22 +507,22 @@ Skin::handle_pledit (const QPixmap &img)
|
|||
if (img.isNull ())
|
||||
return false;
|
||||
|
||||
QIcon icon;
|
||||
PBPixmaps button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (167, 3, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy ( 52, 42, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_PLS_CLOSE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (167, 3, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy ( 52, 42, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_PLS_CLOSE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (158, 3, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy ( 62, 42, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_PLS_SHADE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (158, 3, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy ( 62, 42, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_PLS_SHADE] = button;
|
||||
|
||||
icon = QIcon ();
|
||||
icon.addPixmap (img.copy (129, 45, 9, 9), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap (img.copy (150, 42, 9, 9), QIcon::Active, QIcon::Off);
|
||||
m_icons[BUTTON_PLS_SHADED_UNSHADE] = icon;
|
||||
button = PBPixmaps ();
|
||||
button.addPixmap (img.copy (129, 45, 9, 9), PBPixmaps::Normal);
|
||||
button.addPixmap (img.copy (150, 42, 9, 9), PBPixmaps::Pressed);
|
||||
m_buttons[BUTTON_PLS_SHADED_UNSHADE] = button;
|
||||
|
||||
m_playlist[PLS_CORNER_UL_0] = img.copy(0, 0, 25, 20);
|
||||
m_playlist[PLS_CORNER_UL_1] = img.copy(0, 21, 25, 20);
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "pixmapbutton.h"
|
||||
|
||||
class QIODevice;
|
||||
|
||||
typedef QList <QPixmap> QPixmapList;
|
||||
|
@ -51,8 +53,8 @@ class Skin : public QObject
|
|||
const PixmapMap getSmallNumbers () const
|
||||
{ return m_smallNumbers; }
|
||||
|
||||
const QIcon getIcon (uint item) const
|
||||
{ return m_icons.value(item); }
|
||||
const PBPixmaps getButton (int button) const
|
||||
{ return m_buttons.value (button); }
|
||||
const QPixmapList getBackgrounds (uint item) const
|
||||
{ return m_backgrounds.value(item); };
|
||||
const PixmapMap getPixmapFont () const
|
||||
|
@ -92,8 +94,7 @@ class Skin : public QObject
|
|||
QString m_skinname;
|
||||
QString m_path;
|
||||
|
||||
|
||||
QMap<uint, QIcon> m_icons;
|
||||
QMap<int, PBPixmaps> m_buttons;
|
||||
QMap<uint, QPixmapList> m_backgrounds;
|
||||
|
||||
QMap<int, QPixmap> m_numbers;
|
||||
|
@ -180,6 +181,8 @@ class Skin : public QObject
|
|||
CLUTTER_D,
|
||||
CLUTTER_V,
|
||||
EQ_WIN_BG,
|
||||
EQ_WIN_TITLE_ACTIVE,
|
||||
EQ_WIN_TITLE_INACTIVE,
|
||||
EQ_WIN_GRAPH_BG,
|
||||
EQ_WIN_BAR_BTN_0,
|
||||
EQ_WIN_BAR_BTN_1,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* This file is a part of Promoe, an XMMS2 Client
|
||||
*
|
||||
* Copyright (C) 2008-2009 XMMS2 Team
|
||||
* Copyright (C) 2008-2010 XMMS2 Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -24,9 +24,25 @@
|
|||
void
|
||||
PixmapButton::paintEvent( QPaintEvent * event )
|
||||
{
|
||||
QPixmap pixmap = icon().pixmap (size(),
|
||||
isDown() ? QIcon::Active : QIcon::Normal,
|
||||
isChecked() ? QIcon::On : QIcon::Off);
|
||||
PBPixmaps::Mode m;
|
||||
if (isActiveWindow ()) {
|
||||
if (isDown ()) {
|
||||
m = PBPixmaps::Pressed;
|
||||
} else {
|
||||
m = PBPixmaps::Normal;
|
||||
}
|
||||
} else {
|
||||
m = PBPixmaps::Inactive;
|
||||
}
|
||||
|
||||
QPixmap pixmap = m_pixmaps.pixmap (m, isChecked () ? PBPixmaps::Checked
|
||||
: PBPixmaps::Unchecked);
|
||||
if (pixmap.isNull ()) {
|
||||
|
||||
pixmap = icon().pixmap (size(),
|
||||
isDown() ? QIcon::Active : QIcon::Normal,
|
||||
isChecked() ? QIcon::On : QIcon::Off);
|
||||
}
|
||||
|
||||
QPainter p;
|
||||
p.begin(this);
|
||||
|
@ -35,4 +51,12 @@ PixmapButton::paintEvent( QPaintEvent * event )
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
PixmapButton::setPixmaps (const PixmapButtonPixmaps & p)
|
||||
{
|
||||
m_pixmaps = p;
|
||||
|
||||
update ();
|
||||
}
|
||||
|
||||
#include "pixmapbutton.moc"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* This file is a part of Promoe, an XMMS2 CLient
|
||||
*
|
||||
* Copyright (C) 2008-2009 XMMS2 Team
|
||||
* Copyright (C) 2008-2010 XMMS2 Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -18,6 +18,10 @@
|
|||
#define __PIXMAPBUTTON_H__
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QMap>
|
||||
#include <QPixmap>
|
||||
|
||||
typedef QMap <int, QPixmap> PixmapMap;
|
||||
|
||||
class QPaintEvent;
|
||||
class QWidget;
|
||||
|
@ -31,17 +35,78 @@ class QWidget;
|
|||
*
|
||||
* only QIcon::Normal QIcon::Off combination is necessary
|
||||
*/
|
||||
class PixmapButtonPixmaps
|
||||
{
|
||||
public:
|
||||
PixmapButtonPixmaps () :
|
||||
m_pixmaps() {}
|
||||
PixmapButtonPixmaps (const PixmapButtonPixmaps &p) :
|
||||
m_pixmaps(p.m_pixmaps) {}
|
||||
|
||||
class PixmapButton : public QAbstractButton {
|
||||
|
||||
enum Mode {
|
||||
Normal = 0, // Used when button is in active Window
|
||||
Inactive = 1, // Used when button is in inactive Window
|
||||
Pressed = 2 // used when button is pressed
|
||||
};
|
||||
|
||||
enum State {
|
||||
Unchecked = 0, // used when button is unchecked
|
||||
Checked = 1 // used when button is checked
|
||||
};
|
||||
|
||||
void addPixmap (const QPixmap & pixmap, Mode m = Normal,
|
||||
State s = Unchecked) {
|
||||
m_pixmaps[getKey(m, s)] = pixmap;
|
||||
if (!m_pixmaps.contains (getKey (Normal, Unchecked))) {
|
||||
m_pixmaps[getKey (Normal, Unchecked)] = pixmap;
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap pixmap (Mode m = Normal, State s = Unchecked) const {
|
||||
if (m_pixmaps.contains (getKey (m, s))) {
|
||||
return m_pixmaps.value (getKey (m, s));
|
||||
|
||||
} else if (s == Checked && m != Normal &&
|
||||
m_pixmaps.contains (getKey (Normal, s))) {
|
||||
return m_pixmaps.value (getKey (Normal, s));
|
||||
} else {
|
||||
return m_pixmaps.value (getKey (Normal, Unchecked));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PixmapButtonPixmaps & operator= (const PixmapButtonPixmaps & p) {
|
||||
m_pixmaps = p.m_pixmaps;
|
||||
}
|
||||
|
||||
protected:
|
||||
PixmapMap m_pixmaps;
|
||||
|
||||
// get the key to be used in the PixmapMap
|
||||
inline int getKey (Mode m, State s) const { return (m + s*3); }
|
||||
};
|
||||
|
||||
typedef PixmapButtonPixmaps PBPixmaps;
|
||||
|
||||
|
||||
class PixmapButton : public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PixmapButton (QWidget *parent) : QAbstractButton (parent) {}
|
||||
~PixmapButton () {};
|
||||
|
||||
void setPixmaps (const PixmapButtonPixmaps & p);
|
||||
|
||||
protected:
|
||||
void paintEvent ( QPaintEvent * event );
|
||||
|
||||
PBPixmaps m_pixmaps;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue