From da552d60ccf7f48b7e502a15173e88038f1746a1 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Sun, 4 Feb 2024 17:23:12 +0100 Subject: [PATCH] refactor: Remove dev flag from bootstrap json With this, the database debug flag can only be activated when using swift with a development build. Setting the development flag in the json also didn't worked previously as expected because the corresponding function to get the flag in application.cpp was called before the setup was loaded. --- .../share/shared/bootstrap/bootstrap.json | 1 - scripts/swift.imp | 2 - src/blackcore/application.cpp | 6 --- src/blackcore/data/globalsetup.cpp | 13 +---- src/blackcore/data/globalsetup.h | 17 +----- src/blackgui/CMakeLists.txt | 3 -- .../components/dbdebugdatabasesetup.cpp | 41 -------------- .../components/dbdebugdatabasesetup.h | 47 ---------------- .../components/dbdebugdatabasesetup.ui | 54 ------------------- src/blackgui/components/dblogincomponent.cpp | 3 -- src/blackgui/components/dblogincomponent.ui | 20 +------ 11 files changed, 4 insertions(+), 203 deletions(-) delete mode 100644 src/blackgui/components/dbdebugdatabasesetup.cpp delete mode 100644 src/blackgui/components/dbdebugdatabasesetup.h delete mode 100644 src/blackgui/components/dbdebugdatabasesetup.ui diff --git a/resources/share/shared/bootstrap/bootstrap.json b/resources/share/shared/bootstrap/bootstrap.json index a1a28efdf..4d174d549 100644 --- a/resources/share/shared/bootstrap/bootstrap.json +++ b/resources/share/shared/bootstrap/bootstrap.json @@ -8,7 +8,6 @@ "dbRootDirectoryUrl": { "url": "https://datastore.swift-project.org/" }, - "development": false, "mappingMinimumVersion": "0.9.0", "ncepGlobalForecastSystemUrl": { "url": "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl" diff --git a/scripts/swift.imp b/scripts/swift.imp index d88d2c3d3..fb6ffd167 100644 --- a/scripts/swift.imp +++ b/scripts/swift.imp @@ -686,8 +686,6 @@ { include: [ "\"dbownmodelsetdialog.h\"", "private", "\"blackgui/components/dbownmodelsetdialog.h\"", "public" ] }, { include: [ "\"components/settingssimulatorcomponent.h\"", "private", "\"blackgui/components/settingssimulatorcomponent.h\"", "public" ] }, { include: [ "\"settingssimulatorcomponent.h\"", "private", "\"blackgui/components/settingssimulatorcomponent.h\"", "public" ] }, - { include: [ "\"components/dbdebugdatabasesetup.h\"", "private", "\"blackgui/components/dbdebugdatabasesetup.h\"", "public" ] }, - { include: [ "\"dbdebugdatabasesetup.h\"", "private", "\"blackgui/components/dbdebugdatabasesetup.h\"", "public" ] }, { include: [ "\"components/internalscomponent.h\"", "private", "\"blackgui/components/internalscomponent.h\"", "public" ] }, { include: [ "\"internalscomponent.h\"", "private", "\"blackgui/components/internalscomponent.h\"", "public" ] }, { include: [ "\"components/modelmatchercomponent.h\"", "private", "\"blackgui/components/modelmatchercomponent.h\"", "public" ] }, diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index f90b962c2..5ce985ff3 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -533,12 +533,6 @@ namespace BlackCore const CDistribution d(this->getOwnDistribution()); if (d.isRestricted() && this->isSet(m_cmdDevelopment)) { return true; } - // we can globally set a dev.flag - if (this->isSetupAvailable()) - { - // assume value from setup - return this->getGlobalSetup().isDevelopment(); - } return false; } diff --git a/src/blackcore/data/globalsetup.cpp b/src/blackcore/data/globalsetup.cpp index 89a440fb2..8562dacc7 100644 --- a/src/blackcore/data/globalsetup.cpp +++ b/src/blackcore/data/globalsetup.cpp @@ -171,11 +171,7 @@ namespace BlackCore::Data bool CGlobalSetup::dbDebugFlag() const { - if (!m_dbDebugFlag) { return false; } - - // further checks could go here - const bool f = this->isDevelopment() || CBuildConfig::isLocalDeveloperDebugBuild(); - return f; + return m_dbDebugFlag && CBuildConfig::isLocalDeveloperDebugBuild(); } void CGlobalSetup::setServerDebugFlag(bool debug) @@ -183,11 +179,6 @@ namespace BlackCore::Data m_dbDebugFlag = debug; } - bool CGlobalSetup::hasSameType(const CGlobalSetup &otherSetup) const - { - return this->isDevelopment() == otherSetup.isDevelopment(); - } - QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate) { if (candidate.isEmpty()) return {}; // not possible @@ -268,8 +259,6 @@ namespace BlackCore::Data QString s = u"timestamp: " % this->getFormattedUtcTimestampYmdhms() % separator % u"Global setup loaded: " % boolToYesNo(this->wasLoadedFromFile()) % separator - % u"For development: " % boolToYesNo(isDevelopment()) % separator - % u"Mapping min.version: " % this->getMappingMinimumVersionString() % separator % u"Distribution URLs: " % getSwiftUpdateInfoFileUrls().toQString(i18n) % separator % u"Bootstrap URLs: " % getSwiftBootstrapFileUrls().toQString(i18n) % separator % u"Help URLs: " % m_onlineHelpUrls.toQString(i18n) % separator; diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index 62467dcd0..fa8ec84b2 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -93,9 +93,6 @@ namespace BlackCore::Data //! Set debug flag void setServerDebugFlag(bool debug); - //! Same type? - bool hasSameType(const CGlobalSetup &otherSetup) const; - //! Crash report server url //! \deprecated NOT used anymore as by RR's info: https://discordapp.com/channels/539048679160676382/539925070550794240/586879411002015756 BlackMisc::Network::CUrl getCrashReportServerUrl() const { return m_crashReportServerUrl; } @@ -184,9 +181,6 @@ namespace BlackCore::Data //! Predefined plus hardcoded BlackMisc::Network::CServerList getPredefinedServersPlusHardcodedServers() const; - //! Is server a development server? - bool isDevelopment() const { return m_development; } - //! Creating mappings requires at least this version or higher //! \remark only valid if wasLoaded() is \c true const QString &getMappingMinimumVersionString() const { return m_mappingMinimumVersion; } @@ -195,9 +189,6 @@ namespace BlackCore::Data //! \remark only valid if wasLoaded() is \c true bool isSwiftVersionMinimumMappingVersion() const; - //! Productive settings? - void setDevelopment(bool development) { m_development = development; } - //! NCEP GFS Forecasts (0.50 degree grid) data url BlackMisc::Network::CUrl getNcepGlobalForecastSystemUrl() const { return m_ncepGlobalForecastSystemUrl; } @@ -239,7 +230,6 @@ namespace BlackCore::Data int m_dbHttpPort = 80; //!< port int m_dbHttpsPort = 443; //!< SSL port qint64 m_pingIntervalSecs = 180; //!< seconds between datastore pings - bool m_development = false; //!< dev. version? QString m_mappingMinimumVersion; //!< minimum version BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server BlackMisc::Network::CUrl m_dbRootDirectoryUrl; //!< Root directory of DB @@ -255,9 +245,7 @@ namespace BlackCore::Data BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl25; //!< NCEP GFS url 0.25 degree resolution BlackMisc::Network::CUrl m_comNavEquipmentHelpUrl; //!< Help URL for COM/NAV equipment codes BlackMisc::Network::CUrl m_ssrEquipmentHelpUrl; //!< Help URL for SSR equipment codes - - // transient members, to be switched on/off via GUI or set from reader - bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing + bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing. Only works with CBuildConfig::isLocalDeveloperDebugBuild //! Set the default URLs void initDefaultValues(); @@ -279,13 +267,12 @@ namespace BlackCore::Data BLACK_METAMEMBER(sharedUrls), BLACK_METAMEMBER(onlineHelpUrls), BLACK_METAMEMBER(predefinedServers), - BLACK_METAMEMBER(development), BLACK_METAMEMBER(mappingMinimumVersion), BLACK_METAMEMBER(ncepGlobalForecastSystemUrl), BLACK_METAMEMBER(ncepGlobalForecastSystemUrl25), BLACK_METAMEMBER(comNavEquipmentHelpUrl), BLACK_METAMEMBER(ssrEquipmentHelpUrl), - BLACK_METAMEMBER(dbDebugFlag, BlackMisc::DisabledForJson) + BLACK_METAMEMBER(dbDebugFlag) ); }; diff --git a/src/blackgui/CMakeLists.txt b/src/blackgui/CMakeLists.txt index 7c4984449..df78bc395 100644 --- a/src/blackgui/CMakeLists.txt +++ b/src/blackgui/CMakeLists.txt @@ -364,7 +364,6 @@ add_library(gui SHARED components/autopublishcomponent.h components/audioadvanceddistributeddialog.ui components/settingsadvancedcomponent.h - components/dbdebugdatabasesetup.h components/copyconfigurationcomponent.h components/airportdialog.h components/settingsmatchingdialog.cpp @@ -537,7 +536,6 @@ add_library(gui SHARED components/interpolationcomponent.ui components/dbownmodelsetformdialog.h components/airportcompleter.cpp - components/dbdebugdatabasesetup.cpp components/modelmatcherlogenable.h components/updateinfocomponent.h components/countryselector.cpp @@ -648,7 +646,6 @@ add_library(gui SHARED components/settingsviewupdatetimes.ui components/airportcompleter.h components/cockpitinfoareacomponent.cpp - components/dbdebugdatabasesetup.ui components/cockpittranspondermodeledscomponent.cpp components/installfsxterrainprobecomponent.h components/interpolationlogdisplay.h diff --git a/src/blackgui/components/dbdebugdatabasesetup.cpp b/src/blackgui/components/dbdebugdatabasesetup.cpp deleted file mode 100644 index a014d1aa7..000000000 --- a/src/blackgui/components/dbdebugdatabasesetup.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "blackgui/components/dbdebugdatabasesetup.h" -#include "blackgui/guiapplication.h" -#include "ui_dbdebugdatabasesetup.h" - -#include - -using namespace BlackCore::Data; -using namespace BlackMisc; - -namespace BlackGui::Components -{ - CDbDebugDatabaseSetup::CDbDebugDatabaseSetup(QWidget *parent) : QFrame(parent), - ui(new Ui::CDbDebugDatabaseSetup) - { - ui->setupUi(this); - const bool enabled = sGui->isDeveloperFlagSet(); - this->setEnabled(enabled); - if (!enabled) - { - this->setToolTip("Disabled, cannot be set!"); - } - else - { - connect(ui->cb_EnableServerDebugging, &QCheckBox::toggled, this, &CDbDebugDatabaseSetup::onDebugChanged); - } - } - - CDbDebugDatabaseSetup::~CDbDebugDatabaseSetup() - {} - - void CDbDebugDatabaseSetup::onDebugChanged(bool set) - { - CGlobalSetup gs(m_setup.getThreadLocal()); - gs.setServerDebugFlag(set); - m_setup.set(gs); - } - -} // ns diff --git a/src/blackgui/components/dbdebugdatabasesetup.h b/src/blackgui/components/dbdebugdatabasesetup.h deleted file mode 100644 index cbbd7ea66..000000000 --- a/src/blackgui/components/dbdebugdatabasesetup.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKGUI_COMPONENTS_DBDEBUGDATABASESETUP_H -#define BLACKGUI_COMPONENTS_DBDEBUGDATABASESETUP_H - -#include "blackcore/data/globalsetup.h" -#include "blackgui/blackguiexport.h" -#include "blackmisc/datacache.h" - -#include -#include -#include - -namespace Ui -{ - class CDbDebugDatabaseSetup; -} -namespace BlackGui::Components -{ - /*! - * Debug settings for DB (only to be used as developer) - * \remarks Disabled when not runnig in dev.environment - */ - class BLACKGUI_EXPORT CDbDebugDatabaseSetup : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CDbDebugDatabaseSetup(QWidget *parent = nullptr); - - //! Dstructor - ~CDbDebugDatabaseSetup(); - - private: - //! Changed the debug checkbox - void onDebugChanged(bool set); - - QScopedPointer ui; - BlackMisc::CData m_setup { this }; //!< data cache - }; -} // ns - -#endif // guard diff --git a/src/blackgui/components/dbdebugdatabasesetup.ui b/src/blackgui/components/dbdebugdatabasesetup.ui deleted file mode 100644 index 6b3fd85b0..000000000 --- a/src/blackgui/components/dbdebugdatabasesetup.ui +++ /dev/null @@ -1,54 +0,0 @@ - - - CDbDebugDatabaseSetup - - - - 0 - 0 - 176 - 40 - - - - Frame - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Server debug flag: - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - diff --git a/src/blackgui/components/dblogincomponent.cpp b/src/blackgui/components/dblogincomponent.cpp index ea09b971c..e6e5be71a 100644 --- a/src/blackgui/components/dblogincomponent.cpp +++ b/src/blackgui/components/dblogincomponent.cpp @@ -49,9 +49,6 @@ namespace BlackGui::Components ui->tbr_InfoAndHints->setHtml(html); ui->tbr_InfoAndHints->setOpenExternalLinks(true); - const bool devEnv = sGui->isDeveloperFlagSet(); - ui->comp_DebugSetup->setVisible(devEnv); - const QString dbUrl = sGui->getGlobalSetup().getDbHomePageUrl().toQString(); ui->lbl_DatabaseName->setText(asHyperlink(dbUrl)); ui->lbl_DatabaseName->setTextFormat(Qt::RichText); diff --git a/src/blackgui/components/dblogincomponent.ui b/src/blackgui/components/dblogincomponent.ui index 5416a2862..1ac35ef85 100644 --- a/src/blackgui/components/dblogincomponent.ui +++ b/src/blackgui/components/dblogincomponent.ui @@ -88,16 +88,6 @@ 6 - - - - - 0 - 40 - - - - @@ -152,7 +142,7 @@ - + Qt::Vertical @@ -406,14 +396,6 @@ p, li { white-space: pre-wrap; } - - - BlackGui::Components::CDbDebugDatabaseSetup - QFrame -
blackgui/components/dbdebugdatabasesetup.h
- 1 -
-
tb_LoginToDbAndHints le_Username