| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 or (at your option) any later version | 
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by | 
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | 
| 22 | ** included in the packaging of this file. Please review the following | 
| 23 | ** information to ensure the GNU General Public License requirements will | 
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 25 | ** | 
| 26 | ** $QT_END_LICENSE$ | 
| 27 | ** | 
| 28 | ****************************************************************************/ | 
| 29 |  | 
| 30 | #include <QtVirtualKeyboard/private/settings_p.h> | 
| 31 | #include <QtCore/private/qobject_p.h> | 
| 32 |  | 
| 33 | QT_BEGIN_NAMESPACE | 
| 34 | namespace QtVirtualKeyboard { | 
| 35 |  | 
| 36 | class SettingsPrivate : public QObjectPrivate | 
| 37 | { | 
| 38 | public: | 
| 39 |     SettingsPrivate() : | 
| 40 |         QObjectPrivate(), | 
| 41 |         style(), | 
| 42 |         styleName(), | 
| 43 |         locale(), | 
| 44 |         availableLocales(), | 
| 45 |         activeLocales(), | 
| 46 |         layoutPath(), | 
| 47 |         wclAutoHideDelay(5000), | 
| 48 |         wclAlwaysVisible(false), | 
| 49 |         wclAutoCommitWord(false), | 
| 50 |         fullScreenMode(false) | 
| 51 |     {} | 
| 52 |  | 
| 53 |     QString style; | 
| 54 |     QString styleName; | 
| 55 |     QString locale; | 
| 56 |     QStringList availableLocales; | 
| 57 |     QStringList activeLocales; | 
| 58 |     QUrl layoutPath; | 
| 59 |     int wclAutoHideDelay; | 
| 60 |     bool wclAlwaysVisible; | 
| 61 |     bool wclAutoCommitWord; | 
| 62 |     bool fullScreenMode; | 
| 63 | }; | 
| 64 |  | 
| 65 | static QScopedPointer<Settings> s_settingsInstance; | 
| 66 |  | 
| 67 | /*! | 
| 68 |     \class QtVirtualKeyboard::Settings | 
| 69 |     \internal | 
| 70 | */ | 
| 71 |  | 
| 72 | Settings::Settings(QObject *parent) : | 
| 73 |     QObject(*new SettingsPrivate(), parent) | 
| 74 | { | 
| 75 | } | 
| 76 |  | 
| 77 | Settings *Settings::instance() | 
| 78 | { | 
| 79 |     if (!s_settingsInstance) | 
| 80 |         s_settingsInstance.reset(other: new Settings()); | 
| 81 |     return s_settingsInstance.data(); | 
| 82 | } | 
| 83 |  | 
| 84 | QString Settings::style() const | 
| 85 | { | 
| 86 |     Q_D(const Settings); | 
| 87 |     return d->style; | 
| 88 | } | 
| 89 |  | 
| 90 | void Settings::setStyle(const QString &style) | 
| 91 | { | 
| 92 |     Q_D(Settings); | 
| 93 |     if (d->style != style) { | 
| 94 |         d->style = style; | 
| 95 |         emit styleChanged(); | 
| 96 |     } | 
| 97 | } | 
| 98 |  | 
| 99 | QString Settings::styleName() const | 
| 100 | { | 
| 101 |     Q_D(const Settings); | 
| 102 |     return d->styleName; | 
| 103 | } | 
| 104 |  | 
| 105 | void Settings::setStyleName(const QString &styleName) | 
| 106 | { | 
| 107 |     Q_D(Settings); | 
| 108 |     if (d->styleName != styleName) { | 
| 109 |         d->styleName = styleName; | 
| 110 |         emit styleNameChanged(); | 
| 111 |     } | 
| 112 | } | 
| 113 |  | 
| 114 | QString Settings::locale() const | 
| 115 | { | 
| 116 |     Q_D(const Settings); | 
| 117 |     return d->locale; | 
| 118 | } | 
| 119 |  | 
| 120 | void Settings::setLocale(const QString &locale) | 
| 121 | { | 
| 122 |     Q_D(Settings); | 
| 123 |     if (d->locale != locale) { | 
| 124 |         d->locale = locale; | 
| 125 |         emit localeChanged(); | 
| 126 |     } | 
| 127 | } | 
| 128 |  | 
| 129 | QStringList Settings::availableLocales() const | 
| 130 | { | 
| 131 |     Q_D(const Settings); | 
| 132 |     return d->availableLocales; | 
| 133 | } | 
| 134 |  | 
| 135 | void Settings::setAvailableLocales(const QStringList &availableLocales) | 
| 136 | { | 
| 137 |     Q_D(Settings); | 
| 138 |     if (d->availableLocales != availableLocales) { | 
| 139 |         d->availableLocales = availableLocales; | 
| 140 |         emit availableLocalesChanged(); | 
| 141 |     } | 
| 142 | } | 
| 143 |  | 
| 144 | QStringList Settings::activeLocales() const | 
| 145 | { | 
| 146 |     Q_D(const Settings); | 
| 147 |     return d->activeLocales; | 
| 148 | } | 
| 149 |  | 
| 150 | void Settings::setActiveLocales(const QStringList &activeLocales) | 
| 151 | { | 
| 152 |     Q_D(Settings); | 
| 153 |     if (d->activeLocales != activeLocales) { | 
| 154 |         d->activeLocales = activeLocales; | 
| 155 |         emit activeLocalesChanged(); | 
| 156 |     } | 
| 157 | } | 
| 158 |  | 
| 159 | QUrl Settings::layoutPath() const | 
| 160 | { | 
| 161 |     Q_D(const Settings); | 
| 162 |     return d->layoutPath; | 
| 163 | } | 
| 164 |  | 
| 165 | void Settings::setLayoutPath(const QUrl &layoutPath) | 
| 166 | { | 
| 167 |     Q_D(Settings); | 
| 168 |     if (d->layoutPath != layoutPath) { | 
| 169 |         d->layoutPath = layoutPath; | 
| 170 |         emit layoutPathChanged(); | 
| 171 |     } | 
| 172 | } | 
| 173 |  | 
| 174 | int Settings::wclAutoHideDelay() const | 
| 175 | { | 
| 176 |     Q_D(const Settings); | 
| 177 |     return d->wclAutoHideDelay; | 
| 178 | } | 
| 179 |  | 
| 180 | void Settings::setWclAutoHideDelay(int wclAutoHideDelay) | 
| 181 | { | 
| 182 |     Q_D(Settings); | 
| 183 |     if (d->wclAutoHideDelay != wclAutoHideDelay) { | 
| 184 |         d->wclAutoHideDelay = wclAutoHideDelay; | 
| 185 |         emit wclAutoHideDelayChanged(); | 
| 186 |     } | 
| 187 | } | 
| 188 |  | 
| 189 | bool Settings::wclAlwaysVisible() const | 
| 190 | { | 
| 191 |     Q_D(const Settings); | 
| 192 |     return d->wclAlwaysVisible; | 
| 193 | } | 
| 194 |  | 
| 195 | void Settings::setWclAlwaysVisible(bool wclAlwaysVisible) | 
| 196 | { | 
| 197 |     Q_D(Settings); | 
| 198 |     if (d->wclAlwaysVisible != wclAlwaysVisible) { | 
| 199 |         d->wclAlwaysVisible = wclAlwaysVisible; | 
| 200 |         emit wclAlwaysVisibleChanged(); | 
| 201 |     } | 
| 202 | } | 
| 203 |  | 
| 204 | bool Settings::wclAutoCommitWord() const | 
| 205 | { | 
| 206 |     Q_D(const Settings); | 
| 207 |     return d->wclAutoCommitWord; | 
| 208 | } | 
| 209 |  | 
| 210 | void Settings::setWclAutoCommitWord(bool wclAutoCommitWord) | 
| 211 | { | 
| 212 |     Q_D(Settings); | 
| 213 |     if (d->wclAutoCommitWord != wclAutoCommitWord) { | 
| 214 |         d->wclAutoCommitWord = wclAutoCommitWord; | 
| 215 |         emit wclAutoCommitWordChanged(); | 
| 216 |     } | 
| 217 | } | 
| 218 |  | 
| 219 | bool Settings::fullScreenMode() const | 
| 220 | { | 
| 221 |     Q_D(const Settings); | 
| 222 |     return d->fullScreenMode; | 
| 223 | } | 
| 224 |  | 
| 225 | void Settings::setFullScreenMode(bool fullScreenMode) | 
| 226 | { | 
| 227 |     Q_D(Settings); | 
| 228 |     if (d->fullScreenMode != fullScreenMode) { | 
| 229 |         d->fullScreenMode = fullScreenMode; | 
| 230 |         emit fullScreenModeChanged(); | 
| 231 |     } | 
| 232 | } | 
| 233 |  | 
| 234 | } // namespace QtVirtualKeyboard | 
| 235 | QT_END_NAMESPACE | 
| 236 |  |