Merge latest upstream changes...

This commit is contained in:
Sebastian Wolf 2020-11-26 15:38:15 +01:00
commit 6f889437ed
18 changed files with 246 additions and 39 deletions

View file

@ -156,39 +156,48 @@ Page {
} }
} }
Text { Loader {
x: Theme.horizontalPageMargin active: !!aboutPage.userInformation.phone_number
width: parent.width - ( 2 * Theme.horizontalPageMargin ) width: parent.width
horizontalAlignment: Text.AlignHCenter sourceComponent: Component {
text: qsTr("Logged in as %1").arg(Emoji.emojify(aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name, Theme.fontSizeSmall)) Column {
font.pixelSize: Theme.fontSizeSmall
wrapMode: Text.Wrap
color: Theme.primaryColor
textFormat: Text.StyledText
anchors {
horizontalCenter: parent.horizontalCenter
}
}
ProfileThumbnail { Text {
photoData: aboutPage.userInformation.profile_photo.small x: Theme.horizontalPageMargin
width: Theme.itemSizeExtraLarge width: parent.width - ( 2 * Theme.horizontalPageMargin )
height: Theme.itemSizeExtraLarge horizontalAlignment: Text.AlignHCenter
replacementStringHint: aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name text: qsTr("Logged in as %1").arg(Emoji.emojify(aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name, Theme.fontSizeSmall))
anchors { font.pixelSize: Theme.fontSizeSmall
horizontalCenter: parent.horizontalCenter wrapMode: Text.Wrap
} color: Theme.primaryColor
} textFormat: Text.StyledText
anchors {
horizontalCenter: parent.horizontalCenter
}
}
Label { ProfileThumbnail {
x: Theme.horizontalPageMargin photoData: aboutPage.userInformation.profile_photo.small
width: parent.width - ( 2 * Theme.horizontalPageMargin ) width: Theme.itemSizeExtraLarge
horizontalAlignment: Text.AlignHCenter height: Theme.itemSizeExtraLarge
text: qsTr("Phone number: +%1").arg(aboutPage.userInformation.phone_number) replacementStringHint: aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name
font.pixelSize: Theme.fontSizeSmall anchors {
wrapMode: Text.Wrap horizontalCenter: parent.horizontalCenter
anchors { }
horizontalCenter: parent.horizontalCenter }
Label {
x: Theme.horizontalPageMargin
width: parent.width - ( 2 * Theme.horizontalPageMargin )
horizontalAlignment: Text.AlignHCenter
text: qsTr("Phone number: +%1").arg(aboutPage.userInformation.phone_number)
font.pixelSize: Theme.fontSizeSmall
wrapMode: Text.Wrap
anchors {
horizontalCenter: parent.horizontalCenter
}
}
}
} }
} }

View file

@ -105,6 +105,13 @@ Page {
Behavior on contentHeight { NumberAnimation {} } Behavior on contentHeight { NumberAnimation {} }
anchors.fill: parent anchors.fill: parent
PullDownMenu {
MenuItem {
text: qsTr("About Fernschreiber")
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
}
}
Column { Column {
id: content id: content
width: parent.width width: parent.width

View file

@ -149,6 +149,23 @@ Page {
} }
} }
SectionHeader {
text: qsTr("Storage")
}
TextSwitch {
checked: appSettings.storageOptimizer
text: qsTr("Enable storage optimizer")
automaticCheck: false
onClicked: {
appSettings.storageOptimizer = !checked
}
}
Item {
width: 1
height: Theme.paddingLarge // Some space at the bottom
}
} }
VerticalScrollDecorator {} VerticalScrollDecorator {}

View file

@ -27,6 +27,7 @@ namespace {
const QString KEY_ANIMATE_STICKERS("animateStickers"); const QString KEY_ANIMATE_STICKERS("animateStickers");
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn"); const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback");
const QString KEY_STORAGE_OPTIMIZER("storageOptimizer");
} }
AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings") AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings")
@ -116,3 +117,17 @@ void AppSettings::setNotificationFeedback(NotificationFeedback feedback)
emit notificationFeedbackChanged(); emit notificationFeedbackChanged();
} }
} }
bool AppSettings::storageOptimizer() const
{
return settings.value(KEY_STORAGE_OPTIMIZER, false).toBool();
}
void AppSettings::setStorageOptimizer(bool enable)
{
if (storageOptimizer() != enable) {
LOG(KEY_STORAGE_OPTIMIZER << enable);
settings.setValue(KEY_STORAGE_OPTIMIZER, enable);
emit storageOptimizerChanged();
}
}

View file

