15
16
* You should have received a copy of the GNU General Public License
16
17
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
66
68
atmosphereDialog = NULL;
69
void ViewDialog::languageChanged()
71
void ViewDialog::retranslate()
73
75
ui->retranslateUi(dialog);
74
shootingStarsZHRChanged();
79
//Hack to shrink the tabs to optimal size after language change
80
//by causing the list items to be laid out again.
81
ui->stackListWidget->setWrapping(false);
87
93
void ViewDialog::createDialogContent()
89
95
ui->setupUi(dialog);
90
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(languageChanged()));
96
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
92
98
// Set the Sky tab activated by default
93
99
ui->stackedWidget->setCurrentIndex(0);
142
148
// Shooting stars section
143
149
MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr);
145
switch(mmgr->getZHR())
147
case 0: ui->zhrNone->setChecked(true); break;
148
case 80: ui->zhr80->setChecked(true); break;
149
case 10000: ui->zhr10000->setChecked(true); break;
150
case 144000: ui->zhr144000->setChecked(true); break;
151
default: ui->zhr10->setChecked(true); break;
153
shootingStarsZHRChanged();
154
connect(ui->zhrNone, SIGNAL(clicked()), this, SLOT(shootingStarsZHRChanged()));
155
connect(ui->zhr10, SIGNAL(clicked()), this, SLOT(shootingStarsZHRChanged()));
156
connect(ui->zhr80, SIGNAL(clicked()), this, SLOT(shootingStarsZHRChanged()));
157
connect(ui->zhr10000, SIGNAL(clicked()), this, SLOT(shootingStarsZHRChanged()));
158
connect(ui->zhr144000, SIGNAL(clicked()), this, SLOT(shootingStarsZHRChanged()));
151
updateZhrControls(mmgr->getZHR());
152
connect(mmgr, SIGNAL(zhrChanged(int)),
153
this, SLOT(updateZhrControls(int)));
154
connect(ui->zhrNone, SIGNAL(clicked()), this, SLOT(setZhrFromControls()));
155
connect(ui->zhr10, SIGNAL(clicked()), this, SLOT(setZhrFromControls()));
156
connect(ui->zhr80, SIGNAL(clicked()), this, SLOT(setZhrFromControls()));
157
connect(ui->zhr10000, SIGNAL(clicked()), this, SLOT(setZhrFromControls()));
158
connect(ui->zhr144000, SIGNAL(clicked()), this, SLOT(setZhrFromControls()));
160
160
// Labels section
161
161
StarMgr* smgr = GETSTELMODULE(StarMgr);
247
247
connect(a, SIGNAL(toggled(bool)), ui->showEquatorialGridCheckBox, SLOT(setChecked(bool)));
248
248
connect(ui->showEquatorialGridCheckBox, SIGNAL(toggled(bool)), a, SLOT(setChecked(bool)));
250
ui->showGalacticGridCheckBox->setChecked(glmgr->getFlagGalacticGrid());
251
a = gui->getGuiActions("actionShow_Galactic_Grid");
252
connect(a, SIGNAL(toggled(bool)), ui->showGalacticGridCheckBox, SLOT(setChecked(bool)));
253
connect(ui->showGalacticGridCheckBox, SIGNAL(toggled(bool)), a, SLOT(setChecked(bool)));
255
ui->showGalacticPlaneLineCheckBox->setChecked(glmgr->getFlagGalacticPlaneLine());
256
a = gui->getGuiActions("actionShow_Galactic_Plane_Line");
257
connect(a, SIGNAL(toggled(bool)), ui->showGalacticPlaneLineCheckBox, SLOT(setChecked(bool)));
258
connect(ui->showGalacticPlaneLineCheckBox, SIGNAL(toggled(bool)), a, SLOT(setChecked(bool)));
250
260
ui->showAzimuthalGridCheckBox->setChecked(glmgr->getFlagAzimuthalGrid());
251
261
a = gui->getGuiActions("actionShow_Azimuthal_Grid");
252
262
connect(a, SIGNAL(toggled(bool)), ui->showAzimuthalGridCheckBox, SLOT(setChecked(bool)));
338
348
l->blockSignals(true);
340
350
LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
341
l->addItems(lmgr->getAllLandscapeNames());
342
l->setCurrentItem(l->findItems(lmgr->getCurrentLandscapeName(), Qt::MatchExactly).at(0));
351
QStringList landscapeList = lmgr->getAllLandscapeNames();
352
foreach (const QString landscapeId, landscapeList)
354
QString label = q_(landscapeId);
355
QListWidgetItem* item = new QListWidgetItem(label);
356
item->setData(Qt::UserRole, landscapeId);
359
QString selectedLandscapeId = lmgr->getCurrentLandscapeName();
360
for (int i = 0; i < l->count(); i++)
362
if (l->item(i)->data(Qt::UserRole).toString() == selectedLandscapeId)
343
368
l->blockSignals(false);
344
369
ui->landscapeTextBrowser->setHtml(lmgr->getCurrentLandscapeHtmlDescription());
345
370
ui->useAsDefaultLandscapeCheckBox->setChecked(lmgr->getDefaultLandscapeID()==lmgr->getCurrentLandscapeID());
389
414
void ViewDialog::updateSkyCultureText()
416
StelApp& app = StelApp::getInstance();
417
QString skyCultureId = app.getSkyCultureMgr().getCurrentSkyCultureID();
391
418
QString descPath;
394
descPath = StelFileMgr::findFile("skycultures/" + StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID() + "/description."+StelApp::getInstance().getLocaleMgr().getAppLanguage()+".utf8");
421
QString lang = app.getLocaleMgr().getAppLanguage();
422
if (!QString("pt_BR zh_CN zh_HK zh_TW").contains(lang))
424
lang = lang.split("_").at(0);
426
descPath = StelFileMgr::findFile("skycultures/" + skyCultureId + "/description."+lang+".utf8");
396
428
catch (std::runtime_error& e)
400
descPath = StelFileMgr::findFile("skycultures/" + StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID() + "/description.en.utf8");
432
descPath = StelFileMgr::findFile("skycultures/" + skyCultureId + "/description.en.utf8");
402
434
catch (std::runtime_error& e)
404
qWarning() << "WARNING: can't find description for skyculture" << StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID();
436
qWarning() << "WARNING: can't find description for skyculture" << skyCultureId;
408
440
QStringList searchPaths;
411
searchPaths << StelFileMgr::findFile("skycultures/" + StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID());
443
searchPaths << StelFileMgr::findFile("skycultures/" + skyCultureId);
413
445
catch (std::runtime_error& e) {}
415
447
ui->skyCultureTextBrowser->setSearchPaths(searchPaths);
416
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
448
StelGui* gui = dynamic_cast<StelGui*>(app.getGui());
418
450
ui->skyCultureTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
426
458
QFile f(descPath);
427
459
f.open(QIODevice::ReadOnly);
428
ui->skyCultureTextBrowser->setHtml(QString::fromUtf8(f.readAll()));
460
QString htmlFile = QString::fromUtf8(f.readAll());
461
#if QT_VERSION == 0x040800
462
// Workaround for https://bugreports.qt-project.org/browse/QTBUG-24077
463
QString path = QFileInfo(f).path();
464
QString newtag = "<img src=\"" + path + "/\\1";
465
htmlFile.replace(QRegExp("<img src=\"(\\w)"), newtag);
467
ui->skyCultureTextBrowser->setHtml(htmlFile);
442
481
void ViewDialog::landscapeChanged(QListWidgetItem* item)
444
483
LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
445
lmgr->setCurrentLandscapeName(item->text());
484
lmgr->setCurrentLandscapeName(item->data(Qt::UserRole).toString());
446
485
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
448
487
ui->landscapeTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
501
540
mmgr->setZHR(zhr);
543
updateZhrDescription(zhr);
546
void ViewDialog::updateZhrControls(int zhr)
548
// As the radio buttons are tied to the clicked() signal,
549
// it won't be triggered by setting the value programmatically.
552
case 0: ui->zhrNone->setChecked(true); break;
553
case 80: ui->zhr80->setChecked(true); break;
554
case 10000: ui->zhr10000->setChecked(true); break;
555
case 144000: ui->zhr144000->setChecked(true); break;
556
default: ui->zhr10->setChecked(true); break;
559
updateZhrDescription(zhr);
562
void ViewDialog::updateZhrDescription(int zhr)