![](https://seccdn.libravatar.org/avatar/09d48268ad1ffb8c8e17fbc3b36e1480.jpg?s=120&d=mm&r=g)
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 <qfont.h> #include "YQPackageSelectorPluginStub.h" -#include "QY2Settings.h" #include "YApplication.h" +class QSettings; class YQPackageSelectorPlugin; @@ -323,7 +323,7 @@ /** * Language-specific font settings **/ - QY2Settings * _langFonts; + QSettings * _langFonts; /** * Translator for the predefined Qt dialogs Modified: trunk/qt/src/YQUI_core.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_core.cc?rev=47642&r1=47641&r2=47642&view=diff ============================================================================== --- trunk/qt/src/YQUI_core.cc (original) +++ trunk/qt/src/YQUI_core.cc Sat May 17 15:56:40 2008 @@ -43,7 +43,6 @@ #include "utf8.h" #include "YQDialog.h" -#include "QY2Settings.h" using std::max; Modified: trunk/qt/src/YQUI_x11.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_x11.cc?rev=47642&r1=47641&r2=47642&view=diff ============================================================================== --- trunk/qt/src/YQUI_x11.cc (original) +++ trunk/qt/src/YQUI_x11.cc Sat May 17 15:56:40 2008 @@ -35,7 +35,6 @@ #include "YEvent.h" #include "YQDialog.h" #include "YQi18n.h" -#include "QY2Settings.h" #include "YQUI.h" // Include low-level X headers AFTER Qt headers: Modified: trunk/qt/src/lang_fonts URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/lang_fonts?rev=47642&r1=47641&r2=47642&view=diff ============================================================================== --- trunk/qt/src/lang_fonts (original) +++ trunk/qt/src/lang_fonts Sat May 17 15:56:40 2008 @@ -1,36 +1,36 @@ # Language specific fonts for yast2-qt # # Used upon UI::SetLanguage( lang ) -# Fallback strategy for a locale "xy_AB.UTF8": +# Fallback strategy for a locale xy_AB.UTF8: # # font[xy_AB.UTF8] = ??? # font[xy_AB] = ??? # font[xy] = ??? # font = ??? # -# If none of those is found, "Sans Serif" is used. +# If none of those is found, Sans Serif is used. # # Don't enumerate all languages just for the fun of it, # better specify a reasonable default with # # font = ??? -font = "Sans Serif" -font[zh] ="Albany AMT,DejaVu Sans,SUSE Sans,FZSongTi,FZMingTiB,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" -font[zh_CN] = "Albany AMT,DejaVu Sans,SUSE Sans,FZSongTi,FZMingTiB,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" -font[zh_SG] = "Albany AMT,DejaVu Sans,SUSE Sans,FZSongTi,FZMingTiB,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" -font[zh_TW] = "Albany AMT,DejaVu Sans,SUSE Sans,FZMingTiB,FZSongTi,AR PL Mingti2L Big5,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" -font[zh_HK] = "Albany AMT,DejaVu Sans,SUSE Sans,FZMingTiB,FZSongTi,AR PL Mingti2L Big5,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" -font[ja] = "Albany AMT,DejaVu Sans,SUSE Sans,HGPGothicB,IPAPGothic,IPAGothic,Sazanami Gothic,Efont Biwidth,Gnu Unifont,Sans Serif" +font="Sans Serif" +font[zh]="Albany AMT,DejaVu Sans,SUSE Sans,FZSongTi,FZMingTiB,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" +font[zh_CN]="Albany AMT,DejaVu Sans,SUSE Sans,FZSongTi,FZMingTiB,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" +font[zh_SG]="Albany AMT,DejaVu Sans,SUSE Sans,FZSongTi,FZMingTiB,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" +font[zh_TW]="Albany AMT,DejaVu Sans,SUSE Sans,FZMingTiB,FZSongTi,AR PL Mingti2L Big5,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" +font[zh_HK]="Albany AMT,DejaVu Sans,SUSE Sans,FZMingTiB,FZSongTi,AR PL Mingti2L Big5,AR PL SungtiL GB,Gnu Unifont,Efont Biwidth,Sans Serif" +font[ja]="Albany AMT,DejaVu Sans,SUSE Sans,HGPGothicB,IPAPGothic,IPAGothic,Sazanami Gothic,Efont Biwidth,Gnu Unifont,Sans Serif" # For debugging -font[xy_AB.UTF8] = "xy_AB_UTF8, Sans Serif" -font[xy_XY] = "xy_XY, Sans Serif" -font[xy] = "xy, Sans Serif" - -font[times] = "Times" -font[sans] = "Sans Serif" -font[helv] = "Helvetica" +font[xy_AB.UTF8]="xy_AB_UTF8, Sans Serif" +font[xy_XY]="xy_XY, Sans Serif" +font[xy]="xy, Sans Serif" + +font[times]="Times" +font[sans]="Sans Serif" +font[helv]="Helvetica" -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org