Skip to content
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
6 changes: 4 additions & 2 deletions depecher/dbus/ChatShareAdaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ static const QString c_dbusObjectPath = QStringLiteral("/org/blacksailer/depeche
static const QString c_dbusInterface = QStringLiteral("org.blacksailer.depecher.share");
static const QString c_extraName = QStringLiteral("dbus");

ChatShareAdaptor::ChatShareAdaptor(QObject *parent) : QObject(parent)
ChatShareAdaptor::ChatShareAdaptor(QObject *parent) : QObject(parent),
m_dbusConnection(NULL)
{
m_dbusServer = new QDBusServer("unix:abstract=depecher-dbus", this);
connect(m_dbusServer, &QDBusServer::newConnection,
Expand Down Expand Up @@ -83,5 +84,6 @@ QDBusVariant ChatShareAdaptor::getChatList(const qint64 lastChatId, const qint64

ChatShareAdaptor::~ChatShareAdaptor()
{
delete m_dbusConnection;
if (m_dbusConnection)
delete m_dbusConnection;
}
2 changes: 2 additions & 0 deletions depecher/depecher.pro
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ CONFIG (debug, debug|release) {
MOC_DIR = build/mocs

SOURCES += \
src/KeysEater.cpp \
src/main.cpp \
src/FileWorker.cpp \
ModelTest.cpp \
Expand Down Expand Up @@ -159,6 +160,7 @@ HEADERS += \
ModelTest.hpp \
src/DBusAdaptor.hpp \
dbus/DepecherAdaptor.hpp \
src/KeysEater.h \
src/singletons/PageAppStarter.hpp \
src/singletons/DNSTXTLookup.hpp \
src/fileGeneratedHandlers/FileGeneratedHandler.hpp \
Expand Down
2 changes: 1 addition & 1 deletion depecher/qml/pages/DialogsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Page {
id: page
allowedOrientations: Orientation.All

property string titleHeader:Qt.application.version
property string titleHeader: "Depecher"
//for search in pageStack
property bool __chat_page: true
property string _opened_chat_id: ""
Expand Down
83 changes: 67 additions & 16 deletions depecher/qml/pages/GroupInfoPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,53 @@ import QtQuick 2.6
import Sailfish.Silica 1.0
import TelegramDAO 1.0
import tdlibQtEnums 1.0
import TelegramModels 1.0
import "items"
import "items/filter_delegates"
Page {

id: page
property alias chat_id: groupInfo.chatId
signal filterChatMembersModelChanged(var membersModel)

BasicGroupInfo {
id:groupInfo
onMembersModelChanged: {
membersList.model = groupInfo.membersModel
filterMembersModel.sourceModel = groupInfo.membersModel
page.filterChatMembersModelChanged(filterMembersModel)
}
}
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: contentWrapper.height + header.height
PageHeader {
id:header
title:qsTr("Group info")
}
PullDownMenu {
visible: groupInfo.inviteLink
MenuItem {
text: groupInfo.inviteLink
}
}

Connections {
target: page
onStatusChanged: {
if (page.status == PageStatus.Inactive) {
searchField.text = ""
searchField.focus = false
}
}
}

Column {
id:contentWrapper
width: parent.width
anchors.top: header.bottom
Row {
width: parent.width
width: parent.width - 2 * x
x:Theme.horizontalPageMargin
CircleImage {
id: avatar
width: Theme.itemSizeLarge
Expand Down Expand Up @@ -103,16 +121,16 @@ Page {
width: 1
height:Theme.paddingLarge
}
SharedContent {
chatId:groupInfo.chatId
SharedContent {
chatId:groupInfo.chatId

photoCount:groupInfo.photoCount
videoCount:groupInfo.videoCount
fileCount:groupInfo.fileCount
audioCount:groupInfo.audioCount
linkCount:groupInfo.linkCount
voiceCount:groupInfo.voiceCount
}
photoCount:groupInfo.photoCount
videoCount:groupInfo.videoCount
fileCount:groupInfo.fileCount
audioCount:groupInfo.audioCount
linkCount:groupInfo.linkCount
voiceCount:groupInfo.voiceCount
}
Item {
width: 1
height:Theme.paddingLarge
Expand Down Expand Up @@ -142,24 +160,53 @@ SharedContent {
}
}

SearchField {
id: searchField
width: membersList.width
placeholderText: "Search"
inputMethodHints: Qt.ImhNoAutoUppercase
focusOutBehavior: FocusBehavior.ClearItemFocus
autoScrollEnabled: false

Component.onCompleted: membersList.searchField = searchField

onFocusChanged: {
flickable.scrollToBottom()
}

onTextChanged: {
filterMembersModel.search = text
flickable.scrollToBottom()
}
}

SilicaListView {
id:membersList
width: parent.width
height: 6 * Theme.itemSizeSmall
height: page.height - searchField.height
interactive: flickable.atYEnd || !membersList.atYBeginning
clip:true
property SearchField searchField

model: FilterChatMembersModel {
id: filterMembersModel
showDeleted: page.visible
}
delegate: BackgroundItem {
width: parent.width
height: Theme.itemSizeSmall
Row {
width: parent.width - 2 * x
height: parent.height
anchors.verticalCenter: parent.verticalCenter
x: Theme.horizontalPageMargin
CircleImage {
id:userPhoto
source: avatar
source: avatar ? avatar : ""
fallbackItemVisible: avatar == undefined
fallbackText:name.charAt(0)
anchors.verticalCenter: parent.verticalCenter
width: parent.height - 3*Theme.paddingSmall
}
Item {
width: Theme.paddingLarge
Expand All @@ -169,15 +216,19 @@ SharedContent {
width: parent.width - userPhoto.width
anchors.verticalCenter: parent.verticalCenter
Label {
text: name
property string mText: model.deleted ? "Deleted account" : (name + (username ? " @" + username : ""))
text: membersList.searchField.text.length ?
Theme.highlightText(mText, filterMembersModel.search, Theme.highlightColor) : mText
font.pixelSize: Theme.fontSizeMedium
width:parent.width
width: parent.width
}
Label {
font.pixelSize: Theme.fontSizeTiny
color:Theme.secondaryColor
text: online_status
width:parent.width
visible: text.length
height: !visible ? 0 : contentHeight
}
}
}
Expand Down
81 changes: 67 additions & 14 deletions depecher/qml/pages/MessagingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Sailfish.Silica 1.0
import TelegramModels 1.0
import QtFeedback 5.0
import tdlibQtEnums 1.0
import depecherUtils 1.0
import Nemo.Notifications 1.0
import Nemo.Configuration 1.0
import "../js/utils.js" as Utils
Expand All @@ -14,16 +15,33 @@ Page {
property alias chatId: messagingModel.peerId
property var forwardMessages: ({})
property var arrayIndex: []
property FilterChatMembersModel filterChatMembersModel: null
property bool infoPageLoaded: false

onStatusChanged: {
if(status == PageStatus.Active) {
if(messagingModel.chatType["type"] == TdlibState.BasicGroup)
pageStack.pushAttached(Qt.resolvedUrl("GroupInfoPage.qml"),{chat_id:parseFloat(chatId)})
else if(messagingModel.chatType["type"] == TdlibState.Secret || messagingModel.chatType["type"] == TdlibState.Private)
if (!infoPageLoaded && status == PageStatus.Active) {
infoPageLoaded = true
if(messagingModel.chatType["type"] == TdlibState.BasicGroup) {
var infoPage = pageStack.pushAttached(Qt.resolvedUrl("GroupInfoPage.qml"),{chat_id:parseFloat(chatId)})
infoPage.filterChatMembersModelChanged.connect(function (membersModel) {
page.filterChatMembersModel = membersModel
})
} else if (messagingModel.chatType["type"] == TdlibState.Secret || messagingModel.chatType["type"] == TdlibState.Private) {
pageStack.pushAttached(Qt.resolvedUrl("UserPage.qml"),{user_id:parseInt(chatId)})
else if (messagingModel.chatType["type"] == TdlibState.Supergroup)// && messagingModel.chatType["is_channel"])
pageStack.pushAttached(Qt.resolvedUrl("UserPage.qml"),{chat_id:parseFloat(chatId),hideOpenMenu:true})
} else if (messagingModel.chatType["type"] == TdlibState.Supergroup) {// && messagingModel.chatType["is_channel"])
var userPage = pageStack.pushAttached(Qt.resolvedUrl("UserPage.qml"),{chat_id:parseFloat(chatId),hideOpenMenu:true})
userPage.filterChatMembersModelChanged.connect(function (membersModel) {
page.filterChatMembersModel = membersModel
})
}
} else if (status == PageStatus.Inactive) {
if (filterChatMembersModel) {
writer.textArea.state = "text"
writer.textArea.searchMemberStr = ""
writer.textArea.searchMemberStrPos = -1
filterChatMembersModel.search = ""
}
}

}

Notification {
Expand Down Expand Up @@ -106,19 +124,54 @@ Page {
id: writer
rootPage: page
anchors.fill: parent

Timer {
//Because TextBase of TextArea uses Timer for losing focus.
//Let's reuse that =)
id: restoreFocusTimer
interval: 50
onTriggered: writer.textArea.forceActiveFocus()
}

KeysEater {
target: keys.length ? writer.textArea._editor : null
keys: {
if (writer.textArea.state === "searchMember" && writer.chatMembersList.count)
return [Qt.Key_Return, Qt.Key_Enter, Qt.Key_Up, Qt.Key_Down]
else
return sendByEnter.value ? [Qt.Key_Return, Qt.Key_Enter] : []
}

onKeyPressed: {
switch (key) {
case Qt.Key_Up:
writer.chatMembersList.currentIndex = Math.max(writer.chatMembersList.currentIndex - 1, 0)
break
case Qt.Key_Down:
writer.chatMembersList.currentIndex = Math.min(writer.chatMembersList.currentIndex + 1, writer.chatMembersList.count - 1)
break
}
}
}

EnterKey.iconSource: sendByEnter.value ? "image://theme/icon-m-enter-next" : "image://theme/icon-m-enter"
EnterKey.onClicked: {
if(sendByEnter.value) {
//removing on enter clicked symbol - /n
var messageText = textArea.text.slice(0,textArea.cursorPosition-1) + textArea.text.slice(textArea.cursorPosition,textArea.text.length)
sendText(messageText,writer.reply_id)
if (textArea.state === "searchMember" && chatMembersList.currentIndex >= 0) {
var targetCursorPos
var sourceIndex = filterChatMembersModel.sourceIndex(chatMembersList.currentIndex)
var username = filterChatMembersModel.sourceModel.getProperty(sourceIndex, "username")
if (username.length) {
targetCursorPos = textArea.searchMemberStrPos + username.length + 2
textArea.text = text.substring(0, textArea.searchMemberStrPos) + "@" + username + " " + text.substring(textArea.cursorPosition)
} else {
var name = filterChatMembersModel.sourceModel.getProperty(sourceIndex, "name")
targetCursorPos = textArea.searchMemberStrPos + name.length + 1
textArea.text = text.substring(0, textArea.searchMemberStrPos) + name + " " + text.substring(textArea.cursorPosition)
}
textArea.cursorPosition = targetCursorPos
chatMembersList.currentIndex = -1
} else if (sendByEnter.value) {
sendText(textArea.text, writer.reply_id)
}
}
Keys.onUpPressed: {
Expand All @@ -128,9 +181,9 @@ Page {
if (listItems[i].messageEditable) {
listItems[i].triggerEdit()
// break; // break here if you want to edit even if someone answered.
// If the list is scrolling, children change index while looping,
// and it ends up peaking the wrong child.
// Is there any porperty that tells whether it is scrolling?
// If the list is scrolling, children change index while looping,
// and it ends up peaking the wrong child.
// Is there any porperty that tells whether it is scrolling?
}
break;
}
Expand Down
Loading