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
|
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kturtlerc"/>
<group name="general">
<entry name="CanvasWidth" type="Int">
<label>The width of the canvas in pixels</label>
<default>300</default>
</entry>
<entry name="CanvasHeight" type="Int">
<label>The height of the canvas in pixels</label>
<default>250</default>
</entry>
</group>
<group name="language">
<entry name="LogoLanguageList" type="StringList">
<label>The list of the available languages for the Logo commands</label>
<code>
// This StringList (LogoLanguageList) is a list of all possible language codes all possible [en_US, fr, nl, etc.]. It is used to (1) find the LogoLanguage variable (that is defined later on), and (2) in the Settings dialog to fill the language ComboBox. Better not to dupe this code. The LogoLanguageList is made pretty in the slotSettings class of kturtle.cpp.
// We assume keyword and highlight files come in pairs (if not there will be no highlight style)
TQStringList xmlFiles = KGlobal::dirs()->findAllResources("data", "kturtle/data/*.xml");
TQStringList LogoLanguageList;
TQString xmlTranslationFiles; // for debug purposes
for ( TQStringList::Iterator it = xmlFiles.begin(); it != xmlFiles.end(); ++it ) {
TQString xmlFile(*it);
xmlTranslationFiles += xmlFile.section('.', -2, -2).append(", "); // for debug purposes
// build list of language codes (en_US, nl, etc.)
LogoLanguageList += xmlFile.section('.', -2, -2);
}
kdDebug(0) << "Available translations of Logo: "<< xmlTranslationFiles <<endl;
LogoLanguageList.sort();
</code>
<default code="true">LogoLanguageList</default>
</entry>
<entry name="LogoLanguage" type="String">
<label>The language of the Logo commands</label>
<code>
// This is the String (LogoLanguage) that actually gets picked up by the app to know what XML files (for HLstyle and Logo language) to use. It is not directly changeable by the ComboBox but is translated from the Ints that ComboBox LogoLanguageList emits. It is better to have the logic that changes the Ints to Strings at the settings dept.
// The KconfigXT framework makes shure the value that is saved in the kturtlerc file will be used in stead of the defaultLanguage that we find here.
// Get the desktops language
KConfigBase *globalConf = KGlobal::config();
globalConf->setGroup("Locale");
TQString desktopLanguage = globalConf->readEntry("Language");
kdDebug(0) << "desktopLanguage: "<< desktopLanguage <<endl;
TQString defaultLanguage = "en_US"; // init to the fall back value
int itemCount = 0; // for the LanguageComboBox
for (TQStringList::Iterator it = LogoLanguageList.begin(); it != LogoLanguageList.end(); ++it ) {
TQString testLanguage(*it);
if (testLanguage == desktopLanguage) { // exact match
defaultLanguage = testLanguage;
break;
} else if ( testLanguage.left(2) == desktopLanguage.left(2) ) { // close match (different dialect)
// The default language must still be one of the kturtle languages.
// defaultLanguage = testLanguage.left(2);
defaultLanguage = testLanguage;
break;
}
itemCount++;
}
kdDebug(0) << "Logo command language: "<< defaultLanguage <<endl;
</code>
<default code="true">defaultLanguage</default>
</entry>
<entry name="LanguageComboBox" type="Int">
<label>The value of the ComboBox</label>
<code>
// This is the parameter that actually gets changed (and emits the signal to the dialog to enable the Apply and Defaults buttons). This value is saved in the kturtlerc file but is never used.
</code>
<default code="true">itemCount</default>
</entry>
</group>
</kcfg>
|