// Update the widget to make sure it is synchrone if the location is changed programmatically void LocationDialog::updateFromProgram(const StelLocation& currentLocation) { if (!dialog->isVisible()) return; StelCore* stelCore = StelApp::getInstance().getCore(); isEditingNew = false; // Check that the use as default check box needs to be updated // Move to setFieldsFromLocation()? --BM? const bool b = currentLocation.getID() == stelCore->getDefaultLocationID(); QSettings* conf = StelApp::getInstance().getSettings(); if (conf->value("init_location/location", "auto").toString() != ("auto")) { updateDefaultLocationControls(b); ui->pushButtonReturnToDefault->setEnabled(!b); } const QString& key1 = currentLocation.getID(); const QString& key2 = locationFromFields().getID(); if (key1!=key2) { setFieldsFromLocation(currentLocation); } LandscapeMgr *lmgr = GETSTELMODULE(LandscapeMgr); if (lmgr->getFlagUseLightPollutionFromDatabase()) { int bidx = currentLocation.bortleScaleIndex; if (!currentLocation.planetName.contains("Earth")) // location not on Earth... bidx = 1; if (bidx<1) // ...or it observatory, or it unknown location bidx = currentLocation.DEFAULT_BORTLE_SCALE_INDEX; stelCore->getSkyDrawer()->setBortleScaleIndex(bidx); lmgr->setAtmosphereBortleLightPollution(bidx); } }
// Update the widget to make sure it is synchrone if the location is changed programmatically void LocationDialog::updateFromProgram() { if (!dialog->isVisible()) return; // Check that the use as default check box needs to be updated const bool b = StelApp::getInstance().getCore()->getCurrentLocation().getID() == StelApp::getInstance().getCore()->getDefaultLocationID(); if (b!=ui->useAsDefaultLocationCheckBox->isChecked()) { ui->useAsDefaultLocationCheckBox->setChecked(b); ui->useAsDefaultLocationCheckBox->setEnabled(!b); } SensorMgr* sensorMgr = (SensorMgr*)StelApp::getInstance().getModuleMgr().getModule("SensorMgr"); if(sensorMgr->getGpsPermitted()) { const bool bg = StelApp::getInstance().getCore()->getUseGPS(); ui->useGPScheckBox->setChecked(bg); } else { ui->useGPScheckBox->setChecked(false); ui->useGPScheckBox->setEnabled(false); } // removing this check and return... we might have the location changed // by a script or plugin, and as such we should update the map whenever the // location window is visible. if (isEditingNew==true) return; const QString& key1 = StelApp::getInstance().getCore()->getCurrentLocation().getID(); const QString& key2 = locationFromFields().getID(); if (key1!=key2) { setFieldsFromLocation(StelApp::getInstance().getCore()->getCurrentLocation()); } }