Commit 10f9ff84 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

HUGE improvement in UI and features and perfs

- replies are displayed and can be sent and clicked-to-jump
- incremental loading is now done by pull-down and push-up menus
- mark as read is less buggy
- lot of UI polishing in small details
- Sailfish settings page for options (ATM only enter-to-send mode)
- Change package version to 0.9.7
parent 15c4bb78
import QtQuick 2.1;
import Sailfish.Silica 1.0;
import Nemo.Configuration 1.0;
Page {
id: page;
ConfigurationValue {
id: configSendTextMsgOnEnterKey;
key: "/apps/telegrame/send_text_msg_on_enter_key";
defaultValue: false;
}
Column {
spacing: Theme.paddingLarge;
anchors {
top: parent.top;
left: parent.left;
right: parent.right;
}
PageHeader {
title: qsTr ("Telegra'me settings");
}
TextSwitch {
text: qsTr ("Quick sending of text messages");
description: qsTr ("Press Enter to send text messages (single-line)")
automaticCheck: true;
onCheckedChanged: {
configSendTextMsgOnEnterKey.value = checked;
}
Binding on checked { value: configSendTextMsgOnEnterKey.value; }
}
}
}
{
"translation_catalog" : "harbour-telegrame",
"entries": [
{
"path": "applications/harbour-telegrame.desktop",
"title": "Telegra'me",
"type": "page",
"icon": "harbour-telegrame",
"params": {
"source": "/usr/share/harbour-telegrame/settings/TelegrameSettings.qml"
}
}
]
}
[telegrame_im => play.mode=short]
sound.profile = im_fg.alert.tone@general => sound.filename
sound.stream.event.id = event-in-call
ffmemless.effect = NGF_SHORT
sound.stream.module-stream-restore.id = x-ringtone-volume
sound.enabled.profile = im_fg.alert.enabled => sound.enabled
haptic.type = short
[telegrame_im => play.mode=*,context@call_state.mode=active]
sound.profile = im_fg.alert.tone@general => sound.filename
sound.stream.event.id = event-in-call
sound.stream.module-stream-restore.id = sink-input-by-media-role:indicator-tone
[telegrame_im => play.mode=foreground]
sound.profile = im_fg.alert.tone => sound.filename
sound.profile.fallback = im_fg.alert.tone@fallback => sound.filename
ffmemless.effect = NGF_SMS
sound.stream.event.id = message-new-email
sound.stream.module-stream-restore.id = x-ringtone-volume
sound.enabled.profile = im_fg.alert.enabled => sound.enabled
haptic.type = short
[telegrame_im]
ffmemless.effect = NGF_SHORT
haptic.type = message
# Email exists indication
[telegrame_im_exists]
mce.led_pattern = PatternCommunicationIM
sound.profile = im.alert.tone => sound.filename
sound.profile.fallback = im.alert.tone@fallback => sound.filename
sound.stream.event.id = message-new-email
sound.stream.module-stream-restore.id = x-ringtone-volume
sound.stream.media.role = notification
sound.stream.droid.device.additional-route = AUDIO_DEVICE_OUT_SPEAKER
sound.enabled.profile = im.alert.enabled => sound.enabled
#https://git.merproject.org/jpetrell/ngfd/blob/master/src/plugins/devicelock/plugin.c
#https://git.merproject.org/mer-core/nemo-qml-plugin-devicelock/blob/master/src/nemo-devicelock/devicelock.h#L40
[telegrame_im_exists => play.mode=*,context@device_lock.state=manager_lockout]
[telegrame_im_exists => play.mode=*,context@call_state.mode=active]
mce.led_pattern = PatternCommunicationIM
[telegrame_im_fg]
#Vibration settings
#https://git.merproject.org/mer-core/ngfd/blob/master/src/include/ngf/haptic.h
#"touch","short","strong","long","notice","message","attention","alarm","ringtone"
sound.profile = im_fg.alert.tone => sound.filename
sound.profile.fallback = im_fg.alert.tone@fallback => sound.filename
sound.stream.event.id = message-new-email
sound.stream.module-stream-restore.id = x-meego-ringing-volume
sound.enabled.profile = im_fg.alert.enabled => sound.enabled
ffmemless.effect = NGF_SHORT
haptic.type = short
#https://git.merproject.org/mer-core/lipstick/blob/master/doc/src/notifications.dox
x-nemo-icon=icon-lock-chat
urgency=1
x-nemo-feedback=telegrame_im,telegrame_im_exists
#https://git.merproject.org/mer-core/lipstick/blob/master/doc/src/notifications.dox#L34
x-nemo-priority=110
x-nemo-display-on=true
#x-nemo-feedback=telegrame_im_fg
x-nemo-led-disabled-without-body-and-summary=false
#https://git.merproject.org/mer-core/lipstick/blob/master/doc/src/notifications.dox
x-nemo-feedback=telegrame_im_fg
x-nemo-led-disabled-without-body-and-summary=false
include ($$PWD/libQtQmlTricks/libQtQmlTricks-3.0.pri)
TARGET = harbour-telegrame
TEMPLATE = app
......@@ -21,25 +23,12 @@ PKGCONFIG += mlite5
INCLUDEPATH += \
/usr/include \
/usr/include/sailfishapp \
$$PWD/libQtQmlTricks \
$$PWD/libQtQmlTricks/core/macros \
$$PWD/libQtQmlTricks/core/models \
$$PWD/libQtQmlTricks/gui/containers \
$$PWD/libQtQmlTricks/gui/helpers \
$$PWD/src
SOURCES += \
$$PWD/src/harbour-telegrame.cpp \
$$PWD/src/QtTdLibJsonWrapper.cpp \
$$PWD/src/QtTdLibEnums.cpp \
$$PWD/libQtQmlTricks/gui/containers/QQuickAbstractContainerBase.cpp \
$$PWD/libQtQmlTricks/gui/containers/QQuickColumnContainer.cpp \
$$PWD/libQtQmlTricks/gui/containers/QQuickContainerAttachedObject.cpp \
$$PWD/libQtQmlTricks/gui/containers/QQuickGridContainer.cpp \
$$PWD/libQtQmlTricks/gui/containers/QQuickRowContainer.cpp \
$$PWD/libQtQmlTricks/gui/helpers/QQuickExtraAnchors.cpp \
$$PWD/libQtQmlTricks/gui/containers/QQuickFastObjectListView.cpp \
$$PWD/libQtQmlTricks/QtQmlTricks.cpp \
$$PWD/src/QtTdLibCommon.cpp \
$$PWD/src/QtTdLibConnection.cpp \
$$PWD/src/QtTdLibGlobal.cpp \
......@@ -54,19 +43,6 @@ SOURCES += \
HEADERS += \
$$PWD/src/QtTdLibJsonWrapper.h \
$$PWD/src/QtTdLibEnums.h \
$$PWD/libQtQmlTricks/core/macros/QmlEnumHelpers.h \
$$PWD/libQtQmlTricks/core/macros/QmlPropertyHelpers.h \
$$PWD/libQtQmlTricks/core/models/QQmlObjectListModel.h \
$$PWD/libQtQmlTricks/core/models/QQmlFastObjectListModel.h \
$$PWD/libQtQmlTricks/gui/containers/QQmlContainerEnums.h \
$$PWD/libQtQmlTricks/gui/containers/QQuickAbstractContainerBase.h \
$$PWD/libQtQmlTricks/gui/containers/QQuickColumnContainer.h \
$$PWD/libQtQmlTricks/gui/containers/QQuickContainerAttachedObject.h \
$$PWD/libQtQmlTricks/gui/containers/QQuickGridContainer.h \
$$PWD/libQtQmlTricks/gui/containers/QQuickRowContainer.h \
$$PWD/libQtQmlTricks/gui/containers/QQuickFastObjectListView.h \
$$PWD/libQtQmlTricks/gui/helpers/QQuickExtraAnchors.h \
$$PWD/libQtQmlTricks/QtQmlTricks.h \
$$PWD/src/QtTdLibCommon.h \
$$PWD/src/QtTdLibConnection.h \
$$PWD/src/QtTdLibGlobal.h \
......@@ -86,23 +62,50 @@ RESOURCES += \
$$PWD/images.qrc
OTHER_FILES += \
$$PWD/rpm/$${TARGET}.yaml
DISTFILES += \
$$PWD/$${TARGET}.desktop \
$$PWD/icons/86x86/$${TARGET}.png \
$$PWD/icons/108x108/$${TARGET}.png \
$$PWD/icons/128x128/$${TARGET}.png \
$$PWD/icons/172x172/$${TARGET}.png \
$$PWD/rpm/$${TARGET}.yaml
$$PWD/dist/telegrame.json \
$$PWD/dist/x-telegrame.im.conf \
$$PWD/dist/x-telegrame.im.fg.conf \
$$PWD/dist/TelegrameSettings.qml \
$$PWD/dist/telegrame_im.ini \
$$PWD/dist/telegrame_im_exists.ini \
$$PWD/dist/telegrame_im_fg.ini
target.files = $${TARGET}
target.path = /usr/bin
desktop.files = $$PWD/$${TARGET}.desktop
desktop.path = /usr/share/applications
icon86.files = $$PWD/icons/86x86/$${TARGET}.png
icon86.path = /usr/share/icons/hicolor/86x86/apps
icon108.files = $$PWD/icons/108x108/$${TARGET}.png
icon108.path = /usr/share/icons/hicolor/108x108/apps
icon128.files = $$PWD/icons/128x128/$${TARGET}.png
icon128.path = /usr/share/icons/hicolor/128x128/apps
icon256.files = $$PWD/icons/256x256/$${TARGET}.png
icon256.path = /usr/share/icons/hicolor/256x256/apps
INSTALLS += target desktop icon86 icon108 icon128 icon256
notificationcategories.files = $$PWD/dist/x-telegrame.im.conf $$PWD/dist/x-telegrame.im.fg.conf
notificationcategories.path = /usr/share/lipstick/notificationcategories
events.files = $$PWD/dist/telegrame_im.ini $$PWD/dist/telegrame_im_exists.ini $$PWD/dist/telegrame_im_fg.ini
events.path = /usr/share/ngfd/events.d
settings_json.files = $$PWD/dist/telegrame.json
settings_json.path = /usr/share/jolla-settings/entries
settings_qml.files = $$PWD/dist/TelegrameSettings.qml
settings_qml.path = /usr/share/$${TARGET}/settings
INSTALLS += target desktop icon86 icon108 icon128 icon256 notificationcategories events settings_json settings_qml
Subproject commit e9f78316e578051780c147410ccb8114b36368c7
Subproject commit aac46537d3dc072247714096cc9df9cd79762037
......@@ -6,6 +6,7 @@ import Qt.labs.folderlistmodel 2.1;
import QtDocGallery 5.0;
import Nemo.Thumbnailer 1.0;
import Nemo.Notifications 1.0;
import Nemo.Configuration 1.0;
import harbour.Telegrame 1.0;
import "cover";
import "pages";
......@@ -28,19 +29,35 @@ ApplicationWindow {
property int currentMsgType : TD_ObjectType.MESSAGE_TEXT;
property bool showInputPanel : false;
property string currentRecording : "";
property TD_StickerSet currentStickerSet : (TD_Global.stickerSetsList.count > 0 ? TD_Global.stickerSetsList.getFirst () : null);
property bool groupImagesInAlbums : true;
property bool groupVideosInAlbums : true;
property bool showInputPanel : false;
property alias groupImagesInAlbums : configGroupImagesInAlbum.value;
property alias groupVideosInAlbums : configGroupVideosInAlbum.value;
property alias sendTextMsgOnEnterKey : configSendTextMsgOnEnterKey.value;
readonly property bool active : (Qt.application.state === Qt.ApplicationActive);
readonly property bool isPortrait : (window.orientation === Orientation.Portrait || window.orientation === Orientation.PortraitInverted);
readonly property bool isLandscape : (window.orientation === Orientation.Landscape || window.orientation === Orientation.LandscapeInverted);
ConfigurationValue {
id: configGroupImagesInAlbum;
key: "/apps/telegrame/group_images_in_album";
defaultValue: true;
}
ConfigurationValue {
id: configGroupVideosInAlbum;
key: "/apps/telegrame/group_videos_in_album";
defaultValue: true;
}
ConfigurationValue {
id: configSendTextMsgOnEnterKey;
key: "/apps/telegrame/send_text_msg_on_enter_key";
defaultValue: false;
}
Item {
rotation: {
switch (window.orientation) {
......@@ -93,7 +110,7 @@ ApplicationWindow {
TextField {
id: inputMsgSingle;
visible: btnSendMsgText.fastSend;
visible: sendTextMsgOnEnterKey;
labelVisible: false;
placeholderText: qsTr ("Text message");
anchors.fill: parent;
......@@ -103,7 +120,7 @@ ApplicationWindow {
}
TextArea {
id: inputMsg;
visible: !btnSendMsgText.fastSend;
visible: !sendTextMsgOnEnterKey;
labelVisible: false;
placeholderText: qsTr ("Text message");
autoScrollEnabled: true;
......@@ -123,15 +140,14 @@ ApplicationWindow {
execute ();
}
readonly property bool fastSend : TD_Global.sendTextOnEnterKey;
readonly property Item textBox : (fastSend ? inputMsgSingle : inputMsg);
readonly property Item textBox : (sendTextMsgOnEnterKey ? inputMsgSingle : inputMsg);
function execute () {
textBox.focus = false;
var tmp = textBox.text.trim ();
if (tmp !== "") {
TD_Global.sendMessageText (TD_Global.currentChat, tmp);
TD_Global.autoScrollDownRequested (true);
//TD_Global.autoScrollDownRequested (true);
}
textBox.text = "";
}
......@@ -176,7 +192,7 @@ ApplicationWindow {
if (TD_Global.selectedPhotosCount > 0) {
TD_Global.sendMessagePhoto (TD_Global.currentChat, groupImagesInAlbums);
TD_Global.unselectAllPhotos ();
TD_Global.autoScrollDownRequested (true);
//TD_Global.autoScrollDownRequested (true);
}
}
}
......@@ -278,7 +294,7 @@ ApplicationWindow {
if (TD_Global.selectedVideosCount > 0) {
TD_Global.sendMessageVideo (TD_Global.currentChat, groupVideosInAlbums);
TD_Global.unselectAllVideos ();
TD_Global.autoScrollDownRequested (true);
//TD_Global.autoScrollDownRequested (true);
}
}
}
......@@ -381,7 +397,7 @@ ApplicationWindow {
implicitHeight: GridView.view.cellHeight;
onClicked: {
TD_Global.sendMessageSticker (TD_Global.currentChat, stickerItem);
TD_Global.autoScrollDownRequested (true);
//TD_Global.autoScrollDownRequested (true);
}
readonly property TD_Sticker stickerItem : modelData;
......
This diff is collapsed.
......@@ -422,7 +422,7 @@ Page {
model: TD_Global.sortedChatsList;
delegate: ListItem {
id: delegateChat;
visible: ((chatItem.messagesModel.count > 0 && chatItem.order > 0) && (inputFilter.value === "" || chatItem.title.toLowerCase ().indexOf (inputFilter.value) >= 0));
visible: ((chatItem.order > 0) && (inputFilter.value === "" || chatItem.title.toLowerCase ().indexOf (inputFilter.value) >= 0));
contentHeight: (Theme.iconSizeMedium + Theme.paddingMedium * 2);
implicitHeight: (Theme.iconSizeMedium + Theme.paddingMedium * 2);
menu: ContextMenu {
......@@ -457,7 +457,7 @@ Page {
readonly property TD_Chat chatItem : modelData;
readonly property TD_ChatPhoto chatPhotoItem : (chatItem ? chatItem.photo : null);
readonly property TD_Message lastMsgItem : (chatItem ? chatItem.messagesModel.lastItem : null);
readonly property TD_Message lastMsgItem : (chatItem ? chatItem.getMessageItemById (chatItem.lastReceivedMessageId) : null);
readonly property TD_User lastMsgUserItem : (lastMsgItem ? TD_Global.getUserItemById (lastMsgItem.senderUserId) : null);
readonly property TD_MessageContent lastMsgContentItem : (lastMsgItem ? lastMsgItem.content : null);
readonly property int unreadCount : (chatItem.notificationSettings.muteFor === 0 ? chatItem.unreadCount : 0);
......@@ -608,6 +608,7 @@ Page {
Rectangle {
color: Theme.secondaryHighlightColor;
opacity: 0.65;
visible: flickerChats.atYBeginning;
implicitHeight: Theme.paddingSmall;
ExtraAnchors.topDock: parent;
}
......
......@@ -14,7 +14,7 @@ Name: harbour-telegrame
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 6
Release: 7
Group: Qt/Qt
License: LICENSE
URL: http://example.org/
......@@ -70,5 +70,9 @@ desktop-file-install --delete-original \
%{_bindir}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/%{name}/settings/*.qml
%{_datadir}/lipstick/notificationcategories/*.conf
%{_datadir}/ngfd/events.d/*.ini
%{_datadir}/jolla-settings/entries/*.json
# >> files
# << files
Name: harbour-telegrame
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 6
Release: 7
Group: Qt/Qt
URL: http://example.org/
License: LICENSE
URL: http://gitlab.unique-conception.org/sailfish-app/telegra-me
License: WTFPL
Sources:
- '%{name}-%{version}.tar.bz2'
......@@ -34,3 +34,7 @@ Files:
- '%{_bindir}'
- '%{_datadir}/applications/%{name}.desktop'
- '%{_datadir}/icons/hicolor/*/apps/%{name}.png'
- '%{_datadir}/%{name}/settings/*.qml'
- '%{_datadir}/lipstick/notificationcategories/*.conf'
- '%{_datadir}/ngfd/events.d/*.ini'
- '%{_datadir}/jolla-settings/entries/*.json'
#include "QtTdLibChat.h"
#include "QtTdLibGlobal.h"
QtTdLibChat::QtTdLibChat (const qint64 id, QObject * parent)
: QtTdLibAbstractInt53IdObject { QtTdLibObjectType::CHAT, id, parent }
, m_isCurrentChat { false }
, m_firstUnreadMessageItem { Q_NULLPTR }
{
QtTdLibCollection::allChats.insert (id, this);
static const QString ICON { "/usr/share/icons/hicolor/128x128/apps/harbour-telegrame.png" };
m_notif.setAppName ("Telegra'me");
m_notif.setCategory ("x-telegrame.im");
m_notif.setIcon (ICON);
m_notif.setAppIcon (ICON);
m_notif.setMaxContentLines (3);
......@@ -17,25 +20,27 @@ QtTdLibChat::QtTdLibChat (const qint64 id, QObject * parent)
"/org/uniqueconception/telegrame",
"org.uniqueconception.telegrame",
"showChat",
QVariantList { /*"argument",*/ get_id () }));
connect (this, &QtTdLibChat::titleChanged, this, &QtTdLibChat::refreshNotification);
connect (this, &QtTdLibChat::unreadCountChanged, this, &QtTdLibChat::refreshNotification);
connect (this, &QtTdLibChat::isCurrentChatChanged, this, &QtTdLibChat::refreshNotification);
connect (&messagesModel, &QQmlFastObjectListModelBase::lastChanged, this, &QtTdLibChat::refreshNotification);
QVariantList { get_id () }));
connect (this, &QtTdLibChat::titleChanged, this, &QtTdLibChat::refreshNotification);
connect (this, &QtTdLibChat::unreadCountChanged, this, &QtTdLibChat::refreshNotification);
connect (this, &QtTdLibChat::isCurrentChatChanged, this, &QtTdLibChat::refreshNotification);
connect (this, &QtTdLibChat::lastReceivedMessageIdChanged, this, &QtTdLibChat::refreshNotification);
connect (&m_timer, &QTimer::timeout, this, [this] (void) {
if (m_unreadCount > 0 && !m_isCurrentChat && m_notificationSettings != Q_NULLPTR && m_notificationSettings->get_muteFor () == 0) {
if (QtTdLibMessage * lastMsg = { messagesModel.getLast () }) {
m_notif.setItemCount (m_unreadCount);
m_notif.setSummary (m_title);
m_notif.setTimestamp (lastMsg->get_date ());
m_notif.setBody (lastMsg->preview ());
m_notif.setPreviewBody (lastMsg->preview ());
m_notif.setPreviewSummary (m_title);
m_notif.publish ();
}
else {
m_notif.close ();
}
QtTdLibMessage * lastMsg = { getMessageItemById (m_lastReceivedMessageId) };
if (!m_isCurrentChat &&
(m_unreadCount > 0) &&
(m_notificationSettings != Q_NULLPTR) &&
(m_notificationSettings->get_muteFor () == 0) &&
(lastMsg != Q_NULLPTR) &&
(lastMsg->get_id () > m_lastNotifiedMessageId)) {
m_lastNotifiedMessageId = lastMsg->get_id ();
m_notif.setItemCount (m_unreadCount);
m_notif.setSummary (m_title);
m_notif.setTimestamp (lastMsg->get_date ());
m_notif.setBody (lastMsg->preview ());
m_notif.setPreviewBody (lastMsg->preview ());
m_notif.setPreviewSummary (m_title);
m_notif.publish ();
}
else {
m_notif.close ();
......@@ -45,6 +50,11 @@ QtTdLibChat::QtTdLibChat (const qint64 id, QObject * parent)
qWarning () << "CLICKED" << get_id ();
emit displayRequested ();
});
connect (this, &QtTdLibChat::lastReadInboxMessageIdChanged, this, &QtTdLibChat::findFirstNewMessage);
connect (this, &QtTdLibChat::lastReadOutboxMessageIdChanged, this, &QtTdLibChat::findFirstNewMessage);
connect (&messagesModel, &QQmlFastObjectListModelBase::itemInserted, this, &QtTdLibChat::findFirstNewMessage);
connect (&messagesModel, &QQmlFastObjectListModelBase::itemRemoved, this, &QtTdLibChat::findFirstNewMessage);
connect (&messagesModel, &QQmlFastObjectListModelBase::itemsCleared, this, &QtTdLibChat::findFirstNewMessage);
m_timer.setTimerType (Qt::CoarseTimer);
m_timer.setSingleShot (true);
m_timer.setInterval (350);
......@@ -61,6 +71,19 @@ void QtTdLibChat::refreshNotification (void) {
}
}
void QtTdLibChat::findFirstNewMessage (void) {
QtTdLibMessage * firstUnreadMessageItem { Q_NULLPTR };
for (int idx { 0 }; idx < messagesModel.count (); ++idx) {
if (QtTdLibMessage * messageItem = { messagesModel.getAt (idx) }) {
if (messageItem->get_id () > m_lastReadInboxMessageId && (idx == 0 || messagesModel.getAt (idx -1)->get_id () <= m_lastReadInboxMessageId)) {
firstUnreadMessageItem = messageItem;
break;
}
}
}
set_firstUnreadMessageItem (firstUnreadMessageItem);
}
QtTdLibMessage * QtTdLibChat::getMessageItemById (const QString & id) const {
return getMessageItemById (id.toLongLong ());
}
......@@ -109,6 +132,11 @@ void QtTdLibChat::updateFromJson (const QJsonObject & json) {
set_type_withJSON (json ["type"].toObject (), &QtTdLibChatType::createAbstract);
set_photo_withJSON (json ["photo"].toObject (), &QtTdLibChatPhoto::create);
set_notificationSettings_withJSON (json ["notification_settings"].toObject (), &QtTdLibChatNotificationSettings::create);
set_lastReceivedMessageId_withJSON (json ["last_message"].toObject () ["id"]);
}
QtTdLibMessageRefWatcher * QtTdLibChat::getMessageRefById (const QString & id) {
return (id != "0" ? new QtTdLibMessageRefWatcher { id.toLongLong (), this } : Q_NULLPTR);
}
QtTdLibChatPhoto::QtTdLibChatPhoto (QObject * parent)
......@@ -313,3 +341,25 @@ void QtTdLibChatMember::updateFromJson (const QJsonObject & json) {
set_joinedChatDate_withJSON (json ["joined_chat_date"]);
set_status_withJSON (json ["status"], &QtTdLibChatMemberStatus::createAbstract);
}
QtTdLibMessageRefWatcher::QtTdLibMessageRefWatcher (const qint64 messageId, QtTdLibChat * parent)
: QObject { parent }
, m_messageItem { (parent ? parent->getMessageItemById (messageId) : Q_NULLPTR) }
, m_messageId { messageId }
{
if (m_messageItem == Q_NULLPTR) {
if (parent != Q_NULLPTR) {
connect (parent, &QtTdLibChat::messageItemAdded, this, &QtTdLibMessageRefWatcher::onMessageItemAdded);
if (QtTdLibGlobal * global = { qobject_cast<QtTdLibGlobal *> (parent->parent ()) }) {
global->loadSingleMessageRef (parent, m_messageId);
}
}
}
}
void QtTdLibMessageRefWatcher::onMessageItemAdded(QtTdLibMessage * messageItem) {
if (messageItem->get_id () == m_messageId) {
set_messageItem (messageItem);
disconnect (qobject_cast<QtTdLibChat *> (parent ()), &QtTdLibChat::messageItemAdded, this, &QtTdLibMessageRefWatcher::onMessageItemAdded);
}
}
......@@ -121,9 +121,9 @@ class QtTdLibSupergroup : public QtTdLibAbstractInt32IdObject, public FactoryInt
Q_TDLIB_PROPERTY_BOOL (isAllHistoryAvailable)
Q_TDLIB_PROPERTY_ID64 (stickerSetId)
Q_TDLIB_PROPERTY_STRING (inviteLink)
Q_TDLIB_PROPERTY_ID64 (pinnedMessageId)
Q_TDLIB_PROPERTY_ID53 (pinnedMessageId)
Q_TDLIB_PROPERTY_ID32 (upgradedFromBasicGroupId)
Q_TDLIB_PROPERTY_ID64 (upgradedFromMaxMessageId)
Q_TDLIB_PROPERTY_ID53 (upgradedFromMaxMessageId)
Q_TDLIB_PROPERTY_SUBOBJECT (status, QtTdLibChatMemberStatus)
QML_OBJMODEL_PROPERTY (members, QtTdLibChatMember)
......@@ -227,6 +227,8 @@ public:
void updateFromJson (const QJsonObject & json) Q_DECL_FINAL;
};
class QtTdLibMessageRefWatcher;
class QtTdLibChat : public QtTdLibAbstractInt53IdObject, public FactoryInt53Id<QtTdLibChat> {
Q_OBJECT
Q_TDLIB_PROPERTY_INT32 (unreadCount)
......@@ -241,10 +243,24 @@ class QtTdLibChat : public QtTdLibAbstractInt53IdObject, public FactoryInt53Id<Q
Q_TDLIB_PROPERTY_SUBOBJECT (type, QtTdLibChatType)
Q_TDLIB_PROPERTY_SUBOBJECT (photo, QtTdLibChatPhoto)
Q_TDLIB_PROPERTY_SUBOBJECT (notificationSettings, QtTdLibChatNotificationSettings)
QML_FASTOBJMODEL_PROPERTY (messagesModel, QtTdLibMessage)
//last_message:message
//draft_message:draftMessage
QML_READONLY_VAR_PROPERTY (isCurrentChat, bool)
/// CUSTOM CONVENIENCE PROPERTIES
QML_FASTOBJMODEL_PROPERTY (messagesModel, QtTdLibMessage)
QML_READONLY_VAR_PROPERTY (isCurrentChat, bool)
QML_READONLY_VAR_PROPERTY (hasReachedFirst, bool)
QML_READONLY_VAR_PROPERTY (hasReachedLast, bool)
Q_TDLIB_PROPERTY_ID53 (lastNotifiedMessageId)
Q_TDLIB_PROPERTY_ID53 (lastReceivedMessageId)
Q_TDLIB_PROPERTY_ID53 (oldestFetchedMessageId)
Q_TDLIB_PROPERTY_ID53 (newestFetchedMessageId)
QML_READONLY_PTR_PROPERTY (firstUnreadMessageItem, QtTdLibMessage)
public:
explicit QtTdLibChat (const qint64 id = 0, QObject * parent = Q_NULLPTR);
......@@ -252,7 +268,8 @@ public:
QHash<qint64, QtTdLibMessage *> allMessages;
Q_INVOKABLE QtTdLibMessage * getMessageItemById (const QString & id) const;
Q_INVOKABLE QtTdLibMessage * getMessageItemById (const QString & id) const;
Q_INVOKABLE QtTdLibMessageRefWatcher * getMessageRefById (const QString & id);
QtTdLibMessage * getMessageItemById (const qint64 id) const;
......@@ -263,13 +280,29 @@ public:
signals:
void displayRequested (void);
void messageItemAdded (QtTdLibMessage * messageItem);
protected slots:
void refreshNotification (void);
void findFirstNewMessage (void);
private:
QTimer m_timer;
Notification m_notif;
};
class QtTdLibMessageRefWatcher : public QObject {
Q_OBJECT
QML_READONLY_PTR_PROPERTY (messageItem, QtTdLibMessage)
public:
explicit QtTdLibMessageRefWatcher (const qint64 messageId = 0, QtTdLibChat * parent = Q_NULLPTR);
protected slots:
void onMessageItemAdded (QtTdLibMessage * messageItem);
private:
const qint64 m_messageId;
};
#endif // QTTDCHAT_H
......@@ -145,7 +145,7 @@ public:
class QtTdLibPhoto : public QtTdLibAbstractInt64IdObject, public FactoryInt64Id<QtTdLibPhoto> {
Q_OBJECT
Q_TDLIB_PROPERTY_BOOL (hasStickers)
QML_OBJMODEL_PROPERTY (sizes, QtTdLibPhotoSize)
QML_OBJMODEL_PROPERTY (sizes, QtTdLibPhotoSize)
public:
explicit QtTdLibPhoto (const qint64 id = 0, QObject * parent = Q_NULLPTR);
......
This diff is collapsed.
......@@ -33,7 +33,7 @@ class DBusAdaptor: public QDBusAbstractAdaptor {
Q_OBJECT
Q_CLASSINFO ("D-Bus Interface", "org.uniqueconception.telegrame")
Q_CLASSINFO ("D-Bus Introspection", ""
" <interface name=\"org.blacksailer.depecher\">\n"
" <interface name=\"org.uniqueconception.telegrame\">\n"
" <method name=\"showChat\">\n"
" <arg direction=\"in\" type=\"x\" name=\"chatId\"/>\n"
" <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\"/>\n"
......@@ -50,20 +50,21 @@ public slots:
class QtTdLibGlobal : public QObject {
Q_OBJECT
Q_TDLIB_PROPERTY_SUBOBJECT (connectionState, QtTdLibConnectionState)
Q_TDLIB_PROPERTY_SUBOBJECT (authorizationState, QtTdLibAuthorizationState)
QML_OBJMODEL_PROPERTY (chatsList, QtTdLibChat)
QML_OBJMODEL_PROPERTY (stickerSetsList, QtTdLibStickerSetInfo)
QML_OBJMODEL_PROPERTY (savedAnimationsList, QtTdLibAnimation)
QML_READONLY_VAR_PROPERTY (recordingDuration, int)
QML_READONLY_VAR_PROPERTY (unreadMessagesCount, int)
QML_READONLY_VAR_PROPERTY (selectedPhotosCount, int)
QML_READONLY_VAR_PROPERTY (selectedVideosCount, int)
QML_READONLY_PTR_PROPERTY (currentChat, QtTdLibChat)
QML_WRITABLE_PTR_PROPERTY (currentMessageContent, QtTdLibMessageContent)
QML_CONSTANT_PTR_PROPERTY (sortedChatsList, QSortFilterProxyModel)
QML_CONSTANT_PTR_PROPERTY (dbusAdaptor, DBusAdaptor)
QML_WRITABLE_VAR_PROPERTY (sendTextOnEnterKey, bool)
Q_TDLIB_PROPERTY_SUBOBJECT (connectionState, QtTdLibConnectionState)
Q_TDLIB_PROPERTY_SUBOBJECT (authorizationState, QtTdLibAuthorizationState)
QML_OBJMODEL_PROPERTY (chatsList, QtTdLibChat)
QML_OBJMODEL_PROPERTY (stickerSetsList, QtTdLibStickerSetInfo)
QML_OBJMODEL_PROPERTY (savedAnimationsList, QtTdLibAnimation)
QML_READONLY_VAR_PROPERTY (recordingDuration, int)
QML_READONLY_VAR_PROPERTY (unreadMessagesCount, int)
QML_READONLY_VAR_PROPERTY (selectedPhotosCount, int)
QML_READONLY_VAR_PROPERTY (selectedVideosCount, int)
QML_READONLY_PTR_PROPERTY (currentChat, QtTdLibChat)
QML_WRITABLE_PTR_PROPERTY (currentMessageContent, QtTdLibMessageContent)
QML_CONSTANT_PTR_PROPERTY (sortedChatsList, QSortFilterProxyModel)
QML_CONSTANT_PTR_PROPERTY (dbusAdaptor, DBusAdaptor)
QML_WRITABLE_VAR_PROPERTY (sendTextOnEnterKey, bool)
QML_WRITABLE_CSTREF_PROPERTY (replyingToMessageId, QString)
public:
explicit QtTdLibGlobal (QObject * parent = Q_NULLPTR);
......@@ -71,6 +72,14 @@ public:
static QObject * qmlSingletonFactory (QQmlEngine * qmlEngine, QJSEngine * scriptEngine);
enum LoadMode {
LOAD_NONE = 0,
LOAD_INIT,
LOAD_NEWER,
LOAD_OLDER,
};
Q_ENUM (LoadMode)
Q_INVOKABLE void send (const QJsonObject & json) const;
Q_INVOKABLE QJsonObject exec (const QJsonObject & json) const;
......@@ -110,7 +119,10 @@ public:
Q_INVOKABLE void markAllMessagesAsRead (QtTdLibChat * chatItem);
Q_INVOKABLE void togglePinChat (QtTdLibChat * chatItem);
Q_INVOKABLE void loadMoreMessages (QtTdLibChat * chatItem, const int count);
Q_INVOKABLE void loadSingleMessageRef (QtTdLibChat * chatItem, const qint64 messageId);
Q_INVOKABLE void loadInitialMessage (QtTdLibChat * chatItem, const qint64 messageId);
Q_INVOKABLE void loadOlderMessages (QtTdLibChat * chatItem, const int count = 15);
Q_INVOKABLE void loadNewerMessages (QtTdLibChat * chatItem, const int count = 15);
Q_INVOKABLE void removeMessage (QtTdLibChat * chatItem, QtTdLibMessage * messageItem, const bool forAll = false);
......@@ -131,17 +143,14 @@ public:
signals:
void showChatRequested (const QString & chatId);
void autoScrollDownRequested (const bool active);
protected:
void onFrame (const QJsonObject & json);
void onPrefetcherTick (void);
private:
const QString DBUS_SERVICE_NAME;