RemoteSyncDialog.cpp   RemoteSyncDialog.cpp 
skipping to change at line 29 skipping to change at line 29
#include <QHostInfo> #include <QHostInfo>
#include "RemoteSync.hpp" #include "RemoteSync.hpp"
#include "RemoteSyncDialog.hpp" #include "RemoteSyncDialog.hpp"
#include "ui_remoteSyncDialog.h" #include "ui_remoteSyncDialog.h"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModule.hpp" #include "StelModule.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPropertyMgr.hpp"
RemoteSyncDialog::RemoteSyncDialog() RemoteSyncDialog::RemoteSyncDialog()
: rs(NULL) : rs(Q_NULLPTR)
{ {
ui = new Ui_remoteSyncDialog(); ui = new Ui_remoteSyncDialog();
dialogName="RemoteSync"; dialogName="RemoteSync";
} }
RemoteSyncDialog::~RemoteSyncDialog() RemoteSyncDialog::~RemoteSyncDialog()
{ {
delete ui; delete ui;
} }
skipping to change at line 63 skipping to change at line 64
rs = GETSTELMODULE(RemoteSync); rs = GETSTELMODULE(RemoteSync);
ui->setupUi(dialog); ui->setupUi(dialog);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//Kinetic scrolling for tablet pc and pc //Kinetic scrolling for tablet pc and pc
QList<QWidget *> addscroll; QList<QWidget *> addscroll;
addscroll << ui->aboutTextBrowser; addscroll << ui->aboutTextBrowser;
installKineticScrolling(addscroll); installKineticScrolling(addscroll);
#endif #endif
ui->pushButtonSelectProperties->setText(QChar(0x2192));
ui->pushButtonDeselectProperties->setText(QChar(0x2190));
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate()));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint))); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint)));
connect(rs, SIGNAL(stateChanged(RemoteSync::SyncState)), this, SLOT( updateState())); connect(rs, SIGNAL(stateChanged(RemoteSync::SyncState)), this, SLOT( updateState()));
updateState(); updateState();
connect(rs, SIGNAL(errorOccurred(QString)), this, SLOT(printErrorMes sage(QString))); connect(rs, SIGNAL(errorOccurred(QString)), this, SLOT(printErrorMes sage(QString)));
ui->clientServerHostEdit->setText(rs->getClientServerHost()); ui->clientServerHostEdit->setText(rs->getClientServerHost());
connect(ui->clientServerHostEdit, SIGNAL(textChanged(QString)), rs, SLOT(setClientServerHost(QString))); connect(ui->clientServerHostEdit, SIGNAL(textChanged(QString)), rs, SLOT(setClientServerHost(QString)));
ui->clientServerPortSpinBox->setValue(rs->getClientServerPort()); ui->clientServerPortSpinBox->setValue(rs->getClientServerPort());
connect(ui->clientServerPortSpinBox, SIGNAL(valueChanged(int)), rs, SLOT(setClientServerPort(int))); connect(ui->clientServerPortSpinBox, SIGNAL(valueChanged(int)), rs, SLOT(setClientServerPort(int)));
ui->serverPortSpinBox->setValue(rs->getServerPort()); ui->serverPortSpinBox->setValue(rs->getServerPort());
connect(ui->serverPortSpinBox, SIGNAL(valueChanged(int)), rs, SLOT(s etServerPort(int))); connect(ui->serverPortSpinBox, SIGNAL(valueChanged(int)), rs, SLOT(s etServerPort(int)));
ui->comboBoxClientServerQuits->setModel(ui->comboBoxClientConnection
Lost->model());
ui->comboBoxClientConnectionLost->setCurrentIndex(rs->getConnectionL
ostBehavior());
ui->comboBoxClientServerQuits->setCurrentIndex(rs->getQuitBehavior()
);
connect(ui->comboBoxClientConnectionLost, SIGNAL(activated(int)), th
is, SLOT(setConnectionLostBehavior(int)));
connect(rs, &RemoteSync::connectionLostBehaviorChanged, ui->comboBox
ClientConnectionLost, &QComboBox::setCurrentIndex);
connect(ui->comboBoxClientServerQuits, SIGNAL(activated(int)), this,
SLOT(setQuitBehavior(int)));
connect(rs, &RemoteSync::quitBehaviorChanged, ui->comboBoxClientServ
erQuits, &QComboBox::setCurrentIndex);
ui->buttonGroupSyncOptions->setId(ui->checkBoxOptionTime, SyncClient
::SyncTime);
ui->buttonGroupSyncOptions->setId(ui->checkBoxOptionLocation, SyncCl
ient::SyncLocation);
ui->buttonGroupSyncOptions->setId(ui->checkBoxOptionSelection, SyncC
lient::SyncSelection);
ui->buttonGroupSyncOptions->setId(ui->checkBoxOptionStelProperty, Sy
ncClient::SyncStelProperty);
ui->buttonGroupSyncOptions->setId(ui->checkBoxOptionView, SyncClient
::SyncView);
ui->buttonGroupSyncOptions->setId(ui->checkBoxOptionFov, SyncClient:
:SyncFov);
ui->buttonGroupSyncOptions->setId(ui->checkBoxExcludeGUIProps, SyncC
lient::SkipGUIProps);
updateCheckboxesFromSyncOptions();
connect(rs, SIGNAL(clientSyncOptionsChanged(SyncClient::SyncOptions)
), this, SLOT(updateCheckboxesFromSyncOptions()));
connect(ui->buttonGroupSyncOptions, SIGNAL(buttonToggled(int,bool)),
this, SLOT(checkboxToggled(int,bool)));
connect(ui->saveSettingsButton, SIGNAL(clicked()), rs, SLOT(saveSett ings())); connect(ui->saveSettingsButton, SIGNAL(clicked()), rs, SLOT(saveSett ings()));
connect(ui->restoreDefaultsButton, SIGNAL(clicked()), rs, SLOT(resto reDefaultSettings())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), rs, SLOT(resto reDefaultSettings()));
populateExclusionLists();
connect(ui->pushButtonSelectProperties, SIGNAL(clicked()), this, SLO
T(addPropertiesForExclusion()));
connect(ui->pushButtonDeselectProperties, SIGNAL(clicked()), this, S
LOT(removePropertiesForExclusion()));
setAboutHtml(); setAboutHtml();
} }
void RemoteSyncDialog::printErrorMessage(const QString error) void RemoteSyncDialog::printErrorMessage(const QString error)
{ {
ui->statusLabel->setText(QString(q_("ERROR: %1")).arg(error)); ui->statusLabel->setText(QString(q_("ERROR: %1")).arg(error));
ui->statusLabel->setStyleSheet("color: Red;"); ui->statusLabel->setStyleSheet("color: Red;");
} }
void RemoteSyncDialog::updateState() void RemoteSyncDialog::updateState()
{ {
RemoteSync::SyncState state = rs->getState(); RemoteSync::SyncState state = rs->getState();
//disconnect the click signals from whatever is connected //disconnect the click signals from whatever is connected
disconnect(ui->serverButton, SIGNAL(clicked(bool)), NULL, NULL); disconnect(ui->serverButton, SIGNAL(clicked(bool)), Q_NULLPTR, Q_NUL
disconnect(ui->clientButton, SIGNAL(clicked(bool)), NULL, NULL); LPTR);
disconnect(ui->clientButton, SIGNAL(clicked(bool)), Q_NULLPTR, Q_NUL
LPTR);
ui->statusLabel->setStyleSheet(""); ui->statusLabel->setStyleSheet("");
if(state == RemoteSync::IDLE) if(state == RemoteSync::IDLE)
{ {
ui->serverGroupBox->setEnabled(true); ui->serverGroupBox->setEnabled(true);
ui->serverControls->setEnabled(true); ui->serverControls->setEnabled(true);
ui->serverButton->setText(q_("Start server")); ui->serverButton->setText(q_("Start server"));
connect(ui->serverButton, SIGNAL(clicked(bool)), rs, SLOT(st artServer())); connect(ui->serverButton, SIGNAL(clicked(bool)), rs, SLOT(st artServer()));
ui->clientGroupBox->setEnabled(true); ui->clientGroupBox->setEnabled(true);
skipping to change at line 126 skipping to change at line 153
else if (state == RemoteSync::SERVER) else if (state == RemoteSync::SERVER)
{ {
ui->serverButton->setText("Stop server"); ui->serverButton->setText("Stop server");
ui->serverControls->setEnabled(false); ui->serverControls->setEnabled(false);
connect(ui->serverButton, SIGNAL(clicked(bool)), rs, SLOT(st opServer())); connect(ui->serverButton, SIGNAL(clicked(bool)), rs, SLOT(st opServer()));
ui->clientGroupBox->setEnabled(false); ui->clientGroupBox->setEnabled(false);
ui->statusLabel->setText(QString(q_("Running as server on po rt %1")).arg(rs->getServerPort())); ui->statusLabel->setText(QString(q_("Running as server on po rt %1")).arg(rs->getServerPort()));
updateIPlabel(true); updateIPlabel(true);
} }
else if(state == RemoteSync::CLIENT_CONNECTING) else
{ {
ui->serverGroupBox->setEnabled(false); connect(ui->clientButton, SIGNAL(clicked(bool)), rs, SLOT(di
ui->clientGroupBox->setEnabled(false); sconnectFromServer()));
ui->clientButton->setText(q_("Connecting..."));
ui->statusLabel->setText(QString(q_("Connecting to %1:%2..."
)).arg(rs->getClientServerHost()).arg(rs->getClientServerPort()));
updateIPlabel(false);
}
else if (state == RemoteSync::CLIENT)
{
ui->serverGroupBox->setEnabled(false); ui->serverGroupBox->setEnabled(false);
ui->clientGroupBox->setEnabled(true); ui->clientGroupBox->setEnabled(true);
ui->clientControls->setEnabled(false); ui->clientControls->setEnabled(false);
updateIPlabel(false);
ui->clientButton->setText(q_("Disconnect from server")); if(state == RemoteSync::CLIENT_CONNECTING)
connect(ui->clientButton, SIGNAL(clicked(bool)), rs, SLOT(di {
sconnectFromServer())); ui->clientButton->setText(q_("Cancel connecting"));
ui->statusLabel->setText(QString(q_("Connecting to %
1: %2...")).arg(rs->getClientServerHost()).arg(rs->getClientServerPort()));
}
else if (state == RemoteSync::CLIENT_WAIT_RECONNECT)
{
ui->clientButton->setText(q_("Cancel connecting"));
ui->statusLabel->setText(QString(q_("Retrying connec
tion to %1: %2...")).arg(rs->getClientServerHost()).arg(rs->getClientServer
Port()));
}
else if (state == RemoteSync::CLIENT_CLOSING)
{
ui->clientGroupBox->setEnabled(false);
ui->statusLabel->setText(QString(q_("Connected to %1:%2")).a ui->clientButton->setText(q_("Disconnecting..."));
rg(rs->getClientServerHost()).arg(rs->getClientServerPort())); ui->statusLabel->setText(q_("Disconnecting..."));
updateIPlabel(false); }
else if (state == RemoteSync::CLIENT)
{
ui->clientButton->setText(q_("Disconnect from server
"));
ui->statusLabel->setText(QString(q_("Connected to %1
: %2")).arg(rs->getClientServerHost()).arg(rs->getClientServerPort()));
}
} }
} }
void RemoteSyncDialog::setAboutHtml(void) void RemoteSyncDialog::setAboutHtml(void)
{ {
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Remote Sync Plug-in") + "</h2><table width=\"90 %\">"; html += "<h2>" + q_("Remote Sync Plug-in") + "</h2><table width=\"90 %\">";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + REMOTESYNC_VERSION + "</td></tr>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + REMOTESYNC_VERSION + "</td></tr>";
html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Flor ian Schaukowitsch</td></tr>"; html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Flor ian Schaukowitsch</td></tr>";
html += "<tr><td><strong>" + q_("Contributors") + ":</strong></td><t d>Georg Zotti</td></tr>"; html += "<tr><td><strong>" + q_("Contributors") + ":</strong></td><t d>Georg Zotti</td></tr>";
html += "</table>"; html += "</table>";
html += "<p>" + q_("The Remote Control plugin provides state synchro html += "<p>" + q_("The Remote Sync plugin provides state synchroniz
nization for multiple Stellarium instances running in a network.") + "</p>" ation for multiple Stellarium instances running in a network.") + "</p>";
; html += "<p>" + q_("This can be used, for example, to create multi-s
// TODO Add longer instructions? creen setups using multiple physical PCs.") + "</p>";
html += "<p>" + q_("Partial synchronization allows parallel setups o
f e.g. overview and detail views.") + "</p>";
html += "<p>" + q_("See manual for detailed description.") + "</p>";
html += "<p>" + q_("This plugin was developed during ESA SoCiS 2015&
amp;2016.") + "</p>";
html += "<h3>" + q_("Links") + "</h3>"; 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("Remote S ync 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("Remote S ync 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 and its history, you can %1get info here%2.").arg("<a href=\"http:/ /stellarium.org/wiki/index.php/RemoteSync_plugin\">").arg("</a>") + "</li>" ; html += "<li>" + q_("If you want to read full information about this plugin and its history, you can %1get info here%2.").arg("<a href=\"http:/ /stellarium.org/wiki/index.php/RemoteSync_plugin\">").arg("</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( ));
if(gui!=NULL) if(gui!=Q_NULLPTR)
{ {
QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlS tyleSheet); ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlS tyleSheet);
} }
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void RemoteSyncDialog::updateIPlabel(bool running) void RemoteSyncDialog::updateIPlabel(bool running)
{ {
if (running) if (running)
skipping to change at line 198 skipping to change at line 239
QHostInfo hostInfo = QHostInfo::fromName(localHostName); QHostInfo hostInfo = QHostInfo::fromName(localHostName);
QString ipString(""); QString ipString("");
foreach (QHostAddress a, hostInfo.addresses()) foreach (QHostAddress a, hostInfo.addresses())
{ {
if ((a.protocol() == QAbstractSocket::IPv4Protocol) && a != QHostAddress(QHostAddress::LocalHost)) if ((a.protocol() == QAbstractSocket::IPv4Protocol) && a != QHostAddress(QHostAddress::LocalHost))
{ {
ipString += a.toString() + " "; ipString += a.toString() + " ";
continue; continue;
} }
} }
ui->label_serverName->setText(q_("Server Name %1, IP: ").arg QString info = QString("%1 %2").arg(q_("Server Name"), local
(localHostName) + ipString); HostName);
if (!ipString.isEmpty())
info.append(QString("(IP: %1)").arg(ipString));
ui->label_serverName->setText(info);
//ui->label_RemoteRunningState->show(); //ui->label_RemoteRunningState->show();
} }
else else
{ {
ui->label_serverName->setText(q_("Server not active.")); ui->label_serverName->setText(q_("Server not active."));
// Maybe even hide the label? // Maybe even hide the label?
//ui->label_RemoteRunningState->hide(); //ui->label_RemoteRunningState->hide();
} }
} }
void RemoteSyncDialog::updateCheckboxesFromSyncOptions()
{
SyncClient::SyncOptions options = rs->getClientSyncOptions();
foreach(QAbstractButton* bt, ui->buttonGroupSyncOptions->buttons())
{
int id = ui->buttonGroupSyncOptions->id(bt);
bt->setChecked(options & id);
}
}
void RemoteSyncDialog::checkboxToggled(int id, bool state)
{
SyncClient::SyncOptions options = rs->getClientSyncOptions();
SyncClient::SyncOption enumVal = static_cast<SyncClient::SyncOption>
(id);
//toggle flag
options = state ? (options|enumVal) : (options&~enumVal);
rs->setClientSyncOptions(options);
}
void RemoteSyncDialog::populateExclusionLists()
{
ui->listWidgetAllProperties->clear();
ui->listWidgetSelectedProperties->clear();
QStringList excluded=rs->getStelPropFilter();
excluded.removeOne(""); // Special case
ui->listWidgetSelectedProperties->addItems(excluded);
QStringList allProps=StelApp::getInstance().getStelPropertyManager()
->getPropertyList();
foreach (QString str, excluded)
{
allProps.removeOne(str);
}
ui->listWidgetAllProperties->addItems(allProps);
ui->listWidgetAllProperties->sortItems();
ui->listWidgetSelectedProperties->sortItems();
}
void RemoteSyncDialog::addPropertiesForExclusion()
{
QStringList strings;
if (ui->listWidgetAllProperties->selectedItems().length()>0)
{
foreach (QListWidgetItem *item, ui->listWidgetAllProperties-
>selectedItems())
{
strings.append(item->text());
}
// Now we have a stringlist with properties to be added.
QStringList currentFilter=rs->getStelPropFilter();
// Add the selected to currentFilter...
currentFilter=currentFilter+strings;
// ...and activate new selection
rs->setStelPropFilter(currentFilter);
// update lists.
populateExclusionLists();
}
}
void RemoteSyncDialog::removePropertiesForExclusion()
{
QStringList strings;
if (ui->listWidgetSelectedProperties->selectedItems().length()>0)
{
foreach (QListWidgetItem *item, ui->listWidgetSelectedProper
ties->selectedItems())
{
strings.append(item->text());
}
// Now we have a stringlist with properties to be removed.
QStringList currentFilter=rs->getStelPropFilter();
// Remove the selected from currentFilter...
foreach (QString str, strings)
{
currentFilter.removeOne(str);
}
// and activate new selection
rs->setStelPropFilter(currentFilter);
// update lists.
populateExclusionLists();
}
}
void RemoteSyncDialog::setConnectionLostBehavior(int idx)
{
rs->setConnectionLostBehavior(static_cast<RemoteSync::ClientBehavior
>(idx));
}
void RemoteSyncDialog::setQuitBehavior(int idx)
{
rs->setQuitBehavior(static_cast<RemoteSync::ClientBehavior>(idx));
}
 End of changes. 16 change blocks. 
26 lines changed or deleted 95 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/