Merge remote-tracking branch 'monich/configure-reaction-button' into aurora_beta

This commit is contained in:
Nikolai Sinyov 2024-07-02 11:35:09 +03:00
commit 3240a122a7
6 changed files with 92 additions and 33 deletions

View file

@ -65,6 +65,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
qml/components/PollPreview.qml \ qml/components/PollPreview.qml \
qml/components/PressEffect.qml \ qml/components/PressEffect.qml \
qml/components/ProfilePictureList.qml \ qml/components/ProfilePictureList.qml \
qml/components/ReactionButton.qml \
qml/components/ReplyMarkupButtons.qml \ qml/components/ReplyMarkupButtons.qml \
qml/components/StickerPicker.qml \ qml/components/StickerPicker.qml \
qml/components/PhotoTextsListItem.qml \ qml/components/PhotoTextsListItem.qml \

View file

@ -127,7 +127,7 @@ ListItem {
Debug.log("Obtaining message reactions") Debug.log("Obtaining message reactions")
tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId);
} }
selectReactionBubble.visible = false; selectReactionBubble.enabled = false;
} }
function getContentWidthMultiplier() { function getContentWidthMultiplier() {
@ -151,9 +151,13 @@ ListItem {
if (messageListItem.messageReactions) { if (messageListItem.messageReactions) {
messageListItem.messageReactions = null; messageListItem.messageReactions = null;
selectReactionBubble.visible = false; selectReactionBubble.enabled = false;
} else { } else {
selectReactionBubble.visible = !selectReactionBubble.visible; if (selectReactionBubble.enabled) {
selectReactionBubble.enabled = false
} else if (appSettings.showReactionButton) {
selectReactionBubble.enabled = true
}
elementSelected(index); elementSelected(index);
} }
} }
@ -190,11 +194,11 @@ ListItem {
target: chatPage target: chatPage
onResetElements: { onResetElements: {
messageListItem.messageReactions = null; messageListItem.messageReactions = null;
selectReactionBubble.visible = false; selectReactionBubble.enabled = false;
} }
onElementSelected: { onElementSelected: {
if (elementIndex !== index) { if (elementIndex !== index) {
selectReactionBubble.visible = false; selectReactionBubble.enabled = false;
} }
} }
onNavigatedTo: { onNavigatedTo: {
@ -735,7 +739,7 @@ ListItem {
onClicked: { onClicked: {
if (messageListItem.messageReactions) { if (messageListItem.messageReactions) {
messageListItem.messageReactions = null; messageListItem.messageReactions = null;
selectReactionBubble.visible = false; selectReactionBubble.enabled = false;
} else { } else {
openReactions(); openReactions();
} }
@ -747,35 +751,23 @@ ListItem {
} }
Rectangle { Loader {
id: selectReactionBubble id: selectReactionBubble
visible: false
opacity: visible ? 0.5 : 0.0
Behavior on opacity { NumberAnimation {} }
anchors { anchors {
horizontalCenter: messageListItem.isOwnMessage ? messageBackground.left : messageBackground.right horizontalCenter: messageListItem.isOwnMessage ? messageBackground.left : messageBackground.right
verticalCenter: messageBackground.verticalCenter verticalCenter: messageBackground.verticalCenter
} }
height: Theme.itemSizeExtraSmall enabled: false
width: Theme.itemSizeExtraSmall opacity: enabled ? 1 : 0
color: Theme.primaryColor active: opacity > 0
radius: parent.width / 2 Behavior on opacity { FadeAnimation {} }
} sourceComponent: Component {
ReactionButton {
IconButton { onClicked: openReactions()
id: selectReactionButton }
visible: selectReactionBubble.visible
opacity: visible ? 1.0 : 0.0
Behavior on opacity { NumberAnimation {} }
icon.source: "image://theme/icon-s-favorite"
anchors.centerIn: selectReactionBubble
onClicked: {
openReactions();
} }
} }
} }
} }
Column { Column {
@ -837,7 +829,7 @@ ListItem {
// Reaction is not yet selected // Reaction is not yet selected
tdLibWrapper.addMessageReaction(chatId, messageId, modelData) tdLibWrapper.addMessageReaction(chatId, messageId, modelData)
messageReactions = null messageReactions = null
selectReactionBubble.visible = false selectReactionBubble.enabled = false
} }
} }
} }

View file

@ -0,0 +1,19 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
Rectangle {
id: button
height: Theme.itemSizeExtraSmall
width: Theme.itemSizeExtraSmall
color: Theme.rgba(Theme.primaryColor, 0.4)
radius: width / 2
signal clicked()
IconButton {
icon.source: "image://theme/icon-s-favorite"
anchors.centerIn: parent
onClicked: button.clicked()
}
}

View file

