Also allow to use SHIFT + button for models, aircraft

* added setTab functions
* shift can be used to reset to first tab
This commit is contained in:
Klaus Basan
2018-08-08 01:12:31 +02:00
parent 461d146619
commit 92deb19572
11 changed files with 62 additions and 29 deletions

View File

@@ -116,6 +116,12 @@ namespace BlackGui
m_updateCounter++;
}
void CAircraftComponent::setTab(CAircraftComponent::AircraftTab tab)
{
const int tabIndex = static_cast<int>(tab);
this->setCurrentIndex(tabIndex);
}
void CAircraftComponent::onInfoAreaTabBarChanged(int index)
{
// ignore in those cases

View File

@@ -23,8 +23,6 @@
#include <QtGlobal>
#include <QTimer>
class QWidget;
namespace BlackMisc
{
namespace Aviation { class CCallsign; }
@@ -44,11 +42,19 @@ namespace BlackGui
Q_OBJECT
public:
//! Tab
//! \remark needs to be in sync with tab order
enum AircraftTab
{
TabAircraftInRange = 0,
TabAirportsInRange
};
//! Constructor
explicit CAircraftComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CAircraftComponent();
virtual ~CAircraftComponent() override;
//! Aircraft in range
int countAircraftInView() const;
@@ -62,6 +68,9 @@ namespace BlackGui
//! Update aircraft/airport view
void update();
//! Set tab
void setTab(AircraftTab tab);
signals:
//! Request a text message
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);

View File

@@ -112,14 +112,23 @@ namespace BlackGui
void CMainInfoAreaComponent::selectArea(CMainInfoAreaComponent::InfoArea infoArea)
{
CInfoArea::selectArea(static_cast<int>(infoArea));
const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers();
const bool shift = km.testFlag(Qt::ShiftModifier);
if (!shift) { return; }
// pressing shift will go to overview
if (infoArea == InfoAreaSettings)
{
// pressing shift will go to overview
const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers();
if (km.testFlag(Qt::ShiftModifier))
{
ui->comp_Settings->setSettingsOverviewTab();
}
ui->comp_Settings->setSettingsOverviewTab();
}
else if (infoArea == InfoAreaAircraft)
{
ui->comp_Aircraft->setTab(CAircraftComponent::TabAircraftInRange);
}
else if (infoArea == InfoAreaMapping)
{
ui->comp_Mappings->setTab(CMappingComponent::TabRenderedAircraft);
}
}
@@ -156,7 +165,7 @@ namespace BlackGui
void CMainInfoAreaComponent::selectSettingsTab(int index)
{
this->selectArea(InfoAreaSettings);
ui->comp_Settings->setSettingsTab(static_cast<CSettingsComponent::SettingTab>(index));
ui->comp_Settings->setTab(static_cast<CSettingsComponent::SettingTab>(index));
}
void CMainInfoAreaComponent::selectAudioTab()

View File

@@ -50,7 +50,7 @@ namespace BlackGui
explicit CMainInfoAreaComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CMainInfoAreaComponent();
virtual ~CMainInfoAreaComponent() override;
//! Info areas
enum InfoArea

View File

@@ -104,13 +104,13 @@ namespace BlackGui
{
QPushButton *senderButton = static_cast<QPushButton *>(QObject::sender());
Q_ASSERT_X(senderButton, Q_FUNC_INFO, "No sender button");
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
if (!sGui || sGui->isShuttingDown()) { return; }
if (!senderButton) { return; }
const CMainInfoAreaComponent::InfoArea ia = buttonToMainInfoArea(senderButton);
if (ia != CMainInfoAreaComponent::InfoAreaNone)
const CMainInfoAreaComponent::InfoArea infoArea = buttonToMainInfoArea(senderButton);
if (infoArea != CMainInfoAreaComponent::InfoAreaNone)
{
Q_ASSERT(senderButton->isCheckable());
emit this->selectedMainInfoAreaDockWidget(ia);
emit this->selectedMainInfoAreaDockWidget(infoArea);
senderButton->setChecked(true); // re-check if got unchecked, we use checked buttons like normal buttons
return;
}
@@ -137,11 +137,11 @@ namespace BlackGui
}
else if (senderButton == ui->pb_Connect)
{
emit connectPressed();
emit this->connectPressed();
}
else if (senderButton == ui->pb_Audio)
{
emit audioPressed();
emit this->audioPressed();
}
}

