mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
Misc. imorvements as discussed in RW/KB worksho
* preparation for a context menu to send text messages from ATC/aircraft view * preparation for context menu for fast pos. updates * reverse ICAO lookup at login screen * display fast updates / parts in GUI * moved max- aircraft into settings * made serverselection own component
This commit is contained in:
@@ -80,7 +80,7 @@ namespace BlackGui
|
||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||
CUpdateTimer *m_updateTimer = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace BlackGui
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::ps_setComFrequency);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestTextMessage, this, &CAtcStationComponent::requestTextMessage);
|
||||
|
||||
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
|
||||
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
|
||||
@@ -264,7 +265,7 @@ namespace BlackGui
|
||||
this->ui->tvp_AtcStationsOnlineTree->setModel(
|
||||
this->ui->tvp_AtcStationsOnline->derivedModel()->toAtcGroupModel()
|
||||
);
|
||||
if (old) { old->deleteLater(); }
|
||||
if (old) { old->deleteLater(); } // delete old model replaced by current model
|
||||
if (!this->ui->tvp_AtcStationsOnlineTree->model()) { return; }
|
||||
|
||||
this->ui->tvp_AtcStationsOnlineTree->expandAll();
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace BlackGui
|
||||
//! Number of online stations
|
||||
int countOnlineStations() const;
|
||||
|
||||
signals:
|
||||
//! Request a text message
|
||||
void requestTextMessage(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
public slots:
|
||||
//! Update stations
|
||||
void update();
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace BlackGui
|
||||
this->ui->le_AircraftIcaoDesignator->setMaxLength(5);
|
||||
this->ui->le_AircraftIcaoDesignator->setValidator(new CUpperCaseValidator(this));
|
||||
connect(ui->le_AircraftIcaoDesignator, &QLineEdit::editingFinished, this, &CLoginComponent::ps_validateAircraftValues);
|
||||
connect(ui->tb_SimulatorIcaoReverseLookup, &QToolButton::clicked, this, &CLoginComponent::ps_reverseLookupModel);
|
||||
|
||||
// server GUI element
|
||||
this->ui->frp_CurrentServer->setReadOnly(true);
|
||||
@@ -278,6 +279,13 @@ namespace BlackGui
|
||||
return values;
|
||||
}
|
||||
|
||||
void CLoginComponent::mergeGuiIcaoValues(CAircraftIcao &icao) const
|
||||
{
|
||||
CGuiAircraftValues values = getAircraftValuesFromGui();
|
||||
CAircraftIcao guiIcao(values.ownAircraftIcaoTypeDesignator, values.ownAircraftCombinedType, values.ownAircraftIcaoAirline, "", "");
|
||||
icao.updateMissingParts(guiIcao);
|
||||
}
|
||||
|
||||
CLoginComponent::CVatsimValues CLoginComponent::getVatsimValuesFromGui() const
|
||||
{
|
||||
CVatsimValues values;
|
||||
@@ -334,18 +342,23 @@ namespace BlackGui
|
||||
|
||||
void CLoginComponent::setOwnModel()
|
||||
{
|
||||
static const CAircraftIcao defaultIcao("C172", "L1P", "FOO", "", ""); //! \todo set values for OBS
|
||||
Q_ASSERT(this->getIContextOwnAircraft());
|
||||
Q_ASSERT(this->getIContextSimulator());
|
||||
|
||||
static const CAircraftIcao defaultIcao("C172", "L1P", "FOO", "", ""); // default values
|
||||
CAircraftIcao icao;
|
||||
|
||||
bool simConnected = this->getIContextSimulator() && this->getIContextSimulator()->isSimulating();
|
||||
if (simConnected)
|
||||
{
|
||||
CAircraftModel model = this->getIContextOwnAircraft()->getOwnAircraft().getModel();
|
||||
this->ui->le_SimulatorModel->setText(model.getModelString());
|
||||
this->setIcaoValuesIfEmpty(model.getIcao());
|
||||
|
||||
// still empty?
|
||||
if (this->ui->le_AircraftIcaoDesignator->text().trimmed().isEmpty())
|
||||
icao = model.getIcao();
|
||||
if (!icao.hasAircraftDesignator())
|
||||
{
|
||||
this->setIcaoValuesIfEmpty(defaultIcao);
|
||||
// not valid, reverse lookup
|
||||
this->getIContextSimulator()->getIcaoForModelString(model.getModelString());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -353,22 +366,27 @@ namespace BlackGui
|
||||
// Set observer mode without simulator
|
||||
//! \todo Currently not working in OBS mode
|
||||
this->ui->gbp_LoginMode->setLoginMode(INetwork::LoginNormal);
|
||||
this->setIcaoValuesIfEmpty(defaultIcao);
|
||||
this->ui->le_SimulatorModel->setText("No simulator");
|
||||
}
|
||||
|
||||
if (icao.hasAircraftDesignator())
|
||||
{
|
||||
this->setGuiIcaoValues(icao, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CLoginComponent::setIcaoValuesIfEmpty(const CAircraftIcao &icao)
|
||||
void CLoginComponent::setGuiIcaoValues(const CAircraftIcao &icao, bool onlyIfEmpty)
|
||||
{
|
||||
if (this->ui->le_AircraftIcaoDesignator->text().trimmed().isEmpty())
|
||||
if (!onlyIfEmpty || this->ui->le_AircraftIcaoDesignator->text().trimmed().isEmpty())
|
||||
{
|
||||
this->ui->le_AircraftIcaoDesignator->setText(icao.getAircraftDesignator());
|
||||
}
|
||||
if (this->ui->le_AircraftIcaoAirline->text().trimmed().isEmpty())
|
||||
if (!onlyIfEmpty || this->ui->le_AircraftIcaoAirline->text().trimmed().isEmpty())
|
||||
{
|
||||
this->ui->le_AircraftIcaoAirline->setText(icao.getAirlineDesignator());
|
||||
}
|
||||
if (this->ui->le_AircraftCombinedType->text().trimmed().isEmpty())
|
||||
if (!onlyIfEmpty || this->ui->le_AircraftCombinedType->text().trimmed().isEmpty())
|
||||
{
|
||||
this->ui->le_AircraftCombinedType->setText(icao.getAircraftCombinedType());
|
||||
}
|
||||
@@ -437,5 +455,29 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CLoginComponent::ps_reverseLookupModel()
|
||||
{
|
||||
Q_ASSERT(getIContextOwnAircraft());
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
|
||||
CAircraftModel model(this->getIContextOwnAircraft()->getOwnAircraft().getModel());
|
||||
CAircraftIcao icao = this->getIContextSimulator()->getIcaoForModelString(model.getModelString());
|
||||
if (icao.hasAircraftDesignator())
|
||||
{
|
||||
CLogMessage(this).validationInfo("Reverse lookup for %1") << model.getModelString();
|
||||
|
||||
// set value in backend
|
||||
this->mergeGuiIcaoValues(icao);
|
||||
this->getIContextOwnAircraft()->updateIcaoData(icao);
|
||||
|
||||
// update GUI
|
||||
this->setGuiIcaoValues(icao, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).validationWarning("Reverse lookup for %1 failed") << model.getModelString();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -79,6 +79,9 @@ namespace BlackGui
|
||||
//! Logoff countdown
|
||||
void ps_logoffCountdown();
|
||||
|
||||
//! Reverse lookup model
|
||||
void ps_reverseLookupModel();
|
||||
|
||||
private:
|
||||
|
||||
//! GUI aircraft values, formatted
|
||||
@@ -136,8 +139,11 @@ namespace BlackGui
|
||||
//! Own model string
|
||||
void setOwnModel();
|
||||
|
||||
//! Set ICAO values if fields are empty
|
||||
void setIcaoValuesIfEmpty(const BlackMisc::Aviation::CAircraftIcao &icao);
|
||||
//! Set ICAO values
|
||||
void setGuiIcaoValues(const BlackMisc::Aviation::CAircraftIcao &icao, bool onlyIfEmpty);
|
||||
|
||||
//! Merge with GUI icao values
|
||||
void mergeGuiIcaoValues(BlackMisc::Aviation::CAircraftIcao &icao) const;
|
||||
|
||||
bool m_visible = false; //!< is this component selected?
|
||||
QScopedPointer<Ui::CLoginComponent> ui;
|
||||
|
||||
@@ -275,7 +275,7 @@
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftIcaoAirline">
|
||||
<property name="toolTip">
|
||||
<string>e.g. DLH, LHA, ...</string>
|
||||
@@ -285,14 +285,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorModel">
|
||||
<property name="text">
|
||||
<string>Model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="le_AircraftIcaoAirline">
|
||||
<property name="toolTip">
|
||||
<string>e.g. DLH</string>
|
||||
@@ -311,7 +304,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<item row="4" column="4">
|
||||
<widget class="QLineEdit" name="le_AircraftCombinedType">
|
||||
<property name="toolTip">
|
||||
<string>e.g. L2J</string>
|
||||
@@ -330,7 +323,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="lbl_AircraftCombinedType">
|
||||
<property name="toolTip">
|
||||
<string>e.g. L2J, L1P, ....</string>
|
||||
@@ -405,14 +398,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="4" column="2">
|
||||
<widget class="BlackGui::CTickLabel" name="lblp_AircraftIcaoAirline">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<item row="4" column="5">
|
||||
<widget class="BlackGui::CTickLabel" name="lblp_AircraftCombinedType">
|
||||
<property name="text">
|
||||
<string/>
|
||||
@@ -426,6 +419,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="BlackGui::CTickLabel" name="lblp_SimulatorModel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="le_SimulatorModel">
|
||||
<property name="readOnly">
|
||||
@@ -433,12 +433,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="BlackGui::CTickLabel" name="lblp_SimulatorModel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="hl_AircraftModel">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_SimulatorModel">
|
||||
<property name="text">
|
||||
<string>Model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_SimulatorIcaoReverseLookup">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -575,6 +593,8 @@
|
||||
<tabstop>cbp_OtherServers</tabstop>
|
||||
<tabstop>pb_OtherServersGotoSettings</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -44,24 +44,15 @@ namespace BlackGui
|
||||
this->ui->tvp_AircraftModels->setResizeMode(CAircraftModelView::ResizingOff);
|
||||
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::requestUpdate, this, &CMappingComponent::ps_onModelsUpdateRequested);
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::requestUpdate, this, &CMappingComponent::ps_onMappingsUpdateRequested);
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::clicked, this, &CMappingComponent::ps_onAircraftSelectedInView);
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::clicked, this, &CMappingComponent::ps_onModelSelectedInView);
|
||||
|
||||
connect(this->ui->pb_ApplyMaxAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onApplyNewMaxRemoteAircraft);
|
||||
connect(this->ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onSaveAircraft);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::clicked, this, &CMappingComponent::ps_onAircraftSelectedInView);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView ::requestUpdate, this, &CMappingComponent::ps_onMappingsUpdateRequested);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::requestTextMessage, this, &CMappingComponent::requestTextMessage);
|
||||
|
||||
// sync slider and text field
|
||||
connect(this->ui->hs_MaxAircraft, &QSlider::valueChanged, [ = ](int newValue)
|
||||
{
|
||||
this->ui->sb_MaxAircraft->setValue(newValue);
|
||||
});
|
||||
connect(this->ui->sb_MaxAircraft, static_cast<void (QSpinBox::*)(int)> (&QSpinBox::valueChanged), [ = ](int newValue)
|
||||
{
|
||||
this->ui->hs_MaxAircraft->setValue(newValue);
|
||||
});
|
||||
connect(this->ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onSaveAircraft);
|
||||
|
||||
this->m_modelCompleter = new QCompleter(this);
|
||||
this->m_currentMappingsViewDelegate = new CCheckBoxDelegate(":/diagona/icons/diagona/icons/tick.png", ":/diagona/icons/diagona/icons/cross.png", this);
|
||||
@@ -106,9 +97,6 @@ namespace BlackGui
|
||||
// requires simulator context
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::objectChanged, this, &CMappingComponent::ps_onChangedSimulatedAircraftInView);
|
||||
|
||||
// data
|
||||
this->ui->hs_MaxAircraft->setValue(getIContextSimulator()->getMaxRenderedAircraft());
|
||||
|
||||
// with external core models might be already available
|
||||
this->ps_onAircraftModelsLoaded();
|
||||
}
|
||||
@@ -197,32 +185,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onApplyNewMaxRemoteAircraft()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
Q_ASSERT(getIContextNetwork());
|
||||
|
||||
// get initial aircraft to render
|
||||
int noRequested = this->ui->hs_MaxAircraft->value();
|
||||
CSimulatedAircraftList inRange(this->getIContextNetwork()->getAircraftInRange());
|
||||
inRange.truncate(noRequested);
|
||||
inRange.sortByDistanceToOwnAircraft();
|
||||
CCallsignList initialCallsigns(inRange.getCallsigns());
|
||||
this->getIContextSimulator()->setMaxRenderedAircraft(noRequested, initialCallsigns);
|
||||
|
||||
// real value
|
||||
int noRendered = this->getIContextSimulator()->getMaxRenderedAircraft();
|
||||
if (noRequested == noRendered)
|
||||
{
|
||||
CLogMessage(this).info("Max.rendered aircraft: %1") << noRendered;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).info("Max.rendered aircraft: %1, requested: %2") << noRendered << noRequested;
|
||||
this->ui->sb_MaxAircraft->setValue(noRendered);
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onSaveAircraft()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
@@ -292,12 +254,18 @@ namespace BlackGui
|
||||
|
||||
void CMappingComponent::ps_onModelPreviewChanged(int state)
|
||||
{
|
||||
static const QPixmap empty;
|
||||
Qt::CheckState s = static_cast<Qt::CheckState>(state);
|
||||
if (s == Qt::Unchecked)
|
||||
{
|
||||
this->ui->lbl_AircraftIconDisplayed->setPixmap(QPixmap());
|
||||
this->ui->lbl_AircraftIconDisplayed->setPixmap(empty);
|
||||
this->ui->lbl_AircraftIconDisplayed->setText("Icon disabled");
|
||||
}
|
||||
else if (s == Qt::Checked)
|
||||
{
|
||||
this->ui->lbl_AircraftIconDisplayed->setPixmap(empty);
|
||||
this->ui->lbl_AircraftIconDisplayed->setText("Icon will go here");
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onMappingsUpdateRequested()
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace BlackGui
|
||||
//! \copydoc CListModelBase::getModelsStartsWith
|
||||
BlackMisc::Simulation::CAircraftModelList findModelsStartingWith(const QString modelName, Qt::CaseSensitivity cs);
|
||||
|
||||
signals:
|
||||
//! Request a text message
|
||||
void requestTextMessage(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
@@ -75,9 +79,6 @@ namespace BlackGui
|
||||
//! Model selected (in view)
|
||||
void ps_onModelSelectedInView(const QModelIndex &index);
|
||||
|
||||
//! Apply new max remote aircraft
|
||||
void ps_onApplyNewMaxRemoteAircraft();
|
||||
|
||||
//! Save changed aircraft
|
||||
void ps_onSaveAircraft();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_MappingComponent" columnstretch="0,0,1,4,0">
|
||||
<layout class="QGridLayout" name="gl_MappingComponent" columnstretch="0,0,1,3,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -35,10 +35,30 @@
|
||||
<property name="horizontalSpacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="3" column="2">
|
||||
<widget class="QSpinBox" name="sb_MaxAircraft">
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftIcon">
|
||||
<property name="text">
|
||||
<string>Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="3" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="lbl_AircraftIconDisplayed">
|
||||
<property name="text">
|
||||
<string>aircraft icon will go here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="cb_AircraftIconDisplayed">
|
||||
<property name="toolTip">
|
||||
<string>show / hide icon</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -116,41 +136,6 @@
|
||||
<item row="2" column="3">
|
||||
<widget class="QLineEdit" name="le_AircraftModel"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lbl_MaxAircraft">
|
||||
<property name="text">
|
||||
<string>Max. aircraft </string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QSlider" name="hs_MaxAircraft">
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>40</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="le_Callsign">
|
||||
<property name="maxLength">
|
||||
@@ -175,13 +160,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="pb_ApplyMaxAircraft">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="cb_AircraftEnabled">
|
||||
<property name="toolTip">
|
||||
@@ -192,33 +170,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftIcon">
|
||||
<property name="text">
|
||||
<string>Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="3" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="lbl_AircraftIconDisplayed">
|
||||
<property name="text">
|
||||
<string>aircraft icon will go here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="cb_AircraftIconDisplayed">
|
||||
<property name="toolTip">
|
||||
<string>show / hide icon</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace BlackGui
|
||||
{
|
||||
CSettingsComponent::CSettingsComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CSettingsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -77,11 +76,9 @@ namespace BlackGui
|
||||
*/
|
||||
void CSettingsComponent::reloadSettings()
|
||||
{
|
||||
// local copy
|
||||
CSettingsNetwork nws = this->getIContextSettings()->getNetworkSettings();
|
||||
|
||||
// update servers
|
||||
this->ui->tvp_SettingsTnServers->updateContainer(nws.getTrafficNetworkServers());
|
||||
// reload components
|
||||
this->ui->comp_AudioSetup->reloadSettings();
|
||||
this->ui->comp_SettingsServersComponent->reloadSettings();
|
||||
|
||||
// update hot keys
|
||||
this->ui->tvp_SettingsMiscHotkeys->updateContainer(this->getIContextSettings()->getHotkeys());
|
||||
@@ -100,7 +97,7 @@ namespace BlackGui
|
||||
*/
|
||||
void CSettingsComponent::runtimeHasBeenSet()
|
||||
{
|
||||
if (!this->getIContextSettings()) qFatal("Settings missing");
|
||||
Q_ASSERT_X(this->getIContextSettings(), "runtimeHasBeenSet", "Missing settings");
|
||||
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsComponent::ps_changedSettings);
|
||||
|
||||
// Opacity, intervals
|
||||
@@ -109,11 +106,6 @@ namespace BlackGui
|
||||
this->connect(this->ui->hs_SettingsGuiAtcRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedAtcStationsUpdateInterval);
|
||||
this->connect(this->ui->hs_SettingsGuiUserRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedUsersUpdateInterval);
|
||||
|
||||
// Settings server
|
||||
this->connect(this->ui->pb_SettingsTnRemoveServer, &QPushButton::released, this, &CSettingsComponent::ps_alterTrafficServer);
|
||||
this->connect(this->ui->pb_SettingsTnSaveServer, &QPushButton::released, this, &CSettingsComponent::ps_alterTrafficServer);
|
||||
this->connect(this->ui->tvp_SettingsTnServers, &QTableView::clicked, this, &CSettingsComponent::ps_networkServerSelected);
|
||||
|
||||
// Settings hotkeys
|
||||
this->connect(this->ui->pb_SettingsMiscCancel, &QPushButton::clicked, this, &CSettingsComponent::reloadSettings);
|
||||
this->connect(this->ui->pb_SettingsMiscSave, &QPushButton::clicked, this, &CSettingsComponent::ps_saveHotkeys);
|
||||
@@ -136,42 +128,6 @@ namespace BlackGui
|
||||
Q_UNUSED(connected);
|
||||
}
|
||||
|
||||
/*
|
||||
* Network has been selected
|
||||
*/
|
||||
void CSettingsComponent::ps_networkServerSelected(QModelIndex index)
|
||||
{
|
||||
const CServer clickedServer = this->ui->tvp_SettingsTnServers->at(index);
|
||||
this->ui->frp_ServerForm->setServer(clickedServer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Alter server
|
||||
*/
|
||||
void CSettingsComponent::ps_alterTrafficServer()
|
||||
{
|
||||
CServer server = this->ui->frp_ServerForm->getServer();
|
||||
CStatusMessageList msgs = server.validate();
|
||||
if (!msgs.isEmpty())
|
||||
{
|
||||
msgs.addCategories(this);
|
||||
msgs.addCategory(CLogCategory::validation());
|
||||
CLogMessage::preformatted(msgs);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathNetworkSettings(), CSettingsNetwork::ValueTrafficServers());
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == this->ui->pb_SettingsTnRemoveServer)
|
||||
{
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdRemove(), server.toCVariant());
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsTnSaveServer)
|
||||
{
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), server.toCVariant());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Settings did change
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,8 @@ namespace BlackGui
|
||||
//! Tabs
|
||||
enum SettingTab
|
||||
{
|
||||
SettingTabNetwork = 0,
|
||||
SettingTabNetworkServers = 0,
|
||||
SettingTabNetwork,
|
||||
SettingTabAircraftAudio,
|
||||
SettingTabSimulator,
|
||||
SettingTabGui,
|
||||
@@ -93,12 +94,6 @@ namespace BlackGui
|
||||
|
||||
private slots:
|
||||
|
||||
//! Network server selected
|
||||
void ps_networkServerSelected(QModelIndex index);
|
||||
|
||||
//! Alter traffic server
|
||||
void ps_alterTrafficServer();
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_changedSettings(uint typeValue);
|
||||
|
||||
|
||||
@@ -22,6 +22,38 @@
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_SettingsTrafficNetworkServers">
|
||||
<attribute name="title">
|
||||
<string>Servers</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_SettingsTrafficNetworkServers">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CSettingsNetworkServersComponent" name="comp_SettingsServersComponent">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
|
||||
<attribute name="title">
|
||||
<string>Network</string>
|
||||
@@ -43,41 +75,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CServerView" name="tvp_SettingsTnServers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::CServerForm" name="frp_ServerForm">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="BlackGui::Components::CSettingsNetworkComponent" name="comp_SettingsNetwork">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
@@ -86,63 +84,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_SettingsTnButtons">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_SettingsBottomBar">
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="hs_SettingsTnSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsTnSaveServer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsTnRemoveServer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_SettingsAudio">
|
||||
@@ -609,11 +550,6 @@
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/keyboardkeyview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CServerView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/serverview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSettingsSimulatorComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
@@ -621,9 +557,15 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CServerForm</class>
|
||||
<class>BlackGui::Components::CSettingsNetworkServersComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/serverform.h</header>
|
||||
<header>blackgui/components/settingsnetworkserverscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSettingsNetworkComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/settingsnetworkcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
||||
50
src/blackgui/components/settingsnetworkcomponent.cpp
Normal file
50
src/blackgui/components/settingsnetworkcomponent.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "settingsnetworkcomponent.h"
|
||||
#include "ui_settingsnetworkcomponent.h"
|
||||
#include "blackcore/context_network.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CSettingsNetworkComponent::CSettingsNetworkComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsNetworkComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(this->ui->cb_FastPositionUpdates, &QCheckBox::released, this, &CSettingsNetworkComponent::ps_guiValuesChanged);
|
||||
}
|
||||
|
||||
CSettingsNetworkComponent::~CSettingsNetworkComponent() { }
|
||||
|
||||
void CSettingsNetworkComponent::runtimeHasBeenSet()
|
||||
{
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
bool enabled = this->getIContextNetwork()->isFastPositionSendingEnabled();
|
||||
this->ui->cb_FastPositionUpdates->setChecked(enabled);
|
||||
}
|
||||
|
||||
void CSettingsNetworkComponent::ps_guiValuesChanged()
|
||||
{
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == ui->cb_FastPositionUpdates)
|
||||
{
|
||||
bool enabled = this->ui->cb_FastPositionUpdates->isChecked();
|
||||
this->getIContextNetwork()->enableFastPositionSending(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
54
src/blackgui/components/settingsnetworkcomponent.h
Normal file
54
src/blackgui/components/settingsnetworkcomponent.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_SETTINGSNETWORKCOMPONENT_H
|
||||
#define BLACKGUI_SETTINGSNETWORKCOMPONENT_H
|
||||
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CSettingsNetworkComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
//! General settings for network
|
||||
class CSettingsNetworkComponent :
|
||||
public QFrame,
|
||||
public CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsNetworkComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CSettingsNetworkComponent();
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
|
||||
private:
|
||||
//! GUI values have been changed
|
||||
void ps_guiValuesChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSettingsNetworkComponent> ui;
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
54
src/blackgui/components/settingsnetworkcomponent.ui
Normal file
54
src/blackgui/components/settingsnetworkcomponent.ui
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsNetworkComponent</class>
|
||||
<widget class="QFrame" name="CSettingsNetworkComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="cb_FastPositionUpdates">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_FastPositionUpdates">
|
||||
<property name="text">
|
||||
<string>Enable fast position updates</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="vs_NetworkSettings">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
98
src/blackgui/components/settingsnetworkserverscomponent.cpp
Normal file
98
src/blackgui/components/settingsnetworkserverscomponent.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "settingsnetworkserverscomponent.h"
|
||||
#include "ui_settingsnetworkserverscomponent.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/settingsblackmiscclasses.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackMisc::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CSettingsNetworkServersComponent::CSettingsNetworkServersComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsNetworkServersComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Settings server
|
||||
this->connect(this->ui->pb_SettingsTnServersRemoveServer, &QPushButton::pressed, this, &CSettingsNetworkServersComponent::ps_alterTrafficServer);
|
||||
this->connect(this->ui->pb_SettingsTnServersSaveServer, &QPushButton::pressed, this, &CSettingsNetworkServersComponent::ps_alterTrafficServer);
|
||||
this->connect(this->ui->tvp_SettingsTnServers, &QTableView::clicked, this, &CSettingsNetworkServersComponent::ps_networkServerSelected);
|
||||
}
|
||||
|
||||
CSettingsNetworkServersComponent::~CSettingsNetworkServersComponent()
|
||||
{ }
|
||||
|
||||
void CSettingsNetworkServersComponent::runtimeHasBeenSet()
|
||||
{
|
||||
Q_ASSERT_X(this->getIContextSettings(), "runtimeHasBeenSet", "Missing settings");
|
||||
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsNetworkServersComponent::ps_changedSettings);
|
||||
}
|
||||
|
||||
void CSettingsNetworkServersComponent::reloadSettings()
|
||||
{
|
||||
// local copy
|
||||
CSettingsNetwork nws = this->getIContextSettings()->getNetworkSettings();
|
||||
|
||||
// update servers
|
||||
this->ui->tvp_SettingsTnServers->updateContainer(nws.getTrafficNetworkServers());
|
||||
}
|
||||
|
||||
void CSettingsNetworkServersComponent::ps_networkServerSelected(QModelIndex index)
|
||||
{
|
||||
const CServer clickedServer = this->ui->tvp_SettingsTnServers->at(index);
|
||||
this->ui->frp_ServerForm->setServer(clickedServer);
|
||||
}
|
||||
|
||||
void CSettingsNetworkServersComponent::ps_alterTrafficServer()
|
||||
{
|
||||
CServer server = this->ui->frp_ServerForm->getServer();
|
||||
CStatusMessageList msgs = server.validate();
|
||||
if (!msgs.isEmpty())
|
||||
{
|
||||
msgs.addCategories(this);
|
||||
msgs.addCategory(CLogCategory::validation());
|
||||
CLogMessage::preformatted(msgs);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathNetworkSettings(), CSettingsNetwork::ValueTrafficServers());
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == this->ui->pb_SettingsTnServersRemoveServer)
|
||||
{
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdRemove(), server.toCVariant());
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsTnServersSaveServer)
|
||||
{
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), server.toCVariant());
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsNetworkServersComponent::ps_changedSettings(uint typeValue)
|
||||
{
|
||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
Q_UNUSED(type);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
63
src/blackgui/components/settingsnetworkserverscomponent.h
Normal file
63
src/blackgui/components/settingsnetworkserverscomponent.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_SETTINGSNETWORKSERVERSCOMPONENT_H
|
||||
#define BLACKGUI_SETTINGSNETWORKSERVERSCOMPONENT_H
|
||||
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CSettingsNetworkServersComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Settings for network servers
|
||||
class CSettingsNetworkServersComponent :
|
||||
public QFrame,
|
||||
public CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsNetworkServersComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CSettingsNetworkServersComponent();
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
|
||||
public slots:
|
||||
//! Reload settings
|
||||
void reloadSettings();
|
||||
|
||||
private slots:
|
||||
//! Network server selected
|
||||
void ps_networkServerSelected(QModelIndex index);
|
||||
|
||||
//! Alter traffic server
|
||||
void ps_alterTrafficServer();
|
||||
|
||||
//! Changed settings
|
||||
void ps_changedSettings(uint typeValue);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSettingsNetworkServersComponent> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
162
src/blackgui/components/settingsnetworkserverscomponent.ui
Normal file
162
src/blackgui/components/settingsnetworkserverscomponent.ui
Normal file
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsNetworkServersComponent</class>
|
||||
<widget class="QFrame" name="CSettingsNetworkServersComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_SettingsNetworkSevers">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CServerView" name="tvp_SettingsTnServers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::CServerForm" name="frp_ServerForm">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_SettingsTnServersButtons">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_SettingsBottomBar">
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="hs_SettingsTnServersSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsTnServersSaveServer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsTnServersRemoveServer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CServerView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/serverview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CServerForm</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/serverform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -3,8 +3,10 @@
|
||||
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blacksim/simulatorinfolist.h"
|
||||
#include "blacksim/setsimulator.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/variant.h"
|
||||
@@ -14,6 +16,8 @@
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackSim;
|
||||
using namespace BlackSim::Settings;
|
||||
using namespace BlackCore;
|
||||
@@ -57,6 +61,9 @@ namespace BlackGui
|
||||
CTime timeOffset = this->getIContextSimulator()->getTimeSynchronizationOffset();
|
||||
this->ui->le_TimeSyncOffset->setText(timeOffset.formattedHrsMin());
|
||||
|
||||
// max.aircraft
|
||||
this->ui->sb_MaxAircraft->setValue(getIContextSimulator()->getMaxRenderedAircraft());
|
||||
|
||||
// only with simulator context set GUI values
|
||||
bool connected = this->connect(this->ui->cb_Plugins, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_pluginHasChanged(int)));
|
||||
Q_ASSERT(connected);
|
||||
@@ -68,8 +75,8 @@ namespace BlackGui
|
||||
connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsSimulatorComponent::ps_settingsHaveChanged);
|
||||
}
|
||||
|
||||
connect(this->ui->cb_TimeSync, &QCheckBox::released, this, &CSettingsSimulatorComponent::ps_guiValueHasChanged);
|
||||
connect(this->ui->le_TimeSyncOffset, &QLineEdit::returnPressed, this, &CSettingsSimulatorComponent::ps_guiValueHasChanged);
|
||||
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyNewMaxRemoteAircraft);
|
||||
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::setCurrentPlugin(const CSimulatorInfo &plugin)
|
||||
@@ -124,37 +131,50 @@ namespace BlackGui
|
||||
this->ui->cb_TimeSync->setChecked(simSettings.isTimeSyncEnabled());
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_guiValueHasChanged()
|
||||
void CSettingsSimulatorComponent::ps_onApplyNewMaxRemoteAircraft()
|
||||
{
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
if (!this->getIContextSettings()) return;
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
Q_ASSERT(getIContextNetwork());
|
||||
|
||||
QObject *sender = QObject::sender();
|
||||
if (!sender) return;
|
||||
// get initial aircraft to render
|
||||
int noRequested = this->ui->sb_MaxAircraft->value();
|
||||
CSimulatedAircraftList inRange(this->getIContextNetwork()->getAircraftInRange());
|
||||
inRange.truncate(noRequested);
|
||||
inRange.sortByDistanceToOwnAircraft();
|
||||
CCallsignList initialCallsigns(inRange.getCallsigns());
|
||||
this->getIContextSimulator()->setMaxRenderedAircraft(noRequested, initialCallsigns);
|
||||
|
||||
const QString ps = IContextSettings::PathSimulatorSettings();
|
||||
if (sender == this->ui->cb_TimeSync)
|
||||
// real value
|
||||
int noRendered = this->getIContextSimulator()->getMaxRenderedAircraft();
|
||||
if (noRequested == noRendered)
|
||||
{
|
||||
bool timeSync = this->ui->cb_TimeSync->isChecked();
|
||||
this->getIContextSettings()->value(CSettingUtilities::appendPaths(ps, CSettingsSimulator::ValueSyncTime()), CSettingUtilities::CmdUpdate(), CVariant::from(timeSync));
|
||||
CLogMessage(this).info("Max.rendered aircraft: %1") << noRendered;
|
||||
}
|
||||
else if (sender == this->ui->le_TimeSyncOffset)
|
||||
else
|
||||
{
|
||||
const QString os = this->ui->le_TimeSyncOffset->text();
|
||||
CTime ost(0, CTimeUnit::hrmin());
|
||||
if (!os.isEmpty())
|
||||
{
|
||||
ost.parseFromString(os);
|
||||
}
|
||||
if (ost.isNull())
|
||||
{
|
||||
CLogMessage().validationWarning("Invalid offset time");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->getIContextSettings()->value(CSettingUtilities::appendPaths(ps, CSettingsSimulator::ValueSyncTimeOffset()), CSettingUtilities::CmdUpdate(), ost.toCVariant());
|
||||
}
|
||||
CLogMessage(this).info("Max.rendered aircraft: %1, requested: %2") << noRendered << noRequested;
|
||||
this->ui->sb_MaxAircraft->setValue(noRendered);
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_onApplyTimeSync()
|
||||
{
|
||||
bool timeSync = this->ui->cb_TimeSync->isChecked();
|
||||
const QString os = this->ui->le_TimeSyncOffset->text();
|
||||
CTime ost(0, CTimeUnit::hrmin());
|
||||
if (!os.isEmpty())
|
||||
{
|
||||
ost.parseFromString(os);
|
||||
}
|
||||
if (ost.isNull())
|
||||
{
|
||||
CLogMessage().validationWarning("Invalid offset time");
|
||||
}
|
||||
else
|
||||
{
|
||||
getIContextSimulator()->setTimeSynchronization(timeSync, ost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -46,8 +46,11 @@ namespace BlackGui
|
||||
//! Settings have been changed
|
||||
void ps_settingsHaveChanged(uint settingsType);
|
||||
|
||||
//! A GUI value has been changed
|
||||
void ps_guiValueHasChanged();
|
||||
//! Apply max aircraft
|
||||
void ps_onApplyNewMaxRemoteAircraft();
|
||||
|
||||
//! Apply time sync
|
||||
void ps_onApplyTimeSync();
|
||||
|
||||
private:
|
||||
Ui::CSettingsSimulatorComponent *ui; //!< UI
|
||||
|
||||
@@ -118,6 +118,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>offset +/-hh:mm</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string>#99:99</string>
|
||||
</property>
|
||||
@@ -130,34 +133,72 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_TimeSyncOffset">
|
||||
<widget class="QPushButton" name="pb_ApplyTimeSync">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>offset +/-hh:mm</string>
|
||||
<string>apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_TimeSync">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_MaxAircraft">
|
||||
<property name="text">
|
||||
<string>Max.aircraft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="hl_MaxAircraft">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sb_MaxAircraft"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ApplyMaxAircraft">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace BlackGui
|
||||
this->ui->le_textMessages->setVisible(false);
|
||||
connect(this->ui->le_textMessages, &QLineEdit::returnPressed, this, &CTextMessageComponent::ps_textMessageEntered);
|
||||
|
||||
this->ui->tvp_TextMessagesAll->rowsResizeModeToContent();
|
||||
this->ui->tvp_TextMessagesAll->setResizeMode(CTextMessageView::ResizingAuto);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user