Ref T225, force stylesheet in CForm base class and used by all forms

* Allows to use stylesheet attributes like [readonly]
* changing to "readonly" applies correct stylesheet
This commit is contained in:
Klaus Basan
2018-01-18 20:08:16 +01:00
parent 0916c90038
commit eaf0095454
19 changed files with 42 additions and 21 deletions

View File

@@ -190,6 +190,8 @@ namespace BlackGui
ui->cb_Rank->setEnabled(!readOnly);
ui->drop_DropData->setVisible(!readOnly);
ui->combined_TypeSelector->setReadOnly(readOnly);
this->forceStyleSheetUpdate();
}
void CAircraftIcaoForm::setSelectOnly()

View File

@@ -32,6 +32,7 @@ namespace BlackGui
ui->editor_AircraftIcao->setReadOnly(readOnly);
ui->editor_Distributor->setReadOnly(readOnly);
ui->editor_Livery->setReadOnly(readOnly);
this->forceStyleSheetUpdate();
}
void CAircraftModelForm::setSelectOnly()

View File

@@ -19,7 +19,6 @@
#include <QJsonDocument>
#include <QJsonParseError>
using namespace BlackGui;
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
@@ -46,6 +45,7 @@ namespace BlackGui
{
CGuiUtility::childrenSetEnabled<QPushButton>(this, !readonly);
CGuiUtility::checkBoxesReadOnly(this, readonly);
this->forceStyleSheetUpdate();
}
void CAircraftPartsForm::setSelectOnly()

View File

@@ -133,6 +133,8 @@ namespace BlackGui
CGuiUtility::checkBoxReadOnly(ui->cb_Va, readOnly);
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
this->forceStyleSheetUpdate();
}
void CAirlineIcaoForm::setSelectOnly()

View File

@@ -65,6 +65,7 @@ namespace BlackGui
ui->cbp_ComPanelTransponderMode->setDisabled(!readonly);
ui->tb_ComPanelCom1Toggle->setEnabled(!readonly);
ui->tb_ComPanelCom2Toggle->setEnabled(!readonly);
this->forceStyleSheetUpdate();
}
void CCockpitComForm::setSelectOnly()

View File

@@ -135,7 +135,7 @@ namespace BlackGui
ui->le_Location->setVisible(!readonly); // does not make sense to show it in ro, no reverse lookup
ui->lbl_Location->setVisible(!readonly);
CGuiUtility::forceStyleSheetUpdate(this);
this->forceStyleSheetUpdate();
}
void CCoordinateForm::setSelectOnly()

View File

@@ -8,10 +8,10 @@
*/
#include "blackgui/components/dbdistributorselectorcomponent.h"
#include "blackgui/dropsite.h"
#include "blackgui/editors/distributorform.h"
#include "blackgui/editors/validationindicator.h"
#include "blackgui/labelandicon.h"
#include "blackgui/dropsite.h"
#include "blackmisc/compare.h"
#include "blackmisc/icons.h"
#include "blackmisc/simulation/distributorlist.h"
@@ -107,6 +107,7 @@ namespace BlackGui
ui->le_Description->setReadOnly(readOnly);
ui->distributor_Selector->setReadOnly(readOnly);
ui->drop_DropData->setVisible(!readOnly);
this->forceStyleSheetUpdate();
}
void CDistributorForm::setSelectOnly()

View File

@@ -23,7 +23,6 @@
class QWidget;
namespace Ui { class CDistributorForm; }
namespace BlackGui
{
namespace Editors

View File

@@ -8,6 +8,7 @@
*/
#include "blackgui/editors/form.h"
#include "blackgui/guiutility.h"
#include <QApplication>
#include <QClipboard>
#include <QShortcut>
@@ -48,6 +49,11 @@ namespace BlackGui
this->jsonPasted(data);
}
void CForm::forceStyleSheetUpdate()
{
CGuiUtility::forceStyleSheetUpdate(this);
}
CFormDbUser::CFormDbUser(QWidget *parent) : CForm(parent)
{ }

View File

@@ -59,6 +59,9 @@ namespace BlackGui
//! Pasted from clipboard
void pasted();
//! \copydoc BlackGui::CGuiUtility::forceStyleSheetUpdate
void forceStyleSheetUpdate();
bool m_readOnly = false; //!< read only
};

View File

@@ -88,6 +88,7 @@ namespace BlackGui
CGuiUtility::checkBoxReadOnly(ui->cb_AircraftPartsSend, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_FastPositionReceive, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_FastPositionSend, readonly);
this->forceStyleSheetUpdate();
}
CStatusMessageList CFsdSetupForm::validate(bool nested) const

View File

@@ -184,6 +184,7 @@ namespace BlackGui
ui->drop_DropData->setVisible(!readOnly);
ui->tb_Paste->setVisible(!readOnly);
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
this->forceStyleSheetUpdate();
}
void CLiveryForm::setSelectOnly()

View File

