1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
//
// C++ Interface: kxkbconfig
//
// Description:
//
//
// Author: Andriy Rysin <[email protected]>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef KXKBCONFIG_H
#define KXKBCONFIG_H
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqptrqueue.h>
#include <tqmap.h>
/* Utility classes for per-window/per-application tqlayout implementation
*/
enum SwitchingPolicy {
SWITCH_POLICY_GLOBAL = 0,
SWITCH_POLICY_WIN_CLASS = 1,
SWITCH_POLICY_WINDOW = 2,
SWITCH_POLICY_COUNT = 3
};
inline TQString createPair(TQString key, TQString value)
{
if( value.isEmpty() )
return key;
return TQString("%1(%2)").arg(key, value);
}
struct LayoutUnit {
TQString tqlayout;
TQString variant;
TQString includeGroup;
TQString displayName;
int defaultGroup;
LayoutUnit() {}
LayoutUnit(TQString tqlayout_, TQString variant_):
tqlayout(tqlayout_),
variant(variant_)
{}
LayoutUnit(TQString pair) {
setFromPair( pair );
}
void setFromPair(const TQString& pair) {
tqlayout = parseLayout(pair);
variant = parseVariant(pair);
}
TQString toPair() const {
return createPair(tqlayout, variant);
}
bool operator<(const LayoutUnit& lu) const {
return tqlayout<lu.tqlayout ||
(tqlayout==lu.tqlayout && variant<lu.variant);
}
bool operator!=(const LayoutUnit& lu) const {
return tqlayout!=lu.tqlayout || variant!=lu.variant;
}
bool operator==(const LayoutUnit& lu) const {
// kdDebug() << tqlayout << "==" << lu.tqlayout << "&&" << variant << "==" << lu.variant << endl;
return tqlayout==lu.tqlayout && variant==lu.variant;
}
//private:
static const TQString parseLayout(const TQString &layvar);
static const TQString parseVariant(const TQString &layvar);
};
extern const LayoutUnit DEFAULT_LAYOUT_UNIT;
extern const char* DEFAULT_MODEL;
class KxkbConfig
{
public:
enum { LOAD_INIT_OPTIONS, LOAD_ACTIVE_OPTIONS, LOAD_ALL };
bool m_useKxkb;
bool m_showSingle;
bool m_showFlag;
bool m_enableXkbOptions;
bool m_resetOldOptions;
SwitchingPolicy m_switchingPolicy;
bool m_stickySwitching;
int m_stickySwitchingDepth;
TQString m_model;
TQString m_options;
TQValueList<LayoutUnit> m_tqlayouts;
LayoutUnit getDefaultLayout();
bool load(int loadMode);
void save();
void setDefaults();
TQStringList getLayoutStringList(/*bool compact*/);
static TQString getDefaultDisplayName(const TQString& code_);
static TQString getDefaultDisplayName(const LayoutUnit& tqlayoutUnit, bool single=false);
private:
static const TQMap<TQString, TQString> parseIncludesMap(const TQStringList& pairList);
};
#endif
|