Added storage optimizer option
This commit is contained in:
parent
4712d3dc0d
commit
b649b71868
5 changed files with 68 additions and 8 deletions
|
@ -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 {}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace {
|
|||
const QString STATUS("status");
|
||||
const QString ID("id");
|
||||
const QString TYPE("type");
|
||||
const QString VALUE("value");
|
||||
|
||||
const QString _TYPE("@type");
|
||||
const QString _EXTRA("@extra");
|
||||
}
|
||||
|
@ -114,6 +116,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();
|
||||
|
||||
|
@ -477,14 +480,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)
|
||||
|
@ -1122,6 +1136,11 @@ void TDLibWrapper::handleOpenWithChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void TDLibWrapper::handleStorageOptimizerChanged()
|
||||
{
|
||||
setOptionBoolean("use_storage_optimizer", appSettings->storageOptimizer());
|
||||
}
|
||||
|
||||
void TDLibWrapper::setInitialParameters()
|
||||
{
|
||||
LOG("Sending initial parameters to TD Lib");
|
||||
|
@ -1140,6 +1159,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);
|
||||
|
|
|
@ -134,6 +134,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);
|
||||
|
@ -242,8 +243,10 @@ public slots:
|
|||
void handleStickerSets(const QVariantList &stickerSets);
|
||||
void handleEmojiSearchCompleted(const QString &queryString, const QVariantList &resultList);
|
||||
void handleOpenWithChanged();
|
||||
void handleStorageOptimizerChanged();
|
||||
|
||||
private:
|
||||
void setOption(const QString &name, const QString &type, const QVariant &value);
|
||||
void setInitialParameters();
|
||||
void setEncryptionKey();
|
||||
void setLogVerbosityLevel();
|
||||
|
|
Loading…
Reference in a new issue