mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Fix deprecated function call issues with Qt 5.13
Update to mtxclient 0.3.0
This commit is contained in:
parent
175737c28b
commit
c0a010acbb
18 changed files with 97 additions and 34 deletions
|
@ -270,7 +270,7 @@ find_package(Boost 1.66 REQUIRED
|
||||||
thread)
|
thread)
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
find_package(MatrixClient 0.1.0 REQUIRED)
|
find_package(MatrixClient 0.3.0 REQUIRED)
|
||||||
find_package(Olm 2 REQUIRED)
|
find_package(Olm 2 REQUIRED)
|
||||||
find_package(spdlog 1.0.0 CONFIG REQUIRED)
|
find_package(spdlog 1.0.0 CONFIG REQUIRED)
|
||||||
find_package(cmark REQUIRED)
|
find_package(cmark REQUIRED)
|
||||||
|
|
5
deps/CMakeLists.txt
vendored
5
deps/CMakeLists.txt
vendored
|
@ -46,17 +46,16 @@ set(BOOST_SHA256
|
||||||
|
|
||||||
set(
|
set(
|
||||||
MTXCLIENT_URL
|
MTXCLIENT_URL
|
||||||
https://github.com/Nheko-Reborn/mtxclient/archive/32065798a2efa205052fcd2f470c52326a46d0b9.tar.gz
|
https://github.com/Nheko-Reborn/mtxclient/archive/35b596a98d516e044a6a25803ba6b93b6c0a538b.tar.gz
|
||||||
)
|
)
|
||||||
set(MTXCLIENT_HASH
|
set(MTXCLIENT_HASH
|
||||||
3ddc6a482b5f388533bbaa69c44f1621d65a4e38fcb6cafaff83330975ea7e2b)
|
ea770f52afaad45706b8050aa3d860fa98780c60f2d3f061f2c89dfd3b3bf9be)
|
||||||
set(
|
set(
|
||||||
TWEENY_URL
|
TWEENY_URL
|
||||||
https://github.com/mobius3/tweeny/archive/b94ce07cfb02a0eb8ac8aaf66137dabdaea857cf.tar.gz
|
https://github.com/mobius3/tweeny/archive/b94ce07cfb02a0eb8ac8aaf66137dabdaea857cf.tar.gz
|
||||||
)
|
)
|
||||||
set(TWEENY_HASH
|
set(TWEENY_HASH
|
||||||
9a632b9da84823fae002ad5d9ba02c8d77c0a3810479974c6b637c5504165475)
|
9a632b9da84823fae002ad5d9ba02c8d77c0a3810479974c6b637c5504165475)
|
||||||
|
|
||||||
set(
|
set(
|
||||||
LMDBXX_HEADER_URL
|
LMDBXX_HEADER_URL
|
||||||
https://raw.githubusercontent.com/bendiken/lmdbxx/0b43ca87d8cfabba392dfe884eb1edb83874de02/lmdb%2B%2B.h
|
https://raw.githubusercontent.com/bendiken/lmdbxx/0b43ca87d8cfabba392dfe884eb1edb83874de02/lmdb%2B%2B.h
|
||||||
|
|
BIN
nheko-backtrace.dump
Normal file
BIN
nheko-backtrace.dump
Normal file
Binary file not shown.
|
@ -182,7 +182,7 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
QFont tsFont;
|
QFont tsFont;
|
||||||
tsFont.setPointSizeF(tsFont.pointSizeF() * 0.9);
|
tsFont.setPointSizeF(tsFont.pointSizeF() * 0.9);
|
||||||
const int msgStampWidth = QFontMetrics(tsFont).width(lastMsgInfo_.timestamp) + 4;
|
const int msgStampWidth = QFontMetrics(tsFont).horizontalAdvance(lastMsgInfo_.timestamp) + 4;
|
||||||
|
|
||||||
// We use the full width of the widget if there is no unread msg bubble.
|
// We use the full width of the widget if there is no unread msg bubble.
|
||||||
const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0;
|
const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0;
|
||||||
|
@ -211,7 +211,7 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
||||||
p.setFont(QFont{});
|
p.setFont(QFont{});
|
||||||
p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName);
|
p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName);
|
||||||
|
|
||||||
int nameWidth = QFontMetrics(QFont{}).width(userName);
|
int nameWidth = QFontMetrics(QFont{}).horizontalAdvance(userName);
|
||||||
|
|
||||||
p.setFont(QFont{});
|
p.setFont(QFont{});
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ TypingDisplay::paintEvent(QPaintEvent *)
|
||||||
text_ = fm.elidedText(text_, Qt::ElideRight, (double)(width() * 0.75));
|
text_ = fm.elidedText(text_, Qt::ElideRight, (double)(width() * 0.75));
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRoundedRect(QRectF(0, 0, fm.width(text_) + 2 * LEFT_PADDING, height()), 3, 3);
|
path.addRoundedRect(QRectF(0, 0, fm.horizontalAdvance(text_) + 2 * LEFT_PADDING, height()), 3, 3);
|
||||||
|
|
||||||
p.fillPath(path, backgroundColor());
|
p.fillPath(path, backgroundColor());
|
||||||
p.drawText(region, Qt::AlignVCenter, text_);
|
p.drawText(region, Qt::AlignVCenter, text_);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QScreen>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
@ -229,8 +231,10 @@ utils::scaleImageToPixmap(const QImage &img, int size)
|
||||||
if (img.isNull())
|
if (img.isNull())
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
|
|
||||||
|
// Deprecated in 5.13: const double sz =
|
||||||
|
// std::ceil(QApplication::desktop()->screen()->devicePixelRatioF() * (double)size);
|
||||||
const double sz =
|
const double sz =
|
||||||
std::ceil(QApplication::desktop()->screen()->devicePixelRatioF() * (double)size);
|
std::ceil(QGuiApplication::primaryScreen()->devicePixelRatio() * (double)size);
|
||||||
return QPixmap::fromImage(
|
return QPixmap::fromImage(
|
||||||
img.scaled(sz, sz, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
img.scaled(sz, sz, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
|
@ -318,16 +322,44 @@ QString
|
||||||
utils::getFormattedQuoteBody(const RelatedInfo &related, const QString &html)
|
utils::getFormattedQuoteBody(const RelatedInfo &related, const QString &html)
|
||||||
{
|
{
|
||||||
return QString("<mx-reply><blockquote><a "
|
return QString("<mx-reply><blockquote><a "
|
||||||
"href=\"https://matrix.to/#/!%1\">In reply "
|
"href=\"https://matrix.to/#/%1/%2\">In reply "
|
||||||
"to</a><a href=\"https://matrix.to/#/%2\">%3</a><br "
|
"to</a>* <a href=\"https://matrix.to/#/%3\">%4</a><br "
|
||||||
"/>%4</blockquote></mx-reply>")
|
"/>%5</blockquote></mx-reply>")
|
||||||
.arg(QString::fromStdString(related.related_event),
|
.arg(related.room,
|
||||||
|
QString::fromStdString(related.related_event),
|
||||||
related.quoted_user,
|
related.quoted_user,
|
||||||
related.quoted_user,
|
related.quoted_user,
|
||||||
related.quoted_body) +
|
getQuoteBody(related)) +
|
||||||
html;
|
html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
utils::getQuoteBody(const RelatedInfo &related)
|
||||||
|
{
|
||||||
|
using MsgType = mtx::events::MessageType;
|
||||||
|
|
||||||
|
switch (related.type) {
|
||||||
|
case MsgType::Text: {
|
||||||
|
return markdownToHtml(related.quoted_body);
|
||||||
|
}
|
||||||
|
case MsgType::File: {
|
||||||
|
return QString("sent a file.");
|
||||||
|
}
|
||||||
|
case MsgType::Image: {
|
||||||
|
return QString("sent an image.");
|
||||||
|
}
|
||||||
|
case MsgType::Audio: {
|
||||||
|
return QString("sent an audio file.");
|
||||||
|
}
|
||||||
|
case MsgType::Video: {
|
||||||
|
return QString("sent a video");
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return related.quoted_body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
utils::linkColor()
|
utils::linkColor()
|
||||||
{
|
{
|
||||||
|
@ -475,7 +507,8 @@ utils::centerWidget(QWidget *widget, QWidget *parent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->move(findCenter(QApplication::desktop()->screenGeometry()));
|
// Deprecated in 5.13: widget->move(findCenter(QApplication::desktop()->screenGeometry()));
|
||||||
|
widget->move(findCenter(QGuiApplication::primaryScreen()->geometry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -22,6 +22,9 @@ class QComboBox;
|
||||||
// outgoing messages
|
// outgoing messages
|
||||||
struct RelatedInfo
|
struct RelatedInfo
|
||||||
{
|
{
|
||||||
|
using MsgType = mtx::events::MessageType;
|
||||||
|
MsgType type;
|
||||||
|
QString room;
|
||||||
QString quoted_body;
|
QString quoted_body;
|
||||||
std::string related_event;
|
std::string related_event;
|
||||||
QString quoted_user;
|
QString quoted_user;
|
||||||
|
@ -238,6 +241,10 @@ markdownToHtml(const QString &text);
|
||||||
QString
|
QString
|
||||||
getFormattedQuoteBody(const RelatedInfo &related, const QString &html);
|
getFormattedQuoteBody(const RelatedInfo &related, const QString &html);
|
||||||
|
|
||||||
|
//! Get the body for the quote, depending on the event type.
|
||||||
|
QString
|
||||||
|
getQuoteBody(const RelatedInfo &related);
|
||||||
|
|
||||||
//! Retrieve the color of the links based on the current theme.
|
//! Retrieve the color of the links based on the current theme.
|
||||||
QString
|
QString
|
||||||
linkColor();
|
linkColor();
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
#include "dialogs/ImageOverlay.h"
|
#include "dialogs/ImageOverlay.h"
|
||||||
|
|
||||||
|
@ -39,7 +41,8 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent)
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
setWindowState(Qt::WindowFullScreen);
|
setWindowState(Qt::WindowFullScreen);
|
||||||
|
|
||||||
screen_ = QApplication::desktop()->availableGeometry();
|
// Deprecated in 5.13: screen_ = QApplication::desktop()->availableGeometry();
|
||||||
|
screen_ = QGuiApplication::primaryScreen()->availableGeometry();
|
||||||
|
|
||||||
move(QApplication::desktop()->mapToGlobal(screen_.topLeft()));
|
move(QApplication::desktop()->mapToGlobal(screen_.topLeft()));
|
||||||
resize(screen_.size());
|
resize(screen_.size());
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
#include <QScreen>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
@ -72,7 +74,8 @@ registerSignalHandlers()
|
||||||
QPoint
|
QPoint
|
||||||
screenCenter(int width, int height)
|
screenCenter(int width, int height)
|
||||||
{
|
{
|
||||||
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
// Deprecated in 5.13: QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
||||||
|
QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
|
||||||
int x = (screenGeometry.width() - width) / 2;
|
int x = (screenGeometry.width() - width) / 2;
|
||||||
int y = (screenGeometry.height() - height) / 2;
|
int y = (screenGeometry.height() - height) / 2;
|
||||||
|
|
|
@ -142,7 +142,7 @@ operator<<(QDBusArgument &arg, const QImage &image)
|
||||||
int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3);
|
int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3);
|
||||||
arg << i.depth() / channels;
|
arg << i.depth() / channels;
|
||||||
arg << channels;
|
arg << channels;
|
||||||
arg << QByteArray(reinterpret_cast<const char *>(i.bits()), i.byteCount());
|
arg << QByteArray(reinterpret_cast<const char *>(i.bits()), i.sizeInBytes());
|
||||||
arg.endStructure();
|
arg.endStructure();
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,7 +731,9 @@ TimelineItem::generateUserName(const QString &user_id, const QString &displaynam
|
||||||
userName_->setToolTipDuration(1500);
|
userName_->setToolTipDuration(1500);
|
||||||
userName_->setAttribute(Qt::WA_Hover);
|
userName_->setAttribute(Qt::WA_Hover);
|
||||||
userName_->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
userName_->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
userName_->setFixedWidth(QFontMetrics(userName_->font()).width(userName_->text()));
|
// width deprecated in 5.13:
|
||||||
|
// userName_->setFixedWidth(QFontMetrics(userName_->font()).width(userName_->text()));
|
||||||
|
userName_->setFixedWidth(QFontMetrics(userName_->font()).horizontalAdvance(userName_->text()));
|
||||||
|
|
||||||
// Set the user color asynchronously if it hasn't been generated yet,
|
// Set the user color asynchronously if it hasn't been generated yet,
|
||||||
// otherwise this will just set it.
|
// otherwise this will just set it.
|
||||||
|
@ -877,9 +879,11 @@ TimelineItem::replyAction()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RelatedInfo related;
|
RelatedInfo related;
|
||||||
|
related.type = message_type_;
|
||||||
related.quoted_body = body_->toPlainText();
|
related.quoted_body = body_->toPlainText();
|
||||||
related.quoted_user = descriptionMsg_.userid;
|
related.quoted_user = descriptionMsg_.userid;
|
||||||
related.related_event = eventId().toStdString();
|
related.related_event = eventId().toStdString();
|
||||||
|
related.room = room_id_;
|
||||||
|
|
||||||
emit ChatPage::instance()->messageReply(related);
|
emit ChatPage::instance()->messageReply(related);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
|
#include "mtx/events.hpp"
|
||||||
|
|
||||||
#include "AvatarProvider.h"
|
#include "AvatarProvider.h"
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
@ -276,6 +278,7 @@ private:
|
||||||
|
|
||||||
QString replaceEmoji(const QString &body);
|
QString replaceEmoji(const QString &body);
|
||||||
QString event_id_;
|
QString event_id_;
|
||||||
|
mtx::events::MessageType message_type_;
|
||||||
QString room_id_;
|
QString room_id_;
|
||||||
|
|
||||||
DescInfo descriptionMsg_;
|
DescInfo descriptionMsg_;
|
||||||
|
@ -349,6 +352,11 @@ TimelineItem::setupWidgetLayout(Widget *widget, const Event &event, bool withSen
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
//if (event.type == mtx::events::EventType::RoomMessage) {
|
||||||
|
// message_type_ = mtx::events::getMessageType(event.content.msgtype);
|
||||||
|
//}
|
||||||
|
// TODO: Fix this.
|
||||||
|
message_type_ = mtx::events::MessageType::Unknown;
|
||||||
event_id_ = QString::fromStdString(event.event_id);
|
event_id_ = QString::fromStdString(event.event_id);
|
||||||
const auto sender = QString::fromStdString(event.sender);
|
const auto sender = QString::fromStdString(event.sender);
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ AudioItem::resizeEvent(QResizeEvent *event)
|
||||||
|
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
const int computedWidth = std::min(
|
const int computedWidth = std::min(
|
||||||
fm.width(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth);
|
fm.horizontalAdvance(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth);
|
||||||
|
|
||||||
resize(computedWidth, Height);
|
resize(computedWidth, Height);
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ FileItem::resizeEvent(QResizeEvent *event)
|
||||||
|
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
const int computedWidth = std::min(
|
const int computedWidth = std::min(
|
||||||
fm.width(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth);
|
fm.horizontalAdvance(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth);
|
||||||
|
|
||||||
resize(computedWidth, Height);
|
resize(computedWidth, Height);
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ ImageItem::paintEvent(QPaintEvent *event)
|
||||||
if (image_.isNull()) {
|
if (image_.isNull()) {
|
||||||
QString elidedText = metrics.elidedText(text_, Qt::ElideRight, max_width_ - 10);
|
QString elidedText = metrics.elidedText(text_, Qt::ElideRight, max_width_ - 10);
|
||||||
|
|
||||||
setFixedSize(metrics.width(elidedText), fontHeight);
|
setFixedSize(metrics.horizontalAdvance(elidedText), fontHeight);
|
||||||
|
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
painter.setPen(QPen(QColor(66, 133, 244)));
|
painter.setPen(QPen(QColor(66, 133, 244)));
|
||||||
|
|
|
@ -30,7 +30,11 @@ public:
|
||||||
gradient.setStart(right0);
|
gradient.setStart(right0);
|
||||||
gradient.setFinalStop(right1);
|
gradient.setFinalStop(right1);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(
|
// Deprecated in 5.13: painter.drawRoundRect(
|
||||||
|
// QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
|
||||||
|
// 0.0,
|
||||||
|
// 0.0);
|
||||||
|
painter.drawRoundedRect(
|
||||||
QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
|
QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
|
||||||
0.0,
|
0.0,
|
||||||
0.0);
|
0.0);
|
||||||
|
@ -41,7 +45,7 @@ public:
|
||||||
gradient.setStart(left0);
|
gradient.setStart(left0);
|
||||||
gradient.setFinalStop(left1);
|
gradient.setFinalStop(left1);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(
|
painter.drawRoundedRect(
|
||||||
QRectF(QPointF(margin * radius, margin), QPointF(0, height - margin)), 0.0, 0.0);
|
QRectF(QPointF(margin * radius, margin), QPointF(0, height - margin)), 0.0, 0.0);
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
|
@ -50,7 +54,7 @@ public:
|
||||||
gradient.setStart(top0);
|
gradient.setStart(top0);
|
||||||
gradient.setFinalStop(top1);
|
gradient.setFinalStop(top1);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(
|
painter.drawRoundedRect(
|
||||||
QRectF(QPointF(width - margin, 0), QPointF(margin, margin)), 0.0, 0.0);
|
QRectF(QPointF(width - margin, 0), QPointF(margin, margin)), 0.0, 0.0);
|
||||||
|
|
||||||
// Bottom
|
// Bottom
|
||||||
|
@ -59,7 +63,7 @@ public:
|
||||||
gradient.setStart(bottom0);
|
gradient.setStart(bottom0);
|
||||||
gradient.setFinalStop(bottom1);
|
gradient.setFinalStop(bottom1);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(
|
painter.drawRoundedRect(
|
||||||
QRectF(QPointF(margin, height - margin), QPointF(width - margin, height)),
|
QRectF(QPointF(margin, height - margin), QPointF(width - margin, height)),
|
||||||
0.0,
|
0.0,
|
||||||
0.0);
|
0.0);
|
||||||
|
@ -71,7 +75,7 @@ public:
|
||||||
gradient.setFinalStop(bottomright1);
|
gradient.setFinalStop(bottomright1);
|
||||||
gradient.setColorAt(endPosition1, end);
|
gradient.setColorAt(endPosition1, end);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(QRectF(bottomright0, bottomright1), 0.0, 0.0);
|
painter.drawRoundedRect(QRectF(bottomright0, bottomright1), 0.0, 0.0);
|
||||||
|
|
||||||
// BottomLeft
|
// BottomLeft
|
||||||
QPointF bottomleft0(margin, height - margin);
|
QPointF bottomleft0(margin, height - margin);
|
||||||
|
@ -80,7 +84,7 @@ public:
|
||||||
gradient.setFinalStop(bottomleft1);
|
gradient.setFinalStop(bottomleft1);
|
||||||
gradient.setColorAt(endPosition1, end);
|
gradient.setColorAt(endPosition1, end);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0);
|
painter.drawRoundedRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0);
|
||||||
|
|
||||||
// TopLeft
|
// TopLeft
|
||||||
QPointF topleft0(margin, margin);
|
QPointF topleft0(margin, margin);
|
||||||
|
@ -89,7 +93,7 @@ public:
|
||||||
gradient.setFinalStop(topleft1);
|
gradient.setFinalStop(topleft1);
|
||||||
gradient.setColorAt(endPosition1, end);
|
gradient.setColorAt(endPosition1, end);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(QRectF(topleft0, topleft1), 0.0, 0.0);
|
painter.drawRoundedRect(QRectF(topleft0, topleft1), 0.0, 0.0);
|
||||||
|
|
||||||
// TopRight
|
// TopRight
|
||||||
QPointF topright0(width - margin, margin);
|
QPointF topright0(width - margin, margin);
|
||||||
|
@ -98,12 +102,12 @@ public:
|
||||||
gradient.setFinalStop(topright1);
|
gradient.setFinalStop(topright1);
|
||||||
gradient.setColorAt(endPosition1, end);
|
gradient.setColorAt(endPosition1, end);
|
||||||
painter.setBrush(QBrush(gradient));
|
painter.setBrush(QBrush(gradient));
|
||||||
painter.drawRoundRect(QRectF(topright0, topright1), 0.0, 0.0);
|
painter.drawRoundedRect(QRectF(topright0, topright1), 0.0, 0.0);
|
||||||
|
|
||||||
// Widget
|
// Widget
|
||||||
painter.setBrush(QBrush("#FFFFFF"));
|
painter.setBrush(QBrush("#FFFFFF"));
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.drawRoundRect(
|
painter.drawRoundedRect(
|
||||||
QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)),
|
QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)),
|
||||||
radius,
|
radius,
|
||||||
radius);
|
radius);
|
||||||
|
|
|
@ -22,7 +22,7 @@ InfoMessage::InfoMessage(QString msg, QWidget *parent)
|
||||||
initFont();
|
initFont();
|
||||||
|
|
||||||
QFontMetrics fm{font()};
|
QFontMetrics fm{font()};
|
||||||
width_ = fm.width(msg_) + HPadding * 2;
|
width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
|
||||||
height_ = fm.ascent() + 2 * VPadding;
|
height_ = fm.ascent() + 2 * VPadding;
|
||||||
|
|
||||||
setFixedHeight(height_ + 2 * HMargin);
|
setFixedHeight(height_ + 2 * HMargin);
|
||||||
|
@ -64,7 +64,7 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
|
||||||
msg_ = datetime.toString(fmt);
|
msg_ = datetime.toString(fmt);
|
||||||
|
|
||||||
QFontMetrics fm{font()};
|
QFontMetrics fm{font()};
|
||||||
width_ = fm.width(msg_) + HPadding * 2;
|
width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
|
||||||
height_ = fm.ascent() + 2 * VPadding;
|
height_ = fm.ascent() + 2 * VPadding;
|
||||||
|
|
||||||
setFixedHeight(height_ + 2 * HMargin);
|
setFixedHeight(height_ + 2 * HMargin);
|
||||||
|
|
|
@ -20,8 +20,10 @@ public:
|
||||||
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 (textWidth < 0)
|
if (textWidth < 0) {
|
||||||
textWidth = m.width(text);
|
// deprecated in 5.13: textWidth = m.width(text);
|
||||||
|
textWidth = m.horizontalAdvance(text);
|
||||||
|
}
|
||||||
drawText((outerw - x - textWidth), y + m.ascent(), text);
|
drawText((outerw - x - textWidth), y + m.ascent(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue