SkyGui.cpp   SkyGui.cpp 
skipping to change at line 26 skipping to change at line 26
* 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 "SkyGui.hpp" #include "SkyGui.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelMainView.hpp"
#include <QGraphicsView> #include <QGraphicsView>
#include <QDebug> #include <QDebug>
#include <QTimeLine> #include <QTimeLine>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QSettings> #include <QSettings>
#include <QTextDocument> #include <QTextDocument>
#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
skipping to change at line 79 skipping to change at line 80
if (conf->value("flag_show_radecofdate", false).toBool()) if (conf->value("flag_show_radecofdate", false).toBool())
infoTextFilters |= StelObject::RaDecOfDate; infoTextFilters |= StelObject::RaDecOfDate;
if (conf->value("flag_show_hourangle", false).toBool()) if (conf->value("flag_show_hourangle", false).toBool())
infoTextFilters |= StelObject::HourAngle; infoTextFilters |= StelObject::HourAngle;
if (conf->value("flag_show_altaz", false).toBool()) if (conf->value("flag_show_altaz", false).toBool())
infoTextFilters |= StelObject::AltAzi; infoTextFilters |= StelObject::AltAzi;
if (conf->value("flag_show_distance", false).toBool()) if (conf->value("flag_show_distance", false).toBool())
infoTextFilters |= StelObject::Distance; infoTextFilters |= StelObject::Distance;
if (conf->value("flag_show_size", false).toBool()) if (conf->value("flag_show_size", false).toBool())
infoTextFilters |= StelObject::Size; infoTextFilters |= StelObject::Size;
if (conf->value("flag_show_extra1", false).toBool()) if (conf->value("flag_show_extra", false).toBool())
infoTextFilters |= StelObject::Extra1; infoTextFilters |= StelObject::Extra;
if (conf->value("flag_show_extra2", false).toBool()) if (conf->value("flag_show_type", false).toBool())
infoTextFilters |= StelObject::Extra2; infoTextFilters |= StelObject::ObjectType;
if (conf->value("flag_show_extra3", false).toBool()) if (conf->value("flag_show_galcoord", false).toBool())
infoTextFilters |= StelObject::Extra3; infoTextFilters |= StelObject::GalacticCoord;
if (conf->value("flag_show_eclcoord", false).toBool())
infoTextFilters |= StelObject::EclTopocentricCoord;
conf->endGroup(); conf->endGroup();
} }
else else
{ {
qWarning() << "config.ini option gui/selected_object_info is invalid, using \"all\""; qWarning() << "config.ini option gui/selected_object_info is invalid, using \"all\"";
infoTextFilters = StelObject::InfoStringGroup(StelObject::Al lInfo); infoTextFilters = StelObject::InfoStringGroup(StelObject::Al lInfo);
} }
} }
void InfoPanel::setTextFromObjects(const QList<StelObjectP>& selected) void InfoPanel::setTextFromObjects(const QList<StelObjectP>& selected)
skipping to change at line 114 skipping to change at line 117
QString s = selected[0]->getInfoString(StelApp::getInstance( ).getCore(), infoTextFilters); QString s = selected[0]->getInfoString(StelApp::getInstance( ).getCore(), infoTextFilters);
setHtml(s); setHtml(s);
} }
} }
const QString InfoPanel::getSelectedText(void) const QString InfoPanel::getSelectedText(void)
{ {
return toPlainText(); return toPlainText();
} }
SkyGui::SkyGui(QGraphicsItem * parent): QGraphicsWidget(parent), stelGui(NU SkyGui::SkyGui(QGraphicsItem * parent)
LL) : QGraphicsWidget(parent)
, btHorizAutoHide(NULL)
, btVertAutoHide(NULL)
, stelGui(NULL)
{ {
setObjectName("StelSkyGui"); setObjectName("StelSkyGui");
// Construct the Windows buttons bar // Construct the Windows buttons bar
winBar = new LeftStelBar(this); winBar = new LeftStelBar(this);
// Construct the bottom buttons bar // Construct the bottom buttons bar
buttonBar = new BottomStelBar(this, QPixmap(":/graphicGui/btbg-left. png"), QPixmap(":/graphicGui/btbg-right.png"), buttonBar = new BottomStelBar(this, QPixmap(":/graphicGui/btbg-left. png"), QPixmap(":/graphicGui/btbg-right.png"),
QPixmap(":/graphicGui/b tbg-middle.png"), QPixmap(":/graphicGui/btbg-single.png")); QPixmap(":/graphicGui/b tbg-middle.png"), QPixmap(":/graphicGui/btbg-single.png"));
infoPanel = new InfoPanel(this); infoPanel = new InfoPanel(this);
// Used to display some progress bar in the lower right corner, e.g. when loading a file // Used to display some progress bar in the lower right corner, e.g. when loading a file
progressBarMgr = new StelProgressBarMgr(this); progressBarMgr = new StelProgressBarMgr(this);
connect(&StelApp::getInstance(), SIGNAL(progressBarAdded(const StelP
rogressController*)), progressBarMgr, SLOT(addProgressBar(const StelProgres
sController*)));
connect(&StelApp::getInstance(), SIGNAL(progressBarRemoved(const Ste
lProgressController*)), progressBarMgr, SLOT(removeProgressBar(const StelPr
ogressController*)));
// The path drawn around the button bars // The path drawn around the button bars
buttonBarPath = new StelBarsPath(this); buttonBarPath = new StelBarsPath(this);
lastButtonbarWidth = 0; lastButtonbarWidth = 0;
autoHidebts = NULL; autoHidebts = NULL;
autoHideHorizontalButtonBar = true; autoHideHorizontalButtonBar = true;
autoHideVerticalButtonBar = true; autoHideVerticalButtonBar = true;
skipping to change at line 162 skipping to change at line 171
winBar->setParentItem(this); winBar->setParentItem(this);
buttonBar->setParentItem(this); buttonBar->setParentItem(this);
buttonBarPath->setParentItem(this); buttonBarPath->setParentItem(this);
infoPanel->setParentItem(this); infoPanel->setParentItem(this);
progressBarMgr->setParentItem(this); progressBarMgr->setParentItem(this);
// Create the 2 auto hide buttons in the bottom left corner // Create the 2 auto hide buttons in the bottom left corner
autoHidebts = new CornerButtons(); autoHidebts = new CornerButtons();
QPixmap pxmapOn = QPixmap(":/graphicGui/HorizontalAutoHideOn.png"); QPixmap pxmapOn = QPixmap(":/graphicGui/HorizontalAutoHideOn.png");
QPixmap pxmapOff = QPixmap(":/graphicGui/HorizontalAutoHideOff.png") ; QPixmap pxmapOff = QPixmap(":/graphicGui/HorizontalAutoHideOff.png") ;
btHorizAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPi btHorizAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPi
xmap(), stelGui->getGuiAction("actionAutoHideHorizontalButtonBar"), true); xmap(), "actionAutoHideHorizontalButtonBar", true);
btHorizAutoHide->setChecked(autoHideHorizontalButtonBar);
pxmapOn = QPixmap(":/graphicGui/VerticalAutoHideOn.png"); pxmapOn = QPixmap(":/graphicGui/VerticalAutoHideOn.png");
pxmapOff = QPixmap(":/graphicGui/VerticalAutoHideOff.png"); pxmapOff = QPixmap(":/graphicGui/VerticalAutoHideOff.png");
btVertAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPix btVertAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPix
map(), stelGui->getGuiAction("actionAutoHideVerticalButtonBar"), true); map(), "actionAutoHideVerticalButtonBar", true);
btVertAutoHide->setChecked(autoHideVerticalButtonBar);
btHorizAutoHide->setPos(1,btVertAutoHide->pixmap().height()-btHorizA utoHide->pixmap().height()+1); btHorizAutoHide->setPos(1,btVertAutoHide->pixmap().height()-btHorizA utoHide->pixmap().height()+1);
btVertAutoHide->setPos(0,0); btVertAutoHide->setPos(0,0);
btVertAutoHide->setZValue(1000); btVertAutoHide->setZValue(1000);
autoHidebts->setParentItem(this); autoHidebts->setParentItem(this);
infoPanel->setPos(8,8); infoPanel->setPos(8,8);
// If auto hide is off, show the relevant toolbars // If auto hide is off, show the relevant toolbars
if (!autoHideHorizontalButtonBar) if (!autoHideHorizontalButtonBar)
skipping to change at line 192 skipping to change at line 199
if (!autoHideVerticalButtonBar) if (!autoHideVerticalButtonBar)
{ {
animLeftBarTimeLine->setDirection(QTimeLine::Forward); animLeftBarTimeLine->setDirection(QTimeLine::Forward);
animLeftBarTimeLine->start(); animLeftBarTimeLine->start();
} }
buttonBarPath->setZValue(-0.1); buttonBarPath->setZValue(-0.1);
updateBarsPos(); updateBarsPos();
connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt ring&)), this, SLOT(setStelStyle(const QString&))); connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt ring&)), this, SLOT(setStelStyle(const QString&)));
connect(buttonBar, SIGNAL(sizeChanged()), this, SLOT(updateBarsPos() ));
} }
void SkyGui::resizeEvent(QGraphicsSceneResizeEvent* event) void SkyGui::resizeEvent(QGraphicsSceneResizeEvent* event)
{ {
QGraphicsWidget::resizeEvent(event); QGraphicsWidget::resizeEvent(event);
updateBarsPos(); updateBarsPos();
} }
void SkyGui::hoverMoveEvent(QGraphicsSceneHoverEvent* event) void SkyGui::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
{ {
skipping to change at line 235 skipping to change at line 243
animBottomBarTimeLine->setDirection(QTimeLine::Forward); animBottomBarTimeLine->setDirection(QTimeLine::Forward);
animBottomBarTimeLine->start(); animBottomBarTimeLine->start();
} }
if (autoHideHorizontalButtonBar && (x>maxX+30 || y<maxY-30) && animB ottomBarTimeLine->state()==QTimeLine::NotRunning && animBottomBarTimeLine-> currentValue()>=0.9999999) if (autoHideHorizontalButtonBar && (x>maxX+30 || y<maxY-30) && animB ottomBarTimeLine->state()==QTimeLine::NotRunning && animBottomBarTimeLine-> currentValue()>=0.9999999)
{ {
animBottomBarTimeLine->setDirection(QTimeLine::Backward); animBottomBarTimeLine->setDirection(QTimeLine::Backward);
animBottomBarTimeLine->start(); animBottomBarTimeLine->start();
} }
} }
int SkyGui::getSkyGuiWidth() const
{
return geometry().width();
}
int SkyGui::getSkyGuiHeight() const
{
return geometry().height();
}
//! Update the position of the button bars in the main window //! Update the position of the button bars in the main window
void SkyGui::updateBarsPos() void SkyGui::updateBarsPos()
{ {
const int ww = geometry().width(); const int ww = getSkyGuiWidth();
const int hh = geometry().height(); const int hh = getSkyGuiHeight();
bool updatePath = false; bool updatePath = false;
// Use a position cache to avoid useless redraw triggered by the pos ition set if the bars don't move // Use a position cache to avoid useless redraw triggered by the pos ition set if the bars don't move
double rangeX = winBar->boundingRectNoHelpLabel().width()+2.*buttonB arPath->getRoundSize()+1.; double rangeX = winBar->boundingRectNoHelpLabel().width()+2.*buttonB arPath->getRoundSize()+1.;
const qreal newWinBarX = buttonBarPath->getRoundSize()-(1.-animLeftB arTimeLine->currentValue())*rangeX-0.5; const qreal newWinBarX = buttonBarPath->getRoundSize()-(1.-animLeftB arTimeLine->currentValue())*rangeX-0.5;
const qreal newWinBarY = hh-winBar->boundingRectNoHelpLabel().height ()-buttonBar->boundingRectNoHelpLabel().height()-20; const qreal newWinBarY = hh-winBar->boundingRectNoHelpLabel().height ()-buttonBar->boundingRectNoHelpLabel().height()-20;
if (winBar->pos().x()!=newWinBarX || winBar->pos().y()!=newWinBarY) if (winBar->pos().x()!=newWinBarX || winBar->pos().y()!=newWinBarY)
{ {
winBar->setPos(round(newWinBarX), round(newWinBarY)); winBar->setPos(round(newWinBarX), round(newWinBarY));
updatePath = true; updatePath = true;
skipping to change at line 279 skipping to change at line 297
const qreal newProgressBarX = ww-progressBarMgr->boundingRect().widt h()-20; const qreal newProgressBarX = ww-progressBarMgr->boundingRect().widt h()-20;
const qreal newProgressBarY = hh-progressBarMgr->boundingRect().heig ht()+7; const qreal newProgressBarY = hh-progressBarMgr->boundingRect().heig ht()+7;
progressBarMgr->setPos(newProgressBarX, newProgressBarY); progressBarMgr->setPos(newProgressBarX, newProgressBarY);
progressBarMgr->setZValue(400); progressBarMgr->setZValue(400);
// Update position of the auto-hide buttons // Update position of the auto-hide buttons
autoHidebts->setPos(0, hh-autoHidebts->childrenBoundingRect().height ()+1); autoHidebts->setPos(0, hh-autoHidebts->childrenBoundingRect().height ()+1);
double opacity = qMax(animLeftBarTimeLine->currentValue(), animBotto mBarTimeLine->currentValue()); double opacity = qMax(animLeftBarTimeLine->currentValue(), animBotto mBarTimeLine->currentValue());
autoHidebts->setOpacity(opacity < 0.01 ? 0.01 : opacity); // W ork around a qt bug autoHidebts->setOpacity(opacity < 0.01 ? 0.01 : opacity); // W ork around a qt bug
// Update the screen as soon as possible.
StelMainView::getInstance().thereWasAnEvent();
} }
void SkyGui::setStelStyle(const QString& style) void SkyGui::setStelStyle(const QString& style)
{ {
if (style == "night_color") Q_UNUSED(style);
{ buttonBarPath->setPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
buttonBarPath->setPen(QColor::fromRgbF(0.7,0.0,0.0,0.5)); buttonBarPath->setBrush(QColor::fromRgbF(0.15, 0.16, 0.19, 0.2));
buttonBarPath->setBrush(QColor::fromRgbF(0.23, 0.0, 0.00, 0. buttonBar->setColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
2)); winBar->setColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
buttonBar->setColor(QColor::fromRgbF(0.9, 0.0, 0.0, 0.9));
winBar->setColor(QColor::fromRgbF(0.9, 0.0, 0.0, 0.9));
winBar->setRedMode(true);
buttonBar->setRedMode(true);
btHorizAutoHide->setRedMode(true);
btVertAutoHide->setRedMode(true);
}
else
{
buttonBarPath->setPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
buttonBarPath->setBrush(QColor::fromRgbF(0.15, 0.16, 0.19, 0
.2));
buttonBar->setColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
winBar->setColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
buttonBar->setRedMode(false);
winBar->setRedMode(false);
btHorizAutoHide->setRedMode(false);
btVertAutoHide->setRedMode(false);
}
} }
// Add a new progress bar in the lower right corner of the screen. // Add a new progress bar in the lower right corner of the screen.
QProgressBar* SkyGui::addProgressBar() void SkyGui::addProgressBar(StelProgressController* p)
{ {
return progressBarMgr->addProgressBar(); return progressBarMgr->addProgressBar(p);
} }
void SkyGui::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) void SkyGui::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)
{ {
stelGui->update(); stelGui->update();
} }
 End of changes. 13 change blocks. 
42 lines changed or deleted 47 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/