Commit 3a561ad3 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Huge refactor that improves code style and UI "compact" feel

parent 7dc62d4f
Subproject commit aac46537d3dc072247714096cc9df9cd79762037
Subproject commit 1756d7c3239e3a66b8d8fea3f31d079f161d073c
......@@ -2,7 +2,6 @@
<qresource prefix="/">
<file>qml/harbour-telegrame.qml</file>
<file>qml/cover/CoverPage.qml</file>
<file>qml/InternationalPhoneCodes.js</file>
<file>qml/pages/PageMain.qml</file>
<file>qml/pages/PageChat.qml</file>
<file>qml/components/DelegateDownloadableImage.qml</file>
......@@ -15,5 +14,35 @@
<file>qml/pages/PageAbout.qml</file>
<file>qml/pages/PageContacts.qml</file>
<file>qml/components/DelegateAvatar.qml</file>
<file>qml/components/Helpers.qml</file>
<file>qml/components/DelegateMessageAnimation.qml</file>
<file>qml/components/DelegateMessageAudio.qml</file>
<file>qml/components/DelegateMessageDocument.qml</file>
<file>qml/components/DelegateMessagePhoto.qml</file>
<file>qml/components/DelegateMessageSticker.qml</file>
<file>qml/components/DelegateMessageText.qml</file>
<file>qml/components/DelegateMessageVideo.qml</file>
<file>qml/pages/PageChatInfoBasicGroup.qml</file>
<file>qml/pages/PageChatInfoPrivate.qml</file>
<file>qml/pages/PageChatInfoSupergroup.qml</file>
<file>qml/pages/PageUserInfo.qml</file>
<file>qml/components/DelegateMessageChatJoinByLink.qml</file>
<file>qml/components/DelegateMessageVoiceNote.qml</file>
<file>qml/components/DelegateMessageUnsupported.qml</file>
<file>qml/components/DelegateMessageChatChangePhoto.qml</file>
<file>qml/components/DelegateMessageCall.qml</file>
<file>qml/components/DelegateMessageSupergroupChatCreate.qml</file>
<file>qml/components/DelegateMessageBasicGroupChatCreate.qml</file>
<file>qml/components/DelegateMessagePinMessage.qml</file>
<file>qml/components/DelegateMessageChatContactRegistered.qml</file>
<file>qml/components/DelegateMessageChatUpgradeTo.qml</file>
<file>qml/components/DelegateMessageChatUpgradeFrom.qml</file>
<file>qml/components/DelegateMessageChatChangeTitle.qml</file>
<file>qml/components/DelegateMessageChatDeleteMember.qml</file>
<file>qml/components/DelegateMessageChatAddMembers.qml</file>
<file>qml/components/InternationalPhoneCodes.js</file>
<file>qml/components/DialogCountrySelector.qml</file>
<file>qml/components/DelegateFormattedText.qml</file>
<file>qml/components/DelegateAbstractMessageContent.qml</file>
</qresource>
</RCC>
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
import QtQml.Models 2.2;
ColumnContainer {
id: self;
property int optimalWidth : 0;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property ObjectModel additionalContextMenuItems : null;
}
......@@ -5,6 +5,7 @@ import harbour.Telegrame 1.0;
import QtGraphicalEffects 1.0;
Item {
id: self;
implicitWidth: size;
implicitHeight: size;
......
......@@ -4,6 +4,7 @@ import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
Item {
id: self;
implicitWidth: Theme.iconSizeMedium;
implicitHeight: Theme.iconSizeMedium;
......
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
TextEdit {
id: self;
text: (formattedTextItem ? formattedTextItem.text : "");
color: Theme.primaryColor;
visible: (text !== "");
readOnly: true;
wrapMode: TextEdit.Wrap;
selectByMouse: false;
selectByKeyboard: false;
font.family: Theme.fontFamily;
font.pixelSize: Theme.fontSizeMedium;
onLinkActivated: {
console.log ("LINK", link);
if (link.indexOf ("td:") === 0) {
// TODO : parse and activate
}
else {
Qt.openUrlExternally (link);
}
}
property TD_FormattedText formattedTextItem : null;
TextFormatter {
id: formatter;
entities: (formattedTextItem ? formattedTextItem.entities : null);
textDocument: self.textDocument;
primaryColor: Theme.primaryColor;
secondaryColor: Theme.secondaryColor;
highlightColor: Theme.highlightColor;
}
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
DelegateAbstractMessageContent {
id: self;
optimalWidth: placeholder.implicitWidth;
property TD_MessageAnimation messageContentItem : null;
property bool paused : true;
readonly property TD_FormattedText captionItem : (messageContentItem ? messageContentItem.caption : null);
readonly property TD_Animation animationItem : (messageContentItem ? messageContentItem.animation : null);
readonly property TD_PhotoSize photoSizeItem : (animationItem ? animationItem.thumbnail : null);
HelperFileState {
id: helper;
fileItem: (animationItem ? animationItem.animation : null);
autoDownload: true;
}
Item {
id: placeholder;
implicitWidth: (animationItem ? Math.min (animationItem.width, self.width) : 1);
implicitHeight: (animationItem ? animationItem.height * implicitWidth / animationItem.width : 1);
DelegateDownloadableImage {
fileItem: (photoSizeItem ? photoSizeItem.photo : null);
autoDownload: true;
anchors.fill: parent;
}
MouseArea {
anchors.fill: parent;
onClicked: { paused = !paused; }
}
Loader {
id: loader;
sourceComponent: {
if (animationItem) {
switch (animationItem.mimeType) {
case "video/mp4": return compoAnimationVideo;
case "image/gif": return compoAnimationGif;
}
}
return null;
}
anchors.fill: parent;
}
Image {
source: ((!helper.downloaded && !helper.downloading && helper.downloadable)
? "image://theme/icon-m-cloud-download?#808080"
: ((helper.downloaded && self.paused)
? "image://theme/icon-m-play?#808080"
: ""));
sourceSize: Qt.size (Theme.iconSizeMedium, Theme.iconSizeMedium);
anchors.centerIn: parent;
}
ProgressCircle {
value: helper.progress;
visible: (helper.downloading || helper.uploading);
implicitWidth: BusyIndicatorSize.Medium;
implicitHeight: BusyIndicatorSize.Medium;
anchors.centerIn: parent;
}
}
Component {
id: compoAnimationGif;
AnimatedImage {
cache: true;
paused: self.paused;
smooth: true;
mipmap: true;
source: helper.url;
fillMode: Image.PreserveAspectFit;
antialiasing: true;
asynchronous: true;
verticalAlignment: Image.AlignVCenter;
horizontalAlignment: Image.AlignLeft;
anchors.fill: parent;
}
}
Component {
id: compoAnimationVideo;
WrapperVideoPlayer {
loop: true;
muted: true;
source: helper.url;
active: !self.paused;
autoLoad: true;
autoPlay: true;
anchors.fill: parent;
}
}
}
import QtQuick 2.6;
import QtMultimedia 5.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
DelegateAbstractMessageContent {
id: self;
property TD_MessageAudio messageContentItem : null;
readonly property TD_Audio audioItem : (messageContentItem ? messageContentItem.audio : null);
readonly property TD_PhotoSize photoSizeItem : (audioItem ? audioItem.albumCoverThumbnail : null);
HelperFileState {
id: helper;
fileItem: (self.audioItem ? self.audioItem.audio : null);
autoDownload: false;
}
WrapperAudioPlayer {
id: player;
source: helper.url;
active: (TD_Global.currentMessageContent && self.messageContentItem && TD_Global.currentMessageContent === self.messageContentItem);
autoLoad: true;
autoPlay: true;
}
DelegateFormattedText {
formattedTextItem: (messageContentItem ? messageContentItem.caption : null);
ExtraAnchors.horizontalFill: parent;
}
LabelFixed {
text: (self.audioItem ? self.audioItem.fileName : "");
elide: Text.ElideRight;
font.pixelSize: Theme.fontSizeSmall;
ExtraAnchors.horizontalFill: parent;
}
LabelFixed {
text: (self.audioItem ? self.audioItem.title : "");
visible: (text !== "");
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.bold: true;
ExtraAnchors.horizontalFill: parent;
}
LabelFixed {
text: (self.audioItem ? self.audioItem.performer : "");
visible: (text !== "");
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.bold: true;
ExtraAnchors.horizontalFill: parent;
}
RowContainer {
spacing: Theme.paddingMedium;
ColumnContainer {
anchors.verticalCenter: parent.verticalCenter;
MouseArea {
implicitWidth: (Theme.iconSizeExtraLarge * 2);
implicitHeight: (Theme.iconSizeExtraLarge * 2);
onClicked: {
if (helper.uploading) {
// NOTHING WE CAN DO
}
else {
if (helper.downloaded) {
if (TD_Global.currentMessageContent === self.messageContentItem) {
if (player.playing) {
player.pause ();
}
else {
player.play ();
}
}
else {
TD_Global.currentMessageContent = self.messageContentItem;
}
}
else {
if (helper.downloadable) {
if (helper.downloading) {
helper.cancelDownload ();
}
else {
helper.tryDownload (true);
}
}
}
}
}
Image {
source: "qrc:///images/cd-box.svg";
visible: !imgAlbumCover.valid;
fillMode: Image.PreserveAspectFit;
anchors.fill: parent;
}
DelegateDownloadableImage {
id: imgAlbumCover;
fileItem: (self.photoSizeItem ? self.photoSizeItem.photo : null);
background: false;
autoDownload: true;
anchors.fill: parent;
}
Image {
source: ((helper.downloadable && !helper.downloading && !helper.downloaded)
? "image://theme/icon-m-cloud-download?#808080"
: ((helper.downloaded && !player.playing)
? "image://theme/icon-m-play?#808080"
: "image://theme/icon-m-pause?#808080"));
sourceSize: Qt.size (Theme.iconSizeMedium, Theme.iconSizeMedium);
anchors.centerIn: parent;
}
}
Item {
implicitHeight: Theme.paddingSmall;
ExtraAnchors.horizontalFill: parent;
Rectangle {
color: Theme.secondaryColor;
anchors.fill: parent;
}
Rectangle {
color: Theme.highlightColor;
implicitWidth: (parent.width * player.progress);
ExtraAnchors.leftDock: parent;
}
}
}
LabelFixed {
text: (self.audioItem
? (player.playing
? ("-" + TD_Global.formatTime (player.remaining, false))
: TD_Global.formatTime ((self.audioItem.duration * 1000), false))
: "--:--");
color: (player.playing ? Theme.highlightColor : Theme.secondaryColor);
font.pixelSize: Theme.fontSizeSmall;
anchors.verticalCenter: parent.verticalCenter;
}
}
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: qsTr ("Group chat '%1' created").arg (messageContentItem.title);
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessageBasicGroupChatCreate messageContentItem : null;
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: {
if (callDiscardReasonItem) {
switch (callDiscardReasonItem.typeOf) {
case TD_ObjectType.CALL_DISCARD_REASON_HUNG_UP: return qsTr ("Call finished (%1)").arg (TD_Global.formatTime (messageContentItem.duration, false));
case TD_ObjectType.CALL_DISCARD_REASON_MISSED: return qsTr ("Call missed");
case TD_ObjectType.CALL_DISCARD_REASON_DECLINED: return qsTr ("Call declined");
case TD_ObjectType.CALL_DISCARD_REASON_DISCONNECTED: return qsTr ("Call disconnected");
case TD_ObjectType.CALL_DISCARD_REASON_EMPTY: return qsTr ("Call unknown state");
}
}
return qsTr ("Call");
}
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessageCall messageContentItem : null;
readonly property TD_CallDiscardReason callDiscardReasonItem : (messageContentItem ? messageContentItem.discardReason : null);
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
DelegateAbstractMessageContent {
id: self;
spacing: Theme.paddingSmall;
property TD_MessageChatAddMembers messageContentItem : null;
LabelFixed {
text: qsTr ("Added members to this group chat :");
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
ExtraAnchors.horizontalFill: parent;
}
Repeater {
model: self.messageContentItem.memberUserIds;
delegate: RowContainer {
id: delegateAddedMember;
spacing: Theme.paddingMedium;
ExtraAnchors.horizontalFill: parent;
readonly property TD_User userItem : TD_Global.getUserItemById (modelData);
DelegateDownloadableImage {
size: Theme.iconSizeMedium;
fileItem: (delegateAddedMember.userItem && delegateAddedMember.userItem.profilePhoto
? delegateAddedMember.userItem.profilePhoto.big
: null);
autoDownload: true;
anchors.verticalCenter: parent.verticalCenter;
}
LabelFixed {
text: (delegateAddedMember.userItem ? delegateAddedMember.userItem.firstName + " " + delegateAddedMember.userItem.lastName : "");
color: Theme.highlightColor;
elide: Text.ElideRight;
maximumLineCount: 1;
anchors.verticalCenter: parent.verticalCenter;
Container.horizontalStretch: 1;
}
}
}
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
DelegateAbstractMessageContent {
id: self;
spacing: Theme.paddingSmall;
property TD_MessageChatChangePhoto messageContentItem : null;
readonly property TD_Photo photoItem : (messageContentItem ? messageContentItem.photo : null);
readonly property TD_PhotoSize photoSizeItem : (photoItem && photoItem.sizes.count > 0 ? photoItem.sizes.getLast () : null);
LabelFixed {
text: qsTr ("Changed the group photo :");
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
}
DelegateDownloadableImage {
size: Theme.iconSizeLarge;
fileItem: (self.photoSizeItem
? self.photoSizeItem.photo
: null);
autoDownload: true;
}
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: qsTr ("Changed the group title to '%1'").arg (messageContentItem.title);
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessageChatChangeTitle messageContentItem : null;
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: qsTr ("Registered in Telegram");
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessagePinMessage messageContentItem : null;
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
DelegateAbstractMessageContent {
id: self;
spacing: Theme.paddingSmall;
property TD_MessageChatDeleteMember messageContentItem : null;
LabelFixed {
text: (self.messageItem.senderUserId !== self.messageContentItem.userId
? qsTr ("Remove member from this group chat :")
: qsTr ("Left this group chat"));
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
ExtraAnchors.horizontalFill: parent;
}
RowContainer {
id: delegateRemovedMember;
spacing: Theme.paddingMedium;
visible: (self.messageItem.senderUserId !== self.messageContentItem.userId);
ExtraAnchors.horizontalFill: parent;
readonly property TD_User userItem : TD_Global.getUserItemById (self.messageContentItem.userId);
DelegateDownloadableImage {
size: Theme.iconSizeMedium;
fileItem: (delegateRemovedMember.userItem && delegateRemovedMember.userItem.profilePhoto
? delegateRemovedMember.userItem.profilePhoto.big
: null);
autoDownload: true;
anchors.verticalCenter: parent.verticalCenter;
}
LabelFixed {
text: (delegateRemovedMember.userItem ? delegateRemovedMember.userItem.firstName + " " + delegateRemovedMember.userItem.lastName : "");
color: Theme.highlightColor;
elide: Text.ElideRight;
maximumLineCount: 1;
anchors.verticalCenter: parent.verticalCenter;
Container.horizontalStretch: 1;
}
}
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: qsTr ("Joined the group chat using the invite link");
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessageChatJoinByLink messageContentItem : null;
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: qsTr ("Upgraded from basic group");
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessageChatUpgradeFrom messageContentItem : null;
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
LabelFixed {
id: self;
text: qsTr ("Upgraded to supergroup");
color: Theme.secondaryHighlightColor;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.italic: true;
font.pixelSize: Theme.fontSizeSmall;
property TD_Chat chatItem : null;
property TD_Message messageItem : null;
property TD_MessageChatUpgradeTo messageContentItem : null;
}
import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
DelegateAbstractMessageContent {
id: self;
spacing: Theme.paddingMedium;
property TD_MessageDocument messageContentItem : null;
readonly property TD_Document documentItem : (messageContentItem ? messageContentItem.document : null);
readonly property TD_PhotoSize photoSizeItem : (documentItem ? documentItem.thumbnail : null);
HelperFileState {
id: helper;
fileItem: (documentItem ? documentItem.document : null);
autoDownload: false;
}
DelegateFormattedText {
formattedTextItem: (messageContentItem ? messageContentItem.caption : null);
ExtraAnchors.horizontalFill: parent;
}
MouseArea {
implicitHeight: (layout.height + layout.anchors.margins * 2);
ExtraAnchors.horizontalFill: parent;
onClicked: {
if (helper.uploading) {
// NOTHING WE CAN DO
}
else {
if (helper.downloaded) {
Qt.openUrlExternally (helper.url);
}
else {
if (helper.downloadable) {
if (helper.downloading) {
helper.cancelDownload ();
}
else {
helper.tryDownload (true);
}
}
}
}
}
Rectangle {
color: Theme.secondaryHighlightColor;
opacity: 0.15;
border {
width: 1;
color: Theme.highlightColor;
}
anchors.fill: parent;
}
RowContainer {
id: layout;
spacing: Theme.paddingMedium;
anchors {
margins: Theme.paddingSmall;
verticalCenter: parent.verticalCenter;
}
ExtraAnchors.horizontalFill: parent;