diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index b2fc06c81..7acd32f9d 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -1369,7 +1369,7 @@ namespace BlackCore void CApplication::onCrashDumpUploadEnabledChanged() { - const bool enabled = CBuildConfig::isReleaseBuild() && m_crashDumpSettings.getThreadLocal().isEnabled(); + const bool enabled = CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal(); this->enableCrashDumpUpload(enabled); } diff --git a/src/blackcore/application.h b/src/blackcore/application.h index f218a2a97..70164cb20 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -657,7 +657,7 @@ namespace BlackCore bool m_localSettingsLoaded = false; //!< local settings loaded? // -------------- crashpad ----------------- - BlackMisc::CSettingReadOnly m_crashDumpSettings { this, &CApplication::onCrashDumpUploadEnabledChanged }; + BlackMisc::CSettingReadOnly m_crashDumpUploadEnabled { this, &CApplication::onCrashDumpUploadEnabledChanged }; //! Upload settings changed void onCrashDumpUploadEnabledChanged(); diff --git a/src/blackcore/application/applicationsettings.h b/src/blackcore/application/applicationsettings.h index 74238b4f9..a07e0736d 100644 --- a/src/blackcore/application/applicationsettings.h +++ b/src/blackcore/application/applicationsettings.h @@ -9,7 +9,6 @@ #include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/input/actionhotkeylist.h" #include "blackmisc/settingscache.h" -#include "blackmisc/crashsettings.h" #include "blackconfig/buildconfig.h" #include @@ -78,11 +77,10 @@ namespace BlackCore::Application }; //! Uploading of crash dumps is enabled or disabled - //! \deprecated remove after changing to - struct TCrashDumpSettings : public BlackMisc::TSettingTrait + struct TCrashDumpUploadEnabled : public BlackMisc::TSettingTrait { //! \copydoc BlackMisc::TSettingTrait::key - static const char *key() { return "application/crashdump"; } + static const char *key() { return "application/crashdumpuploadenabled"; } //! \copydoc BlackMisc::TSettingTrait::humanReadable static const QString &humanReadable() @@ -92,7 +90,7 @@ namespace BlackCore::Application } //! \copydoc BlackMisc::TSettingTrait::defaultValue - // static bool defaultValue() { return BlackMisc::Settings::CCrashSettings(); } + static bool defaultValue() { return true; } }; } // ns diff --git a/src/blackgui/components/legalinfocomponent.cpp b/src/blackgui/components/legalinfocomponent.cpp index d2d39cb5b..ea1b28c9f 100644 --- a/src/blackgui/components/legalinfocomponent.cpp +++ b/src/blackgui/components/legalinfocomponent.cpp @@ -7,7 +7,6 @@ #include "blackgui/guiapplication.h" #include "blackcore/data/globalsetup.h" #include "blackmisc/network/url.h" -#include "blackmisc/crashsettings.h" #include "blackmisc/logmessage.h" #include "blackmisc/statusmessage.h" #include "blackconfig/buildconfig.h" @@ -16,7 +15,6 @@ using namespace BlackMisc; using namespace BlackMisc::Network; -using namespace BlackMisc::Settings; using namespace BlackCore::Data; using namespace BlackConfig; @@ -28,8 +26,8 @@ namespace BlackGui::Components ui->setupUi(this); this->setChecklistInfo(); - const CCrashSettings settings = m_crashDumpSettings.get(); - ui->cb_CrashDumps->setChecked(settings.isEnabled()); + const bool crashDumpUploadEnabled = m_crashDumpUploadEnabled.getThreadLocal(); + ui->cb_CrashDumps->setChecked(crashDumpUploadEnabled); ui->cb_Agree->setChecked(CBuildConfig::isLocalDeveloperDebugBuild()); connect(ui->cb_CrashDumps, &QCheckBox::toggled, this, &CLegalInfoComponent::onAllowCrashDumps); @@ -59,9 +57,7 @@ namespace BlackGui::Components void CLegalInfoComponent::onAllowCrashDumps(bool checked) { - CCrashSettings settings = m_crashDumpSettings.get(); - settings.setEnabled(checked); - CLogMessage::preformatted(m_crashDumpSettings.setAndSave(settings)); + CLogMessage::preformatted(m_crashDumpUploadEnabled.setAndSave(checked)); } void CLegalInfoComponent::showCrashDumpHint() diff --git a/src/blackgui/components/legalinfocomponent.h b/src/blackgui/components/legalinfocomponent.h index 1a6ccee38..0b694103d 100644 --- a/src/blackgui/components/legalinfocomponent.h +++ b/src/blackgui/components/legalinfocomponent.h @@ -49,7 +49,7 @@ namespace BlackGui::Components void setChecklistInfo(); QScopedPointer ui; - BlackMisc::CSetting m_crashDumpSettings { this }; + BlackMisc::CSetting m_crashDumpUploadEnabled { this }; }; /*! diff --git a/src/blackgui/components/settingsadvancedcomponent.cpp b/src/blackgui/components/settingsadvancedcomponent.cpp index eb43d0e5d..8c3d298bd 100644 --- a/src/blackgui/components/settingsadvancedcomponent.cpp +++ b/src/blackgui/components/settingsadvancedcomponent.cpp @@ -3,10 +3,8 @@ #include "ui_settingsadvancedcomponent.h" #include "blackgui/components/settingsadvancedcomponent.h" -#include "blackmisc/crashsettings.h" using namespace BlackMisc; -using namespace BlackMisc::Settings; namespace BlackGui::Components { @@ -15,8 +13,8 @@ namespace BlackGui::Components { ui->setupUi(this); - const CCrashSettings settings = m_crashDumpSettings.getThreadLocal(); - ui->cb_crashDumpsUpload->setChecked(settings.isEnabled()); + const bool crashDumpUploadEnabled = m_crashDumpUploadEnabled.getThreadLocal(); + ui->cb_crashDumpsUpload->setChecked(crashDumpUploadEnabled); connect(ui->cb_crashDumpsUpload, &QCheckBox::stateChanged, this, &CSettingsAdvancedComponent::crashDumpUploadEnabledChanged); } @@ -31,9 +29,7 @@ namespace BlackGui::Components ui->cb_crashDumpsUpload->setText(ui->cb_crashDumpsUpload->text() + " (restart needed)"); } - CCrashSettings settings = m_crashDumpSettings.getThreadLocal(); - settings.setEnabled(state == Qt::Checked); - m_crashDumpSettings.set(settings); + m_crashDumpUploadEnabled.set(state == Qt::Checked); } } // ns diff --git a/src/blackgui/components/settingsadvancedcomponent.h b/src/blackgui/components/settingsadvancedcomponent.h index 540ac6bac..2e0eb93db 100644 --- a/src/blackgui/components/settingsadvancedcomponent.h +++ b/src/blackgui/components/settingsadvancedcomponent.h @@ -36,7 +36,7 @@ namespace BlackGui::Components void crashDumpUploadEnabledChanged(int state); QScopedPointer ui; - BlackMisc::CSetting m_crashDumpSettings { this }; + BlackMisc::CSetting m_crashDumpUploadEnabled { this }; }; } // ns diff --git a/src/blackmisc/CMakeLists.txt b/src/blackmisc/CMakeLists.txt index 09c1c62f1..9c40a7e92 100644 --- a/src/blackmisc/CMakeLists.txt +++ b/src/blackmisc/CMakeLists.txt @@ -196,8 +196,6 @@ add_library(misc SHARED crashhandler.h crashinfo.cpp crashinfo.h - crashsettings.cpp - crashsettings.h datacache.cpp datacache.h datastream.h diff --git a/src/blackmisc/crashsettings.cpp b/src/blackmisc/crashsettings.cpp deleted file mode 100644 index d43b3d1eb..000000000 --- a/src/blackmisc/crashsettings.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "blackmisc/crashsettings.h" -#include "blackmisc/stringutils.h" -#include "blackmisc/comparefunctions.h" - -#include - -BLACK_DEFINE_VALUEOBJECT_MIXINS(BlackMisc::Settings, CCrashSettings) - -namespace BlackMisc::Settings -{ - CCrashSettings::CCrashSettings() {} - - QString CCrashSettings::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - return QStringLiteral("{ %1, %2 }").arg(boolToYesNo(this->isEnabled()), boolToYesNo(this->withPrivacyInfo())); - } - - QVariant CCrashSettings::propertyByIndex(CPropertyIndexRef index) const - { - if (index.isMyself()) { return QVariant::fromValue(*this); } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexEnabled: return QVariant::fromValue(this->isEnabled()); - case IndexPrivateInfo: return QVariant::fromValue(this->withPrivacyInfo()); - default: break; - } - return CValueObject::propertyByIndex(index); - } - - void CCrashSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant) - { - if (index.isMyself()) - { - (*this) = variant.value(); - return; - } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexEnabled: this->setEnabled(variant.toBool()); break; - case IndexPrivateInfo: this->setPrivacyInfo(variant.toBool()); break; - default: CValueObject::setPropertyByIndex(index, variant); break; - } - } - - int CCrashSettings::comparePropertyByIndex(CPropertyIndexRef index, const CCrashSettings &compareValue) const - { - if (index.isMyself()) { return this->convertToQString().compare(compareValue.convertToQString()); } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexEnabled: return Compare::compare(this->isEnabled(), compareValue.isEnabled()); - case IndexPrivateInfo: return Compare::compare(this->withPrivacyInfo(), compareValue.withPrivacyInfo()); - default: return CValueObject::comparePropertyByIndex(index.copyFrontRemoved(), compareValue); - } - } -} // ns diff --git a/src/blackmisc/crashsettings.h b/src/blackmisc/crashsettings.h deleted file mode 100644 index 5a4fa3dfe..000000000 --- a/src/blackmisc/crashsettings.h +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKMISC_CRASHSETTINGS_H -#define BLACKMISC_CRASHSETTINGS_H - -#include "blackmisc/valueobject.h" - -BLACK_DECLARE_VALUEOBJECT_MIXINS(BlackMisc::Settings, CCrashSettings) - -namespace BlackMisc::Settings -{ - /*! - * Crash info. Details about crash context. - */ - class BLACKMISC_EXPORT CCrashSettings : public CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexEnabled = CPropertyIndexRef::GlobalIndexCCrashSettings, - IndexPrivateInfo - }; - - //! Default constructor. - CCrashSettings(); - - //! Is enabled? - bool isEnabled() const { return m_enabled; } - - //! Set enabled - void setEnabled(bool enabled) { m_enabled = enabled; } - - //! With privacy info - bool withPrivacyInfo() const { return m_privacyInfo; } - - //! Set privacy info - void setPrivacyInfo(bool privacy) { m_privacyInfo = privacy; } - - //! \copydoc BlackMisc::Mixin::String::toQString - QString convertToQString(bool i18n = false) const; - - //! \copydoc BlackMisc::Mixin::Index::propertyByIndex - QVariant propertyByIndex(CPropertyIndexRef index) const; - - //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex - void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant); - - //! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex - int comparePropertyByIndex(CPropertyIndexRef index, const CCrashSettings &compareValue) const; - - private: - bool m_enabled = false; - bool m_privacyInfo = false; - - BLACK_METACLASS( - CCrashSettings, - BLACK_METAMEMBER(enabled), - BLACK_METAMEMBER(privacyInfo) - ); - }; -} // ns - -Q_DECLARE_METATYPE(BlackMisc::Settings::CCrashSettings) - -#endif // guard diff --git a/src/blackmisc/registermetadata.cpp b/src/blackmisc/registermetadata.cpp index 55d74aa86..b3551637a 100644 --- a/src/blackmisc/registermetadata.cpp +++ b/src/blackmisc/registermetadata.cpp @@ -15,7 +15,6 @@ #include "blackmisc/sharedstate/passiveobserver.h" #include "blackmisc/applicationinfolist.h" #include "blackmisc/countrylist.h" -#include "blackmisc/crashsettings.h" #include "blackmisc/directories.h" #include "blackmisc/iconlist.h" #include "blackmisc/identifierlist.h" @@ -91,7 +90,6 @@ namespace BlackMisc Network::registerMetadata(); PhysicalQuantities::registerMetadata(); Simulation::registerMetadata(); - Settings::CCrashSettings::registerMetadata(); Weather::registerMetadata(); SharedState::CAnyMatch::registerMetadata();