[yast-commit] r47642 - in /trunk/qt/src: CMakeLists.txt QY2Settings.cc QY2Settings.h YQApplication.cc YQApplication.h YQUI_core.cc YQUI_x11.cc lang_fonts
Author: coolo
Date: Sat May 17 15:56:40 2008
New Revision: 47642
URL: http://svn.opensuse.org/viewcvs/yast?rev=47642&view=rev
Log:
fix support of lang_fonts
Removed:
trunk/qt/src/QY2Settings.cc
trunk/qt/src/QY2Settings.h
Modified:
trunk/qt/src/CMakeLists.txt
trunk/qt/src/YQApplication.cc
trunk/qt/src/YQApplication.h
trunk/qt/src/YQUI_core.cc
trunk/qt/src/YQUI_x11.cc
trunk/qt/src/lang_fonts
Modified: trunk/qt/src/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/CMakeLists.txt?rev=47642&r1=47641&r2=47642&view=diff
==============================================================================
--- trunk/qt/src/CMakeLists.txt (original)
+++ trunk/qt/src/CMakeLists.txt Sat May 17 15:56:40 2008
@@ -17,7 +17,6 @@
QY2DiskUsageList.cc
QY2HelpDialog.cc
QY2ListView.cc
- QY2Settings.cc
QY2Styler.cc
YFrameBuffer.cc
YQAlignment.cc
@@ -78,7 +77,6 @@
QY2DiskUsageList.h
QY2HelpDialog.h
QY2ListView.h
- QY2Settings.h
QY2Styler.h
utf8.h
YFrameBuffer.h
Modified: trunk/qt/src/YQApplication.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQApplication.cc?rev=47642&r1=47641&r2=47642&view=diff
==============================================================================
--- trunk/qt/src/YQApplication.cc (original)
+++ trunk/qt/src/YQApplication.cc Sat May 17 15:56:40 2008
@@ -26,6 +26,7 @@
#include <QFileDialog>
#include <QDesktopWidget>
#include <QMessageBox>
+#include <QSettings>
#define YUILogComponent "qt-ui"
#include "YUILog.h"
@@ -44,7 +45,6 @@
, _currentFont( 0 )
, _headingFont( 0 )
, _boldFont( 0 )
- , _fontFamily( "Sans Serif" )
, _langFonts( 0 )
, _qtTranslations( 0 )
, _autoFonts( false )
@@ -64,11 +64,8 @@
YQApplication::~YQApplication()
{
- if ( _langFonts )
- delete _langFonts;
-
- if ( _qtTranslations )
- delete _qtTranslations;
+ delete _langFonts;
+ delete _qtTranslations;
deleteFonts();
}
@@ -78,6 +75,7 @@
YQApplication::setLanguage( const string & language,
const string & encoding )
{
+ yuiMilestone() << "setLanguage " << language << endl;
YApplication::setLanguage( language, encoding );
loadPredefinedQtTranslations();
setLangFonts( language, encoding );
@@ -145,17 +143,20 @@
void
YQApplication::setLangFonts( const string & language, const string & encoding )
{
+ if ( _fontFamily.isEmpty() )
+ _fontFamily = qApp->font().family();
+
QString oldFontFamily = _fontFamily;
if ( ! _langFonts )
{
- _langFonts = new QY2Settings( LANG_FONTS_FILE );
+ _langFonts = new QSettings( LANG_FONTS_FILE, QSettings::IniFormat );
Q_CHECK_PTR( _langFonts );
- if ( _langFonts->readError() )
+ if ( _langFonts->status() != QSettings::NoError )
yuiError() << "Error reading " << _langFonts->fileName() << endl;
else
- yuiMilestone() << _langFonts->fileName() << " read OK" << endl;
+ yuiMilestone() << _langFonts->fileName() << " read OK" << qPrintable( _langFonts->allKeys().join( "-" ) ) << endl;
}
QString lang = language.c_str();
@@ -165,41 +166,58 @@
QString key;
- if ( ! _langFonts->hasKey( fontKey( lang ) ) ) // Try with encoding ("zh_CN.UTF8" etc.)
+ if ( ! _langFonts->contains( fontKey( lang ) ) ) // Try with encoding ("zh_CN.UTF8" etc.)
{
lang = language.c_str(); // Try without encoding ("zh_CN")
- if ( ! _langFonts->hasKey( fontKey( lang ) ) )
+ if ( ! _langFonts->contains( fontKey( lang ) ) )
lang.replace( QRegExp( "_.*$" ), "" ); // Cut off trailing country ("_CN")
}
- if ( _langFonts->hasKey( fontKey( lang ) ) )
+ if ( _langFonts->contains( fontKey( lang ) ) )
{
- _fontFamily = _langFonts->get( fontKey( lang ), "Sans Serif" );
+ _fontFamily = _langFonts->value( fontKey( lang ), _fontFamily ).toString();
yuiMilestone() << fontKey( lang ) << " = \"" << _fontFamily << "\"" << endl;
}
else
{
- _fontFamily = _langFonts->get( fontKey( "" ), "Sans Serif" );
+ _fontFamily = _langFonts->value( fontKey( "" ), _fontFamily ).toString();
yuiMilestone() << "Using fallback for " << lang
<< ": font = \"" << _fontFamily << "\""
<< endl;
}
- if ( _fontFamily != oldFontFamily && ! _fontFamily.isEmpty() )
+ if ( _fontFamily.isEmpty() ) {
+ _fontFamily = "Sans Serif";
+ }
+
+ if ( _fontFamily != oldFontFamily )
{
yuiMilestone() << "New font family: " << _fontFamily << endl;
deleteFonts();
- int size = qApp->font().pointSize();
- QFont font( _fontFamily );
- font.setPointSize( size );
- qApp->setFont(font); // font, informWidgets
+
+ foreach (QWidget *widget, QApplication::allWidgets())
+ {
+ if ( widget->font().family() != oldFontFamily )
+ {
+ yuiMilestone() << "font " << qPrintable( widget->font().family() ) << " family is not " << oldFontFamily << endl;
+ continue;
+ }
+ QFont wfont( widget->font() );
+ wfont.setFamily( _fontFamily );
+ widget->setFont( wfont );
+ }
+ QFont font( qApp->font() );
+ font.setFamily( _fontFamily );
+ qApp->setFont(font); // font, informWidgets
+
yuiMilestone() << "Reloading fonts - now using \"" << font.toString() << "\"" << endl;
}
else
{
yuiDebug() << "No font change" << endl;
}
+
}
@@ -302,14 +320,9 @@
void
YQApplication::deleteFonts()
{
- if ( _currentFont )
- delete _currentFont;
-
- if ( _headingFont )
- delete _headingFont;
-
- if ( _boldFont )
- delete _boldFont;
+ delete _currentFont;
+ delete _headingFont;
+ delete _boldFont;
_currentFont = 0;
_headingFont = 0;
Modified: trunk/qt/src/YQApplication.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQApplication.h?rev=47642&r1=47641&r2=47642&view=diff
==============================================================================
--- trunk/qt/src/YQApplication.h (original)
+++ trunk/qt/src/YQApplication.h Sat May 17 15:56:40 2008
@@ -25,9 +25,9 @@
#include
participants (1)
-
coolo@svn.opensuse.org