diff --git a/src/blackgui/components/flightplancomponent.cpp b/src/blackgui/components/flightplancomponent.cpp index 150c8df17..4096a0b3b 100644 --- a/src/blackgui/components/flightplancomponent.cpp +++ b/src/blackgui/components/flightplancomponent.cpp @@ -75,6 +75,9 @@ namespace BlackGui // overlay this->setOverlaySizeFactors(0.8, 0.9); + this->setReducedInfo(true); + this->setForceSmall(true); + this->showKillButton(false); // validators CUpperCaseValidator *ucv = new CUpperCaseValidator(this); @@ -433,7 +436,7 @@ namespace BlackGui m = CStatusMessage(this).validationError("No errors, but not connected, cannot send flight plan"); } ui->le_LastSent->setText(lastSent); - this->showOverlayMessage(m, showOverlayMs); + this->showOverlayMessage(m, OverlayMessageMs); m_sentFlightPlan = flightPlan; // last valid FP } else @@ -782,7 +785,7 @@ namespace BlackGui } // messages - this->showOverlayMessages(msgs, false, showOverlayMs); + this->showOverlayMessages(msgs, false, OverlayMessageMs); // copy over if (msgs.isSuccess()) diff --git a/src/blackgui/components/flightplancomponent.h b/src/blackgui/components/flightplancomponent.h index 9fab56d86..4628e849b 100644 --- a/src/blackgui/components/flightplancomponent.h +++ b/src/blackgui/components/flightplancomponent.h @@ -68,7 +68,7 @@ namespace BlackGui BlackMisc::CDataReadOnly m_lastAircraftModel { this }; //!< recently used aircraft model BlackMisc::CDataReadOnly m_lastServer { this }; //!< recently used server (VATSIM, other) - static constexpr int showOverlayMs = 5000; + static constexpr int OverlayMessageMs = 5000; //! Validate, generates status messages BlackMisc::CStatusMessageList validateAndInitializeFlightPlan(BlackMisc::Aviation::CFlightPlan &fligtPlan); diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index 4b47113a8..c2aca8195 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -70,7 +70,7 @@ namespace BlackGui } CLoginComponent::CLoginComponent(QWidget *parent) : - QFrame(parent), + COverlayMessagesFrame(parent), ui(new Ui::CLoginComponent) { ui->setupUi(this); @@ -102,6 +102,12 @@ namespace BlackGui ui->lblp_AircraftIcao->setToolTips("ok", "wrong"); ui->lblp_Callsign->setToolTips("ok", "wrong"); + // overlay + this->setOverlaySizeFactors(0.8, 0.5); + this->setReducedInfo(true); + this->setForceSmall(true); + this->showKillButton(false); + // Stored data this->loadRememberedUserData(); @@ -141,7 +147,7 @@ namespace BlackGui CServerList otherServers(m_otherTrafficNetworkServers.getThreadLocal()); // add a testserver when no servers can be loaded - if (otherServers.isEmpty() && sGui->isRunningInDeveloperEnvironment()) + if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isLocalDeveloperDebugBuild())) { otherServers.push_back(sGui->getGlobalSetup().getFsdTestServersPlusHardcodedServers()); CLogMessage(this).info("Added servers for testing"); @@ -151,7 +157,6 @@ namespace BlackGui connect(ui->pb_copyCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::copyCredentialsToPilot); connect(ui->pb_CopyCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::copyCredentialsToPilot); this->setUiLoginState(false); - } CLoginComponent::~CLoginComponent() @@ -202,7 +207,7 @@ namespace BlackGui { if (ui->tw_Network->currentWidget() == ui->pg_FsdDetails) { - CLogMessage(this).validationError("No login possible from this very tab, use VATSIM or other servers"); + this->showOverlayMessage(CStatusMessage(this).validationError("No login possible from this very tab, use VATSIM or other servers"), OverlayMessageMs); return; } const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected(); @@ -218,14 +223,14 @@ namespace BlackGui { if (!this->validateAircraftValues()) { - CLogMessage(this).validationWarning("Invalid aircraft data, login not possible"); + this->showOverlayMessage(CStatusMessage(this).validationWarning("Invalid aircraft data, login not possible"), OverlayMessageMs); return; } const CStatusMessageList pilotMsgs = ui->editor_Pilot->validate(); if (pilotMsgs.isFailure()) { - CLogMessage(this).validationWarning("Invalid pilot data, login not possible"); + this->showOverlayMessage(CStatusMessage(this).validationWarning("Invalid pilot data, login not possible"), OverlayMessageMs); return; } diff --git a/src/blackgui/components/logincomponent.h b/src/blackgui/components/logincomponent.h index bdc1100ab..128871606 100644 --- a/src/blackgui/components/logincomponent.h +++ b/src/blackgui/components/logincomponent.h @@ -14,8 +14,9 @@ #include "blackcore/vatsim/vatsimsettings.h" #include "blackcore/data/vatsimsetup.h" -#include "blackgui/blackguiexport.h" #include "blackgui/settings/guisettings.h" +#include "blackgui/blackguiexport.h" +#include "blackgui/overlaymessagesframe.h" #include "blackmisc/simulation/data/lastmodel.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/aviation/callsign.h" @@ -54,7 +55,7 @@ namespace BlackGui /*! * Login component to flight network */ - class BLACKGUI_EXPORT CLoginComponent : public QFrame + class BLACKGUI_EXPORT CLoginComponent : public COverlayMessagesFrame { Q_OBJECT @@ -200,6 +201,7 @@ namespace BlackGui //! Tab widget (server) changed void onServerTabWidgetChanged(int index); + static const int OverlayMessageMs = 5000; QScopedPointer ui; QScopedPointer m_mappingWizard; BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginComponent::loginDataChangedDigest, 1500, 10 }; diff --git a/src/blackgui/components/mappingcomponent.cpp b/src/blackgui/components/mappingcomponent.cpp index 93534c118..3e23eff25 100644 --- a/src/blackgui/components/mappingcomponent.cpp +++ b/src/blackgui/components/mappingcomponent.cpp @@ -66,6 +66,8 @@ namespace BlackGui Q_ASSERT_X(sGui->getIContextNetwork(), Q_FUNC_INFO, "need network context"); ui->setupUi(this); + ui->tw_ListViews->setCurrentIndex(0); + ui->tvp_AircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnAircraftModelClient); ui->tvp_AircraftModels->setResizeMode(CAircraftModelView::ResizingOff); ui->tvp_AircraftModels->addFilterDialog(); @@ -94,6 +96,10 @@ namespace BlackGui m_currentMappingsViewDelegate = new CCheckBoxDelegate(":/diagona/icons/diagona/icons/tick.png", ":/diagona/icons/diagona/icons/cross.png", this); ui->tvp_RenderedAircraft->setItemDelegateForColumn(0, m_currentMappingsViewDelegate); + + // overlay + this->setReducedInfo(true); + this->setForceSmall(true); this->showKillButton(false); // Aircraft previews @@ -129,6 +135,12 @@ namespace BlackGui CMappingComponent::~CMappingComponent() { } + const CLogCategoryList &CMappingComponent::getLogCategories() + { + static const CLogCategoryList cats({ CLogCategory::mapping(), CLogCategory::guiComponent() }); + return cats; + } + int CMappingComponent::countCurrentMappings() const { Q_ASSERT(ui->tvp_RenderedAircraft); @@ -182,7 +194,7 @@ namespace BlackGui if (!saFromBackend.hasValidCallsign()) { return; } // obviously deleted const bool nowEnabled = sa.isEnabled(); if (saFromBackend.isEnabled() == nowEnabled) { return; } // already same value - CLogMessage(this).info("Request to %1 aircraft %2") << (nowEnabled ? "enable" : "disable") << saFromBackend.getCallsign().toQString(); + CLogMessage(this).info("Request to %1 aircraft '%2'") << (nowEnabled ? "enable" : "disable") << saFromBackend.getCallsign().toQString(); sGui->getIContextNetwork()->updateAircraftEnabled(saFromBackend.getCallsign(), nowEnabled); } @@ -218,12 +230,12 @@ namespace BlackGui } } - CCallsign CMappingComponent::validateRenderedCallsign() const + CCallsign CMappingComponent::validateRenderedCallsign() { const QString cs = ui->le_Callsign->text().trimmed(); if (!CCallsign::isValidAircraftCallsign(cs)) { - CLogMessage(this).validationError("Invalid callsign for mapping"); + this->showOverlayMessage(CStatusMessage(this).validationError("Invalid callsign for mapping"), OverlayMessageMs); return CCallsign(); } @@ -231,7 +243,8 @@ namespace BlackGui const bool hasCallsign = ui->tvp_RenderedAircraft->container().containsCallsign(callsign); if (!hasCallsign) { - CLogMessage(this).validationError("Unmapped callsign %1 for mapping") << callsign.asString(); + const CStatusMessage msg = CStatusMessage(this).validationError("Unmapped callsign '%1' for mapping") << callsign.asString(); + this->showOverlayMessage(msg); return CCallsign(); } return callsign; @@ -245,14 +258,14 @@ namespace BlackGui const QString modelString = ui->completer_ModelStrings->getModelString(); if (modelString.isEmpty()) { - CLogMessage(this).validationError("Missing model for mapping"); + this->showOverlayMessage(CStatusMessage(this).validationError("Missing model for mapping"), OverlayMessageMs); return; } const bool hasModel = ui->tvp_AircraftModels->container().containsModelString(modelString); if (!hasModel) { - CLogMessage(this).validationError("Invalid model for mapping, reload models"); + this->showOverlayMessage(CStatusMessage(this).validationError("Invalid model for mapping, reloading model set"), OverlayMessageMs); if (ui->tvp_AircraftModels->isEmpty()) { this->onModelsUpdateRequested(); @@ -268,7 +281,8 @@ namespace BlackGui const CAircraftModelList models = sGui->getIContextSimulator()->getModelSetModelsStartingWith(modelString); if (models.isEmpty()) { - CLogMessage(this).validationError("No model for title: %1") << modelString; + const CStatusMessage msg = CStatusMessage(this).validationError("No model for title: '%1'") << modelString; + this->showOverlayMessage(msg, OverlayMessageMs); return; } @@ -281,11 +295,12 @@ namespace BlackGui } else { - CLogMessage(this).validationInfo("Ambigious title: %1, using %2") << modelString << model.getModelString(); + const CStatusMessage msg = CStatusMessage(this).validationInfo("Ambigious title: '%1', using '%2'") << modelString << model.getModelString(); + this->showOverlayMessage(msg, OverlayMessageMs); } } model.setModelType(CAircraftModel::TypeManuallySet); - CLogMessage(this).info("Requesting changes for %1") << callsign.asString(); + CLogMessage(this).info("Requesting changes for '%1'") << callsign.asString(); changed = sGui->getIContextNetwork()->updateAircraftModel(aircraftFromBackend.getCallsign(), model, identifier()); } if (aircraftFromBackend.isEnabled() != enabled) @@ -295,7 +310,7 @@ namespace BlackGui if (!changed) { - CLogMessage(this).info("Model mapping, nothing to change"); + this->showOverlayMessage(CLogMessage(this).info("Model mapping, nothing to change"), OverlayMessageMs); } } @@ -305,14 +320,10 @@ namespace BlackGui const CCallsign callsign(this->validateRenderedCallsign()); if (callsign.isEmpty()) { return; } const bool reset = sGui->getIContextSimulator()->resetToModelMatchingAircraft(callsign); - if (reset) - { - CLogMessage(this).info("Model reset for '%1'") << callsign.toQString(); - } - else - { - CLogMessage(this).info("Reset failed for '%1'") << callsign.toQString(); - } + const CStatusMessage msg = reset ? + CStatusMessage(this).info("Model reset for '%1'") << callsign.toQString() : + CStatusMessage(this).info("Reset failed for '%1'") << callsign.toQString(); + this->showOverlayMessage(msg); } void CMappingComponent::onModelPreviewChanged(int state) diff --git a/src/blackgui/components/mappingcomponent.h b/src/blackgui/components/mappingcomponent.h index 1f554d1db..13d9fb81c 100644 --- a/src/blackgui/components/mappingcomponent.h +++ b/src/blackgui/components/mappingcomponent.h @@ -61,6 +61,9 @@ namespace BlackGui //! Destructor virtual ~CMappingComponent(); + //! Log categories + static const BlackMisc::CLogCategoryList &getLogCategories(); + //! Number of current mappings int countCurrentMappings() const; @@ -143,15 +146,16 @@ namespace BlackGui void updateRenderedAircraftView(bool forceUpdate = false); //! Check callsign entered - BlackMisc::Aviation::CCallsign validateRenderedCallsign() const; + BlackMisc::Aviation::CCallsign validateRenderedCallsign(); + static constexpr int OverlayMessageMs = 5000; QScopedPointer ui; - BlackMisc::CSettingReadOnly m_settings { this, &CMappingComponent::settingsChanged }; //!< settings changed bool m_missedRenderedAircraftUpdate = true; //! Rendered aircraft need update QTimer m_updateTimer { this }; BlackMisc::CTokenBucket m_bucket { 3, BlackMisc::PhysicalQuantities::CTime(5.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()), 1}; Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr; //! checkbox in view BlackMisc::CIdentifier m_identifier { "MappingComponent", this }; + BlackMisc::CSettingReadOnly m_settings { this, &CMappingComponent::settingsChanged }; //!< settings changed }; } // namespace } // namespace