Skip to content

Commit

Permalink
Version 0.1.3.
Browse files Browse the repository at this point in the history
- Bug fixes and performance improvements.
  • Loading branch information
qtinsider committed Jan 8, 2022
1 parent 899bde4 commit 640a736
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 23 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
meegram (0.1.3) unstable; urgency=low

* Add chat mute menu
* Bug fixes and performance improvements.

-- Chukwudi Nwutobo <nwutobo@outlook.com> Fri, 07 Jan 2022 19:47:26 +0100

meegram (0.1.1) unstable; urgency=low

* Bug fixes and performance improvements.
Expand Down
7 changes: 5 additions & 2 deletions resources/qml/MessagePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import "components"
Page {
id: root

property string chatId: ""
property variant chat: null
property int replyMessageId: 0
property int editMessageId: 0

property bool loading: true

Flickable {
Expand Down Expand Up @@ -366,6 +369,6 @@ Page {
}
}

Component.onCompleted: myMessageModel.openChat(chatId)
Component.onCompleted: myMessageModel.openChat(chat.id)
Component.onDestruction: myMessageModel.closeChat()
}
2 changes: 1 addition & 1 deletion resources/qml/components/ChatItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Item {
anchors.fill: parent

onClicked: {
pageStack.push(Qt.createComponent("qrc:/qml/MessagePage.qml"), { chatId: myChatModel.get(index).id })
pageStack.push(Qt.createComponent("qrc:/qml/MessagePage.qml"), { chat: myChatModel.get(index) })
}
onPressAndHold: root.pressAndHold()
}
Expand Down
30 changes: 12 additions & 18 deletions resources/qml/components/MessageBubble.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,24 @@ import com.nokia.meego 1.1
Item {
id: root

property string sender: model.sender
property string date: model.date
property bool isOutgoing: model.isOutgoing

property bool isServiceMessage: model.isServiceMessage

property alias content: contentItem.children

property int childrenWidth

signal clicked
signal pressAndHold

height: isServiceMessage ? contentItem.children[0].height + 30 : contentItem.children[0].height + messageDate.height + (senderLabel.text !== "" ? senderLabel.height : 0) + (isOutgoing ? 28 : 30);
height: model.isServiceMessage ? contentItem.children[0].height + 30 : contentItem.children[0].height + messageDate.height + (senderLabel.text !== "" ? senderLabel.height : 0) + (model.isOutgoing ? 28 : 30);
width: parent.width

BorderImage {
height: parent.height + (isOutgoing ? 2 : 0)
width: Math.max(childrenWidth, messageDate.paintedWidth + (isOutgoing ? 28 : 0), senderLabel.paintedWidth) + 26
width: Math.max(childrenWidth, messageDate.paintedWidth + (model.isOutgoing ? 28 : 0), senderLabel.paintedWidth) + 26
anchors {
left: parent.left
leftMargin: isServiceMessage ? (parent.width - width) / 2 : isOutgoing ? 10 : parent.width - width - 10
leftMargin: model.isServiceMessage ? (parent.width - width) / 2 : model.isOutgoing ? 10 : parent.width - width - 10
top: parent.top
topMargin: isServiceMessage ? 2 : isOutgoing ? 8 : 1
topMargin: model.isServiceMessage ? 2 : model.isOutgoing ? 8 : 1
}

source: internal.getBubbleImage();
Expand All @@ -51,7 +45,7 @@ Item {
width: parent.width -100
anchors { left: parent.left; leftMargin: 80 }
color: "white"
text: sender
text: model.sender
font.pixelSize: 20
font.bold: true
wrapMode: Text.WrapAnywhere
Expand All @@ -66,7 +60,7 @@ Item {
height: contentItem.children[0].height
anchors {
top: parent.top
topMargin: isServiceMessage ? 15 : senderLabel.text === "" ? 16 : 46
topMargin: model.isServiceMessage ? 15 : senderLabel.text === "" ? 16 : 46
}
}

Expand All @@ -80,23 +74,23 @@ Item {
top: contentItem.bottom
topMargin: 4
}
text: date
color: isOutgoing ? "black" : "white"
text: model.date
color: model.isOutgoing ? "black" : "white"
font.pixelSize: 16
font.weight: Font.Light
horizontalAlignment: isServiceMessage ? Text.AlignHCenter : isOutgoing ? Text.AlignLeft : Text.AlignRight
visible: !isServiceMessage
horizontalAlignment: model.isServiceMessage ? Text.AlignHCenter : model.isOutgoing ? Text.AlignLeft : Text.AlignRight
visible: !model.isServiceMessage
}

QtObject {
id: internal

function getBubbleImage() {
var imageSrc = "qrc:/images/";
if (isServiceMessage) {
if (model.isServiceMessage) {
imageSrc += "notification"
} else {
imageSrc += isOutgoing ? "outgoing" : "incoming"
imageSrc += model.isOutgoing ? "outgoing" : "incoming"
imageSrc += mouseArea.pressed ? "-pressed" : "-normal"
}

Expand Down
32 changes: 31 additions & 1 deletion src/ChatModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@

#include <algorithm>

namespace detail {

QString getChatType(qint64 chatId)
{
auto chat = TdApi::getInstance().chatStore->get(chatId);

auto type = chat.value("type").toMap();
auto chatType = type.value("@type").toByteArray();

switch (fnv::hashRuntime(chatType.constData()))
{
case fnv::hash("chatTypePrivate"):
return "private";
case fnv::hash("chatTypeSecret"):
return "secret";
case fnv::hash("chatTypeBasicGroup"):
return "group";
case fnv::hash("chatTypeSupergroup"): {
if (type.value("is_channel").toBool())
return "channel";

return "supergroup";
}
}

return {};
}

} // namespace detail

ChatModel::ChatModel(QObject *parent)
: QAbstractListModel(parent)
, m_sortTimer(new QTimer(this))
Expand Down Expand Up @@ -83,7 +113,7 @@ QVariant ChatModel::data(const QModelIndex &index, int role) const
case IdRole:
return QString::number(chatId);
case TypeRole:
return {};
return detail::getChatType(chatId);
case TitleRole:
return Utils::getChatTitle(chatId, true);
case PhotoRole: {
Expand Down
2 changes: 1 addition & 1 deletion src/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <initializer_list>

static constexpr auto AppName = "MeeGram";
static constexpr auto AppVersion = "0.1.1";
static constexpr auto AppVersion = "0.1.3";

static constexpr auto ApiId = 142713;
static constexpr auto ApiHash = "9e9e687a70150c6436afe3a2b6bfd7d7";
Expand Down

0 comments on commit 640a736

Please sign in to comment.