mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Mapping component, hide splitter when model details are not needed (based on selected tab)
This commit is contained in:
@@ -72,7 +72,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(sGui->getIContextNetwork(), Q_FUNC_INFO, "need network context");
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->tw_ListViews->setCurrentIndex(0);
|
||||
ui->tw_SpecializedViews->setCurrentIndex(0);
|
||||
|
||||
ui->tvp_AircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnAircraftModelClient);
|
||||
ui->tvp_AircraftModels->setResizeMode(CAircraftModelView::ResizingOff);
|
||||
@@ -139,6 +139,8 @@ namespace BlackGui
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::removedAircraft, this, &CMappingComponent::tokenBucketUpdate);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMappingComponent::onConnectionStatusChanged);
|
||||
|
||||
connect(ui->tw_SpecializedViews, &QTabWidget::currentChanged, this, &CMappingComponent::onTabWidgetChanged);
|
||||
|
||||
// requires simulator context
|
||||
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView);
|
||||
|
||||
@@ -188,15 +190,15 @@ namespace BlackGui
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
const int am = ui->tw_ListViews->indexOf(ui->tb_AircraftModels);
|
||||
const int cm = ui->tw_ListViews->indexOf(ui->tb_CurrentMappings);
|
||||
const int am = ui->tw_SpecializedViews->indexOf(ui->tb_AircraftModels);
|
||||
const int cm = ui->tw_SpecializedViews->indexOf(ui->tb_CurrentMappings);
|
||||
const QString amf = ui->tvp_AircraftModels->derivedModel()->hasFilter() ? "F" : "";
|
||||
QString a = ui->tw_ListViews->tabBar()->tabText(am);
|
||||
QString c = ui->tw_ListViews->tabBar()->tabText(cm);
|
||||
QString a = ui->tw_SpecializedViews->tabBar()->tabText(am);
|
||||
QString c = ui->tw_SpecializedViews->tabBar()->tabText(cm);
|
||||
a = CGuiUtility::replaceTabCountValue(a, this->countAircraftModels()) + amf;
|
||||
c = CGuiUtility::replaceTabCountValue(c, this->countCurrentMappings());
|
||||
ui->tw_ListViews->tabBar()->setTabText(am, a);
|
||||
ui->tw_ListViews->tabBar()->setTabText(cm, c);
|
||||
ui->tw_SpecializedViews->tabBar()->setTabText(am, a);
|
||||
ui->tw_SpecializedViews->tabBar()->setTabText(cm, c);
|
||||
}
|
||||
|
||||
void CMappingComponent::onChangedSimulatedAircraftInView(const CVariant &object, const CPropertyIndex &index)
|
||||
@@ -426,6 +428,25 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::showAircraftModelDetails(bool show)
|
||||
{
|
||||
QList<int> sizes = ui->sp_MappingComponentSplitter->sizes();
|
||||
Q_ASSERT_X(sizes.size() == 2, Q_FUNC_INFO, "Wrong splitter sizes");
|
||||
const int total = sizes[0] + sizes[1];
|
||||
QList<int> newSizes({0, 0});
|
||||
if (show)
|
||||
{
|
||||
newSizes[0] = total * 0.8;
|
||||
newSizes[1] = total * 0.2;
|
||||
}
|
||||
else
|
||||
{
|
||||
newSizes[0] = total;
|
||||
newSizes[1] = 0;
|
||||
}
|
||||
ui->sp_MappingComponentSplitter->setSizes(newSizes);
|
||||
}
|
||||
|
||||
void CMappingComponent::addingRemoteAircraftFailed(const CSimulatedAircraft &aircraft, const CStatusMessage &message)
|
||||
{
|
||||
this->tokenBucketUpdate();
|
||||
@@ -441,6 +462,14 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::onTabWidgetChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
const TabWidget w = static_cast<TabWidget>(index);
|
||||
const bool show = (w == TabAircraftModels) || (w == TabRenderedAircraft);
|
||||
this->showAircraftModelDetails(show);
|
||||
}
|
||||
|
||||
void CMappingComponent::updateRenderedAircraftView(bool forceUpdate)
|
||||
{
|
||||
m_updateTimer.start(); // restart
|
||||
|
||||
@@ -55,6 +55,16 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Tab widget
|
||||
enum TabWidget {
|
||||
TabRenderedAircraft = 0,
|
||||
TabAircraftModels,
|
||||
TabInterpolatorSetup,
|
||||
TabStatistics,
|
||||
TabMatchingLog,
|
||||
TabPartsLog
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
explicit CMappingComponent(QWidget *parent = nullptr);
|
||||
|
||||
@@ -118,9 +128,15 @@ namespace BlackGui
|
||||
//! Enable / disable aircraft
|
||||
void onMenuToggleEnableAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Widget changed
|
||||
void onTabWidgetChanged(int index);
|
||||
|
||||
//! Highlight in simulator
|
||||
void onMenuHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Show / hide model details
|
||||
void showAircraftModelDetails(bool show);
|
||||
|
||||
//! Adding a remote aircraft failed
|
||||
void addingRemoteAircraftFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CStatusMessage &message);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTabWidget" name="tw_ListViews">
|
||||
<widget class="QTabWidget" name="tw_SpecializedViews">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -149,28 +149,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_AircraftPartsHistory">
|
||||
<attribute name="title">
|
||||
<string>Aircraft parts log</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_AircraftPartsHistory">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CAircraftPartsHistory" name="comp_AircraftPartsHistory"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QFrame" name="fr_AircraftModifications">
|
||||
<property name="maximumSize">
|
||||
@@ -327,12 +305,6 @@
|
||||
<header>blackgui/components/modelmatcherlogcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CAircraftPartsHistory</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/aircraftpartshistory.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CAircraftModelStringCompleter</class>
|
||||
<extends>QFrame</extends>
|
||||
|
||||
Reference in New Issue
Block a user