@ -29,6 +29,7 @@ class AppSettings : public QObject {
Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged) Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged)
Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged) Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged)
Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged)
Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged)
public: public:
enum NotificationFeedback { enum NotificationFeedback {
@ -59,6 +60,9 @@ public:
NotificationFeedback notificationFeedback() const; NotificationFeedback notificationFeedback() const;
void setNotificationFeedback(NotificationFeedback feedback); void setNotificationFeedback(NotificationFeedback feedback);
bool storageOptimizer() const;
void setStorageOptimizer(bool enable);
signals: signals:
void sendByEnterChanged(); void sendByEnterChanged();
void useOpenWithChanged(); void useOpenWithChanged();
@ -66,6 +70,7 @@ signals:
void animateStickersChanged(); void animateStickersChanged();
void notificationTurnsDisplayOnChanged(); void notificationTurnsDisplayOnChanged();
void notificationFeedbackChanged(); void notificationFeedbackChanged();
void storageOptimizerChanged();
private: private:
QSettings settings; QSettings settings;

View file

@ -40,6 +40,7 @@ namespace {
const QString LAST_NAME("last_name"); const QString LAST_NAME("last_name");
const QString FIRST_NAME("first_name"); const QString FIRST_NAME("first_name");
const QString USERNAME("username"); const QString USERNAME("username");
const QString VALUE("value");
const QString _TYPE("@type"); const QString _TYPE("@type");
const QString _EXTRA("@extra"); const QString _EXTRA("@extra");
} }
@ -119,6 +120,7 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface,
connect(&emojiSearchWorker, SIGNAL(searchCompleted(QString, QVariantList)), this, SLOT(handleEmojiSearchCompleted(QString, QVariantList))); connect(&emojiSearchWorker, SIGNAL(searchCompleted(QString, QVariantList)), this, SLOT(handleEmojiSearchCompleted(QString, QVariantList)));
connect(this->appSettings, SIGNAL(useOpenWithChanged()), this, SLOT(handleOpenWithChanged())); connect(this->appSettings, SIGNAL(useOpenWithChanged()), this, SLOT(handleOpenWithChanged()));
connect(this->appSettings, SIGNAL(storageOptimizerChanged()), this, SLOT(handleStorageOptimizerChanged()));
this->tdLibReceiver->start(); this->tdLibReceiver->start();
@ -482,14 +484,25 @@ void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId)
void TDLibWrapper::setOptionInteger(const QString &optionName, int optionValue) void TDLibWrapper::setOptionInteger(const QString &optionName, int optionValue)
{ {
LOG("Setting integer option" << optionName << optionValue); LOG("Setting integer option" << optionName << optionValue);
QVariantMap requestObject; setOption(optionName, "optionValueInteger", optionValue);
requestObject.insert(_TYPE, "setOption"); }
requestObject.insert("name", optionName);
QVariantMap optionValueMap; void TDLibWrapper::setOptionBoolean(const QString &optionName, bool optionValue)
optionValueMap.insert(_TYPE, "optionValueInteger"); {
optionValueMap.insert("value", optionValue); LOG("Setting boolean option" << optionName << optionValue);
requestObject.insert("value", optionValueMap); setOption(optionName, "optionValueBoolean", optionValue);
this->sendRequest(requestObject); }
void TDLibWrapper::setOption(const QString &name, const QString &type, const QVariant &value)
{
QVariantMap optionValue;
optionValue.insert(_TYPE, type);
optionValue.insert(VALUE, value);
QVariantMap request;
request.insert(_TYPE, "setOption");
request.insert("name", name);
request.insert(VALUE, optionValue);
sendRequest(request);
} }
void TDLibWrapper::setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings) void TDLibWrapper::setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings)
@ -1177,6 +1190,11 @@ void TDLibWrapper::handleSecretChatUpdated(const QString &secretChatId, const QV
emit secretChatUpdated(secretChatId, secretChat); emit secretChatUpdated(secretChatId, secretChat);
} }
void TDLibWrapper::handleStorageOptimizerChanged()
{
setOptionBoolean("use_storage_optimizer", appSettings->storageOptimizer());
}
void TDLibWrapper::setInitialParameters() void TDLibWrapper::setInitialParameters()
{ {
LOG("Sending initial parameters to TD Lib"); LOG("Sending initial parameters to TD Lib");
@ -1195,6 +1213,7 @@ void TDLibWrapper::setInitialParameters()
initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString()); initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString());
initialParameters.insert("system_version", QSysInfo::prettyProductName()); initialParameters.insert("system_version", QSysInfo::prettyProductName());
initialParameters.insert("application_version", "0.5"); initialParameters.insert("application_version", "0.5");
initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer());
// initialParameters.insert("use_test_dc", true); // initialParameters.insert("use_test_dc", true);
requestObject.insert("parameters", initialParameters); requestObject.insert("parameters", initialParameters);
this->sendRequest(requestObject); this->sendRequest(requestObject);

