22 QString summary = QString::fromStdString(issue.
getSummary());
23 QString details = QString::fromStdString(issue.
getDetails(
true));
24 helpPath = QString::fromStdString(issue.
getHelpPath());
26 QString text = QString(
"<h3>%1</h3><p>%2</p>").arg(summary).arg(details);
27 textLabel =
new QLabel(text,
this);
29 textLabel->installEventFilter(
this);
30 textLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
31 textLabel->setOpenExternalLinks(
true);
33 layout =
new QVBoxLayout(
this);
34 layout->addWidget(textLabel, 0, Qt::AlignTop);
38 QToolButton *helpButton =
new QToolButton(textLabel);
39 helpButton->setIcon(QIcon(
":/Icons/question-circle.svg"));
40 helpButton->setStyleSheet(
"QToolButton { border: none; }");
41 helpButton->setCursor(Qt::PointingHandCursor);
42 connect(helpButton, &QToolButton::clicked,
this, &VuoErrorPopover::helpButtonClicked);
45 QVBoxLayout *innerLayout =
new QVBoxLayout(textLabel);
46 innerLayout->setContentsMargins(0, 4, 4, 0);
47 innerLayout->addWidget(helpButton, 0, Qt::AlignTop | Qt::AlignRight);
48 textLabel->setLayout(innerLayout);
55 dragInProgress =
false;
64 void VuoErrorPopover::setStyle()
67 textLabel->setMargin(5);
68 textLabel->setWordWrap(
true);
70 Qt::WindowFlags flags = windowFlags();
71 flags |= Qt::FramelessWindowHint;
73 setWindowFlags(flags);
76 setAttribute(Qt::WA_TranslucentBackground,
true);
78 setArrowSide(Qt::AnchorTop);
93 QColor backgroundColor = isDark ? QColor(
"#282828") : QColor(
"#f9f9f9");
95 QPainter painter(
this);
98 painter.setCompositionMode(QPainter::CompositionMode_Clear);
99 painter.setBrush(backgroundColor);
100 painter.drawRect(QRect(0, 0, width(), height()));
101 painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
103 painter.setRenderHint(QPainter::Antialiasing,
true);
105 painter.setPen(Qt::NoPen);
106 painter.fillPath(
getPopoverPath(arrowSide, arrowTipY), backgroundColor);
115 if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseMove || event->type() == QEvent::MouseButtonRelease)
117 QMouseEvent *mouseEvent =
static_cast<QMouseEvent *
>(event);
119 if (mouseEvent->type() == QEvent::MouseButtonPress && mouseEvent->button() == Qt::LeftButton)
121 dragInProgress =
true;
122 positionBeforeDrag = mouseEvent->globalPos();
124 else if (mouseEvent->type() == QEvent::MouseMove && (mouseEvent->buttons() & Qt::LeftButton) && dragInProgress)
126 QPoint delta = mouseEvent->globalPos() - positionBeforeDrag;
127 move(x() + delta.x(), y() + delta.y());
128 positionBeforeDrag = mouseEvent->globalPos();
130 else if (mouseEvent->type() == QEvent::MouseButtonRelease && mouseEvent->button() == Qt::LeftButton)
132 dragInProgress =
false;
139 void VuoErrorPopover::helpButtonClicked()
141 QDesktopServices::openUrl(
"vuo-help:" + helpPath);
147 void VuoErrorPopover::setArrowSide(Qt::AnchorPoint arrowSide)
149 this->arrowSide = arrowSide;
175 void VuoErrorPopover::updateColor(
bool isDark)
177 QString textColor = isDark ?
"#cacaca" :
"#000000";
178 textLabel->setStyleSheet(QString(
"color: %1;").arg(textColor));