1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/***************************** LICENSE START ***********************************
Copyright 2012 ECMWF and INPE. This software is distributed under the terms
of the Apache License version 2.0. In applying this license, ECMWF does not
waive the privileges and immunities granted to it by virtue of its status as
an Intergovernmental Organization or submit itself to any jurisdiction.
***************************** LICENSE END *************************************/
#include <QDebug>
#include <QFile>
#include <QPainter>
#include "MvQProgressItem.h"
MvQProgressItem::MvQProgressItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{
font_= new QFont();
font_->setPointSize(26);
fontMetrics_= new QFontMetrics(*font_);
//fontPen_=QPen(Qt::white);
//fontBrush_=QBrush(Qt::white);
fontPen_=QPen();
fontBrush_=QBrush();
bgPen_=QPen(QColor(255,255,255,190));
bgBrush_=QBrush(QColor(120,120,120,190));
}
MvQProgressItem::~MvQProgressItem()
{
}
void MvQProgressItem::setRect(QRectF r)
{
if(rect_ != r)
{
rect_=r;
update();
}
}
QRectF MvQProgressItem::boundingRect() const
{
return rect_;
}
void MvQProgressItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->setPen(bgPen_);
painter->setBrush(bgBrush_);
painter->setRenderHint(QPainter::Antialiasing,true);
painter->drawRect(rect_);
//Render text
painter->translate(rect_.width()/2,rect_.height()/2);
painter->scale(1.,-1.);
painter->drawText(0,0,QObject::tr("Loading ..."));
}
|