diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 5d401bb29..9fdfd0e71 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -1005,8 +1005,7 @@ namespace BlackCore } CUrl serverUrl; - if (CBuildConfig::isReleaseBuild()) { serverUrl = getGlobalSetup().getCrashreportServerUrl(); } - + serverUrl = getGlobalSetup().getCrashreportServerUrl(); std::map annotations; // Caliper (mini-breakpad-server) annotations @@ -1015,7 +1014,7 @@ namespace BlackCore m_crashReportDatabase = CrashReportDatabase::Initialize(qstringToFilePath(database)); auto settings = m_crashReportDatabase->GetSettings(); - settings->SetUploadsEnabled(true); + settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal()); m_crashpadClient = std::make_unique(); m_crashpadClient->StartHandler(qstringToFilePath(handler), qstringToFilePath(database), serverUrl.getFullUrl().toStdString(), annotations, {}, false); @@ -1023,4 +1022,13 @@ namespace BlackCore #endif } + void CApplication::crashDumpUploadEnabledChanged() + { + #ifdef BLACK_USE_CRASHPAD + if (!m_crashReportDatabase) { return; } + auto settings = m_crashReportDatabase->GetSettings(); + settings->SetUploadsEnabled(CBuildConfig::isReleaseBuild() && m_crashDumpUploadEnabled.getThreadLocal()); + #endif + } + } // ns diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 556140486..48a8454c8 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -30,6 +30,7 @@ #include "blackcore/data/globalsetup.h" #include "blackcore/data/updateinfo.h" #include "blackcore/db/databasereaderconfig.h" +#include "blackcore/application/applicationsettings.h" #include "blackcore/webreaderflags.h" #include "blackmisc/network/url.h" #include "blackmisc/network/urllist.h" @@ -414,6 +415,8 @@ namespace BlackCore void initCrashHandler(); + void crashDumpUploadEnabledChanged(); + QScopedPointer m_coreFacade; //!< core facade if any QScopedPointer m_setupReader; //!< setup reader QScopedPointer m_webDataServices; //!< web data services @@ -434,8 +437,11 @@ namespace BlackCore bool m_unitTest = false; //!< is UNIT test bool m_autoSaveSettings = true;//!< automatically saving all settings + #ifdef BLACK_USE_CRASHPAD std::unique_ptr m_crashpadClient; std::unique_ptr m_crashReportDatabase; + BlackMisc::CSetting m_crashDumpUploadEnabled { this, &CApplication::crashDumpUploadEnabledChanged }; + #endif }; } // namespace diff --git a/src/blackcore/application/applicationsettings.h b/src/blackcore/application/applicationsettings.h index d3563f063..e1394661d 100644 --- a/src/blackcore/application/applicationsettings.h +++ b/src/blackcore/application/applicationsettings.h @@ -91,6 +91,17 @@ namespace BlackCore }; } }; + + //! Uploading of crash dumps is enabled or disabled + struct TCrashDumpUploadEnabled : public BlackMisc::TSettingTrait + { + //! \copydoc BlackCore::TSettingTrait::key + static const char *key() { return "application/crashdumpuploadenabled"; } + + //! \copydoc BlackCore::TSettingTrait::defaultValue + static bool defaultValue() { return true; } + }; + } // ns } // ns diff --git a/src/blackgui/components/settingsadvancedcomponent.cpp b/src/blackgui/components/settingsadvancedcomponent.cpp new file mode 100644 index 000000000..df8e3fe19 --- /dev/null +++ b/src/blackgui/components/settingsadvancedcomponent.cpp @@ -0,0 +1,43 @@ +/* Copyright (C) 2015 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "blackgui/components/settingsadvancedcomponent.h" +#include "ui_settingsadvancedcomponent.h" + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CSettingsAdvancedComponent::CSettingsAdvancedComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CSettingsAdvancedComponent) + { + ui->setupUi(this); + ui->m_crashDumpsUpload->setChecked(m_crashDumpUploadEnabled.getThreadLocal()); + connect(ui->m_crashDumpsUpload, &QCheckBox::stateChanged, this, &CSettingsAdvancedComponent::crashDumpUploadEnabledChanged); + } + + CSettingsAdvancedComponent::~CSettingsAdvancedComponent() + { + } + + void CSettingsAdvancedComponent::crashDumpUploadEnabledChanged(int state) + { + auto text = ui->m_crashDumpsUpload->text(); + if (!text.endsWith("(restart needed)")) + { + ui->m_crashDumpsUpload->setText(ui->m_crashDumpsUpload->text() + " (restart needed)"); + } + m_crashDumpUploadEnabled.set(state == Qt::Checked); + } + + } // ns +} // ns diff --git a/src/blackgui/components/settingsadvancedcomponent.h b/src/blackgui/components/settingsadvancedcomponent.h new file mode 100644 index 000000000..fc5ed4211 --- /dev/null +++ b/src/blackgui/components/settingsadvancedcomponent.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2015 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_SETTINGSGENERALCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSGENERALCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackcore/application/applicationsettings.h" +#include "blackmisc/settingscache.h" + +#include +#include +#include + +class QWidget; + +namespace Ui { class CSettingsAdvancedComponent; } + +namespace BlackGui +{ + namespace Components + { + //! Configure general settings + class BLACKGUI_EXPORT CSettingsAdvancedComponent : + public QFrame + { + Q_OBJECT + + public: + //! Constructor + CSettingsAdvancedComponent(QWidget *parent = nullptr); + + //! Destructor + ~CSettingsAdvancedComponent(); + + private: + void crashDumpUploadEnabledChanged(int state); + + QScopedPointer ui; + BlackMisc::CSetting m_crashDumpUploadEnabled { this }; + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/settingsadvancedcomponent.ui b/src/blackgui/components/settingsadvancedcomponent.ui new file mode 100644 index 000000000..b148b9a6a --- /dev/null +++ b/src/blackgui/components/settingsadvancedcomponent.ui @@ -0,0 +1,57 @@ + + + CSettingsAdvancedComponent + + + + 0 + 0 + 400 + 193 + + + + sample_hotkeys + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 1 + + + 1 + + + 1 + + + + + Upload crash dumps + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + diff --git a/src/blackgui/components/settingscomponent.ui b/src/blackgui/components/settingscomponent.ui index 6e60e2ef5..5c8d9d0c7 100644 --- a/src/blackgui/components/settingscomponent.ui +++ b/src/blackgui/components/settingscomponent.ui @@ -687,6 +687,23 @@ + + + Advanced + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + @@ -695,6 +712,12 @@
blackgui/components/audiosetupcomponent.h
1
+ + BlackGui::Components::CSettingsAdvancedComponent + QFrame +
blackgui/components/settingsadvancedcomponent.h
+ 1 +
BlackGui::Components::CSettingsSimulatorComponent QFrame