SkyGui::SkyGui(QGraphicsItem * parent): QGraphicsWidget(parent), stelGui(NULL) { setObjectName("StelSkyGui"); // Construct the Windows buttons bar winBar = new LeftStelBar(this); // Construct the bottom buttons bar buttonBar = new BottomStelBar(this, QPixmap(":/graphicGui/btbg-left.png"), QPixmap(":/graphicGui/btbg-right.png"), QPixmap(":/graphicGui/btbg-middle.png"), QPixmap(":/graphicGui/btbg-single.png")); infoPanel = new InfoPanel(this); // Used to display some progress bar in the lower right corner, e.g. when loading a file progressBarMgr = new StelProgressBarMgr(this); connect(&StelApp::getInstance(), SIGNAL(progressBarAdded(const StelProgressController*)), progressBarMgr, SLOT(addProgressBar(const StelProgressController*))); connect(&StelApp::getInstance(), SIGNAL(progressBarRemoved(const StelProgressController*)), progressBarMgr, SLOT(removeProgressBar(const StelProgressController*))); // The path drawn around the button bars buttonBarPath = new StelBarsPath(this); lastButtonbarWidth = 0; autoHidebts = NULL; autoHideHorizontalButtonBar = true; autoHideVerticalButtonBar = true; animLeftBarTimeLine = new QTimeLine(200, this); animLeftBarTimeLine->setCurveShape(QTimeLine::EaseInOutCurve); connect(animLeftBarTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(updateBarsPos())); animBottomBarTimeLine = new QTimeLine(200, this); animBottomBarTimeLine->setCurveShape(QTimeLine::EaseInOutCurve); connect(animBottomBarTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(updateBarsPos())); setAcceptHoverEvents(true); }
// Used to recompute the bars position when we toggle the gui off and on. // This was not necessary with Qt < 5.4. So it might be a bug. QVariant SkyGui::itemChange(GraphicsItemChange change, const QVariant & value) { #if QT_VERSION > QT_VERSION_CHECK(5, 5, 0) #warning Please test if this code is still needed. #endif if (change == QGraphicsItem::ItemVisibleHasChanged && value.toBool()) updateBarsPos(); return QGraphicsItem::itemChange(change, value); }
void SkyGui::init(StelGui* astelGui) { stelGui = astelGui; winBar->setParentItem(this); buttonBar->setParentItem(this); buttonBarPath->setParentItem(this); infoPanel->setParentItem(this); progressBarMgr->setParentItem(this); // Create the 2 auto hide buttons in the bottom left corner autoHidebts = new CornerButtons(); QPixmap pxmapOn = QPixmap(":/graphicGui/HorizontalAutoHideOn.png"); QPixmap pxmapOff = QPixmap(":/graphicGui/HorizontalAutoHideOff.png"); btHorizAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPixmap(), "actionAutoHideHorizontalButtonBar", true); pxmapOn = QPixmap(":/graphicGui/VerticalAutoHideOn.png"); pxmapOff = QPixmap(":/graphicGui/VerticalAutoHideOff.png"); btVertAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPixmap(), "actionAutoHideVerticalButtonBar", true); btHorizAutoHide->setPos(1,btVertAutoHide->pixmap().height()-btHorizAutoHide->pixmap().height()+1); btVertAutoHide->setPos(0,0); btVertAutoHide->setZValue(1000); autoHidebts->setParentItem(this); infoPanel->setPos(8,8); // If auto hide is off, show the relevant toolbars if (!autoHideHorizontalButtonBar) { animBottomBarTimeLine->setDirection(QTimeLine::Forward); animBottomBarTimeLine->start(); } if (!autoHideVerticalButtonBar) { animLeftBarTimeLine->setDirection(QTimeLine::Forward); animLeftBarTimeLine->start(); } buttonBarPath->setZValue(-0.1); updateBarsPos(); connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setStelStyle(const QString&))); connect(buttonBar, SIGNAL(sizeChanged()), this, SLOT(updateBarsPos())); }
void SkyGui::resizeEvent(QGraphicsSceneResizeEvent* event) { QGraphicsWidget::resizeEvent(event); updateBarsPos(); }
// Used to recompute the bars position when we toggle the gui off and on. // This was not necessary with Qt < 5.4. So it might be a bug. QVariant SkyGui::itemChange(GraphicsItemChange change, const QVariant & value) { if (change == QGraphicsItem::ItemVisibleHasChanged && value.toBool()) updateBarsPos(); return QGraphicsItem::itemChange(change, value); }