"Fossies" - the Fresh Open Source Software Archive

Member "qt-everywhere-src-6.3.1/qtvirtualkeyboard/src/plugins/pinyin/3rdparty/pinyin/patches/0001-Make-the-keyboard-layout-changeable-in-password-url-.patch" (8 Jun 2022, 4695 Bytes) of package /linux/misc/qt-everywhere-src-6.3.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 From 1290471fc3e542388e79e27cb2c4ce654f5023f3 Mon Sep 17 00:00:00 2001
    2 From: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
    3 Date: Tue, 5 Aug 2014 13:37:49 +0300
    4 Subject: [PATCH] Make the keyboard layout changeable in password / url input
    5  mode
    6 
    7 Removed latin-only restriction with specific input method hints.
    8 More specifically, the latin-only keyboard was previously enforced
    9 when password, hidden, sensitive or latin-only flags were set for
   10 the input control.
   11 
   12 Now it is possible to use non-latin input methods and keyboard
   13 layouts with these modes too. However, this change implies some
   14 additional changes to the Pinyin and Hunspell input methods.
   15 
   16 Changes to PinyinInputMethod:
   17 - Disable the user dictionary when sensitive data flag is set.
   18   This is required so that sensitive data (such as passwords)
   19   is not stored in the user dictionary.
   20 
   21 Changes to HunspellInputMethod:
   22 - Disable the auto space functionality when the input mode is not
   23   latin, or the exclusive input mode is set to url or email input.
   24 
   25 Task-number: QTRD-3210
   26 Change-Id: I444c4b87c9805b69dc773ef6cac76f1c11dd220a
   27 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
   28 Reviewed-by: Rainer Keller <rainer.keller@digia.com>
   29 ---
   30  .../3rdparty/pinyin/include/matrixsearch.h         |  4 ++++
   31  .../3rdparty/pinyin/include/pinyinime.h            | 12 +++++++++++
   32  .../3rdparty/pinyin/share/matrixsearch.cpp         | 23 ++++++++++++++++++++++
   33  .../3rdparty/pinyin/share/pinyinime.cpp            | 11 +++++++++++
   34  4 files changed, 50 insertions(+)
   35 
   36 diff --git a/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h b/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h
   37 index f581d30..61e78aa 100644
   38 --- a/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h
   39 +++ b/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h
   40 @@ -380,6 +380,10 @@ class MatrixSearch {
   41    bool init_fd(int sys_fd, long start_offset, long length,
   42                 const char *fn_usr_dict);
   43  
   44 +  void init_user_dictionary(const char *fn_usr_dict);
   45 +
   46 +  bool is_user_dictionary_enabled() const;
   47 +
   48    void set_max_lens(size_t max_sps_len, size_t max_hzs_len);
   49  
   50    void close();
   51 diff --git a/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h b/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h
   52 index 0744ec7..e376c20 100644
   53 --- a/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h
   54 +++ b/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h
   55 @@ -202,6 +202,18 @@ extern "C" {
   56     * Enable Yunmus in ShouZiMu mode.
   57     */
   58    void im_enable_ym_as_szm(bool enable);
   59 +
   60 +  /**
   61 +   * Initializes or uninitializes the user dictionary.
   62 +   *
   63 +   * @param fn_usr_dict The file name of the user dictionary.
   64 +   */
   65 +  void im_init_user_dictionary(const char *fn_usr_dict);
   66 +
   67 +  /**
   68 +   * Returns the current status of user dictinary.
   69 +   */
   70 +  bool im_is_user_dictionary_enabled(void);
   71  }
   72  
   73  #ifdef __cplusplus
   74 diff --git a/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp b/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp
   75 index 12d092a..41e1143 100644
   76 --- a/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp
   77 +++ b/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp
   78 @@ -169,6 +169,29 @@ bool MatrixSearch::init_fd(int sys_fd, long start_offset, long length,
   79    return true;
   80  }
   81  
   82 +void MatrixSearch::init_user_dictionary(const char *fn_usr_dict) {
   83 +  assert(inited_);
   84 +
   85 +  if (NULL != user_dict_) {
   86 +    delete user_dict_;
   87 +    user_dict_ = NULL;
   88 +  }
   89 +
   90 +  if (NULL != fn_usr_dict) {
   91 +    user_dict_ = static_cast<AtomDictBase*>(new UserDict());
   92 +    if (!user_dict_->load_dict(fn_usr_dict, kUserDictIdStart, kUserDictIdEnd)) {
   93 +      delete user_dict_;
   94 +      user_dict_ = NULL;
   95 +    }
   96 +  }
   97 +
   98 +  reset_search0();
   99 +}
  100 +
  101 +bool MatrixSearch::is_user_dictionary_enabled() const {
  102 +  return NULL != user_dict_;
  103 +}
  104 +
  105  void MatrixSearch::set_max_lens(size_t max_sps_len, size_t max_hzs_len) {
  106    if (0 != max_sps_len)
  107      max_sps_len_ = max_sps_len;
  108 diff --git a/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp b/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp
  109 index 550da7b..4d206a7 100644
  110 --- a/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp
  111 +++ b/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp
  112 @@ -181,6 +181,17 @@ extern "C" {
  113      spl_trie.szm_enable_ym(enable);
  114    }
  115  
  116 +  void im_init_user_dictionary(const char *fn_usr_dict) {
  117 +    if (!matrix_search)
  118 +        return;
  119 +    matrix_search->flush_cache();
  120 +    matrix_search->init_user_dictionary(fn_usr_dict);
  121 +  }
  122 +
  123 +  bool im_is_user_dictionary_enabled(void) {
  124 +    return NULL != matrix_search ? matrix_search->is_user_dictionary_enabled() : false;
  125 +  }
  126 +
  127  #ifdef __cplusplus
  128  }
  129  #endif
  130 -- 
  131 2.14.1.windows.1
  132