11#include <QApplication>
12#include <QDesktopWidget>
17#include <QStyleOptionViewItem>
25 class AADisplayEventFilter :
public QObject
27 QWidget *
const Display_;
29 explicit AADisplayEventFilter (QWidget *
display)
38 switch (
event->type ())
40 case QEvent::KeyRelease:
43 case QEvent::MouseButtonRelease:
53 QTimer::singleShot (0,
69 px =
px.scaled (
availGeom, Qt::KeepAspectRatio, Qt::SmoothTransformation);
72 label->setWindowFlags (Qt::Tool);
73 label->setAttribute (Qt::WA_DeleteOnClose);
74 label->setFixedSize (
px.size ());
77 label->activateWindow ();
78 label->installEventFilter (
new AADisplayEventFilter (
label));
86 color.setRedF (alpha *
c1.redF () + (1 - alpha) *
c2.redF ());
87 color.setGreenF (alpha *
c1.greenF () + (1 - alpha) *
c2.greenF ());
88 color.setBlueF (alpha *
c1.blueF () + (1 - alpha) *
c2.blueF ());
94 return option.fontMetrics.elidedText (text, Qt::ElideRight,
option.rect.width ());
107 return "<em>" +
name +
"</em>";
113 const auto&
iconSize =
px.size () /
px.devicePixelRatio ();
120 const auto width =
fm.horizontalAdvance (text) + 2. *
iconSize.width () / 10.;
130 p.setRenderHint (QPainter::Antialiasing);
131 p.setRenderHint (QPainter::TextAntialiasing);
144 if (!
icon.availableSizes ().isEmpty ())
147 constexpr auto pxSize = 256;
QLabel * ShowPixmapLabel(const QPixmap &srcPx, const QPoint &pos)
Shows a pixmap at the given pos.
QColor TintColors(const QColor &c1, const QColor &c2, double alpha)
Mixes two colors with the given weights.
void TintPalette(QWidget *widget, const QColor &color, double alpha, const QList< QPalette::ColorRole > &roles)
Mixes some of the widget's palette roles with the given color.
Container< T > Filter(const Container< T > &c, F f)
QString ElideProgressBarText(const QString &text, const QStyleOptionViewItem &option)
QRect AvailableGeometry(const QPoint &p)
QPixmap DrawOverlayText(QPixmap px, const QString &text, QFont font, const QPen &pen, const QBrush &brush)
QIcon FixupTrayIcon(const QIcon &icon)
QString FormatName(const QString &name)
HTML-formats the name to let the user know it is not a part of the fixed dialog text.