aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Fabio Bas2010-12-21 12:00:56 +0000
committerGravatar Fabio Bas2010-12-21 12:00:56 +0000
commit6ce3e627e8eaba998b575d191f0c84da7810e175 (patch)
treec8ca05fea624cbff13488ffd80bd8d6b9ef4f419 /src
parentdocumentation fixes on file module by OmegaPhil (diff)
downloadKVIrc-6ce3e627e8eaba998b575d191f0c84da7810e175.tar.gz
KVIrc-6ce3e627e8eaba998b575d191f0c84da7810e175.tar.bz2
KVIrc-6ce3e627e8eaba998b575d191f0c84da7810e175.zip
Reworked the text encoding menu: items are now macrogrouped, and a new "current" item will show the currently chosen encoding
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5216 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvilib/system/kvi_locale.cpp286
-rw-r--r--src/kvilib/system/kvi_locale.h3
-rw-r--r--src/kvirc/ui/kvi_window.cpp210
-rw-r--r--src/kvirc/ui/kvi_window.h5
4 files changed, 300 insertions, 204 deletions
diff --git a/src/kvilib/system/kvi_locale.cpp b/src/kvilib/system/kvi_locale.cpp
index 6cc880ceb..db97446c4 100644
--- a/src/kvilib/system/kvi_locale.cpp
+++ b/src/kvilib/system/kvi_locale.cpp
@@ -608,146 +608,192 @@ namespace KviLocale
{
#ifndef QT_NO_BIG_CODECS
#define NUM_ENCODINGS 109
+ #define NUM_ENCODING_GROUPS 8
#else
#define NUM_ENCODINGS 85
+ #define NUM_ENCODING_GROUPS 5
#endif
- static EncodingDescription supported_encodings[]=
+ static const char * encoding_groups[] =
{
- { "UTF-8" , 0 , 0 , "8-bit Unicode" },
- { "ISO-8859-1" , 0 , 0 , "Western, Latin-1" },
- { "ISO-8859-2" , 0 , 0 , "Central European 1" },
- { "ISO-8859-3" , 0 , 0 , "Central European 2" },
- { "ISO-8859-4" , 0 , 0 , "Baltic, Standard" },
- { "ISO-8859-5" , 0 , 0 , "Cyrillic, ISO" },
- { "ISO-8859-6" , 0 , 0 , "Arabic, Standard" },
- { "ISO-8859-7" , 0 , 0 , "Greek" },
- { "ISO-8859-8" , 0 , 0 , "Hebrew, visually ordered" },
- { "ISO-8859-8-i" , 0 , 0 , "Hebrew, logically ordered" },
- { "ISO-8859-9" , 0 , 0 , "Turkish, Latin-5" },
- { "ISO-8859-15" , 0 , 0 , "Western, Latin-1 + Euro" },
- { "KOI8-R" , 0 , 0 , "Cyrillic, KOI" },
- { "KOI8-U" , 0 , 0 , "Ukrainian" },
- { "CP-1250" , 0 , 0 , "Central European 3" },
- { "CP-1251" , 0 , 0 , "Cyrillic, Windows" },
- { "CP-1252" , 0 , 0 , "Western, CP" },
- { "CP-1253" , 0 , 0 , "Greek, CP" },
- { "CP-1256" , 0 , 0 , "Arabic, CP" },
- { "CP-1257" , 0 , 0 , "Baltic, CP" },
- { "CP-1255" , 0 , 0 , "Hebrew, CP" },
- { "CP-1254" , 0 , 0 , "Turkish, CP" },
- { "TIS-620" , 0 , 0 , "Thai" },
+ "Unicode",
+ "West European",
+ "East European",
+ "Cyrillic",
+ "Middle Eastern",
#ifndef QT_NO_BIG_CODECS
- { "Big5" , 0 , 0 , "Chinese Traditional" },
- { "Big5-HKSCS" , 0 , 0 , "Chinese Traditional, Hong Kong" },
- { "GB18030" , 0 , 0 , "Chinese Simplified" },
- { "JIS7" , 0 , 0 , "Japanese (JIS7)" },
- { "Shift-JIS" , 0 , 0 , "Japanese (Shift-JIS)" },
- { "EUC-JP" , 0 , 0 , "Japanese (EUC-JP)" },
- { "EUC-KR" , 0 , 0 , "Korean" },
- { "TSCII" , 0 , 0 , "Tamil" },
+ "Chinese",
+ "Japanese",
+ "Other asiatic",
#endif
- { "ISO-8859-10" , 0 , 0 , "ISO-8859-10" },
- { "ISO-8859-13" , 0 , 0 , "ISO-8859-13" },
- { "ISO-8859-14" , 0 , 0 , "ISO-8859-14" },
- { "IBM-850" , 0 , 0 , "IBM-850" },
- { "IBM-866" , 0 , 0 , "IBM-866" },
- { "CP874" , 0 , 0 , "CP874" },
+ 0
+ };
+ static EncodingDescription supported_encodings[]=
+ {
+ // Unicode
+ { "UTF-8" , 0 , 0 , 0, "8-bit Unicode" },
+ // West European
+ { "ISO-8859-1" , 0 , 0 , 1, "Western, Latin-1" },
+ { "ISO-8859-15" , 0 , 0 , 1, "Western, Latin-1 + Euro" },
+ { "IBM-850" , 0 , 0 , 1, "IBM-850" },
+ { "CP-1252" , 0 , 0 , 1, "Western Codepage" },
+ { "ISO-8859-14" , 0 , 0 , 1, "Celtic" },
+ { "ISO-8859-7" , 0 , 0 , 1, "Greek" },
+ { "CP-1253" , 0 , 0 , 1, "Greek Codepage" },
+ { "ISO-8859-10" , 0 , 0 , 1, "Nordic" },
+ { "ISO-8859-3" , 0 , 0 , 1, "South European" },
+ // East European
+ { "ISO-8859-4" , 0 , 0 , 2, "Baltic, Standard" },
+ { "ISO-8859-13" , 0 , 0 , 2, "Baltic" },
+ { "CP-1257" , 0 , 0 , 2, "Baltic Codepage" },
+ { "ISO-8859-2" , 0 , 0 , 2, "Central European" },
+ { "CP-1250" , 0 , 0 , 2, "Central European Codepage" },
+ { "ISO-8859-9" , 0 , 0 , 2, "Turkish, Latin-5" },
+ { "CP-1254" , 0 , 0 , 2, "Turkish Codepage" },
+ // Cyrillic
+ { "ISO-8859-5" , 0 , 0 , 3, "Cyrillic, ISO" },
+ { "CP-1251" , 0 , 0 , 3, "Cyrillic Codepage" },
+ { "KOI8-R" , 0 , 0 , 3, "Cyrillic, KOI" },
+ { "KOI8-U" , 0 , 0 , 3, "Cyrillic/Ukrainian" },
+ { "IBM-866" , 0 , 0 , 3, "IBM-866" },
+ // Middle Eastern
+ { "ISO-8859-6" , 0 , 0 , 4, "Arabic, Standard" },
+ { "CP-1256" , 0 , 0 , 4, "Arabic Codepage" },
+ { "ISO-8859-8" , 0 , 0 , 4, "Hebrew, visually ordered" },
+ { "ISO-8859-8-i" , 0 , 0 , 4, "Hebrew, logically ordered" },
+ { "CP-1255" , 0 , 0 , 4, "Hebrew Codepage" },
+ // Other asiatic
+ { "TIS-620" , 0 , 0 , 7, "Thai" },
+ { "CP874" , 0 , 0 , 7, "Thai Codepage" },
+#ifndef QT_NO_BIG_CODECS
+ // Chinese
+ { "Big5" , 0 , 0 , 5, "Chinese Traditional" },
+ { "Big5-HKSCS" , 0 , 0 , 5, "Chinese Traditional, Hong Kong" },
+ { "GB18030" , 0 , 0 , 5, "Chinese Simplified" },
+ // Japanese
+ { "JIS7" , 0 , 0 , 6, "Japanese (JIS7)" },
+ { "Shift-JIS" , 0 , 0 , 6, "Japanese (Shift-JIS)" },
+ { "EUC-JP" , 0 , 0 , 6, "Japanese (EUC-JP)" },
+ // Other asiatic
+ { "EUC-KR" , 0 , 0 , 7, "Korean" },
+ { "TSCII" , 0 , 0 , 7, "Tamil" },
+#endif
+
// smart codecs that send in the local charset
- { "ISO-8859-1 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Western Latin-1, O: Western Latin-1" },
- { "ISO-8859-2 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Central European 1, O: Central European 1" },
- { "ISO-8859-3 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Central European 2, O: Central European 2" },
- { "ISO-8859-4 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Baltic, Standard, O: Baltic, Standard" },
- { "ISO-8859-5 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, ISO, O: Cyrillic, ISO" },
- { "ISO-8859-6 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Arabic, Standard, O: Arabic, Standard" },
- { "ISO-8859-7 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Greek, O: Greek" },
- { "ISO-8859-8 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Hebrew, visually ordered, O: Hebrew, visually ordered" },
- { "ISO-8859-8-i [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Hebrew, logically ordered, O: Hebrew, logically ordered" },
- { "ISO-8859-9 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Turkish, Latin-5, O: Turkish, Latin-5" },
- { "ISO-8859-15 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: Western, Latin-1 + Euro" },
- { "KOI8-R [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, KOI, O: Cyrillic, KOI" },
- { "KOI8-U [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Ukrainian, O: Ukrainian" },
- { "CP-1250 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Central European 3, O: Central European 3" },
- { "CP-1251 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Cyrillic, Windows, O: Cyrillic, Windows" },
- { "CP-1252 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Western, CP, O: Western, CP" },
- { "CP-1253 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Greek, CP, O: Greek, CP" },
- { "CP-1256 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Arabic, CP, O: Arabic, CP" },
- { "CP-1257 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Baltic, CP, O: Baltic, CP" },
- { "CP-1255 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Hebrew, CP, O: Hebrew, CP" },
- { "CP-1254 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Turkish, CP, O: Turkish, CP" },
- { "TIS-620 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Thai, O: Thai" },
+ // West European
+ { "ISO-8859-1 [UTF-8]" , 1 , 0 , 1, "Western, Latin-1 - Unicode" },
+ { "ISO-8859-15 [UTF-8]" , 1 , 0 , 1, "Western, Latin-1 + Euro - Unicode" },
+ { "IBM-850 [UTF-8]" , 1 , 0 , 1, "IBM-850 - Unicode" },
+ { "CP-1252 [UTF-8]" , 1 , 0 , 1, "Western Codepage - Unicode" },
+ { "ISO-8859-14 [UTF-8]" , 1 , 0 , 1, "Celtic - Unicode" },
+ { "ISO-8859-7 [UTF-8]" , 1 , 0 , 1, "Greek - Unicode" },
+ { "CP-1253 [UTF-8]" , 1 , 0 , 1, "Greek Codepage - Unicode" },
+ { "ISO-8859-10 [UTF-8]" , 1 , 0 , 1, "Nordic - Unicode" },
+ { "ISO-8859-3 [UTF-8]" , 1 , 0 , 1, "South European - Unicode" },
+ // East European
+ { "ISO-8859-4 [UTF-8]" , 1 , 0 , 2, "Baltic, Standard - Unicode" },
+ { "ISO-8859-13 [UTF-8]" , 1 , 0 , 2, "Baltic - Unicode" },
+ { "CP-1257 [UTF-8]" , 1 , 0 , 2, "Baltic Codepage - Unicode" },
+ { "ISO-8859-2 [UTF-8]" , 1 , 0 , 2, "Central European - Unicode" },
+ { "CP-1250 [UTF-8]" , 1 , 0 , 2, "Central European Codepage - Unicode" },
+ { "ISO-8859-9 [UTF-8]" , 1 , 0 , 2, "Turkish, Latin-5 - Unicode" },
+ { "CP-1254 [UTF-8]" , 1 , 0 , 2, "Turkish Codepage - Unicode" },
+ // Cyrillic
+ { "ISO-8859-5 [UTF-8]" , 1 , 0 , 3, "Cyrillic, ISO - Unicode" },
+ { "CP-1251 [UTF-8]" , 1 , 0 , 3, "Cyrillic Codepage - Unicode" },
+ { "KOI8-R [UTF-8]" , 1 , 0 , 3, "Cyrillic, KOI - Unicode" },
+ { "KOI8-U [UTF-8]" , 1 , 0 , 3, "Cyrillic/Ukrainian - Unicode" },
+ { "IBM-866 [UTF-8]" , 1 , 0 , 3, "IBM-866 - Unicode" },
+ // Middle Eastern
+ { "ISO-8859-6 [UTF-8]" , 1 , 0 , 4, "Arabic, Standard - Unicode" },
+ { "CP-1256 [UTF-8]" , 1 , 0 , 4, "Arabic Codepage - Unicode" },
+ { "ISO-8859-8 [UTF-8]" , 1 , 0 , 4, "Hebrew, visually ordered - Unicode" },
+ { "ISO-8859-8-i [UTF-8]" , 1 , 0 , 4, "Hebrew, logically ordered - Unicode" },
+ { "CP-1255 [UTF-8]" , 1 , 0 , 4, "Hebrew Codepage - Unicode" },
+ // Other asiatic
+ { "TIS-620 [UTF-8]" , 1 , 0 , 7, "Thai - Unicode" },
+ { "CP874 [UTF-8]" , 1 , 0 , 7, "Thai Codepage - Unicode" },
#ifndef QT_NO_BIG_CODECS
- { "Big5 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Chinese Traditional, O: Chinese Traditional" },
- { "Big5-HKSCS [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: Chinese Traditional, Hong Kong" },
- { "GB18030 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Chinese Simplified, O: Chinese Simplified" },
- { "JIS7 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Japanese (JIS7), O: Japanese " },
- { "Shift-JIS [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" },
- { "EUC-JP [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" },
- { "EUC-KR [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Korean, O: Korean" },
- { "TSCII [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / Tamil, O: Tamil" },
+ // Chinese
+ { "Big5 [UTF-8]" , 1 , 0 , 5, "Chinese Traditional - Unicode" },
+ { "Big5-HKSCS [UTF-8]" , 1 , 0 , 5, "Chinese Traditional, Hong Kong - Unicode" },
+ { "GB18030 [UTF-8]" , 1 , 0 , 5, "Chinese Simplified - Unicode" },
+ // Japanese
+ { "JIS7 [UTF-8]" , 1 , 0 , 6, "Japanese (JIS7) - Unicode" },
+ { "Shift-JIS [UTF-8]" , 1 , 0 , 6, "Japanese (Shift-JIS) - Unicode" },
+ { "EUC-JP [UTF-8]" , 1 , 0 , 6, "Japanese (EUC-JP) - Unicode" },
+ // Other asiatic
+ { "EUC-KR [UTF-8]" , 1 , 0 , 7, "Korean - Unicode" },
+ { "TSCII [UTF-8]" , 1 , 0 , 7, "Tamil - Unicode" },
#endif
- { "ISO-8859-10 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-10, O: ISO-8859-10" },
- { "ISO-8859-13 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-13, O: ISO-8859-13" },
- { "ISO-8859-14 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / ISO-8859-14, O: ISO-8859-14" },
- { "IBM-850 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / IBM-850, O: IBM-850" },
- { "IBM-866 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / IBM-866, O: IBM-866" },
- { "CP874 [UTF-8]" , 1 , 0 , "I: 8-bit Unicode / CP874, O: CP874" },
// smart codecs that send in utf8
- { "UTF-8 [ISO-8859-1]" , 1 , 1 , "I: 8-bit Unicode / Western Latin-1, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-2]" , 1 , 1 , "I: 8-bit Unicode / Central European 1, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-3]" , 1 , 1 , "I: 8-bit Unicode / Central European 2, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-4]" , 1 , 1 , "I: 8-bit Unicode / Baltic, Standard, O: 8-bit Unicode" },
-
- { "UTF-8 [ISO-8859-5]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, ISO, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-6]" , 1 , 1 , "I: 8-bit Unicode / Arabic, Standard, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-7]" , 1 , 1 , "I: 8-bit Unicode / Greek, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-8]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, visually ordered, O: 8-bit Unicode" },
-
- { "UTF-8 [ISO-8859-8-i]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, logically ordered, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-9]" , 1 , 1 , "I: 8-bit Unicode / Turkish, Latin-5, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-15]" , 1 , 1 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: 8-bit Unicode" },
- { "UTF-8 [KOI8-R]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, KOI, O: 8-bit Unicode" },
-
- { "UTF-8 [KOI8-U]" , 1 , 1 , "I: 8-bit Unicode / Ukrainian, O: 8-bit Unicode" },
- { "UTF-8 [CP-1250]" , 1 , 1 , "I: 8-bit Unicode / Central European 3, O: 8-bit Unicode" },
- { "UTF-8 [CP-1251]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, Windows, O: 8-bit Unicode" },
- { "UTF-8 [CP-1252]" , 1 , 1 , "I: 8-bit Unicode / Western, CP, O: 8-bit Unicode" },
-
- { "UTF-8 [CP-1253]" , 1 , 1 , "I: 8-bit Unicode / Greek, CP, O: 8-bit Unicode" },
- { "UTF-8 [CP-1256]" , 1 , 1 , "I: 8-bit Unicode / Arabic, CP, O: 8-bit Unicode" },
- { "UTF-8 [CP-1257]" , 1 , 1 , "I: 8-bit Unicode / Baltic, CP, O: 8-bit Unicode" },
- { "UTF-8 [CP-1255]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, CP, O: 8-bit Unicode" },
-
- { "UTF-8 [CP-1254]" , 1 , 1 , "I: 8-bit Unicode / Turkish, CP, O: 8-bit Unicode" },
- { "UTF-8 [TIS-620]" , 1 , 1 , "I: 8-bit Unicode / Thai, O: 8-bit Unicode" },
+ // West European
+ { "UTF-8 [ISO-8859-1]" , 1 , 1 , 1, "Unicode - Western, Latin-1" },
+ { "UTF-8 [ISO-8859-15]" , 1 , 1 , 1, "Unicode - Western, Latin-1 + Euro" },
+ { "UTF-8 [IBM-850]" , 1 , 1 , 1, "Unicode - IBM-850" },
+ { "UTF-8 [CP-1252]" , 1 , 1 , 1, "Unicode - Western Codepage" },
+ { "UTF-8 [ISO-8859-14]" , 1 , 1 , 1, "Unicode - Celtic" },
+ { "UTF-8 [ISO-8859-7]" , 1 , 1 , 1, "Unicode - Greek" },
+ { "UTF-8 [CP-1253]" , 1 , 1 , 1, "Unicode - Greek Codepage" },
+ { "UTF-8 [ISO-8859-10]" , 1 , 1 , 1, "Unicode - Nordic" },
+ { "UTF-8 [ISO-8859-3]" , 1 , 1 , 1, "Unicode - South European" },
+ // East European
+ { "UTF-8 [ISO-8859-4]" , 1 , 1 , 2, "Unicode - Baltic, Standard" },
+ { "UTF-8 [ISO-8859-13]" , 1 , 1 , 2, "Unicode - Baltic" },
+ { "UTF-8 [CP-1257]" , 1 , 1 , 2, "Unicode - Baltic Codepage" },
+ { "UTF-8 [ISO-8859-2]" , 1 , 1 , 2, "Unicode - Central European" },
+ { "UTF-8 [CP-1250]" , 1 , 1 , 2, "Unicode - Central European Codepage" },
+ { "UTF-8 [ISO-8859-9]" , 1 , 1 , 2, "Unicode - Turkish, Latin-5" },
+ { "UTF-8 [CP-1254]" , 1 , 1 , 2, "Unicode - Turkish Codepage" },
+ // Cyrillic
+ { "UTF-8 [ISO-8859-5]" , 1 , 1 , 3, "Unicode - Cyrillic, ISO" },
+ { "UTF-8 [CP-1251]" , 1 , 1 , 3, "Unicode - Cyrillic Codepage" },
+ { "UTF-8 [KOI8-R]" , 1 , 1 , 3, "Unicode - Cyrillic, KOI" },
+ { "UTF-8 [KOI8-U]" , 1 , 1 , 3, "Unicode - Cyrillic/Ukrainian" },
+ { "UTF-8 [IBM-866]" , 1 , 1 , 3, "Unicode - IBM-866" },
+ // Middle Eastern
+ { "UTF-8 [ISO-8859-6]" , 1 , 1 , 4, "Unicode - Arabic, Standard" },
+ { "UTF-8 [CP-1256]" , 1 , 1 , 4, "Unicode - Arabic Codepage" },
+ { "UTF-8 [ISO-8859-8]" , 1 , 1 , 4, "Unicode - Hebrew, visually ordered" },
+ { "UTF-8 [ISO-8859-8-i]" , 1 , 1 , 4, "Unicode - Hebrew, logically ordered" },
+ { "UTF-8 [CP-1255]" , 1 , 1 , 4, "Unicode - Hebrew Codepage" },
+ // Other asiatic
+ { "UTF-8 [TIS-620]" , 1 , 1 , 7, "Unicode - Thai" },
+ { "UTF-8 [CP874]" , 1 , 1 , 7, "Unicode - Thai Codepage" },
#ifndef QT_NO_BIG_CODECS
- { "UTF-8 [Big5]" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, O: 8-bit Unicode" },
- { "UTF-8 [Big5-HKSCS]" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: 8-bit Unicode" },
-
- { "UTF-8 [GB18030]" , 1 , 1 , "I: 8-bit Unicode / Chinese Simplified, O: 8-bit Unicode" },
- { "UTF-8 [JIS7]" , 1 , 1 , "I: 8-bit Unicode / Japanese (JIS7), O: 8-bit Unicode" },
- { "UTF-8 [Shift-JIS]" , 1 , 1 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" },
- { "UTF-8 [EUC-JP]" , 1 , 1 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" },
-
- { "UTF-8 [EUC-KR]" , 1 , 1 , "I: 8-bit Unicode / Korean, O: 8-bit Unicode" },
- { "UTF-8 [TSCII]" , 1 , 1 , "I: 8-bit Unicode / Tamil, O: 8-bit Unicode" },
+ // Chinese
+ { "UTF-8 [Big5]" , 1 , 1 , 5, "Unicode - Chinese Traditional" },
+ { "UTF-8 [Big5-HKSCS]" , 1 , 1 , 5, "Unicode - Chinese Traditional, Hong Kong" },
+ { "UTF-8 [GB18030]" , 1 , 1 , 5, "Unicode - Chinese Simplified" },
+ // Japanese
+ { "UTF-8 [JIS7]" , 1 , 1 , 6, "Unicode - Japanese (JIS7)" },
+ { "UTF-8 [Shift-JIS]" , 1 , 1 , 6, "Unicode - Japanese (Shift-JIS)" },
+ { "UTF-8 [EUC-JP]" , 1 , 1 , 6, "Unicode - Japanese (EUC-JP)" },
+ // Other asiatic
+ { "UTF-8 [EUC-KR]" , 1 , 1 , 7, "Unicode - Korean" },
+ { "UTF-8 [TSCII]" , 1 , 1 , 7, "Unicode - Tamil" },
#endif
- { "UTF-8 [ISO-8859-10]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-10, O: 8-bit Unicode" },
- { "UTF-8 [ISO-8859-13]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-13, O: 8-bit Unicode" },
+ { 0 , 0 , 0 , 0 , 0 }
+ };
- { "UTF-8 [ISO-8859-14]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-14, O: 8-bit Unicode" },
- { "UTF-8 [IBM-850]" , 1 , 1 , "I: 8-bit Unicode / IBM-850, O: 8-bit Unicode" },
- { "UTF-8 [IBM-866]" , 1 , 1 , "I: 8-bit Unicode / IBM-866, O: 8-bit Unicode" },
- { "UTF-8 [CP874]" , 1 , 1 , "I: 8-bit Unicode / CP874, O: 8-bit Unicode" },
+ uint encodingGroups()
+ {
+ return NUM_ENCODING_GROUPS;
+ }
- { 0 , 0 , 0 , 0 }
- };
+ const char * encodingGroup(int iIdx)
+ {
+ if(iIdx > NUM_ENCODING_GROUPS)
+ return encoding_groups[NUM_ENCODING_GROUPS];
+ return encoding_groups[iIdx];
+ }
EncodingDescription * encodingDescription(int iIdx)
{
- if(iIdx > NUM_ENCODINGS)return &(supported_encodings[NUM_ENCODINGS]);
+ if(iIdx > NUM_ENCODINGS)
+ return &(supported_encodings[NUM_ENCODINGS]);
return &(supported_encodings[iIdx]);
}
diff --git a/src/kvilib/system/kvi_locale.h b/src/kvilib/system/kvi_locale.h
index 665628b27..2d91002b7 100644
--- a/src/kvilib/system/kvi_locale.h
+++ b/src/kvilib/system/kvi_locale.h
@@ -43,12 +43,15 @@ namespace KviLocale
const char * szName;
char bSmart; // is it a smart codec ?
char bSendUtf8; // does it send utf8 or the local charset ?
+ uint uGroup; // group
const char * szDescription;
} EncodingDescription;
// you MUST start iterating from 0 and terminate when
// you get an entry with a NULL szName
KVILIB_API EncodingDescription * encodingDescription(int iIdx);
+ KVILIB_API uint encodingGroups();
+ KVILIB_API const char * encodingGroup(int iIdx);
KVILIB_API QTextCodec * codecForName(const char * szName);
KVILIB_API const KviStr & localeName();
KVILIB_API bool findCatalogue(QString &szBuffer,const QString& name,const QString& szLocaleDir);
diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp
index 338923dec..46c5b76f5 100644
--- a/src/kvirc/ui/kvi_window.cpp
+++ b/src/kvirc/ui/kvi_window.cpp
@@ -74,6 +74,7 @@
#include <QEvent>
#include <QCloseEvent>
#include <QIcon>
+#include <QActionGroup>
#ifdef COMPILE_CRYPT_SUPPORT
#include "kvi_crypt.h"
@@ -95,6 +96,9 @@ static KviTalPopupMenu * g_pMdiWindowSystemTextEncodingPopup = 0;
static KviTalPopupMenu * g_pMdiWindowSystemTextEncodingPopupStandard = 0;
static KviTalPopupMenu * g_pMdiWindowSystemTextEncodingPopupSmart = 0;
static KviTalPopupMenu * g_pMdiWindowSystemTextEncodingPopupSmartUtf8 = 0;
+static QActionGroup * g_pMdiWindowSystemTextEncodingActionGroup = 0;
+static QAction * g_pMdiWindowSystemTextEncodingCurrentAction = 0;
+static QAction * g_pMdiWindowSystemTextEncodingDefaultAction = 0;
unsigned long int g_uUniqueWindowId = 1;
@@ -665,102 +669,148 @@ void KviWindow::updateCaption()
void KviWindow::createSystemTextEncodingPopup()
{
if(!g_pMdiWindowSystemTextEncodingPopup)
- g_pMdiWindowSystemTextEncodingPopup = new KviTalPopupMenu();
- else
{
- g_pMdiWindowSystemTextEncodingPopup->clear();
- }
-
- if(!g_pMdiWindowSystemTextEncodingPopupStandard)
+ // first time called, create the menu
+ g_pMdiWindowSystemTextEncodingPopup = new KviTalPopupMenu();
g_pMdiWindowSystemTextEncodingPopupStandard = new KviTalPopupMenu();
- else
- {
- g_pMdiWindowSystemTextEncodingPopupStandard->clear();
- disconnect(g_pMdiWindowSystemTextEncodingPopupStandard,SIGNAL(activated(int)),0,0);
- }
-
- if(!g_pMdiWindowSystemTextEncodingPopupSmart)
g_pMdiWindowSystemTextEncodingPopupSmart = new KviTalPopupMenu();
- else
- {
- g_pMdiWindowSystemTextEncodingPopupSmart->clear();
- disconnect(g_pMdiWindowSystemTextEncodingPopupSmart,SIGNAL(activated(int)),0,0);
- }
-
- if(!g_pMdiWindowSystemTextEncodingPopupSmartUtf8)
g_pMdiWindowSystemTextEncodingPopupSmartUtf8 = new KviTalPopupMenu();
- else
- {
- g_pMdiWindowSystemTextEncodingPopupSmartUtf8->clear();
- disconnect(g_pMdiWindowSystemTextEncodingPopupSmartUtf8,SIGNAL(activated(int)),0,0);
- }
+ g_pMdiWindowSystemTextEncodingActionGroup = new QActionGroup(g_pMdiWindowSystemTextEncodingPopup);
+ connect(g_pMdiWindowSystemTextEncodingActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(systemTextEncodingPopupActivated(QAction*)));
- QTextCodec * c = defaultTextCodec();
- QString tmp = __tr2qs("Use Default Encoding");
- if(c)
- {
- tmp += " (";
- tmp += c->name();
- tmp += ")";
- }
+ //default action
+ QTextCodec * c = defaultTextCodec();
+ QString tmp = __tr2qs("Use Default Encoding");
+ if(c)
+ {
+ tmp += " (";
+ tmp += c->name();
+ tmp += ")";
+ }
- int id = g_pMdiWindowSystemTextEncodingPopup->insertItem(tmp,this,SLOT(systemTextEncodingPopupDefault()));
- if(m_szTextEncoding.isEmpty())g_pMdiWindowSystemTextEncodingPopup->setItemChecked(id,true);
- g_pMdiWindowSystemTextEncodingPopup->insertSeparator();
+ g_pMdiWindowSystemTextEncodingDefaultAction = g_pMdiWindowSystemTextEncodingPopup->addAction(tmp);
+ g_pMdiWindowSystemTextEncodingActionGroup->addAction(g_pMdiWindowSystemTextEncodingDefaultAction);
+ g_pMdiWindowSystemTextEncodingDefaultAction->setData(-1);
+ if(m_szTextEncoding.isEmpty())
+ {
+ g_pMdiWindowSystemTextEncodingDefaultAction->setCheckable(true);
+ g_pMdiWindowSystemTextEncodingDefaultAction->setChecked(true);
+ }
- g_pMdiWindowSystemTextEncodingPopup->insertItem(__tr2qs("Standard"),g_pMdiWindowSystemTextEncodingPopupStandard);
- g_pMdiWindowSystemTextEncodingPopup->insertItem(__tr2qs("Smart (Send Local)"),g_pMdiWindowSystemTextEncodingPopupSmart);
- g_pMdiWindowSystemTextEncodingPopup->insertItem(__tr2qs("Smart (Send UTF-8)"),g_pMdiWindowSystemTextEncodingPopupSmartUtf8);
+ //current action
+ g_pMdiWindowSystemTextEncodingCurrentAction = g_pMdiWindowSystemTextEncodingPopup->addAction(__tr2qs("Current: "));
+ g_pMdiWindowSystemTextEncodingActionGroup->addAction(g_pMdiWindowSystemTextEncodingCurrentAction);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(false);
+
+ // other first level menus
+ g_pMdiWindowSystemTextEncodingPopup->insertSeparator();
- int i = 0;
- KviLocale::EncodingDescription * d = KviLocale::encodingDescription(i);
- while(d->szName)
- {
- KviQString::sprintf(tmp,"%s (%s)",d->szName,d->szDescription);
- KviTalPopupMenu * ppp = d->bSmart ? (d->bSendUtf8 ? g_pMdiWindowSystemTextEncodingPopupSmartUtf8 : g_pMdiWindowSystemTextEncodingPopupSmart) : g_pMdiWindowSystemTextEncodingPopupStandard;
- id = ppp->insertItem(tmp);
- if(KviQString::equalCI(m_szTextEncoding,d->szName))
- ppp->setItemChecked(id,true);
- i = i + 1;
- d = KviLocale::encodingDescription(i);
- }
+ g_pMdiWindowSystemTextEncodingPopup->insertItem(__tr2qs("Standard"),g_pMdiWindowSystemTextEncodingPopupStandard);
+ g_pMdiWindowSystemTextEncodingPopup->insertItem(__tr2qs("Smart (Send Local)"),g_pMdiWindowSystemTextEncodingPopupSmart);
+ g_pMdiWindowSystemTextEncodingPopup->insertItem(__tr2qs("Smart (Send UTF-8)"),g_pMdiWindowSystemTextEncodingPopupSmartUtf8);
- connect(g_pMdiWindowSystemTextEncodingPopupSmart,SIGNAL(activated(int)),this,SLOT(systemTextEncodingPopupSmartActivated(int)));
- connect(g_pMdiWindowSystemTextEncodingPopupSmartUtf8,SIGNAL(activated(int)),this,SLOT(systemTextEncodingPopupSmartUtf8Activated(int)));
- connect(g_pMdiWindowSystemTextEncodingPopupStandard,SIGNAL(activated(int)),this,SLOT(systemTextEncodingPopupStandardActivated(int)));
-}
+ // second level menus (encoding groups)
+ uint uGroups = KviLocale::encodingGroups();
+ QMenu * aPopupStandard[uGroups];
+ QMenu * aPopupSmart[uGroups];
+ QMenu * aPopupSmartUtf8[uGroups];
-void KviWindow::systemTextEncodingPopupDefault()
-{
- // default
- setTextEncoding("");
-}
+ uint j = 0;
+ const char * szEncodingGroup = KviLocale::encodingGroup(j);
-void KviWindow::systemTextEncodingPopupSmartActivated(int id)
-{
- if(!g_pMdiWindowSystemTextEncodingPopupSmart)
- return;
- QString tmp = g_pMdiWindowSystemTextEncodingPopupSmart->text(id);
- KviQString::cutFromFirst(tmp," (");
- setTextEncoding(tmp);
-}
+ while(szEncodingGroup)
+ {
+ aPopupStandard[j] = g_pMdiWindowSystemTextEncodingPopupStandard->addMenu(szEncodingGroup);
+ if(j) //only standard popup contains unicode menu
+ {
+ aPopupSmart[j] = g_pMdiWindowSystemTextEncodingPopupSmart->addMenu(szEncodingGroup);
+ aPopupSmartUtf8[j] = g_pMdiWindowSystemTextEncodingPopupSmartUtf8->addMenu(szEncodingGroup);
+ }
+
+ szEncodingGroup = KviLocale::encodingGroup(++j);
+ }
-void KviWindow::systemTextEncodingPopupSmartUtf8Activated(int id)
-{
- if(!g_pMdiWindowSystemTextEncodingPopupSmartUtf8)
- return;
- QString tmp = g_pMdiWindowSystemTextEncodingPopupSmartUtf8->text(id);
- KviQString::cutFromFirst(tmp," (");
- setTextEncoding(tmp);
+ // third level menus (encodings)
+ uint i=0;
+ KviLocale::EncodingDescription * d = KviLocale::encodingDescription(i);
+ while(d->szName)
+ {
+ KviQString::sprintf(tmp,"%s (%s)",d->szName,d->szDescription);
+ if(KviQString::equalCI(m_szTextEncoding,d->szName))
+ {
+ g_pMdiWindowSystemTextEncodingCurrentAction->setText(__tr2qs("Current: ") + tmp);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setCheckable(true);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setChecked(true);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(true);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setData(i);
+ } else {
+ QMenu * ppp = d->bSmart ? (d->bSendUtf8 ?
+ aPopupSmartUtf8[d->uGroup] :
+ aPopupSmart[d->uGroup]
+ ) : aPopupStandard[d->uGroup];
+
+ QAction * pAction = ppp->addAction(tmp);
+ pAction->setData(i);
+ g_pMdiWindowSystemTextEncodingActionGroup->addAction(pAction);
+ }
+
+ d = KviLocale::encodingDescription(++i);
+ }
+ } else {
+ //default action: refresh the name
+ QTextCodec * c = defaultTextCodec();
+ QString tmp = __tr2qs("Use Default Encoding");
+ if(c)
+ {
+ tmp += " (";
+ tmp += c->name();
+ tmp += ")";
+ }
+
+ g_pMdiWindowSystemTextEncodingDefaultAction->setText(tmp);
+
+ //menu already exists, choose the right item
+ if(m_szTextEncoding.isEmpty())
+ {
+ //default action; hide the current action
+ g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(false);
+
+ g_pMdiWindowSystemTextEncodingDefaultAction->setCheckable(true);
+ g_pMdiWindowSystemTextEncodingDefaultAction->setChecked(true);
+ } else {
+ int i=0;
+ KviLocale::EncodingDescription * d = KviLocale::encodingDescription(i);
+ while(d->szName)
+ {
+ if(KviQString::equalCI(m_szTextEncoding,d->szName))
+ {
+ KviQString::sprintf(tmp,"%s (%s)",d->szName,d->szDescription);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setText(__tr2qs("Current: ") + tmp);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setCheckable(true);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setChecked(true);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setVisible(true);
+ g_pMdiWindowSystemTextEncodingCurrentAction->setData(i);
+ break;
+ }
+
+ d = KviLocale::encodingDescription(++i);
+ }
+ }
+ }
}
-void KviWindow::systemTextEncodingPopupStandardActivated(int id)
+void KviWindow::systemTextEncodingPopupActivated(QAction * pAction)
{
- if(!g_pMdiWindowSystemTextEncodingPopupStandard)
+ if(!pAction || pAction == g_pMdiWindowSystemTextEncodingCurrentAction)
return;
- QString tmp = g_pMdiWindowSystemTextEncodingPopupStandard->text(id);
- KviQString::cutFromFirst(tmp," (");
- setTextEncoding(tmp);
+ if(pAction == g_pMdiWindowSystemTextEncodingDefaultAction)
+ {
+ setTextEncoding("");
+ } else {
+ QString tmp = pAction->text();
+ KviQString::cutFromFirst(tmp," (");
+ setTextEncoding(tmp);
+ }
}
void KviWindow::savePropertiesAsDefault()
diff --git a/src/kvirc/ui/kvi_window.h b/src/kvirc/ui/kvi_window.h
index 17f90f6c3..39516854d 100644
--- a/src/kvirc/ui/kvi_window.h
+++ b/src/kvirc/ui/kvi_window.h
@@ -312,10 +312,7 @@ protected slots:
void cryptControllerFinished(); // same as above
void cryptSessionInfoDestroyed(); // same as above
void textEncodingButtonClicked();
- void systemTextEncodingPopupSmartActivated(int id);
- void systemTextEncodingPopupSmartUtf8Activated(int id);
- void systemTextEncodingPopupStandardActivated(int id);
- void systemTextEncodingPopupDefault();
+ void systemTextEncodingPopupActivated(QAction *pAction);
void childDestroyed();
signals:
void windowNameChanged();