2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _PUMPASETTINGS_H_
21 #define _PUMPASETTINGS_H_
28 #include <QStringList>
30 #include "pumpa_defines.h"
32 class PumpaSettings
: public QObject
{
35 PumpaSettings(QString filename
="", QObject
* parent
=0);
38 static PumpaSettings
* getSettings(bool create
=false, QString filename
="",
41 bool firstStart() const { return m_firstStart
; }
43 bool contains(QString key
) const { return m_s
->contains(key
); }
46 QString
siteUrl() const;
47 QString
userName() const {
48 return getValue("username", "", "Account").toString();
51 QString
clientId() const {
52 return getValue("oauth_client_id", "", "Account").toString();
54 QString
clientSecret() const {
55 return getValue("oauth_client_secret", "", "Account").toString();
58 QString
token() const {
59 return getValue("oauth_token", "", "Account").toString();
61 QString
tokenSecret() const {
62 return getValue("oauth_token_secret", "", "Account").toString();
65 int reloadTime() const;
67 bool useTrayIcon() const {
68 return getValue("use_tray_icon", false).toBool();
71 int highlightFeeds() const;
72 int popupFeeds() const;
75 return getValue("size", QSize(550, 500), "MainWindow").toSize();
79 return getValue("pos", QPoint(0, 0), "MainWindow").toPoint();
82 int defaultToAddress() const {
83 return getValue("default_to", RECIPIENT_PUBLIC
).toInt();
86 int defaultCcAddress() const {
87 return getValue("default_cc", RECIPIENT_FOLLOWERS
).toInt();
90 bool commentOnComments() const {
91 return getValue("comment_on_comments", false).toBool();
94 bool useMarkdown() const {
95 return getValue("use_markdown", false).toBool();
98 bool ignoreSslErrors() const {
99 return getValue("ignore_ssl_errors", false).toBool();
102 QString
locale() const { return getValue("locale", ""). toString(); }
104 QString
linkColor() const { return getValue("link_color", "").toString(); }
106 QString
firehoseUrl() const {
107 return getValue("firehose_url",
108 "https://ofirehose.com/feed.json").toString();
111 int maxTimelineItems() const {
112 return getValue("max_timeline_items", 20).toInt();
115 int maxFirehoseItems() const {
116 return getValue("max_timeline_items", 20).toInt();
119 QStringList
hideAuthors() const {
120 return getValue("minimise_authors", QStringList()).toStringList();
123 bool showPreview() const {
124 return getValue("show_preview", true).toBool();
127 bool showCharCount() const {
128 return getValue("show_charcount", false).toBool();
132 void siteUrl(QString s
) { setValue("site_url", s
, "Account"); }
133 void userName(QString s
) { setValue("username", s
, "Account"); }
135 void clientId(QString s
) { setValue("oauth_client_id", s
, "Account"); }
136 void clientSecret(QString s
) {
137 setValue("oauth_client_secret", s
, "Account");
140 void token(QString s
) { setValue("oauth_token", s
, "Account"); }
141 void tokenSecret(QString s
) { setValue("oauth_token_secret", s
, "Account"); }
143 void reloadTime(int i
) { setValue("reload_time", i
); }
145 void useTrayIcon(bool b
);
147 void highlightFeeds(int i
) { setValue("highlight_feeds", i
); }
148 void popupFeeds(int i
) { setValue("popup_feeds", i
); }
150 void size(QSize s
) { setValue("size", s
, "MainWindow"); }
151 void pos(QPoint p
) { setValue("pos", p
, "MainWindow"); }
153 void defaultToAddress(int i
) { setValue("default_to", i
); }
154 void defaultCcAddress(int i
) { setValue("default_cc", i
); }
156 void commentOnComments(bool b
) { setValue("comment_on_comments", b
); }
158 void useMarkdown(bool b
) { setValue("use_markdown", b
); }
160 void ignoreSslErrors(bool b
) { setValue("ignore_ssl_errors", b
); }
162 void hideAuthors(QStringList sl
) { setValue("minimise_authors", sl
); }
164 void showPreview(bool b
) { setValue("show_preview", b
); }
166 void showCharCount(bool b
) { setValue("show_charcount", b
); }
169 void trayIconChanged();
172 QVariant
getValue(QString name
, QVariant defaultValue
=QVariant(),
173 QString group
="General") const;
174 void setValue(QString name
, QVariant value
, QString group
="General");
182 static PumpaSettings
* s_settings
;
185 #endif /* _PUMPASETTINGS_H_ */