Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #145 from mymike00/master
Browse files Browse the repository at this point in the history
Hide avatar and prepared mute/unmute button in channels
  • Loading branch information
Flohack74 authored Mar 4, 2018
2 parents 9a495ca + 946ba01 commit 8c88e64
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
43 changes: 35 additions & 8 deletions telegram/app/qml/AccountSendMessage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ Rectangle {
id: smsg
height: txt.height + units.gu(2)
z: 2
color: "white"
color: channelToolbar ? "transparent" : "white"

property Dialog currentDialog
property bool isChat: currentDialog != telegramObject.nullDialog ? currentDialog.peer.chatId != 0 : false
property bool isChannel: currentDialog != telegramObject.nullDialog ? currentDialog.peer.channelId != 0 : false
property bool dialogIsChannel: currentDialog ? currentDialog.peer.channelId != 0 : false
property Chat chat: currentDialog ? telegramObject.chat(dialogIsChannel ? currentDialog.peer.channelId : currentDialog.peer.chatId) : null
property int dialogId: isChannel ? currentDialog.peer.channelId : isChat ? currentDialog.peer.chatId : currentDialog.peer.userId
property bool isMuted: telegramObject.userData.isMuted(dialogId)

property bool channelToolbar: isChannel && !chat.megaGroup && false //need to replace 'false' with the property saying if you can write messages to the channel or not

signal accepted( string text, int inReplyTo )
signal copyRequest()
Expand Down Expand Up @@ -85,6 +91,26 @@ Rectangle {
checkForSharedContent()
}


UC.Button {
visible: channelToolbar
anchors.fill: parent
anchors.margins: units.dp(6)
text: isMuted ? i18n.tr("Unmute") : i18n.tr("Mute")
//iconName: "notification"
onClicked: {
//if (override) return;

if (isMuted)
telegramObject.unmute(dialogId);
else
telegramObject.mute(dialogId);

isMuted = telegramObject.userData.isMuted(dialogId)
text = isMuted ? i18n.tr("Unmute") : i18n.tr("Mute")
}
}

HashObject {
id: temp_hash
}
Expand Down Expand Up @@ -159,7 +185,7 @@ Rectangle {
height: parent.height
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
visible: enchat && (isWaiting || isDiscarded)
visible: enchat && (isWaiting || isDiscarded) && !channelToolbar
color: "grey"
fontSize: "medium"
text: enchat ? delegate_utils.getSecretChatState(encryptedTypes, enchat.classType) : ""
Expand All @@ -181,7 +207,7 @@ Rectangle {

opacity: privates.buttonsOpacity
Behavior on opacity { UbuntuNumberAnimation {} }
visible: opacity > 0 && !messagePlaceholder.visible
visible: (opacity > 0 && !messagePlaceholder.visible) && !channelToolbar

// This value is to avoid letter and underline being cut off.
height: units.gu(4.3)
Expand Down Expand Up @@ -295,7 +321,7 @@ Rectangle {

opacity: privates.buttonsOpacity
Behavior on opacity { UbuntuNumberAnimation {} }
visible: opacity > 0 && !messagePlaceholder.visible && (!txt.focus || (txt.text.length == 0 && !txt.inputMethodComposing))
visible: (opacity > 0 && !messagePlaceholder.visible && (!txt.focus || (txt.text.length == 0 && !txt.inputMethodComposing))) && !channelToolbar

AbstractButton {
anchors.fill: parent
Expand Down Expand Up @@ -339,7 +365,7 @@ Rectangle {

opacity: privates.buttonsOpacity
Behavior on opacity { UbuntuNumberAnimation {} }
visible: opacity > 0 && !messagePlaceholder.visible && (!txt.focus || (txt.text.length == 0 && !txt.inputMethodComposing))
visible: (opacity > 0 && !messagePlaceholder.visible && (!txt.focus || (txt.text.length == 0 && !txt.inputMethodComposing))) && !channelToolbar

AbstractButton {
anchors.fill: parent
Expand Down Expand Up @@ -378,7 +404,7 @@ Rectangle {
bottom: parent.bottom
}
width: send_mouse_area.width
visible: !messagePlaceholder.visible
visible: !messagePlaceholder.visible && !channelToolbar

// To work on desktop change the following line to:
// enabled: True
Expand Down Expand Up @@ -514,7 +540,7 @@ Rectangle {
width: parent.width
height: messageReply.height
anchors.bottom: parent.top
visible: messageReply.replyMessage
visible: messageReply.replyMessage && !channelToolbar

Rectangle {
anchors.fill: parent
Expand Down Expand Up @@ -693,7 +719,7 @@ Rectangle {

opacity: privates.audioRecorded ? 1.0 : 0.0
Behavior on opacity { UbuntuNumberAnimation {} }
visible: opacity > 0
visible: opacity > 0 && !channelToolbar

signal resetRequested()
onResetRequested: {
Expand Down Expand Up @@ -736,6 +762,7 @@ Rectangle {

AudioRecordingBar {
id: audioRecordingBar
visible: !channelToolbar

telegram: telegramObject
signal totalUploadedPercentChanged()
Expand Down
8 changes: 7 additions & 1 deletion telegram/app/qml/components/MessagesListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ListItem {

property Message message
property Dialog dialog
property bool dialogIsChat: dialog ? dialog.peer.chatId != 0 : false
property bool dialogIsChannel: dialog ? dialog.peer.channelId != 0 : false
property Chat chat: dialog ? telegramObject.chat(dialogIsChannel ? dialog.peer.channelId : dialog.peer.chatId) : null
property string messageText: message.message
property string messageHtmlText: parseText(message.message)
property User user: telegramObject.user(message.fromId)
Expand Down Expand Up @@ -125,7 +128,7 @@ ListItem {
topMargin: units.gu(.5)
}
height: units.gu(5)
visible: message_item.visibleNames && !message.out
visible: message_item.visibleNames && !message.out && !(dialogIsChannel && !message_item.chat.megagroup)

telegram: telegramObject
user: message_item.user
Expand All @@ -134,6 +137,9 @@ ListItem {
onClicked:{
userTapBackHome = false;
message_item.dialogRequest(telegramObject.fakeDialogObject(contact_image.user.id, false))
console.log("\n")
console.log("dialogIsChannel: "+dialogIsChannel)
console.log("megagroup: "+message_item.chat.megaGroup)
}
}

Expand Down

0 comments on commit 8c88e64

Please sign in to comment.