mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
Globally store an icon loader different that the global one (eg the KPart one);
this way we can load our custom icons when embedded in other shells than ours. svn path=/trunk/KDE/kdegraphics/okular/; revision=752473
This commit is contained in:
parent
cad5fe4806
commit
44aa2d7088
3
part.cpp
3
part.cpp
|
@ -75,6 +75,7 @@
|
|||
#include "ui/findbar.h"
|
||||
#include "ui/sidebar.h"
|
||||
#include "ui/fileprinterpreview.h"
|
||||
#include "ui/guiutils.h"
|
||||
#include "conf/preferencesdialog.h"
|
||||
#include "settings.h"
|
||||
#include "core/bookmarkmanager.h"
|
||||
|
@ -150,6 +151,8 @@ m_cliPresentation(false), m_generatorGuiClient(0)
|
|||
// we need an instance
|
||||
setComponentData(okularPartFactory::componentData());
|
||||
|
||||
GuiUtils::setIconLoader( iconLoader() );
|
||||
|
||||
m_sidebar = new Sidebar( parentWidget );
|
||||
setWidget( m_sidebar );
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <klocale.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "guiutils.h"
|
||||
|
||||
PixmapPreviewSelector::PixmapPreviewSelector( QWidget * parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
|
@ -102,9 +104,9 @@ void PixmapPreviewSelector::iconComboChanged( const QString& icon )
|
|||
}
|
||||
|
||||
QString path;
|
||||
QPixmap pixmap = KIconLoader::global()->loadIcon( m_icon.toLower(), KIconLoader::User, m_previewSize, KIconLoader::DefaultState, QStringList(), &path, true );
|
||||
QPixmap pixmap = GuiUtils::iconLoader()->loadIcon( m_icon.toLower(), KIconLoader::User, m_previewSize, KIconLoader::DefaultState, QStringList(), &path, true );
|
||||
if ( path.isEmpty() )
|
||||
pixmap = KIconLoader::global()->loadIcon( m_icon.toLower(), KIconLoader::NoGroup, m_previewSize );
|
||||
pixmap = GuiUtils::iconLoader()->loadIcon( m_icon.toLower(), KIconLoader::NoGroup, m_previewSize );
|
||||
m_iconLabel->setPixmap( pixmap );
|
||||
|
||||
emit iconChanged( m_icon );
|
||||
|
|
|
@ -10,11 +10,25 @@
|
|||
#include "guiutils.h"
|
||||
|
||||
// qt/kde includes
|
||||
#include <kglobal.h>
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
|
||||
// local includes
|
||||
#include "core/annotations.h"
|
||||
|
||||
struct GuiUtilsHelper
|
||||
{
|
||||
GuiUtilsHelper()
|
||||
: il( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
KIconLoader * il;
|
||||
};
|
||||
|
||||
K_GLOBAL_STATIC( GuiUtilsHelper, s_data )
|
||||
|
||||
namespace GuiUtils {
|
||||
|
||||
QString captionForAnnotation( const Okular::Annotation * ann )
|
||||
|
@ -124,4 +138,14 @@ bool canBeMoved( const Okular::Annotation * ann )
|
|||
return false;
|
||||
}
|
||||
|
||||
void setIconLoader( KIconLoader * loader )
|
||||
{
|
||||
s_data->il = loader;
|
||||
}
|
||||
|
||||
KIconLoader* iconLoader()
|
||||
{
|
||||
return s_data->il ? s_data->il : KIconLoader::global();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <QtCore/QString>
|
||||
|
||||
class KIconLoader;
|
||||
|
||||
namespace Okular {
|
||||
class Annotation;
|
||||
}
|
||||
|
@ -30,6 +32,9 @@ namespace GuiUtils
|
|||
QString prettyToolTip( const Okular::Annotation * annotation );
|
||||
|
||||
bool canBeMoved( const Okular::Annotation * annotation );
|
||||
|
||||
void setIconLoader( KIconLoader * loader );
|
||||
KIconLoader* iconLoader();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "core/page.h"
|
||||
#include "core/annotations.h"
|
||||
#include "core/utils.h"
|
||||
#include "guiutils.h"
|
||||
#include "settings.h"
|
||||
|
||||
K_GLOBAL_STATIC_WITH_ARGS( QPixmap, busyPixmap, ( KIconLoader::global()->loadIcon("graphics-viewer-document", KIconLoader::NoGroup, 32, KIconLoader::DefaultState, QStringList(), 0, true) ) )
|
||||
|
@ -529,9 +530,9 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const Okular::Page
|
|||
{
|
||||
// get pixmap, colorize and alpha-blend it
|
||||
QString path;
|
||||
QPixmap pixmap = KIconLoader::global()->loadIcon( text->textIcon().toLower(), KIconLoader::User, 32, KIconLoader::DefaultState, QStringList(), &path, true );
|
||||
QPixmap pixmap = GuiUtils::iconLoader()->loadIcon( text->textIcon().toLower(), KIconLoader::User, 32, KIconLoader::DefaultState, QStringList(), &path, true );
|
||||
if ( path.isEmpty() )
|
||||
pixmap = KIconLoader::global()->loadIcon( text->textIcon().toLower(), KIconLoader::NoGroup, 32 );
|
||||
pixmap = GuiUtils::iconLoader()->loadIcon( text->textIcon().toLower(), KIconLoader::NoGroup, 32 );
|
||||
QImage scaledImage;
|
||||
QRect annotBoundary2 = QRect( annotBoundary.topLeft(), QSize( TEXTANNOTATION_ICONSIZE, TEXTANNOTATION_ICONSIZE ) );
|
||||
QRect annotRect2 = annotBoundary2.intersect( limits );
|
||||
|
@ -559,9 +560,9 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const Okular::Page
|
|||
|
||||
// get pixmap and alpha blend it if needed
|
||||
QString path;
|
||||
QPixmap pixmap = KIconLoader::global()->loadIcon( stamp->stampIconName().toLower(), KIconLoader::User, qMin( annotBoundary.width(), annotBoundary.height() ), KIconLoader::DefaultState, QStringList(), &path, true );
|
||||
QPixmap pixmap = GuiUtils::iconLoader()->loadIcon( stamp->stampIconName().toLower(), KIconLoader::User, qMin( annotBoundary.width(), annotBoundary.height() ), KIconLoader::DefaultState, QStringList(), &path, true );
|
||||
if ( path.isEmpty() )
|
||||
pixmap = KIconLoader::global()->loadIcon( stamp->stampIconName().toLower(), KIconLoader::NoGroup, qMin( annotBoundary.width(), annotBoundary.height() ) );
|
||||
pixmap = GuiUtils::iconLoader()->loadIcon( stamp->stampIconName().toLower(), KIconLoader::NoGroup, qMin( annotBoundary.width(), annotBoundary.height() ) );
|
||||
QImage scaledImage;
|
||||
scalePixmapOnImage( scaledImage, &pixmap, annotBoundary.width(),
|
||||
annotBoundary.height(), innerRect, QImage::Format_ARGB32 );
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
// local includes
|
||||
#include "formwidgets.h"
|
||||
#include "guiutils.h"
|
||||
#include "core/page.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
@ -348,7 +349,7 @@ ToolBarButton::ToolBarButton( QWidget * parent, const AnnotationToolItem &item )
|
|||
setAutoRaise( true );
|
||||
resize( buttonSize, buttonSize );
|
||||
setIconSize( QSize( iconSize, iconSize ) );
|
||||
setIcon( KIcon( item.pixmap ) );
|
||||
setIcon( KIcon( item.pixmap, GuiUtils::iconLoader() ) );
|
||||
// set shortcut if defined
|
||||
if ( !item.shortcut.isEmpty() )
|
||||
setShortcut( QKeySequence( item.shortcut ) );
|
||||
|
|
Loading…
Reference in a new issue