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