@@ -68,6 +68,7 @@ namespace BlackGui
ui->le_Description->setReadOnly(readOnly);
ui->le_ModelKey->setReadOnly(readOnly);
ui->le_Name->setReadOnly(readOnly);
this->forceStyleSheetUpdate();
}
void CModelMappingForm::setSelectOnly()

View File

@@ -88,6 +88,7 @@ namespace BlackGui
{
// void
Q_UNUSED(readOnly);
// this->forceStyleSheetUpdate();
}
void CModelMappingModifyForm::userChanged()

View File

@@ -36,11 +36,11 @@ namespace BlackGui
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
ui->comp_SimulatorSelector->setLeftMargin(0);
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &COwnModelSetForm::ps_simulatorChanged);
connect(ui->rb_DisplayAllDistributors, &QRadioButton::clicked, this, &COwnModelSetForm::ps_changeDistributorDisplay);
connect(ui->rb_DisplayPreferencesDistributors, &QRadioButton::clicked, this, &COwnModelSetForm::ps_changeDistributorDisplay);
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &COwnModelSetForm::onSimulatorChanged);
connect(ui->rb_DisplayAllDistributors, &QRadioButton::clicked, this, &COwnModelSetForm::changeDistributorDisplay);
connect(ui->rb_DisplayPreferencesDistributors, &QRadioButton::clicked, this, &COwnModelSetForm::changeDistributorDisplay);
this->ps_simulatorChanged(ui->comp_SimulatorSelector->getValue());
this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue());
}
COwnModelSetForm::~COwnModelSetForm()
@@ -88,19 +88,19 @@ namespace BlackGui
return ui->cb_ConsolidateModelSet->isChecked();
}
void COwnModelSetForm::ps_preferencesChanged()
void COwnModelSetForm::onPreferencesChanged()
{
// void
}
void COwnModelSetForm::ps_simulatorChanged(const CSimulatorInfo &simulator)
void COwnModelSetForm::onSimulatorChanged(const CSimulatorInfo &simulator)
{
this->setSimulator(simulator);
this->reloadData();
emit simulatorChanged(simulator);
emit this->simulatorChanged(simulator);
}
void COwnModelSetForm::ps_changeDistributorDisplay()
void COwnModelSetForm::changeDistributorDisplay()
{
if (ui->rb_DisplayAllDistributors->isChecked())
{
@@ -128,7 +128,7 @@ namespace BlackGui
{
ui->rb_DisplayAllDistributors->setChecked(true);
}
this->ps_changeDistributorDisplay();
this->changeDistributorDisplay();
}
void COwnModelSetForm::setDistributorView(bool hasPreferences)

View File

@@ -34,7 +34,7 @@ namespace BlackGui
explicit COwnModelSetForm(QWidget *parent = nullptr);
//! Destructor
~COwnModelSetForm();
virtual ~COwnModelSetForm();
//! Reload data
void reloadData();
@@ -90,17 +90,16 @@ namespace BlackGui
//! Simulator changed
void simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
private slots:
private:
//! Changed preferences
void ps_preferencesChanged();
void onPreferencesChanged();
//! Simulator changed
void ps_simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
void onSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Display distributors based on checkboxes
void ps_changeDistributorDisplay();
void changeDistributorDisplay();
private:
//! Init the options which distributors are displayed
void initDistributorDisplay();
@@ -109,7 +108,7 @@ namespace BlackGui
QScopedPointer<Ui::COwnModelSetForm> ui;
BlackMisc::Simulation::CSimulatorInfo m_simulator;
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TDistributorListPreferences> m_distributorPreferences { this, &COwnModelSetForm::ps_preferencesChanged };
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TDistributorListPreferences> m_distributorPreferences { this, &COwnModelSetForm::onPreferencesChanged };
};
} // ns
} // ns

View File

@@ -116,6 +116,7 @@ namespace BlackGui
ui->lblp_HomeAirport->setVisible(!readonly);
ui->lblp_Password->setVisible(!readonly);
ui->lblp_RealName->setVisible(!readonly);
this->forceStyleSheetUpdate();
}
CStatusMessageList CPilotForm::validate(bool nested) const

View File

@@ -56,7 +56,7 @@ namespace BlackGui
const CUser user(
ui->le_NetworkId->text().trimmed(),
ui->le_RealName->text().trimmed().simplified(),
"",
QStringLiteral(""),
ui->le_Password->text().trimmed()
);
const CFsdSetup setup(ui->form_ServerFsd->getValue());
@@ -90,6 +90,7 @@ namespace BlackGui
ui->form_ServerFsd->setReadOnly(readOnly);
ui->cb_ServerType->setEnabled(!readOnly);
ui->cbp_Ecosystem->setEnabled(!readOnly);
this->forceStyleSheetUpdate();
}
void CServerForm::showPasswordField(bool show)

View File

@@ -113,6 +113,7 @@ namespace BlackGui
void CSituationForm::setReadOnly(bool readonly)
{
ui->comp_Coordinate->setReadOnly(readonly);
this->forceStyleSheetUpdate();
}
void CSituationForm::setSelectOnly()