diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index aebf817..c28f5e8 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -156,39 +156,48 @@ Page { } } - Text { - x: Theme.horizontalPageMargin - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - horizontalAlignment: Text.AlignHCenter - text: qsTr("Logged in as %1").arg(Emoji.emojify(aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name, Theme.fontSizeSmall)) - font.pixelSize: Theme.fontSizeSmall - wrapMode: Text.Wrap - color: Theme.primaryColor - textFormat: Text.StyledText - anchors { - horizontalCenter: parent.horizontalCenter - } - } + Loader { + active: !!aboutPage.userInformation.phone_number + width: parent.width + sourceComponent: Component { + Column { - ProfileThumbnail { - photoData: aboutPage.userInformation.profile_photo.small - width: Theme.itemSizeExtraLarge - height: Theme.itemSizeExtraLarge - replacementStringHint: aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name - anchors { - horizontalCenter: parent.horizontalCenter - } - } + Text { + x: Theme.horizontalPageMargin + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + horizontalAlignment: Text.AlignHCenter + text: qsTr("Logged in as %1").arg(Emoji.emojify(aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name, Theme.fontSizeSmall)) + font.pixelSize: Theme.fontSizeSmall + wrapMode: Text.Wrap + color: Theme.primaryColor + textFormat: Text.StyledText + 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 + ProfileThumbnail { + photoData: aboutPage.userInformation.profile_photo.small + width: Theme.itemSizeExtraLarge + height: Theme.itemSizeExtraLarge + replacementStringHint: aboutPage.userInformation.first_name + " " + aboutPage.userInformation.last_name + 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 + } + } + } } } diff --git a/qml/pages/InitializationPage.qml b/qml/pages/InitializationPage.qml index 2e839d4..5648151 100644 --- a/qml/pages/InitializationPage.qml +++ b/qml/pages/InitializationPage.qml @@ -105,6 +105,13 @@ Page { Behavior on contentHeight { NumberAnimation {} } anchors.fill: parent + PullDownMenu { + MenuItem { + text: qsTr("About Fernschreiber") + onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml")) + } + } + Column { id: content width: parent.width diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 1218704..e9abe19 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -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 {} diff --git a/src/appsettings.cpp b/src/appsettings.cpp index 5f402ff..497578f 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -27,6 +27,7 @@ namespace { const QString KEY_ANIMATE_STICKERS("animateStickers"); const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); + const QString KEY_STORAGE_OPTIMIZER("storageOptimizer"); } AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings") @@ -116,3 +117,17 @@ void AppSettings::setNotificationFeedback(NotificationFeedback feedback) 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(); + } +} diff --git a/src/appsettings.h b/src/appsettings.h index a813300..bb63cdf 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -29,6 +29,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged) Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) + Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) public: enum NotificationFeedback { @@ -59,6 +60,9 @@ public: NotificationFeedback notificationFeedback() const; void setNotificationFeedback(NotificationFeedback feedback); + bool storageOptimizer() const; + void setStorageOptimizer(bool enable); + signals: void sendByEnterChanged(); void useOpenWithChanged(); @@ -66,6 +70,7 @@ signals: void animateStickersChanged(); void notificationTurnsDisplayOnChanged(); void notificationFeedbackChanged(); + void storageOptimizerChanged(); private: QSettings settings; diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index d9dd99c..dfc1dde 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -40,6 +40,7 @@ namespace { const QString LAST_NAME("last_name"); const QString FIRST_NAME("first_name"); const QString USERNAME("username"); + const QString VALUE("value"); const QString _TYPE("@type"); 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(this->appSettings, SIGNAL(useOpenWithChanged()), this, SLOT(handleOpenWithChanged())); + connect(this->appSettings, SIGNAL(storageOptimizerChanged()), this, SLOT(handleStorageOptimizerChanged())); this->tdLibReceiver->start(); @@ -482,14 +484,25 @@ void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId) void TDLibWrapper::setOptionInteger(const QString &optionName, int optionValue) { LOG("Setting integer option" << optionName << optionValue); - QVariantMap requestObject; - requestObject.insert(_TYPE, "setOption"); - requestObject.insert("name", optionName); - QVariantMap optionValueMap; - optionValueMap.insert(_TYPE, "optionValueInteger"); - optionValueMap.insert("value", optionValue); - requestObject.insert("value", optionValueMap); - this->sendRequest(requestObject); + setOption(optionName, "optionValueInteger", optionValue); +} + +void TDLibWrapper::setOptionBoolean(const QString &optionName, bool optionValue) +{ + LOG("Setting boolean option" << optionName << optionValue); + setOption(optionName, "optionValueBoolean", optionValue); +} + +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 ¬ificationSettings) @@ -1177,6 +1190,11 @@ void TDLibWrapper::handleSecretChatUpdated(const QString &secretChatId, const QV emit secretChatUpdated(secretChatId, secretChat); } +void TDLibWrapper::handleStorageOptimizerChanged() +{ + setOptionBoolean("use_storage_optimizer", appSettings->storageOptimizer()); +} + void TDLibWrapper::setInitialParameters() { 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("system_version", QSysInfo::prettyProductName()); initialParameters.insert("application_version", "0.5"); + initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer()); // initialParameters.insert("use_test_dc", true); requestObject.insert("parameters", initialParameters); this->sendRequest(requestObject); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 23ff18f..426d5c6 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -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 getMessage(const QString &chatId, const QString &messageId); 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 ¬ificationSettings); Q_INVOKABLE void editMessageText(const QString &chatId, const QString &messageId, const QString &message); Q_INVOKABLE void deleteMessages(const QString &chatId, const QVariantList messageIds); @@ -260,8 +261,10 @@ public slots: void handleOpenWithChanged(); void handleSecretChatReceived(const QString &secretChatId, const QVariantMap &secretChat); void handleSecretChatUpdated(const QString &secretChatId, const QVariantMap &secretChat); + void handleStorageOptimizerChanged(); private: + void setOption(const QString &name, const QString &type, const QVariant &value); void setInitialParameters(); void setEncryptionKey(); void setLogVerbosityLevel(); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index a944b45..f567081 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -833,6 +833,10 @@ Use the international format, e.g. %1 Nutzen Sie das internationale Format, z.B. %1 + + About Fernschreiber + Über Fernschreiber + LocationPreview @@ -1249,6 +1253,14 @@ Notification turns on the display Hinweis schaltet den Bildschirm an + + Storage + Speicher + + + Enable storage optimizer + Speicheroptimierer einschalten + StickerPicker diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index e1ba79b..d9aad5d 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -833,6 +833,10 @@ Use the international format, e.g. %1 Use the international format, e.g. %1 + + About Fernschreiber + About Fernschreiber + LocationPreview @@ -1249,6 +1253,14 @@ Notification turns on the display Notification turns on the display + + Storage + Storage + + + Enable storage optimizer + Enable storage optimizer + StickerPicker diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 770a726..8949356 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -823,6 +823,10 @@ Use the international format, e.g. %1 Usar el formato internacional %1 + + About Fernschreiber + Acerca de + LocationPreview @@ -1230,6 +1234,14 @@ Notification turns on the display + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 9d03ed7..22ace3a 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -834,6 +834,10 @@ Use the international format, e.g. %1 Käytä kansainvälistä muotoa, esimerkiksi %1 + + About Fernschreiber + Tietoa Fernschreiberista + LocationPreview @@ -1250,6 +1254,14 @@ Notification turns on the display Ilmoitus kytkee näytön päälle + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index b34e31d..0fbcec8 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -823,6 +823,10 @@ Use the international format, e.g. %1 + + About Fernschreiber + A Fernschreiber névjegye + LocationPreview @@ -1230,6 +1234,14 @@ Notification turns on the display + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index af11ec6..3cabd13 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -833,6 +833,10 @@ Loading... Carica... + + About Fernschreiber + Informazioni su Fernschreiber + LocationPreview @@ -1249,6 +1253,14 @@ Notification turns on the display Notifiche attivano il display + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 8de180d..ff4c3c6 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -843,6 +843,10 @@ Use the international format, e.g. %1 Użyj międzynarodowego formatu, %1 + + About Fernschreiber + O Fernschreiber + LocationPreview @@ -1268,6 +1272,14 @@ Notification turns on the display + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 19e46da..74c69a9 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -843,6 +843,10 @@ Use the international format, e.g. %1 Используйте международный формат, например %1 + + About Fernschreiber + + LocationPreview @@ -1268,6 +1272,14 @@ Notification turns on the display + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index b262811..2724b54 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -833,6 +833,10 @@ Use the international format, e.g. %1 Använd internationellt format, t.ex. %1 + + About Fernschreiber + Om Fernschreiber + LocationPreview @@ -1249,6 +1253,14 @@ Notification turns on the display Avisering tänder skärmen + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 13c7f0e..0bf69e7 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -823,6 +823,10 @@ Use the international format, e.g. %1 请使用国际区号格式,例如 %1 + + About Fernschreiber + 关于 Fernschreiber + LocationPreview @@ -1230,6 +1234,14 @@ Notification turns on the display 收到通知时点亮屏幕 + + Storage + + + + Enable storage optimizer + + StickerPicker diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 5be7bdd..5d67afc 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -833,6 +833,10 @@ Use the international format, e.g. %1 Use the international format, e.g. %1 + + About Fernschreiber + About Fernschreiber + LocationPreview @@ -1249,6 +1253,14 @@ Notification turns on the display + + Storage + + + + Enable storage optimizer + + StickerPicker