Skip to content
Snippets Groups Projects
Commit dcb5b7d2 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Warning sign now provides failure message box on mouse click

parent a6ced099
No related branches found
No related tags found
No related merge requests found
......@@ -231,6 +231,7 @@ QString PySampleWidget::generateCodeSnippet()
result.append(QString::fromStdString(ostr.str()));
} catch(const std::exception &ex) {
m_warningSign = new WarningSignWidget(this);
m_warningSign->setWarningMessage(QString::fromStdString(ex.what()));
m_warningSign->setPosition(width()-warning_sign_xpos, height()-warning_sign_ypos);
m_warningSign->show();
......
......@@ -16,6 +16,7 @@
#include "WarningSignWidget.h"
#include <QPainter>
#include <QRect>
#include <QMessageBox>
WarningSignWidget::WarningSignWidget(QWidget * parent = 0) : QWidget(parent) {
setAttribute(Qt::WA_NoSystemBackground);
......@@ -34,9 +35,16 @@ void WarningSignWidget::paintEvent(QPaintEvent *event) {
painter.drawPixmap(target, m_pixmap);
}
void WarningSignWidget::mousePressEvent(QMouseEvent *event)
{
QMessageBox::warning(this, tr("Generation failed"),
QString("Generation of Python Script failed with the following error message\n\n%1")
.arg(m_warning_message));
}
//! set geometry of widget around center point
void WarningSignWidget::setPosition(int x, int y)
{
// setGeometry(x, y, m_pixmap.width(), m_pixmap.height());
setGeometry(x, y, m_pixmap.width(), m_pixmap.height());
}
......@@ -30,8 +30,11 @@ public:
void setPosition(int x, int y);
void setWarningMessage(const QString &message) {m_warning_message = message;}
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
QPixmap m_pixmap;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment