StelGuiItems.cpp   StelGuiItems.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelUtils.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelMainView.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelActionMgr.hpp"
#include "StelProgressController.hpp"
#include <QPainter> #include <QPainter>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsLineItem> #include <QGraphicsLineItem>
#include <QRectF> #include <QRectF>
#include <QDebug> #include <QDebug>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGraphicsTextItem> #include <QGraphicsTextItem>
#include <QTimeLine> #include <QTimeLine>
#include <QMouseEvent> #include <QMouseEvent>
#include <QAction>
#include <QRegExp> #include <QRegExp>
#include <QPixmapCache> #include <QPixmapCache>
#include <QProgressBar> #include <QProgressBar>
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QGraphicsProxyWidget> #include <QGraphicsProxyWidget>
#include <QGraphicsLinearLayout> #include <QGraphicsLinearLayout>
#include <QSettings> #include <QSettings>
#ifdef _MSC_BUILD #ifdef _MSC_BUILD
#define round(dbl) dbl >= 0.0 ? (int)(dbl + 0.5) : ((dbl - (double)(int)dbl ) <= -0.5 ? (int)dbl : (int)(dbl - 0.5)) #define round(dbl) dbl >= 0.0 ? (int)(dbl + 0.5) : ((dbl - (double)(int)dbl ) <= -0.5 ? (int)dbl : (int)(dbl - 0.5))
#endif #endif
StelButton::StelButton(QGraphicsItem* parent, void StelButton::initCtor(const QPixmap& apixOn,
const QPixmap& apixOn, const QPixmap& apixOff,
const QPixmap& apixOff, const QPixmap& apixNoChange,
const QPixmap& apixHover, const QPixmap& apixHover,
QAction* aaction, StelAction* aaction,
bool noBackground) : bool noBackground,
QGraphicsPixmapItem(apixOff, parent), bool isTristate)
pixOn(apixOn), {
pixOff(apixOff), pixOn = apixOn;
pixHover(apixHover), pixOff = apixOff;
checked(ButtonStateOff), pixHover = apixHover;
action(aaction), pixNoChange = apixNoChange;
noBckground(noBackground), noBckground = noBackground;
isTristate_(false), isTristate_ = isTristate;
opacity(1.), opacity = 1.;
hoverOpacity(0.) hoverOpacity = 0.;
{ action = aaction;
checked = false;
Q_ASSERT(!pixOn.isNull()); Q_ASSERT(!pixOn.isNull());
Q_ASSERT(!pixOff.isNull()); Q_ASSERT(!pixOff.isNull());
redMode = StelApp::getInstance().getVisionModeNight(); if (isTristate_)
pixOnRed = StelButton::makeRed(pixOn); {
pixOffRed = StelButton::makeRed(pixOff); Q_ASSERT(!pixNoChange.isNull());
if (!pixHover.isNull()) }
pixHoverRed = StelButton::makeRed(pixHover);
if (!pixBackground.isNull())
pixBackgroundRed = StelButton::makeRed(pixBackground);
setShapeMode(QGraphicsPixmapItem::BoundingRectShape); setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
setAcceptsHoverEvents(true); setAcceptHoverEvents(true);
timeLine = new QTimeLine(250, this); timeLine = new QTimeLine(250, this);
timeLine->setCurveShape(QTimeLine::EaseOutCurve); timeLine->setCurveShape(QTimeLine::EaseOutCurve);
connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animValueC connect(timeLine, SIGNAL(valueChanged(qreal)),
hanged(qreal))); this, SLOT(animValueChanged(qreal)));
if (action!=NULL) if (action!=NULL)
{ {
QObject::connect(action, SIGNAL(toggled(bool)),
this, SLOT(setChecked(bool)));
if (action->isCheckable()) if (action->isCheckable())
{ {
setChecked(action->isChecked()); setChecked(action->isChecked());
QObject::connect(this, SIGNAL(toggled(bool)), connect(action, SIGNAL(toggled(bool)), this, SLOT(se
action, SLOT(setChecked(bool))); tChecked(bool)));
connect(this, SIGNAL(toggled(bool)), action, SLOT(se
tChecked(bool)));
} }
else else
{ {
QObject::connect(this, SIGNAL(triggered()), QObject::connect(this, SIGNAL(triggered()), action,
action, SLOT(trigger())); SLOT(trigger()));
} }
} }
} }
StelButton::StelButton(QGraphicsItem* parent, StelButton::StelButton(QGraphicsItem* parent,
const QPixmap& apixOn, const QPixmap& apixOn,
const QPixmap& apixOff, const QPixmap& apixOff,
const QPixmap& apixHover,
StelAction *aaction,
bool noBackground) :
QGraphicsPixmapItem(apixOff, parent)
{
initCtor(apixOn, apixOff, QPixmap(), apixHover, aaction, noBackgroun
d, false);
}
StelButton::StelButton(QGraphicsItem* parent,
const QPixmap& apixOn,
const QPixmap& apixOff,
const QPixmap& apixNoChange, const QPixmap& apixNoChange,
const QPixmap& apixHover, const QPixmap& apixHover,
QAction* aaction, const QString& aactionId,
bool noBackground, bool noBackground,
bool isTristate) : bool isTristate) :
QGraphicsPixmapItem(apixOff, parent), QGraphicsPixmapItem(apixOff, parent)
pixOn(apixOn),
pixOff(apixOff),
pixNoChange(apixNoChange),
pixHover(apixHover),
checked(ButtonStateOff),
action(aaction),
noBckground(noBackground),
isTristate_(isTristate),
opacity(1.),
hoverOpacity(0.)
{ {
Q_ASSERT(!pixOn.isNull()); StelAction *action = StelApp::getInstance().getStelActionManager()->
Q_ASSERT(!pixOff.isNull()); findAction(aactionId);
initCtor(apixOn, apixOff, apixNoChange, apixHover, action, noBackgro
redMode = StelApp::getInstance().getVisionModeNight(); und, isTristate);
pixOnRed = StelButton::makeRed(pixOn); }
pixOffRed = StelButton::makeRed(pixOff);
if (isTristate_)
{
Q_ASSERT(!pixNoChange.isNull());
pixNoChangeRed = StelButton::makeRed(pixNoChange);
}
if (!pixHover.isNull())
pixHoverRed = StelButton::makeRed(pixHover);
if (!pixBackground.isNull())
pixBackgroundRed = StelButton::makeRed(pixBackground);
setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
setAcceptsHoverEvents(true);
timeLine = new QTimeLine(250, this);
timeLine->setCurveShape(QTimeLine::EaseOutCurve);
connect(timeLine, SIGNAL(valueChanged(qreal)),
this, SLOT(animValueChanged(qreal)));
if (action!=NULL) StelButton::StelButton(QGraphicsItem* parent,
{ const QPixmap& apixOn,
QObject::connect(action, SIGNAL(toggled(bool)), const QPixmap& apixOff,
this, SLOT(setChecked(bool))); const QPixmap& apixHover,
if (action->isCheckable()) const QString& aactionId,
{ bool noBackground)
setChecked(action->isChecked()); :QGraphicsPixmapItem(apixOff, parent)
QObject::connect(this, SIGNAL(toggled(bool)), {
action, SLOT(setChecked(bool))); StelAction *action = StelApp::getInstance().getStelActionManager()->
} findAction(aactionId);
else initCtor(apixOn, apixOff, QPixmap(), apixHover, action, noBackground
{ , false);
QObject::connect(this, SIGNAL(triggered()),
action, SLOT(trigger()));
}
}
} }
int StelButton::toggleChecked(int checked) int StelButton::toggleChecked(int checked)
{ {
if (!isTristate_) if (!isTristate_)
checked = !!!checked; checked = !!!checked;
else else
{ {
if (++checked > ButtonStateNoChange) if (++checked > ButtonStateNoChange)
checked = ButtonStateOff; checked = ButtonStateOff;
skipping to change at line 217 skipping to change at line 193
void StelButton::updateIcon() void StelButton::updateIcon()
{ {
if (opacity < 0.) if (opacity < 0.)
opacity = 0; opacity = 0;
QPixmap pix(pixOn.size()); QPixmap pix(pixOn.size());
pix.fill(QColor(0,0,0,0)); pix.fill(QColor(0,0,0,0));
QPainter painter(&pix); QPainter painter(&pix);
painter.setOpacity(opacity); painter.setOpacity(opacity);
if (!pixBackground.isNull() && noBckground==false) if (!pixBackground.isNull() && noBckground==false)
painter.drawPixmap(0, 0, redMode ? pixBackgroundRed : pixBac kground); painter.drawPixmap(0, 0, pixBackground);
painter.drawPixmap(0, 0, painter.drawPixmap(0, 0,
(isTristate_ && checked == ButtonStateNoChange) ? (redMode ? (isTristate_ && checked == ButtonStateNoChange) ? (pixNoChan
pixNoChangeRed : pixNoChange) : ge) :
(checked == ButtonStateOn) ? (redMode ? pixOnRed : pixOn) : (checked == ButtonStateOn) ? (pixOn) :
/* (checked == ButtonStateOff) ? */ (redMode ? pixOffRed : p /* (checked == ButtonStateOff) ? */ (pixOff));
ixOff));
if (hoverOpacity > 0) if (hoverOpacity > 0)
{ {
painter.setOpacity(hoverOpacity * opacity); painter.setOpacity(hoverOpacity * opacity);
painter.drawPixmap(0, 0, redMode ? pixHoverRed : pixHover); painter.drawPixmap(0, 0, pixHover);
} }
setPixmap(pix); setPixmap(pix);
} }
void StelButton::animValueChanged(qreal value) void StelButton::animValueChanged(qreal value)
{ {
hoverOpacity = value; hoverOpacity = value;
updateIcon(); updateIcon();
} }
void StelButton::setChecked(int b) void StelButton::setChecked(int b)
{ {
checked=b; checked=b;
updateIcon(); updateIcon();
} }
void StelButton::setBackgroundPixmap(const QPixmap &newBackground) void StelButton::setBackgroundPixmap(const QPixmap &newBackground)
{ {
pixBackground = newBackground; pixBackground = newBackground;
pixBackgroundRed = makeRed(newBackground);
updateIcon(); updateIcon();
} }
QPixmap StelButton::makeRed(const QPixmap& p) LeftStelBar::LeftStelBar(QGraphicsItem* parent)
{ : QGraphicsItem(parent)
QImage im = p.toImage().convertToFormat(QImage::Format_ARGB32); , hideTimeLine(NULL)
Q_ASSERT(im.format()==QImage::Format_ARGB32);
QRgb* bits = (QRgb*)im.bits();
const QRgb* stop = bits+im.width()*im.height();
do
{
Vec3f col = StelUtils::getNightColor(Vec3f(qRed(*bits)/256.0
, qGreen(*bits)/256.0, qBlue(*bits)/256.0));
*bits = qRgba((int)(256*col[0]), (int)(256*col[1]), (int)(25
6*col[2]), qAlpha(*bits));
++bits;
}
while (bits!=stop);
return QPixmap::fromImage(im);
}
LeftStelBar::LeftStelBar(QGraphicsItem* parent) : QGraphicsItem(parent)
{ {
// Create the help label // Create the help label
helpLabel = new QGraphicsSimpleTextItem("", this); helpLabel = new QGraphicsSimpleTextItem("", this);
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::childItems().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., round(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)));
} }
skipping to change at line 305 skipping to change at line 265
QRectF LeftStelBar::boundingRect() const QRectF LeftStelBar::boundingRect() const
{ {
return childrenBoundingRect(); return childrenBoundingRect();
} }
QRectF LeftStelBar::boundingRectNoHelpLabel() const QRectF LeftStelBar::boundingRectNoHelpLabel() const
{ {
// Re-use original Qt code, just remove the help label // Re-use original Qt code, just remove the help label
QRectF childRect; QRectF childRect;
foreach (QGraphicsItem *child, QGraphicsItem::children()) foreach (QGraphicsItem *child, QGraphicsItem::childItems())
{ {
if (child==helpLabel) if (child==helpLabel)
continue; continue;
QPointF childPos = child->pos(); QPointF childPos = child->pos();
QTransform matrix = child->transform() * QTransform().transl ate(childPos.x(), childPos.y()); QTransform matrix = child->transform() * QTransform().transl ate(childPos.x(), childPos.y());
childRect |= matrix.mapRect(child->boundingRect() | child->c hildrenBoundingRect()); childRect |= matrix.mapRect(child->boundingRect() | child->c hildrenBoundingRect());
} }
return childRect; return childRect;
} }
// Update the help label when a button is hovered // Update the help label when a button is hovered
void LeftStelBar::buttonHoverChanged(bool b) void LeftStelBar::buttonHoverChanged(bool b)
{ {
StelButton* button = qobject_cast<StelButton*>(sender()); StelButton* button = qobject_cast<StelButton*>(sender());
Q_ASSERT(button); Q_ASSERT(button);
if (b==true) if (b==true)
{ {
if (button->action) if (button->action)
{ {
QString tip(button->action->toolTip()); QString tip(button->action->getText());
QString shortcut(button->action->shortcut().toString QString shortcut(button->action->getShortcut().toStr
()); ing(QKeySequence::NativeText));
if (!shortcut.isEmpty()) if (!shortcut.isEmpty())
{ {
//XXX: this should be unnecessary since we u sed NativeText.
if (shortcut == "Space") if (shortcut == "Space")
shortcut = q_("Space"); shortcut = q_("Space");
tip += " [" + shortcut + "]"; tip += " [" + shortcut + "]";
} }
helpLabel->setText(tip); helpLabel->setText(tip);
helpLabel->setPos(round(boundingRectNoHelpLabel().wi dth()+15.5),round(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("");
} }
// Update the screen as soon as possible.
StelMainView::getInstance().thereWasAnEvent();
} }
// 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)
{ {
helpLabel->setBrush(c); helpLabel->setBrush(c);
} }
// Activate red mode for the buttons, i.e. will reduce the non red color co
mponent of the icon
void LeftStelBar::setRedMode(bool b)
{
foreach (QGraphicsItem *child, QGraphicsItem::children())
{
StelButton* bt = qgraphicsitem_cast<StelButton*>(child);
if (bt==0)
continue;
bt->setRedMode(b);
}
}
BottomStelBar::BottomStelBar(QGraphicsItem* parent, BottomStelBar::BottomStelBar(QGraphicsItem* parent,
const QPixmap& pixLeft, const QPixmap& pixLeft,
const QPixmap& pixRight, const QPixmap& pixRight,
const QPixmap& pixMiddle, const QPixmap& pixMiddle,
const QPixmap& pixSingle) : const QPixmap& pixSingle) :
QGraphicsItem(parent), QGraphicsItem(parent),
pixBackgroundLeft(pixLeft), pixBackgroundLeft(pixLeft),
pixBackgroundRight(pixRight), pixBackgroundRight(pixRight),
pixBackgroundMiddle(pixMiddle), pixBackgroundMiddle(pixMiddle),
pixBackgroundSingle(pixSingle) pixBackgroundSingle(pixSingle)
skipping to change at line 431 skipping to change at line 382
} }
} }
if (done == false) if (done == false)
g.append(button); g.append(button);
button->setVisible(true); button->setVisible(true);
button->setParentItem(this); button->setParentItem(this);
updateButtonsGroups(); updateButtonsGroups();
connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverCh anged(bool))); connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverCh anged(bool)));
emit sizeChanged();
} }
StelButton* BottomStelBar::hideButton(const QString& actionName) StelButton* BottomStelBar::hideButton(const QString& actionName)
{ {
QString gName; QString gName;
StelButton* bToRemove = NULL; StelButton* bToRemove = NULL;
for (QMap<QString, ButtonGroup>::iterator iter=buttonGroups.begin(); iter!=buttonGroups.end();++iter) for (QMap<QString, ButtonGroup>::iterator iter=buttonGroups.begin(); iter!=buttonGroups.end();++iter)
{ {
int i=0; int i=0;
foreach (StelButton* b, iter.value().elems) foreach (StelButton* b, iter.value().elems)
skipping to change at line 463 skipping to change at line 415
return NULL; return NULL;
if (buttonGroups[gName].elems.size() == 0) if (buttonGroups[gName].elems.size() == 0)
{ {
buttonGroups.remove(gName); buttonGroups.remove(gName);
} }
// Cannot really delete because some part of the GUI depend on the p resence of some buttons // Cannot really delete because some part of the GUI depend on the p resence of some buttons
// so just make invisible // so just make invisible
bToRemove->setParentItem(NULL); bToRemove->setParentItem(NULL);
bToRemove->setVisible(false); bToRemove->setVisible(false);
updateButtonsGroups(); updateButtonsGroups();
emit sizeChanged();
return bToRemove; return bToRemove;
} }
// Set the margin at the left and right of a button group in pixels // Set the margin at the left and right of a button group in pixels
void BottomStelBar::setGroupMargin(const QString& groupName, int left, int right) void BottomStelBar::setGroupMargin(const QString& groupName, int left, int right)
{ {
if (!buttonGroups.contains(groupName)) if (!buttonGroups.contains(groupName))
return; return;
buttonGroups[groupName].leftMargin = left; buttonGroups[groupName].leftMargin = left;
buttonGroups[groupName].rightMargin = right; buttonGroups[groupName].rightMargin = right;
skipping to change at line 499 skipping to change at line 452
buttonGroups[groupName].pixBackgroundMiddle = new QPixmap(pixMiddle) ; buttonGroups[groupName].pixBackgroundMiddle = new QPixmap(pixMiddle) ;
buttonGroups[groupName].pixBackgroundSingle = new QPixmap(pixSingle) ; buttonGroups[groupName].pixBackgroundSingle = new QPixmap(pixSingle) ;
updateButtonsGroups(); updateButtonsGroups();
} }
QRectF BottomStelBar::getButtonsBoundingRect() const QRectF BottomStelBar::getButtonsBoundingRect() const
{ {
// Re-use original Qt code, just remove the help label // Re-use original Qt code, just remove the help label
QRectF childRect; QRectF childRect;
bool hasBtn = false; bool hasBtn = false;
foreach (QGraphicsItem *child, QGraphicsItem::children()) foreach (QGraphicsItem *child, QGraphicsItem::childItems())
{ {
if (qgraphicsitem_cast<StelButton*>(child)==0) if (qgraphicsitem_cast<StelButton*>(child)==0)
continue; continue;
hasBtn = true; hasBtn = true;
QPointF childPos = child->pos(); QPointF childPos = child->pos();
QTransform matrix = child->transform() * QTransform().transl ate(childPos.x(), childPos.y()); QTransform matrix = child->transform() * QTransform().transl ate(childPos.x(), childPos.y());
childRect |= matrix.mapRect(child->boundingRect() | child->c hildrenBoundingRect()); childRect |= matrix.mapRect(child->boundingRect() | child->c hildrenBoundingRect());
} }
if (hasBtn) if (hasBtn)
skipping to change at line 619 skipping to change at line 572
if (std::abs(deltaT)>60.) if (std::abs(deltaT)>60.)
datetime->setToolTip(QString("%1T = %2 (%3s) %6 [n-dot @ -23.8946\"/cy%4%5]").arg(QChar(0x0394)).arg(StelUtils::hoursToH msStr(deltaT/3600.)).arg(deltaT, 5, 'f', 2).arg(QChar(0x00B2)).arg(sigmaInf o).arg(validRangeInfo)); datetime->setToolTip(QString("%1T = %2 (%3s) %6 [n-dot @ -23.8946\"/cy%4%5]").arg(QChar(0x0394)).arg(StelUtils::hoursToH msStr(deltaT/3600.)).arg(deltaT, 5, 'f', 2).arg(QChar(0x00B2)).arg(sigmaInf o).arg(validRangeInfo));
else else
datetime->setToolTip(QString("%1T = %2s%5 [n -dot @ -23.8946\"/cy%3%4]").arg(QChar(0x0394)).arg(deltaT, 3, 'f', 3).arg(Q Char(0x00B2)).arg(sigmaInfo).arg(validRangeInfo)); datetime->setToolTip(QString("%1T = %2s%5 [n -dot @ -23.8946\"/cy%3%4]").arg(QChar(0x0394)).arg(deltaT, 3, 'f', 3).arg(Q Char(0x00B2)).arg(sigmaInfo).arg(validRangeInfo));
} }
else else
datetime->setToolTip(""); datetime->setToolTip("");
} }
QString newLocation = flagShowLocation ? q_(core->getCurrentLocation QString newLocation = "";
().planetName) +", " const StelLocation* loc = &core->getCurrentLocation();
+core->getCurrentLocation().name + ", " if (flagShowLocation && !loc->name.isEmpty())
// xgettext:no-c-format {
+q_("%1m").arg(core->getCurrentLocation().altitude) newLocation = q_(loc->planetName) +", "+loc->name + ", "+q_(
: " "; "%1m").arg(loc->altitude);
}
if (flagShowLocation && loc->name.isEmpty())
{
newLocation = q_(loc->planetName)+", "
+StelUtils::radToDmsStr(loc->latitude)+", "
+StelUtils::radToDmsStr(loc->longitude);
}
if (location->text()!=newLocation) if (location->text()!=newLocation)
{ {
updatePos = true; updatePos = true;
location->setText(newLocation); location->setText(newLocation);
float lat = core->getCurrentLocation().latitude; float lat = core->getCurrentLocation().latitude;
float lon = core->getCurrentLocation().longitude; float lon = core->getCurrentLocation().longitude;
QString latStr, lonStr, pm; QString latStr, lonStr, pm;
if (lat >= 0) if (lat >= 0)
pm = "N"; pm = "N";
else else
skipping to change at line 653 skipping to change at line 614
QSettings* confSettings = StelApp::getInstance().getSettings(); QSettings* confSettings = StelApp::getInstance().getSettings();
QString str; QString str;
QTextStream wos(&str); QTextStream wos(&str);
wos << "FOV " << qSetRealNumberPrecision(3) << core->getMovementMgr( )->getCurrentFov() << QChar(0x00B0); wos << "FOV " << qSetRealNumberPrecision(3) << core->getMovementMgr( )->getCurrentFov() << QChar(0x00B0);
if (fov->text()!=str) if (fov->text()!=str)
{ {
updatePos = true; updatePos = true;
if (confSettings->value("gui/flag_show_fov", true).toBool()) if (confSettings->value("gui/flag_show_fov", true).toBool())
{ {
fov->setText(str); fov->setText(str);
fov->setToolTip(q_("Field of view"));
} }
else else
{ {
fov->setText(""); fov->setText("");
fov->setToolTip("");
} }
} }
str=""; str="";
QTextStream wos2(&str); QTextStream wos2(&str);
wos2 << qSetRealNumberPrecision(3) << StelApp::getInstance().getFps( ) << " FPS"; wos2 << qSetRealNumberPrecision(3) << StelApp::getInstance().getFps( ) << " FPS";
if (fps->text()!=str) if (fps->text()!=str)
{ {
updatePos = true; updatePos = true;
if (confSettings->value("gui/flag_show_fps", true).toBool()) if (confSettings->value("gui/flag_show_fps", true).toBool())
{ {
fps->setText(str); fps->setText(str);
fps->setToolTip(q_("Frames per second"));
} }
else else
{ {
fps->setText(""); fps->setText("");
fps->setToolTip("");
} }
} }
if (updatePos) if (updatePos)
{ {
QRectF rectCh = getButtonsBoundingRect(); QRectF rectCh = getButtonsBoundingRect();
location->setPos(0, 0); location->setPos(0, 0);
int dtp = rectCh.right()-datetime->boundingRect().width()-5; int dtp = rectCh.right()-datetime->boundingRect().width()-5;
if ((dtp%2) == 1) dtp--; // make even pixel if ((dtp%2) == 1) dtp--; // make even pixel
datetime->setPos(dtp,0); datetime->setPos(dtp,0);
skipping to change at line 695 skipping to change at line 660
} }
} }
void BottomStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidg et*) 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::childItems().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);
} }
QRectF BottomStelBar::boundingRectNoHelpLabel() const QRectF BottomStelBar::boundingRectNoHelpLabel() const
{ {
// Re-use original Qt code, just remove the help label // Re-use original Qt code, just remove the help label
QRectF childRect; QRectF childRect;
foreach (QGraphicsItem *child, QGraphicsItem::children()) foreach (QGraphicsItem *child, QGraphicsItem::childItems())
{ {
if (child==helpLabel) if (child==helpLabel)
continue; continue;
QPointF childPos = child->pos(); QPointF childPos = child->pos();
QTransform matrix = child->transform() * QTransform().transl ate(childPos.x(), childPos.y()); QTransform matrix = child->transform() * QTransform().transl ate(childPos.x(), childPos.y());
childRect |= matrix.mapRect(child->boundingRect() | child->c hildrenBoundingRect()); childRect |= matrix.mapRect(child->boundingRect() | child->c hildrenBoundingRect());
} }
return childRect; return childRect;
} }
// Set the pen for all the sub elements // Set the pen for all the sub elements
void BottomStelBar::setColor(const QColor& c) void BottomStelBar::setColor(const QColor& c)
{ {
datetime->setBrush(c); datetime->setBrush(c);
location->setBrush(c); location->setBrush(c);
fov->setBrush(c); fov->setBrush(c);
fps->setBrush(c); fps->setBrush(c);
helpLabel->setBrush(c); helpLabel->setBrush(c);
} }
// Activate red mode for the buttons, i.e. will reduce the non red color co
mponent of the icon
void BottomStelBar::setRedMode(bool b)
{
foreach (QGraphicsItem *child, QGraphicsItem::children())
{
StelButton* bt = qgraphicsitem_cast<StelButton*>(child);
if (bt==0)
continue;
bt->setRedMode(b);
}
}
// Update the help label when a button is hovered // Update the help label when a button is hovered
void BottomStelBar::buttonHoverChanged(bool b) void BottomStelBar::buttonHoverChanged(bool b)
{ {
StelButton* button = qobject_cast<StelButton*>(sender()); StelButton* button = qobject_cast<StelButton*>(sender());
Q_ASSERT(button); Q_ASSERT(button);
if (b==true) if (b==true)
{ {
QAction* action = button->action; StelAction* action = button->action;
if (action) if (action)
{ {
QString tip(action->toolTip()); QString tip(action->getText());
QString shortcut(action->shortcut().toString(QKeySeq QString shortcut(action->getShortcut().toString(QKey
uence::NativeText)); Sequence::NativeText));
if (!shortcut.isEmpty()) if (!shortcut.isEmpty())
{ {
//XXX: this should be unnecessary since we u sed NativeText.
if (shortcut == "Space") if (shortcut == "Space")
shortcut = q_("Space"); shortcut = q_("Space");
tip += " [" + shortcut + "]"; tip += " [" + shortcut + "]";
} }
helpLabel->setText(tip); helpLabel->setText(tip);
//helpLabel->setPos(button->pos().x()+button->pixmap ().size().width()/2,-27); //helpLabel->setPos(button->pos().x()+button->pixmap ().size().width()/2,-27);
helpLabel->setPos(20,-27); helpLabel->setPos(20,-27);
} }
} }
else else
{ {
helpLabel->setText(""); helpLabel->setText("");
} }
// Update the screen as soon as possible.
StelMainView::getInstance().thereWasAnEvent();
} }
StelBarsPath::StelBarsPath(QGraphicsItem* parent) : QGraphicsPathItem(paren t) StelBarsPath::StelBarsPath(QGraphicsItem* parent) : QGraphicsPathItem(paren t)
{ {
roundSize = 6; roundSize = 6;
QPen aPen(QColor::fromRgbF(0.7,0.7,0.7,0.5)); QPen aPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
aPen.setWidthF(1.); aPen.setWidthF(1.);
setBrush(QBrush(QColor::fromRgbF(0.22, 0.22, 0.23, 0.2))); setBrush(QBrush(QColor::fromRgbF(0.22, 0.22, 0.23, 0.2)));
setPen(aPen); setPen(aPen);
} }
skipping to change at line 813 skipping to change at line 769
} }
/* /*
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);
}*/ }*/
QProgressBar* StelProgressBarMgr::addProgressBar() void StelProgressBarMgr::addProgressBar(const StelProgressController* p)
{ {
QProgressBar* pb = new QProgressBar(); QProgressBar* pb = new QProgressBar();
pb->setFixedHeight(25); pb->setFixedHeight(25);
pb->setFixedWidth(200); pb->setFixedWidth(200);
pb->setTextVisible(true); pb->setTextVisible(true);
pb->setValue(66); pb->setValue(p->getValue());
pb->setMinimum(p->getMin());
pb->setMaximum(p->getMax());
pb->setFormat(p->getFormat());
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; allBars.insert(p, pb);
pb->setVisible(true);
connect(p, SIGNAL(changed()), this, SLOT(oneBarChanged()));
}
void StelProgressBarMgr::removeProgressBar(const StelProgressController *p)
{
QProgressBar* pb = allBars[p];
pb->deleteLater();
allBars.remove(p);
}
void StelProgressBarMgr::oneBarChanged()
{
const StelProgressController *p = static_cast<StelProgressController
*>(QObject::sender());
QProgressBar* pb = allBars[p];
pb->setValue(p->getValue());
pb->setMinimum(p->getMin());
pb->setMaximum(p->getMax());
pb->setFormat(p->getFormat());
} }
CornerButtons::CornerButtons(QGraphicsItem*) : lastOpacity(10) CornerButtons::CornerButtons(QGraphicsItem*) : lastOpacity(10)
{ {
} }
void CornerButtons::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidg et*) 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::childItems().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);
} }
void CornerButtons::setOpacity(double opacity) void CornerButtons::setOpacity(double opacity)
{ {
if (opacity<=0. && lastOpacity<=0.) if (opacity<=0. && lastOpacity<=0.)
return; return;
lastOpacity = opacity; lastOpacity = opacity;
if (QGraphicsItem::children().size()==0) if (QGraphicsItem::childItems().size()==0)
return; return;
foreach (QGraphicsItem *child, QGraphicsItem::children()) foreach (QGraphicsItem *child, QGraphicsItem::childItems())
{ {
StelButton* sb = qgraphicsitem_cast<StelButton*>(child); StelButton* sb = qgraphicsitem_cast<StelButton*>(child);
Q_ASSERT(sb!=NULL); Q_ASSERT(sb!=NULL);
sb->setOpacity(opacity); sb->setOpacity(opacity);
} }
} }
 End of changes. 48 change blocks. 
162 lines changed or deleted 143 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/