Fix deprecation warnings on Qt 5.15.1.
This commit is contained in:
parent
9c9a4bc4d8
commit
d4c99701b5
15 changed files with 42 additions and 32 deletions
|
|
@ -19,7 +19,7 @@ NumbersAnimation::NumbersAnimation(
|
|||
: _font(font)
|
||||
, _animationCallback(std::move(animationCallback)) {
|
||||
for (auto ch = '0'; ch != '9'; ++ch) {
|
||||
accumulate_max(_digitWidth, _font->m.width(ch));
|
||||
accumulate_max(_digitWidth, _font->m.horizontalAdvance(ch));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ void NumbersAnimation::realSetText(QString text, int value) {
|
|||
digit.from = digit.to;
|
||||
digit.fromWidth = digit.toWidth;
|
||||
digit.to = (newSize + i < size) ? QChar(0) : text[newSize + i - size];
|
||||
digit.toWidth = digit.to.unicode() ? _font->m.width(digit.to) : 0;
|
||||
digit.toWidth = digit.to.unicode() ? _font->m.horizontalAdvance(digit.to) : 0;
|
||||
if (digit.from != digit.to) {
|
||||
animating = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ void BoxContent::paintEvent(QPaintEvent *e) {
|
|||
Painter p(this);
|
||||
|
||||
if (testAttribute(Qt::WA_OpaquePaintEvent)) {
|
||||
for (auto rect : e->region().rects()) {
|
||||
for (const auto rect : e->region()) {
|
||||
p.fillRect(rect, st::boxBg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ void BoxLayerWidget::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius));
|
||||
if (!other.isEmpty()) {
|
||||
for (auto rect : other.rects()) {
|
||||
for (const auto rect : other) {
|
||||
p.fillRect(rect, st::boxBg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,8 +280,8 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) {
|
|||
// (alpha_final - alpha_current) / (1 - alpha_current) so we won't get glitches
|
||||
// in the transparent special layer cache corners after filling special layer
|
||||
// rect above its cache with alpha_current opacity.
|
||||
auto region = QRegion(bg) - specialLayerBox;
|
||||
for (auto rect : region.rects()) {
|
||||
const auto region = QRegion(bg) - specialLayerBox;
|
||||
for (const auto rect : region) {
|
||||
p.fillRect(rect, st::layerBg);
|
||||
}
|
||||
p.setOpacity((bgOpacity - overSpecialOpacity) / (1. - (overSpecialOpacity * st::layerBg->c.alphaF())));
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ public:
|
|||
|
||||
void drawTextLeft(int x, int y, int outerw, const QString &text, int textWidth = -1) {
|
||||
QFontMetrics m(fontMetrics());
|
||||
if (style::RightToLeft() && textWidth < 0) textWidth = m.width(text);
|
||||
if (style::RightToLeft() && textWidth < 0) textWidth = m.horizontalAdvance(text);
|
||||
drawText(style::RightToLeft() ? (outerw - x - textWidth) : x, y + m.ascent(), text);
|
||||
}
|
||||
void drawTextRight(int x, int y, int outerw, const QString &text, int textWidth = -1) {
|
||||
QFontMetrics m(fontMetrics());
|
||||
if (!style::RightToLeft() && textWidth < 0) textWidth = m.width(text);
|
||||
if (!style::RightToLeft() && textWidth < 0) textWidth = m.horizontalAdvance(text);
|
||||
drawText(style::RightToLeft() ? x : (outerw - x - textWidth), y + m.ascent(), text);
|
||||
}
|
||||
void drawPixmapLeft(int x, int y, int outerw, const QPixmap &pix, const QRect &from) {
|
||||
|
|
@ -84,8 +84,7 @@ public:
|
|||
static constexpr QPainter::RenderHint Hints[] = {
|
||||
QPainter::Antialiasing,
|
||||
QPainter::SmoothPixmapTransform,
|
||||
QPainter::TextAntialiasing,
|
||||
QPainter::HighQualityAntialiasing
|
||||
QPainter::TextAntialiasing
|
||||
};
|
||||
|
||||
const auto hints = _painter.renderHints();
|
||||
|
|
@ -112,6 +111,6 @@ public:
|
|||
|
||||
private:
|
||||
QPainter &_painter;
|
||||
QPainter::RenderHints _hints = 0;
|
||||
QPainter::RenderHints _hints;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@
|
|||
//
|
||||
#include "ui/platform/linux/ui_utility_linux.h"
|
||||
|
||||
#include "base/flat_set.h"
|
||||
#include "ui/ui_log.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "base/flat_set.h"
|
||||
|
||||
#include <QtCore/QPoint>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
namespace Ui {
|
||||
|
|
@ -28,19 +29,18 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
|
|||
}
|
||||
if (const auto native = QGuiApplication::platformNativeInterface()) {
|
||||
if (const auto desktop = QApplication::desktop()) {
|
||||
const auto index = desktop->screenNumber(globalPosition);
|
||||
const auto screens = QGuiApplication::screens();
|
||||
if (const auto screen = (index >= 0 && index < screens.size()) ? screens[index] : QGuiApplication::primaryScreen()) {
|
||||
if (const auto screen = base::QScreenNearestTo(globalPosition)) {
|
||||
if (native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen)) {
|
||||
return true;
|
||||
}
|
||||
const auto index = QGuiApplication::screens().indexOf(screen);
|
||||
static auto WarnedAbout = base::flat_set<int>();
|
||||
if (!WarnedAbout.contains(index)) {
|
||||
WarnedAbout.emplace(index);
|
||||
UI_LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
|
||||
}
|
||||
} else {
|
||||
UI_LOG(("WARNING: Could not get screen for index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
|
||||
UI_LOG(("WARNING: Could not get screen for position %1,%2").arg(globalPosition.x()).arg(globalPosition.y()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class QPaintEvent;
|
|||
namespace Ui {
|
||||
namespace Platform {
|
||||
|
||||
inline void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||
inline void StartTranslucentPaint(QPainter &p, const QRegion ®ion) {
|
||||
}
|
||||
|
||||
inline void InitOnTopPanel(not_null<QWidget*> panel) {
|
||||
|
|
|
|||
|
|
@ -68,10 +68,10 @@ void ReInitOnTopPanel(not_null<QWidget*> panel) {
|
|||
[platformPanel setCollectionBehavior:newBehavior];
|
||||
}
|
||||
|
||||
void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||
void StartTranslucentPaint(QPainter &p, const QRegion ®ion) {
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
for (const auto &r : rects) {
|
||||
p.fillRect(r, Qt::transparent);
|
||||
for (const auto rect : region) {
|
||||
p.fillRect(rect, Qt::transparent);
|
||||
}
|
||||
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Platform {
|
|||
[[nodiscard]] bool IsApplicationActive();
|
||||
|
||||
[[nodiscard]] bool TranslucentWindowsSupported(QPoint globalPosition);
|
||||
void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects);
|
||||
void StartTranslucentPaint(QPainter &p, const QRegion ®ion);
|
||||
|
||||
void InitOnTopPanel(not_null<QWidget*> panel);
|
||||
void DeInitOnTopPanel(not_null<QWidget*> panel);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ inline void DeInitOnTopPanel(not_null<QWidget*> panel) {
|
|||
inline void ReInitOnTopPanel(not_null<QWidget*> panel) {
|
||||
}
|
||||
|
||||
inline void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||
inline void StartTranslucentPaint(QPainter &p, const QRegion ®ion) {
|
||||
}
|
||||
|
||||
inline void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ QString MonospaceFont() {
|
|||
// Prefer system monospace font.
|
||||
const auto metrics = QFontMetrics(QFont(system));
|
||||
const auto useSystem = manual.isEmpty()
|
||||
|| (metrics.charWidth("i", 0) == metrics.charWidth("W", 0));
|
||||
|| (metrics.horizontalAdvance(QChar('i')) == metrics.horizontalAdvance(QChar('W')));
|
||||
#endif // Q_OS_WIN || Q_OS_MAC
|
||||
return useSystem ? system : manual;
|
||||
}();
|
||||
|
|
|
|||
|
|
@ -69,13 +69,13 @@ enum FontFlags {
|
|||
class FontData {
|
||||
public:
|
||||
int width(const QString &str) const {
|
||||
return m.width(str);
|
||||
return m.horizontalAdvance(str);
|
||||
}
|
||||
int width(const QString &str, int32 from, int32 to) const {
|
||||
return width(str.mid(from, to));
|
||||
}
|
||||
int width(QChar ch) const {
|
||||
return m.width(ch);
|
||||
return m.horizontalAdvance(ch);
|
||||
}
|
||||
QString elided(
|
||||
const QString &str,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "base/qthelp_url.h"
|
||||
#include "base/qthelp_regex.h"
|
||||
#include "base/crc32hash.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "ui/text/text.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/emoji_config.h"
|
||||
|
|
@ -1403,7 +1404,7 @@ QStringList PrepareSearchWords(
|
|||
auto list = clean.split(SplitterOverride
|
||||
? *SplitterOverride
|
||||
: RegExpWordSplit(),
|
||||
QString::SkipEmptyParts);
|
||||
base::QStringSkipEmptyParts);
|
||||
auto size = list.size();
|
||||
result.reserve(list.size());
|
||||
for (const auto &word : std::as_const(list)) {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,12 @@
|
|||
#include "ui/ui_utility.h"
|
||||
#include "ui/delayed_activation.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
||||
#include <QtGui/QtEvents>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
|
||||
namespace Ui {
|
||||
|
||||
|
|
@ -448,7 +449,9 @@ void PopupMenu::popup(const QPoint &p) {
|
|||
}
|
||||
|
||||
void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource source) {
|
||||
if (!parent && ::Platform::IsMac() && !Platform::IsApplicationActive()) {
|
||||
const auto screen = base::QScreenNearestTo(p);
|
||||
if (!screen
|
||||
|| (!parent && ::Platform::IsMac() && !Platform::IsApplicationActive())) {
|
||||
_hiding = false;
|
||||
_a_opacity.stop();
|
||||
_a_show.stop();
|
||||
|
|
@ -476,7 +479,7 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
|||
&& (*_forcedOrigin == Origin::BottomLeft
|
||||
|| *_forcedOrigin == Origin::BottomRight);
|
||||
auto w = p - QPoint(0, _padding.top());
|
||||
auto r = QApplication::desktop()->screenGeometry(p);
|
||||
auto r = screen->availableGeometry();
|
||||
_useTransparency = Platform::TranslucentWindowsSupported(p);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
||||
handleCompositingUpdate();
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@
|
|||
#include "ui/ui_utility.h"
|
||||
#include "ui/platform/ui_platform_utility.h"
|
||||
#include "base/invoke_queued.h"
|
||||
#include "base/qt_adapters.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
|
||||
namespace Ui {
|
||||
|
||||
|
|
@ -72,6 +73,12 @@ Tooltip::~Tooltip() {
|
|||
}
|
||||
|
||||
void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *st) {
|
||||
const auto screen = base::QScreenNearestTo(m);
|
||||
if (!screen) {
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isEventFilter) {
|
||||
_isEventFilter = true;
|
||||
QCoreApplication::instance()->installEventFilter(this);
|
||||
|
|
@ -108,7 +115,7 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *
|
|||
}
|
||||
|
||||
// adjust tooltip position
|
||||
QRect r(QApplication::desktop()->screenGeometry(m));
|
||||
const auto r = screen->availableGeometry();
|
||||
if (r.x() + r.width() - _st->skip < p.x() + s.width() && p.x() + s.width() > m.x()) {
|
||||
p.setX(qMax(r.x() + r.width() - int32(_st->skip) - s.width(), m.x() - s.width()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue