本文整理汇总了C++中KIconLoader::iconPath方法的典型用法代码示例。如果您正苦于以下问题:C++ KIconLoader::iconPath方法的具体用法?C++ KIconLoader::iconPath怎么用?C++ KIconLoader::iconPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KIconLoader
的用法示例。
在下文中一共展示了KIconLoader::iconPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testUnknownIconNotCached
void testUnknownIconNotCached()
{
// This is a test to ensure that "unknown" icons do not pin themselves
// in the icon loader. Or in other words, if an "unknown" icon is
// returned, but the appropriate icon is subsequently installed
// properly, the next request for that icon should return the new icon
// instead of the unknown icon.
// Since we'll need to create an icon we'll need a temporary directory,
// and we want that established before creating the icon loader.
QString tempRoot = QDir::tempPath() + QLatin1String("/kiconloader_unittest");
QString temporaryDir = tempRoot + QLatin1String("/hicolor/22x22/actions");
QVERIFY(QDir::root().mkpath(temporaryDir));
QVERIFY(KGlobal::dirs()->addResourceDir("icon", tempRoot, false));
KIconLoader iconLoader;
// First find an existing icon. The only ones installed for sure by
// kdelibs are the kimproxy ones.
QString loadedIconPath = iconLoader.iconPath(
QLatin1String("presence_online"),
KIconLoader::DefaultState,
false /* Ensure "unknown" icon can't be returned */
);
QVERIFY(!loadedIconPath.isEmpty());
QString nonExistingIconName = QLatin1String("fhqwhgads_homsar");
// Find a non-existent icon, allowing unknown icon to be returned
QPixmap nonExistingIcon = iconLoader.loadIcon(
nonExistingIconName, KIconLoader::Toolbar);
QCOMPARE(nonExistingIcon.isNull(), false);
// Install the existing icon by copying.
QFileInfo existingIconInfo(loadedIconPath);
QString newIconPath = temporaryDir + QLatin1String("/")
+ nonExistingIconName + QLatin1String(".png");
QVERIFY(QFile::copy(loadedIconPath, newIconPath));
// Verify the icon can now be found.
QPixmap nowExistingIcon = iconLoader.loadIcon(
nonExistingIconName, KIconLoader::Toolbar);
QVERIFY(nowExistingIcon.cacheKey() != nonExistingIcon.cacheKey());
QCOMPARE(iconLoader.iconPath(nonExistingIconName, KIconLoader::Toolbar),
newIconPath);
// Cleanup
QFile::remove(newIconPath);
QStringList entries(QDir(tempRoot).entryList(
QDir::Dirs | QDir::NoDotAndDotDot,
QDir::Name | QDir::Reversed));
Q_FOREACH(const QString &dirName, entries) {
QDir::root().rmdir(dirName);
}
示例2: reloadImages
void starter::reloadImages()
{
KIconLoader* iLoader = KGlobal::iconLoader();
QString pth;
if (_VALID_(BaseURL))
pth = configDialog->BaseURL->url();
else
pth = iLoader->iconPath("bStarter", KIcon::Small, true);
if (pth)
pixmap = QImage(pth);
if (!pth || pixmap.isNull())
{
pixmap = QPixmap(22,22);
pixmap.fill(Qt::black);
}
pth = QString();
if (_VALID_(HoverURL))
pth = configDialog->HoverURL->url();
else
pth = iLoader->iconPath("bStarter_hover", KIcon::Small, true);
if (pth)
hoverPixmap = QImage(pth);
if (!pth || hoverPixmap.isNull())
{
hoverPixmap = QPixmap(22,22);
hoverPixmap.fill(Qt::black);
}
pth = QString();
if (_VALID_(DownURL))
pth = configDialog->DownURL->url();
else
pth = iLoader->iconPath("bStarter_down", KIcon::Small, true);
if (pth)
downPixmap = QImage(pth);
if (!pth || downPixmap.isNull())
{
downPixmap = QPixmap(22,22);
downPixmap.fill(Qt::white);
}
int wd = pixmap.width();
int ht = pixmap.height();
if (wd < hoverPixmap.width()) wd = hoverPixmap.width();
if (wd < downPixmap.width()) wd = downPixmap.width();
if (ht < hoverPixmap.height()) ht = hoverPixmap.height();
if (ht < downPixmap.height()) ht = downPixmap.height();
mainView->setFixedSize(wd,ht);
repaint();
}
示例3: KIcon
KTechLab::ComponentMetaData KTechLab::IComponent::metaData ( const QString& name, const KConfig& metaData )
{
KConfigGroup item = metaData.group(name);
KIconLoader *iconLoader = KIconLoader::global();
iconLoader->addAppDir( "ktechlab" );
ComponentMetaData data = {
item.readEntry("name").toUtf8(),
item.readEntry("title"),
item.readEntry("category"),
KIcon( iconLoader->iconPath( item.readEntry("icon"), KIconLoader::User ) ),
item.readEntry("type").toUtf8()
};
return data;
}
示例4: ServiceBase
OpmlDirectoryService::OpmlDirectoryService( OpmlDirectoryServiceFactory* parent, const QString &name, const QString &prettyName )
: ServiceBase( name, parent, false, prettyName )
{
setShortDescription( i18n( "A large listing of podcasts" ) );
setIcon( KIcon( "view-services-opml-amarok" ) );
setLongDescription( i18n( "A comprehensive list of searchable podcasts that you can subscribe to directly from within Amarok." ) );
KIconLoader loader;
setImagePath( loader.iconPath( "view-services-opml-amarok", -128, true ) );
The::amarokUrlHandler()->registerRunner( this, command() );
setServiceReady( true );
}
示例5: _img
void
KbfxPlasmaCanvasItem::setIconPath ( QString str )
{
KIconLoader *iconload = KGlobal::iconLoader ();
m_iconPath = iconload->iconPath ( str, KIcon::Desktop, false );
// m_icon.load(m_iconPath);
QImage _img ( m_iconPath );
if ( _img.height() > 128 )
{
_img = _img.smoothScale ( 32,32 );
}
m_icon.convertFromImage ( _img );
}
示例6: QVBox
void
SummaryWidget::createDiskMaps()
{
DiskList disks;
const QCString free = i18n( "Free" ).local8Bit();
const QCString used = i18n( "Used" ).local8Bit();
KIconLoader loader;
oldScheme = Config::scheme;
Config::scheme = (Filelight::MapScheme)2000;
for (DiskList::ConstIterator it = disks.begin(), end = disks.end(); it != end; ++it)
{
Disk const &disk = *it;
if (disk.free == 0 && disk.used == 0)
continue;
QWidget *box = new QVBox( this );
RadialMap::Widget *map = new MyRadialMap( box );
QString text; QTextOStream( &text )
<< "<img src='" << loader.iconPath( disk.icon, KIcon::Toolbar ) << "'>"
<< " " << disk.mount << " "
<< "<i>(" << disk.device << ")</i>";
QLabel *label = new QLabel( text, box );
label->setAlignment( Qt::AlignCenter );
label->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum );
box->show(); // will show its children too
Directory *tree = new Directory( disk.mount.local8Bit() );
tree->append( free, disk.free );
tree->append( used, disk.used );
map->create( tree ); //must be done when visible
connect( map, SIGNAL(activated( const KURL& )), SIGNAL(activated( const KURL& )) );
}
}
示例7: QPixmap
ImageCache::ImageCache()
{
KIconLoader *l = KGlobal::iconLoader();
/* 2002-01-24 FP */
// _archive = new QPixmap(l->iconPath("package", KIcon::Toolbar));
_archive = new QPixmap(l->iconPath("tar", KIcon::Small));
/* 2002-01-24 FP */
_backup = new QPixmap(l->iconPath("kdat_backup", KIcon::Toolbar));
_file = new QPixmap(l->iconPath("mime_empty", KIcon::Small));
_folderClosed = new QPixmap(l->iconPath("folder_blue", KIcon::Small));
_folderOpen = new QPixmap(l->iconPath("folder_blue_open", KIcon::Small));
_restore = new QPixmap(l->iconPath("kdat_restore", KIcon::Toolbar));
_selectAll = new QPixmap(l->iconPath("kdat_select_all", KIcon::Toolbar));
_selectNone = new QPixmap(l->iconPath("kdat_select_none", KIcon::Toolbar));
_selectSome = new QPixmap(l->iconPath("kdat_select_some", KIcon::Toolbar));
// 2002-01-28 FP
// _tape = new QPixmap(l->iconPath("kdat_archive", KIcon::Toolbar));
_tape = new QPixmap(l->iconPath("kdat", KIcon::Small));
// 2002-01-28 FP
_tapeMounted = new QPixmap(l->iconPath("kdat_mounted", KIcon::Toolbar));
_tapeUnmounted = new QPixmap(l->iconPath("kdat_unmounted", KIcon::Toolbar));
_verify = new QPixmap(l->iconPath("kdat_verify", KIcon::Toolbar));
}