NotificationArea/Preferences: Allow Opt-in for Developer warnings and errors
============================================================================ The old preferences had errors and warnings ON by default and allowed to opt-out. It was not possible to separate errors/warnings intended for users from those intended for developers. The new version has developer errors and warnings OFF by default. User intended ones are ON. It is possible to opt-in for developer errors and warnings from the preferences dialog. As developer errors and warnings are NOT translated, if opting-in, they won't be localised. User errors and warnings should be translated. If they are not, it is a bug.
This commit is contained in:
committed by
abdullahtahiriyo
parent
0e85b24348
commit
12a7f3b236
@@ -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)
|
||||
|
||||
@@ -64,22 +64,22 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="GroupBoxSubscriptions">
|
||||
<property name="title">
|
||||
<string>Additional data Sources</string>
|
||||
<string>Additional data sources</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="errorSubscriptionEnabled">
|
||||
<widget class="Gui::PrefCheckBox" name="developerErrorSubscriptionEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Errors will appear in the notification area</string>
|
||||
<string>Errors intended for developers will appear in the notification area</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Errors</string>
|
||||
<string>Debug errors</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ErrorSubscriptionEnabled</cstring>
|
||||
<cstring>DeveloperErrorSubscriptionEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
@@ -87,18 +87,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="warningSubscriptionEnabled">
|
||||
<widget class="Gui::PrefCheckBox" name="developerWarningSubscriptionEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Warnings will appear in the notification area</string>
|
||||
<string>Warnings intended for developers will appear in the notification area</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Warnings</string>
|
||||
<string>Debug warnings</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>WarningSubscriptionEnabled</cstring>
|
||||
<cstring>DeveloperWarningSubscriptionEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user