• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • localization
klocale_win.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 * Copyright 2005, 2008 Jaroslaw Staniek <staniek@kde.org>
3 * Copyright 2010 John Layt <john@layt.net>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "klocale_win_p.h"
22
23#include <QtCore/QLocale>
24#include <QtCore/QTextCodec>
25
26KLocaleWindowsPrivate::KLocaleWindowsPrivate(KLocale *q_ptr, const QString &catalogName, KSharedConfig::Ptr config)
27 :KLocalePrivate(q_ptr)
28{
29 // Lock in the current Windows Locale ID
30 // Can we also lock in the actual settings like we do for Mac?
31 m_winLocaleId = GetUserDefaultLCID();
32 init(catalogName, QString(), QString(), config, 0);
33}
34
35KLocaleWindowsPrivate::KLocaleWindowsPrivate(KLocale *q_ptr, const QString& catalogName,
36 const QString &language, const QString &country, KConfig *config)
37 :KLocalePrivate(q_ptr)
38{
39 // Lock in the current Windows Locale ID
40 // Can we also lock in the actual settings like we do for Mac?
41 m_winLocaleId = GetUserDefaultLCID();
42 init(catalogName, language, country, KSharedConfig::Ptr(), config);
43}
44
45KLocaleWindowsPrivate::KLocaleWindowsPrivate( const KLocaleWindowsPrivate &rhs )
46 :KLocalePrivate( rhs )
47{
48 KLocalePrivate::copy( rhs );
49 m_winLocaleId = rhs.m_winLocaleId;
50 strcpy( m_win32SystemEncoding, rhs.m_win32SystemEncoding );
51}
52
53KLocaleWindowsPrivate &KLocaleWindowsPrivate::operator=( const KLocaleWindowsPrivate &rhs )
54{
55 KLocalePrivate::copy( rhs );
56 m_winLocaleId = rhs.m_winLocaleId;
57 strcpy( m_win32SystemEncoding, rhs.m_win32SystemEncoding );
58 return *this;
59}
60
61KLocaleWindowsPrivate::~KLocaleWindowsPrivate()
62{
63}
64
65QString KLocaleWindowsPrivate::windowsLocaleValue( LCTYPE key ) const
66{
67 // Find out how big the buffer needs to be
68 int size = GetLocaleInfoW( m_winLocaleId, key, 0, 0 );
69
70 QString result;
71 if ( size ) {
72 wchar_t* buffer = new wchar_t[size];
73 if ( GetLocaleInfoW( m_winLocaleId, key, buffer, size ) )
74 result = QString::fromWCharArray( buffer );
75 delete[] buffer;
76 }
77 return result;
78}
79
80QString KLocaleWindowsPrivate::systemCountry() const
81{
82 return windowsLocaleValue( LOCALE_SISO3166CTRYNAME );
83}
84
85QStringList KLocaleWindowsPrivate::systemLanguageList() const
86{
87 QStringList list;
88 getLanguagesFromVariable( list, QLocale::system().name().toLocal8Bit().data() );
89 return list;
90}
91
92QByteArray KLocaleWindowsPrivate::systemCodeset() const
93{
94 return QByteArray();
95}
96
97const QByteArray KLocaleWindowsPrivate::encoding()
98{
99 if ( qstrcmp( codecForEncoding()->name(), "System" ) == 0 ) {
100 //win32 returns "System" codec name here but KDE apps expect a real name:
101 strcpy( m_win32SystemEncoding, "cp " );
102 // MSDN says the returned string for LOCALE_IDEFAULTANSICODEPAGE is max 6 char including '\0'
103 char buffer[6];
104 if ( GetLocaleInfoA( MAKELCID( MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT ), SORT_DEFAULT ),
105 LOCALE_IDEFAULTANSICODEPAGE, buffer, sizeof( buffer ) ) ) {
106 strcpy( m_win32SystemEncoding + 3, buffer );
107 return m_win32SystemEncoding;
108 }
109 }
110 return KLocalePrivate::encoding();
111}
112
113/*
114These functions are commented out for now until all required Date/Time functions are implemented
115to ensure consistent behaviour, i.e. all KDE format or all Windows format, not some invalid mixture
116
117void KLocaleMacPrivate::initDayPeriods(const KConfigGroup &cg)
118{
119 QString amText = windowsLocaleValue(LOCALE_S1159);
120 QString pmText = windowsLocaleValue(LOCALE_S2359);
121
122 m_dayPeriods.clear();
123 m_dayPeriods.append(KDayPeriod("am", amText, amText, amText
124 QTime(0, 0, 0), QTime(11, 59, 59, 999), 0, 12));
125 m_dayPeriods.append(KDayPeriod("pm", pmText, pmText, pmText,
126 QTime(12, 0, 0), QTime(23, 59, 59, 999), 0, 12));
127}
128
129*/
KConfig
The central class of the KDE configuration data system.
Definition: kconfig.h:71
KLocalePrivate
Definition: klocale_p.h:35
KLocalePrivate::language
virtual QString language() const
Definition: klocale_kde.cpp:780
KLocalePrivate::getLanguagesFromVariable
static void getLanguagesFromVariable(QStringList &list, const char *variable, bool isLanguageList=false)
Definition: klocale_kde.cpp:329
KLocalePrivate::encoding
virtual const QByteArray encoding()
Definition: klocale_kde.cpp:3050
KLocalePrivate::config
KConfig * config()
Definition: klocale_kde.cpp:130
KLocalePrivate::init
virtual void init(const QString &catalogName, const QString &language, const QString &country, KSharedConfig::Ptr persistantconfig, KConfig *tempConfig)
Definition: klocale_kde.cpp:229
KLocalePrivate::codecForEncoding
virtual QTextCodec * codecForEncoding() const
Definition: klocale_kde.cpp:3068
KLocalePrivate::country
virtual QString country() const
Definition: klocale_kde.cpp:785
KLocalePrivate::copy
virtual void copy(const KLocalePrivate &rhs)
Definition: klocale_kde.cpp:139
KLocaleWindowsPrivate
Definition: klocale_win_p.h:28
KLocaleWindowsPrivate::systemCodeset
virtual QByteArray systemCodeset() const
Definition: klocale_win.cpp:92
KLocaleWindowsPrivate::~KLocaleWindowsPrivate
virtual ~KLocaleWindowsPrivate()
Definition: klocale_win.cpp:61
KLocaleWindowsPrivate::operator=
KLocaleWindowsPrivate & operator=(const KLocaleWindowsPrivate &rhs)
Definition: klocale_win.cpp:53
KLocaleWindowsPrivate::encoding
virtual const QByteArray encoding()
Definition: klocale_win.cpp:97
KLocaleWindowsPrivate::systemCountry
virtual QString systemCountry() const
Definition: klocale_win.cpp:80
KLocaleWindowsPrivate::KLocaleWindowsPrivate
KLocaleWindowsPrivate(KLocale *q_ptr, const QString &catalogName, KSharedConfig::Ptr config)
Definition: klocale_win.cpp:26
KLocaleWindowsPrivate::systemLanguageList
virtual QStringList systemLanguageList() const
Definition: klocale_win.cpp:85
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:70
KSharedPtr< KSharedConfig >
QStringList
QString
klocale_win_p.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal