-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LNJ
committed
Aug 3, 2017
1 parent
ff7ce45
commit f010784
Showing
4 changed files
with
113 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Kaidan - A user-friendly XMPP client for every device! | ||
* | ||
* Copyright (C) 2017 LNJ <git@lnj.li> | ||
* | ||
* Kaidan is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Kaidan is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import QtQml 2.0 | ||
import QtQuick 2.0 | ||
import QtQuick.Layouts 1.3 | ||
import QtQuick.Controls 2.0 as Controls | ||
import org.kde.kirigami 2.0 as Kirigami | ||
|
||
Kirigami.SwipeListItem { | ||
id: listItem | ||
topPadding: Kirigami.Units.smallSpacing * 1.5 | ||
height: Kirigami.Units.gridUnit * 3.5 | ||
|
||
RowLayout { | ||
spacing: Kirigami.Units.gridUnit * 0.5 | ||
|
||
// left side: Avatar | ||
Image { | ||
source: kaidan.getResourcePath("images/fallback-avatar.svg") | ||
fillMode: Image.PreserveAspectFit | ||
Layout.preferredHeight: parent.height | ||
Layout.preferredWidth: parent.height | ||
} | ||
// right side | ||
ColumnLayout { | ||
// top | ||
RowLayout { | ||
// contact name | ||
Kirigami.Heading { | ||
// use the Name or JID | ||
text: model.name ? model.name : model.jid | ||
level: 3 | ||
Layout.fillWidth: true | ||
} | ||
// unread message counter | ||
Rectangle { | ||
id: counterCircle | ||
visible: model.unreadMessages > 0 | ||
Layout.preferredHeight: Kirigami.Units.gridUnit * 1.25 | ||
Layout.preferredWidth: Kirigami.Units.gridUnit * 1.25 | ||
radius: counterCircle.height * 0.5 | ||
color: "#4CAF50" | ||
|
||
Text { | ||
id: msgCounter | ||
text: model.unreadMessages | ||
color: "white" | ||
anchors.centerIn: parent | ||
} | ||
} | ||
} | ||
// bottom | ||
Kirigami.Label { | ||
Layout.fillWidth: true | ||
text: model.lastMessage | ||
} | ||
} | ||
|
||
// placeholder | ||
Item { | ||
width: Kirigami.Units.gridUnit * 2.5 | ||
} | ||
} | ||
|
||
onClicked: { | ||
// first push the chat page | ||
pageStack.push(chatPage, { | ||
"chatName": (model.name ? model.name : model.jid), | ||
"recipientJid": model.jid | ||
}); | ||
|
||
// then set the message filter for this jid | ||
// this will update the unread message count, | ||
// which will update the roster and will reset the | ||
// model variable | ||
kaidan.chatPartner = model.jid; | ||
} | ||
|
||
actions: [ | ||
Kirigami.Action { | ||
iconName: "bookmark-remove" | ||
onTriggered: { | ||
removeContactSheet.jid = model.jid; | ||
removeContactSheet.open(); | ||
} | ||
} | ||
] | ||
} |