diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index 7674f11c..91ecd58a 100644
--- a/src/ChatPage.cpp
+++ b/src/ChatPage.cpp
@@ -307,16 +307,16 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
QString mimeClass,
const QString &fn,
const std::optional<RelatedInfo> &related) {
- QMimeDatabase db;
- QMimeType mime = db.mimeTypeForData(dev.data());
-
if (!dev->open(QIODevice::ReadOnly)) {
emit uploadFailed(
QString("Error while reading media: %1").arg(dev->errorString()));
return;
}
- auto bin = dev->peek(dev->size());
+ auto bin = dev->readAll();
+ QMimeDatabase db;
+ QMimeType mime = db.mimeTypeForData(bin);
+
auto payload = std::string(bin.data(), bin.size());
std::optional<mtx::crypto::EncryptedFile> encryptedFile;
if (cache::isRoomEncrypted(current_room_.toStdString())) {
@@ -328,10 +328,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
QSize dimensions;
QString blurhash;
if (mimeClass == "image") {
- dimensions = QImageReader(dev.data()).size();
-
QImage img;
img.loadFromData(bin);
+ dimensions = img.size();
if (img.height() > 200 && img.width() > 360)
img = img.scaled(360, 200, Qt::KeepAspectRatioByExpanding);
std::vector<unsigned char> data;
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index 7bae01a0..6a7c5b35 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -55,6 +55,7 @@ UserSettings::load()
hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool();
isStartInTrayEnabled_ = settings.value("user/window/start_in_tray", false).toBool();
isGroupViewEnabled_ = settings.value("user/group_view", true).toBool();
+ isButtonsInTimelineEnabled_ = settings.value("user/timeline/buttons", true).toBool();
isMarkdownEnabled_ = settings.value("user/markdown_enabled", true).toBool();
isTypingNotificationsEnabled_ = settings.value("user/typing_notifications", true).toBool();
ignoreMinorEvents_ = settings.value("user/minor_events", false).toBool();
@@ -127,6 +128,10 @@ UserSettings::save()
settings.setValue("start_in_tray", isStartInTrayEnabled_);
settings.endGroup();
+ settings.beginGroup("timeline");
+ settings.setValue("buttons", isButtonsInTimelineEnabled_);
+ settings.endGroup();
+
settings.setValue("avatar_circles", avatarCircles_);
settings.setValue("font_size", baseFontSize_);
@@ -192,6 +197,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
startInTrayToggle_ = new Toggle{this};
avatarCircles_ = new Toggle{this};
groupViewToggle_ = new Toggle{this};
+ timelineButtonsToggle_ = new Toggle{this};
typingNotifications_ = new Toggle{this};
ignoreMinorEvents_ = new Toggle{this};
readReceipts_ = new Toggle{this};
@@ -295,6 +301,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
formLayout_->addRow(new HorizontalLine{this});
boxWrap(tr("Circular Avatars"), avatarCircles_);
boxWrap(tr("Group's sidebar"), groupViewToggle_);
+ boxWrap(tr("Show buttons in timeline"), timelineButtonsToggle_);
boxWrap(tr("Typing notifications"), typingNotifications_);
boxWrap(tr("Ignore minor events in room list"), ignoreMinorEvents_);
formLayout_->addRow(new HorizontalLine{this});
@@ -402,6 +409,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
settings_->setIgnoreMinorEvents(!isDisabled);
});
+ connect(timelineButtonsToggle_, &Toggle::toggled, this, [this](bool isDisabled) {
+ settings_->setButtonsInTimeline(!isDisabled);
+ });
+
connect(readReceipts_, &Toggle::toggled, this, [this](bool isDisabled) {
settings_->setReadReceipts(!isDisabled);
});
@@ -437,6 +448,7 @@ UserSettingsPage::showEvent(QShowEvent *)
avatarCircles_->setState(!settings_->isAvatarCirclesEnabled());
typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
ignoreMinorEvents_->setState(!settings_->isIgnoreMinorEventsEnabled());
+ timelineButtonsToggle_->setState(!settings_->isButtonsInTimelineEnabled());
readReceipts_->setState(!settings_->isReadReceiptsEnabled());
markdownEnabled_->setState(!settings_->isMarkdownEnabled());
desktopNotifications_->setState(!settings_->hasDesktopNotifications());
diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index e1c52277..9dbe643e 100644
--- a/src/UserSettingsPage.h
+++ b/src/UserSettingsPage.h
@@ -90,6 +90,11 @@ public:
void setIgnoreMinorEvents(bool state)
{
ignoreMinorEvents_ = state;
+ }
+
+ void setButtonsInTimeline(bool state)
+ {
+ isButtonsInTimelineEnabled_ = state;
save();
}
@@ -113,6 +118,7 @@ public:
bool isMarkdownEnabled() const { return isMarkdownEnabled_; }
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
bool isIgnoreMinorEventsEnabled() const { return ignoreMinorEvents_; }
+ bool isButtonsInTimelineEnabled() const { return isButtonsInTimelineEnabled_; }
bool isReadReceiptsEnabled() const { return isReadReceiptsEnabled_; }
bool hasDesktopNotifications() const { return hasDesktopNotifications_; }
double fontSize() const { return baseFontSize_; }
@@ -135,6 +141,7 @@ private:
bool isMarkdownEnabled_;
bool isTypingNotificationsEnabled_;
bool ignoreMinorEvents_;
+ bool isButtonsInTimelineEnabled_;
bool isReadReceiptsEnabled_;
bool hasDesktopNotifications_;
bool avatarCircles_;
@@ -183,6 +190,7 @@ private:
Toggle *trayToggle_;
Toggle *startInTrayToggle_;
Toggle *groupViewToggle_;
+ Toggle *timelineButtonsToggle_;
Toggle *typingNotifications_;
Toggle *ignoreMinorEvents_;
Toggle *readReceipts_;
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index e1d2e822..ec98da23 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -716,7 +716,7 @@ TimelineModel::decryptEvent(const mtx::events::EncryptedEvent<mtx::events::msg::
dummy.sender = e.sender;
dummy.content.body =
tr("-- Encrypted Event (No keys found for decryption) --",
- "Placeholder, when the message was not decrypted yet or can't be decrypted")
+ "Placeholder, when the message was not decrypted yet or can't be decrypted.")
.toStdString();
try {
@@ -763,7 +763,7 @@ TimelineModel::decryptEvent(const mtx::events::EncryptedEvent<mtx::events::msg::
dummy.content.body =
tr("-- Decryption Error (%1) --",
"Placeholder, when the message can't be decrypted. In this case, the Olm "
- "decrytion returned an error, which is passed ad %1")
+ "decrytion returned an error, which is passed ad %1.")
.arg(e.what())
.toStdString();
return {dummy, false};
@@ -792,7 +792,7 @@ TimelineModel::decryptEvent(const mtx::events::EncryptedEvent<mtx::events::msg::
dummy.content.body =
tr("-- Encrypted Event (Unknown event type) --",
"Placeholder, when the message was decrypted, but we couldn't parse it, because "
- "Nheko/mtxclient don't support that event type yet")
+ "Nheko/mtxclient don't support that event type yet.")
.toStdString();
return {dummy, false};
}
@@ -1426,7 +1426,7 @@ QString
TimelineModel::formatTypingUsers(const std::vector<QString> &users, QColor bg)
{
QString temp =
- tr("%1 and %2 are typing",
+ tr("%1 and %2 are typing.",
"Multiple users are typing. First argument is a comma separated list of potentially "
"multiple users. Second argument is the last user of that list. (If only one user is "
"typing, %1 is empty. You should still use it in your string though to silence Qt "
@@ -1494,9 +1494,9 @@ TimelineModel::formatJoinRuleEvent(QString id)
switch (event->content.join_rule) {
case mtx::events::state::JoinRule::Public:
- return tr("%1 opened the room to the public").arg(name);
+ return tr("%1 opened the room to the public.").arg(name);
case mtx::events::state::JoinRule::Invite:
- return tr("%1 made this room require and invitation to join").arg(name);
+ return tr("%1 made this room require and invitation to join.").arg(name);
default:
// Currently, knock and private are reserved keywords and not implemented in Matrix.
return "";
@@ -1519,9 +1519,9 @@ TimelineModel::formatGuestAccessEvent(QString id)
switch (event->content.guest_access) {
case mtx::events::state::AccessState::CanJoin:
- return tr("%1 made the room open to guests").arg(name);
+ return tr("%1 made the room open to guests.").arg(name);
case mtx::events::state::AccessState::Forbidden:
- return tr("%1 has closed the room to guest access").arg(name);
+ return tr("%1 has closed the room to guest access.").arg(name);
default:
return "";
}
@@ -1545,16 +1545,16 @@ TimelineModel::formatHistoryVisibilityEvent(QString id)
switch (event->content.history_visibility) {
case mtx::events::state::Visibility::WorldReadable:
return tr("%1 made the room history world readable. Events may be now read by "
- "non-joined people")
+ "non-joined people.")
.arg(name);
case mtx::events::state::Visibility::Shared:
- return tr("%1 set the room history visible to members from this point on")
+ return tr("%1 set the room history visible to members from this point on.")
.arg(name);
case mtx::events::state::Visibility::Invited:
- return tr("%1 set the room history visible to members since they were invited")
+ return tr("%1 set the room history visible to members since they were invited.")
.arg(name);
case mtx::events::state::Visibility::Joined:
- return tr("%1 set the room history visible to members since they joined the room")
+ return tr("%1 set the room history visible to members since they joined the room.")
.arg(name);
default:
return "";
@@ -1661,7 +1661,7 @@ TimelineModel::formatMemberEvent(QString id)
else
rendered = tr("Kicked %1.").arg(name);
} else if (prevEvent->content.membership == Membership::Ban) {
- rendered = tr("Unbanned %1").arg(name);
+ rendered = tr("Unbanned %1.").arg(name);
} else if (prevEvent->content.membership == Membership::Knock) {
if (event->state_key == event->sender)
rendered = tr("%1 redacted their knock.").arg(name);
@@ -1675,7 +1675,7 @@ TimelineModel::formatMemberEvent(QString id)
break;
case Membership::Ban:
- rendered = tr("%1 was banned").arg(name);
+ rendered = tr("%1 was banned.").arg(name);
break;
case Membership::Knock:
rendered = tr("%1 knocked.").arg(name);
|