Console: Remove Translated Notification message

===============================================

With the new console extension, the translation state is coded separatedly.

Therefore, it is possible to code a Notification as translated without needing a specific type.

Additionally, any other message, such as Error of Warning can be translated.

It does not make sense to leave this message, if only for reasons of coherence and to simplify
maintainance of code.
This commit is contained in:
Abdullah Tahiri
2023-05-21 16:45:44 +02:00
committed by abdullahtahiriyo
parent c973033b6c
commit cc13da5470
4 changed files with 16 additions and 41 deletions

View File

@@ -97,9 +97,6 @@ public:
case ConsoleSingleton::MsgType_Notification:
Console().notifyPrivate(LogStyle::Notification, ce->recipient, ce->content, ce->notifier, ce->msg);
break;
case ConsoleSingleton::MsgType_TranslatedNotification:
Console().notifyPrivate(LogStyle::TranslatedNotification, ce->recipient, ce->content, ce->notifier, ce->msg);
break;
}
}
}
@@ -212,11 +209,6 @@ ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType(const char* sObs, ConsoleMsg
flags |= MsgType_Notification;
pObs->bNotification = b;
}
if ( type&MsgType_TranslatedNotification ){
if ( pObs->bTranslatedNotification != b )
flags |= MsgType_TranslatedNotification;
pObs->bTranslatedNotification = b;
}
return flags;
}
@@ -242,8 +234,6 @@ bool ConsoleSingleton::IsMsgTypeEnabled(const char* sObs, FreeCAD_ConsoleMsgType
return pObs->bCritical;
case MsgType_Notification:
return pObs->bNotification;
case MsgType_TranslatedNotification:
return pObs->bTranslatedNotification;
default:
return false;
}
@@ -628,10 +618,8 @@ PyObject *ConsoleSingleton::sPyGetStatus(PyObject * /*self*/, PyObject *args)
b = pObs->bCritical;
else if (strcmp(pstr2,"Notification") == 0)
b = pObs->bNotification;
else if (strcmp(pstr2,"TranslatedNotification") == 0)
b = pObs->bTranslatedNotification;
else
Py_Error(Base::PyExc_FC_GeneralError,"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical', 'Notification' or 'TranslatedNotification')");
Py_Error(Base::PyExc_FC_GeneralError,"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical' or 'Notification')");
return PyBool_FromLong(b ? 1 : 0);
}
@@ -662,10 +650,8 @@ PyObject *ConsoleSingleton::sPySetStatus(PyObject * /*self*/, PyObject *args)
pObs->bCritical = status;
else if (strcmp(pstr2,"Notification") == 0)
pObs->bNotification = status;
else if (strcmp(pstr2,"TranslatedNotification") == 0)
pObs->bTranslatedNotification = status;
else
Py_Error(Base::PyExc_FC_GeneralError,"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical', 'Notification' or 'TranslatedNotification')");
Py_Error(Base::PyExc_FC_GeneralError,"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical' or 'Notification')");
Py_Return;
}

View File

