mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
use char32_t as the inner string unit.
This commit is contained in:
parent
728a5b9651
commit
9857ed0559
14
main.cc
14
main.cc
|
@ -44,23 +44,12 @@
|
|||
#include "lionsupport.h"
|
||||
#endif
|
||||
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) )
|
||||
|
||||
void gdMessageHandler( QtMsgType type, const QMessageLogContext &context, const QString &mess )
|
||||
{
|
||||
Q_UNUSED( context );
|
||||
QString message( mess );
|
||||
QByteArray msg = message.toUtf8().constData();
|
||||
|
||||
#else
|
||||
|
||||
void gdMessageHandler( QtMsgType type, const char *msg_ )
|
||||
{
|
||||
QString message = QString::fromUtf8( msg_ );
|
||||
QByteArray msg = QByteArray::fromRawData( msg_, strlen( msg_ ) );
|
||||
|
||||
#endif
|
||||
|
||||
switch (type) {
|
||||
|
||||
case QtDebugMsg:
|
||||
|
@ -94,15 +83,12 @@ void gdMessageHandler( QtMsgType type, const char *msg_ )
|
|||
else
|
||||
fprintf(stderr, "Fatal: %s\n", msg.constData());
|
||||
abort();
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 5, 0 )
|
||||
case QtInfoMsg:
|
||||
if( logFilePtr && logFilePtr->isOpen() )
|
||||
message.insert( 0, "Info: " );
|
||||
else
|
||||
fprintf(stderr, "Info: %s\n", msg.constData());
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if( logFilePtr && logFilePtr->isOpen() )
|
||||
|
|
|
@ -629,9 +629,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
ui.tabWidget->setCornerWidget( &addTab, Qt::TopLeftCorner );
|
||||
//ui.tabWidget->setCornerWidget( &closeTab, Qt::TopRightCorner );
|
||||
|
||||
#if QT_VERSION >= 0x040500
|
||||
ui.tabWidget->setMovable( true );
|
||||
#endif
|
||||
|
||||
#ifndef Q_OS_WIN32
|
||||
ui.tabWidget->setDocumentMode( true );
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
#include "wstring.hh"
|
||||
#include "iconv.hh"
|
||||
#include <wchar.h>
|
||||
#include <QString>
|
||||
|
||||
namespace gd
|
||||
{
|
||||
wstring __nativeToWs( wchar_t const * str )
|
||||
{
|
||||
return Iconv::toWstring( "WCHAR_T", str, wcslen( str ) * sizeof( wchar_t ) );
|
||||
QString qStr=QString::fromWCharArray(str);
|
||||
return qStr.toStdU32String();
|
||||
//return Iconv::toWstring( "WCHAR_T", str, wcslen( str ) * sizeof( wchar_t ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,10 +43,9 @@
|
|||
|
||||
namespace gd
|
||||
{
|
||||
#ifdef __WIN32
|
||||
|
||||
typedef char32_t wchar;
|
||||
typedef std::u32string wstring;
|
||||
#ifdef __WIN32
|
||||
|
||||
// GD_NATIVE_TO_WS is used to convert L"" strings to a const pointer to
|
||||
// wchar.
|
||||
|
@ -55,8 +54,6 @@ namespace gd
|
|||
|
||||
#else
|
||||
|
||||
typedef char32_t wchar;
|
||||
typedef std::u32string wstring;
|
||||
#define GD_NATIVE_TO_WS( str ) ( str )
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -3,22 +3,13 @@
|
|||
|
||||
namespace gd
|
||||
{
|
||||
#ifdef __WIN32
|
||||
|
||||
|
||||
QString toQString( wstring const & in )
|
||||
{
|
||||
return QString::fromUcs4( in.c_str() );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
QString toQString( wstring const & in )
|
||||
{
|
||||
return QString::fromStdWString( in );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
wstring toWString( QString const & in )
|
||||
{
|
||||
QVector< unsigned int > v = in.toUcs4();
|
||||
|
|
Loading…
Reference in a new issue