class StelAction* StelModule::addAction(const QString& id, const QString& groupId, const QString& text, QObject* target, const char* slot, const QString& shortcut, const QString& altShortcut) { StelActionMgr* mgr = StelApp::getInstance().getStelActionManager(); return mgr->addAction(id, groupId, text, target, slot, shortcut, altShortcut); }
void StelScriptMgr::initActions() { StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager(); QSignalMapper* mapper = new QSignalMapper(this); foreach(const QString script, getScriptList()) { QString shortcut = getShortcut(script); QString actionId = "actionScript/" + script; StelAction* action = actionMgr->addAction( actionId, N_("Scripts"), q_(getName(script).trimmed()), mapper, "map()", shortcut); mapper->setMapping(action, script); }
void StelGui::init(QGraphicsWidget *atopLevelGraphicsWidget) { qDebug() << "Creating GUI ..."; StelGuiBase::init(atopLevelGraphicsWidget); skyGui = new SkyGui(atopLevelGraphicsWidget); locationDialog = new LocationDialog(atopLevelGraphicsWidget); helpDialog = new HelpDialog(atopLevelGraphicsWidget); dateTimeDialog = new DateTimeDialog(atopLevelGraphicsWidget); searchDialog = new SearchDialog(atopLevelGraphicsWidget); viewDialog = new ViewDialog(atopLevelGraphicsWidget); shortcutsDialog = new ShortcutsDialog(atopLevelGraphicsWidget); configurationDialog = new ConfigurationDialog(this, atopLevelGraphicsWidget); #ifdef ENABLE_SCRIPT_CONSOLE scriptConsole = new ScriptConsole(atopLevelGraphicsWidget); #endif astroCalcDialog = new AstroCalcDialog(atopLevelGraphicsWidget); bookmarksDialog = new BookmarksDialog(atopLevelGraphicsWidget); /////////////////////////////////////////////////////////////////////// // Create all the main actions of the program, associated with shortcuts /////////////////////////////////////////////////////////////////////// // Connect all the GUI actions signals with the Core of Stellarium StelActionMgr* actionsMgr = StelApp::getInstance().getStelActionManager(); // XXX: this should probably go into the script manager. QString datetimeGroup = N_("Date and Time"); QString windowsGroup = N_("Windows"); QString miscGroup = N_("Miscellaneous"); actionsMgr->addAction("actionQuit_Global", miscGroup, N_("Quit"), this, "quit()", "Ctrl+Q", "Ctrl+X"); actionsMgr->addAction("actionIncrease_Script_Speed", datetimeGroup, N_("Speed up the script execution rate"), this, "increaseScriptSpeed()"); actionsMgr->addAction("actionDecrease_Script_Speed", datetimeGroup, N_("Slow down the script execution rate"), this, "decreaseScriptSpeed()"); actionsMgr->addAction("actionSet_Real_Script_Speed", datetimeGroup, N_("Set the normal script execution rate"), this, "setRealScriptSpeed()"); actionsMgr->addAction("actionStop_Script", datetimeGroup, N_("Stop script execution"), this, "stopScript()", "Ctrl+D, S"); actionsMgr->addAction("actionPause_Script", datetimeGroup, N_("Pause script execution"), this, "pauseScript()", "Ctrl+D, P"); actionsMgr->addAction("actionResume_Script", datetimeGroup, N_("Resume script execution"), this, "resumeScript()", "Ctrl+D, R"); #ifdef ENABLE_SCRIPT_CONSOLE actionsMgr->addAction("actionShow_ScriptConsole_Window_Global", windowsGroup, N_("Script console window"), scriptConsole, "visible", "F12", "", true); #endif actionsMgr->addAction("actionShow_Help_Window_Global", windowsGroup, N_("Help window"), helpDialog, "visible", "F1", "", true); actionsMgr->addAction("actionShow_Configuration_Window_Global", windowsGroup, N_("Configuration window"), configurationDialog, "visible", "F2", "", true); actionsMgr->addAction("actionShow_Search_Window_Global", windowsGroup, N_("Search window"), searchDialog, "visible", "F3", "Ctrl+F", true); actionsMgr->addAction("actionShow_SkyView_Window_Global", windowsGroup, N_("Sky and viewing options window"), viewDialog, "visible", "F4", "", true); actionsMgr->addAction("actionShow_DateTime_Window_Global", windowsGroup, N_("Date/time window"), dateTimeDialog, "visible", "F5", "", true); actionsMgr->addAction("actionShow_Location_Window_Global", windowsGroup, N_("Location window"), locationDialog, "visible", "F6", "", true); actionsMgr->addAction("actionShow_Shortcuts_Window_Global", windowsGroup, N_("Shortcuts window"), shortcutsDialog, "visible", "F7", "", true); actionsMgr->addAction("actionShow_AstroCalc_Window_Global", windowsGroup, N_("AstroCalc window"), astroCalcDialog, "visible", "F10", "Alt+A", true); actionsMgr->addAction("actionShow_Bookmarks_Window_Global", windowsGroup, N_("Bookmarks window"), bookmarksDialog, "visible", "Alt+B", "", true); actionsMgr->addAction("actionSave_Copy_Object_Information_Global", miscGroup, N_("Copy selected object information to clipboard"), this, "copySelectedObjectInfo()", "Ctrl+C", "", true); QSettings* conf = StelApp::getInstance().getSettings(); Q_ASSERT(conf); setAutoHideHorizontalButtonBar(conf->value("gui/auto_hide_horizontal_toolbar", true).toBool()); setAutoHideVerticalButtonBar(conf->value("gui/auto_hide_vertical_toolbar", true).toBool()); actionsMgr->addAction("actionAutoHideHorizontalButtonBar", miscGroup, N_("Auto hide horizontal button bar"), this, "autoHideHorizontalButtonBar"); actionsMgr->addAction("actionAutoHideVerticalButtonBar", miscGroup, N_("Auto hide vertical button bar"), this, "autoHideVerticalButtonBar"); setGuiVisible(conf->value("gui/flag_show_gui", true).toBool()); actionsMgr->addAction("actionToggle_GuiHidden_Global", miscGroup, N_("Toggle visibility of GUI"), this, "visible", "Ctrl+T", "", true); #ifndef DISABLE_SCRIPTING StelScriptMgr* scriptMgr = &StelApp::getInstance().getScriptMgr(); connect(scriptMgr, SIGNAL(scriptRunning()), this, SLOT(scriptStarted())); connect(scriptMgr, SIGNAL(scriptStopped()), this, SLOT(scriptStopped())); #endif /////////////////////////////////////////////////////////////////////////// //// QGraphicsView based GUI /////////////////////////////////////////////////////////////////////////// // Add everything QPixmap pxmapDefault; QPixmap pxmapGlow(":/graphicGui/glow.png"); QPixmap pxmapOn(":/graphicGui/2-on-location.png"); QPixmap pxmapOff(":/graphicGui/2-off-location.png"); StelButton* b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Location_Window_Global"); skyGui->winBar->addButton(b); pxmapOn = QPixmap(":/graphicGui/1-on-time.png"); pxmapOff = QPixmap(":/graphicGui/1-off-time.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_DateTime_Window_Global"); skyGui->winBar->addButton(b); pxmapOn = QPixmap(":/graphicGui/5-on-labels.png"); pxmapOff = QPixmap(":/graphicGui/5-off-labels.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_SkyView_Window_Global"); skyGui->winBar->addButton(b); pxmapOn = QPixmap(":/graphicGui/6-on-search.png"); pxmapOff = QPixmap(":/graphicGui/6-off-search.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Search_Window_Global"); skyGui->winBar->addButton(b); pxmapOn = QPixmap(":/graphicGui/8-on-settings.png"); pxmapOff = QPixmap(":/graphicGui/8-off-settings.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Configuration_Window_Global"); skyGui->winBar->addButton(b); pxmapOn = QPixmap(":/graphicGui/9-on-help.png"); pxmapOff = QPixmap(":/graphicGui/9-off-help.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Help_Window_Global"); skyGui->winBar->addButton(b); QPixmap pxmapGlow32x32(":/graphicGui/glow32x32.png"); pxmapOn = QPixmap(":/graphicGui/btConstellationLines-on.png"); pxmapOff = QPixmap(":/graphicGui/btConstellationLines-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Constellation_Lines"); skyGui->buttonBar->addButton(b, "010-constellationsGroup"); pxmapOn = QPixmap(":/graphicGui/btConstellationLabels-on.png"); pxmapOff = QPixmap(":/graphicGui/btConstellationLabels-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Constellation_Labels"); skyGui->buttonBar->addButton(b, "010-constellationsGroup"); pxmapOn = QPixmap(":/graphicGui/btConstellationArt-on.png"); pxmapOff = QPixmap(":/graphicGui/btConstellationArt-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Constellation_Art"); skyGui->buttonBar->addButton(b, "010-constellationsGroup"); pxmapOn = QPixmap(":/graphicGui/btEquatorialGrid-on.png"); pxmapOff = QPixmap(":/graphicGui/btEquatorialGrid-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Equatorial_Grid"); skyGui->buttonBar->addButton(b, "020-gridsGroup"); pxmapOn = QPixmap(":/graphicGui/btAzimuthalGrid-on.png"); pxmapOff = QPixmap(":/graphicGui/btAzimuthalGrid-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Azimuthal_Grid"); skyGui->buttonBar->addButton(b, "020-gridsGroup"); pxmapOn = QPixmap(":/graphicGui/btGround-on.png"); pxmapOff = QPixmap(":/graphicGui/btGround-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Ground"); skyGui->buttonBar->addButton(b, "030-landscapeGroup"); pxmapOn = QPixmap(":/graphicGui/btCardinalPoints-on.png"); pxmapOff = QPixmap(":/graphicGui/btCardinalPoints-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Cardinal_Points"); skyGui->buttonBar->addButton(b, "030-landscapeGroup"); pxmapOn = QPixmap(":/graphicGui/btAtmosphere-on.png"); pxmapOff = QPixmap(":/graphicGui/btAtmosphere-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Atmosphere"); skyGui->buttonBar->addButton(b, "030-landscapeGroup"); pxmapOn = QPixmap(":/graphicGui/btNebula-on.png"); pxmapOff = QPixmap(":/graphicGui/btNebula-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Nebulas"); skyGui->buttonBar->addButton(b, "040-nebulaeGroup"); pxmapOn = QPixmap(":/graphicGui/btPlanets-on.png"); pxmapOff = QPixmap(":/graphicGui/btPlanets-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Planets_Labels"); skyGui->buttonBar->addButton(b, "040-nebulaeGroup"); pxmapOn = QPixmap(":/graphicGui/btEquatorialMount-on.png"); pxmapOff = QPixmap(":/graphicGui/btEquatorialMount-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionSwitch_Equatorial_Mount"); skyGui->buttonBar->addButton(b, "060-othersGroup"); pxmapOn = QPixmap(":/graphicGui/btGotoSelectedObject-on.png"); pxmapOff = QPixmap(":/graphicGui/btGotoSelectedObject-off.png"); buttonGotoSelectedObject = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionGoto_Selected_Object"); skyGui->buttonBar->addButton(buttonGotoSelectedObject, "060-othersGroup"); pxmapOn = QPixmap(":/graphicGui/btNightView-on.png"); pxmapOff = QPixmap(":/graphicGui/btNightView-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Night_Mode"); skyGui->buttonBar->addButton(b, "060-othersGroup"); pxmapOn = QPixmap(":/graphicGui/btFullScreen-on.png"); pxmapOff = QPixmap(":/graphicGui/btFullScreen-off.png"); b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionSet_Full_Screen_Global"); skyGui->buttonBar->addButton(b, "060-othersGroup"); pxmapOn = QPixmap(":/graphicGui/btTimeRewind-on.png"); pxmapOff = QPixmap(":/graphicGui/btTimeRewind-off.png"); buttonTimeRewind = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionDecrease_Time_Speed"); skyGui->buttonBar->addButton(buttonTimeRewind, "070-timeGroup"); pxmapOn = QPixmap(":/graphicGui/btTimeRealtime-on.png"); pxmapOff = QPixmap(":/graphicGui/btTimeRealtime-off.png"); pxmapDefault = QPixmap(":/graphicGui/btTimePause-on.png"); buttonTimeRealTimeSpeed = new StelButton(NULL, pxmapOn, pxmapOff, pxmapDefault, pxmapGlow32x32, "actionSet_Real_Time_Speed"); skyGui->buttonBar->addButton(buttonTimeRealTimeSpeed, "070-timeGroup"); pxmapOn = QPixmap(":/graphicGui/btTimeNow-on.png"); pxmapOff = QPixmap(":/graphicGui/btTimeNow-off.png"); buttonTimeCurrent = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionReturn_To_Current_Time"); skyGui->buttonBar->addButton(buttonTimeCurrent, "070-timeGroup"); pxmapOn = QPixmap(":/graphicGui/btTimeForward-on.png"); pxmapOff = QPixmap(":/graphicGui/btTimeForward-off.png"); buttonTimeForward = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionIncrease_Time_Speed"); skyGui->buttonBar->addButton(buttonTimeForward, "070-timeGroup"); skyGui->buttonBar->setGroupMargin("070-timeGroup", 32, 0); pxmapOn = QPixmap(":/graphicGui/btQuit.png"); b = new StelButton(NULL, pxmapOn, pxmapOn, pxmapGlow32x32, "actionQuit_Global"); skyGui->buttonBar->addButton(b, "080-quitGroup"); // add the flip buttons if requested in the config setFlagShowFlipButtons(conf->value("gui/flag_show_flip_buttons", false).toBool()); setFlagShowNebulaBackgroundButton(conf->value("gui/flag_show_nebulae_background_button", false).toBool()); /////////////////////////////////////////////////////////////////////// // Create the main base widget skyGui->init(this); QGraphicsGridLayout* l = new QGraphicsGridLayout(); l->setContentsMargins(0,0,0,0); l->setSpacing(0); l->addItem(skyGui, 0, 0); atopLevelGraphicsWidget->setLayout(l); setStelStyle(StelApp::getInstance().getCurrentStelStyle()); skyGui->setGeometry(atopLevelGraphicsWidget->geometry()); skyGui->updateBarsPos(); // The disabled text for checkboxes is embossed with the QPalette::Light setting for the ColorGroup Disabled. // It doesn't appear to be possible to set this from the stylesheet. Instead we'll make it 100% transparent // and set the text color for disabled in the stylesheets. QPalette p = QGuiApplication::palette(); p.setColor(QPalette::Disabled, QPalette::Light, QColor(0,0,0,0)); // And this is for the focus... apparently the focus indicator is the inverted value for Active/Button. p.setColor(QPalette::Active, QPalette::Button, QColor(255,255,255)); QGuiApplication::setPalette(p); // FIXME: Workaround for set UI language when app is started --AW updateI18n(); StelApp *app = &StelApp::getInstance(); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setStelStyle(const QString&))); initDone = true; }
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(); }