Show pinned chat icon in list
This commit is contained in:
parent
26c1677993
commit
9299205379
11 changed files with 67 additions and 8 deletions
|
@ -25,6 +25,7 @@ PhotoTextsListItem {
|
||||||
unreadCount: unread_count
|
unreadCount: unread_count
|
||||||
isSecret: ( chat_type === TelegramAPI.ChatTypeSecret )
|
isSecret: ( chat_type === TelegramAPI.ChatTypeSecret )
|
||||||
isMarkedAsUnread: is_marked_as_unread
|
isMarkedAsUnread: is_marked_as_unread
|
||||||
|
isPinned: is_pinned
|
||||||
|
|
||||||
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
|
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ ListItem {
|
||||||
property bool isSecret: false
|
property bool isSecret: false
|
||||||
property bool isVerified: false
|
property bool isVerified: false
|
||||||
property bool isMarkedAsUnread: false
|
property bool isMarkedAsUnread: false
|
||||||
|
property bool isPinned: false
|
||||||
property alias pictureThumbnail: pictureThumbnail
|
property alias pictureThumbnail: pictureThumbnail
|
||||||
|
|
||||||
contentHeight: mainRow.height + separator.height + 2 * Theme.paddingMedium
|
contentHeight: mainRow.height + separator.height + 2 * Theme.paddingMedium
|
||||||
|
@ -49,6 +50,24 @@ ListItem {
|
||||||
height: parent.width
|
height: parent.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: chatPinnedBackground
|
||||||
|
color: Theme.overlayBackgroundColor
|
||||||
|
width: Theme.fontSizeExtraLarge
|
||||||
|
height: Theme.fontSizeExtraLarge
|
||||||
|
anchors.top: parent.top
|
||||||
|
radius: parent.width / 2
|
||||||
|
visible: chatListViewItem.isPinned
|
||||||
|
}
|
||||||
|
|
||||||
|
Image {
|
||||||
|
source: "image://theme/icon-s-favorite"
|
||||||
|
height: Theme.fontSizeMedium
|
||||||
|
width: Theme.fontSizeMedium
|
||||||
|
anchors.centerIn: chatPinnedBackground
|
||||||
|
visible: chatListViewItem.isPinned
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: chatSecretBackground
|
id: chatSecretBackground
|
||||||
color: Theme.overlayBackgroundColor
|
color: Theme.overlayBackgroundColor
|
||||||
|
|
|
@ -58,7 +58,7 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "Fernschreiber 0.6"
|
text: "Fernschreiber 0.6.1"
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
font.pixelSize: Theme.fontSizeExtraLarge
|
font.pixelSize: Theme.fontSizeExtraLarge
|
||||||
anchors {
|
anchors {
|
||||||
|
|
|
@ -11,8 +11,8 @@ Name: harbour-fernschreiber
|
||||||
# << macros
|
# << macros
|
||||||
|
|
||||||
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
||||||
Version: 0.6
|
Version: 0.6.1
|
||||||
Release: 66
|
Release: 1
|
||||||
Group: Qt/Qt
|
Group: Qt/Qt
|
||||||
License: LICENSE
|
License: LICENSE
|
||||||
URL: http://werkwolf.eu/
|
URL: http://werkwolf.eu/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Name: harbour-fernschreiber
|
Name: harbour-fernschreiber
|
||||||
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
||||||
Version: 0.6
|
Version: 0.6.1
|
||||||
Release: 66
|
Release: 1
|
||||||
# The contents of the Group field should be one of the groups listed here:
|
# The contents of the Group field should be one of the groups listed here:
|
||||||
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
|
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
|
||||||
Group: Qt/Qt
|
Group: Qt/Qt
|
||||||
|
|
|
@ -48,6 +48,7 @@ namespace {
|
||||||
const QString IS_CHANNEL("is_channel");
|
const QString IS_CHANNEL("is_channel");
|
||||||
const QString IS_VERIFIED("is_verified");
|
const QString IS_VERIFIED("is_verified");
|
||||||
const QString IS_MARKED_AS_UNREAD("is_marked_as_unread");
|
const QString IS_MARKED_AS_UNREAD("is_marked_as_unread");
|
||||||
|
const QString IS_PINNED("is_pinned");
|
||||||
const QString PINNED_MESSAGE_ID("pinned_message_id");
|
const QString PINNED_MESSAGE_ID("pinned_message_id");
|
||||||
const QString _TYPE("@type");
|
const QString _TYPE("@type");
|
||||||
const QString SECRET_CHAT_ID("secret_chat_id");
|
const QString SECRET_CHAT_ID("secret_chat_id");
|
||||||
|
@ -77,6 +78,7 @@ public:
|
||||||
bool isChannel() const;
|
bool isChannel() const;
|
||||||
bool isHidden() const;
|
bool isHidden() const;
|
||||||
bool isMarkedAsUnread() const;
|
bool isMarkedAsUnread() const;
|
||||||
|
bool isPinned() const;
|
||||||
bool updateUnreadCount(int unreadCount);
|
bool updateUnreadCount(int unreadCount);
|
||||||
bool updateLastReadInboxMessageId(qlonglong messageId);
|
bool updateLastReadInboxMessageId(qlonglong messageId);
|
||||||
QVector<int> updateLastMessage(const QVariantMap &message);
|
QVector<int> updateLastMessage(const QVariantMap &message);
|
||||||
|
@ -272,6 +274,11 @@ bool ChatListModel::ChatData::isMarkedAsUnread() const
|
||||||
return chatData.value(IS_MARKED_AS_UNREAD).toBool();
|
return chatData.value(IS_MARKED_AS_UNREAD).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatListModel::ChatData::isPinned() const
|
||||||
|
{
|
||||||
|
return chatData.value(IS_PINNED).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatListModel::ChatData::updateUnreadCount(int count)
|
bool ChatListModel::ChatData::updateUnreadCount(int count)
|
||||||
{
|
{
|
||||||
const int prevUnreadCount(unreadCount());
|
const int prevUnreadCount(unreadCount());
|
||||||
|
@ -364,6 +371,7 @@ ChatListModel::ChatListModel(TDLibWrapper *tdLibWrapper) : showHiddenChats(false
|
||||||
connect(tdLibWrapper, SIGNAL(secretChatReceived(qlonglong, QVariantMap)), this, SLOT(handleSecretChatUpdated(qlonglong, QVariantMap)));
|
connect(tdLibWrapper, SIGNAL(secretChatReceived(qlonglong, QVariantMap)), this, SLOT(handleSecretChatUpdated(qlonglong, QVariantMap)));
|
||||||
connect(tdLibWrapper, SIGNAL(chatTitleUpdated(QString, QString)), this, SLOT(handleChatTitleUpdated(QString, QString)));
|
connect(tdLibWrapper, SIGNAL(chatTitleUpdated(QString, QString)), this, SLOT(handleChatTitleUpdated(QString, QString)));
|
||||||
connect(tdLibWrapper, SIGNAL(chatIsMarkedAsUnreadUpdated(qlonglong, bool)), this, SLOT(handleChatIsMarkedAsUnreadUpdated(qlonglong, bool)));
|
connect(tdLibWrapper, SIGNAL(chatIsMarkedAsUnreadUpdated(qlonglong, bool)), this, SLOT(handleChatIsMarkedAsUnreadUpdated(qlonglong, bool)));
|
||||||
|
connect(tdLibWrapper, SIGNAL(chatPinnedUpdated(qlonglong, bool)), this, SLOT(handleChatPinnedUpdated(qlonglong, bool)));
|
||||||
connect(tdLibWrapper, SIGNAL(chatDraftMessageUpdated(qlonglong, QVariantMap, QString)), this, SLOT(handleChatDraftMessageUpdated(qlonglong, QVariantMap, QString)));
|
connect(tdLibWrapper, SIGNAL(chatDraftMessageUpdated(qlonglong, QVariantMap, QString)), this, SLOT(handleChatDraftMessageUpdated(qlonglong, QVariantMap, QString)));
|
||||||
|
|
||||||
// Don't start the timer until we have at least one chat
|
// Don't start the timer until we have at least one chat
|
||||||
|
@ -399,6 +407,7 @@ QHash<int,QByteArray> ChatListModel::roleNames() const
|
||||||
roles.insert(ChatListModel::RoleIsVerified, "is_verified");
|
roles.insert(ChatListModel::RoleIsVerified, "is_verified");
|
||||||
roles.insert(ChatListModel::RoleIsChannel, "is_channel");
|
roles.insert(ChatListModel::RoleIsChannel, "is_channel");
|
||||||
roles.insert(ChatListModel::RoleIsMarkedAsUnread, "is_marked_as_unread");
|
roles.insert(ChatListModel::RoleIsMarkedAsUnread, "is_marked_as_unread");
|
||||||
|
roles.insert(ChatListModel::RoleIsPinned, "is_pinned");
|
||||||
roles.insert(ChatListModel::RoleFilter, "filter");
|
roles.insert(ChatListModel::RoleFilter, "filter");
|
||||||
roles.insert(ChatListModel::RoleDraftMessageDate, "draft_message_date");
|
roles.insert(ChatListModel::RoleDraftMessageDate, "draft_message_date");
|
||||||
roles.insert(ChatListModel::RoleDraftMessageText, "draft_message_text");
|
roles.insert(ChatListModel::RoleDraftMessageText, "draft_message_text");
|
||||||
|
@ -432,6 +441,7 @@ QVariant ChatListModel::data(const QModelIndex &index, int role) const
|
||||||
case ChatListModel::RoleIsVerified: return data->verified;
|
case ChatListModel::RoleIsVerified: return data->verified;
|
||||||
case ChatListModel::RoleIsChannel: return data->isChannel();
|
case ChatListModel::RoleIsChannel: return data->isChannel();
|
||||||
case ChatListModel::RoleIsMarkedAsUnread: return data->isMarkedAsUnread();
|
case ChatListModel::RoleIsMarkedAsUnread: return data->isMarkedAsUnread();
|
||||||
|
case ChatListModel::RoleIsPinned: return data->isPinned();
|
||||||
case ChatListModel::RoleFilter: return QString(data->title() + " " + data->senderMessageText()).trimmed();
|
case ChatListModel::RoleFilter: return QString(data->title() + " " + data->senderMessageText()).trimmed();
|
||||||
case ChatListModel::RoleDraftMessageText: return data->draftMessageText();
|
case ChatListModel::RoleDraftMessageText: return data->draftMessageText();
|
||||||
case ChatListModel::RoleDraftMessageDate: return data->draftMessageDate();
|
case ChatListModel::RoleDraftMessageDate: return data->draftMessageDate();
|
||||||
|
@ -850,6 +860,26 @@ void ChatListModel::handleChatTitleUpdated(const QString &chatId, const QString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatListModel::handleChatPinnedUpdated(qlonglong chatId, bool chatIsPinned)
|
||||||
|
{
|
||||||
|
if (chatIndexMap.contains(chatId)) {
|
||||||
|
LOG("Updating chat is pinned for" << chatId << chatIsPinned);
|
||||||
|
const int chatIndex = chatIndexMap.value(chatId);
|
||||||
|
ChatData *chat = chatList.at(chatIndex);
|
||||||
|
chat->chatData.insert(IS_PINNED, chatIsPinned);
|
||||||
|
QVector<int> changedRoles;
|
||||||
|
changedRoles.append(ChatListModel::RoleIsPinned);
|
||||||
|
const QModelIndex modelIndex(index(chatIndex));
|
||||||
|
emit dataChanged(modelIndex, modelIndex, changedRoles);
|
||||||
|
} else {
|
||||||
|
ChatData *chat = hiddenChats.value(chatId);
|
||||||
|
if (chat) {
|
||||||
|
LOG("Updating chat is pinned for hidden chat" << chatId);
|
||||||
|
chat->chatData.insert(IS_PINNED, chatIsPinned);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatListModel::handleChatIsMarkedAsUnreadUpdated(qlonglong chatId, bool chatIsMarkedAsUnread)
|
void ChatListModel::handleChatIsMarkedAsUnreadUpdated(qlonglong chatId, bool chatIsMarkedAsUnread)
|
||||||
{
|
{
|
||||||
if (chatIndexMap.contains(chatId)) {
|
if (chatIndexMap.contains(chatId)) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
RoleIsVerified,
|
RoleIsVerified,
|
||||||
RoleIsChannel,
|
RoleIsChannel,
|
||||||
RoleIsMarkedAsUnread,
|
RoleIsMarkedAsUnread,
|
||||||
|
RoleIsPinned,
|
||||||
RoleFilter,
|
RoleFilter,
|
||||||
RoleDraftMessageText,
|
RoleDraftMessageText,
|
||||||
RoleDraftMessageDate
|
RoleDraftMessageDate
|
||||||
|
@ -79,6 +80,7 @@ private slots:
|
||||||
void handleGroupUpdated(qlonglong groupId);
|
void handleGroupUpdated(qlonglong groupId);
|
||||||
void handleSecretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
|
void handleSecretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
|
||||||
void handleChatTitleUpdated(const QString &chatId, const QString &title);
|
void handleChatTitleUpdated(const QString &chatId, const QString &title);
|
||||||
|
void handleChatPinnedUpdated(qlonglong chatId, bool chatIsPinned);
|
||||||
void handleChatIsMarkedAsUnreadUpdated(qlonglong chatId, bool chatIsMarkedAsUnread);
|
void handleChatIsMarkedAsUnreadUpdated(qlonglong chatId, bool chatIsMarkedAsUnread);
|
||||||
void handleChatDraftMessageUpdated(qlonglong chatId, const QVariantMap &draftMessage, const QString &order);
|
void handleChatDraftMessageUpdated(qlonglong chatId, const QVariantMap &draftMessage, const QString &order);
|
||||||
void handleRelativeTimeRefreshTimer();
|
void handleRelativeTimeRefreshTimer();
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace {
|
||||||
const QString POSITIONS("positions");
|
const QString POSITIONS("positions");
|
||||||
const QString PHOTO("photo");
|
const QString PHOTO("photo");
|
||||||
const QString ORDER("order");
|
const QString ORDER("order");
|
||||||
|
const QString IS_PINNED("is_pinned");
|
||||||
const QString BASIC_GROUP("basic_group");
|
const QString BASIC_GROUP("basic_group");
|
||||||
const QString SUPERGROUP("supergroup");
|
const QString SUPERGROUP("supergroup");
|
||||||
const QString LAST_MESSAGE("last_message");
|
const QString LAST_MESSAGE("last_message");
|
||||||
|
@ -287,9 +288,12 @@ void TDLibReceiver::processUpdateChatOrder(const QVariantMap &receivedInformatio
|
||||||
void TDLibReceiver::processUpdateChatPosition(const QVariantMap &receivedInformation)
|
void TDLibReceiver::processUpdateChatPosition(const QVariantMap &receivedInformation)
|
||||||
{
|
{
|
||||||
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
||||||
const QString order(receivedInformation.value(POSITION).toMap().value(ORDER).toString());
|
QVariantMap positionMap = receivedInformation.value(POSITION).toMap();
|
||||||
LOG("Chat position updated for ID" << chat_id << "new order" << order);
|
const QString order(positionMap.value(ORDER).toString());
|
||||||
|
bool is_pinned = positionMap.value(IS_PINNED).toBool();
|
||||||
|
LOG("Chat position updated for ID" << chat_id << "new order" << order << "is pinned" << is_pinned);
|
||||||
emit chatOrderUpdated(chat_id, order);
|
emit chatOrderUpdated(chat_id, order);
|
||||||
|
emit chatPinnedUpdated(chat_id.toLongLong(), is_pinned);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDLibReceiver::processUpdateChatReadInbox(const QVariantMap &receivedInformation)
|
void TDLibReceiver::processUpdateChatReadInbox(const QVariantMap &receivedInformation)
|
||||||
|
|
|
@ -49,6 +49,7 @@ signals:
|
||||||
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
|
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
|
||||||
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
|
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
|
||||||
void chatOrderUpdated(const QString &chatId, const QString &order);
|
void chatOrderUpdated(const QString &chatId, const QString &order);
|
||||||
|
void chatPinnedUpdated(qlonglong chatId, bool isPinned);
|
||||||
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
|
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
|
||||||
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
|
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
|
||||||
void basicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
|
void basicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
|
||||||
|
|
|
@ -120,6 +120,7 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface,
|
||||||
connect(this->tdLibReceiver, SIGNAL(chatPermissionsUpdated(QString, QVariantMap)), this, SIGNAL(chatPermissionsUpdated(QString, QVariantMap)));
|
connect(this->tdLibReceiver, SIGNAL(chatPermissionsUpdated(QString, QVariantMap)), this, SIGNAL(chatPermissionsUpdated(QString, QVariantMap)));
|
||||||
connect(this->tdLibReceiver, SIGNAL(chatPhotoUpdated(qlonglong, QVariantMap)), this, SIGNAL(chatPhotoUpdated(qlonglong, QVariantMap)));
|
connect(this->tdLibReceiver, SIGNAL(chatPhotoUpdated(qlonglong, QVariantMap)), this, SIGNAL(chatPhotoUpdated(qlonglong, QVariantMap)));
|
||||||
connect(this->tdLibReceiver, SIGNAL(chatTitleUpdated(QString, QString)), this, SIGNAL(chatTitleUpdated(QString, QString)));
|
connect(this->tdLibReceiver, SIGNAL(chatTitleUpdated(QString, QString)), this, SIGNAL(chatTitleUpdated(QString, QString)));
|
||||||
|
connect(this->tdLibReceiver, SIGNAL(chatPinnedUpdated(qlonglong, bool)), this, SIGNAL(chatPinnedUpdated(qlonglong, bool)));
|
||||||
connect(this->tdLibReceiver, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)), this, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)));
|
connect(this->tdLibReceiver, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)), this, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)));
|
||||||
connect(this->tdLibReceiver, SIGNAL(messageIsPinnedUpdated(qlonglong, qlonglong, bool)), this, SLOT(handleMessageIsPinnedUpdated(qlonglong, qlonglong, bool)));
|
connect(this->tdLibReceiver, SIGNAL(messageIsPinnedUpdated(qlonglong, qlonglong, bool)), this, SLOT(handleMessageIsPinnedUpdated(qlonglong, qlonglong, bool)));
|
||||||
connect(this->tdLibReceiver, SIGNAL(usersReceived(QString, QVariantList, int)), this, SIGNAL(usersReceived(QString, QVariantList, int)));
|
connect(this->tdLibReceiver, SIGNAL(usersReceived(QString, QVariantList, int)), this, SIGNAL(usersReceived(QString, QVariantList, int)));
|
||||||
|
@ -1467,7 +1468,7 @@ void TDLibWrapper::setInitialParameters()
|
||||||
QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat);
|
QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat);
|
||||||
initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString());
|
initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString());
|
||||||
initialParameters.insert("system_version", QSysInfo::prettyProductName());
|
initialParameters.insert("system_version", QSysInfo::prettyProductName());
|
||||||
initialParameters.insert("application_version", "0.6");
|
initialParameters.insert("application_version", "0.6.1");
|
||||||
initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer());
|
initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer());
|
||||||
// initialParameters.insert("use_test_dc", true);
|
// initialParameters.insert("use_test_dc", true);
|
||||||
requestObject.insert("parameters", initialParameters);
|
requestObject.insert("parameters", initialParameters);
|
||||||
|
|
|
@ -210,6 +210,7 @@ signals:
|
||||||
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
|
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
|
||||||
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
|
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
|
||||||
void chatOrderUpdated(const QString &chatId, const QString &order);
|
void chatOrderUpdated(const QString &chatId, const QString &order);
|
||||||
|
void chatPinnedUpdated(qlonglong chatId, bool isPinned);
|
||||||
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
|
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
|
||||||
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
|
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
|
||||||
void userUpdated(const QString &userId, const QVariantMap &userInformation);
|
void userUpdated(const QString &userId, const QVariantMap &userInformation);
|
||||||
|
|
Loading…
Reference in a new issue