2
* This file is part of Maliit Plugins
4
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
6
* Contact: Mohammad Anwari <Mohammad.Anwari@nokia.com>
8
* Redistribution and use in source and binary forms, with or without modification,
9
* are permitted provided that the following conditions are met:
11
* Redistributions of source code must retain the above copyright notice, this list
12
* of conditions and the following disclaimer.
13
* Redistributions in binary form must reproduce the above copyright notice, this list
14
* of conditions and the following disclaimer in the documentation and/or other materials
15
* provided with the distribution.
16
* Neither the name of Nokia Corporation nor the names of its contributors may be
17
* used to endorse or promote products derived from this software without specific
18
* prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
#ifndef MALIIT_KEYBOARD_TEXTEDITOR_H
33
#define MALIIT_KEYBOARD_TEXTEDITOR_H
35
#include "models/key.h"
36
#include "models/wordcandidate.h"
37
#include "models/text.h"
38
#include "logic/abstractwordengine.h"
39
#include "logic/abstractlanguagefeatures.h"
42
#include <QtGui/QKeyEvent>
44
namespace MaliitKeyboard {
49
// all delays are in milliseconds
50
int backspace_auto_repeat_delay; // delay before first automatically repeated key
51
int backspace_auto_repeat_interval; // interval between automatically repeated keys
54
class AbstractTextEditorPrivate;
56
class AbstractTextEditor
60
Q_DISABLE_COPY(AbstractTextEditor)
61
Q_DECLARE_PRIVATE(AbstractTextEditor)
62
Q_PROPERTY(bool preeditEnabled READ isPreeditEnabled
63
WRITE setPreeditEnabled
64
NOTIFY preeditEnabledChanged)
65
Q_PROPERTY(bool autoCorrectEnabled READ isAutoCorrectEnabled
66
WRITE setAutoCorrectEnabled
67
NOTIFY autoCorrectEnabledChanged)
68
Q_PROPERTY(bool autoCapsEnabled READ isAutoCapsEnabled
69
WRITE setAutoCapsEnabled
70
NOTIFY autoCapsEnabledChanged)
81
Replacement(int position)
84
, cursor_position(position)
87
Replacement(int r_start,
92
, cursor_position(position)
100
explicit AbstractTextEditor(const EditorOptions &options,
102
Logic::AbstractWordEngine *word_engine,
103
Logic::AbstractLanguageFeatures *language_features,
104
QObject *parent = 0);
105
virtual ~AbstractTextEditor() = 0;
107
Model::Text * text() const;
108
Logic::AbstractWordEngine * wordEngine() const;
109
Logic::AbstractLanguageFeatures * languageFeatures() const;
111
Q_SLOT void onKeyPressed(const Key &key);
112
Q_SLOT void onKeyReleased(const Key &key);
113
Q_SLOT void onKeyEntered(const Key &key);
114
Q_SLOT void onKeyExited(const Key &key);
115
Q_SLOT void onCursorPositionChanged(int cursor_position,
116
const QString &surrounding_text);
117
Q_SLOT void replacePreedit(const QString &replacement);
118
Q_SLOT void replaceAndCommitPreedit(const QString &replacement);
119
Q_SLOT void clearPreedit();
121
bool isPreeditEnabled() const;
122
Q_SLOT void setPreeditEnabled(bool enabled);
123
Q_SIGNAL void preeditEnabledChanged(bool enabled);
125
bool isAutoCorrectEnabled() const;
126
Q_SLOT void setAutoCorrectEnabled(bool enabled);
127
Q_SIGNAL void autoCorrectEnabledChanged(bool enabled);
129
bool isAutoCapsEnabled() const;
130
Q_SLOT void setAutoCapsEnabled(bool enabled);
131
Q_SIGNAL void autoCapsEnabledChanged(bool enabled);
133
Q_SLOT void showUserCandidate();
134
Q_SLOT void addToUserDictionary(const QString &word);
136
Q_SIGNAL void keyboardClosed();
137
Q_SIGNAL void wordCandidatesChanged(const WordCandidateList &word_candidates);
138
Q_SIGNAL void autoCapsActivated();
139
Q_SIGNAL void leftLayoutSelected();
140
Q_SIGNAL void rightLayoutSelected();
142
Q_SLOT virtual void onLanguageChanged(const QString& languageId);
145
const QScopedPointer<AbstractTextEditorPrivate> d_ptr;
147
void sendPreeditString(const QString &preedit,
148
Model::Text::PreeditFace face);
150
virtual void sendPreeditString(const QString &preedit,
151
Model::Text::PreeditFace face,
152
const Replacement &replacement) = 0;
153
virtual void sendCommitString(const QString &commit) = 0;
154
virtual void sendKeyEvent(const QKeyEvent &ev) = 0;
155
virtual void invokeAction(const QString &action, const QKeySequence &sequence) = 0;
157
void commitPreedit();
158
Q_SLOT void autoRepeatBackspace();
161
} // namespace MaliitKeyboard
163
#endif // MALIIT_KEYBOARD_ABSTRACTTEXTEDITOR_H