@@ -471,7 +471,6 @@ enum class LogStyle{
Log,
Critical, // Special message to mark critical notifications
Notification, // Special message for notifications to the user (e.g. educational)
TranslatedNotification, // Special message for already translated notifications to the user (e.g. educational)
};
enum class IntendedRecipient {
@@ -497,7 +496,7 @@ class BaseExport ILogger
{
public:
ILogger()
:bErr(true), bMsg(true), bLog(true), bWrn(true), bCritical(true), bNotification(false), bTranslatedNotification(false){}
:bErr(true), bMsg(true), bLog(true), bWrn(true), bCritical(true), bNotification(false){}
virtual ~ILogger() = 0;
/** Used to send a Log message at the given level.
@@ -542,23 +541,20 @@ public:
if(category == Base::LogStyle::Notification) {
return bNotification;
}
else
if(category == Base::LogStyle::TranslatedNotification) {
return bTranslatedNotification;
}
return false;
}
virtual const char *Name(){return nullptr;}
bool bErr, bMsg, bLog, bWrn, bCritical, bNotification, bTranslatedNotification;
bool bErr, bMsg, bLog, bWrn, bCritical, bNotification;
};
/** The console class
* This class manage all the stdio stuff. This includes
* Messages, Warnings, Log entries, Errors, Criticals, Notifications and
* TranslatedNotifications. The incoming Messages are distributed with the
* FCConsoleObserver. The FCConsole class itself makes no IO, it's more like a manager.
* Messages, Warnings, Log entries, Errors, Criticals, Notifications. The incoming Messages are
* distributed with the FCConsoleObserver. The FCConsole class itself makes no IO, it's more like
* a manager.
* \par
* ConsoleSingleton is a singleton! That means you can access the only
* instance of the class from every where in c++ by simply using:
@@ -576,9 +572,9 @@ class BaseExport ConsoleSingleton
public:
// exported functions goes here +++++++++++++++++++++++++++++++++++++++
/** Sends a message of type LogStyle (Message, Warning, Error, Log, Critical, Notification or TranslatedNotification).
This function is used by all specific convenience functions (Send(), Message(), Warning(), Error(), Log(), Critical
UserNotification and UserTranslatedNotification, without or without notifier id).
/** Sends a message of type LogStyle (Message, Warning, Error, Log, Critical or Notification).
This function is used by all specific convenience functions (Send(), Message(), Warning(), Error(), Log(), Critical and
UserNotification, without or without notifier id).
Notification can be direct or via queue.
*/
@@ -672,7 +668,6 @@ public:
MsgType_Err = 8,
MsgType_Critical = 16, // Special message to notify critical information
MsgType_Notification = 32, // Special message to for notifications to the user
MsgType_TranslatedNotification = 64, // Special message for already translated notifications to the user
};
/// Change mode
@@ -771,8 +766,7 @@ inline constexpr ConsoleSingleton::FreeCAD_ConsoleMsgType ConsoleSingleton::getC
FreeCAD_ConsoleMsgType::MsgType_Err,
FreeCAD_ConsoleMsgType::MsgType_Log,
FreeCAD_ConsoleMsgType::MsgType_Critical,
FreeCAD_ConsoleMsgType::MsgType_Notification,
FreeCAD_ConsoleMsgType::MsgType_TranslatedNotification
FreeCAD_ConsoleMsgType::MsgType_Notification
};
return msgTypes.at(static_cast<std::size_t>(style));

View File

@@ -81,7 +81,7 @@ public:
// Constructor that will block message types passed as parameter. By default, all types are blocked.
inline explicit ILoggerBlocker(const char* co, ConsoleMsgFlags msgTypes =
ConsoleSingleton::MsgType_Txt | ConsoleSingleton::MsgType_Log | ConsoleSingleton::MsgType_Wrn | ConsoleSingleton::MsgType_Err |
ConsoleSingleton::MsgType_Critical | ConsoleSingleton::MsgType_Notification | ConsoleSingleton::MsgType_TranslatedNotification);
ConsoleSingleton::MsgType_Critical | ConsoleSingleton::MsgType_Notification);
// Disable copy & move constructors
ILoggerBlocker(ILoggerBlocker const&) = delete;
ILoggerBlocker(ILoggerBlocker const &&) = delete;

View File

@@ -234,7 +234,6 @@ NotificationAreaObserver::NotificationAreaObserver(NotificationArea* notificatio
bLog = false; // ignore log messages
bMsg = false; // ignore messages
bNotification = true; // activate user notifications
bTranslatedNotification = true;// activate translated user notifications
}
NotificationAreaObserver::~NotificationAreaObserver()
@@ -377,16 +376,14 @@ public:
if (tableWidget) {
for (int i = tableWidget->topLevelItemCount() - 1; i >= 0; i--) {
auto* item = static_cast<NotificationItem*>(tableWidget->topLevelItem(i));
if (item->notificationType == Base::LogStyle::Notification
|| item->notificationType == Base::LogStyle::TranslatedNotification) {
if (item->notificationType == Base::LogStyle::Notification) {
delete item;
}
}
}
for (int i = pushedItems.size() - 1; i >= 0; i--) {
auto* item = static_cast<NotificationItem*>(pushedItems.at(i));
if (item->notificationType == Base::LogStyle::Notification
|| item->notificationType == Base::LogStyle::TranslatedNotification) {
if (item->notificationType == Base::LogStyle::Notification) {
delete pushedItems.takeAt(i);
}
}
@@ -1057,9 +1054,7 @@ void NotificationArea::showInNotificationArea()
item->notifying = false;
if (pImp->autoRemoveUserNotifications) {
if (item->notificationType == Base::LogStyle::Notification
|| item->notificationType
== Base::LogStyle::TranslatedNotification) {
if (item->notificationType == Base::LogStyle::Notification) {
static_cast<NotificationsAction*>(pImp->notificationaction)
->deleteItem(item);