LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VirtualKeyboardPreferences.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef VIRTUAL_KEYBOARD_PREFERENCES_H
23 #define VIRTUAL_KEYBOARD_PREFERENCES_H
24 
25 #include <string>
26 #include <vector>
27 
28 #include "VirtualKeyboard.h"
29 #include "qobject.h"
30 
32 {
33  Q_OBJECT
34 
35  struct SKeyboardCombo
36  {
37  void clear() { layout.clear(); language.clear(); }
38  void set(const std::string & layout_) { layout = layout_; language.clear(); }
39  void set(const std::string & layout_, const std::string & language_)
40  { layout = layout_; language = language_; }
41 
42  bool empty() const { return layout.empty() && language.empty(); }
43  bool operator==(const SKeyboardCombo & rhs) { return layout == rhs.layout && language == rhs.language; }
44  bool operator!=(const SKeyboardCombo & rhs) { return layout != rhs.layout || language != rhs.language; }
45 
46  std::string layout;
47  std::string language;
48  };
49 
50 public Q_SLOTS:
51 
52  void bootFinished();
53 
54 public:
56 
57  // An instance always exists, hence the reference as opposed to a pointer...
59 
60  // This is the only way to get access to the virtual keyboard outside of its implementation.
61  // Will return NULL when it's not yet created, when in WebAppMgr, or when there is none (physical keyboard...)
62  VirtualKeyboard * virtualKeyboard() const { return mVirtualKeyboard; }
63 
64  void applyInitSettings(VirtualKeyboard * keyboard);
65 
66  void applyFirstUseSettings();
67  Q_INVOKABLE void localeChanged();
68 
70  void selectKeyboardCombo(int index);
71  void selectLayoutCombo(const char * layoutName);
72  void selectKeyboardSize(int size); // 0 is default, 1 is large, -1 small, -2 extra small...
73  int getKeyboardComboCount() const { return mCombos.size(); }
74  const SKeyboardCombo & getkeyboardCombo(int index) const { return mCombos[index]; }
75 
76  SKeyboardCombo getDefault();
78  void clearDefaultDeyboards();
79  void setTapSounds(bool on);
80 
81  void virtualKeyboardPreferencesChanged(const char * prefs);
82  void virtualKeyboardSettingsChanged(const char * settings);
83 
84  bool getTapSounds() const { return mTapSounds; }
85  bool getSpaces2period() const { return mSpaces2period; }
86  void activateCombo();
87 
88 private:
89  void saveSettings();
90  void savePreferences(const std::vector<SKeyboardCombo> & combos); // normaly only ever done by the prefs app. For testing only.
91 
92  bool mTapSounds; // should key presses make a sound?
93  bool mSpaces2period; // should two-spaces be converted to a period, à la iPhone & Blackberry?
94  int mKeyboardSize;
95 
96  bool mSettingsReceived;
97  bool mPrefsReceived;
98 
99  std::vector<SKeyboardCombo> mCombos;
100  SKeyboardCombo mActiveCombo;
101 
102  VirtualKeyboard * mVirtualKeyboard;
103 };
104 
105 #define PALM_VIRTUAL_KEYBOARD_PREFS "x_palm_virtualkeyboard_prefs"
106 #define PALM_VIRTUAL_KEYBOARD_SETTINGS "x_palm_virtualkeyboard_settings"
107 #define PALM_VIRTUAL_KEYBOARD_LAYOUTS "x_palm_virtualkeyboard_layouts"
108 
109 #endif // VIRTUAL_KEYBOARD_PREFERENCES_H