View File

@@ -45,6 +45,9 @@ namespace BlackGui
//! Destructor
virtual ~CMainKeypadAreaComponent();
//! Main info area changed
void onMainInfoAreaChanged(int currentTabIndex, QList<int> dockedIndexes, QList<int> floatingIndexes);
signals:
//! Button to select main info area has been pressed
//! \sa CMainInfoAreaComponent
@@ -68,10 +71,6 @@ namespace BlackGui
//! Request audio
void audioPressed();
public slots:
//! Main info area changed
void onMainInfoAreaChanged(int currentTabIndex, QList<int> dockedIndexes, QList<int> floatingIndexes);
private:
//! Button was clicked
void buttonSelected();

View File

@@ -176,6 +176,12 @@ namespace BlackGui
return ui->tvp_AircraftModels->rowCount();
}
void CMappingComponent::setTab(CMappingComponent::TabWidget tab)
{
const int tabIndex = static_cast<int>(tab);
ui->tw_SpecializedViews->setCurrentIndex(tabIndex);
}
CAircraftModelList CMappingComponent::findModelsStartingWith(const QString modelName, Qt::CaseSensitivity cs)
{
Q_ASSERT(ui->tvp_AircraftModels);

View File

@@ -55,6 +55,7 @@ namespace BlackGui
public:
//! Tab widget
//! \remark needs to be in sync with tab order
enum TabWidget
{
TabRenderedAircraft = 0,
@@ -65,21 +66,24 @@ namespace BlackGui
TabPartsLog
};
//! Log categories
static const BlackMisc::CLogCategoryList &getLogCategories();
//! Constructor
explicit CMappingComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CMappingComponent();
//! Log categories
static const BlackMisc::CLogCategoryList &getLogCategories();
//! Number of current mappings
int countCurrentMappings() const;
//! Numer of models
int countAircraftModels() const;
//! Set tab
void setTab(TabWidget tab);
//! Find models starting with
BlackMisc::Simulation::CAircraftModelList findModelsStartingWith(const QString modelName, Qt::CaseSensitivity cs);

View File

@@ -141,14 +141,14 @@ namespace BlackGui
return ui->comp_SettingsSimulatorBasics->getSimulatorSettings(simulator);
}
void CSettingsComponent::setSettingsTab(CSettingsComponent::SettingTab tab)
void CSettingsComponent::setTab(CSettingsComponent::SettingTab tab)
{
this->setCurrentIndex(static_cast<int>(tab));
}
void CSettingsComponent::setSettingsOverviewTab()
{
this->setSettingsTab(SettingTabOverview);
this->setTab(SettingTabOverview);
}
void CSettingsComponent::setGuiOpacity(double value)

View File

@@ -63,7 +63,7 @@ namespace BlackGui
BlackMisc::Simulation::Settings::CSpecializedSimulatorSettings getSimulatorSettings(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Set the tab
void setSettingsTab(SettingTab tab);
void setTab(SettingTab tab);
//! Set the overview tab
void setSettingsOverviewTab();
@@ -96,7 +96,7 @@ namespace BlackGui
QScopedPointer<Ui::CSettingsComponent> ui;
};
}
} // namespace
} // namespace
#endif // guard

View File

@@ -244,7 +244,7 @@ void SwiftGuiStd::initGuiSignals()
connect(ui->comp_Login, &CLoginComponent::requestNetworkSettings, [ this ]()
{
this->setMainPageInfoArea(CMainInfoAreaComponent::InfoAreaSettings);
ui->comp_MainInfoArea->getSettingsComponent()->setSettingsTab(CSettingsComponent::SettingTabServers);
ui->comp_MainInfoArea->getSettingsComponent()->setTab(CSettingsComponent::SettingTabServers);
});
connect(this, &SwiftGuiStd::currentMainInfoAreaChanged, ui->comp_Login, &CLoginComponent::mainInfoAreaChanged);