Changeset View
Changeset View
Standalone View
Standalone View
src/KeyboardTranslatorManager.h
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 42 | public: | |||
---|---|---|---|---|---|
63 | 63 | | |||
64 | /** | 64 | /** | ||
65 | * Deletes a translator. Returns true on successful deletion or false otherwise. | 65 | * Deletes a translator. Returns true on successful deletion or false otherwise. | ||
66 | * | 66 | * | ||
67 | * TODO: More documentation | 67 | * TODO: More documentation | ||
68 | */ | 68 | */ | ||
69 | bool deleteTranslator(const QString &name); | 69 | bool deleteTranslator(const QString &name); | ||
70 | 70 | | |||
71 | /** | ||||
72 | * Checks whether a translator can be deleted or not (by checking if | ||||
73 | * the directory containing the .keytab file is writable, because one | ||||
74 | * can still delete a file owned by a different user if the directory | ||||
75 | * containing it is writable for the current user). | ||||
76 | */ | ||||
77 | bool isTranslatorDeletable(const QString &name) const; | ||||
78 | | ||||
79 | /** | ||||
80 | * Checks whether a translator can be reset to its default values. | ||||
81 | * This is only applicable for translators that exist in two different | ||||
82 | * locations: | ||||
83 | * - system-wide location which is read-only for the user (typically | ||||
84 | * /usr/share/konsole/ on Linux) | ||||
85 | * - writable user-specific location under the user's home directory | ||||
86 | * (typically ~/.local/share/konsole on Linux) | ||||
87 | * | ||||
88 | * Reseting here basically means it deletes the translator from the | ||||
89 | * location under the user's home directory, then "reloads" it from | ||||
90 | * the system-wide location. | ||||
91 | */ | ||||
92 | bool isTranslatorResettable(const QString &name) const; | ||||
93 | | ||||
71 | /** Returns the default translator for Konsole. */ | 94 | /** Returns the default translator for Konsole. */ | ||
72 | const KeyboardTranslator *defaultTranslator(); | 95 | const KeyboardTranslator *defaultTranslator(); | ||
73 | 96 | | |||
74 | /** | 97 | /** | ||
75 | * Returns the keyboard translator with the given name or 0 if no translator | 98 | * Returns the keyboard translator with the given name or 0 if no translator | ||
76 | * with that name exists. | 99 | * with that name exists. | ||
77 | * | 100 | * | ||
78 | * The first time that a translator with a particular name is requested, | 101 | * The first time that a translator with a particular name is requested, | ||
79 | * the on-disk .keytab file is loaded and parsed. | 102 | * the on-disk .keytab file is loaded and parsed. | ||
80 | */ | 103 | */ | ||
81 | const KeyboardTranslator *findTranslator(const QString &name); | 104 | const KeyboardTranslator *findTranslator(const QString &name); | ||
82 | /** | 105 | /** | ||
83 | * Returns a list of the names of available keyboard translators. | 106 | * Returns a list of the names of available keyboard translators. | ||
84 | * | 107 | * | ||
85 | * The first time this is called, a search for available | 108 | * The first time this is called, a search for available | ||
86 | * translators is started. | 109 | * translators is started. | ||
87 | */ | 110 | */ | ||
88 | QStringList allTranslators(); | 111 | const QStringList allTranslators(); | ||
89 | 112 | | |||
90 | /** Returns the global KeyboardTranslatorManager instance. */ | 113 | /** Returns the global KeyboardTranslatorManager instance. */ | ||
91 | static KeyboardTranslatorManager *instance(); | 114 | static KeyboardTranslatorManager *instance(); | ||
92 | 115 | | |||
116 | /** Returns the translator path */ | ||||
117 | const QString findTranslatorPath(const QString &name) const; | ||||
118 | | ||||
93 | private: | 119 | private: | ||
94 | void findTranslators(); // locate all available translators | 120 | void findTranslators(); // locate all available translators | ||
95 | 121 | | |||
96 | // loads the translator with the given name | 122 | // loads the translator with the given name | ||
97 | KeyboardTranslator *loadTranslator(const QString &name); | 123 | KeyboardTranslator *loadTranslator(const QString &name); | ||
98 | KeyboardTranslator *loadTranslator(QIODevice *source, const QString &name); | 124 | KeyboardTranslator *loadTranslator(QIODevice *source, const QString &name); | ||
99 | 125 | | |||
100 | bool saveTranslator(const KeyboardTranslator *translator); | 126 | bool saveTranslator(const KeyboardTranslator *translator); | ||
101 | QString findTranslatorPath(const QString &name); | | |||
102 | 127 | | |||
103 | bool _haveLoadedAll; | 128 | bool _haveLoadedAll; | ||
104 | 129 | | |||
105 | const KeyboardTranslator *_fallbackTranslator; | 130 | const KeyboardTranslator *_fallbackTranslator; | ||
106 | QHash<QString, KeyboardTranslator *> _translators; | 131 | QHash<QString, KeyboardTranslator *> _translators; | ||
107 | }; | 132 | }; | ||
108 | } | 133 | } | ||
109 | 134 | | |||
110 | #endif // KEYBOARDTRANSLATOR_MANAGER_H | 135 | #endif // KEYBOARDTRANSLATOR_MANAGER_H |