source: SMSSender/src/business/BCSettings.cpp @ 56:e63ceb8090cd

3.0
Last change on this file since 56:e63ceb8090cd was 56:e63ceb8090cd, checked in by Sämy Zehnder <saemy.zehnder@…>, 9 years ago
  • Renamed accountmodel to accounttreemodel
  • Implemented creation of new contact if number is unknown in vcmain
  • Areacode is now in its own field in vceditcontact
  • Accountlist in vcmain is now controlled by a model (Needs filtering of only active ones)
  • Settingspath is dynamic and user-based now
File size: 4.7 KB
Line 
1/*
2 * BCSettings.cpp
3 *
4 *  Created on: May 1, 2009
5 *      Author: saemy
6 */
7
8#include "BCSettings.h"
9
10#include <QDirIterator>
11#include <QFileInfo>
12#include <QCoreApplication>
13#include <QDesktopServices>
14
15#include "../persistence/PersistenceFactory.h"
16
17BCSettings * BCSettings::instance_=0;
18BCSettings* BCSettings::instance(){
19    if (instance_ == 0)
20        instance_ = new BCSettings;
21    return instance_;
22}
23
24ISettings* BCSettings::getSettings(){
25    return PersistenceFactory::instance()->getSettings();
26}
27
28QString BCSettings::getSettingsPath(){
29    if (QFile::exists(qApp->applicationDirPath() + "/data.db")) {
30        return qApp->applicationDirPath() + "/";
31    } else {
32        return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/gorrion/SMSSender/";
33    }
34}
35
36const QString BCSettings::getLocalePath(){
37    return qApp->applicationDirPath() + "/locale/";
38}
39
40QLocale BCSettings::getLocale(){
41    return getSettings()->getLocale();
42}
43
44QList<QLocale> BCSettings::getLocales(){
45    QList<QLocale> return_;
46
47    return_.append(QLocale(QLocale::English)); // Default language
48
49    QDirIterator i(getLocalePath());
50    while (i.hasNext()) {
51         QString localeStr = QFileInfo(i.next()).baseName();
52         QLocale locale(localeStr);
53         if ((locale != QLocale::c()) && (!return_.contains(locale))){ // Was the creation of the locale successful?
54             return_.append(locale);
55         }
56     }
57     return return_;
58}
59
60bool BCSettings::getCheckForUpdates(){
61    return getSettings()->getCheckForUpdates();
62}
63
64bool BCSettings::getAddSuffix(){
65    return getSettings()->getAddSuffix();
66}
67
68QString BCSettings::getSMSSuffix(){
69    return getSettings()->getSMSSuffix();
70}
71
72QString BCSettings::getActiveAccountId(){
73    return getSettings()->getActiveAccountId();
74}
75
76bool BCSettings::getShowSentConfirmation(){
77    return getSettings()->getShowSentConfirmation();
78}
79
80
81bool BCSettings::isProxyEnabled(){
82    return getSettings()->isProxyEnabled();
83}
84
85QString BCSettings::getProxyHost(){
86    return getSettings()->getProxyHost();
87}
88
89int BCSettings::getProxyPort(){
90    return getSettings()->getProxyPort();
91}
92
93bool BCSettings::isProxyAuthEnabled(){
94    return getSettings()->isProxyAuthEnabled();
95}
96
97QString BCSettings::getProxyUsername(){
98    return getSettings()->getProxyUsername();
99}
100
101QString BCSettings::getProxyPassword(){
102    return getSettings()->getProxyPassword();
103}
104
105
106SShortcut BCSettings::getNewMessageShortCut(){
107    return getSettings()->getNewMessageShortCut();
108}
109
110SShortcut BCSettings::getClearMessageTextShortCut(){
111    return getSettings()->getClearMessageTextShortCut();
112}
113
114SShortcut BCSettings::getClearRecipientsShortCut(){
115    return getSettings()->getClearRecipientsShortCut();
116}
117
118SShortcut BCSettings::getSendShortCut(){
119    return getSettings()->getSendShortCut();
120}
121
122
123QString BCSettings::getUpdateUrl(){
124    return getSettings()->getUpdateUrl();
125}
126
127
128void BCSettings::setLocale(const QLocale& locale){
129    return getSettings()->setLocale(locale);
130}
131
132void BCSettings::setCheckForUpdates(bool checkForUpdates){
133    return getSettings()->setCheckForUpdates(checkForUpdates);
134}
135
136void BCSettings::setAddSuffix(bool addSuffix){
137    return getSettings()->setAddSuffix(addSuffix);
138}
139
140void BCSettings::setSMSSuffix(const QString& smsSuffix){
141    return getSettings()->setSMSSuffix(smsSuffix);
142}
143
144void BCSettings::setActiveAccountId(const QString& accountId){
145    return getSettings()->setActiveAccountId(accountId);
146}
147
148void BCSettings::setShowSentConfirmation(bool showSentConfirmation){
149    return getSettings()->setShowSentConfirmation(showSentConfirmation);
150}
151
152
153void BCSettings::setProxyEnabled(bool enabled){
154    return getSettings()->setProxyEnabled(enabled);
155}
156
157void BCSettings::setProxyHost(const QString& host){
158    return getSettings()->setProxyHost(host);
159}
160
161void BCSettings::setProxyPort(int port){
162    return getSettings()->setProxyPort(port);
163}
164
165void BCSettings::setProxyAuthEnabled(bool enabled){
166    return getSettings()->setProxyAuthEnabled(enabled);
167}
168
169void BCSettings::setProxyUsername(const QString& username){
170    return getSettings()->setProxyUsername(username);
171}
172
173void BCSettings::setProxyPassword(const QString& password){
174    return getSettings()->setProxyPassword(password);
175}
176
177
178void BCSettings::setNewMessageShortCut(const SShortcut& shortcut){
179    return getSettings()->setNewMessageShortCut(shortcut);
180}
181
182void BCSettings::setClearMessageTextShortCut(const SShortcut& shortcut){
183    return getSettings()->setClearMessageTextShortCut(shortcut);
184}
185
186void BCSettings::setClearRecipientsShortCut(const SShortcut& shortcut){
187    return getSettings()->setClearRecipientsShortCut(shortcut);
188}
189
190void BCSettings::setSendShortCut(const SShortcut& shortcut){
191    return getSettings()->setSendShortCut(shortcut);
192}
Note: See TracBrowser for help on using the repository browser.