@ -21,6 +21,8 @@ import QtQuick 2.6
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import WerkWolf.Fernschreiber 1.0 import WerkWolf.Fernschreiber 1.0
import ".."
AccordionItem { AccordionItem {
text: qsTr("Behavior") text: qsTr("Behavior")
Component { Component {
@ -114,6 +116,31 @@ AccordionItem {
} }
} }
TextSwitch {
width: parent.columnWidth
checked: appSettings.showReactionButton
text: qsTr("Show reaction button on tap")
description: qsTr("The reaction button may appear when you tap the message bubble, to make access to the reactions even easier.")
automaticCheck: false
onClicked: {
appSettings.showReactionButton = !checked
}
ReactionButton {
Behavior on opacity { FadeAnimation {} }
opacity: appSettings.showReactionButton ? 1 : 0
visible: opacity > 0
anchors {
right: parent.right
rightMargin: parent.rightMargin
verticalCenter: parent.verticalCenter
}
onClicked: {
appSettings.showReactionButton = !parent.checked
}
}
}
ComboBox { ComboBox {
id: feedbackComboBox id: feedbackComboBox
width: parent.columnWidth width: parent.columnWidth

View file

@ -42,6 +42,7 @@ namespace {
const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen"); const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen");
const QString KEY_SPONSORED_MESS("sponsoredMess"); const QString KEY_SPONSORED_MESS("sponsoredMess");
const QString KEY_HIGHLIGHT_UNREADCONVS("highlightUnreadConversations"); const QString KEY_HIGHLIGHT_UNREADCONVS("highlightUnreadConversations");
const QString KEY_SHOW_REACTION_BUTTON("showReactionButton");
} }
AppSettings::AppSettings(QObject *parent) : QObject(parent), settings(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/de.ygriega/fernschreiber/settings.conf", QSettings::NativeFormat) AppSettings::AppSettings(QObject *parent) : QObject(parent), settings(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/de.ygriega/fernschreiber/settings.conf", QSettings::NativeFormat)
@ -329,6 +330,20 @@ void AppSettings::setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen)
} }
} }
bool AppSettings::showReactionButton() const
{
return settings.value(KEY_SHOW_REACTION_BUTTON, true).toBool();
}
void AppSettings::setShowReactionButton(bool enable)
{
if (showReactionButton() != enable) {
LOG(KEY_SHOW_REACTION_BUTTON << enable);
settings.setValue(KEY_SHOW_REACTION_BUTTON, enable);
emit showReactionButtonChanged();
}
}
AppSettings::SponsoredMess AppSettings::getSponsoredMess() const AppSettings::SponsoredMess AppSettings::getSponsoredMess() const
{ {
return (SponsoredMess) settings.value(KEY_SPONSORED_MESS, (int) return (SponsoredMess) settings.value(KEY_SPONSORED_MESS, (int)

View file

@ -43,8 +43,9 @@ class AppSettings : public QObject {
Q_PROPERTY(bool onlineOnlyMode READ onlineOnlyMode WRITE setOnlineOnlyMode NOTIFY onlineOnlyModeChanged) Q_PROPERTY(bool onlineOnlyMode READ onlineOnlyMode WRITE setOnlineOnlyMode NOTIFY onlineOnlyModeChanged)
Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged) Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged)
Q_PROPERTY(bool focusTextAreaOnChatOpen READ getFocusTextAreaOnChatOpen WRITE setFocusTextAreaOnChatOpen NOTIFY focusTextAreaOnChatOpenChanged) Q_PROPERTY(bool focusTextAreaOnChatOpen READ getFocusTextAreaOnChatOpen WRITE setFocusTextAreaOnChatOpen NOTIFY focusTextAreaOnChatOpenChanged)
Q_PROPERTY(SponsoredMess sponsoredMess READ getSponsoredMess WRITE setSponsoredMess NOTIFY sponsoredMessChanged)
Q_PROPERTY(bool highlightUnreadConversations READ highlightUnreadConversations WRITE setHighlightUnreadConversations NOTIFY highlightUnreadConversationsChanged) Q_PROPERTY(bool highlightUnreadConversations READ highlightUnreadConversations WRITE setHighlightUnreadConversations NOTIFY highlightUnreadConversationsChanged)
Q_PROPERTY(bool showReactionButton READ showReactionButton WRITE setShowReactionButton NOTIFY showReactionButtonChanged)
Q_PROPERTY(SponsoredMess sponsoredMess READ getSponsoredMess WRITE setSponsoredMess NOTIFY sponsoredMessChanged)
public: public:
enum SponsoredMess { enum SponsoredMess {
@ -121,12 +122,15 @@ public:
bool getFocusTextAreaOnChatOpen() const; bool getFocusTextAreaOnChatOpen() const;
void setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen); void setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen);
SponsoredMess getSponsoredMess() const;
void setSponsoredMess(SponsoredMess sponsoredMess);
bool highlightUnreadConversations() const; bool highlightUnreadConversations() const;
void setHighlightUnreadConversations(bool enable); void setHighlightUnreadConversations(bool enable);
bool showReactionButton() const;
void setShowReactionButton(bool enable);
SponsoredMess getSponsoredMess() const;
void setSponsoredMess(SponsoredMess sponsoredMess);
signals: signals:
void sendByEnterChanged(); void sendByEnterChanged();
void focusTextAreaAfterSendChanged(); void focusTextAreaAfterSendChanged();
@ -147,8 +151,9 @@ signals:
void onlineOnlyModeChanged(); void onlineOnlyModeChanged();
void delayMessageReadChanged(); void delayMessageReadChanged();
void focusTextAreaOnChatOpenChanged(); void focusTextAreaOnChatOpenChanged();
void sponsoredMessChanged();
void highlightUnreadConversationsChanged(); void highlightUnreadConversationsChanged();
void showReactionButtonChanged();
void sponsoredMessChanged();
private: private:
QSettings settings; QSettings settings;