aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/virtualkeyboard/settings.cpp')
-rw-r--r--src/virtualkeyboard/settings.cpp204
1 files changed, 174 insertions, 30 deletions
diff --git a/src/virtualkeyboard/settings.cpp b/src/virtualkeyboard/settings.cpp
index 1d324687..15d66bbc 100644
--- a/src/virtualkeyboard/settings.cpp
+++ b/src/virtualkeyboard/settings.cpp
@@ -1,34 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtVirtualKeyboard/private/settings_p.h>
#include <QtCore/private/qobject_p.h>
+#include <QStandardPaths>
+#include <QFileInfo>
+#include <QDir>
+#include "virtualkeyboarddebug_p.h"
QT_BEGIN_NAMESPACE
namespace QtVirtualKeyboard {
@@ -47,8 +25,29 @@ public:
wclAutoHideDelay(5000),
wclAlwaysVisible(false),
wclAutoCommitWord(false),
- fullScreenMode(false)
- {}
+ fullScreenMode(false),
+ userDataPath(QStringLiteral("%1/qtvirtualkeyboard")
+ .arg(QStandardPaths::writableLocation(
+ QStandardPaths::GenericConfigLocation))),
+ hwrTimeoutForAlphabetic(500),
+ hwrTimeoutForCjk(500),
+ handwritingModeDisabled(false),
+ defaultInputMethodDisabled(false),
+ defaultDictionaryDisabled(false),
+ visibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKey::All),
+ closeOnReturn(false)
+ {
+ ensureUserDataPathExists();
+ }
+
+ void ensureUserDataPathExists() const
+ {
+ if (!userDataPath.isEmpty() && !QFileInfo::exists(userDataPath)) {
+ if (!QDir::root().mkpath(userDataPath)) {
+ VIRTUALKEYBOARD_WARN() << "Cannot create directory for user data" << userDataPath;
+ }
+ }
+ }
QString style;
QString styleName;
@@ -60,6 +59,15 @@ public:
bool wclAlwaysVisible;
bool wclAutoCommitWord;
bool fullScreenMode;
+ QString userDataPath;
+ int hwrTimeoutForAlphabetic;
+ int hwrTimeoutForCjk;
+ Qt::InputMethodHints inputMethodHints;
+ bool handwritingModeDisabled;
+ bool defaultInputMethodDisabled;
+ bool defaultDictionaryDisabled;
+ QtVirtualKeyboard::KeyboardFunctionKeys visibleFunctionKeys;
+ bool closeOnReturn;
};
static QScopedPointer<Settings> s_settingsInstance;
@@ -231,5 +239,141 @@ void Settings::setFullScreenMode(bool fullScreenMode)
}
}
+QString Settings::userDataPath() const
+{
+ Q_D(const Settings);
+ return d->userDataPath;
+}
+
+void Settings::setUserDataPath(const QString &userDataPath)
+{
+ Q_D(Settings);
+ if (d->userDataPath != userDataPath) {
+ d->userDataPath = userDataPath;
+ d->ensureUserDataPathExists();
+ emit userDataPathChanged();
+ }
+}
+
+int Settings::hwrTimeoutForAlphabetic() const
+{
+ Q_D(const Settings);
+ return d->hwrTimeoutForAlphabetic;
+}
+
+void Settings::setHwrTimeoutForAlphabetic(int hwrTimeoutForAlphabetic)
+{
+ Q_D(Settings);
+ if (d->hwrTimeoutForAlphabetic != hwrTimeoutForAlphabetic) {
+ d->hwrTimeoutForAlphabetic = hwrTimeoutForAlphabetic;
+ emit hwrTimeoutForAlphabeticChanged();
+ }
+}
+
+int Settings::hwrTimeoutForCjk() const
+{
+ Q_D(const Settings);
+ return d->hwrTimeoutForCjk;
+}
+
+void Settings::setHwrTimeoutForCjk(int hwrTimeoutForCjk)
+{
+ Q_D(Settings);
+ if (d->hwrTimeoutForCjk != hwrTimeoutForCjk) {
+ d->hwrTimeoutForCjk = hwrTimeoutForCjk;
+ emit hwrTimeoutForCjkChanged();
+ }
+}
+
+Qt::InputMethodHints Settings::inputMethodHints() const
+{
+ Q_D(const Settings);
+ return d->inputMethodHints;
+}
+
+void Settings::setInputMethodHints(const Qt::InputMethodHints &inputMethodHints)
+{
+ Q_D(Settings);
+ if (d->inputMethodHints != inputMethodHints) {
+ d->inputMethodHints = inputMethodHints;
+ emit inputMethodHintsChanged();
+ }
+}
+
+bool Settings::isHandwritingModeDisabled() const
+{
+ Q_D(const Settings);
+ return d->handwritingModeDisabled;
+}
+
+void Settings::setHandwritingModeDisabled(bool handwritingModeDisabled)
+{
+ Q_D(Settings);
+ if (d->handwritingModeDisabled != handwritingModeDisabled) {
+ d->handwritingModeDisabled = handwritingModeDisabled;
+ emit handwritingModeDisabledChanged();
+ }
+}
+
+bool Settings::isDefaultInputMethodDisabled() const
+{
+ Q_D(const Settings);
+ return d->defaultInputMethodDisabled;
+}
+
+void Settings::setDefaultInputMethodDisabled(bool defaultInputMethodDisabled)
+{
+ Q_D(Settings);
+ if (d->defaultInputMethodDisabled != defaultInputMethodDisabled) {
+ d->defaultInputMethodDisabled = defaultInputMethodDisabled;
+ emit defaultInputMethodDisabledChanged();
+ }
+}
+
+bool QtVirtualKeyboard::Settings::isDefaultDictionaryDisabled() const
+{
+ Q_D(const Settings);
+ return d->defaultDictionaryDisabled;
+}
+
+void QtVirtualKeyboard::Settings::setDefaultDictionaryDisabled(bool defaultDictionaryDisabled)
+{
+ Q_D(Settings);
+ if (d->defaultDictionaryDisabled != defaultDictionaryDisabled) {
+ d->defaultDictionaryDisabled = defaultDictionaryDisabled;
+ emit defaultDictionaryDisabledChanged();
+ }
+}
+
+QtVirtualKeyboard::KeyboardFunctionKeys Settings::visibleFunctionKeys() const
+{
+ Q_D(const Settings);
+ return d->visibleFunctionKeys;
+}
+
+void Settings::setVisibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKeys newVisibleFunctionKeys)
+{
+ Q_D(Settings);
+ if (d->visibleFunctionKeys != newVisibleFunctionKeys) {
+ d->visibleFunctionKeys = newVisibleFunctionKeys;
+ emit visibleFunctionKeysChanged();
+ }
+}
+
+bool Settings::closeOnReturn() const
+{
+ Q_D(const Settings);
+ return d->closeOnReturn;
+}
+
+void Settings::setCloseOnReturn(bool enabled)
+{
+ Q_D(Settings);
+ if (d->closeOnReturn != enabled) {
+ d->closeOnReturn = enabled;
+ emit closeOnReturnChanged();
+ }
+}
+
} // namespace QtVirtualKeyboard
QT_END_NAMESPACE