2 Copyright 2008 Aaron Seigo <aseigo@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "brandingbutton.h"
22 #include <QtGui/QPainter>
24 #include <KConfigGroup>
26 #include <KStandardDirs>
30 #include <Plasma/Theme>
35 BrandingButton::BrandingButton(QWidget
*parent
)
36 : QToolButton(parent
),
37 m_svg(new Plasma::Svg(this))
39 m_svg
->setImagePath("widgets/branding");
42 connect(m_svg
, SIGNAL(repaintNeeded()), this, SLOT(checkBranding()));
43 connect(this, SIGNAL(clicked()), SLOT(openHomepage()));
44 setCursor(Qt::PointingHandCursor
);
47 QSize
BrandingButton::minimumSizeHint() const
52 QSize
BrandingButton::sizeHint() const
57 void BrandingButton::checkBranding()
59 m_doingBranding
= m_svg
->isValid() && m_svg
->hasElement("brilliant");
61 if (!m_doingBranding
) {
66 m_size
= m_svg
->elementSize("brilliant");
69 void BrandingButton::openHomepage()
71 //FIXME: 4.3 .. add a brandingConfig to Theme
72 KUrl
home("http://www.kde.org");
73 QString themePath
= KStandardDirs::locate("data", "desktoptheme/" +
74 Plasma::Theme::defaultTheme()->themeName() +
76 if (!themePath
.isEmpty()) {
78 KConfigGroup
brandConfig(&c
, "Branding");
79 home
= brandConfig
.readEntry("homepage", home
);
82 new KRun(home
, topLevelWidget(), false, false);
85 void BrandingButton::paintEvent(QPaintEvent
*event
)
88 if (!m_doingBranding
) {
89 //kDebug() << "bad branding svg!";
94 QSize s
= m_svg
->elementSize("brilliant");
97 // center ourselves in the full rect
98 if (r
.width() > s
.width()) {
99 r
.setX(r
.x() + (r
.width() - s
.width()) / 2);
102 if (r
.height() > s
.height()) {
103 r
.setY(r
.y() + (r
.height() - s
.height()) / 2);
106 m_svg
->paint(&p
, rect(), "brilliant");
109 } // namespace KickOff
111 #include "brandingbutton.moc"