diff --git a/client/htmlfilter.cpp b/client/htmlfilter.cpp
index db9c3e2d..5fb65f6a 100644
--- a/client/htmlfilter.cpp
+++ b/client/htmlfilter.cpp
@@ -700,7 +700,7 @@ Processor::rewrite_t Processor::filterTag(QStringView tag,
continue;
if (ff[0] == '\'' || ff[0] == '"')
ff = ff.mid(1, ff.length() - 2);
- if (QFontDatabase().isFixedPitch(ff.toString())) {
+ if (QFontDatabase::isFixedPitch(ff.toString())) {
rewrite.emplace_back().first = "code";
break;
}
diff --git a/client/main.cpp b/client/main.cpp
index d10bc73f..09101aa4 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -145,21 +145,19 @@ int main( int argc, char* argv[] )
// Extract a number from another macro and turn it to a const char[]
#define ITOA(i) #i
- loadTranslations(
- { { { "qt", "qtbase", "qtnetwork", "qtdeclarative", "qtmultimedia",
- "qtquickcontrols", "qtquickcontrols2",
- // QtKeychain tries to install its translations to Qt's path;
- // try to look there, just in case (see also below)
- "qtkeychain" },
- QLibraryInfo::location(QLibraryInfo::TranslationsPath) },
- { { "qtkeychain" },
- QStandardPaths::locate(QStandardPaths::GenericDataLocation,
- "qt" ITOA(QT_VERSION_MAJOR) "keychain/translations",
- QStandardPaths::LocateDirectory) },
- { { "qt", "qtkeychain", "quotient", "quaternion" },
- QStandardPaths::locate(QStandardPaths::AppLocalDataLocation,
- "translations",
- QStandardPaths::LocateDirectory) } });
+ loadTranslations({ { { "qt", "qtbase", "qtnetwork", "qtdeclarative", "qtmultimedia",
+ "qtquickcontrols", "qtquickcontrols2",
+ // QtKeychain tries to install its translations to Qt's path;
+ // try to look there, just in case (see also below)
+ "qtkeychain" },
+ QLibraryInfo::path(QLibraryInfo::TranslationsPath) },
+ { { "qtkeychain" },
+ QStandardPaths::locate(QStandardPaths::GenericDataLocation,
+ "qt" ITOA(QT_VERSION_MAJOR) "keychain/translations",
+ QStandardPaths::LocateDirectory) },
+ { { "qt", "qtkeychain", "quotient", "quaternion" },
+ QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "translations",
+ QStandardPaths::LocateDirectory) } });
#undef ITOA
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index 06684138..bb66b138 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -130,7 +130,7 @@ MainWindow::MainWindow()
MainWindow::~MainWindow()
{
saveSettings();
- for (auto* acc: qAsConst(logoutOnExit))
+ for (auto* acc: std::as_const(logoutOnExit))
logout(acc);
accountRegistry->disconnect(this);
}
@@ -193,8 +193,8 @@ void MainWindow::createMenu()
static const auto quitShortcut = QSysInfo::productType() == "windows"
? QKeySequence(Qt::CTRL | Qt::Key_Q)
: QKeySequence::Quit;
- connectionMenu->addAction(QIcon::fromTheme("application-exit"),
- tr("&Quit"), qApp, &QApplication::quit, quitShortcut);
+ connectionMenu->addAction(QIcon::fromTheme("application-exit"), tr("&Quit"), quitShortcut, qApp,
+ &QApplication::quit);
// View menu
auto viewMenu = menuBar()->addMenu(tr("&View"));
@@ -347,9 +347,8 @@ void MainWindow::createMenu()
openRoomAction->setStatusTip(tr("Open a room from the room list"));
openRoomAction->setShortcut(QKeySequence::Open);
openRoomAction->setDisabled(true);
- roomMenu->addAction(QIcon::fromTheme("window-close"),
- tr("&Close current room"), [this] { selectRoom(nullptr); },
- QKeySequence::Close);
+ roomMenu->addAction(QIcon::fromTheme("window-close"), tr("&Close current room"),
+ QKeySequence::Close, [this] { selectRoom(nullptr); });
// Settings menu
auto settingsMenu = menuBar()->addMenu(tr("&Settings"));
diff --git a/client/models/messageeventmodel.cpp b/client/models/messageeventmodel.cpp
index 10d76bf4..cae830db 100644
--- a/client/models/messageeventmodel.cpp
+++ b/client/models/messageeventmodel.cpp
@@ -860,7 +860,7 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const
const auto& annotations =
m_currentRoom->relatedEvents(evt, EventRelation::AnnotationType);
for (const auto& a: annotations)
- if (const auto e = eventCast(a)) {
+ if (const auto *const e = eventCast(a)) {
auto rIt = std::find_if(reactions.begin(), reactions.end(),
[&e] (const Reaction& r) {
return r.key == e->key();
diff --git a/client/models/roomlistmodel.cpp b/client/models/roomlistmodel.cpp
index c8803f14..73f9ade9 100644
--- a/client/models/roomlistmodel.cpp
+++ b/client/models/roomlistmodel.cpp
@@ -490,8 +490,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const
for (const auto& m: directChatMembers)
userNames.push_back(m.htmlSafeDisplayName());
result += "
"
- % tr("Direct chat with %1")
- .arg(QLocale().createSeparatedList(userNames));
+ % tr("Direct chat with %1").arg(QLocale().createSeparatedList(userNames));
}
if (room->usesEncryption())
diff --git a/client/qml/Timeline.qml b/client/qml/Timeline.qml
index 26a5fc0c..bb7dd7c1 100644
--- a/client/qml/Timeline.qml
+++ b/client/qml/Timeline.qml
@@ -5,7 +5,7 @@ import Quotient 1.0
Page {
id: root
- property var room: messageModel ? messageModel.room : undefined
+ property Room room: messageModel?.room
readonly property Logger lc: Logger { }
TimelineSettings {
@@ -50,9 +50,8 @@ Page {
height: headerText.height
// implicitWidth on its own doesn't respect the scale down of
// the received image (that almost always happens)
- width: Math.min(implicitHeight > 0
- ? headerText.height / implicitHeight * implicitWidth
- : 0,
+ width: Math.min(implicitHeight > 0 ? headerText.height / implicitHeight * implicitWidth
+ : 0,
parent.width / 2.618) // Golden ratio - just for fun
// Safe upper limit (see also topicField)
@@ -87,7 +86,7 @@ Page {
font: roomName.font
elide: Text.ElideRight
elideWidth: headerText.width
- text: room ? room.displayName : ""
+ text: room?.displayName ?? ""
}
text: roomNameMetrics.elidedText
@@ -110,10 +109,9 @@ Page {
width: parent.width
leftPadding: headerText.innerLeftPadding
- text: !room ? "" :
- room.successorId !== ""
- ? qsTr("This room has been upgraded.") :
- room.isUnstable ? qsTr("Unstable room version!") : ""
+ text: room?.successorId !== "" ? qsTr("This room has been upgraded.")
+ : room?.isUnstable ? qsTr("Unstable room version!")
+ : ""
elide: Text.ElideRight
font.italic: true
renderType: settings.render_type
@@ -175,8 +173,7 @@ Page {
MouseArea {
anchors.fill: headerText
acceptedButtons: Qt.MiddleButton | Qt.RightButton
- cursorShape: topicText.hoveredLink
- ? Qt.PointingHandCursor : Qt.IBeamCursor
+ cursorShape: topicText.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
onClicked: (mouse) => {
if (topicText.hoveredLink)
@@ -188,8 +185,7 @@ Page {
Menu {
id: headerContextMenu
MenuItem {
- text: roomHeader.showTopic ? qsTr("Hide topic")
- : qsTr("Show topic")
+ text: roomHeader.showTopic ? qsTr("Hide topic") : qsTr("Show topic")
onTriggered: roomHeader.showTopic = !roomHeader.showTopic
}
}
@@ -201,8 +197,7 @@ Page {
anchors.verticalCenter: headerText.verticalCenter
anchors.right: parent.right
width: visible * implicitWidth
- text: !room ? "" : room.successorId !== ""
- ? qsTr("Go to\nnew room") : qsTr("Room\nsettings")
+ text: room?.successorId !== "" ? qsTr("Go to\nnew room") : qsTr("Room\nsettings")
onClicked:
if (room.successorId !== "")
@@ -232,8 +227,7 @@ Page {
clip: true
ScrollBar.vertical: ScrollBar {
- policy: settings.use_shuttle_dial ? ScrollBar.AlwaysOff
- : ScrollBar.AsNeeded
+ policy: settings.use_shuttle_dial ? ScrollBar.AlwaysOff : ScrollBar.AsNeeded
interactive: true
active: true
// background: Item { /* TODO: timeline map */ }
@@ -276,10 +270,9 @@ Page {
return
// Take the current speed, or assume we can scroll 8 screens/s
- var velocity = moving ? -verticalVelocity :
- cruisingAnimation.running ?
- cruisingAnimation.velocity :
- chatView.height * 8
+ var velocity = moving ? -verticalVelocity
+ : cruisingAnimation.running ? cruisingAnimation.velocity
+ : chatView.height * 8
// Check if we're about to bump into the ceiling in
// 2 seconds and if yes, request the amount of messages
// enough to scroll at this rate for 3 more seconds
@@ -457,8 +450,7 @@ Page {
font.bold: true
opacity: 0.8
renderType: settings.render_type
- text: chatView.underlayingItem ?
- chatView.underlayingItem.ListView.section : ""
+ text: chatView.underlayingItem?.ListView.section ?? ""
}
}
}
@@ -471,27 +463,20 @@ Page {
// A proxy property for animation
property int requestedHistoryEventsCount: room?.requestedHistorySize ?? 0
- AnimationBehavior on requestedHistoryEventsCount {
- NormalNumberAnimation { }
- }
+ AnimationBehavior on requestedHistoryEventsCount { NormalNumberAnimation { } }
property real averageEvtHeight:
chatView.count + requestedHistoryEventsCount > 0
- ? chatView.height
- / (chatView.count + requestedHistoryEventsCount)
- : 0
- AnimationBehavior on averageEvtHeight {
- FastNumberAnimation { }
- }
+ ? chatView.height / (chatView.count + requestedHistoryEventsCount) : 0
+ AnimationBehavior on averageEvtHeight { FastNumberAnimation { } }
anchors.horizontalCenter: shuttleDial.horizontalCenter
anchors.bottom: chatView.bottom
anchors.bottomMargin:
averageEvtHeight * chatView.bottommostVisibleIndex
width: shuttleDial.backgroundWidth / 2
- height: chatView.bottommostVisibleIndex < 0 ? 0 :
- averageEvtHeight
- * (chatView.count - chatView.bottommostVisibleIndex)
+ height: chatView.bottommostVisibleIndex < 0
+ ? 0 : averageEvtHeight * (chatView.count - chatView.bottommostVisibleIndex)
visible: shuttleDial.visible
color: palette.mid
@@ -593,9 +578,8 @@ Page {
anchors.top: chatView.top
anchors.bottom: chatView.bottom
anchors.right: parent.right
- width: settings.use_shuttle_dial
- ? shuttleDial.backgroundWidth
- : chatView.ScrollBar.vertical.width
+ width: settings.use_shuttle_dial ? shuttleDial.backgroundWidth
+ : chatView.ScrollBar.vertical.width
acceptedButtons: Qt.NoButton
hoverEnabled: true
@@ -608,10 +592,9 @@ Page {
width: childrenRect.width + 3
height: childrenRect.height + 3
color: palette.alternateBase
- property bool shown:
- (chatView.bottommostVisibleIndex >= 0
- && (scrollerArea.containsMouse || scrollAnimation.running))
- || (room && room.requestedEventsCount > 0)
+ property bool shown: (chatView.bottommostVisibleIndex >= 0
+ && (scrollerArea.containsMouse || scrollAnimation.running))
+ || (room?.requestedHistorySize > 0)
onShownChanged: {
if (shown) {
@@ -635,9 +618,8 @@ Page {
text: (chatView.count > 0
? (chatView.bottommostVisibleIndex === 0
? qsTr("Latest events")
- : qsTr("%Ln events back from now","",
- chatView.bottommostVisibleIndex))
- + "\n" + qsTr("%Ln events cached", "", chatView.count)
+ : qsTr("%Ln events back from now","", chatView.bottommostVisibleIndex))
+ + "\n" + qsTr("%Ln events cached", "", chatView.count)
: "")
+ (room?.requestedHistorySize > 0
? (chatView.count > 0 ? "\n" : "")
diff --git a/client/qml/TimelineItem.qml b/client/qml/TimelineItem.qml
index 2d59f267..de738e69 100644
--- a/client/qml/TimelineItem.qml
+++ b/client/qml/TimelineItem.qml
@@ -16,11 +16,10 @@ Item {
readonly property bool pending: marks > EventStatus.Normal
&& marks < EventStatus.Redacted
readonly property bool failed: marks === EventStatus.SendingFailed
- readonly property string authorName:
- room && author ? room.safeMemberName(author.id) : ""
+ readonly property string authorName: author?.displayName ?? ""
// FIXME: boilerplate with models/userlistmodel.cpp:115
readonly property string authorColor: // contrast but not too heavy
- Qt.hsla(author ? author.hueF : 0.0, (1-palette.window.hslSaturation),
+ Qt.hsla(author?.hueF ?? 0, (1-palette.window.hslSaturation),
(-0.7*palette.window.hslLightness + 0.9), palette.buttonText.a)
readonly property bool actionEvent: eventType === "state"
@@ -236,25 +235,20 @@ Item {
horizontalAlignment: Image.AlignRight
forMember: author
- sourceSize: Qt.size(width,
- visible ? settings.minimalTimelineItemHeight
- : 0)
+ sourceSize: Qt.size(width, visible ? settings.minimalTimelineItemHeight : 0)
AuthorInteractionArea { }
}
Label {
id: authorLabel
visible: settings.timelineStyleIsXChat
- || (authorSectionVisible
- && (!actionEvent || authorHasAvatar))
+ || (authorSectionVisible && (!actionEvent || authorHasAvatar))
anchors.left: authorAvatar.right
anchors.leftMargin: 2
anchors.top: authorAvatar.top
- width: settings.timelineStyleIsXChat
- ? 120 - authorAvatar.width
- : Math.min(textField.width, implicitWidth)
- horizontalAlignment:
- actionEvent ? Text.AlignRight : Text.AlignLeft
+ width: settings.timelineStyleIsXChat ? 120 - authorAvatar.width
+ : Math.min(textField.width, implicitWidth)
+ horizontalAlignment: actionEvent ? Text.AlignRight : Text.AlignLeft
elide: Text.ElideRight
color: authorColor
@@ -262,8 +256,7 @@ Item {
font.bold: !settings.timelineStyleIsXChat
renderType: settings.render_type
- text: (actionEvent && settings.timelineStyleIsXChat ? "* " : "")
- + authorName
+ text: (actionEvent && settings.timelineStyleIsXChat ? "* " : "") + authorName
AuthorInteractionArea { }
}
@@ -296,10 +289,9 @@ Item {
id: textField
height: textFieldImpl.height
anchors.top:
- !settings.timelineStyleIsXChat && authorLabel.visible
- ? authorLabel.bottom : authorLabel.top
- anchors.left: (settings.timelineStyleIsXChat
- ? authorLabel : authorAvatar).right
+ !settings.timelineStyleIsXChat && authorLabel.visible ? authorLabel.bottom
+ : authorLabel.top
+ anchors.left: (settings.timelineStyleIsXChat ? authorLabel : authorAvatar).right
anchors.leftMargin: 2
anchors.right: parent.right
anchors.rightMargin: 1
@@ -334,7 +326,7 @@ Item {
+ (time ? toHtmlEscaped(time) : "")
+ ""
+ (actionEvent && !authorLabel.visible
- ? (""
+ toHtmlEscaped(authorName) + " ")
@@ -365,8 +357,7 @@ Item {
TimelineMouseArea {
anchors.fill: parent
- cursorShape: textFieldImpl.hoveredLink
- ? Qt.PointingHandCursor : Qt.IBeamCursor
+ cursorShape: textFieldImpl.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
acceptedButtons: Qt.MiddleButton | Qt.RightButton
onClicked: (mouse) => {
@@ -419,18 +410,14 @@ Item {
anchors.right: textField.right
sourceComponent: ImageContent {
- property var info:
- !progressInfo.isUpload && !progressInfo.active &&
- content.info && content.info.thumbnail_info
- ? content.info.thumbnail_info
- : content.info
+ property var info: !progressInfo.isUpload && !progressInfo.active
+ ? content?.info?.thumbnail_info : content.info
sourceSize: if (info) { Qt.size(info.w, info.h) }
source: downloaded || progressInfo.isUpload
? progressInfo.localPath
: progressInfo.failed
? ""
- : content.info && content.info.thumbnail_info
- && !autoload
+ : content?.info.thumbnail_info && !autoload
? "image://thumbnail/" + content.thumbnailMediaId
: ""
maxHeight: chatView.height - textField.height -
@@ -452,8 +439,7 @@ Item {
Label {
id: annotationLabel
- anchors.top: imageLoader.active ? imageLoader.bottom
- : fileLoader.bottom
+ anchors.top: imageLoader.active ? imageLoader.bottom : fileLoader.bottom
anchors.left: textField.left
anchors.right: textField.right
height: annotation ? implicitHeight : 0
@@ -482,15 +468,13 @@ Item {
+ modelData.authorsCount
textFormat: Text.PlainText
font.pointSize: settings.font.pointSize - 1
- color: modelData.includesLocalUser
- ? palette.highlight
- : palette.buttonText
+ color: modelData.includesLocalUser ? palette.highlight
+ : palette.buttonText
}
background: Rectangle {
radius: 4
- color: reactionButton.down ? palette.button
- : "transparent"
+ color: reactionButton.down ? palette.button : "transparent"
border.color: modelData.includesLocalUser
? palette.highlight
: settings.disabledPalette.buttonText
@@ -629,9 +613,7 @@ Item {
MouseArea {
anchors.fill: parent
- cursorShape: parent.hoveredLink ?
- Qt.PointingHandCursor :
- Qt.IBeamCursor
+ cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
acceptedButtons: Qt.NoButton
}
}
diff --git a/client/systemtrayicon.cpp b/client/systemtrayicon.cpp
index ee1e18f1..993920b3 100644
--- a/client/systemtrayicon.cpp
+++ b/client/systemtrayicon.cpp
@@ -11,6 +11,7 @@
#include
#include
#include
+#include
#include "mainwindow.h"
#include "quaternionroom.h"
@@ -57,9 +58,9 @@ void SystemTrayIcon::highlightCountChanged(Quotient::Room* room)
tr("%Ln highlight(s)", "", room->highlightCount()));
if (mode != "non-intrusive")
m_parent->activateWindow();
- connectSingleShot(this, &SystemTrayIcon::messageClicked, m_parent,
- [this,qRoom=static_cast(room)]
- { m_parent->selectRoom(qRoom); });
+ QtFuture::connect(this, &SystemTrayIcon::messageClicked)
+ .then(m_parent, std::bind_front(&MainWindow::selectRoom, m_parent,
+ static_cast(room)));
}
}
diff --git a/client/timelinewidget.cpp b/client/timelinewidget.cpp
index d6de0507..f09bfc61 100644
--- a/client/timelinewidget.cpp
+++ b/client/timelinewidget.cpp
@@ -215,8 +215,7 @@ void TimelineWidget::showMenu(int index, const QString& hoveredLink,
modelIndex.data(MessageEventModel::EventTypeRole).toString();
if (eventType == "image" || eventType == "file") {
const auto progressInfo =
- modelIndex.data(MessageEventModel::LongOperationRole)
- .value();
+ modelIndex.data(MessageEventModel::LongOperationRole).value();
const bool downloaded = !progressInfo.isUpload
&& progressInfo.completed();