View file

@ -144,6 +144,7 @@ public:
Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, const bool sendCopy, const bool removeCaption); Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, const bool sendCopy, const bool removeCaption);
Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId); Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId);
Q_INVOKABLE void setOptionInteger(const QString &optionName, int optionValue); Q_INVOKABLE void setOptionInteger(const QString &optionName, int optionValue);
Q_INVOKABLE void setOptionBoolean(const QString &optionName, bool optionValue);
Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings); Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings);
Q_INVOKABLE void editMessageText(const QString &chatId, const QString &messageId, const QString &message); Q_INVOKABLE void editMessageText(const QString &chatId, const QString &messageId, const QString &message);
Q_INVOKABLE void deleteMessages(const QString &chatId, const QVariantList messageIds); Q_INVOKABLE void deleteMessages(const QString &chatId, const QVariantList messageIds);
@ -260,8 +261,10 @@ public slots:
void handleOpenWithChanged(); void handleOpenWithChanged();
void handleSecretChatReceived(const QString &secretChatId, const QVariantMap &secretChat); void handleSecretChatReceived(const QString &secretChatId, const QVariantMap &secretChat);
void handleSecretChatUpdated(const QString &secretChatId, const QVariantMap &secretChat); void handleSecretChatUpdated(const QString &secretChatId, const QVariantMap &secretChat);
void handleStorageOptimizerChanged();
private: private:
void setOption(const QString &name, const QString &type, const QVariant &value);
void setInitialParameters(); void setInitialParameters();
void setEncryptionKey(); void setEncryptionKey();
void setLogVerbosityLevel(); void setLogVerbosityLevel();

View file

@ -833,6 +833,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Nutzen Sie das internationale Format, z.B. %1</translation> <translation>Nutzen Sie das internationale Format, z.B. %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>Über Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1249,6 +1253,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation>Hinweis schaltet den Bildschirm an</translation> <translation>Hinweis schaltet den Bildschirm an</translation>
</message> </message>
<message>
<source>Storage</source>
<translation>Speicher</translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation>Speicheroptimierer einschalten</translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -833,6 +833,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Use the international format, e.g. %1</translation> <translation>Use the international format, e.g. %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>About Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1249,6 +1253,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation>Notification turns on the display</translation> <translation>Notification turns on the display</translation>
</message> </message>
<message>
<source>Storage</source>
<translation>Storage</translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation>Enable storage optimizer</translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -823,6 +823,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Usar el formato internacional %1</translation> <translation>Usar el formato internacional %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>Acerca de</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1230,6 +1234,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -834,6 +834,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Käytä kansainvälistä muotoa, esimerkiksi %1</translation> <translation>Käytä kansainvälistä muotoa, esimerkiksi %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>Tietoa Fernschreiberista</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1250,6 +1254,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation>Ilmoitus kytkee näytön päälle</translation> <translation>Ilmoitus kytkee näytön päälle</translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -823,6 +823,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>A Fernschreiber névjegye</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1230,6 +1234,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -833,6 +833,10 @@
<source>Loading...</source> <source>Loading...</source>
<translation>Carica...</translation> <translation>Carica...</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>Informazioni su Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1249,6 +1253,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation>Notifiche attivano il display</translation> <translation>Notifiche attivano il display</translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -843,6 +843,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Użyj międzynarodowego formatu, %1</translation> <translation>Użyj międzynarodowego formatu, %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>O Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1268,6 +1272,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -843,6 +843,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Используйте международный формат, например %1</translation> <translation>Используйте международный формат, например %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1268,6 +1272,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -833,6 +833,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Använd internationellt format, t.ex. %1</translation> <translation>Använd internationellt format, t.ex. %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>Om Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1249,6 +1253,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation>Avisering tänder skärmen</translation> <translation>Avisering tänder skärmen</translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -823,6 +823,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>使 %1</translation> <translation>使 %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation> Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1230,6 +1234,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -833,6 +833,10 @@
<source>Use the international format, e.g. %1</source> <source>Use the international format, e.g. %1</source>
<translation>Use the international format, e.g. %1</translation> <translation>Use the international format, e.g. %1</translation>
</message> </message>
<message>
<source>About Fernschreiber</source>
<translation>About Fernschreiber</translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>
@ -1249,6 +1253,14 @@
<source>Notification turns on the display</source> <source>Notification turns on the display</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Storage</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>