diff options
author | Luiz Agostini <luiz.agostini@openbossa.org> | 2009-10-31 18:39:43 -0300 |
---|---|---|
committer | Luiz Agostini <luiz.agostini@openbossa.org> | 2009-11-05 00:42:09 -0300 |
commit | 5e2061270167479ab940a459a01ee2334aced88b (patch) | |
tree | dda1297162b746168e790837e15cba9beb1b7e1d /weather | |
parent | 20d5aea3940dd19b3c5c6235f13476c6d14e05b0 (diff) |
Weather: title bar is now using pixmap loader.
Signed-off-by: Luiz Agostini <luiz.agostini@openbossa.org>
Diffstat (limited to 'weather')
-rw-r--r-- | weather/bootmanager.cpp | 2 | ||||
-rw-r--r-- | weather/titlebar.cpp | 28 | ||||
-rw-r--r-- | weather/titlebar.h | 6 |
3 files changed, 15 insertions, 21 deletions
diff --git a/weather/bootmanager.cpp b/weather/bootmanager.cpp index aa60b01..45a8085 100644 --- a/weather/bootmanager.cpp +++ b/weather/bootmanager.cpp @@ -7,6 +7,7 @@ #include "forecastsnow.h" #include "forecaststars.h" #include "cityinfodisplay.h" +#include "titlebar.h" #include <QDebug> @@ -30,6 +31,7 @@ void BootManager::run() count += ForecastSnow::loadImages(); count += ForecastStars::loadImages(); count += CityInfoDisplay::loadImages(); + count += TitleBar::loadImages(); m_imagesLoaded = count == 0; diff --git a/weather/titlebar.cpp b/weather/titlebar.cpp index 231d2e1..53b695d 100644 --- a/weather/titlebar.cpp +++ b/weather/titlebar.cpp @@ -31,6 +31,7 @@ #include "titlebar.h" #include "settings.h" +#include "pixmaploader.h" #include <QFont> #include <QCoreApplication> @@ -38,9 +39,8 @@ // CloseButton CloseButton::CloseButton(QGraphicsItem *parent) - : QGraphicsPixmapItem(Settings::getScaledPic("button_close"), parent) + : PixmapButton(80.0, PixmapLoader::getPic("button_close"), parent) { - setShapeMode(BoundingRectShape); } void CloseButton::mousePressEvent(QGraphicsSceneMouseEvent *event) @@ -49,25 +49,10 @@ void CloseButton::mousePressEvent(QGraphicsSceneMouseEvent *event) QCoreApplication::instance()->quit(); } -QPainterPath CloseButton::shape() const -{ - return QGraphicsItem::shape(); -} - -QRectF CloseButton::boundingRect() const -{ - static const qreal minSize = 80.0; - QRectF result(QGraphicsPixmapItem::boundingRect()); - qreal hMargin = minSize < result.width() ? 0 : (minSize - result.width()) / 2; - qreal vMargin = minSize < result.height() ? 0 : (minSize - result.height()) / 2; - result.adjust(-hMargin, -vMargin, hMargin, vMargin); - return result; -} - // TitleBar TitleBar::TitleBar(QGraphicsItem *parent) - : QGraphicsPixmapItem(Settings::getScaledPic("title_bar"), parent) + : QGraphicsPixmapItem(PixmapLoader::getPic("title_bar"), parent) { QGraphicsTextItem *text = new QGraphicsTextItem(this); QFont font = text->font(); @@ -83,3 +68,10 @@ TitleBar::TitleBar(QGraphicsItem *parent) CloseButton *button = new CloseButton(this); button->setPos(Settings::scaleWidth(442.0), Settings::scaleHeight(14.0)); } + +int TitleBar::loadImages() +{ + PixmapLoader::load("button_close"); + PixmapLoader::load("title_bar"); + return 2; +} diff --git a/weather/titlebar.h b/weather/titlebar.h index ab2c2ae..4636a77 100644 --- a/weather/titlebar.h +++ b/weather/titlebar.h @@ -33,13 +33,12 @@ #define TITLEBAR_H #include <QGraphicsPixmapItem> +#include "pixmapbutton.h" -class CloseButton: public QGraphicsPixmapItem +class CloseButton: public PixmapButton { public: CloseButton(QGraphicsItem *parent = 0); - QRectF boundingRect() const; - QPainterPath shape() const; protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); }; @@ -48,6 +47,7 @@ class TitleBar : public QGraphicsPixmapItem { public: TitleBar(QGraphicsItem *parent = 0); + static int loadImages(); }; #endif // TITLEBAR_H |