Some qt6 prep

pull/867/head
Nicolas Werner 3 years ago
parent 2866826356
commit 5ca98829f7
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 2
      .gitignore
  2. 8
      src/BlurhashProvider.h
  3. 2
      src/Cache.cpp
  4. 5
      src/ChatPage.cpp
  5. 4
      src/CompletionProxyModel.cpp
  6. 14
      src/JdenticonProvider.h
  7. 3
      src/LoginPage.cpp
  8. 4
      src/MatrixClient.cpp
  9. 10
      src/MxcImageProvider.cpp
  10. 11
      src/MxcImageProvider.h
  11. 4
      src/RegisterPage.cpp
  12. 5
      src/TrayIcon.cpp
  13. 6
      src/TrayIcon.h
  14. 3
      src/UserSettingsPage.cpp
  15. 6
      src/Utils.cpp
  16. 2
      src/WelcomePage.cpp
  17. 5
      src/dialogs/CreateRoom.cpp
  18. 6
      src/dialogs/FallbackAuth.cpp
  19. 1
      src/dialogs/ImageOverlay.cpp
  20. 6
      src/dialogs/Logout.cpp
  21. 8
      src/dialogs/PreviewUploadOverlay.cpp
  22. 6
      src/dialogs/ReCaptcha.cpp
  23. 1
      src/main.cpp
  24. 8
      src/timeline/InputBar.cpp
  25. 2
      src/timeline/InputBar.h
  26. 12
      src/timeline/TimelineModel.cpp
  27. 1
      src/ui/FloatingButton.cpp
  28. 2
      src/ui/MxcAnimatedImage.h
  29. 2
      src/ui/OverlayWidget.cpp
  30. 2
      src/ui/SnackBar.cpp
  31. 2
      src/ui/UserProfile.h
  32. 2
      src/voip/CallManager.h

2
.gitignore vendored

@ -26,6 +26,8 @@ GPATH
*.dylib *.dylib
vgcore.* vgcore.*
heaptrack.*
massif.*
# Qt-es # Qt-es

