33 QGraphicsDropShadowEffect *effect =
new QGraphicsDropShadowEffect(widget);
34 effect->setBlurRadius(6);
36 effect->setColor(color);
37 widget->setGraphicsEffect(effect);
56 , m_showOverParent(showOverParent)
58 , m_priority(priority)
59 , m_alignment(alignment)
63 setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip | Qt::WindowTransparentForInput);
64 setFocusPolicy(Qt::NoFocus);
65 setAttribute(Qt::WA_ShowWithoutActivating);
70 m_iconLabel->setAttribute(Qt::WA_TranslucentBackground);
73 palette().color( QPalette::Normal, QPalette::WindowText ).getHsv( &h, &s, &
v );
74 const QColor shadowColor =
v > 128 ? Qt::black : Qt::white;
154 const QSize minImageSize =
m_icon.size().boundedTo(QSize(100, 100));
157 const QSize margin( (M +
MARGIN) * 2, (M +
MARGIN) * 2);
158 const QSize image =
m_icon.isNull() ? QSize(0, 0) : minImageSize;
159 QRect geom = parentWidget()->geometry();
160 QPoint
p(geom.width() / 2 + geom.left(), geom.height() / 2 + geom.top());
161 QScreen *s = qApp->screenAt(
p);
164 max = QSize(s->availableGeometry().size() - margin);
167 max = QSize(1024, 768);
169#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
171 m_message.replace(QRegExp(
" +\n"),
"\n");
173 m_message.replace(QRegExp(
"\n+"),
"\n");
180 QRegExp
r2((
"\n+"));
185 QRect
rect = fontMetrics().boundingRect(0, 0, max.width() - image.width(), max.height(),
189 const int availableWidth = max.width() -
rect.width() - M;
193 Qt::KeepAspectRatio, Qt::SmoothTransformation));
196 rect.setWidth( widthIncludingImage );
207 const QSize newSize =
rect.size();
210 screen = s->availableGeometry();
213 screen = QRect(0, 0, 1024, 768);
219 screen = parentWidget()->geometry();
220 screen.setTopLeft(parentWidget()->mapToGlobal(QPoint(
MARGIN,
MARGIN + 50)));
221 newPos = screen.topLeft();
225 newPos.rx() = screen.width() -
MARGIN - newSize.width();
228 if (newPos.y() + newSize.height() > screen.height() -
MARGIN) {
229 newPos.ry() = screen.height() -
MARGIN - newSize.height();
232 newPos += screen.topLeft();
234 if (parentWidget()) {
236 newPos.setX(newPos.x() -
MARGIN);
240 QRect rc(newPos,
rect.size());