Commit 15c4bb78 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Fix headers appearance and behavior (display pulley hint, scroll down)

Display mention "@" notification on chats list

Prepare for opt-in "enter-to-send" param

Add more delay to message prefetcher to avoid blocking page animation

Fix issue with audio or video content replay when going back-and-forth
parent 001c5b9b
......@@ -57,13 +57,13 @@ ApplicationWindow {
MouseArea {
id: footerChat;
enabled: showInputPanel;
opacity: (enabled ? 1.0 : 0.0);
implicitHeight: (layoutFooter.height + layoutFooter.anchors.margins * 2);
anchors.bottomMargin: (showInputPanel ? 0 : -height);
ExtraAnchors.bottomDock: parent;
onPressed: { }
onReleased: { }
Behavior on anchors.bottomMargin { NumberAnimation { duration: 150; } }
Rectangle {
color: Qt.rgba (1.0 - Theme.primaryColor.r, 1.0 - Theme.primaryColor.g, 1.0 - Theme.primaryColor.b, 0.85);
anchors.fill: parent;
......@@ -80,19 +80,30 @@ ApplicationWindow {
ExtraAnchors.horizontalFill: parent;
Container.forcedHeight: (implicitHeight + anchors.margins * 2);
onVisibleChanged: {
if (!visible && inputMsg.activeFocus) {
inputMsg.focus = false;
if (!visible && btnSendMsgText.textBox.activeFocus) {
btnSendMsgText.textBox.focus = false;
}
}
Item {
implicitHeight: Math.min (inputMsg.implicitHeight, Theme.itemSizeLarge * 2);
implicitHeight: Math.min (btnSendMsgText.textBox.implicitHeight, Theme.itemSizeLarge * 2);
anchors.bottom: parent.bottom;
anchors.margins: Theme.paddingSmall;
Container.horizontalStretch: 1;
TextField {
id: inputMsgSingle;
visible: btnSendMsgText.fastSend;
labelVisible: false;
placeholderText: qsTr ("Text message");
anchors.fill: parent;
Keys.onReturnPressed: {
btnSendMsgText.execute ();
}
}
TextArea {
id: inputMsg;
visible: !btnSendMsgText.fastSend;
labelVisible: false;
placeholderText: qsTr ("Text message");
autoScrollEnabled: true;
......@@ -100,20 +111,29 @@ ApplicationWindow {
}
}
RectangleButton {
id: btnSendMsgText;
icon: "icon-m-enter";
enabled: (inputMsg.text.trim () !== "");
size: (Theme.iconSizeMedium * 0.65);
enabled: (textBox.text.trim () !== "");
implicitWidth: Theme.itemSizeExtraSmall;
implicitHeight: Theme.itemSizeExtraSmall;
anchors.bottom: parent.bottom;
anchors.margins: Theme.paddingSmall;
onClicked: {
var tmp = inputMsg.text.trim ();
execute ();
}
readonly property bool fastSend : TD_Global.sendTextOnEnterKey;
readonly property Item textBox : (fastSend ? 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);
}
inputMsg.text = "";
textBox.text = "";
}
}
}
......@@ -559,9 +579,9 @@ ApplicationWindow {
onPressed: {
active = TD_Global.startRecordingAudio ();
if (active) {
console.log ("RECORDING STARTED", active);
currentRecording = "";
}
console.log ("RECORDING STARTED", active);
}
onReleased: {
if (active) {
......
......@@ -558,6 +558,7 @@ Page {
id: headerChat;
opacity: (pulleyTop.active ? 0.0 : 1.0);
implicitHeight: (layoutHeader.height + layoutHeader.anchors.margins * 2);
anchors.topMargin: Math.max (-flickerMessages.contentY, 0);
ExtraAnchors.topDock: parent;
onPressed: { }
onReleased: { }
......@@ -566,6 +567,13 @@ Page {
Rectangle {
color: Qt.rgba (1.0 - Theme.primaryColor.r, 1.0 - Theme.primaryColor.g, 1.0 - Theme.primaryColor.b, 0.85);
anchors.fill: parent;
Rectangle {
color: Theme.secondaryHighlightColor;
opacity: 0.65;
implicitHeight: Theme.paddingSmall;
ExtraAnchors.topDock: parent;
}
}
RowContainer {
id: layoutHeader;
......
......@@ -364,6 +364,51 @@ Page {
contentHeight: layoutChats.height;
anchors.fill: parent;
PullDownMenu {
id: pulley;
MenuItem {
text: qsTr ("About [TODO]");
enabled: false;
onClicked: {
// TODO
}
}
MenuItem {
text: qsTr ("Settings [TODO]");
enabled: false;
onClicked: {
// TODO
}
}
MenuItem {
text: qsTr ("New group chat [TODO]");
enabled: false;
onClicked: {
// TODO
}
}
MenuItem {
text: qsTr ("Contacts list [TODO]");
enabled: false;
onClicked: {
// TODO
}
}
MenuItem {
text: (layoutSearch.visible ? qsTr ("Hide search bar") : qsTr ("Show search bar"));
onClicked: {
if (layoutSearch.visible) {
inputFilter.focus = false;
layoutSearch.visible = false;
}
else {
layoutSearch.visible = true;
inputFilter.forceActiveFocus ();
}
}
}
}
Column {
id: layoutChats;
ExtraAnchors.topDock: parent;
......@@ -490,6 +535,28 @@ Page {
sourceSize: Qt.size (Theme.iconSizeSmall, Theme.iconSizeSmall);
anchors.verticalCenter: parent.verticalCenter;
}
Item {
visible: (delegateChat.chatItem.unreadMentionCount > 0);
Container.forcedWidth: Theme.paddingMedium;
}
LabelFixed {
text: "@";
color: ((delegateChat.chatItem && delegateChat.chatItem.notificationSettings && delegateChat.chatItem.notificationSettings.muteFor > 0)
? Theme.secondaryColor
: Theme.highlightColor);
visible: (delegateChat.chatItem.unreadMentionCount > 0);
anchors.verticalCenter: parent.verticalCenter;
Rectangle {
z: -1;
color: Theme.secondaryColor;
radius: (height * 0.5);
opacity: 0.35;
implicitWidth: Math.max (parent.width + Theme.paddingMedium * 2, implicitHeight);
implicitHeight: (parent.height + Theme.paddingSmall * 2);
anchors.centerIn: parent;
}
}
Item {
visible: (delegateChat.chatItem.unreadCount > 0);
Container.forcedWidth: Theme.paddingMedium;
......@@ -513,7 +580,7 @@ Page {
}
}
Item {
visible: (delegateChat.chatItem.unreadCount > 0);
visible: (delegateChat.chatItem.unreadCount > 0 || delegateChat.chatItem.unreadMentionCount > 0);
Container.forcedWidth: Theme.paddingMedium;
}
}
......@@ -524,16 +591,26 @@ Page {
}
MouseArea {
id: headerConversations;
opacity: (pulley.active ? 0.65 : 1.0);
implicitHeight: (window.isPortrait
? (layoutTitle.height + layoutSearch.height + Theme.paddingMedium * 3)
: (Math.max (layoutTitle.height, layoutSearch.height) + Theme.paddingMedium * 2));
? (layoutTitle.height + (layoutSearch.visible ? layoutSearch.height + Theme.paddingMedium : 0) + Theme.paddingMedium * 2)
: (Math.max (layoutTitle.height, (layoutSearch.visible ? layoutSearch.height : 0)) + Theme.paddingMedium * 2));
anchors.topMargin: Math.max (-flickerChats.contentY, 0);
ExtraAnchors.topDock: parent;
onPressed: { }
onReleased: { }
Behavior on opacity { NumberAnimation { duration: 150; } }
Rectangle {
color: Qt.rgba (1.0 - Theme.primaryColor.r, 1.0 - Theme.primaryColor.g, 1.0 - Theme.primaryColor.b, 0.85);
anchors.fill: parent;
Rectangle {
color: Theme.secondaryHighlightColor;
opacity: 0.65;
implicitHeight: Theme.paddingSmall;
ExtraAnchors.topDock: parent;
}
}
RowContainer {
id: layoutTitle;
......@@ -575,6 +652,7 @@ Page {
RowContainer {
id: layoutSearch;
spacing: Theme.paddingSmall;
visible: false;
anchors {
top: (window.isPortrait ? layoutTitle.bottom : parent.top);
left: parent.left;
......
......@@ -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: 5
Release: 6
Group: Qt/Qt
License: LICENSE
URL: http://example.org/
......
Name: harbour-telegrame
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 5
Release: 6
Group: Qt/Qt
URL: http://example.org/
......
......@@ -56,7 +56,9 @@ QtTdLibChat::~QtTdLibChat (void) {
}
void QtTdLibChat::refreshNotification (void) {
m_timer.start ();
if (!m_timer.isActive ()) {
m_timer.start ();
}
}
QtTdLibMessage * QtTdLibChat::getMessageItemById (const QString & id) const {
......
......@@ -18,7 +18,12 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
, m_currentMessageContent { Q_NULLPTR }
, m_sortedChatsList { new QSortFilterProxyModel { this } }
, m_dbusAdaptor { new DBusAdaptor { this } }
, m_svgIconForMimetype {
, m_sendTextOnEnterKey { false }
, DBUS_SERVICE_NAME { "org.uniqueconception.telegrame" }
, DBUS_OBJECT_PATH { "/org/uniqueconception/telegrame" }
, DBUS_INTERFACE { "org.uniqueconception.telegrame" }
, CONF_KEY_SEND_ON_ENTER { "send_text_msg_on_enter" }
, SVG_ICON_FOR_MIMETYPE {
{ "image/png", "image" },
{ "image/jpeg", "image" },
{ "image/gif", "image" },
......@@ -82,10 +87,19 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
, m_audioRecorder { new QAudioRecorder { this } }
, m_autoPreFetcher { new QTimer { this } }
{
if (!m_settings.contains (CONF_KEY_SEND_ON_ENTER)) {
m_settings.setValue (CONF_KEY_SEND_ON_ENTER, m_sendTextOnEnterKey);
}
else {
m_sendTextOnEnterKey = m_settings.value (CONF_KEY_SEND_ON_ENTER).toBool ();
}
connect (this, &QtTdLibGlobal::sendTextOnEnterKeyChanged, this, [this] (void) {
m_settings.setValue (CONF_KEY_SEND_ON_ENTER, m_sendTextOnEnterKey);
});
QDBusConnection dbus { QDBusConnection::sessionBus () };
dbus.registerObject (dbusObjectPath, m_dbusAdaptor);
if (!dbus.interface ()->isServiceRegistered (dbusServiceName)) {
dbus.registerService (dbusServiceName);
dbus.registerObject (DBUS_OBJECT_PATH, m_dbusAdaptor);
if (!dbus.interface ()->isServiceRegistered (DBUS_SERVICE_NAME)) {
dbus.registerService (DBUS_SERVICE_NAME);
}
m_sortedChatsList->setSourceModel (m_chatsList);
m_sortedChatsList->setSortRole (m_chatsList->roleForName ("order"));
......@@ -98,6 +112,7 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
audioEncoderSettings.setSampleRate (22050);
m_audioRecorder->setEncodingSettings (audioEncoderSettings);
m_audioRecorder->setContainerFormat ("wav"); // "ogg"
qWarning () << "VOLUME" << m_audioRecorder->volume () << m_audioRecorder->audioInput () << m_audioRecorder->audioInputDescription (m_audioRecorder->audioInput ());
connect (m_audioRecorder, &QAudioRecorder::durationChanged, [this] (void) {
if (m_audioRecorder->status () == QMediaRecorder::RecordingStatus || m_audioRecorder->status () == QMediaRecorder::FinalizingStatus) {
set_recordingDuration (int (m_audioRecorder->duration ()));
......@@ -111,8 +126,8 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
QtTdLibGlobal::~QtTdLibGlobal (void) {
QDBusConnection dbus { QDBusConnection::sessionBus () };
dbus.unregisterObject (dbusObjectPath);
dbus.unregisterService (dbusServiceName);
dbus.unregisterObject (DBUS_OBJECT_PATH);
dbus.unregisterService (DBUS_SERVICE_NAME);
m_tdLibJsonWrapper->send (QJsonObject {
{ "@type", "close" }
});
......@@ -205,7 +220,7 @@ QString QtTdLibGlobal::getMimeTypeForPath (const QString & path) const {
}
QString QtTdLibGlobal::getSvgIconForMimeType (const QString & type) const {
return m_svgIconForMimetype.value (type, "file");
return SVG_ICON_FOR_MIMETYPE.value (type, "file");
}
QtTdLibFile * QtTdLibGlobal::getFileItemById (const qint32 id) const {
......@@ -326,11 +341,12 @@ void QtTdLibGlobal::openChat (QtTdLibChat * chatItem) {
{ "@type", "openChat" },
{ "chat_id", chatItem->get_id () },
});
m_autoPreFetcher->start (0);
m_autoPreFetcher->start (350);
}
}
void QtTdLibGlobal::closeChat (QtTdLibChat * chatItem) {
set_currentMessageContent (Q_NULLPTR);
if (chatItem != Q_NULLPTR) {
chatItem->set_isCurrentChat (false);
set_currentChat (Q_NULLPTR);
......@@ -354,6 +370,7 @@ void QtTdLibGlobal::markAllMessagesAsRead (QtTdLibChat * chatItem) {
{ "@type", "viewMessages" },
{ "chat_id", chatItem->get_id_asJSON () },
{ "message_ids", messageIdsJson },
{ "force_read", true },
});
}
}
......
......@@ -15,6 +15,7 @@
#include <QTimer>
#include <QtMath>
#include <QUrl>
#include <QSettings>
#include "QtTdLibCommon.h"
#include "QtTdLibJsonWrapper.h"
......@@ -62,6 +63,7 @@ class QtTdLibGlobal : public QObject {
QML_WRITABLE_PTR_PROPERTY (currentMessageContent, QtTdLibMessageContent)
QML_CONSTANT_PTR_PROPERTY (sortedChatsList, QSortFilterProxyModel)
QML_CONSTANT_PTR_PROPERTY (dbusAdaptor, DBusAdaptor)
QML_WRITABLE_VAR_PROPERTY (sendTextOnEnterKey, bool)
public:
explicit QtTdLibGlobal (QObject * parent = Q_NULLPTR);
......@@ -136,7 +138,11 @@ protected:
void onPrefetcherTick (void);
private:
const QHash<QString, QString> m_svgIconForMimetype;
const QString DBUS_SERVICE_NAME;
const QString DBUS_OBJECT_PATH;
const QString DBUS_INTERFACE;
const QString CONF_KEY_SEND_ON_ENTER;
const QHash<QString, QString> SVG_ICON_FOR_MIMETYPE;
struct SelectionPhoto {
QString path;
......@@ -157,6 +163,7 @@ private:
QAudioRecorder * m_audioRecorder;
QTimer * m_autoPreFetcher;
QMimeDatabase m_mimeDb;
QSettings m_settings;
};
#endif // QTTDLIBGLOBAL_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment