Revert "Ref T401, adjusted settings used in components"

This reverts commit 705a56b1cb.
Only the bool member of the CrashSettings class was used.
For simplification, use only the bool that was already used
previously to store this setting.
This commit is contained in:
Lars Toenning
2024-04-28 10:44:10 +02:00
parent 0dba1b8566
commit 89b7e672a1
11 changed files with 13 additions and 158 deletions

View File

@@ -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);
}

View File

@@ -657,7 +657,7 @@ namespace BlackCore
bool m_localSettingsLoaded = false; //!< local settings loaded?
// -------------- crashpad -----------------
BlackMisc::CSettingReadOnly<Application::TCrashDumpSettings> m_crashDumpSettings { this, &CApplication::onCrashDumpUploadEnabledChanged };
BlackMisc::CSettingReadOnly<Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this, &CApplication::onCrashDumpUploadEnabledChanged };
//! Upload settings changed
void onCrashDumpUploadEnabledChanged();

View File

@@ -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 <QStringList>
@@ -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<BlackMisc::Settings::CCrashSettings>
struct TCrashDumpUploadEnabled : public BlackMisc::TSettingTrait<bool>
{
//! \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

View File

@@ -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()

View File

@@ -49,7 +49,7 @@ namespace BlackGui::Components
void setChecklistInfo();
QScopedPointer<Ui::CLegalInfoComponent> ui;
BlackMisc::CSetting<BlackCore::Application::TCrashDumpSettings> m_crashDumpSettings { this };
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this };
};
/*!

View File

@@ -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

View File

@@ -36,7 +36,7 @@ namespace BlackGui::Components
void crashDumpUploadEnabledChanged(int state);
QScopedPointer<Ui::CSettingsAdvancedComponent> ui;
BlackMisc::CSetting<BlackCore::Application::TCrashDumpSettings> m_crashDumpSettings { this };
BlackMisc::CSetting<BlackCore::Application::TCrashDumpUploadEnabled> m_crashDumpUploadEnabled { this };
};
} // ns

View File

@@ -196,8 +196,6 @@ add_library(misc SHARED
crashhandler.h
crashinfo.cpp
crashinfo.h
crashsettings.cpp
crashsettings.h
datacache.cpp
datacache.h
datastream.h

View File

@@ -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 <QStringBuilder>
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<ColumnIndex>();
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<CCrashSettings>();
return;
}
const ColumnIndex i = index.frontCasted<ColumnIndex>();
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<ColumnIndex>();
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

View File

@@ -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<CCrashSettings>
{
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

View File

@@ -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();