Added showStickersAsImages option

This commit is contained in:
Slava Monich 2020-10-09 18:09:29 +03:00
parent 0dbc0e5887
commit c60f2e59ce
2 changed files with 20 additions and 0 deletions

View file

@ -22,6 +22,7 @@
namespace { namespace {
const QString KEY_SEND_BY_ENTER("sendByEnter"); const QString KEY_SEND_BY_ENTER("sendByEnter");
const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
} }
AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings") AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings")
@ -41,3 +42,17 @@ void AppSettings::setSendByEnter(bool sendByEnter)
emit sendByEnterChanged(); emit sendByEnterChanged();
} }
} }
bool AppSettings::showStickersAsImages() const
{
return settings.value(KEY_SHOW_STICKERS_AS_IMAGES, true).toBool();
}
void AppSettings::setShowStickersAsImages(bool showAsImages)
{
if (showStickersAsImages() != showAsImages) {
LOG(KEY_SHOW_STICKERS_AS_IMAGES << showAsImages);
settings.setValue(KEY_SHOW_STICKERS_AS_IMAGES, showAsImages);
emit showStickersAsImagesChanged();
}
}

View file

@ -24,6 +24,7 @@
class AppSettings : public QObject { class AppSettings : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool sendByEnter READ getSendByEnter WRITE setSendByEnter NOTIFY sendByEnterChanged) Q_PROPERTY(bool sendByEnter READ getSendByEnter WRITE setSendByEnter NOTIFY sendByEnterChanged)
Q_PROPERTY(bool showStickersAsImages READ showStickersAsImages WRITE setShowStickersAsImages NOTIFY showStickersAsImagesChanged)
public: public:
AppSettings(QObject *parent = Q_NULLPTR); AppSettings(QObject *parent = Q_NULLPTR);
@ -31,8 +32,12 @@ public:
bool getSendByEnter() const; bool getSendByEnter() const;
void setSendByEnter(bool sendByEnter); void setSendByEnter(bool sendByEnter);
bool showStickersAsImages() const;
void setShowStickersAsImages(bool showAsImages);
signals: signals:
void sendByEnterChanged(); void sendByEnterChanged();
void showStickersAsImagesChanged();
private: private:
QSettings settings; QSettings settings;