Applets
brandingbutton.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "brandingbutton.h"
00021
00022 #include <QtGui/QPainter>
00023
00024 #include <KDebug>
00025
00026 #include "plasma/svg.h"
00027
00028
00029 #include "plasma/theme.h"
00030 #include <KStandardDirs>
00031 namespace Kickoff
00032 {
00033
00034 BrandingButton::BrandingButton(QWidget *parent)
00035 : QToolButton(parent),
00036 m_svg(new Plasma::Svg())
00037 {
00038 m_svg->setImagePath("widgets/branding");
00039 m_svg->resize();
00040 setCursor(Qt::PointingHandCursor);
00041 }
00042
00043 QSize BrandingButton::minimumSizeHint() const
00044 {
00045 return sizeHint();
00046 }
00047
00048 QSize BrandingButton::sizeHint() const
00049 {
00050 return m_svg->elementSize("brilliant");
00051 }
00052
00053 void BrandingButton::paintEvent(QPaintEvent *event)
00054 {
00055 if (!m_svg->isValid()) {
00056 kDebug() << "bad branding svg!";
00057 return;
00058 }
00059
00060 QPainter p(this);
00061 QSize s = m_svg->elementSize("brilliant");
00062 QRect r = rect();
00063
00064
00065 if (r.width() > s.width()) {
00066 r.setX(r.x() + (r.width() - s.width()) / 2);
00067 }
00068
00069 if (r.height() > s.height()) {
00070 r.setY(r.y() + (r.height() - s.height()) / 2);
00071 }
00072
00073 m_svg->paint(&p, rect(), "brilliant");
00074 }
00075
00076 }
00077