StelGuiItems.cpp   StelGuiItems.cpp 
skipping to change at line 51 skipping to change at line 51
#include <QPixmapCache> #include <QPixmapCache>
#include <QProgressBar> #include <QProgressBar>
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QGraphicsProxyWidget> #include <QGraphicsProxyWidget>
#include <QGraphicsLinearLayout> #include <QGraphicsLinearLayout>
StelButton::StelButton(QGraphicsItem* parent, const QPixmap& apixOn, const QPixmap& apixOff, StelButton::StelButton(QGraphicsItem* parent, const QPixmap& apixOn, const QPixmap& apixOff,
const QPixmap& apixHover, QAction* aaction, bool noBackgroun d) : const QPixmap& apixHover, QAction* aaction, bool noBackgroun d) :
QGraphicsPixmapItem(apixOff, parent), pixOn(apixOn), pixOff(apixOff), pixHover(apixHover), QGraphicsPixmapItem(apixOff, parent), pixOn(apixOn), pixOff(apixOff), pixHover(apixHover),
checked(ButtonStateOff), action(aaction), noBckgroun d(noBackground), isTristate_(false), checked(ButtonStateOff), action(aaction), noBckgroun d(noBackground), isTristate_(false),
opacity(1.), hoverOpacity(0.), redMode(false) opacity(1.), hoverOpacity(0.)
{ {
Q_ASSERT(!pixOn.isNull()); Q_ASSERT(!pixOn.isNull());
Q_ASSERT(!pixOff.isNull()); Q_ASSERT(!pixOff.isNull());
redMode = StelApp::getInstance().getVisionModeNight();
pixOnRed = StelButton::makeRed(pixOn); pixOnRed = StelButton::makeRed(pixOn);
pixOffRed = StelButton::makeRed(pixOff); pixOffRed = StelButton::makeRed(pixOff);
if (!pixHover.isNull()) if (!pixHover.isNull())
pixHoverRed = StelButton::makeRed(pixHover); pixHoverRed = StelButton::makeRed(pixHover);
if (!pixBackground.isNull()) if (!pixBackground.isNull())
pixBackgroundRed = StelButton::makeRed(pixBackground); pixBackgroundRed = StelButton::makeRed(pixBackground);
setShapeMode(QGraphicsPixmapItem::BoundingRectShape); setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
setAcceptsHoverEvents(true); setAcceptsHoverEvents(true);
timeLine = new QTimeLine(250, this); timeLine = new QTimeLine(250, this);
skipping to change at line 88 skipping to change at line 89
{ {
QObject::connect(this, SIGNAL(triggered()), action, SLOT(trigger())); QObject::connect(this, SIGNAL(triggered()), action, SLOT(trigger()));
} }
} }
} }
StelButton::StelButton(QGraphicsItem* parent, const QPixmap& apixOn, const QPixmap& apixOff, const QPixmap& apixNoChange, StelButton::StelButton(QGraphicsItem* parent, const QPixmap& apixOn, const QPixmap& apixOff, const QPixmap& apixNoChange,
const QPixmap& apixHover, QAction* aaction, bool noBackgroun d, bool isTristate) : const QPixmap& apixHover, QAction* aaction, bool noBackgroun d, bool isTristate) :
QGraphicsPixmapItem(apixOff, parent), pixOn(apixOn), pixOff(apixOff), pixNoChange(apixNoChange), pixHover(apixHover), QGraphicsPixmapItem(apixOff, parent), pixOn(apixOn), pixOff(apixOff), pixNoChange(apixNoChange), pixHover(apixHover),
checked(ButtonStateOff), action(aaction), noBckgroun d(noBackground), isTristate_(isTristate), checked(ButtonStateOff), action(aaction), noBckgroun d(noBackground), isTristate_(isTristate),
opacity(1.), hoverOpacity(0.), redMode(false) opacity(1.), hoverOpacity(0.)
{ {
Q_ASSERT(!pixOn.isNull()); Q_ASSERT(!pixOn.isNull());
Q_ASSERT(!pixOff.isNull()); Q_ASSERT(!pixOff.isNull());
redMode = StelApp::getInstance().getVisionModeNight();
pixOnRed = StelButton::makeRed(pixOn); pixOnRed = StelButton::makeRed(pixOn);
pixOffRed = StelButton::makeRed(pixOff); pixOffRed = StelButton::makeRed(pixOff);
if (isTristate_) { if (isTristate_) {
Q_ASSERT(!pixNoChange.isNull()); Q_ASSERT(!pixNoChange.isNull());
pixNoChangeRed = StelButton::makeRed(pixNoChange); pixNoChangeRed = StelButton::makeRed(pixNoChange);
} }
if (!pixHover.isNull()) if (!pixHover.isNull())
pixHoverRed = StelButton::makeRed(pixHover); pixHoverRed = StelButton::makeRed(pixHover);
if (!pixBackground.isNull()) if (!pixBackground.isNull())
pixBackgroundRed = StelButton::makeRed(pixBackground); pixBackgroundRed = StelButton::makeRed(pixBackground);
skipping to change at line 143 skipping to change at line 145
} }
void StelButton::mousePressEvent(QGraphicsSceneMouseEvent* event) void StelButton::mousePressEvent(QGraphicsSceneMouseEvent* event)
{ {
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
event->accept(); event->accept();
setChecked(toggleChecked(checked)); setChecked(toggleChecked(checked));
emit(toggled(checked)); emit(toggled(checked));
emit(triggered()); emit(triggered());
} }
void StelButton::hoverEnterEvent(QGraphicsSceneHoverEvent* event) void StelButton::hoverEnterEvent(QGraphicsSceneHoverEvent*)
{ {
timeLine->setDirection(QTimeLine::Forward); timeLine->setDirection(QTimeLine::Forward);
if (timeLine->state()!=QTimeLine::Running) if (timeLine->state()!=QTimeLine::Running)
timeLine->start(); timeLine->start();
emit(hoverChanged(true)); emit(hoverChanged(true));
} }
void StelButton::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) void StelButton::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
{ {
timeLine->setDirection(QTimeLine::Backward); timeLine->setDirection(QTimeLine::Backward);
if (timeLine->state()!=QTimeLine::Running) if (timeLine->state()!=QTimeLine::Running)
timeLine->start(); timeLine->start();
emit(hoverChanged(false)); emit(hoverChanged(false));
} }
void StelButton::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) void StelButton::mouseReleaseEvent(QGraphicsSceneMouseEvent*)
{ {
if (action!=NULL && !action->isCheckable()) if (action!=NULL && !action->isCheckable())
setChecked(toggleChecked(checked)); setChecked(toggleChecked(checked));
} }
void StelButton::updateIcon() void StelButton::updateIcon()
{ {
if (opacity<0.) if (opacity<0.)
opacity=0; opacity=0;
QPixmap pix(pixOn.size()); QPixmap pix(pixOn.size());
skipping to change at line 220 skipping to change at line 222
} }
while (bits!=stop); while (bits!=stop);
return QPixmap::fromImage(im); return QPixmap::fromImage(im);
} }
LeftStelBar::LeftStelBar(QGraphicsItem* parent) : QGraphicsItem(parent) LeftStelBar::LeftStelBar(QGraphicsItem* parent) : QGraphicsItem(parent)
{ {
// Create the help label // Create the help label
helpLabel = new QGraphicsSimpleTextItem("", this); helpLabel = new QGraphicsSimpleTextItem("", this);
QFont font("DejaVuSans");
font.setPixelSize(13);
helpLabel->setFont(font);
helpLabel->setBrush(QBrush(QColor::fromRgbF(1,1,1,1))); helpLabel->setBrush(QBrush(QColor::fromRgbF(1,1,1,1)));
} }
LeftStelBar::~LeftStelBar() LeftStelBar::~LeftStelBar()
{ {
} }
void LeftStelBar::addButton(StelButton* button) void LeftStelBar::addButton(StelButton* button)
{ {
double posY = 0; double posY = 0;
if (QGraphicsItem::children().size()!=0) if (QGraphicsItem::children().size()!=0)
{ {
const QRectF& r = childrenBoundingRect(); const QRectF& r = childrenBoundingRect();
posY += r.bottom()-1; posY += r.bottom()-1;
} }
button->setParentItem(this); button->setParentItem(this);
button->prepareGeometryChange(); // could possibly be removed when q t 4.6 become stable button->prepareGeometryChange(); // could possibly be removed when q t 4.6 become stable
button->setPos(0.5, posY+10.5); button->setPos(0., round(posY+10.5));
connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverCh anged(bool))); connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverCh anged(bool)));
} }
void LeftStelBar::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void LeftStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget *)
{ {
} }
QRectF LeftStelBar::boundingRect() const QRectF LeftStelBar::boundingRect() const
{ {
return childrenBoundingRect(); return childrenBoundingRect();
} }
QRectF LeftStelBar::boundingRectNoHelpLabel() const QRectF LeftStelBar::boundingRectNoHelpLabel() const
{ {
skipping to change at line 287 skipping to change at line 286
{ {
QString tip(button->action->toolTip()); QString tip(button->action->toolTip());
QString shortcut(button->action->shortcut().toString ()); QString shortcut(button->action->shortcut().toString ());
if (!shortcut.isEmpty()) if (!shortcut.isEmpty())
{ {
if (shortcut == "Space") if (shortcut == "Space")
shortcut = q_("Space"); shortcut = q_("Space");
tip += " [" + shortcut + "]"; tip += " [" + shortcut + "]";
} }
helpLabel->setText(tip); helpLabel->setText(tip);
helpLabel->setPos(boundingRectNoHelpLabel().width()+ 15.5,button->pos().y()+button->pixmap().size().height()/2-8); helpLabel->setPos(round(boundingRectNoHelpLabel().wi dth()+15.5),round(button->pos().y()+button->pixmap().size().height()/2-8));
} }
} }
else else
{ {
helpLabel->setText(""); helpLabel->setText("");
} }
} }
// Set the pen for all the sub elements // Set the pen for all the sub elements
void LeftStelBar::setColor(const QColor& c) void LeftStelBar::setColor(const QColor& c)
skipping to change at line 318 skipping to change at line 317
if (bt==0) if (bt==0)
continue; continue;
bt->setRedMode(b); bt->setRedMode(b);
} }
} }
BottomStelBar::BottomStelBar(QGraphicsItem* parent, const QPixmap& pixLeft, const QPixmap& pixRight, BottomStelBar::BottomStelBar(QGraphicsItem* parent, const QPixmap& pixLeft, const QPixmap& pixRight,
const QPixmap& pixMiddle, const QPixmap& pixSingle) : QGraph icsItem(parent), pixBackgroundLeft(pixLeft), pixBackgroundRight(pixRight), const QPixmap& pixMiddle, const QPixmap& pixSingle) : QGraph icsItem(parent), pixBackgroundLeft(pixLeft), pixBackgroundRight(pixRight),
pixBackgroundMiddle(pixMiddle), pixBackgroundSingle(pixSingl e) pixBackgroundMiddle(pixMiddle), pixBackgroundSingle(pixSingl e)
{ {
QFont font("DejaVuSans");
font.setPixelSize(12);
// The text is dummy just for testing // The text is dummy just for testing
datetime = new QGraphicsSimpleTextItem("2008-02-06 17:33", this); datetime = new QGraphicsSimpleTextItem("2008-02-06 17:33", this);
location = new QGraphicsSimpleTextItem("Munich, Earth, 500m", this); location = new QGraphicsSimpleTextItem("Munich, Earth, 500m", this);
fov = new QGraphicsSimpleTextItem("FOV 43.45", this); fov = new QGraphicsSimpleTextItem("FOV 43.45", this);
fps = new QGraphicsSimpleTextItem("43.2 FPS", this); fps = new QGraphicsSimpleTextItem("43.2 FPS", this);
// Create the help label // Create the help label
helpLabel = new QGraphicsSimpleTextItem("", this); helpLabel = new QGraphicsSimpleTextItem("", this);
QFont font2("DejaVuSans");
font2.setPixelSize(13);
helpLabel->setFont(font2);
helpLabel->setBrush(QBrush(QColor::fromRgbF(1,1,1,1))); helpLabel->setBrush(QBrush(QColor::fromRgbF(1,1,1,1)));
QColor color = QColor::fromRgbF(1,1,1,1); QColor color = QColor::fromRgbF(1,1,1,1);
setColor(color); setColor(color);
datetime->setFont(font); datetime->font().setPixelSize(12);
location->setFont(font); location->font().setPixelSize(12);
fov->setFont(font); fov->font().setPixelSize(12);
fps->setFont(font); fps->font().setPixelSize(12);
flagShowTime = true; flagShowTime = true;
flagShowLocation = true; flagShowLocation = true;
} }
BottomStelBar::~BottomStelBar() BottomStelBar::~BottomStelBar()
{ {
// Remove currently hidden buttons which are not delete by a parent element // Remove currently hidden buttons which are not delete by a parent element
for (QMap<QString, ButtonGroup>::iterator iter=buttonGroups.begin(); iter!=buttonGroups.end();++iter) for (QMap<QString, ButtonGroup>::iterator iter=buttonGroups.begin(); iter!=buttonGroups.end();++iter)
{ {
skipping to change at line 580 skipping to change at line 573
if (updatePos) if (updatePos)
{ {
QRectF rectCh = getButtonsBoundingRect(); QRectF rectCh = getButtonsBoundingRect();
location->setPos(0, 0); location->setPos(0, 0);
datetime->setPos(rectCh.right()-datetime->boundingRect().wid th()-5,0); datetime->setPos(rectCh.right()-datetime->boundingRect().wid th()-5,0);
fov->setPos(datetime->x()-230, 0); fov->setPos(datetime->x()-230, 0);
fps->setPos(datetime->x()-140, 0); fps->setPos(datetime->x()-140, 0);
} }
} }
void BottomStelBar::paint(QPainter* painter, const QStyleOptionGraphicsItem * option, QWidget* widget) void BottomStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidg et*)
{ {
updateText(); updateText();
} }
QRectF BottomStelBar::boundingRect() const QRectF BottomStelBar::boundingRect() const
{ {
if (QGraphicsItem::children().size()==0) if (QGraphicsItem::children().size()==0)
return QRectF(); return QRectF();
const QRectF& r = childrenBoundingRect(); const QRectF& r = childrenBoundingRect();
return QRectF(0, 0, r.width()-1, r.height()-1); return QRectF(0, 0, r.width()-1, r.height()-1);
skipping to change at line 691 skipping to change at line 684
newPath.lineTo(p2.x()+r2.width()+roundSize, p2.y()+r2.height()+round Size); newPath.lineTo(p2.x()+r2.width()+roundSize, p2.y()+r2.height()+round Size);
newPath.lineTo(p.x()-roundSize, p2.y()+r2.height()+roundSize); newPath.lineTo(p.x()-roundSize, p2.y()+r2.height()+roundSize);
setPath(newPath); setPath(newPath);
} }
void StelBarsPath::setBackgroundOpacity(double opacity) void StelBarsPath::setBackgroundOpacity(double opacity)
{ {
setBrush(QBrush(QColor::fromRgbF(0.22, 0.22, 0.23, opacity))); setBrush(QBrush(QColor::fromRgbF(0.22, 0.22, 0.23, opacity)));
} }
StelProgressBarMgr::StelProgressBarMgr(QGraphicsItem* parent) StelProgressBarMgr::StelProgressBarMgr(QGraphicsItem*)
{ {
setLayout(new QGraphicsLinearLayout(Qt::Vertical)); setLayout(new QGraphicsLinearLayout(Qt::Vertical));
} }
/* /*
QRectF StelProgressBarMgr::boundingRect() const QRectF StelProgressBarMgr::boundingRect() const
{ {
if (QGraphicsItem::children().size()==0) if (QGraphicsItem::children().size()==0)
return QRectF(); return QRectF();
const QRectF& r = childrenBoundingRect(); const QRectF& r = childrenBoundingRect();
return QRectF(0, 0, r.width()-1, r.height()-1); return QRectF(0, 0, r.width()-1, r.height()-1);
skipping to change at line 719 skipping to change at line 712
pb->setTextVisible(true); pb->setTextVisible(true);
pb->setValue(66); pb->setValue(66);
QGraphicsProxyWidget* pbProxy = new QGraphicsProxyWidget(); QGraphicsProxyWidget* pbProxy = new QGraphicsProxyWidget();
pbProxy->setWidget(pb); pbProxy->setWidget(pb);
pbProxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); pbProxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
pbProxy->setZValue(150); pbProxy->setZValue(150);
static_cast<QGraphicsLinearLayout*>(layout())->addItem(pbProxy); static_cast<QGraphicsLinearLayout*>(layout())->addItem(pbProxy);
return pb; return pb;
} }
CornerButtons::CornerButtons(QGraphicsItem* parent) : lastOpacity(10) CornerButtons::CornerButtons(QGraphicsItem*) : lastOpacity(10)
{ {
} }
void CornerButtons::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void CornerButtons::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidg et*)
{ {
// Do nothing. Just paint the child widgets // Do nothing. Just paint the child widgets
} }
QRectF CornerButtons::boundingRect() const QRectF CornerButtons::boundingRect() const
{ {
if (QGraphicsItem::children().size()==0) if (QGraphicsItem::children().size()==0)
return QRectF(); return QRectF();
const QRectF& r = childrenBoundingRect(); const QRectF& r = childrenBoundingRect();
return QRectF(0, 0, r.width()-1, r.height()-1); return QRectF(0, 0, r.width()-1, r.height()-1);
 End of changes. 18 change blocks. 
25 lines changed or deleted 18 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/