Changeset View
Changeset View
Standalone View
Standalone View
geometrytip.cpp
Show All 34 Lines | 28 | { | |||
---|---|---|---|---|---|
35 | setWindowFlags(Qt::X11BypassWindowManagerHint); | 35 | setWindowFlags(Qt::X11BypassWindowManagerHint); | ||
36 | sizeHints = xSizeHints; | 36 | sizeHints = xSizeHints; | ||
37 | } | 37 | } | ||
38 | 38 | | |||
39 | GeometryTip::~GeometryTip() | 39 | GeometryTip::~GeometryTip() | ||
40 | { | 40 | { | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | static QString numberWithSign(int n) | ||||
apol: call it `numberWithSign`. | |||||
44 | { | ||||
45 | const QLocale locale; | ||||
46 | const QChar sign = n >= 0 ? locale.positiveSign() : locale.negativeSign(); | ||||
47 | return sign + QString::number(std::abs(n)); | ||||
48 | } | ||||
49 | | ||||
43 | void GeometryTip::setGeometry(const QRect& geom) | 50 | void GeometryTip::setGeometry(const QRect& geom) | ||
44 | { | 51 | { | ||
45 | int w = geom.width(); | 52 | int w = geom.width(); | ||
46 | int h = geom.height(); | 53 | int h = geom.height(); | ||
47 | 54 | | |||
48 | if (sizeHints) { | 55 | if (sizeHints) { | ||
49 | if (sizeHints->hasResizeIncrements()) { | 56 | if (sizeHints->hasResizeIncrements()) { | ||
50 | w = (w - sizeHints->baseSize().width()) / sizeHints->resizeIncrements().width(); | 57 | w = (w - sizeHints->baseSize().width()) / sizeHints->resizeIncrements().width(); | ||
51 | h = (h - sizeHints->baseSize().height()) / sizeHints->resizeIncrements().height(); | 58 | h = (h - sizeHints->baseSize().height()) / sizeHints->resizeIncrements().height(); | ||
52 | } | 59 | } | ||
53 | } | 60 | } | ||
54 | 61 | | |||
55 | h = qMax(h, 0); // in case of isShade() and PBaseSize | 62 | h = qMax(h, 0); // in case of isShade() and PBaseSize | ||
56 | QString pos; | 63 | const QString pos = QStringLiteral("%1,%2<br>(<b>%3 x %4</b>)") | ||
57 | pos.sprintf("%+d,%+d<br>(<b>%d x %d</b>)", | 64 | .arg(numberWithSign(geom.x())) | ||
58 | geom.x(), geom.y(), w, h); | 65 | .arg(numberWithSign(geom.y())) | ||
66 | .arg(w) | ||||
67 | .arg(h); | ||||
59 | setText(pos); | 68 | setText(pos); | ||
60 | adjustSize(); | 69 | adjustSize(); | ||
61 | move(geom.x() + ((geom.width() - width()) / 2), | 70 | move(geom.x() + ((geom.width() - width()) / 2), | ||
62 | geom.y() + ((geom.height() - height()) / 2)); | 71 | geom.y() + ((geom.height() - height()) / 2)); | ||
63 | } | 72 | } | ||
64 | 73 | | |||
65 | } // namespace | 74 | } // namespace | ||
66 | 75 | |
call it numberWithSign.