File indexing completed on 2024-11-24 05:00:21

0001 /*
0002     SPDX-FileCopyrightText: 2014 Weng Xuetian <wengxt@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 #pragma once
0007 #include <QByteArray>
0008 #include <QList>
0009 #include <QMap>
0010 #include <QQueue>
0011 #include <QString>
0012 #include <QStringList>
0013 #include <ibus.h>
0014 
0015 class EngineManager
0016 {
0017 public:
0018     EngineManager();
0019     virtual ~EngineManager();
0020 
0021     void setEngines(IBusEngineDesc **engines);
0022     IBusEngineDesc **engines()
0023     {
0024         return m_engines;
0025     }
0026     size_t length()
0027     {
0028         return m_length;
0029     }
0030     void setUseGlobalEngine(gboolean g_variant_get_boolean);
0031     void setCurrentContext(const gchar *input_context_path);
0032     QString currentEngine();
0033     bool useGlobalEngine()
0034     {
0035         return m_useGlobalEngine;
0036     }
0037     void setCurrentEngine(const char *name);
0038     const char *navigate(IBusEngineDesc *engine, bool forward);
0039     void moveToFirst(IBusEngineDesc *engine_desc);
0040     QStringList engineOrder();
0041     void setOrder(const gchar **engine_names, size_t len);
0042     size_t getIndexByName(const char *name);
0043 
0044 private:
0045     QQueue<QString> m_history;
0046     QMap<QString, QString> m_engineMap;
0047     QString m_currentContext;
0048     IBusEngineDesc **m_engines;
0049     size_t m_length;
0050     bool m_useGlobalEngine;
0051     void freeOldEngine();
0052 };