ConfigurationDialog.cpp   ConfigurationDialog.cpp 
skipping to change at line 30 skipping to change at line 30
#include "Dialog.hpp" #include "Dialog.hpp"
#include "ConfigurationDialog.hpp" #include "ConfigurationDialog.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelMainWindow.hpp" #include "StelMainWindow.hpp"
#include "ui_configurationDialog.h" #include "ui_configurationDialog.h"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "Projector.hpp" #include "StelProjector.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "MovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "SkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "Location.hpp" #include "StelLocation.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "MeteorMgr.hpp" #include "MeteorMgr.hpp"
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "StelScriptMgr.hpp"
#include "StelDownloadMgr.hpp"
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QFrame>
#include <QFile> #include <QFile>
#include <QFileDialog>
#include "StelAppGraphicsScene.hpp" #include "StelAppGraphicsScene.hpp"
ConfigurationDialog::ConfigurationDialog() ConfigurationDialog::ConfigurationDialog()
{ {
ui = new Ui_configurationDialogForm; ui = new Ui_configurationDialogForm;
downloadMgr = &StelApp::getInstance().getDownloadMgr();
updatesData = NULL;
StelFileMgr& fileMgr = StelApp::getInstance().getFileMgr();
starsDir = fileMgr.getUserDir()+"/stars/default";
if(!fileMgr.exists(starsDir))
fileMgr.mkDir(starsDir);
downloaded = 0;
} }
ConfigurationDialog::~ConfigurationDialog() ConfigurationDialog::~ConfigurationDialog()
{ {
delete ui; delete ui;
if(updatesData != NULL)
delete updatesData;
} }
void ConfigurationDialog::languageChanged() void ConfigurationDialog::languageChanged()
{ {
if (dialog) if (dialog)
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
} }
void ConfigurationDialog::styleChanged() void ConfigurationDialog::styleChanged()
{ {
// Nothing for now // Nothing for now
} }
void ConfigurationDialog::createDialogContent() void ConfigurationDialog::createDialogContent()
{ {
Projector* proj = StelApp::getInstance().getCore()->getProjection(); const StelProjectorP proj = StelApp::getInstance().getCore()->getPro
Navigator* nav = StelApp::getInstance().getCore()->getNavigation(); jection(Mat4d());
MovementMgr* mvmgr = (MovementMgr*)GETSTELMODULE("MovementMgr"); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator(
);
StelMovementMgr* mvmgr = (StelMovementMgr*)GETSTELMODULE("StelMoveme
ntMgr");
StelGui* gui = (StelGui*)GETSTELMODULE("StelGui"); StelGui* gui = (StelGui*)GETSTELMODULE("StelGui");
ui->setupUi(dialog); ui->setupUi(dialog);
// Set the main tab activated by default // Set the main tab activated by default
ui->configurationTabWidget->setCurrentIndex(0); ui->configurationTabWidget->setCurrentIndex(0);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
// Main tab // Main tab
// Fill the language list widget from the available list // Fill the language list widget from the available list
// QListWidget* c = ui->programLanguageListWidget;
// c->clear();
// c->addItems(Translator::globalTranslator.getAvailableLanguagesNamesN
ative(StelApp::getInstance().getFileMgr().getLocaleDir()));
//
// QString l = Translator::iso639_1CodeToNativeName(appLang);
// QList<QListWidgetItem*> litem = c->findItems(l, Qt::MatchExactly);
// if (litem.empty() && appLang.contains('_'))
// {
// l = appLang.left(appLang.indexOf('_'));
// l=Translator::iso639_1CodeToNativeName(l);
// litem = c->findItems(l, Qt::MatchExactly);
// }
// if (!litem.empty())
// c->setCurrentItem(litem.at(0));
// connect(c, SIGNAL(currentTextChanged(const QString&)), this, SLOT(la
nguageChanged(const QString&)));
QString appLang = StelApp::getInstance().getLocaleMgr().getAppLangua ge(); QString appLang = StelApp::getInstance().getLocaleMgr().getAppLangua ge();
QComboBox* cb = ui->programLanguageComboBox; QComboBox* cb = ui->programLanguageComboBox;
cb->clear(); cb->clear();
cb->addItems(Translator::globalTranslator.getAvailableLanguagesNames cb->addItems(StelTranslator::globalTranslator.getAvailableLanguagesN
Native(StelApp::getInstance().getFileMgr().getLocaleDir())); amesNative(StelApp::getInstance().getFileMgr().getLocaleDir()));
QString l2 = Translator::iso639_1CodeToNativeName(appLang); QString l2 = StelTranslator::iso639_1CodeToNativeName(appLang);
int lt = cb->findText(l2, Qt::MatchExactly); int lt = cb->findText(l2, Qt::MatchExactly);
if (lt == -1 && appLang.contains('_')) if (lt == -1 && appLang.contains('_'))
{ {
l2 = appLang.left(appLang.indexOf('_')); l2 = appLang.left(appLang.indexOf('_'));
l2=Translator::iso639_1CodeToNativeName(l2); l2=StelTranslator::iso639_1CodeToNativeName(l2);
lt = cb->findText(l2, Qt::MatchExactly); lt = cb->findText(l2, Qt::MatchExactly);
} }
if (lt!=-1) if (lt!=-1)
cb->setCurrentIndex(lt); cb->setCurrentIndex(lt);
connect(cb, SIGNAL(currentIndexChanged(const QString&)), this, SLOT( languageChanged(const QString&))); connect(cb, SIGNAL(currentIndexChanged(const QString&)), this, SLOT( languageChanged(const QString&)));
starSettings = ((StarMgr*)GETSTELMODULE("StarMgr"))->getStarSettings
();
connect(ui->getStarsButton, SIGNAL(clicked(void)), this, SLOT(downlo
adStars(void)));
connect(ui->downloadCancelButton, SIGNAL(clicked(void)), this, SLOT(
cancelDownload(void)));
connect(ui->downloadRetryButton, SIGNAL(clicked(void)), this, SLOT(r
etryDownload(void)));
checkUpdates();
// Selected object info // Selected object info
if (gui->getInfoPanel()->getInfoTextFilters() == (StelObject::InfoSt ringGroup)0) if (gui->getInfoPanel()->getInfoTextFilters() == (StelObject::InfoSt ringGroup)0)
ui->noSelectedInfoRadio->setChecked(true); ui->noSelectedInfoRadio->setChecked(true);
else if (gui->getInfoPanel()->getInfoTextFilters() == StelObject::In foStringGroup(StelObject::ShortInfo)) else if (gui->getInfoPanel()->getInfoTextFilters() == StelObject::In foStringGroup(StelObject::ShortInfo))
ui->briefSelectedInfoRadio->setChecked(true); ui->briefSelectedInfoRadio->setChecked(true);
else else
ui->allSelectedInfoRadio->setChecked(true); ui->allSelectedInfoRadio->setChecked(true);
connect(ui->noSelectedInfoRadio, SIGNAL(released()), this, SLOT(setN oSelectedInfo())); connect(ui->noSelectedInfoRadio, SIGNAL(released()), this, SLOT(setN oSelectedInfo()));
connect(ui->allSelectedInfoRadio, SIGNAL(released()), this, SLOT(set AllSelectedInfo())); connect(ui->allSelectedInfoRadio, SIGNAL(released()), this, SLOT(set AllSelectedInfo()));
connect(ui->briefSelectedInfoRadio, SIGNAL(released()), this, SLOT(s etBriefSelectedInfo())); connect(ui->briefSelectedInfoRadio, SIGNAL(released()), this, SLOT(s etBriefSelectedInfo()));
skipping to change at line 157 skipping to change at line 160
ui->todayTimeSpinBox->setTime(nav->getInitTodayTime()); ui->todayTimeSpinBox->setTime(nav->getInitTodayTime());
connect(ui->todayTimeSpinBox, SIGNAL(timeChanged(QTime)), nav, SLOT( setInitTodayTime(QTime))); connect(ui->todayTimeSpinBox, SIGNAL(timeChanged(QTime)), nav, SLOT( setInitTodayTime(QTime)));
ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(nav->get PresetSkyTime())); ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(nav->get PresetSkyTime()));
connect(ui->fixedDateTimeEdit, SIGNAL(dateTimeChanged(QDateTime)), n av, SLOT(setPresetSkyTime(QDateTime))); connect(ui->fixedDateTimeEdit, SIGNAL(dateTimeChanged(QDateTime)), n av, SLOT(setPresetSkyTime(QDateTime)));
ui->enableKeysNavigationCheckBox->setChecked(mvmgr->getFlagEnableMov eKeys() || mvmgr->getFlagEnableZoomKeys()); ui->enableKeysNavigationCheckBox->setChecked(mvmgr->getFlagEnableMov eKeys() || mvmgr->getFlagEnableZoomKeys());
ui->enableMouseNavigationCheckBox->setChecked(mvmgr->getFlagEnableMo useNavigation()); ui->enableMouseNavigationCheckBox->setChecked(mvmgr->getFlagEnableMo useNavigation());
connect(ui->enableKeysNavigationCheckBox, SIGNAL(toggled(bool)), mvm gr, SLOT(setFlagEnableMoveKeys(bool))); connect(ui->enableKeysNavigationCheckBox, SIGNAL(toggled(bool)), mvm gr, SLOT(setFlagEnableMoveKeys(bool)));
connect(ui->enableKeysNavigationCheckBox, SIGNAL(toggled(bool)), mvm gr, SLOT(setFlagEnableZoomKeys(bool))); connect(ui->enableKeysNavigationCheckBox, SIGNAL(toggled(bool)), mvm gr, SLOT(setFlagEnableZoomKeys(bool)));
connect(ui->enableMouseNavigationCheckBox, SIGNAL(toggled(bool)), mv mgr, SLOT(setFlagEnableMouseNavigation(bool))); connect(ui->enableMouseNavigationCheckBox, SIGNAL(toggled(bool)), mv mgr, SLOT(setFlagEnableMouseNavigation(bool)));
connect(ui->fixedDateTimeCurrentButton, SIGNAL(clicked()), this, SLO T(setFixedDateTimeToCurrent()));
// Tools tab // Tools tab
ConstellationMgr* cmgr = (ConstellationMgr*)GETSTELMODULE("Constella
tionMgr");
Q_ASSERT(cmgr);
ui->sphericMirrorCheckbox->setChecked(StelAppGraphicsScene::getInsta nce().getViewPortDistorterType() == "fisheye_to_spheric_mirror"); ui->sphericMirrorCheckbox->setChecked(StelAppGraphicsScene::getInsta nce().getViewPortDistorterType() == "fisheye_to_spheric_mirror");
connect(ui->sphericMirrorCheckbox, SIGNAL(toggled(bool)), this, SLOT (setSphericMirror(bool))); connect(ui->sphericMirrorCheckbox, SIGNAL(toggled(bool)), this, SLOT (setSphericMirror(bool)));
ui->gravityLabelCheckbox->setChecked(proj->getFlagGravityLabels()); ui->gravityLabelCheckbox->setChecked(proj->getFlagGravityLabels());
connect(ui->gravityLabelCheckbox, SIGNAL(toggled(bool)), proj, SLOT( connect(ui->gravityLabelCheckbox, SIGNAL(toggled(bool)), StelApp::ge
setFlagGravityLabels(bool))); tInstance().getCore(), SLOT(setFlagGravityLabels(bool)));
ui->discViewportCheckbox->setChecked(proj->getMaskType() == Projecto ui->selectSingleConstellationButton->setChecked(cmgr->getFlagIsolate
r::Disk); Selected());
connect(ui->selectSingleConstellationButton, SIGNAL(toggled(bool)),
cmgr, SLOT(setFlagIsolateSelected(bool)));
ui->discViewportCheckbox->setChecked(proj->getMaskType() == StelProj
ector::MaskDisk);
connect(ui->discViewportCheckbox, SIGNAL(toggled(bool)), this, SLOT( setDiskViewport(bool))); connect(ui->discViewportCheckbox, SIGNAL(toggled(bool)), this, SLOT( setDiskViewport(bool)));
ui->autoZoomResetsDirectionCheckbox->setChecked(mvmgr->getFlagAutoZo omOutResetsDirection()); ui->autoZoomResetsDirectionCheckbox->setChecked(mvmgr->getFlagAutoZo omOutResetsDirection());
connect(ui->autoZoomResetsDirectionCheckbox, SIGNAL(toggled(bool)), mvmgr, SLOT(setFlagAutoZoomOutResetsDirection(bool))); connect(ui->autoZoomResetsDirectionCheckbox, SIGNAL(toggled(bool)), mvmgr, SLOT(setFlagAutoZoomOutResetsDirection(bool)));
ui->showFlipButtonsCheckbox->setChecked(gui->getFlagShowFlipButtons( )); ui->showFlipButtonsCheckbox->setChecked(gui->getFlagShowFlipButtons( ));
connect(ui->showFlipButtonsCheckbox, SIGNAL(toggled(bool)), gui, SLO T(setFlagShowFlipButtons(bool))); connect(ui->showFlipButtonsCheckbox, SIGNAL(toggled(bool)), gui, SLO T(setFlagShowFlipButtons(bool)));
ui->mouseTimeoutCheckbox->setChecked(StelAppGraphicsScene::getInstan ce().getFlagCursorTimeout()); ui->mouseTimeoutCheckbox->setChecked(StelAppGraphicsScene::getInstan ce().getFlagCursorTimeout());
ui->mouseTimeoutSpinBox->setValue(StelAppGraphicsScene::getInstance( ).getCursorTimeout()); ui->mouseTimeoutSpinBox->setValue(StelAppGraphicsScene::getInstance( ).getCursorTimeout());
connect(ui->mouseTimeoutCheckbox, SIGNAL(clicked()), this, SLOT(curs orTimeOutChanged())); connect(ui->mouseTimeoutCheckbox, SIGNAL(clicked()), this, SLOT(curs orTimeOutChanged()));
connect(ui->mouseTimeoutCheckbox, SIGNAL(toggled(bool)), this, SLOT( cursorTimeOutChanged())); connect(ui->mouseTimeoutCheckbox, SIGNAL(toggled(bool)), this, SLOT( cursorTimeOutChanged()));
connect(ui->mouseTimeoutSpinBox, SIGNAL(valueChanged(double)), this, SLOT(cursorTimeOutChanged(double))); connect(ui->mouseTimeoutSpinBox, SIGNAL(valueChanged(double)), this, SLOT(cursorTimeOutChanged(double)));
connect(ui->setViewingOptionAsDefaultPushButton, SIGNAL(clicked()), this, SLOT(saveCurrentViewOptions())); connect(ui->setViewingOptionAsDefaultPushButton, SIGNAL(clicked()), this, SLOT(saveCurrentViewOptions()));
//connect(ui->resetAlloptionsPushButton, SIGNAL(clicked()), this, SL connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(set
OT(resetAllOptions())); DefaultViewOptions()));
ui->screenshotDirEdit->setText(StelApp::getInstance().getFileMgr().g
etScreenshotDir());
connect(ui->screenshotDirEdit, SIGNAL(textChanged(QString)), this, S
LOT(selectScreenshotDir(QString)));
connect(ui->screenshotBrowseButton, SIGNAL(clicked()), this, SLOT(br
owseForScreenshotDir()));
ui->invertScreenShotColorsCheckBox->setChecked(StelMainGraphicsView:
:getInstance().getFlagInvertScreenShotColors());
connect(ui->invertScreenShotColorsCheckBox, SIGNAL(toggled(bool)), &
StelMainGraphicsView::getInstance(), SLOT(setFlagInvertScreenShotColors(boo
l)));
// script tab controls
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr();
connect(ui->scriptListWidget, SIGNAL(currentTextChanged(const QStrin
g&)), this, SLOT(scriptSelectionChanged(const QString&)));
connect(ui->runScriptButton, SIGNAL(clicked()), this, SLOT(runScript
Clicked()));
connect(ui->stopScriptButton, SIGNAL(clicked()), this, SLOT(stopScri
ptClicked()));
if (scriptMgr.scriptIsRunning())
aScriptIsRunning();
else
aScriptHasStopped();
connect(&scriptMgr, SIGNAL(scriptRunning()), this, SLOT(aScriptIsRun
ning()));
connect(&scriptMgr, SIGNAL(scriptStopped()), this, SLOT(aScriptHasSt
opped()));
ui->scriptListWidget->setSortingEnabled(true);
populateScriptsList();
connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(populateScrip
tsList()));
updateConfigLabels(); updateConfigLabels();
} }
void ConfigurationDialog::languageChanged(const QString& langName) void ConfigurationDialog::languageChanged(const QString& langName)
{ {
StelApp::getInstance().getLocaleMgr().setAppLanguage(Translator::nat QString code = StelTranslator::nativeNameToIso639_1Code(langName);
iveNameToIso639_1Code(langName)); StelApp::getInstance().getLocaleMgr().setAppLanguage(code);
StelApp::getInstance().getLocaleMgr().setSkyLanguage(Translator::nat StelApp::getInstance().getLocaleMgr().setSkyLanguage(code);
iveNameToIso639_1Code(langName)); updateConfigLabels();
} }
void ConfigurationDialog::setStartupTimeMode(void) void ConfigurationDialog::setStartupTimeMode(void)
{ {
Navigator* nav = StelApp::getInstance().getCore()->getNavigation(); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Q_ASSERT(nav); Q_ASSERT(nav);
if (ui->systemTimeRadio->isChecked()) if (ui->systemTimeRadio->isChecked())
StelApp::getInstance().getCore()->getNavigation()->setStartu pTimeMode("actual"); StelApp::getInstance().getCore()->getNavigator()->setStartup TimeMode("actual");
else if (ui->todayRadio->isChecked()) else if (ui->todayRadio->isChecked())
StelApp::getInstance().getCore()->getNavigation()->setStartu pTimeMode("today"); StelApp::getInstance().getCore()->getNavigator()->setStartup TimeMode("today");
else else
StelApp::getInstance().getCore()->getNavigation()->setStartu pTimeMode("preset"); StelApp::getInstance().getCore()->getNavigator()->setStartup TimeMode("preset");
nav->setInitTodayTime(ui->todayTimeSpinBox->time()); nav->setInitTodayTime(ui->todayTimeSpinBox->time());
nav->setPresetSkyTime(ui->fixedDateTimeEdit->dateTime()); nav->setPresetSkyTime(ui->fixedDateTimeEdit->dateTime());
} }
void ConfigurationDialog::setDiskViewport(bool b) void ConfigurationDialog::setDiskViewport(bool b)
{ {
Projector* proj = StelApp::getInstance().getCore()->getProjection();
assert(proj);
if (b) if (b)
proj->setMaskType(Projector::Disk); StelApp::getInstance().getCore()->setMaskType(StelProjector: :MaskDisk);
else else
proj->setMaskType(Projector::None); StelApp::getInstance().getCore()->setMaskType(StelProjector: :MaskNone);
} }
void ConfigurationDialog::setSphericMirror(bool b) void ConfigurationDialog::setSphericMirror(bool b)
{ {
if (b) if (b)
StelAppGraphicsScene::getInstance().setViewPortDistorterType ("fisheye_to_spheric_mirror"); StelAppGraphicsScene::getInstance().setViewPortDistorterType ("fisheye_to_spheric_mirror");
else else
StelAppGraphicsScene::getInstance().setViewPortDistorterType ("none"); StelAppGraphicsScene::getInstance().setViewPortDistorterType ("none");
} }
void ConfigurationDialog::setNoSelectedInfo(void) void ConfigurationDialog::setNoSelectedInfo(void)
{ {
StelGui* newGui = (StelGui*)GETSTELMODULE("StelGui"); StelGui* newGui = (StelGui*)GETSTELMODULE("StelGui");
assert(newGui); Q_ASSERT(newGui);
newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro up(0)); newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro up(0));
} }
void ConfigurationDialog::setAllSelectedInfo(void) void ConfigurationDialog::setAllSelectedInfo(void)
{ {
StelGui* newGui = (StelGui*)GETSTELMODULE("StelGui"); StelGui* newGui = (StelGui*)GETSTELMODULE("StelGui");
assert(newGui); Q_ASSERT(newGui);
newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro up(StelObject::AllInfo)); newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro up(StelObject::AllInfo));
} }
void ConfigurationDialog::setBriefSelectedInfo(void) void ConfigurationDialog::setBriefSelectedInfo(void)
{ {
StelGui* newGui = (StelGui*)GETSTELMODULE("StelGui"); StelGui* newGui = (StelGui*)GETSTELMODULE("StelGui");
assert(newGui); Q_ASSERT(newGui);
newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro up(StelObject::ShortInfo)); newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro up(StelObject::ShortInfo));
} }
void ConfigurationDialog::cursorTimeOutChanged() void ConfigurationDialog::cursorTimeOutChanged()
{ {
StelAppGraphicsScene::getInstance().setFlagCursorTimeout(ui->mouseTi meoutCheckbox->isChecked()); StelAppGraphicsScene::getInstance().setFlagCursorTimeout(ui->mouseTi meoutCheckbox->isChecked());
StelAppGraphicsScene::getInstance().setCursorTimeout(ui->mouseTimeou tSpinBox->value()); StelAppGraphicsScene::getInstance().setCursorTimeout(ui->mouseTimeou tSpinBox->value());
} }
void ConfigurationDialog::browseForScreenshotDir()
{
QString oldScreenshorDir = StelApp::getInstance().getFileMgr().getSc
reenshotDir();
QString newScreenshotDir = QFileDialog::getExistingDirectory(NULL, q
_("Select screenshot directory"), oldScreenshorDir, QFileDialog::ShowDirsOn
ly);
if (!newScreenshotDir.isEmpty()) {
// remove trailing slash
if (newScreenshotDir.right(1) == "/")
newScreenshotDir = newScreenshotDir.left(newScreensh
otDir.length()-1);
ui->screenshotDirEdit->setText(newScreenshotDir);
}
}
void ConfigurationDialog::selectScreenshotDir(const QString& dir)
{
try
{
StelApp::getInstance().getFileMgr().setScreenshotDir(dir);
}
catch (std::runtime_error& e)
{
// nop
// this will happen when people are only half way through ty
ping dirs
}
}
// Save the current viewing option including landscape, location and sky cu lture // Save the current viewing option including landscape, location and sky cu lture
// This doesn't include the current viewing direction, time and FOV since t hose have specific controls // This doesn't include the current viewing direction, time and FOV since t hose have specific controls
void ConfigurationDialog::saveCurrentViewOptions() void ConfigurationDialog::saveCurrentViewOptions()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
LandscapeMgr* lmgr = (LandscapeMgr*)GETSTELMODULE("LandscapeMgr"); LandscapeMgr* lmgr = (LandscapeMgr*)GETSTELMODULE("LandscapeMgr");
Q_ASSERT(lmgr); Q_ASSERT(lmgr);
SolarSystem* ssmgr = (SolarSystem*)GETSTELMODULE("SolarSystem"); SolarSystem* ssmgr = (SolarSystem*)GETSTELMODULE("SolarSystem");
Q_ASSERT(ssmgr); Q_ASSERT(ssmgr);
MeteorMgr* mmgr = (MeteorMgr*)GETSTELMODULE("MeteorMgr"); MeteorMgr* mmgr = (MeteorMgr*)GETSTELMODULE("MeteorMgr");
Q_ASSERT(mmgr); Q_ASSERT(mmgr);
SkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer(); StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer ();
Q_ASSERT(skyd); Q_ASSERT(skyd);
ConstellationMgr* cmgr = (ConstellationMgr*)GETSTELMODULE("Constella tionMgr"); ConstellationMgr* cmgr = (ConstellationMgr*)GETSTELMODULE("Constella tionMgr");
Q_ASSERT(cmgr); Q_ASSERT(cmgr);
StarMgr* smgr = (StarMgr*)GETSTELMODULE("StarMgr"); StarMgr* smgr = (StarMgr*)GETSTELMODULE("StarMgr");
Q_ASSERT(smgr); Q_ASSERT(smgr);
NebulaMgr* nmgr = (NebulaMgr*)GETSTELMODULE("NebulaMgr"); NebulaMgr* nmgr = (NebulaMgr*)GETSTELMODULE("NebulaMgr");
Q_ASSERT(nmgr); Q_ASSERT(nmgr);
GridLinesMgr* glmgr = (GridLinesMgr*)GETSTELMODULE("GridLinesMgr"); GridLinesMgr* glmgr = (GridLinesMgr*)GETSTELMODULE("GridLinesMgr");
Q_ASSERT(glmgr); Q_ASSERT(glmgr);
StelGui* gui = (StelGui*)GETSTELMODULE("StelGui"); StelGui* gui = (StelGui*)GETSTELMODULE("StelGui");
Q_ASSERT(gui); Q_ASSERT(gui);
MovementMgr* mvmgr = (MovementMgr*)GETSTELMODULE("MovementMgr"); StelMovementMgr* mvmgr = (StelMovementMgr*)GETSTELMODULE("StelMoveme ntMgr");
Q_ASSERT(mvmgr); Q_ASSERT(mvmgr);
Navigator* nav = StelApp::getInstance().getCore()->getNavigation(); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Q_ASSERT(nav); Q_ASSERT(nav);
Projector* proj = StelApp::getInstance().getCore()->getProjection(); const StelProjectorP proj = StelApp::getInstance().getCore()->getPro jection(Mat4d());
Q_ASSERT(proj); Q_ASSERT(proj);
// view dialog / sky tab settings // view dialog / sky tab settings
conf->setValue("stars/absolute_scale", skyd->getAbsoluteStarScale()) ; conf->setValue("stars/absolute_scale", skyd->getAbsoluteStarScale()) ;
conf->setValue("stars/relative_scale", skyd->getRelativeStarScale()) ; conf->setValue("stars/relative_scale", skyd->getRelativeStarScale()) ;
conf->setValue("stars/flag_star_twinkle", skyd->getFlagTwinkle()); conf->setValue("stars/flag_star_twinkle", skyd->getFlagTwinkle());
conf->setValue("stars/star_twinkle_amount", skyd->getTwinkleAmount() ); conf->setValue("stars/star_twinkle_amount", skyd->getTwinkleAmount() );
conf->setValue("viewing/use_luminance_adaptation", skyd->getFlagLumi nanceAdaptation()); conf->setValue("viewing/use_luminance_adaptation", skyd->getFlagLumi nanceAdaptation());
conf->setValue("astro/flag_planets", ssmgr->getFlagPlanets()); conf->setValue("astro/flag_planets", ssmgr->getFlagPlanets());
conf->setValue("astro/flag_planets_hints", ssmgr->getFlagHints()); conf->setValue("astro/flag_planets_hints", ssmgr->getFlagHints());
conf->setValue("astro/flag_planets_orbits", ssmgr->getFlagOrbits()); conf->setValue("astro/flag_planets_orbits", ssmgr->getFlagOrbits());
conf->setValue("astro/flag_light_travel_time", ssmgr->getFlagLightTr avelTime()); conf->setValue("astro/flag_light_travel_time", ssmgr->getFlagLightTr avelTime());
conf->setValue("viewing/flag_moon_scaled", ssmgr->getFlagMoonScale() ); conf->setValue("viewing/flag_moon_scaled", ssmgr->getFlagMoonScale() );
conf->setValue("astro/meteor_rate", mmgr->getZHR()); conf->setValue("astro/meteor_rate", mmgr->getZHR());
// view dialog / markings tab settings // view dialog / markings tab settings
conf->setValue("viewing/flag_azimutal_grid", glmgr->getFlagAzimutalG rid()); conf->setValue("viewing/flag_azimuthal_grid", glmgr->getFlagAzimutha lGrid());
conf->setValue("viewing/flag_equatorial_grid", glmgr->getFlagEquator Grid()); conf->setValue("viewing/flag_equatorial_grid", glmgr->getFlagEquator Grid());
conf->setValue("viewing/flag_equator_line", glmgr->getFlagEquatorLin e()); conf->setValue("viewing/flag_equator_line", glmgr->getFlagEquatorLin e());
conf->setValue("viewing/flag_ecliptic_line", glmgr->getFlagEclipticL ine()); conf->setValue("viewing/flag_ecliptic_line", glmgr->getFlagEclipticL ine());
conf->setValue("viewing/flag_meridian_line", glmgr->getFlagMeridianL ine()); conf->setValue("viewing/flag_meridian_line", glmgr->getFlagMeridianL ine());
conf->setValue("viewing/flag_equatorial_J2000_grid", glmgr->getFlagE quatorJ2000Grid()); conf->setValue("viewing/flag_equatorial_J2000_grid", glmgr->getFlagE quatorJ2000Grid());
conf->setValue("viewing/flag_cardinal_points", lmgr->getFlagCardinal sPoints()); conf->setValue("viewing/flag_cardinal_points", lmgr->getFlagCardinal sPoints());
conf->setValue("viewing/flag_constellation_drawing", cmgr->getFlagLi nes()); conf->setValue("viewing/flag_constellation_drawing", cmgr->getFlagLi nes());
conf->setValue("viewing/flag_constellation_name", cmgr->getFlagLabel s()); conf->setValue("viewing/flag_constellation_name", cmgr->getFlagLabel s());
conf->setValue("viewing/flag_constellation_boundaries", cmgr->getFla gBoundaries()); conf->setValue("viewing/flag_constellation_boundaries", cmgr->getFla gBoundaries());
conf->setValue("viewing/flag_constellation_art", cmgr->getFlagArt()) ; conf->setValue("viewing/flag_constellation_art", cmgr->getFlagArt()) ;
conf->setValue("viewing/flag_constellation_isolate_selected", cmgr-> getFlagIsolateSelected());
conf->setValue("viewing/constellation_art_intensity", cmgr->getArtIn tensity()); conf->setValue("viewing/constellation_art_intensity", cmgr->getArtIn tensity());
conf->setValue("astro/flag_star_name", smgr->getFlagLabels()); conf->setValue("astro/flag_star_name", smgr->getFlagLabels());
conf->setValue("stars/labels_amount", smgr->getLabelsAmount()); conf->setValue("stars/labels_amount", smgr->getLabelsAmount());
conf->setValue("astro/flag_planets_labels", ssmgr->getFlagLabels()); conf->setValue("astro/flag_planets_labels", ssmgr->getFlagLabels());
conf->setValue("astro/labels_amount", ssmgr->getLabelsAmount()); conf->setValue("astro/labels_amount", ssmgr->getLabelsAmount());
conf->setValue("astro/nebula_hints_amount", nmgr->getHintsAmount()); conf->setValue("astro/nebula_hints_amount", nmgr->getHintsAmount());
conf->setValue("astro/flag_nebula_name", nmgr->getFlagHints()); conf->setValue("astro/flag_nebula_name", nmgr->getFlagHints());
conf->setValue("projection/type", StelApp::getInstance().getCore()-> getProjection()->getCurrentMapping().getId()); conf->setValue("projection/type", StelApp::getInstance().getCore()-> getCurrentProjectionTypeKey());
// view dialog / landscape tab settings // view dialog / landscape tab settings
lmgr->setDefaultLandscapeID(lmgr->getCurrentLandscapeID()); lmgr->setDefaultLandscapeID(lmgr->getCurrentLandscapeID());
conf->setValue("landscape/flag_landscape_sets_location", lmgr->getFl agLandscapeSetsLocation()); conf->setValue("landscape/flag_landscape_sets_location", lmgr->getFl agLandscapeSetsLocation());
conf->setValue("landscape/flag_landscape", lmgr->getFlagLandscape()) ; conf->setValue("landscape/flag_landscape", lmgr->getFlagLandscape()) ;
conf->setValue("landscape/flag_atmosphere", lmgr->getFlagAtmosphere( )); conf->setValue("landscape/flag_atmosphere", lmgr->getFlagAtmosphere( ));
conf->setValue("landscape/flag_fog", lmgr->getFlagFog()); conf->setValue("landscape/flag_fog", lmgr->getFlagFog());
conf->setValue("stars/init_bortle_scale", StelApp::getInstance().get Core()->getSkyDrawer()->getBortleScale()); conf->setValue("stars/init_bortle_scale", StelApp::getInstance().get Core()->getSkyDrawer()->getBortleScale());
// view dialog / starlore tab // view dialog / starlore tab
StelApp::getInstance().getSkyCultureMgr().setDefaultSkyCultureID(Ste lApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID()); StelApp::getInstance().getSkyCultureMgr().setDefaultSkyCultureID(Ste lApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID());
// Save default location // Save default location
StelApp::getInstance().getCore()->getNavigation()->setDefaultLocatio nID(StelApp::getInstance().getCore()->getNavigation()->getCurrentLocation() .getID()); nav->setDefaultLocationID(nav->getCurrentLocation().getID());
// configuration dialog / main tab // configuration dialog / main tab
QString langName = StelApp::getInstance().getLocaleMgr().getAppLangu age(); QString langName = StelApp::getInstance().getLocaleMgr().getAppLangu age();
conf->setValue("localization/app_locale", Translator::nativeNameToIs conf->setValue("localization/app_locale", StelTranslator::nativeName
o639_1Code(langName)); ToIso639_1Code(langName));
langName = StelApp::getInstance().getLocaleMgr().getSkyLanguage();
conf->setValue("localization/sky_locale", StelTranslator::nativeName
ToIso639_1Code(langName));
if (gui->getInfoPanel()->getInfoTextFilters() == (StelObject::InfoSt ringGroup)0) if (gui->getInfoPanel()->getInfoTextFilters() == (StelObject::InfoSt ringGroup)0)
conf->setValue("gui/selected_object_info", "none"); conf->setValue("gui/selected_object_info", "none");
else if (gui->getInfoPanel()->getInfoTextFilters() == StelObject::In foStringGroup(StelObject::ShortInfo)) else if (gui->getInfoPanel()->getInfoTextFilters() == StelObject::In foStringGroup(StelObject::ShortInfo))
conf->setValue("gui/selected_object_info", "short"); conf->setValue("gui/selected_object_info", "short");
else else
conf->setValue("gui/selected_object_info", "all"); conf->setValue("gui/selected_object_info", "all");
// toolbar auto-hide status
conf->setValue("gui/auto_hide_horizontal_toolbar", gui->getAutoHideH
orizontalButtonBar());
conf->setValue("gui/auto_hide_vertical_toolbar", gui->getAutoHideVer
ticalButtonBar());
mvmgr->setInitFov(StelApp::getInstance().getCore()->getMovementMgr()
->getCurrentFov());
StelApp::getInstance().getCore()->getNavigator()->setInitViewDirecti
onToCurrent();
// configuration dialog / navigation tab // configuration dialog / navigation tab
conf->setValue("navigation/flag_enable_zoom_keys", mvmgr->getFlagEna bleZoomKeys()); conf->setValue("navigation/flag_enable_zoom_keys", mvmgr->getFlagEna bleZoomKeys());
conf->setValue("navigation/flag_enable_mouse_navigation", mvmgr->get FlagEnableMouseNavigation()); conf->setValue("navigation/flag_enable_mouse_navigation", mvmgr->get FlagEnableMouseNavigation());
conf->setValue("navigation/flag_enable_move_keys", mvmgr->getFlagEna bleMoveKeys()); conf->setValue("navigation/flag_enable_move_keys", mvmgr->getFlagEna bleMoveKeys());
conf->setValue("navigation/startup_time_mode", nav->getStartupTimeMo de()); conf->setValue("navigation/startup_time_mode", nav->getStartupTimeMo de());
conf->setValue("navigation/today_time", nav->getInitTodayTime()); conf->setValue("navigation/today_time", nav->getInitTodayTime());
conf->setValue("navigation/preset_sky_time", nav->getPresetSkyTime() ); conf->setValue("navigation/preset_sky_time", nav->getPresetSkyTime() );
conf->setValue("navigation/init_fov", proj->getInitFov()); conf->setValue("navigation/init_fov", mvmgr->getInitFov());
if (nav->getMountMode() == StelNavigator::MountAltAzimuthal)
conf->setValue("navigation/viewing_mode", "horizon");
else
conf->setValue("navigation/viewing_mode", "equator");
// configuration dialog / tools tab // configuration dialog / tools tab
conf->setValue("gui/flag_show_flip_buttons", gui->getFlagShowFlipBut tons()); conf->setValue("gui/flag_show_flip_buttons", gui->getFlagShowFlipBut tons());
conf->setValue("video/distorter", StelAppGraphicsScene::getInstance( ).getViewPortDistorterType()); conf->setValue("video/distorter", StelAppGraphicsScene::getInstance( ).getViewPortDistorterType());
conf->setValue("projection/viewport", Projector::maskTypeToString(pr oj->getMaskType())); conf->setValue("projection/viewport", StelProjector::maskTypeToStrin g(proj->getMaskType()));
conf->setValue("viewing/flag_gravity_labels", proj->getFlagGravityLa bels()); conf->setValue("viewing/flag_gravity_labels", proj->getFlagGravityLa bels());
conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->g etFlagAutoZoomOutResetsDirection()); conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->g etFlagAutoZoomOutResetsDirection());
conf->setValue("gui/flag_mouse_cursor_timeout", StelAppGraphicsScene ::getInstance().getFlagCursorTimeout()); conf->setValue("gui/flag_mouse_cursor_timeout", StelAppGraphicsScene ::getInstance().getFlagCursorTimeout());
conf->setValue("gui/mouse_cursor_timeout", StelAppGraphicsScene::get Instance().getCursorTimeout()); conf->setValue("gui/mouse_cursor_timeout", StelAppGraphicsScene::get Instance().getCursorTimeout());
StelApp::getInstance().getCore()->getProjection()->setInitFov(StelAp conf->setValue("main/screenshot_dir", StelApp::getInstance().getFile
p::getInstance().getCore()->getProjection()->getFov()); Mgr().getScreenshotDir());
StelApp::getInstance().getCore()->getNavigation()->setInitViewDirect
ionToCurrent();
// full screen and window size // full screen and window size
conf->setValue("video/fullscreen", StelMainWindow::getInstance().get FullScreen()); conf->setValue("video/fullscreen", StelMainWindow::getInstance().get FullScreen());
if (!StelMainWindow::getInstance().getFullScreen()) if (!StelMainWindow::getInstance().getFullScreen())
{ {
conf->setValue("video/screen_w", StelMainWindow::getInstance ().size().width()); conf->setValue("video/screen_w", StelMainWindow::getInstance ().size().width());
conf->setValue("video/screen_h", StelMainWindow::getInstance ().size().height()); conf->setValue("video/screen_h", StelMainWindow::getInstance ().size().height());
} }
// clear the restore defaults flag if it is set.
conf->setValue("main/restore_defaults", false);
updateConfigLabels(); updateConfigLabels();
} }
void ConfigurationDialog::updateConfigLabels() void ConfigurationDialog::updateConfigLabels()
{ {
ui->startupFOVLabel->setText(q_("Startup FOV: %1%2").arg(StelApp::ge tInstance().getCore()->getProjection()->getFov()).arg(QChar(0x00B0))); ui->startupFOVLabel->setText(q_("Startup FOV: %1%2").arg(StelApp::ge tInstance().getCore()->getMovementMgr()->getCurrentFov()).arg(QChar(0x00B0) ));
double az, alt; double az, alt;
const Vec3d v = StelApp::getInstance().getCore()->getNavigation()->g etInitViewingDirection(); const Vec3d v = StelApp::getInstance().getCore()->getNavigator()->ge tInitViewingDirection();
StelUtils::rectToSphe(&az, &alt, v); StelUtils::rectToSphe(&az, &alt, v);
az = 3.*M_PI - az; // N is zero, E is 90 degrees az = 3.*M_PI - az; // N is zero, E is 90 degrees
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
ui->startupDirectionOfViewlabel->setText(q_("Startup direction of vi ew Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(a lt))); ui->startupDirectionOfViewlabel->setText(q_("Startup direction of vi ew Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(a lt)));
// Not a very nice way to update the text
checkUpdates();
}
void ConfigurationDialog::setDefaultViewOptions()
{
QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("main/restore_defaults", true);
}
void ConfigurationDialog::populateScriptsList(void)
{
int prevSel = ui->scriptListWidget->currentRow();
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr();
ui->scriptListWidget->clear();
ui->scriptListWidget->addItems(scriptMgr.getScriptList());
// If we had a valid previous selection (i.e. not first time we popu
late), restore it
if (prevSel >= 0 && prevSel < ui->scriptListWidget->count())
ui->scriptListWidget->setCurrentRow(prevSel);
else
ui->scriptListWidget->setCurrentRow(0);
}
void ConfigurationDialog::scriptSelectionChanged(const QString& s)
{
if (s.isEmpty() || s=="")
return;
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr();
//ui->scriptInfoBrowser->document()->setDefaultStyleSheet(QString(St
elApp::getInstance().getCurrentStelStyle()->htmlStyleSheet));
QString html = "<html><head></head><body>";
html += "<h2>" + scriptMgr.getName(s) + "</h2>";
html += "<h3>" + q_("Author") + ": " + scriptMgr.getAuthor(s) + "</h
3>";
html += "<h3>" + q_("License") + ": " + scriptMgr.getLicense(s) + "<
/h3>";
QString d = scriptMgr.getDescription(s);
d.replace("\n", "<br />");
html += "<p>" + d + "</p>";
html += "</body></html>";
ui->scriptInfoBrowser->setHtml(html);
}
void ConfigurationDialog::runScriptClicked(void)
{
if (ui->closeWindowAtScriptRunCheckbox->isChecked())
this->close();
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr();
if (ui->scriptListWidget->currentItem())
{
ui->runScriptButton->setEnabled(false);
ui->stopScriptButton->setEnabled(true);
scriptMgr.runScript(ui->scriptListWidget->currentItem()->tex
t());
}
}
void ConfigurationDialog::stopScriptClicked(void)
{
StelApp::getInstance().getScriptMgr().stopScript();
}
void ConfigurationDialog::aScriptIsRunning(void)
{
ui->scriptStatusLabel->setText(q_("Running script: ") + StelApp::get
Instance().getScriptMgr().runningScriptId());
ui->runScriptButton->setEnabled(false);
ui->stopScriptButton->setEnabled(true);
}
void ConfigurationDialog::aScriptHasStopped(void)
{
ui->scriptStatusLabel->setText(q_("Running script: [none]"));
ui->runScriptButton->setEnabled(true);
ui->stopScriptButton->setEnabled(false);
}
void ConfigurationDialog::setUpdatesState(ConfigurationDialog::UpdatesState
state)
{
// everything invisible by default
ui->getStarsButton->setVisible(false);
ui->downloadLabel->setText("");
ui->downloadCancelButton->setVisible(false);
ui->downloadRetryButton->setVisible(false);
switch(state)
{
case ConfigurationDialog::ShowAvailable:
Q_ASSERT(updatesData);
if(newCatalogs.size()-downloaded > 0)
{
QString cat = newCatalogs.at(downloaded);
ui->getStarsButton->setVisible(true);
ui->getStarsButton->setText(q_("Get catalog
%1 of %2").arg(downloaded+1).arg(newCatalogs.size()));
ui->downloadLabel->setText(q_("Download size
: %1MB\nStar count: %2\nMagnitude range: %3 - %4")
.arg(updatesData->value(cat+"/size")
.toString())
.arg(updatesData->value(cat+"/count"
).toString())
.arg(updatesData->value(cat+"/mag_lo
wer").toString())
.arg(updatesData->value(cat+"/mag_up
per").toString()));
} else
setUpdatesState(ConfigurationDialog::Finishe
d);
break;
case ConfigurationDialog::Checking:
ui->downloadLabel->setText(q_("Checking for new star
catalogs..."));
break;
case ConfigurationDialog::NoUpdates:
ui->downloadLabel->setText(q_("All star catalogs are
up to date."));
break;
case ConfigurationDialog::Downloading:
ui->downloadLabel->setText(q_("Downloading %1...\n(Y
ou can close this window.)").arg(downloadName));
ui->downloadCancelButton->setVisible(true);
break;
case ConfigurationDialog::Finished:
ui->downloadLabel->setText(q_("Finished downloading
new star catalogs!\nRestart Stellarium to display them."));
break;
case ConfigurationDialog::Verifying:
ui->downloadLabel->setText(q_("Verifying file integr
ity..."));
break;
case ConfigurationDialog::UpdatesError:
ui->downloadLabel->setText(q_("Error checking update
s:\n%1").arg(downloadMgr->errorString()));
ui->downloadRetryButton->setVisible(true);
break;
case ConfigurationDialog::MoveError:
ui->downloadLabel->setText(q_("Could not finalize do
wnload:\nError moving temporary file %1.tmp to %1.cat").arg(downloadName));
break;
case ConfigurationDialog::DownloadError:
ui->downloadLabel->setText(q_("Error downloading %1:
\n%2").arg(downloadName).arg(downloadMgr->errorString()));
ui->downloadRetryButton->setVisible(true);
break;
case ConfigurationDialog::ChecksumError:
ui->downloadLabel->setText(q_("Error downloading %1:
\nFile is corrupted.").arg(downloadName));
ui->downloadRetryButton->setVisible(true);
break;
}
}
void ConfigurationDialog::updatesDownloadError(QNetworkReply::NetworkError
code, QString errorString)
{
qDebug() << "Error checking updates from" << downloadMgr->url() << "
: Code" << code << errorString;
setUpdatesState(ConfigurationDialog::UpdatesError);
}
void ConfigurationDialog::updatesDownloadFinished(void)
{
newCatalogs.clear();
updatesData = new QSettings(updatesFileName, QSettings::IniFormat);
updatesData->beginGroup("extra_stars");
QListIterator<QString> it(updatesData->childKeys());
// For some reason, updatesData->childGroups() doesn't work at
// all in this case. The workaround is to list the groups as key-val
ue pairs.
while(it.hasNext())
{
QString catName = updatesData->value(it.next()).toString();
bool catPathExists = !starSettings->value(catName+"/path",""
).toString().isEmpty();
if(!catPathExists)
newCatalogs.append(catName);
}
if(newCatalogs.size() > 0)
setUpdatesState(ConfigurationDialog::ShowAvailable);
else
setUpdatesState(ConfigurationDialog::NoUpdates);
}
void ConfigurationDialog::checkUpdates(void)
{
setUpdatesState(ConfigurationDialog::Checking);
updatesFileName = starsDir+"/updates.ini";
downloadMgr->setBarVisible(false);
downloadMgr->setBlockQuit(false);
downloadMgr->get(starSettings->value("updates_url").toString(), upda
tesFileName);
connect(downloadMgr, SIGNAL(finished()), this, SLOT(updatesDownloadF
inished()));
connect(downloadMgr, SIGNAL(error(QNetworkReply::NetworkError, QStri
ng)), this, SLOT(updatesDownloadError(QNetworkReply::NetworkError, QString)
));
}
void ConfigurationDialog::cancelDownload(void)
{
downloadMgr->abort();
setUpdatesState(ConfigurationDialog::ShowAvailable);
}
void ConfigurationDialog::retryDownload(void)
{
if(!updatesData)
checkUpdates();
else
downloadStars();
}
void ConfigurationDialog::downloadError(QNetworkReply::NetworkError code, Q
String errorString)
{
qDebug() << "Error downloading file" << downloadMgr->url() << ": Cod
e " << code << errorString;
setUpdatesState(ConfigurationDialog::DownloadError);
}
void ConfigurationDialog::downloadVerifying(void)
{
setUpdatesState(ConfigurationDialog::Verifying);
}
void ConfigurationDialog::badChecksum(void)
{
qDebug() << "Error downloading file" << downloadMgr->url() << ": Fil
e is corrupted.";
setUpdatesState(ConfigurationDialog::ChecksumError);
}
void ConfigurationDialog::downloadFinished(void)
{
downloaded++;
QString tempFileName = starsDir+"/"+downloadName+".tmp";
QString finalFileName = starsDir+"/"+downloadName+".cat";
if( ( QFile::exists(finalFileName) && !QFile::remove(finalFileName)
) ||
!QFile::copy(tempFileName, finalFileName) ||
!QFile::remove(tempFileName))
{
qDebug() << "Error moving" << tempFileName << "to" << finalF
ileName;
setUpdatesState(ConfigurationDialog::MoveError);
}
else
{
starSettings->setValue(downloadName+"/path", downloadName+".
cat");
setUpdatesState(ConfigurationDialog::ShowAvailable);
}
}
void ConfigurationDialog::downloadStars(void)
{
Q_ASSERT(updatesData);
downloadMgr->disconnect();
downloadName = newCatalogs.at(downloaded);
QString url = updatesData->value(downloadName+"/url").toString();
QString path = QString("%1/%2.tmp").arg(starsDir).arg(downloadName);
quint16 checksum = updatesData->value(downloadName+"/checksum").toUI
nt();
downloadMgr->setBarVisible(true);
downloadMgr->setBlockQuit(true);
downloadMgr->setBarFormat(QString("%p%: %1 of %2").arg(downloaded+1)
.arg(newCatalogs.size()));
downloadMgr->get(url, path, checksum);
connect(downloadMgr, SIGNAL(finished()), this, SLOT(downloadFinished
()));
connect(downloadMgr, SIGNAL(error(QNetworkReply::NetworkError, QStri
ng)), this, SLOT(downloadError(QNetworkReply::NetworkError, QString)));
connect(downloadMgr, SIGNAL(verifying()), this, SLOT(downloadVerifyi
ng()));
connect(downloadMgr, SIGNAL(badChecksum()), this, SLOT(badChecksum()
));
setUpdatesState(ConfigurationDialog::Downloading);
} }
// Reset all stellarium options. void ConfigurationDialog::setFixedDateTimeToCurrent(void)
// This basically replaces the config.ini by the default one
void ConfigurationDialog::resetAllOptions()
{ {
ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(StelApp:
:getInstance().getCore()->getNavigator()->getJDay()));
ui->fixedTimeRadio->setChecked(true);
setStartupTimeMode();
} }
 End of changes. 49 change blocks. 
72 lines changed or deleted 474 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/