@ -64,8 +64,12 @@ public:
}; };
class BlurhashProvider class BlurhashProvider
: public QObject :
, public QQuickAsyncImageProvider #if QT_VERSION < 0x60000
public QObject
,
#endif
public QQuickAsyncImageProvider
{ {
Q_OBJECT Q_OBJECT
public slots: public slots:

@ -3835,7 +3835,7 @@ Cache::displayName(const QString &room_id, const QString &user_id)
static bool static bool
isDisplaynameSafe(const std::string &s) isDisplaynameSafe(const std::string &s)
{ {
for (QChar c : QString::fromStdString(s).toUcs4()) { for (QChar c : QString::fromStdString(s)) {
if (c.isPrint() && !c.isSpace()) if (c.isPrint() && !c.isSpace())
return false; return false;
} }

@ -62,7 +62,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
topLayout_ = new QHBoxLayout(this); topLayout_ = new QHBoxLayout(this);
topLayout_->setSpacing(0); topLayout_->setSpacing(0);
topLayout_->setMargin(0);
view_manager_ = new TimelineViewManager(callManager_, this); view_manager_ = new TimelineViewManager(callManager_, this);
@ -1303,7 +1302,7 @@ ChatPage::handleMatrixUri(QString uri)
auto tempPath = uri_.path(QUrl::ComponentFormattingOption::FullyEncoded); auto tempPath = uri_.path(QUrl::ComponentFormattingOption::FullyEncoded);
if (tempPath.startsWith('/')) if (tempPath.startsWith('/'))
tempPath.remove(0, 1); tempPath.remove(0, 1);
auto segments = tempPath.splitRef('/'); auto segments = QStringView(tempPath).split('/');
if (segments.size() != 2 && segments.size() != 4) if (segments.size() != 2 && segments.size() != 4)
return false; return false;
@ -1314,7 +1313,7 @@ ChatPage::handleMatrixUri(QString uri)
return false; return false;
QString mxid2; QString mxid2;
if (segments.size() == 4 && segments[2] == "e") { if (segments.size() == 4 && segments[2] == QStringView(u"e")) {
if (segments[3].isEmpty()) if (segments[3].isEmpty())
return false; return false;
else else

@ -48,7 +48,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
.toString() .toString()
.toLower(); .toLower();
for (const auto &e : string1.splitRef(splitPoints)) { for (const auto &e : QStringView(string1).split(splitPoints)) {
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14 if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
trie_.insert(e.toUcs4(), i); trie_.insert(e.toUcs4(), i);
} }
@ -59,7 +59,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
.toLower(); .toLower();
if (!string2.isEmpty()) { if (!string2.isEmpty()) {
for (const auto &e : string2.splitRef(splitPoints)) { for (const auto &e : QStringView(string2).split(splitPoints)) {
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14 if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
trie_.insert(e.toUcs4(), i); trie_.insert(e.toUcs4(), i);
} }

@ -53,8 +53,12 @@ public:
}; };
class JdenticonProvider class JdenticonProvider
: public QObject :
, public QQuickAsyncImageProvider #if QT_VERSION < 0x60000
public QObject
,
#endif
public QQuickAsyncImageProvider
{ {
Q_OBJECT Q_OBJECT
@ -72,11 +76,11 @@ public slots:
auto queryStart = id.lastIndexOf('?'); auto queryStart = id.lastIndexOf('?');
if (queryStart != -1) { if (queryStart != -1) {
id_ = id.left(queryStart); id_ = id.left(queryStart);
auto query = id.midRef(queryStart + 1); auto query = id.mid(queryStart + 1);
auto queryBits = query.split('&'); auto queryBits = query.splitRef('&');
for (auto b : queryBits) { for (auto b : queryBits) {
if (b.startsWith("radius=")) { if (b.startsWith(QStringView(u"radius="))) {
radius = b.mid(7).toDouble(); radius = b.mid(7).toDouble();
} }
} }

@ -40,7 +40,6 @@ LoginPage::LoginPage(QWidget *parent)
top_bar_layout_ = new QHBoxLayout(); top_bar_layout_ = new QHBoxLayout();
top_bar_layout_->setSpacing(0); top_bar_layout_->setSpacing(0);
top_bar_layout_->setMargin(0);
back_button_ = new FlatButton(this); back_button_ = new FlatButton(this);
back_button_->setMinimumSize(QSize(30, 30)); back_button_->setMinimumSize(QSize(30, 30));
@ -497,7 +496,7 @@ void
LoginPage::paintEvent(QPaintEvent *) LoginPage::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.initFrom(this);
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }

@ -22,7 +22,7 @@ Q_DECLARE_METATYPE(mtx::responses::Sync)
Q_DECLARE_METATYPE(mtx::responses::JoinedGroups) Q_DECLARE_METATYPE(mtx::responses::JoinedGroups)
Q_DECLARE_METATYPE(mtx::responses::GroupProfile) Q_DECLARE_METATYPE(mtx::responses::GroupProfile)
Q_DECLARE_METATYPE(nlohmann::json) // Q_DECLARE_METATYPE(nlohmann::json)
Q_DECLARE_METATYPE(std::string) Q_DECLARE_METATYPE(std::string)
Q_DECLARE_METATYPE(std::vector<std::string>) Q_DECLARE_METATYPE(std::vector<std::string>)
Q_DECLARE_METATYPE(std::vector<QString>) Q_DECLARE_METATYPE(std::vector<QString>)
@ -54,7 +54,7 @@ init()
qRegisterMetaType<mtx::responses::JoinedGroups>(); qRegisterMetaType<mtx::responses::JoinedGroups>();
qRegisterMetaType<mtx::responses::GroupProfile>(); qRegisterMetaType<mtx::responses::GroupProfile>();
qRegisterMetaType<std::string>(); qRegisterMetaType<std::string>();
qRegisterMetaType<nlohmann::json>(); // qRegisterMetaType<nlohmann::json>();
qRegisterMetaType<std::vector<std::string>>(); qRegisterMetaType<std::vector<std::string>>();
qRegisterMetaType<std::vector<QString>>(); qRegisterMetaType<std::vector<QString>>();
qRegisterMetaType<std::map<QString, bool>>("std::map<QString, bool>"); qRegisterMetaType<std::map<QString, bool>>("std::map<QString, bool>");

@ -32,15 +32,15 @@ MxcImageProvider::requestImageResponse(const QString &id, const QSize &requested
auto queryStart = id.lastIndexOf('?'); auto queryStart = id.lastIndexOf('?');
if (queryStart != -1) { if (queryStart != -1) {
id_ = id.left(queryStart); id_ = id.left(queryStart);
auto query = id.midRef(queryStart + 1); auto query = QStringView(id).mid(queryStart + 1);
auto queryBits = query.split('&'); auto queryBits = query.split('&');
for (auto b : queryBits) { for (auto b : queryBits) {
if (b == "scale") { if (b == QStringView(u"scale")) {
crop = false; crop = false;
} else if (b.startsWith("radius=")) { } else if (b.startsWith(QStringView(u"radius="))) {
radius = b.mid(7).toDouble(); radius = b.mid(7).toDouble();
} else if (b.startsWith("height=")) { } else if (b.startsWith(u"height=")) {
size.setHeight(b.mid(7).toInt()); size.setHeight(b.mid(7).toInt());
size.setWidth(0); size.setWidth(0);
} }
@ -109,7 +109,7 @@ MxcImageProvider::download(const QString &id,
// Protect against synapse not following the spec: // Protect against synapse not following the spec:
// https://github.com/matrix-org/synapse/issues/5302 // https://github.com/matrix-org/synapse/issues/5302
&& requestedSize.height() <= 600 && requestedSize.width() <= 800) { && requestedSize.height() <= 600 && requestedSize.width() <= 800) {
QString fileName = QString("%1_%2x%3_%4_radius%5") QString fileName = QStringLiteral("%1_%2x%3_%4_radius%5")
.arg(QString::fromUtf8(id.toUtf8().toBase64( .arg(QString::fromUtf8(id.toUtf8().toBase64(
QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals))) QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)))
.arg(requestedSize.width()) .arg(requestedSize.width())

@ -71,8 +71,12 @@ public:
}; };
class MxcImageProvider class MxcImageProvider
: public QObject :
, public QQuickAsyncImageProvider #if QT_VERSION < 0x60000
public QObject
,
#endif
public QQuickAsyncImageProvider
{ {
Q_OBJECT Q_OBJECT
public slots: public slots:
@ -85,7 +89,4 @@ public slots:
std::function<void(QString, QSize, QImage, QString)> then, std::function<void(QString, QSize, QImage, QString)> then,
bool crop = true, bool crop = true,
double radius = 0); double radius = 0);
private:
// QThreadPool pool;
}; };

@ -61,7 +61,6 @@ RegisterPage::RegisterPage(QWidget *parent)
logo_->setPixmap(logo.pixmap(128)); logo_->setPixmap(logo.pixmap(128));
logo_layout_ = new QHBoxLayout(); logo_layout_ = new QHBoxLayout();
logo_layout_->setMargin(0);
logo_layout_->addWidget(logo_, 0, Qt::AlignHCenter); logo_layout_->addWidget(logo_, 0, Qt::AlignHCenter);
form_wrapper_ = new QHBoxLayout(); form_wrapper_ = new QHBoxLayout();
@ -128,7 +127,6 @@ RegisterPage::RegisterPage(QWidget *parent)
button_layout_ = new QHBoxLayout(); button_layout_ = new QHBoxLayout();
button_layout_->setSpacing(0); button_layout_->setSpacing(0);
button_layout_->setMargin(0);
error_label_ = new QLabel(this); error_label_ = new QLabel(this);
error_label_->setWordWrap(true); error_label_->setWordWrap(true);
@ -406,7 +404,7 @@ void
RegisterPage::paintEvent(QPaintEvent *) RegisterPage::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.initFrom(this);
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }

@ -69,7 +69,10 @@ MsgCountComposedIcon::clone() const
} }
QList<QSize> QList<QSize>
MsgCountComposedIcon::availableSizes(QIcon::Mode mode, QIcon::State state) const MsgCountComposedIcon::availableSizes(QIcon::Mode mode, QIcon::State state)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const
#endif
{ {
Q_UNUSED(mode); Q_UNUSED(mode);
Q_UNUSED(state); Q_UNUSED(state);

@ -20,7 +20,11 @@ public:
void paint(QPainter *p, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; void paint(QPainter *p, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
QIconEngine *clone() const override; QIconEngine *clone() const override;
QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) const override; QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const
#endif
override;
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
int msgCount = 0; int msgCount = 0;

@ -771,7 +771,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
topBarLayout_ = new QHBoxLayout; topBarLayout_ = new QHBoxLayout;
topBarLayout_->setSpacing(0); topBarLayout_->setSpacing(0);
topBarLayout_->setMargin(0);
topBarLayout_->addWidget(backBtn_, 1, Qt::AlignLeft | Qt::AlignVCenter); topBarLayout_->addWidget(backBtn_, 1, Qt::AlignLeft | Qt::AlignVCenter);
topBarLayout_->addStretch(1); topBarLayout_->addStretch(1);
@ -1443,7 +1442,7 @@ void
UserSettingsPage::paintEvent(QPaintEvent *) UserSettingsPage::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.initFrom(this);
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }

@ -8,7 +8,6 @@
#include <QBuffer> #include <QBuffer>
#include <QComboBox> #include <QComboBox>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QDesktopWidget>
#include <QGuiApplication> #include <QGuiApplication>
#include <QImageReader> #include <QImageReader>
#include <QProcessEnvironment> #include <QProcessEnvironment>
@ -389,7 +388,7 @@ utils::humanReadableFingerprint(const QString &ed25519)
{ {
QString fingerprint; QString fingerprint;
for (int i = 0; i < ed25519.length(); i = i + 4) { for (int i = 0; i < ed25519.length(); i = i + 4) {
fingerprint.append(ed25519.midRef(i, 4)); fingerprint.append(QStringView(ed25519).mid(i, 4));
if (i > 0 && i % 16 == 12) if (i > 0 && i % 16 == 12)
fingerprint.append('\n'); fingerprint.append('\n');
else if (i < ed25519.length()) else if (i < ed25519.length())
@ -513,7 +512,8 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
while ((boundaryEnd = tbf.toNextBoundary()) != -1) { while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
charIdx++; charIdx++;
// Split text to get current char // Split text to get current char
auto curChar = nodeText.midRef(boundaryStart, boundaryEnd - boundaryStart); auto curChar =
QStringView(nodeText).mid(boundaryStart, boundaryEnd - boundaryStart);
boundaryStart = boundaryEnd; boundaryStart = boundaryEnd;
// Don't rainbowify whitespaces // Don't rainbowify whitespaces
if (curChar.trimmed().isEmpty() || codepointIsEmoji(curChar.toUcs4().first())) { if (curChar.trimmed().isEmpty() || codepointIsEmoji(curChar.toUcs4().first())) {

@ -81,7 +81,7 @@ void
WelcomePage::paintEvent(QPaintEvent *) WelcomePage::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.initFrom(this);
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }

@ -32,7 +32,10 @@ CreateRoom::CreateRoom(QWidget *parent)
auto layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setSpacing(conf::modals::WIDGET_SPACING); layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN); layout->setContentsMargins(conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN);
auto buttonLayout = new QHBoxLayout(); auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(15); buttonLayout->setSpacing(15);

@ -25,11 +25,13 @@ FallbackAuth::FallbackAuth(const QString &authType, const QString &session, QWid
auto layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setSpacing(conf::modals::WIDGET_SPACING); layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN); layout->setContentsMargins(conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN);
auto buttonLayout = new QHBoxLayout(); auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(8); buttonLayout->setSpacing(8);
buttonLayout->setMargin(0);
openBtn_ = new QPushButton(tr("Open Fallback in Browser"), this); openBtn_ = new QPushButton(tr("Open Fallback in Browser"), this);
cancelBtn_ = new QPushButton(tr("Cancel"), this); cancelBtn_ = new QPushButton(tr("Cancel"), this);

@ -4,7 +4,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include <QApplication> #include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication> #include <QGuiApplication>
#include <QPainter> #include <QPainter>
#include <QScreen> #include <QScreen>

@ -25,11 +25,13 @@ Logout::Logout(QWidget *parent)
auto layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setSpacing(conf::modals::WIDGET_SPACING); layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN); layout->setContentsMargins(conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN);
auto buttonLayout = new QHBoxLayout(); auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(0); buttonLayout->setSpacing(0);
buttonLayout->setMargin(0);
confirmBtn_ = new QPushButton("Logout", this); confirmBtn_ = new QPushButton("Logout", this);
cancelBtn_ = new QPushButton(tr("Cancel"), this); cancelBtn_ = new QPushButton(tr("Cancel"), this);

@ -33,7 +33,6 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent)
hlayout->addStretch(1); hlayout->addStretch(1);
hlayout->addWidget(&cancel_); hlayout->addWidget(&cancel_);
hlayout->addWidget(&upload_); hlayout->addWidget(&upload_);
hlayout->setMargin(0);
auto vlayout = new QVBoxLayout{this}; auto vlayout = new QVBoxLayout{this};
vlayout->addWidget(&titleLabel_); vlayout->addWidget(&titleLabel_);
@ -41,7 +40,10 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent)
vlayout->addWidget(&fileName_); vlayout->addWidget(&fileName_);
vlayout->addLayout(hlayout); vlayout->addLayout(hlayout);
vlayout->setSpacing(conf::modals::WIDGET_SPACING); vlayout->setSpacing(conf::modals::WIDGET_SPACING);
vlayout->setMargin(conf::modals::WIDGET_MARGIN); vlayout->setContentsMargins(conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN);
upload_.setDefault(true); upload_.setDefault(true);
connect(&upload_, &QPushButton::clicked, [this]() { connect(&upload_, &QPushButton::clicked, [this]() {
@ -217,4 +219,4 @@ PreviewUploadOverlay::keyPressEvent(QKeyEvent *event)
} else { } else {
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }
} }

@ -25,11 +25,13 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent)
auto layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setSpacing(conf::modals::WIDGET_SPACING); layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN); layout->setContentsMargins(conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN,
conf::modals::WIDGET_MARGIN);
auto buttonLayout = new QHBoxLayout(); auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(8); buttonLayout->setSpacing(8);
buttonLayout->setMargin(0);
openCaptchaBtn_ = new QPushButton("Open reCAPTCHA", this); openCaptchaBtn_ = new QPushButton("Open reCAPTCHA", this);
cancelBtn_ = new QPushButton(tr("Cancel"), this); cancelBtn_ = new QPushButton(tr("Cancel"), this);

@ -8,7 +8,6 @@
#include <QApplication> #include <QApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDesktopWidget>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QFontDatabase> #include <QFontDatabase>

@ -140,7 +140,7 @@ InputBar::updateAtRoom(const QString &t)
auto start = finder.position(); auto start = finder.position();
finder.toNextBoundary(); finder.toNextBoundary();
auto end = finder.position(); auto end = finder.position();
if (start > 0 && end - start >= 4 && t.midRef(start, end - start) == "room" && if (start > 0 && end - start >= 4 && t.mid(start, end - start) == "room" &&
t.at(start - 1) == QChar('@')) { t.at(start - 1) == QChar('@')) {
roomMention = true; roomMention = true;
break; break;
@ -324,7 +324,7 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
QString body; QString body;
bool firstLine = true; bool firstLine = true;
for (const auto &line : related.quoted_body.split("\n")) { for (auto line : related.quoted_body.splitRef(u'\n')) {
if (firstLine) { if (firstLine) {
firstLine = false; firstLine = false;
body = QString("> <%1> %2\n").arg(related.quoted_user, line); body = QString("> <%1> %2\n").arg(related.quoted_user, line);
@ -707,9 +707,9 @@ InputBar::showPreview(const QMimeData &source, const QString &path, const QStrin
QSize dimensions; QSize dimensions;
QString blurhash; QString blurhash;
auto mimeClass = mime.split("/")[0]; auto mimeClass = mime.splitRef(u'/')[0];
nhlog::ui()->debug("Mime: {}", mime.toStdString()); nhlog::ui()->debug("Mime: {}", mime.toStdString());
if (mimeClass == "image") { if (mimeClass == u"image") {
QImage img = utils::readImage(data); QImage img = utils::readImage(data);
dimensions = img.size(); dimensions = img.size();

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include <QStringList>
#include <QTimer> #include <QTimer>
#include <deque> #include <deque>
@ -15,7 +16,6 @@ class TimelineModel;
class CombinedImagePackModel; class CombinedImagePackModel;
class QMimeData; class QMimeData;
class QDropEvent; class QDropEvent;
class QStringList;
enum class MarkdownOverride enum class MarkdownOverride
{ {

@ -643,7 +643,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
// only show read receipts for messages not from us // only show read receipts for messages not from us
if (acc::sender(event) != http::client()->user_id().to_string()) if (acc::sender(event) != http::client()->user_id().to_string())
return qml_mtx_events::Empty; return qml_mtx_events::Empty;
else if (!id.isEmpty() && id[0] == "m") else if (!id.isEmpty() && id[0] == 'm')
return qml_mtx_events::Sent; return qml_mtx_events::Sent;
else if (read.contains(id) || containsOthers(cache::readReceipts(id, room_id_))) else if (read.contains(id) || containsOthers(cache::readReceipts(id, room_id_)))
return qml_mtx_events::Read; return qml_mtx_events::Read;
@ -1029,7 +1029,7 @@ TimelineModel::setCurrentIndex(int index)
if (!ChatPage::instance()->isActiveWindow()) if (!ChatPage::instance()->isActiveWindow())
return; return;
if (!currentId.startsWith("m")) { if (!currentId.startsWith('m')) {
auto oldReadIndex = auto oldReadIndex =
cache::getEventIndex(roomId().toStdString(), currentReadId.toStdString()); cache::getEventIndex(roomId().toStdString(), currentReadId.toStdString());
auto nextEventIndexAndId = auto nextEventIndexAndId =
@ -1759,16 +1759,16 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
if (startIndex - index != 0) if (startIndex - index != 0)
coloredUsername += coloredUsername +=
prefix + prefix + uncoloredUsername.mid(index, startIndex > 0 ? startIndex - index : -1) +
uncoloredUsername.midRef(index, startIndex > 0 ? startIndex - index : -1) + QStringLiteral("</font>");
"</font>";
auto endIndex = uncoloredUsername.indexOf("</font>", startIndex); auto endIndex = uncoloredUsername.indexOf("</font>", startIndex);
if (endIndex > 0) if (endIndex > 0)
endIndex += sizeof("</font>") - 1; endIndex += sizeof("</font>") - 1;
if (endIndex - startIndex != 0) if (endIndex - startIndex != 0)
coloredUsername += uncoloredUsername.midRef(startIndex, endIndex - startIndex); coloredUsername +=
QStringView(uncoloredUsername).mid(startIndex, endIndex - startIndex);
index = endIndex; index = endIndex;
} while (index > 0 && index < uncoloredUsername.size()); } while (index > 0 && index < uncoloredUsername.size());

@ -2,6 +2,7 @@
// //
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include <QEvent>
#include <QPainter> #include <QPainter>
#include <QPainterPath> #include <QPainterPath>

@ -9,7 +9,7 @@
#include <QObject> #include <QObject>
#include <QQuickItem> #include <QQuickItem>
class TimelineModel; #include "timeline/TimelineModel.h"
// This is an AnimatedImage, that can draw encrypted images // This is an AnimatedImage, that can draw encrypted images
class MxcAnimatedImage : public QQuickItem class MxcAnimatedImage : public QQuickItem

@ -72,7 +72,7 @@ OverlayWidget::paintEvent(QPaintEvent *event)
Q_UNUSED(event); Q_UNUSED(event);
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.initFrom(this);
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }

@ -17,7 +17,7 @@ SnackBar::SnackBar(QWidget *parent)
{ {
QFont font; QFont font;
font.setPointSizeF(font.pointSizeF() * 1.2); font.setPointSizeF(font.pointSizeF() * 1.2);
font.setWeight(50); font.setWeight(QFont::Weight::Thin);
setFont(font); setFont(font);
boxHeight_ = QFontMetrics(font).height() * 2; boxHeight_ = QFontMetrics(font).height() * 2;

@ -12,6 +12,7 @@
#include <mtx/responses/common.hpp> #include <mtx/responses/common.hpp>
#include "CacheCryptoStructs.h" #include "CacheCryptoStructs.h"
#include "timeline/TimelineModel.h"
namespace verification { namespace verification {
Q_NAMESPACE Q_NAMESPACE
@ -28,7 +29,6 @@ Q_ENUM_NS(Status)
} }
class DeviceVerificationFlow; class DeviceVerificationFlow;
class TimelineModel;
class TimelineViewManager; class TimelineViewManager;
class DeviceInfo class DeviceInfo

@ -10,6 +10,7 @@
#include <QMediaPlayer> #include <QMediaPlayer>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QStringList>
#include <QTimer> #include <QTimer>
#include "CallDevices.h" #include "CallDevices.h"
@ -21,7 +22,6 @@ namespace mtx::responses {
struct TurnServer; struct TurnServer;
} }
class QStringList;
class QUrl; class QUrl;
class CallManager : public QObject class CallManager : public QObject

Loading…
Cancel
Save