Commit 0584a940 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add the "New contact" dialog in Contacts page pulley menu

parent d41995eb
......@@ -20,9 +20,11 @@ for(LINE, YAML_LINES) {
equals(YAML_KEY, "Version") {
YAML_VALUE = $$section(LINE, ": ", 1, 1)
message ("Extracted app version from YAML '" $$YAML_VALUE "' : OK !")
DEFINES += YAML_VERSION=$$YAML_VALUE
APP_VERSION = $$YAML_VALUE
}
}
QMAKE_SUBSTITUTES += \
$$PWD/src/buildconf.h.in
QMAKE_CXXFLAGS -= -g
QMAKE_CXXFLAGS_DEBUG -= -g
......@@ -51,6 +53,7 @@ PKGCONFIG += mlite5
INCLUDEPATH += \
/usr/include \
/usr/include/sailfishapp \
$$OUT_PWD/src \
$$PWD/src
SOURCES += \
......@@ -84,7 +87,8 @@ HEADERS += \
$$PWD/src/QtTdLibUser.h \
$$PWD/src/TextFormatter.h \
$$PWD/src/QtTdLibChatAction.h \
$$PWD/src/CountryCodes.h
$$PWD/src/CountryCodes.h \
src/buildconf.h.in
RESOURCES += \
$$PWD/qml.qrc \
......
......@@ -61,7 +61,7 @@ DelegateAbstractMessageContent {
id: emblem;
text: qsTr ("(saved in gallery)");
opacity: 0.65;
visible: TD_Global.isPhotoSavedToGallery (photoSizeItem.photo);
visible: (photoSizeItem && TD_Global.isPhotoSavedToGallery (photoSizeItem.photo));
horizontalAlignment: Text.AlignHCenter;
font.pixelSize: Theme.fontSizeExtraSmall;
ExtraAnchors.horizontalFill: img;
......
......@@ -59,15 +59,106 @@ Page {
}
}
}
PullDownMenu {
id: pulleyTop;
MenuItem {
text: qsTr ("Add contact...");
onClicked: {
pageStack.push (compoDlgNewContact, { });
}
Component {
id: compoDlgNewContact;
Dialog {
id: dlgNewContact;
onDone: {
if (result === DialogResult.Accepted) {
TD_Global.send ({
"@type" : "importContacts",
"contacts" : [
{
"@type" : "contact",
"first_name" : inputContactFirstName.text.trim (),
"last_name" : inputContactLastName.text.trim (),
"phone_number" : inputContactPhoneNumber.text.trim (),
}
]
});
}
else { }
}
ColumnContainer {
spacing: Theme.paddingSmall;
ExtraAnchors.topDock: parent;
DialogHeader {
implicitHeight: (dlgNewContact.isPortrait ? Theme.itemSizeLarge : Theme.itemSizeSmall);
ExtraAnchors.horizontalFill: parent;
}
Item {
ExtraAnchors.horizontalFill: parent;
Container.forcedHeight: Theme.paddingLarge;
}
LabelFixed {
text: qsTr ("Add contact");
color: Theme.highlightColor;
font {
family: Theme.fontFamilyHeading;
pixelSize: Theme.fontSizeLarge;
}
anchors.margins: Theme.paddingLarge;
ExtraAnchors.horizontalFill: parent;
}
Item {
ExtraAnchors.horizontalFill: parent;
Container.forcedHeight: Theme.paddingLarge;
}
TextField {
id: inputContactFirstName;
label: qsTr ("First name");
placeholderText: label;
ExtraAnchors.horizontalFill: parent;
}
TextField {
id: inputContactLastName;
label: qsTr ("Last name");
placeholderText: label;
ExtraAnchors.horizontalFill: parent;
}
TextField {
id: inputContactPhoneNumber;
label: qsTr ("Phone number");
inputMethodHints: Qt.ImhDialableCharactersOnly;
placeholderText: label;
ExtraAnchors.horizontalFill: parent;
}
}
}
}
}
}
}
VerticalScrollDecorator {
flickable: flickerContacts;
}
PanelFixed {
id: headerContacts;
opacity: (pulleyTop.active ? 0.65 : 1.0);
implicitHeight: (title.height + title.anchors.margins * 2);
anchors.topMargin: Math.max (-flickerContacts.contentY - height, 0);
ExtraAnchors.topDock: parent;
Rectangle {
color: Theme.rgba (Theme.secondaryHighlightColor, 0.65);
visible: flickerContacts.atYBeginning;
implicitHeight: Theme.paddingSmall;
ExtraAnchors.topDock: parent;
}
LabelFixed {
id: title;
text: qsTr ("All contacts");
......
......@@ -106,9 +106,9 @@ Page {
TextField {
id: inputPhoneNumber;
placeholderText: qsTr ("Phone number");
inputMethodHints: Qt.ImhDialableCharactersOnly;
anchors.verticalCenter: parent.verticalCenter;
Container.horizontalStretch: 1;
inputMethodHints: Qt.ImhDialableCharactersOnly;
}
}
MouseArea {
......
......@@ -13,7 +13,7 @@ Name: harbour-telegrame
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: A native Telegram client for Sailfish OS
Version: 22
Version: 23
Release: 1
Group: Qt/Qt
License: WTFPL
......
Name: harbour-telegrame
Summary: A native Telegram client for Sailfish OS
Version: 22
Version: 23
Release: 1
Group: Qt/Qt
......
......@@ -63,6 +63,7 @@ QtTdLibObjectType::Type QtTdLibEnums::objectTypeEnumFromString (const QString &
{ "document", QtTdLibObjectType::DOCUMENT },
{ "file", QtTdLibObjectType::FILE },
{ "formattedText", QtTdLibObjectType::FORMATTED_TEXT },
{ "importedContacts", QtTdLibObjectType::IMPORTED_CONTACTS },
{ "linkStateIsContact", QtTdLibObjectType::LINK_STATE_IS_CONTACT },
{ "linkStateKnowsPhoneNumber", QtTdLibObjectType::LINK_STATE_KNOWS_PHONE_NUMBER },
{ "linkStateNone", QtTdLibObjectType::LINK_STATE_NONE },
......
......@@ -66,6 +66,7 @@ QML_ENUM_CLASS (QtTdLibObjectType,
DOCUMENT,
FILE,
FORMATTED_TEXT,
IMPORTED_CONTACTS,
LINK_STATE_IS_CONTACT,
LINK_STATE_KNOWS_PHONE_NUMBER,
LINK_STATE_NONE,
......
......@@ -1163,6 +1163,28 @@ void QtTdLibGlobal::onFrame (const QJsonObject & json) {
}
break;
}
case QtTdLibObjectType::USER: {
const qint32 userId { QtTdLibId32Helper::fromJsonToCpp (json ["id"]) };
if (QtTdLibUser * userItem = { getUserItemById (userId) }) {
userItem->updateFromJson (json);
if (json ["@extra"].toObject () ["add_contact"].toBool ()) {
if (!m_contactsList->contains (userItem)) {
m_contactsList->append (userItem);
}
}
}
else {
userItem = QtTdLibUser::create (json, this);
if (userItem != nullptr) {
if (json ["@extra"].toObject () ["add_contact"].toBool ()) {
if (!m_contactsList->contains (userItem)) {
m_contactsList->append (userItem);
}
}
}
}
break;
}
case QtTdLibObjectType::CHAT: {
const qint64 chatId { QtTdLibId53Helper::fromJsonToCpp (json ["id"]) };
if (QtTdLibChat * chatItem = { getChatItemById (chatId) }) {
......@@ -1380,6 +1402,23 @@ void QtTdLibGlobal::onFrame (const QJsonObject & json) {
else { }
break;
}
case QtTdLibObjectType::IMPORTED_CONTACTS: {
const QJsonArray userIdsJson = json ["user_ids"].toArray ();
for (const QJsonValue & tmp : userIdsJson) {
const qint32 userId { QtTdLibId32Helper::fromJsonToCpp (tmp) };
if (userId != 0) {
send (QJsonObject {
{ "@type", "getUser" },
{ "user_id", tmp },
{ "@extra", QJsonObject {
{ "add_contact", true },
}
}
});
}
}
break;
}
case QtTdLibObjectType::STICKER_SETS: {
const QJsonArray setsJson = json ["sets"].toArray ();
for (const QJsonValue & tmp : setsJson) {
......
#ifndef BUILDCONF_H_IN
#define BUILDCONF_H_IN
#define APP_VERSION "$$APP_VERSION"
#endif // BUILDCONF_H_IN
......@@ -23,10 +23,12 @@
#include "QtTdLibChat.h"
#include "TextFormatter.h"
#include "buildconf.h"
int main (int argc, char * argv []) {
SailfishApp::application (argc, argv);
QGuiApplication::setApplicationName (QStringLiteral ("harbour-telegrame"));
QGuiApplication::setApplicationVersion (QString::number (int (YAML_VERSION)));
QGuiApplication::setApplicationVersion (QString::number (int (APP_VERSION)));
QtQmlTricks::registerComponents ();
qmlRegisterType<TextFormatter> ("harbour.Telegrame", 1, 0, "TextFormatter");
qmlRegisterType<CountryCodes> ("harbour.Telegrame", 1, 0, "CountryCodes");
......
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