From 596b99b513b65a06f39f9fa5dd912581b29d5b5f Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 22 Jun 2005 12:19:50 +0000 Subject: [PATCH] 1) provide customization of translation files formats 2) loadPixmap() method returns default icon if the resource file is not found --- src/Qtx/QtxResourceMgr.cxx | 39 +++++++++++++++++++++++++++++++++++++- src/Qtx/QtxResourceMgr.h | 2 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index f85b9382f..7b791d5bc 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -13,6 +13,29 @@ #include +/* XPM */ +static const char* pixmap_not_found_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #A80000", +" ", +" ", +" . . ", +" .+. .+. ", +" .+++. .+++. ", +" .+++.+++. ", +" .+++++. ", +" .+++. ", +" .+++++. ", +" .+++.+++. ", +" .+++. .+++. ", +" .+. .+. ", +" . . ", +" ", +" ", +" "}; + /*! Class: QtxResourceMgr::Resources Level: Internal @@ -1093,13 +1116,16 @@ QString QtxResourceMgr::langSection() const return res; } -QPixmap QtxResourceMgr::loadPixmap( const QString& prefix, const QString& name ) const +QPixmap QtxResourceMgr::loadPixmap( const QString& prefix, const QString& name, const bool useDefault ) const { initialize(); + static QPixmap defaultPixmap( pixmap_not_found_xpm ); QPixmap pix; for ( ResListIterator it( myResources ); it.current() && pix.isNull(); ++it ) pix = it.current()->loadPixmap( resSection(), prefix, name ); + if ( pix.isNull() && useDefault ) + return defaultPixmap; return pix; } @@ -1122,6 +1148,17 @@ void QtxResourceMgr::loadLanguage( const QString& pref, const QString& l ) substMap.insert( 'L', lang ); + QString trs; + if ( value( langSection(), "translators", trs, false ) && !trs.isEmpty() ) + { + QStringList translators = QStringList::split( "|", option( "translators" ) ); + QStringList newTranslators = QStringList::split( "|", trs ); + for ( uint i = 0; i < newTranslators.count(); i++ ) + if ( translators.find( newTranslators[i] ) == translators.end() ) + translators += newTranslators[i]; + setOption( "translators", translators.join( "|" ) ); + } + QStringList trList = QStringList::split( "|", option( "translators" ) ); if ( trList.isEmpty() ) { diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index 2972ca037..4c657e73c 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -96,7 +96,7 @@ public: QString resSection() const; QString langSection() const; - QPixmap loadPixmap( const QString&, const QString& ) const; + QPixmap loadPixmap( const QString&, const QString&, const bool = true ) const; void loadLanguage( const QString& = QString::null, const QString& = QString::null ); void raiseTranslators( const QString& ); -- 2.39.2