Added new function VAbstractApplication::ClearMessage.

It will help clear messages from unneeded '"' at the start and at the end.
qWarning and others adds them.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-05-25 17:54:21 +03:00
parent 270f3b44a1
commit 81caed8f5f
4 changed files with 25 additions and 6 deletions

View File

@ -199,7 +199,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
{
if (topWinAllowsPop)
{
messageBox.setText(msg);
messageBox.setText(VAbstractApplication::ClearMessage(msg));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);

View File

@ -185,20 +185,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
switch (type)
{
case QtWarningMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning."));
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning"));
messageBox.setIcon(QMessageBox::Warning);
break;
case QtCriticalMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error."));
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error"));
messageBox.setIcon(QMessageBox::Critical);
break;
case QtFatalMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error."));
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error"));
messageBox.setIcon(QMessageBox::Critical);
break;
#if QT_VERSION > QT_VERSION_CHECK(5, 4, 2)
case QtInfoMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information."));
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information"));
messageBox.setIcon(QMessageBox::Information);
break;
#endif
@ -213,7 +213,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
{
if (topWinAllowsPop)
{
messageBox.setText(msg);
messageBox.setText(VAbstractApplication::ClearMessage(msg));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);

View File

@ -234,6 +234,23 @@ QUndoStack *VAbstractApplication::getUndoStack() const
return undoStack;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ClearMessage helps to clear a message string from standard Qt function.
* @param msg the message that contains '"' at the start and at the end
* @return cleared string
*/
QString VAbstractApplication::ClearMessage(QString msg)
{
if (msg.startsWith('"') && msg.endsWith('"'))
{
msg.remove(0, 1);
msg.chop(1);
}
return msg;
}
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_WIN)
void VAbstractApplication::WinAttachConsole()

View File

@ -115,6 +115,8 @@ public:
static void WinAttachConsole();
#endif
static QString ClearMessage(QString msg);
protected:
QUndoStack *undoStack;