bool ScriptEditorWidget::setRunning(bool run) { if (run && isModified() && !save()) { return false; } if (_scriptEngine != NULL) { disconnect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged); disconnect(_scriptEngine, &ScriptEngine::update, this, &ScriptEditorWidget::onScriptModified); disconnect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); } auto scriptEngines = DependencyManager::get<ScriptEngines>(); if (run) { const QString& scriptURLString = QUrl(_currentScript).toString(); // Reload script so that an out of date copy is not retrieved from the cache _scriptEngine = scriptEngines->loadScript(scriptURLString, true, true, false, true); connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged); connect(_scriptEngine, &ScriptEngine::update, this, &ScriptEditorWidget::onScriptModified); connect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); } else { connect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); const QString& scriptURLString = QUrl(_currentScript).toString(); scriptEngines->stopScript(scriptURLString); _scriptEngine = NULL; } _console->setScriptEngine(_scriptEngine); return true; }
void UBApplication::showInternet() { applicationController->showInternet(); webController->showTabAtTop(true); boardController->paletteManager()->featuresWidget()->switchToBookmarks(); stopScript(); }
bool XBPython::StopScript(const CStdString &path) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ int id = getScriptId(path); if (id != -1) { /* if we are here we already know that this script is running. * But we will check it again to be sure :) */ if (isRunning(id)) { stopScript(id); return true; } } return false; }
StelScriptMgr::StelScriptMgr(QObject *parent): QObject(parent) { connect(&StelApp::getInstance(), SIGNAL(aboutToQuit()), this, SLOT(stopScript()), Qt::DirectConnection); // Scripting images ScreenImageMgr* scriptImages = new ScreenImageMgr(); scriptImages->init(); StelApp::getInstance().getModuleMgr().registerModule(scriptImages); // Allow Vec3f managment in scripts qScriptRegisterMetaType(&engine, vec3fToScriptValue, vec3fFromScriptValue); // Constructor QScriptValue ctor = engine.newFunction(createVec3f); engine.globalObject().setProperty("Vec3f", ctor); // Add the core object to access methods related to core mainAPI = new StelMainScriptAPI(this); QScriptValue objectValue = engine.newQObject(mainAPI); engine.globalObject().setProperty("core", objectValue); engine.evaluate("function mywait__(sleepDurationSec) {" "if (sleepDurationSec<0) return;" "var date = new Date();" "var curDate = null;" "do {curDate = new Date();}" "while(curDate-date < sleepDurationSec*1000/scriptRateReadOnly);}"); engine.evaluate("core['wait'] = mywait__;"); engine.evaluate("function mywaitFor__(dt, spec) {" "if (!spec) spec=\"utc\";" "var deltaJD = core.jdFromDateString(dt, spec) - core.getJDay();" "var timeSpeed = core.getTimeRate();" "if (timeSpeed == 0.) {core.debug(\"waitFor called with no time passing - would be infinite. not waiting!\"); return;}" "var date = new Date();" "var curDate = null;" "do {curDate = new Date();}" "while(curDate-date < deltaJD*86400000/timeSpeed);}"); engine.evaluate("core['waitFor'] = mywaitFor__;"); // Add other classes which we want to be directly accessible from scripts if(StelSkyLayerMgr* smgr = GETSTELMODULE(StelSkyLayerMgr)) objectValue = engine.newQObject(smgr); // For accessing star scale, twinkle etc. objectValue = engine.newQObject(StelApp::getInstance().getCore()->getSkyDrawer()); engine.globalObject().setProperty("StelSkyDrawer", objectValue); setScriptRate(1.0); engine.setProcessEventsInterval(10); agent = new StelScriptEngineAgent(&engine); engine.setAgent(agent); initActions(); }
void Agent::unhandledException(std::string info, bool wasscript) { // TODO: do something with this? empty the stack? if (world.autostop) { // autostop is mostly for Creatures Village, which is full of buggy scripts stopScript(); } else if (world.autokill && !dynamic_cast<CreatureAgent *>(this)) { // don't autokill creatures! TODO: someday we probably should :) kill(); if (wasscript) std::cerr << identify() << " was autokilled during script " << lastScript << " due to: " << info << std::endl; else std::cerr << identify() << " was autokilled due to: " << info << std::endl; } else { stopScript(); if (wasscript) std::cerr << identify() << " caused an exception during script " << lastScript << ": " << info << std::endl; else std::cerr << identify() << " caused an exception: " << info << std::endl; } }
void ScriptEngine::stopScripts(){ DEBUG_BLOCK QMap<QString, ScriptObject*> s = scripts; auto it = s.begin(); for (; it != s.end(); ++it) stopScript(it.key()); scripts.clear(); }
void MainWindow::executeScript() { QAction *action = static_cast<QAction *>(sender()); if (action->data().toString() != "Execute") { stopScript(); return; } QueryWidget *widget = _workArea->currentQueryWidget(); if (!widget) return; widget->execute(); }
void Agent::vmTick() { // Tick the VM associated with this agent. assert(vm); // There must *be* a VM to tick. LifeAssert la(this); // sanity check // If we're out of timeslice, give ourselves some more (depending on the game type). if (!vm->timeslice) { vm->timeslice = (engine.version < 3) ? 1 : 5; } // Keep trying to run VMs while we don't run out of timeslice, end up with a blocked VM, or a VM stops. while (vm && vm->timeslice && !vm->isBlocking() && !vm->stopped()) { assert(vm->timeslice > 0); // Tell the VM to tick (using all available timeslice), catching exceptions as necessary. try { vm->tick(); } catch (invalidAgentException &e) { // try letting the exception script handle it if (!queueScript(255)) unhandledException(e.prettyPrint(), true); else stopScript(); // we still want current script to die } catch (creaturesException &e) { unhandledException(e.prettyPrint(), true); } catch (std::exception &e) { unhandledException(e.what(), true); } // If the VM stopped, it's done. if (vm && vm->stopped()) { world.freeVM(vm); vm = NULL; } } // Zot any remaining timeslice, since we're done now. if (vm) vm->timeslice = 0; // If there's no current VM but there's one on the call stack, a previous VM must have finished, // pop one from the call stack to run next time. if (!vm && !vmstack.empty()) { vm = vmstack.front(); vmstack.pop_front(); } }
void ScriptEngine::loadScript(const QString &path){ DEBUG_BLOCK QFile f(path); if (!f.exists()) return; stopScript(path); if (path.endsWith(".js", Qt::CaseInsensitive)) loadJSScript(path); #ifdef USE_QML else if (path.endsWith(".qml", Qt::CaseInsensitive)) loadQMLScript(path); #endif }
int UBApplication::exec(const QString& pFileToImport) { QPixmapCache::setCacheLimit(1024 * 100); QString webDbPath = UBSettings::userDataDirectory() + "/web-databases"; QDir webDbDir(webDbPath); if (!webDbDir.exists(webDbPath)) webDbDir.mkpath(webDbPath); QWebSettings::setIconDatabasePath(webDbPath); QWebSettings::setOfflineStoragePath (webDbPath); QWebSettings *gs = QWebSettings::globalSettings(); gs->setAttribute(QWebSettings::JavaEnabled, true); gs->setAttribute(QWebSettings::PluginsEnabled, true); gs->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); gs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); gs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); gs->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); gs->setAttribute(QWebSettings::DnsPrefetchEnabled, true); mainWindow = new UBMainWindow(0, Qt::FramelessWindowHint); // deleted by application destructor mainWindow->setAttribute(Qt::WA_NativeWindow, true); mainWindow->actionCopy->setShortcuts(QKeySequence::Copy); mainWindow->actionPaste->setShortcuts(QKeySequence::Paste); mainWindow->actionCut->setShortcuts(QKeySequence::Cut); connect(mainWindow->actionBoard, SIGNAL(triggered()), this, SLOT(showBoard())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(showInternet())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(showDocument())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(closing())); connect(mainWindow, SIGNAL(closeEvent_Signal(QCloseEvent*)), this, SLOT(closeEvent(QCloseEvent*))); boardController = new UBBoardController(mainWindow); boardController->init(); webController = new UBWebController(mainWindow); documentController = new UBDocumentController(mainWindow); boardController->paletteManager()->connectToDocumentController(); UBDrawingController::drawingController()->setStylusTool((int)UBStylusTool::Pen); applicationController = new UBApplicationController(boardController->controlView(), boardController->displayView(), mainWindow, staticMemoryCleaner); connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), boardController->paletteManager(), SLOT(slot_changeMainMode(UBApplicationController::MainMode))); connect(applicationController, SIGNAL(desktopMode(bool)), boardController->paletteManager(), SLOT(slot_changeDesktopMode(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), applicationController, SLOT(showDesktop(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), this, SLOT(stopScript())); #ifndef Q_WS_MAC connect(mainWindow->actionHideApplication, SIGNAL(triggered()), mainWindow, SLOT(showMinimized())); #else connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized())); #endif mPreferencesController = new UBPreferencesController(mainWindow); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), applicationController, SLOT(showTutorial())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); toolBarPositionChanged(UBSettings::settings()->appToolBarPositionedAtTop->get()); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); mainWindow->actionMultiScreen->setChecked(bUseMultiScreen); connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool))); connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool))); connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool))); connect(mainWindow->actionImportUniboardDocuments, SIGNAL(triggered()), this, SLOT(importUniboardFiles())); connect(mainWindow->actionCut, SIGNAL(triggered()), applicationController, SLOT(actionCut())); connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy())); connect(mainWindow->actionPaste, SIGNAL(triggered()), applicationController, SLOT(actionPaste())); applicationController->initScreenLayout(bUseMultiScreen); boardController->setupLayout(); if (pFileToImport.length() > 0) { UBApplication::applicationController->importFile(pFileToImport); } #if defined(Q_WS_MAC) static AEEventHandlerUPP ub_proc_ae_handlerUPP = AEEventHandlerUPP(ub_appleEventProcessor); AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, ub_proc_ae_handlerUPP, SRefCon(UBApplication::applicationController), true); #endif if (UBSettings::settings()->appStartMode->get() == "Desktop") applicationController->showDesktop(); else applicationController->showBoard(); return QApplication::exec(); }
connect(this, SIGNAL(requestStopSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(stopSound(const QString&))); connect(this, SIGNAL(requestDropSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(dropSound(const QString&))); connect(this, SIGNAL(requestLoadVideo(const QString&, const QString&, float, float, bool, float)), StelApp::getInstance().getStelVideoMgr(), SLOT(loadVideo(const QString&, const QString&, float, float, bool, float))); connect(this, SIGNAL(requestPlayVideo(const QString&, const bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(playVideo(const QString&, const bool))); connect(this, SIGNAL(requestPlayVideoPopout(QString,float,float,float,float,float,float,float,bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(playVideoPopout(QString,float,float,float,float,float,float,float,bool))); connect(this, SIGNAL(requestPauseVideo(const QString&)), StelApp::getInstance().getStelVideoMgr(), SLOT(pauseVideo(const QString&))); connect(this, SIGNAL(requestStopVideo(const QString&)), StelApp::getInstance().getStelVideoMgr(), SLOT(stopVideo(const QString&))); connect(this, SIGNAL(requestDropVideo(const QString&)), StelApp::getInstance().getStelVideoMgr(), SLOT(dropVideo(const QString&))); connect(this, SIGNAL(requestSeekVideo(const QString&, qint64, bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(seekVideo(const QString&, qint64, bool))); connect(this, SIGNAL(requestSetVideoXY(const QString&, float, float, bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(setVideoXY(const QString&, float, float, bool))); connect(this, SIGNAL(requestSetVideoAlpha(const QString&, float)), StelApp::getInstance().getStelVideoMgr(), SLOT(setVideoAlpha(const QString&, float))); connect(this, SIGNAL(requestResizeVideo(const QString&, float, float)), StelApp::getInstance().getStelVideoMgr(), SLOT(resizeVideo(const QString&, float, float))); connect(this, SIGNAL(requestShowVideo(const QString&, bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(showVideo(const QString&, bool))); connect(this, SIGNAL(requestExit()), this->parent(), SLOT(stopScript())); connect(this, SIGNAL(requestSetNightMode(bool)), &StelApp::getInstance(), SLOT(setVisionModeNight(bool))); connect(this, SIGNAL(requestSetProjectionMode(QString)), StelApp::getInstance().getCore(), SLOT(setCurrentProjectionTypeKey(QString))); connect(this, SIGNAL(requestSetSkyCulture(QString)), &StelApp::getInstance().getSkyCultureMgr(), SLOT(setCurrentSkyCultureID(QString))); connect(this, SIGNAL(requestSetDiskViewport(bool)), StelApp::getInstance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool))); connect(this, SIGNAL(requestSetHomePosition()), StelApp::getInstance().getCore(), SLOT(returnToHome())); } StelMainScriptAPI::~StelMainScriptAPI() { } //! Set the current date in Julian Day //! @param JD the Julian Date (UT) void StelMainScriptAPI::setJDay(double JD) {
void ScriptConsole::createDialogContent() { ui->setupUi(dialog); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); highlighter = new StelScriptSyntaxHighlighter(ui->scriptEdit->document()); ui->includeEdit->setText(StelFileMgr::getInstallationDir() + "/scripts"); ui->quickrunCombo->addItem(q_("quickrun...")); ui->quickrunCombo->addItem(q_("selected text")); ui->quickrunCombo->addItem(q_("clear text")); ui->quickrunCombo->addItem(q_("clear images")); ui->quickrunCombo->addItem(q_("natural")); ui->quickrunCombo->addItem(q_("starchart")); connect(ui->scriptEdit, SIGNAL(cursorPositionChanged()), this, SLOT(rowColumnChanged())); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(loadScript())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveScript())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearButtonPressed())); connect(ui->preprocessSSCButton, SIGNAL(clicked()), this, SLOT(preprocessScript())); connect(ui->runButton, SIGNAL(clicked()), this, SLOT(runScript())); connect(ui->stopButton, SIGNAL(clicked()), &StelApp::getInstance().getScriptMgr(), SLOT(stopScript())); connect(ui->includeBrowseButton, SIGNAL(clicked()), this, SLOT(includeBrowse())); connect(ui->quickrunCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(quickRun(int))); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptRunning()), this, SLOT(scriptStarted())); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptStopped()), this, SLOT(scriptEnded())); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptDebug(const QString&)), this, SLOT(appendLogLine(const QString&))); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptOutput(const QString&)), this, SLOT(appendOutputLine(const QString&))); ui->tabs->setCurrentIndex(0); ui->scriptEdit->setFocus(); }
bool ScriptManager::slotRunScript( bool silent ) { if( !m_gui->runButton->isEnabled() ) return false; QListViewItem* const li = m_gui->listView->currentItem(); const QString name = li->text( 0 ); if( m_scripts[name].type == "lyrics" && lyricsScriptRunning() != QString::null ) { if( !silent ) KMessageBox::sorry( 0, i18n( "Another lyrics script is already running. " "You may only run one lyrics script at a time." ) ); return false; } if( m_scripts[name].type == "transcode" && transcodeScriptRunning() != QString::null ) { if( !silent ) KMessageBox::sorry( 0, i18n( "Another transcode script is already running. " "You may only run one transcode script at a time." ) ); return false; } // Don't start a script twice if( m_scripts[name].process ) return false; AmaroKProcIO* script = new AmaroKProcIO(); script->setComm( static_cast<KProcess::Communication>( KProcess::All ) ); const KURL url = m_scripts[name].url; *script << url.path(); script->setWorkingDirectory( amaroK::saveLocation( "scripts-data/" ) ); connect( script, SIGNAL( receivedStderr( KProcess*, char*, int ) ), SLOT( slotReceivedStderr( KProcess*, char*, int ) ) ); connect( script, SIGNAL( receivedStdout( KProcess*, char*, int ) ), SLOT( slotReceivedStdout( KProcess*, char*, int ) ) ); connect( script, SIGNAL( processExited( KProcess* ) ), SLOT( scriptFinished( KProcess* ) ) ); if( script->start( KProcess::NotifyOnExit ) ) { if( m_scripts[name].type == "score" && !scoreScriptRunning().isNull() ) { stopScript( scoreScriptRunning() ); m_gui->listView->setCurrentItem( li ); } AmarokConfig::setLastScoreScript( name ); } else { if( !silent ) KMessageBox::sorry( 0, i18n( "<p>Could not start the script <i>%1</i>.</p>" "<p>Please make sure that the file has execute (+x) permissions.</p>" ).arg( name ) ); delete script; return false; } li->setPixmap( 0, SmallIcon( amaroK::icon( "play" ) ) ); debug() << "Running script: " << url.path() << endl; m_scripts[name].process = script; slotCurrentChanged( m_gui->listView->currentItem() ); if( m_scripts[name].type == "lyrics" ) emit lyricsScriptChanged(); return true; }
void StelGui::init(QGraphicsWidget* atopLevelGraphicsWidget, StelAppGraphicsWidget* astelAppGraphicsWidget) { qDebug() << "Creating GUI ..."; StelGuiBase::init(atopLevelGraphicsWidget, astelAppGraphicsWidget); skyGui = new SkyGui(atopLevelGraphicsWidget); locationDialog = new LocationDialog(); helpDialog = new HelpDialog(); dateTimeDialog = new DateTimeDialog(); searchDialog = new SearchDialog(); viewDialog = new ViewDialog(); shortcutsDialog = new ShortcutsDialog(); configurationDialog = new ConfigurationDialog(this); #ifdef ENABLE_SCRIPT_CONSOLE scriptConsole = new ScriptConsole(); #endif /////////////////////////////////////////////////////////////////////// // Create all the main actions of the program, associated with shortcuts StelApp::getInstance().getStelShortcutManager()->loadShortcuts(); #ifdef ENABLE_SCRIPT_CONSOLE StelApp::getInstance().getStelShortcutManager()-> addGuiAction("actionShow_ScriptConsole_Window_Global", true, N_("Script console window"), "F12", "", N_("Windows"), true, false, true); #endif /////////////////////////////////////////////////////////////////////// // Connect all the GUI actions signals with the Core of Stellarium connect(getGuiAction("actionQuit_Global"), SIGNAL(triggered()), this, SLOT(quit())); initConstellationMgr(); initGrindLineMgr(); initLandscapeMgr(); NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr); connect(getGuiAction("actionShow_Nebulas"), SIGNAL(toggled(bool)), nmgr, SLOT(setFlagHints(bool))); getGuiAction("actionShow_Nebulas")->setChecked(nmgr->getFlagHints()); StelSkyLayerMgr* imgr = GETSTELMODULE(StelSkyLayerMgr); connect(getGuiAction("actionShow_DSS"), SIGNAL(toggled(bool)), imgr, SLOT(setFlagShow(bool))); getGuiAction("actionShow_DSS")->setChecked(imgr->getFlagShow()); StelCore* core = StelApp::getInstance().getCore(); StelMovementMgr* mmgr = GETSTELMODULE(StelMovementMgr); connect(getGuiAction("actionIncrease_Script_Speed"), SIGNAL(triggered()), this, SLOT(increaseScriptSpeed())); connect(getGuiAction("actionDecrease_Script_Speed"), SIGNAL(triggered()), this, SLOT(decreaseScriptSpeed())); connect(getGuiAction("actionSet_Real_Script_Speed"), SIGNAL(triggered()), this, SLOT(setRealScriptSpeed())); connect(getGuiAction("actionStop_Script"), SIGNAL(triggered()), this, SLOT(stopScript())); connect(getGuiAction("actionPause_Script"), SIGNAL(triggered()), this, SLOT(pauseScript())); connect(getGuiAction("actionResume_Script"), SIGNAL(triggered()), this, SLOT(resumeScript())); connect(getGuiAction("actionIncrease_Time_Speed"), SIGNAL(triggered()), core, SLOT(increaseTimeSpeed())); connect(getGuiAction("actionDecrease_Time_Speed"), SIGNAL(triggered()), core, SLOT(decreaseTimeSpeed())); connect(getGuiAction("actionIncrease_Time_Speed_Less"), SIGNAL(triggered()), core, SLOT(increaseTimeSpeedLess())); connect(getGuiAction("actionDecrease_Time_Speed_Less"), SIGNAL(triggered()), core, SLOT(decreaseTimeSpeedLess())); connect(getGuiAction("actionSet_Real_Time_Speed"), SIGNAL(triggered()), core, SLOT(toggleRealTimeSpeed())); connect(getGuiAction("actionSet_Time_Rate_Zero"), SIGNAL(triggered()), core, SLOT(setZeroTimeSpeed())); connect(getGuiAction("actionReturn_To_Current_Time"), SIGNAL(triggered()), core, SLOT(setTimeNow())); connect(getGuiAction("actionSwitch_Equatorial_Mount"), SIGNAL(toggled(bool)), mmgr, SLOT(setEquatorialMount(bool))); getGuiAction("actionSwitch_Equatorial_Mount")->setChecked(mmgr->getMountMode() != StelMovementMgr::MountAltAzimuthal); connect(getGuiAction("actionAdd_Solar_Hour"), SIGNAL(triggered()), core, SLOT(addHour())); connect(getGuiAction("actionAdd_Solar_Day"), SIGNAL(triggered()), core, SLOT(addDay())); connect(getGuiAction("actionAdd_Solar_Week"), SIGNAL(triggered()), core, SLOT(addWeek())); connect(getGuiAction("actionSubtract_Solar_Hour"), SIGNAL(triggered()), core, SLOT(subtractHour())); connect(getGuiAction("actionSubtract_Solar_Day"), SIGNAL(triggered()), core, SLOT(subtractDay())); connect(getGuiAction("actionSubtract_Solar_Week"), SIGNAL(triggered()), core, SLOT(subtractWeek())); connect(getGuiAction("actionAdd_Sidereal_Day"), SIGNAL(triggered()), core, SLOT(addSiderealDay())); connect(getGuiAction("actionAdd_Sidereal_Week"), SIGNAL(triggered()), core, SLOT(addSiderealWeek())); connect(getGuiAction("actionAdd_Sidereal_Month"), SIGNAL(triggered()), core, SLOT(addSiderealMonth())); connect(getGuiAction("actionAdd_Sidereal_Year"), SIGNAL(triggered()), core, SLOT(addSiderealYear())); connect(getGuiAction("actionSubtract_Sidereal_Day"), SIGNAL(triggered()), core, SLOT(subtractSiderealDay())); connect(getGuiAction("actionSubtract_Sidereal_Week"), SIGNAL(triggered()), core, SLOT(subtractSiderealWeek())); connect(getGuiAction("actionSubtract_Sidereal_Month"), SIGNAL(triggered()), core, SLOT(subtractSiderealMonth())); connect(getGuiAction("actionSubtract_Sidereal_Year"), SIGNAL(triggered()), core, SLOT(subtractSiderealYear())); connect(getGuiAction("actionSet_Home_Planet_To_Selected"), SIGNAL(triggered()), core, SLOT(moveObserverToSelected())); connect(getGuiAction("actionGo_Home_Global"), SIGNAL(triggered()), core, SLOT(returnToHome())); // connect the actor after setting the nightmode. // StelApp::init() already set flagNightMode for us, don't do it twice! getGuiAction("actionShow_Night_Mode")->setChecked(StelApp::getInstance().getVisionModeNight()); connect(getGuiAction("actionShow_Night_Mode"), SIGNAL(toggled(bool)), &StelApp::getInstance(), SLOT(setVisionModeNight(bool))); connect(getGuiAction("actionGoto_Selected_Object"), SIGNAL(triggered()), mmgr, SLOT(setFlagTracking())); connect(getGuiAction("actionZoom_In_Auto"), SIGNAL(triggered()), mmgr, SLOT(autoZoomIn())); connect(getGuiAction("actionZoom_Out_Auto"), SIGNAL(triggered()), mmgr, SLOT(autoZoomOut())); connect(getGuiAction("actionSet_Tracking"), SIGNAL(toggled(bool)), mmgr, SLOT(setFlagTracking(bool))); getGuiAction("actionSet_Tracking")->setChecked(mmgr->getFlagTracking()); connect(getGuiAction("actionSet_Full_Screen_Global"), SIGNAL(toggled(bool)), &StelMainWindow::getInstance(), SLOT(setFullScreen(bool))); getGuiAction("actionSet_Full_Screen_Global")->setChecked(StelMainWindow::getInstance().isFullScreen()); QAction* tempAction = getGuiAction("actionShow_Location_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), locationDialog, SLOT(setVisible(bool))); connect(locationDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); #ifdef ENABLE_SCRIPT_CONSOLE tempAction = getGuiAction("actionShow_ScriptConsole_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), scriptConsole, SLOT(setVisible(bool))); connect(scriptConsole, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); #endif tempAction = getGuiAction("actionShow_Configuration_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), configurationDialog, SLOT(setVisible(bool))); connect(configurationDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); tempAction = getGuiAction("actionShow_SkyView_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), viewDialog, SLOT(setVisible(bool))); connect(viewDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); tempAction = getGuiAction("actionShow_Help_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), helpDialog, SLOT(setVisible(bool))); connect(helpDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); tempAction = getGuiAction("actionShow_DateTime_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), dateTimeDialog, SLOT(setVisible(bool))); connect(dateTimeDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); tempAction = getGuiAction("actionShow_Search_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), searchDialog, SLOT(setVisible(bool))); connect(searchDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); tempAction = getGuiAction("actionShow_Shortcuts_Window_Global"); connect(tempAction, SIGNAL(toggled(bool)), shortcutsDialog, SLOT(setVisible(bool))); connect(shortcutsDialog, SIGNAL(visibleChanged(bool)), tempAction, SLOT(setChecked(bool))); connect(getGuiAction("actionSave_Screenshot_Global"), SIGNAL(triggered()), &StelMainGraphicsView::getInstance(), SLOT(saveScreenShot())); connect(getGuiAction("actionSave_Copy_Object_Information_Global"), SIGNAL(triggered()), this, SLOT(copySelectedObjectInfo())); getGuiAction("actionToggle_GuiHidden_Global")->setChecked(true); connect(getGuiAction("actionToggle_GuiHidden_Global"), SIGNAL(toggled(bool)), this, SLOT(setGuiVisible(bool))); connect(getGuiAction("actionHorizontal_Flip"), SIGNAL(toggled(bool)), StelApp::getInstance().getCore(), SLOT(setFlipHorz(bool))); getGuiAction("actionHorizontal_Flip")->setChecked(StelApp::getInstance().getCore()->getFlipHorz()); connect(getGuiAction("actionVertical_Flip"), SIGNAL(toggled(bool)), StelApp::getInstance().getCore(), SLOT(setFlipVert(bool))); getGuiAction("actionVertical_Flip")->setChecked(StelApp::getInstance().getCore()->getFlipVert()); StarMgr* smgr = GETSTELMODULE(StarMgr); connect(getGuiAction("actionShow_Stars"), SIGNAL(toggled(bool)), smgr, SLOT(setFlagStars(bool))); getGuiAction("actionShow_Stars")->setChecked(smgr->getFlagStars()); connect(getGuiAction("actionShow_Stars_Labels"), SIGNAL(toggled(bool)), smgr, SLOT(setFlagLabels(bool))); getGuiAction("actionShow_Stars_Labels")->setChecked(smgr->getFlagLabels()); SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); connect(getGuiAction("actionShow_Planets_Labels"), SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagLabels(bool))); getGuiAction("actionShow_Planets_Labels")->setChecked(ssmgr->getFlagLabels()); connect(getGuiAction("actionShow_Planets_Orbits"), SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagOrbits(bool))); getGuiAction("actionShow_Planets_Orbits")->setChecked(ssmgr->getFlagOrbits()); connect(getGuiAction("actionShow_Planets_Trails"), SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagTrails(bool))); getGuiAction("actionShow_Planets_Trails")->setChecked(ssmgr->getFlagTrails()); 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()); connect(getGuiAction("actionAutoHideHorizontalButtonBar"), SIGNAL(toggled(bool)), this, SLOT(setAutoHideHorizontalButtonBar(bool))); getGuiAction("actionAutoHideHorizontalButtonBar")->setChecked(getAutoHideHorizontalButtonBar()); connect(getGuiAction("actionAutoHideVerticalButtonBar"), SIGNAL(toggled(bool)), this, SLOT(setAutoHideVerticalButtonBar(bool))); getGuiAction("actionAutoHideVerticalButtonBar")->setChecked(getAutoHideVerticalButtonBar()); #ifndef DISABLE_SCRIPTING StelScriptMgr& scriptMgr = StelMainGraphicsView::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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("actionSwitch_Equatorial_Mount")); b->setChecked(getGuiAction("actionSwitch_Equatorial_Mount")->isChecked()); 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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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, getGuiAction("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); stelAppGraphicsWidget->setLayout(l); setStelStyle(StelApp::getInstance().getCurrentStelStyle()); skyGui->setGeometry(stelAppGraphicsWidget->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 = QApplication::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)); QApplication::setPalette(p); StelApp *app = &StelApp::getInstance(); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setStelStyle(const QString&))); initDone = true; }