Ref T659, improved handling of override checkbox in FSD details/voice

* the checkbox can be always enabled
* or disabled in read only mode
This commit is contained in:
Klaus Basan
2019-08-06 20:09:00 +02:00
committed by Mat Sutcliffe
parent 4e9bf35cfc
commit d546ebdcba
7 changed files with 60 additions and 3 deletions

View File

@@ -101,9 +101,11 @@ namespace BlackGui
ui->form_FsdDetails->showEnableInfo(true); ui->form_FsdDetails->showEnableInfo(true);
ui->form_FsdDetails->setFsdSetupEnabled(false); ui->form_FsdDetails->setFsdSetupEnabled(false);
ui->form_FsdDetails->setAlwaysAllowOverride(true);
ui->form_Voice->showEnableInfo(true); ui->form_Voice->showEnableInfo(true);
ui->form_Voice->setVoiceSetupEnabled(false); ui->form_Voice->setVoiceSetupEnabled(false);
ui->form_Voice->setAlwaysAllowOverride(true);
ui->lblp_AircraftCombinedType->setToolTips("ok", "wrong"); ui->lblp_AircraftCombinedType->setToolTips("ok", "wrong");
ui->lblp_AirlineIcao->setToolTips("ok", "wrong"); ui->lblp_AirlineIcao->setToolTips("ok", "wrong");

View File

@@ -65,6 +65,16 @@ namespace BlackGui
ui->cb_3LetterAirlineICAO->setChecked(setup.force3LetterAirlineCodes()); ui->cb_3LetterAirlineICAO->setChecked(setup.force3LetterAirlineCodes());
} }
void CFsdSetupForm::setAlwaysAllowOverride(bool allow)
{
m_alwaysAllowOverride = allow;
if (allow)
{
ui->cb_Override->setEnabled(true);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false);
}
}
bool CFsdSetupForm::isFsdSetupEnabled() const bool CFsdSetupForm::isFsdSetupEnabled() const
{ {
return ui->cb_Override->isChecked(); return ui->cb_Override->isChecked();
@@ -86,12 +96,20 @@ namespace BlackGui
ui->le_TextCodec->setReadOnly(readonly); ui->le_TextCodec->setReadOnly(readonly);
ui->pb_SetDefaults->setEnabled(!readonly); ui->pb_SetDefaults->setEnabled(!readonly);
CGuiUtility::checkBoxesReadOnly(this, readonly); CGuiUtility::checkBoxesReadOnly(this, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false); // always editable if (m_alwaysAllowOverride)
{
ui->cb_Override->setEnabled(true);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false);
}
/**
if (readonly && ui->cb_Override->isChecked()) if (readonly && ui->cb_Override->isChecked())
{ {
// this is no value which will be stored
ui->cb_Override->setChecked(false); ui->cb_Override->setChecked(false);
} }
**/
this->forceStyleSheetUpdate(); this->forceStyleSheetUpdate();
} }

View File

@@ -44,6 +44,9 @@ namespace BlackGui
//! Set to GUI //! Set to GUI
void setValue(const BlackMisc::Network::CFsdSetup &setup); void setValue(const BlackMisc::Network::CFsdSetup &setup);
//! Allow override even in read only mode
void setAlwaysAllowOverride(bool allow);
//! Enabled? //! Enabled?
bool isFsdSetupEnabled() const; bool isFsdSetupEnabled() const;
@@ -70,7 +73,8 @@ namespace BlackGui
void visibleEnableInfo(bool visible); void visibleEnableInfo(bool visible);
QScopedPointer<Ui::CFsdSetupForm> ui; QScopedPointer<Ui::CFsdSetupForm> ui;
bool m_visibleEnableInfo = true; bool m_visibleEnableInfo = true;
bool m_alwaysAllowOverride = false;
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -84,6 +84,11 @@ namespace BlackGui
return ui->cb_ServerType->currentData().value<CServer::ServerType>(); return ui->cb_ServerType->currentData().value<CServer::ServerType>();
} }
void CServerForm::resetToFirstTab()
{
ui->tw_ServerForm->setCurrentIndex(0);
}
void CServerForm::setReadOnly(bool readOnly) void CServerForm::setReadOnly(bool readOnly)
{ {
ui->form_ServerFsd->setReadOnly(readOnly); ui->form_ServerFsd->setReadOnly(readOnly);

View File

@@ -47,6 +47,9 @@ namespace BlackGui
//! Get currently selected server type //! Get currently selected server type
BlackMisc::Network::CServer::ServerType getServerType() const; BlackMisc::Network::CServer::ServerType getServerType() const;
//! Reset to 1st tab
void resetToFirstTab();
//! \name Form class implementations //! \name Form class implementations
//! @{ //! @{
virtual void setReadOnly(bool readonly) override; virtual void setReadOnly(bool readonly) override;

View File

@@ -61,6 +61,16 @@ namespace BlackGui
ui->cb_Override->setChecked(enabled); ui->cb_Override->setChecked(enabled);
} }
void CVoiceSetupForm::setAlwaysAllowOverride(bool allow)
{
m_alwaysAllowOverride = allow;
if (allow)
{
ui->cb_Override->setEnabled(true);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false);
}
}
void CVoiceSetupForm::showEnableInfo(bool visible) void CVoiceSetupForm::showEnableInfo(bool visible)
{ {
m_visibleEnableInfo = visible; m_visibleEnableInfo = visible;
@@ -71,10 +81,21 @@ namespace BlackGui
{ {
ui->pb_SetDefaults->setEnabled(!readonly); ui->pb_SetDefaults->setEnabled(!readonly);
ui->le_VatsimUdpPort->setReadOnly(readonly); ui->le_VatsimUdpPort->setReadOnly(readonly);
CGuiUtility::checkBoxesReadOnly(this, readonly);
if (m_alwaysAllowOverride)
{
ui->cb_Override->setEnabled(true);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false);
}
/**
if (readonly && ui->cb_Override->isChecked()) if (readonly && ui->cb_Override->isChecked())
{ {
// this is no value which will be stored
ui->cb_Override->setChecked(false); ui->cb_Override->setChecked(false);
} }
**/
this->forceStyleSheetUpdate(); this->forceStyleSheetUpdate();
} }

View File

@@ -49,6 +49,9 @@ namespace BlackGui
//! Set enabled / disabled //! Set enabled / disabled
void setVoiceSetupEnabled(bool enabled); void setVoiceSetupEnabled(bool enabled);
//! Allow override even in read only mode
void setAlwaysAllowOverride(bool allow);
//! Show the enable info //! Show the enable info
void showEnableInfo(bool visible); void showEnableInfo(bool visible);
@@ -69,7 +72,8 @@ namespace BlackGui
void visibleEnableInfo(bool visible); void visibleEnableInfo(bool visible);
QScopedPointer<Ui::CVoiceSetupForm> ui; QScopedPointer<Ui::CVoiceSetupForm> ui;
bool m_visibleEnableInfo = true; bool m_alwaysAllowOverride = false;
bool m_visibleEnableInfo = true;
}; };
} // ns } // ns
} // ns } // ns