[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/okular/ui
From: Pino Toscano <pino () kde ! org>
Date: 2008-11-15 23:27:28
Message-ID: 1226791648.596993.5133.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 884837 by pino:
changes to the stamp loading system:
- instead of load the stamps from single SVGs, load them from elements of a single \
SVG containing all of them
- cache that said SVG (should make their drawing fast again)
M +29 -4 guiutils.cpp
--- trunk/KDE/kdegraphics/okular/ui/guiutils.cpp #884836:884837
@@ -24,6 +24,8 @@
#include "core/annotations.h"
#include "core/document.h"
+#include <memory>
+
struct GuiUtilsHelper
{
GuiUtilsHelper()
@@ -31,9 +33,29 @@
{
}
+ QSvgRenderer* svgStamps();
+
KIconLoader * il;
+ std::auto_ptr< QSvgRenderer > svgStampFile;
};
+QSvgRenderer* GuiUtilsHelper::svgStamps()
+{
+ if ( !svgStampFile.get() )
+ {
+ const QString stampFile = KStandardDirs::locate( "data", \
"okular/pics/stamps.svg" ); + if ( !stampFile.isEmpty() )
+ {
+ svgStampFile.reset( new QSvgRenderer( stampFile ) );
+ if ( !svgStampFile->isValid() )
+ {
+ svgStampFile.reset();
+ }
+ }
+ }
+ return svgStampFile.get();
+}
+
K_GLOBAL_STATIC( GuiUtilsHelper, s_data )
namespace GuiUtils {
@@ -145,13 +167,16 @@
const QString name = _name.toLower();
if ( name.startsWith( QLatin1String( "stamp-" ) ) )
{
- QSvgRenderer r( KStandardDirs::locate( "data", QString::fromLatin1( \
"okular/pics/" ) + name + ".svg" ) );
- if ( r.isValid() )
+ const QString stampName = name.mid( 6 );
+ QSvgRenderer * r = 0;
+ if ( ( r = s_data->svgStamps() ) && r->elementExists( stampName ) )
{
- QPixmap pixmap( size.isValid() ? size : r.defaultSize() );
+ const QRectF stampElemRect = r->boundsOnElement( stampName );
+ const QRectF stampRect( size.isValid() ? QRectF( QPointF( 0, 0 ), size ) \
: stampElemRect ); + QPixmap pixmap( stampRect.size().toSize() );
pixmap.fill( Qt::transparent );
QPainter p( &pixmap );
- r.render( &p );
+ r->render( &p, stampName );
p.end();
return pixmap;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic