Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the reaction button configurable #553

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions harbour-fernschreiber.pro
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
qml/components/PollPreview.qml \
qml/components/PressEffect.qml \
qml/components/ProfilePictureList.qml \
qml/components/ReactionButton.qml \
qml/components/ReplyMarkupButtons.qml \
qml/components/StickerPicker.qml \
qml/components/PhotoTextsListItem.qml \
Expand Down
48 changes: 20 additions & 28 deletions qml/components/MessageListViewItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ListItem {
Debug.log("Obtaining message reactions")
tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId);
}
selectReactionBubble.visible = false;
selectReactionBubble.enabled = false;
}

function getContentWidthMultiplier() {
Expand All @@ -150,9 +150,13 @@ ListItem {

if (messageListItem.messageReactions) {
messageListItem.messageReactions = null;
selectReactionBubble.visible = false;
selectReactionBubble.enabled = false;
} else {
selectReactionBubble.visible = !selectReactionBubble.visible;
if (selectReactionBubble.enabled) {
selectReactionBubble.enabled = false
} else if (appSettings.showReactionButton) {
selectReactionBubble.enabled = true
}
elementSelected(index);
}
}
Expand Down Expand Up @@ -189,11 +193,11 @@ ListItem {
target: chatPage
onResetElements: {
messageListItem.messageReactions = null;
selectReactionBubble.visible = false;
selectReactionBubble.enabled = false;
}
onElementSelected: {
if (elementIndex !== index) {
selectReactionBubble.visible = false;
selectReactionBubble.enabled = false;
}
}
onNavigatedTo: {
Expand Down Expand Up @@ -716,7 +720,7 @@ ListItem {
onClicked: {
if (messageListItem.messageReactions) {
messageListItem.messageReactions = null;
selectReactionBubble.visible = false;
selectReactionBubble.enabled = false;
} else {
openReactions();
}
Expand All @@ -728,35 +732,23 @@ ListItem {

}

Rectangle {
Loader {
id: selectReactionBubble
visible: false
opacity: visible ? 0.5 : 0.0
Behavior on opacity { NumberAnimation {} }
anchors {
horizontalCenter: messageListItem.isOwnMessage ? messageBackground.left : messageBackground.right
verticalCenter: messageBackground.verticalCenter
}
height: Theme.itemSizeExtraSmall
width: Theme.itemSizeExtraSmall
color: Theme.primaryColor
radius: parent.width / 2
}

IconButton {
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();
enabled: false
opacity: enabled ? 1 : 0
active: opacity > 0
Behavior on opacity { FadeAnimation {} }
sourceComponent: Component {
ReactionButton {
onClicked: openReactions()
}
}
}

}

}

Column {
Expand Down Expand Up @@ -818,7 +810,7 @@ ListItem {
// Reaction is not yet selected
tdLibWrapper.addMessageReaction(chatId, messageId, modelData)
messageReactions = null
selectReactionBubble.visible = false
selectReactionBubble.enabled = false
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions qml/components/ReactionButton.qml
Original file line number Diff line number Diff line change
@@ -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()
}
}
27 changes: 27 additions & 0 deletions qml/components/settingsPage/SettingsBehavior.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import QtQuick 2.6
import Sailfish.Silica 1.0
import WerkWolf.Fernschreiber 1.0

import ".."

AccordionItem {
text: qsTr("Behavior")
Component {
Expand Down Expand Up @@ -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 {
id: feedbackComboBox
width: parent.columnWidth
Expand Down
15 changes: 15 additions & 0 deletions src/appsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace {
const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen");
const QString KEY_SPONSORED_MESS("sponsoredMess");
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)
Expand Down Expand Up @@ -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
{
return (SponsoredMess) settings.value(KEY_SPONSORED_MESS, (int)
Expand Down
15 changes: 10 additions & 5 deletions src/appsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class AppSettings : public QObject {
Q_PROPERTY(bool onlineOnlyMode READ onlineOnlyMode WRITE setOnlineOnlyMode NOTIFY onlineOnlyModeChanged)
Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged)
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 showReactionButton READ showReactionButton WRITE setShowReactionButton NOTIFY showReactionButtonChanged)
Q_PROPERTY(SponsoredMess sponsoredMess READ getSponsoredMess WRITE setSponsoredMess NOTIFY sponsoredMessChanged)

public:
enum SponsoredMess {
Expand Down Expand Up @@ -121,12 +122,15 @@ class AppSettings : public QObject {
bool getFocusTextAreaOnChatOpen() const;
void setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen);

SponsoredMess getSponsoredMess() const;
void setSponsoredMess(SponsoredMess sponsoredMess);

bool highlightUnreadConversations() const;
void setHighlightUnreadConversations(bool enable);

bool showReactionButton() const;
void setShowReactionButton(bool enable);

SponsoredMess getSponsoredMess() const;
void setSponsoredMess(SponsoredMess sponsoredMess);

signals:
void sendByEnterChanged();
void focusTextAreaAfterSendChanged();
Expand All @@ -147,8 +151,9 @@ class AppSettings : public QObject {
void onlineOnlyModeChanged();
void delayMessageReadChanged();
void focusTextAreaOnChatOpenChanged();
void sponsoredMessChanged();
void highlightUnreadConversationsChanged();
void showReactionButtonChanged();
void sponsoredMessChanged();

private:
QSettings settings;
Expand Down