QuasarsDialog.cpp   QuasarsDialog.cpp 
skipping to change at line 21 skipping to change at line 21
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "config.h"
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
#include <QUrl> #include <QUrl>
#include <QFileDialog> #include <QFileDialog>
#include "StelApp.hpp" #include "StelApp.hpp"
#include "ui_quasarsDialog.h" #include "ui_quasarsDialog.h"
#include "QuasarsDialog.hpp" #include "QuasarsDialog.hpp"
#include "Quasars.hpp" #include "Quasars.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainView.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
QuasarsDialog::QuasarsDialog() : updateTimer(NULL) QuasarsDialog::QuasarsDialog()
: qsr(NULL)
, updateTimer(NULL)
{ {
ui = new Ui_quasarsDialog; ui = new Ui_quasarsDialog;
} }
QuasarsDialog::~QuasarsDialog() QuasarsDialog::~QuasarsDialog()
{ {
if (updateTimer) if (updateTimer)
{ {
updateTimer->stop(); updateTimer->stop();
delete updateTimer; delete updateTimer;
skipping to change at line 69 skipping to change at line 73
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
refreshUpdateValues(); refreshUpdateValues();
setAboutHtml(); setAboutHtml();
} }
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void QuasarsDialog::createDialogContent() void QuasarsDialog::createDialogContent()
{ {
qsr = GETSTELMODULE(Quasars);
ui->setupUi(dialog); ui->setupUi(dialog);
ui->tabs->setCurrentIndex(0); ui->tabs->setCurrentIndex(0);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslate())); this, SLOT(retranslate()));
// Settings tab / updates group // Settings tab / updates group
ui->displayModeCheckBox->setChecked(GETSTELMODULE(Quasars)->getDispl ayMode()); ui->displayModeCheckBox->setChecked(qsr->getDisplayMode());
connect(ui->displayModeCheckBox, SIGNAL(stateChanged(int)), this, SL OT(setDistributionEnabled(int))); connect(ui->displayModeCheckBox, SIGNAL(stateChanged(int)), this, SL OT(setDistributionEnabled(int)));
ui->displayAtStartupCheckBox->setChecked(GETSTELMODULE(Quasars)->get EnableAtStartup()); ui->displayAtStartupCheckBox->setChecked(qsr->getEnableAtStartup());
connect(ui->displayAtStartupCheckBox, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayAtStartupEnabled(int))); connect(ui->displayAtStartupCheckBox, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayAtStartupEnabled(int)));
ui->displayShowQuasarsButton->setChecked(GETSTELMODULE(Quasars)->get FlagShowQuasarsButton()); ui->displayShowQuasarsButton->setChecked(qsr->getFlagShowQuasarsButt on());
connect(ui->displayShowQuasarsButton, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayShowQuasarsButton(int))); connect(ui->displayShowQuasarsButton, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayShowQuasarsButton(int)));
connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this , SLOT(setUpdatesEnabled(int))); connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this , SLOT(setUpdatesEnabled(int)));
connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON() )); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON() ));
connect(GETSTELMODULE(Quasars), SIGNAL(updateStateChanged(Quasars::U connect(qsr, SIGNAL(updateStateChanged(Quasars::UpdateState)), this,
pdateState)), this, SLOT(updateStateReceiver(Quasars::UpdateState))); SLOT(updateStateReceiver(Quasars::UpdateState)));
connect(GETSTELMODULE(Quasars), SIGNAL(jsonUpdateComplete(void)), th connect(qsr, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateComp
is, SLOT(updateCompleteReceiver(void))); leteReceiver(void)));
connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int)));
refreshUpdateValues(); // fetch values for last updated and so on refreshUpdateValues(); // fetch values for last updated and so on
// if the state didn't change, setUpdatesEnabled will not be called, so we force it // if the state didn't change, setUpdatesEnabled will not be called, so we force it
setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState()); setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState());
updateTimer = new QTimer(this); updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValu es())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValu es()));
updateTimer->start(7000); updateTimer->start(7000);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res toreDefaults())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res toreDefaults()));
connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe ttings())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe ttings()));
// About tab // About tab
setAboutHtml(); setAboutHtml();
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); if(gui!=NULL)
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui-> ui->aboutTextBrowser->document()->setDefaultStyleSheet(QStri
getStelStyle().htmlStyleSheet)); ng(gui->getStelStyle().htmlStyleSheet));
updateGuiFromSettings(); updateGuiFromSettings();
} }
void QuasarsDialog::setAboutHtml(void) void QuasarsDialog::setAboutHtml(void)
{ {
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Quasars Plug-in") + "</h2><table width=\"90%\"> "; html += "<h2>" + q_("Quasars Plug-in") + "</h2><table width=\"90%\"> ";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + QUASARS_PLUGIN_VERSION + "</td></tr>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + QUASARS_PLUGIN_VERSION + "</td></tr>";
html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Alex ander Wolf &lt;alex.v.wolf@gmail.com&gt;</td></tr>"; html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Alex ander Wolf &lt;alex.v.wolf@gmail.com&gt;</td></tr>";
html += "</table>"; html += "</table>";
html += QString("<p>%1 (<a href=\"%2\">%3</a>)</p>") html += QString("<p>%1 (<a href=\"%2\">%3</a>)</p>")
.arg(q_("The Quasars plugin provides visualization o f some quasars brighter than 16 visual magnitude. A catalogue of quasars co mpiled from \"Quasars and Active Galactic Nuclei\" (13th Ed.)")) .arg(q_("The Quasars plugin provides visualization o f some quasars brighter than visual magnitude 16. The catalogue of quasars was compiled from \"Quasars and Active Galactic Nuclei\" (13th Ed.)"))
.arg("http://adsabs.harvard.edu/abs/2010A%26A...518A ..10V") .arg("http://adsabs.harvard.edu/abs/2010A%26A...518A ..10V")
.arg(q_("Veron+ 2010")); .arg(q_("Veron+ 2010"));
html += "</ul><h3>" + q_("Links") + "</h3>"; html += "</ul><p>" + q_("The current catalog contains info about %1
quasars.").arg(qsr->getCountQuasars()) + "</p>";
html += "<h3>" + q_("Links") + "</h3>";
html += "<p>" + QString(q_("Support is provided via the Launchpad we bsite. Be sure to put \"%1\" in the subject when posting.")).arg("Quasars plugin") + "</p>"; html += "<p>" + QString(q_("Support is provided via the Launchpad we bsite. Be sure to put \"%1\" in the subject when posting.")).arg("Quasars plugin") + "</p>";
html += "<p><ul>"; html += "<p><ul>";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + QString(q_("If you have a question, you can %1get a n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\" >")).arg("</a>") + "</li>"; html += "<li>" + QString(q_("If you have a question, you can %1get a n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\" >")).arg("</a>") + "</li>";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + QString(q_("Bug reports can be made %1here%2.")).ar g("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>") + "</li >"; html += "<li>" + QString(q_("Bug reports can be made %1here%2.")).ar g("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>") + "</li >";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + q_("If you would like to make a feature request, yo u can create a bug report, and set the severity to \"wishlist\".") + "</li> "; html += "<li>" + q_("If you would like to make a feature request, yo u can create a bug report, and set the severity to \"wishlist\".") + "</li> ";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + q_("If you want to read full information about this plugin, its history and format of catalog, you can %1get info here%2.").ar g("<a href=\"http://stellarium.org/wiki/index.php/Quasars_plugin\">").arg(" </a>") + "</li>"; html += "<li>" + q_("If you want to read full information about this plugin, its history and format of the catalog, you can %1get info here%2." ).arg("<a href=\"http://stellarium.org/wiki/index.php/Quasars_plugin\">").a rg("</a>") + "</li>";
html += "</ul></p></body></html>"; html += "</ul></p></body></html>";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); if(gui!=NULL)
QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); {
ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleShee QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
t); ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlS
tyleSheet);
}
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void QuasarsDialog::refreshUpdateValues(void) void QuasarsDialog::refreshUpdateValues(void)
{ {
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Quasars)->getL ui->lastUpdateDateTimeEdit->setDateTime(qsr->getLastUpdate());
astUpdate()); ui->updateFrequencySpinBox->setValue(qsr->getUpdateFrequencyDays());
ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Quasars)->getUpda int secondsToUpdate = qsr->getSecondsToUpdate();
teFrequencyDays()); ui->internetUpdatesCheckbox->setChecked(qsr->getUpdatesEnabled());
int secondsToUpdate = GETSTELMODULE(Quasars)->getSecondsToUpdate(); if (!qsr->getUpdatesEnabled())
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Quasars)->getU
pdatesEnabled());
if (!GETSTELMODULE(Quasars)->getUpdatesEnabled())
ui->nextUpdateLabel->setText(q_("Internet updates disabled") ); ui->nextUpdateLabel->setText(q_("Internet updates disabled") );
else if (GETSTELMODULE(Quasars)->getUpdateState() == Quasars::Updati ng) else if (qsr->getUpdateState() == Quasars::Updating)
ui->nextUpdateLabel->setText(q_("Updating now...")); ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (secondsToUpdate <= 60) else if (secondsToUpdate <= 60)
ui->nextUpdateLabel->setText(q_("Next update: < 1 minute")); ui->nextUpdateLabel->setText(q_("Next update: < 1 minute"));
else if (secondsToUpdate < 3600) else if (secondsToUpdate < 3600)
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min utes")).arg((secondsToUpdate/60)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min utes")).arg((secondsToUpdate/60)+1));
else if (secondsToUpdate < 86400) else if (secondsToUpdate < 86400)
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou rs")).arg((secondsToUpdate/3600)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou rs")).arg((secondsToUpdate/3600)+1));
else else
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 day s")).arg((secondsToUpdate/86400)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 day s")).arg((secondsToUpdate/86400)+1));
} }
void QuasarsDialog::setUpdateValues(int days) void QuasarsDialog::setUpdateValues(int days)
{ {
GETSTELMODULE(Quasars)->setUpdateFrequencyDays(days); qsr->setUpdateFrequencyDays(days);
refreshUpdateValues(); refreshUpdateValues();
} }
void QuasarsDialog::setUpdatesEnabled(int checkState) void QuasarsDialog::setUpdatesEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Quasars)->setUpdatesEnabled(b); qsr->setUpdatesEnabled(b);
ui->updateFrequencySpinBox->setEnabled(b); ui->updateFrequencySpinBox->setEnabled(b);
if(b) if(b)
ui->updateButton->setText(q_("Update now")); ui->updateButton->setText(q_("Update now"));
else else
ui->updateButton->setText(q_("Update from files")); ui->updateButton->setText(q_("Update from files"));
refreshUpdateValues(); refreshUpdateValues();
} }
void QuasarsDialog::setDistributionEnabled(int checkState) void QuasarsDialog::setDistributionEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Quasars)->setDisplayMode(b); qsr->setDisplayMode(b);
} }
void QuasarsDialog::setDisplayAtStartupEnabled(int checkState) void QuasarsDialog::setDisplayAtStartupEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Quasars)->setEnableAtStartup(b); qsr->setEnableAtStartup(b);
} }
void QuasarsDialog::setDisplayShowQuasarsButton(int checkState) void QuasarsDialog::setDisplayShowQuasarsButton(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Quasars)->setFlagShowQuasarsButton(b); qsr->setFlagShowQuasarsButton(b);
} }
void QuasarsDialog::updateStateReceiver(Quasars::UpdateState state) void QuasarsDialog::updateStateReceiver(Quasars::UpdateState state)
{ {
//qDebug() << "QuasarsDialog::updateStateReceiver got a signal"; //qDebug() << "QuasarsDialog::updateStateReceiver got a signal";
if (state==Quasars::Updating) if (state==Quasars::Updating)
ui->nextUpdateLabel->setText(q_("Updating now...")); ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (state==Quasars::DownloadError || state==Quasars::OtherError ) else if (state==Quasars::DownloadError || state==Quasars::OtherError )
{ {
ui->nextUpdateLabel->setText(q_("Update error")); ui->nextUpdateLabel->setText(q_("Update error"));
updateTimer->start(); // make sure message is displayed for a while... updateTimer->start(); // make sure message is displayed for a while...
} }
} }
void QuasarsDialog::updateCompleteReceiver(void) void QuasarsDialog::updateCompleteReceiver(void)
{ {
ui->nextUpdateLabel->setText(QString(q_("Quasars is updated"))); ui->nextUpdateLabel->setText(QString(q_("Quasars is updated")));
// display the status for another full interval before refreshing st atus // display the status for another full interval before refreshing st atus
updateTimer->start(); updateTimer->start();
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Quasars)->getL astUpdate()); ui->lastUpdateDateTimeEdit->setDateTime(qsr->getLastUpdate());
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) ; connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) ;
} }
void QuasarsDialog::restoreDefaults(void) void QuasarsDialog::restoreDefaults(void)
{ {
qDebug() << "Quasars::restoreDefaults"; qDebug() << "Quasars::restoreDefaults";
GETSTELMODULE(Quasars)->restoreDefaults(); qsr->restoreDefaults();
GETSTELMODULE(Quasars)->readSettingsFromConfig(); qsr->readSettingsFromConfig();
updateGuiFromSettings(); updateGuiFromSettings();
} }
void QuasarsDialog::updateGuiFromSettings(void) void QuasarsDialog::updateGuiFromSettings(void)
{ {
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Quasars)->getU pdatesEnabled()); ui->internetUpdatesCheckbox->setChecked(qsr->getUpdatesEnabled());
refreshUpdateValues(); refreshUpdateValues();
} }
void QuasarsDialog::saveSettings(void) void QuasarsDialog::saveSettings(void)
{ {
GETSTELMODULE(Quasars)->saveSettingsToConfig(); qsr->saveSettingsToConfig();
} }
void QuasarsDialog::updateJSON(void) void QuasarsDialog::updateJSON(void)
{ {
if(GETSTELMODULE(Quasars)->getUpdatesEnabled()) if(qsr->getUpdatesEnabled())
{ {
GETSTELMODULE(Quasars)->updateJSON(); qsr->updateJSON();
} }
} }
 End of changes. 26 change blocks. 
40 lines changed or deleted 46 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/