diff --git a/src/Gui/DlgSettingsNotificationArea.cpp b/src/Gui/DlgSettingsNotificationArea.cpp index c2f77c7e9c..2a6bfab7c1 100644 --- a/src/Gui/DlgSettingsNotificationArea.cpp +++ b/src/Gui/DlgSettingsNotificationArea.cpp @@ -51,8 +51,8 @@ DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent) ui->autoRemoveUserNotifications->setEnabled(true); ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->setEnabled(true); ui->preventNonIntrusiveNotificationsWhenWindowNotActive->setEnabled(true); - ui->errorSubscriptionEnabled->setEnabled(true); - ui->warningSubscriptionEnabled->setEnabled(true); + ui->developerErrorSubscriptionEnabled->setEnabled(true); + ui->developerWarningSubscriptionEnabled->setEnabled(true); QMessageBox::information(this, tr("Notification Area"), tr("Activation of the Notification Area only takes effect " @@ -68,8 +68,8 @@ DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent) ui->autoRemoveUserNotifications->setEnabled(false); ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->setEnabled(false); ui->preventNonIntrusiveNotificationsWhenWindowNotActive->setEnabled(false); - ui->errorSubscriptionEnabled->setEnabled(false); - ui->warningSubscriptionEnabled->setEnabled(false); + ui->developerErrorSubscriptionEnabled->setEnabled(false); + ui->developerWarningSubscriptionEnabled->setEnabled(false); // N.B: Deactivation is handled by the Notification Area itself, as it listens to all // its configuration parameters. } @@ -91,8 +91,8 @@ void DlgSettingsNotificationArea::saveSettings() ui->notificationWidth->onSave(); ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->onSave(); ui->preventNonIntrusiveNotificationsWhenWindowNotActive->onSave(); - ui->errorSubscriptionEnabled->onSave(); - ui->warningSubscriptionEnabled->onSave(); + ui->developerErrorSubscriptionEnabled->onSave(); + ui->developerWarningSubscriptionEnabled->onSave(); } void DlgSettingsNotificationArea::loadSettings() @@ -107,8 +107,8 @@ void DlgSettingsNotificationArea::loadSettings() ui->notificationWidth->onRestore(); ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->onRestore(); ui->preventNonIntrusiveNotificationsWhenWindowNotActive->onRestore(); - ui->errorSubscriptionEnabled->onRestore(); - ui->warningSubscriptionEnabled->onRestore(); + ui->developerErrorSubscriptionEnabled->onRestore(); + ui->developerWarningSubscriptionEnabled->onRestore(); } void DlgSettingsNotificationArea::changeEvent(QEvent* e) diff --git a/src/Gui/DlgSettingsNotificationArea.ui b/src/Gui/DlgSettingsNotificationArea.ui index 1d7dcd466d..3b3ddd961a 100644 --- a/src/Gui/DlgSettingsNotificationArea.ui +++ b/src/Gui/DlgSettingsNotificationArea.ui @@ -64,22 +64,22 @@ - Additional data Sources + Additional data sources - + - + - Errors will appear in the notification area + Errors intended for developers will appear in the notification area - Errors + Debug errors - true + false - ErrorSubscriptionEnabled + DeveloperErrorSubscriptionEnabled NotificationArea @@ -87,18 +87,18 @@ - + - Warnings will appear in the notification area + Warnings intended for developers will appear in the notification area - Warnings + Debug warnings - true + false - WarningSubscriptionEnabled + DeveloperWarningSubscriptionEnabled NotificationArea diff --git a/src/Gui/NotificationArea.cpp b/src/Gui/NotificationArea.cpp index 326b58498e..e8ae746140 100644 --- a/src/Gui/NotificationArea.cpp +++ b/src/Gui/NotificationArea.cpp @@ -109,6 +109,14 @@ struct NotificationAreaP const unsigned int inhibitNotificationTime = 250; //@} + /** @name Data source control */ + //@{ + /* Controls whether debug warnings and errors intended for developers should be processed or not + */ + bool developerErrorSubscriptionEnabled = false; + bool developerWarningSubscriptionEnabled = false; + //@} + bool missedNotifications = false; // Access control @@ -231,9 +239,9 @@ NotificationAreaObserver::NotificationAreaObserver(NotificationArea* notificatio : notificationArea(notificationarea) { Base::Console().AttachObserver(this); - bLog = false; // ignore log messages - bMsg = false; // ignore messages - bNotification = true; // activate user notifications + bLog = false; // ignore log messages + bMsg = false; // ignore messages + bNotification = true;// activate user notifications } NotificationAreaObserver::~NotificationAreaObserver() @@ -241,8 +249,9 @@ NotificationAreaObserver::~NotificationAreaObserver() Base::Console().DetachObserver(this); } -void NotificationAreaObserver::SendLog(const std::string& notifiername, const std::string& msg, Base::LogStyle level, - Base::IntendedRecipient recipient, Base::ContentType content) +void NotificationAreaObserver::SendLog(const std::string& notifiername, const std::string& msg, + Base::LogStyle level, Base::IntendedRecipient recipient, + Base::ContentType content) { // 1. As notification system is shared with report view and others, the expectation is that any // individual error and warning message will end in "\n". This means the string must be stripped @@ -252,8 +261,19 @@ void NotificationAreaObserver::SendLog(const std::string& notifiername, const st // "\n", as this generates problems with the translation system. Then the string must be // stripped of "\n" before translation. - if( recipient == Base::IntendedRecipient::Developer || - content == Base::ContentType::Untranslatable) { + bool violatesBasicPolicy = (recipient == Base::IntendedRecipient::Developer + || content == Base::ContentType::Untranslatable); + + // We allow derogations for debug purposes according to user preferences + bool meetsDerogationCriteria = false; + + if (violatesBasicPolicy) { + meetsDerogationCriteria = + (level == Base::LogStyle::Warning && notificationArea->areDeveloperWarningsActive()) + || (level == Base::LogStyle::Error && notificationArea->areDeveloperErrorsActive()); + } + + if (violatesBasicPolicy && !meetsDerogationCriteria) { return; } @@ -682,15 +702,15 @@ NotificationArea::ParameterObserver::ParameterObserver(NotificationArea* notific auto enabled = hGrp->GetBool(string.c_str(), true); notificationArea->pImp->preventNonIntrusiveNotificationsWhenWindowNotActive = enabled; }}, - {"ErrorSubscriptionEnabled", + {"DeveloperErrorSubscriptionEnabled", [this](const std::string& string) { - auto enabled = hGrp->GetBool(string.c_str(), true); - notificationArea->pImp->observer->bErr = enabled; + auto enabled = hGrp->GetBool(string.c_str(), false); + notificationArea->pImp->developerErrorSubscriptionEnabled = enabled; }}, - {"WarningSubscriptionEnabled", + {"DeveloperWarningSubscriptionEnabled", [this](const std::string& string) { - auto enabled = hGrp->GetBool(string.c_str(), true); - notificationArea->pImp->observer->bWrn = enabled; + auto enabled = hGrp->GetBool(string.c_str(), false); + notificationArea->pImp->developerWarningSubscriptionEnabled = enabled; }}, }; @@ -865,6 +885,16 @@ void NotificationArea::mousePressEvent(QMouseEvent* e) QPushButton::mousePressEvent(e); } +bool NotificationArea::areDeveloperWarningsActive() const +{ + return pImp->developerWarningSubscriptionEnabled; +} + +bool NotificationArea::areDeveloperErrorsActive() const +{ + return pImp->developerErrorSubscriptionEnabled; +} + void NotificationArea::pushNotification(const QString& notifiername, const QString& message, Base::LogStyle level) { diff --git a/src/Gui/NotificationArea.h b/src/Gui/NotificationArea.h index 9af248faa7..9e5622b9bb 100644 --- a/src/Gui/NotificationArea.h +++ b/src/Gui/NotificationArea.h @@ -66,6 +66,9 @@ public: void pushNotification(const QString& notifiername, const QString& message, Base::LogStyle level); + bool areDeveloperWarningsActive () const; + bool areDeveloperErrorsActive () const; + private: void showInNotificationArea(); bool confirmationRequired(Base::LogStyle level);