/* Init our module */ void Novae::init() { try { StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::getUserDir()+"/modules/Novae"); // If no settings in the main config file, create with defaults if (!conf->childGroups().contains("Novae")) { qDebug() << "Novae: no Novae section exists in main config file - creating with defaults"; restoreDefaultConfigIni(); } // populate settings from main config file. readSettingsFromConfig(); novaeJsonPath = StelFileMgr::findFile("modules/Novae", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/novae.json"; if (novaeJsonPath.isEmpty()) return; texPointer = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); addAction("actionShow_Novae_ConfigDialog", N_("Bright Novae"), N_("Bright Novae configuration window"), configDialog, "visible"); } catch (std::runtime_error &e) { qWarning() << "Novae: init error:" << e.what(); return; } // A timer for hiding alert messages messageTimer = new QTimer(this); messageTimer->setSingleShot(true); // recurring check for update messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->stop(); connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout())); // If the json file does not already exist, create it from the resource in the Qt resource if(QFileInfo(novaeJsonPath).exists()) { if (!checkJsonFileFormat() || getJsonFileVersion()<CATALOG_FORMAT_VERSION) { restoreDefaultJsonFile(); } } else { qDebug() << "Novae: novae.json does not exist - copying default file to" << QDir::toNativeSeparators(novaeJsonPath); restoreDefaultJsonFile(); } qDebug() << "Novae: loading catalog file:" << QDir::toNativeSeparators(novaeJsonPath); readJsonFile(); // Set up download manager and the update schedule downloadMgr = new QNetworkAccessManager(this); connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(updateDownloadComplete(QNetworkReply*))); updateState = CompleteNoUpdates; updateTimer = new QTimer(this); updateTimer->setSingleShot(false); // recurring check for update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate())); updateTimer->start(); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); }
void Satellites::init() { QSettings* conf = StelApp::getInstance().getSettings(); try { // TODO: Compatibility with installation-dir modules? --BM // It seems that the original code couldn't handle them either. QString dirPath = StelFileMgr::getUserDir() + "/modules/Satellites"; // TODO: Ideally, this should return a QDir object StelFileMgr::makeSureDirExistsAndIsWritable(dirPath); dataDir.setPath(dirPath); // If no settings in the main config file, create with defaults if (!conf->childGroups().contains("Satellites")) { //qDebug() << "Stellites: created section in config file."; restoreDefaultSettings(); } // populate settings from main config file. loadSettings(); // absolute file name for inner catalog of the satellites catalogPath = dataDir.absoluteFilePath("satellites.json"); // absolute file name for qs.mag file qsMagFilePath = dataDir.absoluteFilePath("qs.mag"); // Load and find resources used in the plugin texPointer = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png"); Satellite::hintTexture = StelApp::getInstance().getTextureManager().createTexture(":/satellites/hint.png"); // key bindings and other actions StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui()); QString satGroup = N_("Satellites"); addAction("actionShow_Satellite_Hints", satGroup, N_("Satellite hints"), "hintsVisible", "Ctrl+Z"); addAction("actionShow_Satellite_Labels", satGroup, N_("Satellite labels"), "labelsVisible", "Shift+Z"); addAction("actionShow_Satellite_ConfigDialog_Global", satGroup, N_("Satellites configuration window"), configDialog, "visible", "Alt+Z"); // Gui toolbar button toolbarButton = new StelButton(NULL, QPixmap(":/satellites/bt_satellites_on.png"), QPixmap(":/satellites/bt_satellites_off.png"), QPixmap(":/graphicGui/glow32x32.png"), "actionShow_Satellite_Hints"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGroup"); } catch (std::runtime_error &e) { qWarning() << "Satellites::init error: " << e.what(); return; } // A timer for hiding alert messages messageTimer = new QTimer(this); messageTimer->setSingleShot(true); // recurring check for update messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->stop(); connect(messageTimer, SIGNAL(timeout()), this, SLOT(hideMessages())); // If the json file does not already exist, create it from the resource in the QT resource if(QFileInfo(catalogPath).exists()) { if (!checkJsonFileFormat() || readCatalogVersion() != SATELLITES_PLUGIN_VERSION) { displayMessage(q_("The old satellites.json file is no longer compatible - using default file"), "#bb0000"); restoreDefaultCatalog(); } } else { qDebug() << "Satellites::init satellites.json does not exist - copying default file to " << QDir::toNativeSeparators(catalogPath); restoreDefaultCatalog(); } if(!QFileInfo(qsMagFilePath).exists()) { restoreDefaultQSMagFile(); } qDebug() << "Satellites: loading catalog file:" << QDir::toNativeSeparators(catalogPath); // create satellites according to content os satellites.json file loadCatalog(); // Set up download manager and the update schedule downloadMgr = new QNetworkAccessManager(this); connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(saveDownloadedUpdate(QNetworkReply*))); updateState = CompleteNoUpdates; updateTimer = new QTimer(this); updateTimer->setSingleShot(false); // recurring check for update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate())); updateTimer->start(); earth = GETSTELMODULE(SolarSystem)->getEarth(); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); // Handle changes to the observer location: connect(StelApp::getInstance().getCore(), SIGNAL(locationChanged(StelLocation)), this, SLOT(updateObserverLocation(StelLocation))); }
/* Init our module */ void Quasars::init() { upgradeConfigIni(); try { StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::getUserDir()+"/modules/Quasars"); // If no settings in the main config file, create with defaults if (!conf->childGroups().contains("Quasars")) { qDebug() << "Quasars: no Quasars section exists in main config file - creating with defaults"; restoreDefaultConfigIni(); } // populate settings from main config file. readSettingsFromConfig(); catalogJsonPath = StelFileMgr::findFile("modules/Quasars", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/quasars.json"; if (catalogJsonPath.isEmpty()) return; texPointer = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); Quasar::markerTexture = StelApp::getInstance().getTextureManager().createTexture(":/Quasars/quasar.png"); // key bindings and other actions addAction("actionShow_Quasars", N_("Quasars"), N_("Show quasars"), "quasarsVisible", "Ctrl+Alt+Q"); addAction("actionShow_Quasars_ConfigDialog", N_("Quasars"), N_("Quasars configuration window"), configDialog, "visible"); GlowIcon = new QPixmap(":/graphicGui/glow32x32.png"); OnIcon = new QPixmap(":/Quasars/btQuasars-on.png"); OffIcon = new QPixmap(":/Quasars/btQuasars-off.png"); setFlagShowQuasars(getEnableAtStartup()); setFlagShowQuasarsButton(flagShowQuasarsButton); } catch (std::runtime_error &e) { qWarning() << "Quasars: init error:" << e.what(); return; } // A timer for hiding alert messages messageTimer = new QTimer(this); messageTimer->setSingleShot(true); // recurring check for update messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->stop(); connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout())); // If the json file does not already exist, create it from the resource in the Qt resource if(QFileInfo(catalogJsonPath).exists()) { if (!checkJsonFileFormat() || getJsonFileFormatVersion()<CATALOG_FORMAT_VERSION) { restoreDefaultJsonFile(); } } else { qDebug() << "Quasars: quasars.json does not exist - copying default file to" << QDir::toNativeSeparators(catalogJsonPath); restoreDefaultJsonFile(); } qDebug() << "Quasars: loading catalog file:" << QDir::toNativeSeparators(catalogJsonPath); readJsonFile(); // Set up download manager and the update schedule downloadMgr = new QNetworkAccessManager(this); connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(updateDownloadComplete(QNetworkReply*))); updateState = CompleteNoUpdates; updateTimer = new QTimer(this); updateTimer->setSingleShot(false); // recurring check for update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate())); updateTimer->start(); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); }
/* Init our module */ void Supernovae::init() { try { StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::getUserDir()+"/modules/Supernovae"); // If no settings in the main config file, create with defaults if (!conf->childGroups().contains("Supernovae")) { qDebug() << "Supernovae::init no Supernovae section exists in main config file - creating with defaults"; restoreDefaultConfigIni(); } // populate settings from main config file. readSettingsFromConfig(); sneJsonPath = StelFileMgr::findFile("modules/Supernovae", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/supernovae.json"; // key bindings and other actions StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui()); connect(gui->getGuiAction("actionShow_Supernovae_ConfigDialog"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool))); connect(configDialog, SIGNAL(visibleChanged(bool)), gui->getGuiAction("actionShow_Supernovae_ConfigDialog"), SLOT(setChecked(bool))); } catch (std::runtime_error &e) { qWarning() << "Supernovas::init error: " << e.what(); return; } // A timer for hiding alert messages messageTimer = new QTimer(this); messageTimer->setSingleShot(true); // recurring check for update messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->stop(); connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout())); // If the json file does not already exist, create it from the resource in the Qt resource if(QFileInfo(sneJsonPath).exists()) { if (!checkJsonFileFormat() || getJsonFileVersion()<CATALOG_FORMAT_VERSION) { restoreDefaultJsonFile(); } } else { qDebug() << "Supernovae::init supernovae.json does not exist - copying default file to " << QDir::toNativeSeparators(sneJsonPath); restoreDefaultJsonFile(); } qDebug() << "Supernovae::init using file: " << QDir::toNativeSeparators(sneJsonPath); readJsonFile(); // Set up download manager and the update schedule downloadMgr = new QNetworkAccessManager(this); connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(updateDownloadComplete(QNetworkReply*))); updateState = CompleteNoUpdates; updateTimer = new QTimer(this); updateTimer->setSingleShot(false); // recurring check for update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate())); updateTimer->start(); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); }