void HGLayout::setSpacing(int s) { HLayout::setSpacing(s); QGraphicsLayout* ll = layout(); if (!ll) return ; switch (layoutType()) { case HEnums::kVBox: case HEnums::kHBox: { QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(ll); l->setSpacing(s); break; } case HEnums::kGrid: { QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(ll); l->setSpacing(s); break; } case HEnums::kAnchor: { QGraphicsAnchorLayout* l = static_cast<QGraphicsAnchorLayout*>(ll); l->setSpacing(s); break; } default: break; } }
void StatusIndicatorMenuDropDownView::applyStyle() { MSceneWindowView::applyStyle(); if (pannableViewport == NULL) { QGraphicsAnchorLayout *backgroundLayout = new QGraphicsAnchorLayout; backgroundLayout->setContentsMargins(0, 0, 0, 0); backgroundLayout->setSpacing(0); backgroundLayout->addCornerAnchors(backgroundWidget, Qt::TopLeftCorner, backgroundLayout, Qt::TopLeftCorner); backgroundLayout->setMaximumHeight(0); // Put all the stuff into the scene window layout pannableViewport = createPannableArea(); topRowWidget = createTopRow(); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addItem(topRowWidget); layout->addItem(backgroundLayout); layout->addItem(pannableViewport); controller->setLayout(layout); } }
int main(int argc, char **argv) { QApplication app(argc, argv); QGraphicsScene scene; scene.setSceneRect(0, 0, 800, 480); QSizeF minSize(30, 100); QSizeF prefSize(210, 100); QSizeF maxSize(300, 100); QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, "A"); QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, "B"); QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C"); QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D"); QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E"); QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)"); QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)"); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; l->setSpacing(0); QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window); w->setPos(20, 20); w->setLayout(l); // vertical QGraphicsAnchor *anchor = l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); anchor = l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); anchor = l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); anchor = l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); anchor = l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); anchor = l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); anchor = l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); anchor = l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); // horizontal anchor = l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); anchor = l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); anchor = l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); anchor = l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); anchor = l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); anchor = l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); anchor = l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); anchor = l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); anchor = l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); anchor = l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); anchor = l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); scene.addItem(w); scene.setBackgroundBrush(Qt::darkGreen); QGraphicsView *view = new QGraphicsView(&scene); view->show(); return app.exec(); }
void StelMainView::init(QSettings* conf) { gui = new StelGui(); #if STEL_USE_NEW_OPENGL_WIDGETS //glWidget->initializeGL(); // protected... //Q_ASSERT(glWidget->isValid()); #else Q_ASSERT(glWidget->isValid()); glWidget->makeCurrent(); #endif // Should be check of requirements disabled? if (conf->value("main/check_requirements", true).toBool()) { // Find out lots of debug info about supported version of OpenGL and vendor/renderer. processOpenGLdiagnosticsAndWarnings(conf, glWidget); } stelApp= new StelApp(); stelApp->setGui(gui); stelApp->init(conf); StelActionMgr *actionMgr = stelApp->getStelActionManager(); actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S"); actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Options"), N_("Full-screen mode"), this, "fullScreen", "F11"); StelPainter::initGLShaders(); skyItem = new StelSkyItem(); guiItem = new StelGuiItem(); QGraphicsAnchorLayout* l = new QGraphicsAnchorLayout(rootItem); l->setSpacing(0); l->setContentsMargins(0,0,0,0); l->addCornerAnchors(skyItem, Qt::TopLeftCorner, l, Qt::TopLeftCorner); l->addCornerAnchors(skyItem, Qt::BottomRightCorner, l, Qt::BottomRightCorner); l->addCornerAnchors(guiItem, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner); l->addCornerAnchors(guiItem, Qt::TopRightCorner, l, Qt::TopRightCorner); rootItem->setLayout(l); scene()->addItem(rootItem); nightModeEffect = new NightModeGraphicsEffect(this); updateNightModeProperty(); rootItem->setGraphicsEffect(nightModeEffect); QSize size = glWidget->windowHandle()->screen()->size(); size = QSize(conf->value("video/screen_w", size.width()).toInt(), conf->value("video/screen_h", size.height()).toInt()); bool fullscreen = conf->value("video/fullscreen", true).toBool(); // Without this, the screen is not shown on a Mac + we should use resize() for correct work of fullscreen/windowed mode switch. --AW WTF??? resize(size); QDesktopWidget *desktop = QApplication::desktop(); int screen = conf->value("video/screen_number", 0).toInt(); if (screen < 0 || screen >= desktop->screenCount()) { qWarning() << "WARNING: screen" << screen << "not found"; screen = 0; } QRect screenGeom = desktop->screenGeometry(screen); if (fullscreen) { // The "+1" below is to work around Linux/Gnome problem with mouse focus. move(screenGeom.x()+1, screenGeom.y()+1); // The fullscreen window appears on screen where is the majority of // the normal window. Therefore we crop the normal window to the // screen area to ensure that the majority is not on another screen. setGeometry(geometry() & screenGeom); setFullScreen(true); } else { setFullScreen(false); int x = conf->value("video/screen_x", 0).toInt(); int y = conf->value("video/screen_y", 0).toInt(); move(x + screenGeom.x(), y + screenGeom.y()); } flagInvertScreenShotColors = conf->value("main/invert_screenshots_colors", false).toBool(); setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", false).toBool()); setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFloat()); maxfps = conf->value("video/maximum_fps",10000.f).toFloat(); minfps = conf->value("video/minimum_fps",10000.f).toFloat(); flagMaxFpsUpdatePending = false; // XXX: This should be done in StelApp::init(), unfortunately for the moment we need init the gui before the // plugins, because the gui create the QActions needed by some plugins. StelApp::getInstance().initPlugIns(); // activate DE430/431 StelApp::getInstance().getCore()->initEphemeridesFunctions(); // The script manager can only be fully initialized after the plugins have loaded. StelApp::getInstance().initScriptMgr(); // Set the global stylesheet, this is only useful for the tooltips. StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui()); if (gui!=NULL) setStyleSheet(gui->getStelStyle().qtStyleSheet); connect(&StelApp::getInstance(), SIGNAL(visionNightModeChanged(bool)), this, SLOT(updateNightModeProperty())); QThread::currentThread()->setPriority(QThread::HighestPriority); startMainLoop(); }