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);
170 m_message.replace(QRegularExpression(
" +\n"),
"\n");
172 m_message.replace(QRegularExpression(
"\n+"),
"\n");
175 QRect
rect = fontMetrics().boundingRect(0, 0, max.width() - image.width(), max.height(),
179 const int availableWidth = max.width() -
rect.width() - M;
183 Qt::KeepAspectRatio, Qt::SmoothTransformation));
186 rect.setWidth( widthIncludingImage );
197 const QSize newSize =
rect.size();
200 screen = s->availableGeometry();
203 screen = QRect(0, 0, 1024, 768);
209 screen = parentWidget()->geometry();
210 screen.setTopLeft(parentWidget()->mapToGlobal(QPoint(
MARGIN,
MARGIN + 50)));
211 newPos = screen.topLeft();
215 newPos.rx() = screen.width() -
MARGIN - newSize.width();
218 if (newPos.y() + newSize.height() > screen.height() -
MARGIN) {
219 newPos.ry() = screen.height() -
MARGIN - newSize.height();
222 newPos += screen.topLeft();
224 if (parentWidget()) {
226 newPos.setX(newPos.x() -
MARGIN);
230 QRect rc(newPos,
rect.size());