ConfigurationDialog.cpp   ConfigurationDialog.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#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 "StelAppGraphicsWidget.hpp"
#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 "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
skipping to change at line 47 skipping to change at line 48
#include "StelLocation.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 "StelScriptMgr.hpp"
#include "StelDownloadMgr.hpp" #include "LabelMgr.hpp"
#include "ScreenImageMgr.hpp"
#include "SkyGui.hpp"
#include "StelJsonParser.hpp"
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include "StelAppGraphicsScene.hpp" ConfigurationDialog::ConfigurationDialog(StelGui* agui) : starCatalogDownlo
adReply(NULL), currentDownloadFile(NULL), progressBar(NULL), gui(agui)
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()
{ {
const StelProjectorP proj = StelApp::getInstance().getCore()->getPro jection(Mat4d()); const StelProjectorP proj = StelApp::getInstance().getCore()->getPro jection(Mat4d());
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( ); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
StelGui* gui = 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->configurationStackedWidget->setCurrentIndex(0);
ui->stackListWidget->setCurrentRow(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
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(StelTranslator::globalTranslator.getAvailableLanguagesN amesNative(StelApp::getInstance().getFileMgr().getLocaleDir())); cb->addItems(StelTranslator::globalTranslator.getAvailableLanguagesN amesNative(StelFileMgr::getLocaleDir()));
QString l2 = StelTranslator::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=StelTranslator::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 = GETSTELMODULE(StarMgr)->getStarSettings(); connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadSt
ars()));
connect(ui->getStarsButton, SIGNAL(clicked(void)), this, SLOT(downlo connect(ui->downloadCancelButton, SIGNAL(clicked()), this, SLOT(canc
adStars(void))); elDownload()));
connect(ui->downloadCancelButton, SIGNAL(clicked(void)), this, SLOT( connect(ui->downloadRetryButton, SIGNAL(clicked()), this, SLOT(downl
cancelDownload(void))); oadStars()));
connect(ui->downloadRetryButton, SIGNAL(clicked(void)), this, SLOT(r refreshStarCatalogButton();
etryDownload(void)));
checkUpdates();
// Selected object info // Selected object info
if (gui->getInfoPanel()->getInfoTextFilters() == (StelObject::InfoSt ringGroup)0) if (gui->getInfoTextFilters() == (StelObject::InfoStringGroup)0)
ui->noSelectedInfoRadio->setChecked(true); ui->noSelectedInfoRadio->setChecked(true);
else if (gui->getInfoPanel()->getInfoTextFilters() == StelObject::In foStringGroup(StelObject::ShortInfo)) else if (gui->getInfoTextFilters() == StelObject::InfoStringGroup(St elObject::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()));
// Navigation tab // Navigation tab
// Startup time // Startup time
if (nav->getStartupTimeMode()=="actual") if (nav->getStartupTimeMode()=="actual")
skipping to change at line 164 skipping to change at line 154
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())); connect(ui->fixedDateTimeCurrentButton, SIGNAL(clicked()), this, SLO T(setFixedDateTimeToCurrent()));
// Tools tab // Tools tab
ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr);
Q_ASSERT(cmgr); Q_ASSERT(cmgr);
ui->sphericMirrorCheckbox->setChecked(StelAppGraphicsScene::getInsta nce().getViewPortDistorterType() == "fisheye_to_spheric_mirror"); ui->sphericMirrorCheckbox->setChecked(StelMainGraphicsView::getInsta nce().getStelAppGraphicsWidget()->getViewportEffect() == "sphericMirrorDist orter");
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)), StelApp::ge tInstance().getCore(), SLOT(setFlagGravityLabels(bool))); connect(ui->gravityLabelCheckbox, SIGNAL(toggled(bool)), StelApp::ge tInstance().getCore(), SLOT(setFlagGravityLabels(bool)));
ui->selectSingleConstellationButton->setChecked(cmgr->getFlagIsolate Selected()); ui->selectSingleConstellationButton->setChecked(cmgr->getFlagIsolate Selected());
connect(ui->selectSingleConstellationButton, SIGNAL(toggled(bool)), cmgr, SLOT(setFlagIsolateSelected(bool))); connect(ui->selectSingleConstellationButton, SIGNAL(toggled(bool)), cmgr, SLOT(setFlagIsolateSelected(bool)));
ui->discViewportCheckbox->setChecked(proj->getMaskType() == StelProj ui->diskViewportCheckbox->setChecked(proj->getMaskType() == StelProj
ector::MaskDisk); ector::MaskDisk);
connect(ui->discViewportCheckbox, SIGNAL(toggled(bool)), this, SLOT( connect(ui->diskViewportCheckbox, SIGNAL(toggled(bool)), this, SLOT(
setDiskViewport(bool))); 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 ui->mouseTimeoutCheckbox->setChecked(StelMainGraphicsView::getInstan
ce().getFlagCursorTimeout()); ce().getFlagCursorTimeout());
ui->mouseTimeoutSpinBox->setValue(StelAppGraphicsScene::getInstance( ui->mouseTimeoutSpinBox->setValue(StelMainGraphicsView::getInstance(
).getCursorTimeout()); ).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->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(set DefaultViewOptions())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(set DefaultViewOptions()));
ui->screenshotDirEdit->setText(StelApp::getInstance().getFileMgr().g etScreenshotDir()); ui->screenshotDirEdit->setText(StelFileMgr::getScreenshotDir());
connect(ui->screenshotDirEdit, SIGNAL(textChanged(QString)), this, S LOT(selectScreenshotDir(QString))); connect(ui->screenshotDirEdit, SIGNAL(textChanged(QString)), this, S LOT(selectScreenshotDir(QString)));
connect(ui->screenshotBrowseButton, SIGNAL(clicked()), this, SLOT(br owseForScreenshotDir())); connect(ui->screenshotBrowseButton, SIGNAL(clicked()), this, SLOT(br owseForScreenshotDir()));
ui->invertScreenShotColorsCheckBox->setChecked(StelMainGraphicsView: :getInstance().getFlagInvertScreenShotColors()); ui->invertScreenShotColorsCheckBox->setChecked(StelMainGraphicsView: :getInstance().getFlagInvertScreenShotColors());
connect(ui->invertScreenShotColorsCheckBox, SIGNAL(toggled(bool)), & StelMainGraphicsView::getInstance(), SLOT(setFlagInvertScreenShotColors(boo l))); connect(ui->invertScreenShotColorsCheckBox, SIGNAL(toggled(bool)), & StelMainGraphicsView::getInstance(), SLOT(setFlagInvertScreenShotColors(boo l)));
// script tab controls // script tab controls
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); StelScriptMgr& scriptMgr = StelMainGraphicsView::getInstance().getSc riptMgr();
connect(ui->scriptListWidget, SIGNAL(currentTextChanged(const QStrin g&)), this, SLOT(scriptSelectionChanged(const QString&))); connect(ui->scriptListWidget, SIGNAL(currentTextChanged(const QStrin g&)), this, SLOT(scriptSelectionChanged(const QString&)));
connect(ui->runScriptButton, SIGNAL(clicked()), this, SLOT(runScript Clicked())); connect(ui->runScriptButton, SIGNAL(clicked()), this, SLOT(runScript Clicked()));
connect(ui->stopScriptButton, SIGNAL(clicked()), this, SLOT(stopScri ptClicked())); connect(ui->stopScriptButton, SIGNAL(clicked()), this, SLOT(stopScri ptClicked()));
if (scriptMgr.scriptIsRunning()) if (scriptMgr.scriptIsRunning())
aScriptIsRunning(); aScriptIsRunning();
else else
aScriptHasStopped(); aScriptHasStopped();
connect(&scriptMgr, SIGNAL(scriptRunning()), this, SLOT(aScriptIsRun ning())); connect(&scriptMgr, SIGNAL(scriptRunning()), this, SLOT(aScriptIsRun ning()));
connect(&scriptMgr, SIGNAL(scriptStopped()), this, SLOT(aScriptHasSt opped())); connect(&scriptMgr, SIGNAL(scriptStopped()), this, SLOT(aScriptHasSt opped()));
ui->scriptListWidget->setSortingEnabled(true); ui->scriptListWidget->setSortingEnabled(true);
populateScriptsList(); populateScriptsList();
connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(populateScrip tsList())); connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(populateScrip tsList()));
// plugins control
connect(ui->pluginsListWidget, SIGNAL(currentTextChanged(const QStri
ng&)), this, SLOT(pluginsSelectionChanged(const QString&)));
connect(ui->pluginLoadAtStartupCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(loadAtStartupChanged(int)));
connect(ui->pluginConfigureButton, SIGNAL(clicked()), this, SLOT(plu
ginConfigureCurrentSelection()));
populatePluginsList();
connect(ui->stackListWidget, SIGNAL(currentItemChanged(QListWidgetIt
em *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWi
dgetItem*)));
updateConfigLabels(); updateConfigLabels();
} }
void ConfigurationDialog::languageChanged(const QString& langName) void ConfigurationDialog::languageChanged(const QString& langName)
{ {
QString code = StelTranslator::nativeNameToIso639_1Code(langName); QString code = StelTranslator::nativeNameToIso639_1Code(langName);
StelApp::getInstance().getLocaleMgr().setAppLanguage(code); StelApp::getInstance().getLocaleMgr().setAppLanguage(code);
StelApp::getInstance().getLocaleMgr().setSkyLanguage(code); StelApp::getInstance().getLocaleMgr().setSkyLanguage(code);
updateConfigLabels(); updateConfigLabels();
StelMainWindow::getInstance().initTitleI18n();
} }
void ConfigurationDialog::setStartupTimeMode(void) void ConfigurationDialog::setStartupTimeMode(void)
{ {
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( ); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Q_ASSERT(nav); Q_ASSERT(nav);
if (ui->systemTimeRadio->isChecked()) if (ui->systemTimeRadio->isChecked())
StelApp::getInstance().getCore()->getNavigator()->setStartup TimeMode("actual"); StelApp::getInstance().getCore()->getNavigator()->setStartup TimeMode("actual");
else if (ui->todayRadio->isChecked()) else if (ui->todayRadio->isChecked())
skipping to change at line 247 skipping to change at line 244
void ConfigurationDialog::setDiskViewport(bool b) void ConfigurationDialog::setDiskViewport(bool b)
{ {
if (b) if (b)
StelApp::getInstance().getCore()->setMaskType(StelProjector: :MaskDisk); StelApp::getInstance().getCore()->setMaskType(StelProjector: :MaskDisk);
else else
StelApp::getInstance().getCore()->setMaskType(StelProjector: :MaskNone); StelApp::getInstance().getCore()->setMaskType(StelProjector: :MaskNone);
} }
void ConfigurationDialog::setSphericMirror(bool b) void ConfigurationDialog::setSphericMirror(bool b)
{ {
StelCore* core = StelApp::getInstance().getCore();
if (b) if (b)
StelAppGraphicsScene::getInstance().setViewPortDistorterType {
("fisheye_to_spheric_mirror"); savedProjectionType = core->getCurrentProjectionType();
core->setCurrentProjectionType(StelCore::ProjectionFisheye);
StelMainGraphicsView::getInstance().getStelAppGraphicsWidget
()->setViewportEffect("sphericMirrorDistorter");
}
else else
StelAppGraphicsScene::getInstance().setViewPortDistorterType {
("none"); core->setCurrentProjectionType((StelCore::ProjectionType)sav
edProjectionType);
StelMainGraphicsView::getInstance().getStelAppGraphicsWidget
()->setViewportEffect("none");
}
} }
void ConfigurationDialog::setNoSelectedInfo(void) void ConfigurationDialog::setNoSelectedInfo(void)
{ {
StelGui* newGui = GETSTELMODULE(StelGui); gui->setInfoTextFilters(StelObject::InfoStringGroup(0));
Q_ASSERT(newGui);
newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro
up(0));
} }
void ConfigurationDialog::setAllSelectedInfo(void) void ConfigurationDialog::setAllSelectedInfo(void)
{ {
StelGui* newGui = GETSTELMODULE(StelGui); gui->setInfoTextFilters(StelObject::InfoStringGroup(StelObject::AllI
Q_ASSERT(newGui); nfo));
newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro
up(StelObject::AllInfo));
} }
void ConfigurationDialog::setBriefSelectedInfo(void) void ConfigurationDialog::setBriefSelectedInfo(void)
{ {
StelGui* newGui = GETSTELMODULE(StelGui); gui->setInfoTextFilters(StelObject::InfoStringGroup(StelObject::Shor
Q_ASSERT(newGui); tInfo));
newGui->getInfoPanel()->setInfoTextFilters(StelObject::InfoStringGro
up(StelObject::ShortInfo));
} }
void ConfigurationDialog::cursorTimeOutChanged() void ConfigurationDialog::cursorTimeOutChanged()
{ {
StelAppGraphicsScene::getInstance().setFlagCursorTimeout(ui->mouseTi StelMainGraphicsView::getInstance().setFlagCursorTimeout(ui->mouseTi
meoutCheckbox->isChecked()); meoutCheckbox->isChecked());
StelAppGraphicsScene::getInstance().setCursorTimeout(ui->mouseTimeou StelMainGraphicsView::getInstance().setCursorTimeout(ui->mouseTimeou
tSpinBox->value()); tSpinBox->value());
} }
void ConfigurationDialog::browseForScreenshotDir() void ConfigurationDialog::browseForScreenshotDir()
{ {
QString oldScreenshorDir = StelApp::getInstance().getFileMgr().getSc reenshotDir(); QString oldScreenshorDir = StelFileMgr::getScreenshotDir();
QString newScreenshotDir = QFileDialog::getExistingDirectory(NULL, q _("Select screenshot directory"), oldScreenshorDir, QFileDialog::ShowDirsOn ly); QString newScreenshotDir = QFileDialog::getExistingDirectory(NULL, q _("Select screenshot directory"), oldScreenshorDir, QFileDialog::ShowDirsOn ly);
if (!newScreenshotDir.isEmpty()) { if (!newScreenshotDir.isEmpty()) {
// remove trailing slash // remove trailing slash
if (newScreenshotDir.right(1) == "/") if (newScreenshotDir.right(1) == "/")
newScreenshotDir = newScreenshotDir.left(newScreensh otDir.length()-1); newScreenshotDir = newScreenshotDir.left(newScreensh otDir.length()-1);
ui->screenshotDirEdit->setText(newScreenshotDir); ui->screenshotDirEdit->setText(newScreenshotDir);
} }
} }
void ConfigurationDialog::selectScreenshotDir(const QString& dir) void ConfigurationDialog::selectScreenshotDir(const QString& dir)
{ {
try try
{ {
StelApp::getInstance().getFileMgr().setScreenshotDir(dir); StelFileMgr::setScreenshotDir(dir);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
// nop // nop
// this will happen when people are only half way through ty ping dirs // 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
skipping to change at line 330 skipping to change at line 329
StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer (); StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer ();
Q_ASSERT(skyd); Q_ASSERT(skyd);
ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr);
Q_ASSERT(cmgr); Q_ASSERT(cmgr);
StarMgr* smgr = GETSTELMODULE(StarMgr); StarMgr* smgr = GETSTELMODULE(StarMgr);
Q_ASSERT(smgr); Q_ASSERT(smgr);
NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr); NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr);
Q_ASSERT(nmgr); Q_ASSERT(nmgr);
GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr); GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr);
Q_ASSERT(glmgr); Q_ASSERT(glmgr);
StelGui* gui = GETSTELMODULE(StelGui);
Q_ASSERT(gui);
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mvmgr); Q_ASSERT(mvmgr);
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( ); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Q_ASSERT(nav); Q_ASSERT(nav);
const StelProjectorP proj = StelApp::getInstance().getCore()->getPro jection(Mat4d()); 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()) ;
skipping to change at line 394 skipping to change at line 391
// Save default location // Save default location
nav->setDefaultLocationID(nav->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", StelTranslator::nativeName ToIso639_1Code(langName)); conf->setValue("localization/app_locale", StelTranslator::nativeName ToIso639_1Code(langName));
langName = StelApp::getInstance().getLocaleMgr().getSkyLanguage(); langName = StelApp::getInstance().getLocaleMgr().getSkyLanguage();
conf->setValue("localization/sky_locale", StelTranslator::nativeName ToIso639_1Code(langName)); conf->setValue("localization/sky_locale", StelTranslator::nativeName ToIso639_1Code(langName));
if (gui->getInfoPanel()->getInfoTextFilters() == (StelObject::InfoSt ringGroup)0) if (gui->getInfoTextFilters() == (StelObject::InfoStringGroup)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->getInfoTextFilters() == StelObject::InfoStringGroup(St elObject::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 // toolbar auto-hide status
conf->setValue("gui/auto_hide_horizontal_toolbar", gui->getAutoHideH orizontalButtonBar()); conf->setValue("gui/auto_hide_horizontal_toolbar", gui->getAutoHideH orizontalButtonBar());
conf->setValue("gui/auto_hide_vertical_toolbar", gui->getAutoHideVer ticalButtonBar()); conf->setValue("gui/auto_hide_vertical_toolbar", gui->getAutoHideVer ticalButtonBar());
mvmgr->setInitFov(StelApp::getInstance().getCore()->getMovementMgr() mvmgr->setInitFov(mvmgr->getCurrentFov());
->getCurrentFov()); mvmgr->setInitViewDirectionToCurrent();
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", mvmgr->getInitFov()); conf->setValue("navigation/init_fov", mvmgr->getInitFov());
if (nav->getMountMode() == StelNavigator::MountAltAzimuthal) if (mvmgr->getMountMode() == StelMovementMgr::MountAltAzimuthal)
conf->setValue("navigation/viewing_mode", "horizon"); conf->setValue("navigation/viewing_mode", "horizon");
else else
conf->setValue("navigation/viewing_mode", "equator"); 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/viewport_effect", StelMainGraphicsView::getIns tance().getStelAppGraphicsWidget()->getViewportEffect());
conf->setValue("projection/viewport", StelProjector::maskTypeToStrin g(proj->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 conf->setValue("gui/flag_mouse_cursor_timeout", StelMainGraphicsView
::getInstance().getFlagCursorTimeout()); ::getInstance().getFlagCursorTimeout());
conf->setValue("gui/mouse_cursor_timeout", StelAppGraphicsScene::get conf->setValue("gui/mouse_cursor_timeout", StelMainGraphicsView::get
Instance().getCursorTimeout()); Instance().getCursorTimeout());
conf->setValue("main/screenshot_dir", StelApp::getInstance().getFile conf->setValue("main/screenshot_dir", StelFileMgr::getScreenshotDir(
Mgr().getScreenshotDir()); ));
conf->setValue("main/invert_screenshots_colors", StelMainGraphicsVie
w::getInstance().getFlagInvertScreenShotColors());
// 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. // clear the restore defaults flag if it is set.
conf->setValue("main/restore_defaults", false); 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()->getMovementMgr()->getCurrentFov()).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()->getNavigator()->ge tInitViewingDirection(); const Vec3d& v = GETSTELMODULE(StelMovementMgr)->getInitViewingDirec tion();
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() void ConfigurationDialog::setDefaultViewOptions()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
conf->setValue("main/restore_defaults", true); conf->setValue("main/restore_defaults", true);
} }
void ConfigurationDialog::populatePluginsList()
{
int prevSel = ui->pluginsListWidget->currentRow();
ui->pluginsListWidget->clear();
const QList<StelModuleMgr::PluginDescriptor> pluginsList = StelApp::
getInstance().getModuleMgr().getPluginsList();
foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList)
{
ui->pluginsListWidget->addItem(desc.info.displayedName);
}
// If we had a valid previous selection (i.e. not first time we popu
late), restore it
if (prevSel >= 0 && prevSel < ui->pluginsListWidget->count())
ui->pluginsListWidget->setCurrentRow(prevSel);
else
ui->pluginsListWidget->setCurrentRow(0);
}
void ConfigurationDialog::pluginsSelectionChanged(const QString& s)
{
const QList<StelModuleMgr::PluginDescriptor> pluginsList = StelApp::
getInstance().getModuleMgr().getPluginsList();
foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList)
{
if (s==desc.info.displayedName)
{
QString html = "<html><head></head><body>";
html += "<h2>" + desc.info.displayedName + "</h2>";
html += "<h3>" + q_("Authors") + ": " + desc.info.au
thors + "</h3>";
QString d = desc.info.description;
d.replace("\n", "<br />");
html += "<p>" + d + "</p>";
html += "<h3>" + q_("Contact") + ": " + desc.info.co
ntact + "</h3>";
html += "</body></html>";
ui->pluginsInfoBrowser->setHtml(html);
ui->pluginLoadAtStartupCheckBox->setChecked(desc.loa
dAtStartup);
StelModule* pmod = StelApp::getInstance().getModuleM
gr().getModule(desc.info.id, true);
if (pmod != NULL)
ui->pluginConfigureButton->setEnabled(pmod->
configureGui(false));
else
ui->pluginConfigureButton->setEnabled(false)
;
return;
}
}
}
void ConfigurationDialog::pluginConfigureCurrentSelection(void)
{
QString s = ui->pluginsListWidget->currentItem()->text();
if (s.isEmpty() || s=="")
return;
const QList<StelModuleMgr::PluginDescriptor> pluginsList = StelApp::
getInstance().getModuleMgr().getPluginsList();
foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList)
{
if (s==desc.info.displayedName)
{
StelModule* pmod = StelApp::getInstance().getModuleM
gr().getModule(desc.info.id);
if (pmod != NULL)
{
pmod->configureGui(true);
}
return;
}
}
}
void ConfigurationDialog::loadAtStartupChanged(int state)
{
if (ui->pluginsListWidget->count() <= 0)
return;
QString name = ui->pluginsListWidget->currentItem()->text();
QString key;
QList<StelModuleMgr::PluginDescriptor> pluginsList = StelApp::getIns
tance().getModuleMgr().getPluginsList();
foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList)
{
if (desc.info.displayedName==name)
key = desc.info.id;
}
if (!key.isEmpty())
StelApp::getInstance().getModuleMgr().setPluginLoadAtStartup
(key, state==Qt::Checked);
}
void ConfigurationDialog::populateScriptsList(void) void ConfigurationDialog::populateScriptsList(void)
{ {
int prevSel = ui->scriptListWidget->currentRow(); int prevSel = ui->scriptListWidget->currentRow();
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); StelScriptMgr& scriptMgr = StelMainGraphicsView::getInstance().getSc riptMgr();
ui->scriptListWidget->clear(); ui->scriptListWidget->clear();
ui->scriptListWidget->addItems(scriptMgr.getScriptList()); ui->scriptListWidget->addItems(scriptMgr.getScriptList());
// If we had a valid previous selection (i.e. not first time we popu late), restore it // If we had a valid previous selection (i.e. not first time we popu late), restore it
if (prevSel >= 0 && prevSel < ui->scriptListWidget->count()) if (prevSel >= 0 && prevSel < ui->scriptListWidget->count())
ui->scriptListWidget->setCurrentRow(prevSel); ui->scriptListWidget->setCurrentRow(prevSel);
else else
ui->scriptListWidget->setCurrentRow(0); ui->scriptListWidget->setCurrentRow(0);
} }
void ConfigurationDialog::scriptSelectionChanged(const QString& s) void ConfigurationDialog::scriptSelectionChanged(const QString& s)
{ {
if (s.isEmpty() || s=="") if (s.isEmpty())
return; return;
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); StelScriptMgr& scriptMgr = StelMainGraphicsView::getInstance().getSc riptMgr();
//ui->scriptInfoBrowser->document()->setDefaultStyleSheet(QString(St elApp::getInstance().getCurrentStelStyle()->htmlStyleSheet)); //ui->scriptInfoBrowser->document()->setDefaultStyleSheet(QString(St elApp::getInstance().getCurrentStelStyle()->htmlStyleSheet));
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + scriptMgr.getName(s) + "</h2>"; html += "<h2>" + scriptMgr.getName(s) + "</h2>";
html += "<h3>" + q_("Author") + ": " + scriptMgr.getAuthor(s) + "</h 3>"; html += "<h3>" + q_("Author") + ": " + scriptMgr.getAuthor(s) + "</h 3>";
html += "<h3>" + q_("License") + ": " + scriptMgr.getLicense(s) + "< /h3>"; html += "<h3>" + q_("License") + ": " + scriptMgr.getLicense(s) + "< /h3>";
QString d = scriptMgr.getDescription(s); QString d = scriptMgr.getDescription(s);
d.replace("\n", "<br />"); d.replace("\n", "<br />");
html += "<p>" + d + "</p>"; html += "<p>" + d + "</p>";
html += "</body></html>"; html += "</body></html>";
ui->scriptInfoBrowser->setHtml(html); ui->scriptInfoBrowser->setHtml(html);
} }
void ConfigurationDialog::runScriptClicked(void) void ConfigurationDialog::runScriptClicked(void)
{ {
if (ui->closeWindowAtScriptRunCheckbox->isChecked()) if (ui->closeWindowAtScriptRunCheckbox->isChecked())
this->close(); this->close();
StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); StelScriptMgr& scriptMgr = StelMainGraphicsView::getInstance().getSc riptMgr();
if (ui->scriptListWidget->currentItem()) if (ui->scriptListWidget->currentItem())
{ {
ui->runScriptButton->setEnabled(false); ui->runScriptButton->setEnabled(false);
ui->stopScriptButton->setEnabled(true); ui->stopScriptButton->setEnabled(true);
scriptMgr.runScript(ui->scriptListWidget->currentItem()->tex t()); scriptMgr.runScript(ui->scriptListWidget->currentItem()->tex t());
} }
} }
void ConfigurationDialog::stopScriptClicked(void) void ConfigurationDialog::stopScriptClicked(void)
{ {
StelApp::getInstance().getScriptMgr().stopScript(); GETSTELMODULE(LabelMgr)->deleteAllLabels();
GETSTELMODULE(ScreenImageMgr)->deleteAllImages();
StelMainGraphicsView::getInstance().getScriptMgr().stopScript();
} }
void ConfigurationDialog::aScriptIsRunning(void) void ConfigurationDialog::aScriptIsRunning(void)
{ {
ui->scriptStatusLabel->setText(q_("Running script: ") + StelApp::get Instance().getScriptMgr().runningScriptId()); ui->scriptStatusLabel->setText(q_("Running script: ") + StelMainGrap hicsView::getInstance().getScriptMgr().runningScriptId());
ui->runScriptButton->setEnabled(false); ui->runScriptButton->setEnabled(false);
ui->stopScriptButton->setEnabled(true); ui->stopScriptButton->setEnabled(true);
} }
void ConfigurationDialog::aScriptHasStopped(void) void ConfigurationDialog::aScriptHasStopped(void)
{ {
ui->scriptStatusLabel->setText(q_("Running script: [none]")); ui->scriptStatusLabel->setText(q_("Running script: [none]"));
ui->runScriptButton->setEnabled(true); ui->runScriptButton->setEnabled(true);
ui->stopScriptButton->setEnabled(false); ui->stopScriptButton->setEnabled(false);
} }
void ConfigurationDialog::setUpdatesState(ConfigurationDialog::UpdatesState state) void ConfigurationDialog::setFixedDateTimeToCurrent(void)
{ {
// everything invisible by default ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(StelApp:
ui->getStarsButton->setVisible(false); :getInstance().getCore()->getNavigator()->getJDay()));
ui->downloadLabel->setText(""); ui->fixedTimeRadio->setChecked(true);
ui->downloadCancelButton->setVisible(false); setStartupTimeMode();
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) void ConfigurationDialog::changePage(QListWidgetItem *current, QListWidgetI tem *previous)
{ {
qDebug() << "Error checking updates from" << downloadMgr->url() << " if (!current)
: Code" << code << errorString; current = previous;
setUpdatesState(ConfigurationDialog::UpdatesError); ui->configurationStackedWidget->setCurrentIndex(ui->stackListWidget-
>row(current));
} }
void ConfigurationDialog::updatesDownloadFinished(void) void ConfigurationDialog::refreshStarCatalogButton()
{ {
newCatalogs.clear(); const QVariantList& catalogConfig = GETSTELMODULE(StarMgr)->getCatal
updatesData = new QSettings(updatesFileName, QSettings::IniFormat); ogsDescription();
updatesData->beginGroup("extra_stars"); nextStarCatalogToDownload.clear();
QListIterator<QString> it(updatesData->childKeys()); int idx=0;
foreach (const QVariant& catV, catalogConfig)
// 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(); ++idx;
bool catPathExists = !starSettings->value(catName+"/path","" const QVariantMap& m = catV.toMap();
).toString().isEmpty(); const bool checked = m.value("checked").toBool();
if(!catPathExists) if (checked)
newCatalogs.append(catName); continue;
nextStarCatalogToDownload=m;
break;
} }
if(newCatalogs.size() > 0) ui->downloadCancelButton->setVisible(false);
setUpdatesState(ConfigurationDialog::ShowAvailable); ui->downloadRetryButton->setVisible(false);
else
setUpdatesState(ConfigurationDialog::NoUpdates);
}
void ConfigurationDialog::checkUpdates(void) if (idx==catalogConfig.size())
{ {
setUpdatesState(ConfigurationDialog::Checking); ui->getStarsButton->setVisible(false);
updatesFileName = starsDir+"/updates.ini"; ui->downloadLabel->setText(q_("Finished downloading all star
downloadMgr->setBarVisible(false); catalogs!"));
downloadMgr->setBlockQuit(false); return;
downloadMgr->get(starSettings->value("updates_url").toString(), upda }
tesFileName);
connect(downloadMgr, SIGNAL(finished()), this, SLOT(updatesDownloadF ui->getStarsButton->setEnabled(true);
inished())); if (!nextStarCatalogToDownload.isEmpty())
connect(downloadMgr, SIGNAL(error(QNetworkReply::NetworkError, QStri {
ng)), this, SLOT(updatesDownloadError(QNetworkReply::NetworkError, QString) ui->getStarsButton->setText(q_("Get catalog %1 of %2").arg(i
)); dx).arg(catalogConfig.size()));
const QVariantList& magRange = nextStarCatalogToDownload.val
ue("magRange").toList();
ui->downloadLabel->setText(q_("Download size: %1MB\nStar cou
nt: %2 Million\nMagnitude range: %3 - %4")
.arg(nextStarCatalogToDownload.value("sizeMb").toStr
ing())
.arg(nextStarCatalogToDownload.value("count").toStri
ng())
.arg(magRange.at(0).toString())
.arg(magRange.at(1).toString()));
ui->getStarsButton->setVisible(true);
}
else
{
ui->downloadLabel->setText(q_("Finished downloading new star
catalogs!\nRestart Stellarium to display them."));
ui->getStarsButton->setVisible(false);
}
} }
void ConfigurationDialog::cancelDownload(void) void ConfigurationDialog::cancelDownload(void)
{ {
downloadMgr->abort(); Q_ASSERT(currentDownloadFile);
setUpdatesState(ConfigurationDialog::ShowAvailable); Q_ASSERT(starCatalogDownloadReply);
qWarning() << "Aborting download";
starCatalogDownloadReply->abort();
} }
void ConfigurationDialog::retryDownload(void) void ConfigurationDialog::newStarCatalogData()
{ {
if(!updatesData) Q_ASSERT(currentDownloadFile);
checkUpdates(); Q_ASSERT(starCatalogDownloadReply);
else Q_ASSERT(progressBar);
downloadStars();
}
void ConfigurationDialog::downloadError(QNetworkReply::NetworkError code, Q int size = starCatalogDownloadReply->bytesAvailable();
String errorString) progressBar->setValue((float)progressBar->value()+(float)size/1024);
{ currentDownloadFile->write(starCatalogDownloadReply->read(size));
qDebug() << "Error downloading file" << downloadMgr->url() << ": Cod
e " << code << errorString;
setUpdatesState(ConfigurationDialog::DownloadError);
} }
void ConfigurationDialog::downloadVerifying(void) void ConfigurationDialog::downloadStars()
{ {
setUpdatesState(ConfigurationDialog::Verifying); Q_ASSERT(!nextStarCatalogToDownload.isEmpty());
Q_ASSERT(starCatalogDownloadReply==NULL);
Q_ASSERT(currentDownloadFile==NULL);
Q_ASSERT(progressBar==NULL);
QString path = StelFileMgr::getUserDir()+QString("/stars/default/")+
nextStarCatalogToDownload.value("fileName").toString();
currentDownloadFile = new QFile(path);
if (!currentDownloadFile->open(QIODevice::WriteOnly))
{
qWarning() << "Can't open a writable file for storing new st
ar catalog: " << path;
currentDownloadFile->deleteLater();
currentDownloadFile = NULL;
ui->downloadLabel->setText(q_("Error downloading %1:\n%2").a
rg(nextStarCatalogToDownload.value("id").toString()).arg(QString("Can't ope
n a writable file for storing new star catalog: %1").arg(path)));
ui->downloadRetryButton->setVisible(true);
return;
}
ui->downloadLabel->setText(q_("Downloading %1...\n(You can close thi
s window.)").arg(nextStarCatalogToDownload.value("id").toString()));
ui->downloadCancelButton->setVisible(true);
ui->downloadRetryButton->setVisible(false);
ui->getStarsButton->setVisible(true);
ui->getStarsButton->setEnabled(false);
QNetworkRequest req(nextStarCatalogToDownload.value("url").toString(
));
req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false)
;
req.setRawHeader("User-Agent", StelUtils::getApplicationName().toAsc
ii());
starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessMa
nager()->get(req);
starCatalogDownloadReply->setReadBufferSize(1024*1024*2);
connect(starCatalogDownloadReply, SIGNAL(readyRead()), this, SLOT(ne
wStarCatalogData()));
connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(dow
nloadFinished()));
connect(starCatalogDownloadReply, SIGNAL(error(QNetworkReply::Networ
kError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
progressBar = StelApp::getInstance().getGui()->addProgressBar();
progressBar->setValue(0);
progressBar->setMaximum(nextStarCatalogToDownload.value("sizeMb").to
Double()*1024);
progressBar->setVisible(true);
progressBar->setFormat(QString("%1: %p%").arg(nextStarCatalogToDownl
oad.value("id").toString()));
} }
void ConfigurationDialog::badChecksum(void) void ConfigurationDialog::downloadError(QNetworkReply::NetworkError code)
{ {
qDebug() << "Error downloading file" << downloadMgr->url() << ": Fil Q_ASSERT(currentDownloadFile);
e is corrupted."; Q_ASSERT(starCatalogDownloadReply);
setUpdatesState(ConfigurationDialog::ChecksumError);
qWarning() << "Error downloading file" << starCatalogDownloadReply->
url() << ": " << starCatalogDownloadReply->errorString();
ui->downloadLabel->setText(q_("Error downloading %1:\n%2").arg(nextS
tarCatalogToDownload.value("id").toString()).arg(starCatalogDownloadReply->
errorString()));
ui->downloadCancelButton->setVisible(false);
ui->downloadRetryButton->setVisible(true);
ui->getStarsButton->setVisible(false);
ui->getStarsButton->setEnabled(true);
} }
void ConfigurationDialog::downloadFinished(void) void ConfigurationDialog::downloadFinished()
{ {
downloaded++; Q_ASSERT(currentDownloadFile);
QString tempFileName = starsDir+"/"+downloadName+".tmp"; Q_ASSERT(starCatalogDownloadReply);
QString finalFileName = starsDir+"/"+downloadName+".cat"; Q_ASSERT(progressBar);
if( ( QFile::exists(finalFileName) && !QFile::remove(finalFileName) if (starCatalogDownloadReply->error()!=QNetworkReply::NoError)
) ||
!QFile::copy(tempFileName, finalFileName) ||
!QFile::remove(tempFileName))
{
qDebug() << "Error moving" << tempFileName << "to" << finalF
ileName;
setUpdatesState(ConfigurationDialog::MoveError);
}
else
{ {
starSettings->setValue(downloadName+"/path", downloadName+". starCatalogDownloadReply->deleteLater();
cat"); starCatalogDownloadReply = NULL;
setUpdatesState(ConfigurationDialog::ShowAvailable); currentDownloadFile->close();
currentDownloadFile->deleteLater();
currentDownloadFile = NULL;
progressBar->deleteLater();
progressBar=NULL;
return;
} }
}
void ConfigurationDialog::downloadStars(void) Q_ASSERT(starCatalogDownloadReply->bytesAvailable()==0);
{
Q_ASSERT(updatesData);
downloadMgr->disconnect(); const QVariant& redirect = starCatalogDownloadReply->attribute(QNetw
downloadName = newCatalogs.at(downloaded); orkRequest::RedirectionTargetAttribute);
QString url = updatesData->value(downloadName+"/url").toString(); if (!redirect.isNull())
QString path = QString("%1/%2.tmp").arg(starsDir).arg(downloadName); {
quint16 checksum = updatesData->value(downloadName+"/checksum").toUI // We got a redirection, we need to follow
nt(); starCatalogDownloadReply->deleteLater();
QNetworkRequest req(redirect.toUrl());
req.setAttribute(QNetworkRequest::CacheSaveControlAttribute,
false);
req.setRawHeader("User-Agent", StelUtils::getApplicationName
().toAscii());
starCatalogDownloadReply = StelApp::getInstance().getNetwork
AccessManager()->get(req);
starCatalogDownloadReply->setReadBufferSize(1024*1024*2);
connect(starCatalogDownloadReply, SIGNAL(readyRead()), this,
SLOT(newStarCatalogData()));
connect(starCatalogDownloadReply, SIGNAL(finished()), this,
SLOT(downloadFinished()));
connect(starCatalogDownloadReply, SIGNAL(error(QNetworkReply
::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
return;
}
downloadMgr->setBarVisible(true); currentDownloadFile->close();
downloadMgr->setBlockQuit(true); currentDownloadFile->deleteLater();
downloadMgr->setBarFormat(QString("%p%: %1 of %2").arg(downloaded+1) currentDownloadFile = NULL;
.arg(newCatalogs.size())); starCatalogDownloadReply->deleteLater();
downloadMgr->get(url, path, checksum); starCatalogDownloadReply = NULL;
progressBar->deleteLater();
progressBar=NULL;
connect(downloadMgr, SIGNAL(finished()), this, SLOT(downloadFinished ui->downloadLabel->setText(q_("Verifying file integrity..."));
())); if (GETSTELMODULE(StarMgr)->checkAndLoadCatalog(nextStarCatalogToDow
connect(downloadMgr, SIGNAL(error(QNetworkReply::NetworkError, QStri nload)==false)
ng)), this, SLOT(downloadError(QNetworkReply::NetworkError, QString))); {
connect(downloadMgr, SIGNAL(verifying()), this, SLOT(downloadVerifyi ui->getStarsButton->setVisible(false);
ng())); ui->downloadLabel->setText(q_("Error downloading %1:\nFile i
connect(downloadMgr, SIGNAL(badChecksum()), this, SLOT(badChecksum() s corrupted.").arg(nextStarCatalogToDownload.value("id").toString()));
)); ui->downloadCancelButton->setVisible(false);
setUpdatesState(ConfigurationDialog::Downloading); ui->downloadRetryButton->setVisible(true);
} }
void ConfigurationDialog::setFixedDateTimeToCurrent(void) refreshStarCatalogButton();
{
ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(StelApp:
:getInstance().getCore()->getNavigator()->getJDay()));
ui->fixedTimeRadio->setChecked(true);
setStartupTimeMode();
} }
 End of changes. 73 change blocks. 
274 lines changed or deleted 369 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/