Ordered settings.hh and settings.cpp

This commit is contained in:
Michael Käufl 2014-10-07 17:33:29 +02:00 committed by Michael Käufl
parent 6bf0b2845b
commit fc8e61f213
2 changed files with 213 additions and 154 deletions

View file

@ -32,6 +32,7 @@ Settings *Settings::instance() {
return m_instance.data();
}
// Login Credentials
void Settings::setServername(QString servername) {
if (_servername != servername) {
_servername = servername;
@ -72,6 +73,15 @@ void Settings::setHttpauthPassword(QString password) {
}
}
void Settings::setIgnoreSSLErrors(bool ignoreSSLErrors) {
if (_ignoreSSLErrors != ignoreSSLErrors) {
_ignoreSSLErrors = ignoreSSLErrors;
m_settings->setValue("ignoreSSLErrors", _ignoreSSLErrors);
emit ignoreSSLErrorsChanged();
}
}
// Startup
void Settings::setAutologin(bool autologin) {
if (_autologin != autologin) {
_autologin = autologin;
@ -88,54 +98,6 @@ void Settings::setUseAutologin(bool useAutologin) {
}
}
void Settings::setIgnoreSSLErrors(bool ignoreSSLErrors) {
if (_ignoreSSLErrors != ignoreSSLErrors) {
_ignoreSSLErrors = ignoreSSLErrors;
m_settings->setValue("ignoreSSLErrors", _ignoreSSLErrors);
emit ignoreSSLErrorsChanged();
}
}
void Settings::setWhiteTheme(bool whiteTheme) {
if (_whiteTheme != whiteTheme) {
_whiteTheme = whiteTheme;
m_settings->setValue("whiteTheme", _whiteTheme);
emit whiteThemeChanged();
}
}
void Settings::setFeeditemsOrder(int feeditemsOrder) {
if (_feeditemsOrder != feeditemsOrder) {
_feeditemsOrder = feeditemsOrder;
m_settings->setValue("feeditemsOrder", _feeditemsOrder);
emit feeditemsOrderChanged();
}
}
void Settings::setDisplayIcons(bool displayIcons) {
if (_displayIcons != displayIcons) {
_displayIcons = displayIcons;
m_settings->setValue("displayIcons", _displayIcons);
emit displayIconsChanged();
}
}
void Settings::setWebviewFontSize(int webviewFontSize) {
if (_webviewFontSize != webviewFontSize) {
_webviewFontSize = webviewFontSize;
m_settings->setValue("webviewFontSize", _webviewFontSize);
emit webviewFontSizeChanged();
}
}
void Settings::setAutoMarkRead(bool autoMarkRead) {
if (_autoMarkRead != autoMarkRead) {
_autoMarkRead = autoMarkRead;
m_settings->setValue("autoMarkRead", _autoMarkRead);
emit autoMarkReadChanged();
}
}
void Settings::setUseAllFeedsOnStartup(bool useAllFeedsOnStartup) {
if (_useAllFeedsOnStartup != useAllFeedsOnStartup) {
_useAllFeedsOnStartup = useAllFeedsOnStartup;
@ -144,6 +106,15 @@ void Settings::setUseAllFeedsOnStartup(bool useAllFeedsOnStartup) {
}
}
// Feeds
void Settings::setDisplayIcons(bool displayIcons) {
if (_displayIcons != displayIcons) {
_displayIcons = displayIcons;
m_settings->setValue("displayIcons", _displayIcons);
emit displayIconsChanged();
}
}
void Settings::setWhiteBackgroundOnIcons(bool whiteBackgroundOnIcons) {
if (_whiteBackgroundOnIcons != whiteBackgroundOnIcons) {
_whiteBackgroundOnIcons = whiteBackgroundOnIcons;
@ -152,11 +123,37 @@ void Settings::setWhiteBackgroundOnIcons(bool whiteBackgroundOnIcons) {
}
}
void Settings::setShowAll(bool showAll) {
if (_showAll != showAll) {
_showAll = showAll;
m_settings->setValue("showAll", _showAll);
emit showAllChanged();
// Item List
void Settings::setFeeditemsOrder(int feeditemsOrder) {
if (_feeditemsOrder != feeditemsOrder) {
_feeditemsOrder = feeditemsOrder;
m_settings->setValue("feeditemsOrder", _feeditemsOrder);
emit feeditemsOrderChanged();
}
}
void Settings::setShowExcerpt(bool showExcerpt) {
if (_showExcerpt != showExcerpt) {
_showExcerpt = showExcerpt;
m_settings->setValue("showExcerpt", _showExcerpt);
emit showExcerptChanged();
}
}
void Settings::setDisplayLabels(bool displayLabels) {
if (_displayLabels != displayLabels) {
_displayLabels = displayLabels;
m_settings->setValue("displayLabels", _displayLabels);
emit displayLabelsChanged();
}
}
// Items
void Settings::setAutoMarkRead(bool autoMarkRead) {
if (_autoMarkRead != autoMarkRead) {
_autoMarkRead = autoMarkRead;
m_settings->setValue("autoMarkRead", _autoMarkRead);
emit autoMarkReadChanged();
}
}
@ -176,43 +173,64 @@ void Settings::setStripInvisibleImg(bool stripInvisibleImg) {
}
}
void Settings::setDisplayLabels(bool displayLabels) {
if (_displayLabels != displayLabels) {
_displayLabels = displayLabels;
m_settings->setValue("displayLabels", _displayLabels);
emit displayLabelsChanged();
void Settings::setWebviewFontSize(int webviewFontSize) {
if (_webviewFontSize != webviewFontSize) {
_webviewFontSize = webviewFontSize;
m_settings->setValue("webviewFontSize", _webviewFontSize);
emit webviewFontSizeChanged();
}
}
void Settings::setShowExcerpt(bool showExcerpt) {
if (_showExcerpt != showExcerpt) {
_showExcerpt = showExcerpt;
m_settings->setValue("showExcerpt", _showExcerpt);
emit showExcerptChanged();
// Harmattan
void Settings::setWhiteTheme(bool whiteTheme) {
if (_whiteTheme != whiteTheme) {
_whiteTheme = whiteTheme;
m_settings->setValue("whiteTheme", _whiteTheme);
emit whiteThemeChanged();
}
}
// Other
void Settings::setShowAll(bool showAll) {
if (_showAll != showAll) {
_showAll = showAll;
m_settings->setValue("showAll", _showAll);
emit showAllChanged();
}
}
Settings::Settings(QObject *parent) : QObject(parent), m_settings(new QSettings(this)) {
// Login Credentials
_servername = m_settings->value("servername", "http://").toString();
_username = m_settings->value("username", "").toString();
_password = m_settings->value("password", "").toString();
_autologin = m_settings->value("autologin", false).toBool();
_useAutologin = m_settings->value("useAutologin", true).toBool();
_ignoreSSLErrors = m_settings->value("ignoreSSLErrors", false).toBool();
_httpauthuser = m_settings->value("httpauthusername", "").toString();
_httpauthpasswd = m_settings->value("httpauthpassword", "").toString();
_ignoreSSLErrors = m_settings->value("ignoreSSLErrors", false).toBool();
_whiteTheme = m_settings->value("whiteTheme", true).toBool();
_feeditemsOrder = m_settings->value("feeditemsOrder", 0).toInt();
_displayIcons = m_settings->value("displayIcons", true).toBool();
_webviewFontSize = m_settings->value("webviewFontSize", 22).toInt();
_autoMarkRead = m_settings->value("autoMarkRead", true).toBool();
// Startup
_autologin = m_settings->value("autologin", false).toBool();
_useAutologin = m_settings->value("useAutologin", true).toBool();
_useAllFeedsOnStartup = m_settings->value("useAllFeedsOnStartup", false).toBool();
// Feeds
_displayIcons = m_settings->value("displayIcons", true).toBool();
_whiteBackgroundOnIcons = m_settings->value("whiteBackgroundOnIcons", true).toBool();
_showAll = m_settings->value("showAll", false).toBool();
// Item List
_feeditemsOrder = m_settings->value("feeditemsOrder", 0).toInt();
_showExcerpt = m_settings->value("showExcerpt", true).toBool();
_displayLabels = m_settings->value("displayLabels", true).toBool();
// Items
_autoMarkRead = m_settings->value("autoMarkRead", true).toBool();
_displayImages = m_settings->value("displayImages", true).toBool();
_stripInvisibleImg = m_settings->value("stripInvisibleImg", false).toBool();
_displayLabels = m_settings->value("displayLabels", true).toBool();
_showExcerpt = m_settings->value("showExcerpt", true).toBool();
_webviewFontSize = m_settings->value("webviewFontSize", 22).toInt();
// Harmattan
_whiteTheme = m_settings->value("whiteTheme", true).toBool();
// Other
_showAll = m_settings->value("showAll", false).toBool();
}

View file

@ -32,31 +32,44 @@ class Settings : public QObject
{
Q_OBJECT
// Login Credentials
Q_PROPERTY(QString servername READ servername WRITE setServername NOTIFY servernameChanged)
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY(bool autologin READ hasAutologin WRITE setAutologin NOTIFY autologinChanged)
Q_PROPERTY(bool useAutologin READ hasUseAutologin WRITE setUseAutologin NOTIFY useAutologinChanged)
Q_PROPERTY(bool ignoreSSLErrors READ ignoreSSLErrors WRITE setIgnoreSSLErrors NOTIFY ignoreSSLErrorsChanged)
Q_PROPERTY(QString httpauthusername READ httpauthUsername WRITE setHttpauthUsername NOTIFY httpauthUsernameChanged)
Q_PROPERTY(QString httpauthpassword READ httpauthPassword WRITE setHttpauthPassword NOTIFY httpauthPasswordChanged)
Q_PROPERTY(bool ignoreSSLErrors READ ignoreSSLErrors WRITE setIgnoreSSLErrors NOTIFY ignoreSSLErrorsChanged)
Q_PROPERTY(bool whiteTheme READ isWhiteTheme WRITE setWhiteTheme NOTIFY whiteThemeChanged)
Q_PROPERTY(int feeditemsOrder READ feeditemsOrder WRITE setFeeditemsOrder NOTIFY feeditemsOrderChanged)
Q_PROPERTY(bool displayIcons READ displayIcons WRITE setDisplayIcons NOTIFY displayIconsChanged)
Q_PROPERTY(int webviewFontSize READ webviewFontSize WRITE setWebviewFontSize NOTIFY webviewFontSizeChanged)
Q_PROPERTY(bool autoMarkRead READ autoMarkRead WRITE setAutoMarkRead NOTIFY autoMarkReadChanged)
// Startup
Q_PROPERTY(bool autologin READ hasAutologin WRITE setAutologin NOTIFY autologinChanged)
Q_PROPERTY(bool useAutologin READ hasUseAutologin WRITE setUseAutologin NOTIFY useAutologinChanged)
Q_PROPERTY(bool useAllFeedsOnStartup READ useAllFeedsOnStartup WRITE setUseAllFeedsOnStartup NOTIFY useAllFeedsOnStartupChanged)
// Feeds
Q_PROPERTY(bool displayIcons READ displayIcons WRITE setDisplayIcons NOTIFY displayIconsChanged)
Q_PROPERTY(bool whiteBackgroundOnIcons READ whiteBackgroundOnIcons WRITE setWhiteBackgroundOnIcons NOTIFY whiteBackgroundOnIconsChanged)
Q_PROPERTY(bool showAll READ showAll WRITE setShowAll NOTIFY showAllChanged)
// Item List
Q_PROPERTY(int feeditemsOrder READ feeditemsOrder WRITE setFeeditemsOrder NOTIFY feeditemsOrderChanged)
Q_PROPERTY(bool showExcerpt READ showExcerpt WRITE setShowExcerpt NOTIFY showExcerptChanged)
Q_PROPERTY(bool displayLabels READ displayLabels WRITE setDisplayLabels NOTIFY displayLabelsChanged)
// Items
Q_PROPERTY(bool autoMarkRead READ autoMarkRead WRITE setAutoMarkRead NOTIFY autoMarkReadChanged)
Q_PROPERTY(bool displayImages READ displayImages WRITE setDisplayImages NOTIFY displayImagesChanged)
Q_PROPERTY(bool stripInvisibleImg READ stripInvisibleImg WRITE setStripInvisibleImg NOTIFY stripInvisibleImgChanged)
Q_PROPERTY(bool displayLabels READ displayLabels WRITE setDisplayLabels NOTIFY displayLabelsChanged)
Q_PROPERTY(bool showExcerpt READ showExcerpt WRITE setShowExcerpt NOTIFY showExcerptChanged)
Q_PROPERTY(int webviewFontSize READ webviewFontSize WRITE setWebviewFontSize NOTIFY webviewFontSizeChanged)
// Harmattan
Q_PROPERTY(bool whiteTheme READ isWhiteTheme WRITE setWhiteTheme NOTIFY whiteThemeChanged)
// Other
Q_PROPERTY(bool showAll READ showAll WRITE setShowAll NOTIFY showAllChanged)
public:
static Settings *instance();
// Login Credentials
QString servername() const {
return this->_servername;
}
@ -72,21 +85,6 @@ public:
}
void setPassword(QString password);
bool hasAutologin() const {
return this->_autologin;
}
void setAutologin(bool autologin);
bool hasUseAutologin() const {
return this->_useAutologin;
}
void setUseAutologin(bool useAutologin);
bool ignoreSSLErrors() const {
return this->_ignoreSSLErrors;
}
void setIgnoreSSLErrors(bool ignoreSSLErrors);
QString httpauthUsername() const {
return this->_httpauthuser;
}
@ -97,45 +95,59 @@ public:
}
void setHttpauthPassword(QString password);
bool isWhiteTheme() const {
return this->_whiteTheme;
bool ignoreSSLErrors() const {
return this->_ignoreSSLErrors;
}
void setWhiteTheme(bool whiteTheme);
void setIgnoreSSLErrors(bool ignoreSSLErrors);
bool feeditemsOrder() const {
return this->_feeditemsOrder;
// Startup
bool hasAutologin() const {
return this->_autologin;
}
void setFeeditemsOrder(int feeditemsOrder);
void setAutologin(bool autologin);
bool displayIcons() const {
return this->_displayIcons;
bool hasUseAutologin() const {
return this->_useAutologin;
}
void setDisplayIcons(bool displayIcons);
int webviewFontSize() const {
return this->_webviewFontSize;
}
void setWebviewFontSize(int webviewFontSize);
bool autoMarkRead() const {
return this->_autoMarkRead;
}
void setAutoMarkRead(bool autoMarkRead);
void setUseAutologin(bool useAutologin);
bool useAllFeedsOnStartup() const {
return this->_useAllFeedsOnStartup;
}
void setUseAllFeedsOnStartup(bool useAllFeedsOnStartup);
// Feeds
bool displayIcons() const {
return this->_displayIcons;
}
void setDisplayIcons(bool displayIcons);
bool whiteBackgroundOnIcons() const {
return this->_whiteBackgroundOnIcons;
}
void setWhiteBackgroundOnIcons(bool whiteBackgroundOnIcons);
bool showAll() const {
return this->_showAll;
// Item List
bool feeditemsOrder() const {
return this->_feeditemsOrder;
}
void setShowAll(bool showAll);
void setFeeditemsOrder(int feeditemsOrder);
bool showExcerpt() const {
return this->_showExcerpt;
}
void setShowExcerpt(bool showExcerpt);
bool displayLabels() const {
return this->_displayLabels;
}
void setDisplayLabels(bool displayLabels);
// Items
bool autoMarkRead() const {
return this->_autoMarkRead;
}
void setAutoMarkRead(bool autoMarkRead);
bool displayImages() const {
return this->_displayImages;
@ -147,39 +159,57 @@ public:
}
void setStripInvisibleImg(bool stripInvisibleImg);
bool displayLabels() const {
return this->_displayLabels;
int webviewFontSize() const {
return this->_webviewFontSize;
}
void setDisplayLabels(bool displayLabels);
void setWebviewFontSize(int webviewFontSize);
bool showExcerpt() const {
return this->_showExcerpt;
// Harmattan
bool isWhiteTheme() const {
return this->_whiteTheme;
}
void setShowExcerpt(bool showExcerpt);
void setWhiteTheme(bool whiteTheme);
// Other
bool showAll() const {
return this->_showAll;
}
void setShowAll(bool showAll);
signals:
// Login Credentials
void servernameChanged();
void usernameChanged();
void passwordChanged();
void autologinChanged();
void useAutologinChanged();
void ignoreSSLErrorsChanged();
void httpauthUsernameChanged();
void httpauthPasswordChanged();
void ignoreSSLErrorsChanged();
void whiteThemeChanged();
void feeditemsOrderChanged();
void displayIconsChanged();
void webviewFontSizeChanged();
void autoMarkReadChanged();
// Startup
void autologinChanged();
void useAutologinChanged();
void useAllFeedsOnStartupChanged();
// Feeds
void displayIconsChanged();
void whiteBackgroundOnIconsChanged();
void showAllChanged();
// Item List
void feeditemsOrderChanged();
void showExcerptChanged();
void displayLabelsChanged();
// Items
void autoMarkReadChanged();
void displayImagesChanged();
void stripInvisibleImgChanged();
void displayLabelsChanged();
void showExcerptChanged();
void webviewFontSizeChanged();
// Harmattan
void whiteThemeChanged();
// Other
void showAllChanged();
private:
static QScopedPointer<Settings> m_instance;
@ -189,27 +219,38 @@ private:
QSettings *m_settings;
// Login Credentials
QString _servername;
QString _username;
QString _password;
bool _autologin;
bool _useAutologin;
bool _ignoreSSLErrors;
QString _httpauthuser;
QString _httpauthpasswd;
bool _ignoreSSLErrors;
bool _whiteTheme;
int _feeditemsOrder;
bool _displayIcons;
int _webviewFontSize;
bool _autoMarkRead;
// Startup
bool _autologin;
bool _useAutologin;
bool _useAllFeedsOnStartup;
// Feeds
bool _displayIcons;
bool _whiteBackgroundOnIcons;
bool _showAll;
// Item List
int _feeditemsOrder;
bool _showExcerpt;
bool _displayLabels;
// Items
bool _autoMarkRead;
bool _displayImages;
bool _stripInvisibleImg;
bool _displayLabels;
bool _showExcerpt;
int _webviewFontSize;
// Harmattan
bool _whiteTheme;
// Other
bool _showAll;
};
#endif // SETTINGS_HH