promoe/src/mainwindow/clutterbar.cpp
Thomas Frauendorfer 096ac37121 OTHER: removed PixWidget
PixWidget sole purpose was to paint a given pixmap. Some of PixWidgets
child classes had to create that pixmap from some other pixmaps. Thus
PixWidget introduced some kind of unnecessary double buffering.
Furthermore, those pixmaps where created even if a widget wasn't
visible. Painting directly to the widget and calling the 'update ()'
method on changes might allow Qt to do some performance optimizations.
Most likely they will be to small to be noticable though.

I also disabled the shortcuts of the titlebarmenu. They were diplayed in
the menu but didn't work. As soon as I figure out how to get them
working again I will enable them again
2008-10-03 01:22:40 +02:00

92 lines
1.9 KiB
C++

/**
* 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 "clutterbar.h"
#include "Skin.h"
#include <QMouseEvent>
#include <QPainter>
ClutterBar::ClutterBar (QWidget *parent) : QWidget (parent)
{
Skin *skin = Skin::getInstance();
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
}
ClutterBar::~ClutterBar ()
{
}
void
ClutterBar::setPixmaps(Skin *skin)
{
m_clutter_on = skin->getItem(Skin::CLUTTER_ON);
m_clutter_off = skin->getItem(Skin::CLUTTER_OFF);
m_clutter_o = skin->getItem(Skin::CLUTTER_O);
m_clutter_a = skin->getItem(Skin::CLUTTER_A);
m_clutter_i = skin->getItem(Skin::CLUTTER_I);
m_clutter_d = skin->getItem(Skin::CLUTTER_D);
m_clutter_v = skin->getItem(Skin::CLUTTER_V);
m_pixmap = m_clutter_on;
setFixedSize (m_clutter_on.size ());
update();
}
void
ClutterBar::mousePressEvent (QMouseEvent *event)
{
int y = event->pos().y();
if (y > 2 && y < 11) {
m_pixmap = m_clutter_o;
} else if (y > 10 && y < 19) {
m_pixmap = m_clutter_a;
} else if (y > 18 && y < 27) {
m_pixmap = m_clutter_i;
} else if (y > 26 && y < 35) {
m_pixmap = m_clutter_d;
} else if (y > 34 && y < 43) {
m_pixmap = m_clutter_v;
}
update();
}
void
ClutterBar::mouseReleaseEvent (QMouseEvent *event)
{
m_pixmap = m_clutter_on;
update();
}
void
ClutterBar::paintEvent (QPaintEvent *event)
{
if (m_pixmap.isNull ()) {
return;
}
QPainter p (this);
p.drawPixmap (rect (), m_pixmap, m_pixmap.rect ());
}