OSDN Git Service

okular: remove redundant icon loader glue
authorIvailo Monev <xakepa10@gmail.com>
Tue, 20 Jun 2023 15:49:23 +0000 (18:49 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 20 Jun 2023 15:49:23 +0000 (18:49 +0300)
there is always only one icon loader and it is KIconLoader::global()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
okular/part.cpp
okular/ui/guiutils.cpp
okular/ui/guiutils.h
okular/ui/pagepainter.cpp

index 23971e4..657a29f 100644 (file)
@@ -316,8 +316,6 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW
     // we need an instance
     setComponentData( componentData );
 
-    GuiUtils::addIconLoader( iconLoader() );
-
     m_sidebar = new Sidebar( parentWidget );
     setWidget( m_sidebar );
     connect( m_sidebar, SIGNAL(urlsDropped(KUrl::List)), SLOT(handleDroppedUrls(KUrl::List)) );
@@ -801,7 +799,6 @@ void Part::setupActions()
 
 Part::~Part()
 {
-    GuiUtils::removeIconLoader( iconLoader() );
     m_document->removeObserver( this );
     m_document->removeObserver( m_toc );
 
index aa96a5a..f9d3628 100644 (file)
@@ -23,8 +23,6 @@
 #include "core/annotations.h"
 #include "core/document.h"
 
-K_GLOBAL_STATIC( QList<KIconLoader *>, s_data )
-
 namespace GuiUtils {
 
 QString captionForAnnotation( const Okular::Annotation * ann )
@@ -134,7 +132,7 @@ QPixmap loadStamp( const QString& _name, const QSize& size, int iconSize )
         return QPixmap(stampFile).scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
     }
     QPixmap pixmap;
-    const KIconLoader * il = iconLoader();
+    const KIconLoader * il = KIconLoader::global();
     QString path;
     const int minSize = iconSize > 0 ? iconSize : qMin( size.width(), size.height() );
     pixmap = il->loadIcon( name, KIconLoader::User, minSize, KIconLoader::DefaultState, QStringList(), &path, true );
@@ -143,21 +141,6 @@ QPixmap loadStamp( const QString& _name, const QSize& size, int iconSize )
     return pixmap;
 }
 
-void addIconLoader( KIconLoader * loader )
-{
-    s_data->append( loader );
-}
-
-void removeIconLoader( KIconLoader * loader )
-{
-    s_data->removeAll( loader );
-}
-
-KIconLoader* iconLoader()
-{
-    return s_data->isEmpty() ? KIconLoader::global() : s_data->back();
-}
-
 void saveEmbeddedFile( Okular::EmbeddedFile *ef, QWidget *parent )
 {
     const QString caption = i18n( "Where do you want to save %1?", ef->name() );
index 6c29e0d..946430e 100644 (file)
@@ -40,10 +40,6 @@ namespace GuiUtils
 
     QPixmap loadStamp( const QString& name, const QSize& size, int iconSize = 0 );
 
-    void addIconLoader( KIconLoader * loader );
-    void removeIconLoader( KIconLoader * loader );
-    KIconLoader* iconLoader();
-
     void saveEmbeddedFile( Okular::EmbeddedFile *ef, QWidget *parent );
 
     // colorize a gray image to the given color
index dadc402..2493f14 100644 (file)
@@ -646,9 +646,9 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
                 {
                 // get pixmap, colorize and alpha-blend it
                     QString path;
-                    QPixmap pixmap = GuiUtils::iconLoader()->loadIcon( text->textIcon().toLower(), KIconLoader::User, 32, KIconLoader::DefaultState, QStringList(), &path, true );
+                    QPixmap pixmap = KIconLoader::global()->loadIcon( text->textIcon().toLower(), KIconLoader::User, 32, KIconLoader::DefaultState, QStringList(), &path, true );
                     if ( path.isEmpty() )
-                        pixmap = GuiUtils::iconLoader()->loadIcon( text->textIcon().toLower(), KIconLoader::NoGroup, 32 );
+                        pixmap = KIconLoader::global()->loadIcon( text->textIcon().toLower(), KIconLoader::NoGroup, 32 );
                     QImage scaledImage;
                     QRect annotBoundary2 = QRect( annotBoundary.topLeft(), QSize( TEXTANNOTATION_ICONSIZE, TEXTANNOTATION_ICONSIZE ) );
                     QRect annotRect2 = annotBoundary2.intersected( limits );