Example #1
0
    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);
        }
Example #2
0
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();
}
Example #3
0
QString MainWindow::introductionString()
{
  KIconLoader *iconloader = KGlobal::iconLoader();
  int iconSize = iconloader->currentSize( KIcon::Desktop );

  QString handbook_icon_path = iconloader->iconPath( "contents2",  KIcon::Desktop );
  QString html_icon_path = iconloader->iconPath( "html",  KIcon::Desktop );
  QString wizard_icon_path = iconloader->iconPath( "wizard",  KIcon::Desktop );

  QString info = i18n( "<h2 style='text-align:center; margin-top: 0px;'>Welcome to Kontact %1</h2>"
      "<p>%1</p>"
      "<table align=\"center\">"
      "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
      "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
      "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
      "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
      "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
      "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
      "</table>"
      "<p style=\"margin-bottom: 0px\"> <a href=\"%1\">Skip this introduction</a></p>" )
      .arg( kapp->aboutData()->version() )
      .arg( i18n( "Kontact handles your e-mail, addressbook, calendar, to-do list and more." ) )
      .arg( "help:/kontact" )
      .arg( iconSize )
      .arg( iconSize )
      .arg( handbook_icon_path )
      .arg( "help:/kontact" )
      .arg( i18n( "Read Manual" ) )
      .arg( i18n( "Learn more about Kontact and its components" ) )
      .arg( "http://kontact.org" )
      .arg( iconSize )
      .arg( iconSize )
      .arg( html_icon_path )
      .arg( "http://kontact.org" )
      .arg( i18n( "Visit Kontact Website" ) )
      .arg( i18n( "Access online resources and tutorials" ) )
      .arg( "exec:/gwwizard" )
      .arg( iconSize )
      .arg( iconSize )
      .arg( wizard_icon_path )
      .arg( "exec:/gwwizard" )
      .arg( i18n( "Configure Kontact as Groupware Client" ) )
      .arg( i18n( "Prepare Kontact for use in corporate networks" ) )
      .arg( "exec:/switch" );
  return info;
}
Example #4
0
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;
}
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 );
}
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 );

}
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 ) << "'>"
            << " &nbsp;" << 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& )) );
    }
}
Example #8
0
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));
}
Example #9
0
void EntryView::buildContents()
{
    // write the html header and contents manipulation scripts
    QString t;

    t += "<html><body>";

    //t += setTheAaronnesqueStyle();
    // precalc the status icon
    Entry::Status status = m_entry->status();
    QString statusIcon;
    KIconLoader *loader = KIconLoader::global();

    switch (status) {
    case Entry::Invalid:
        statusIcon = "<img src='" + loader->iconPath("dialog-error", -KIconLoader::SizeSmall) + "' />";
        break;
    case Entry::Downloadable:
        // find a good icon to represent downloadable data
        //statusIcon = "<img src='" + loader->iconPath("network-server", -KIconLoader::SizeSmall) + "' />";
        break;
    case Entry::Installed:
        statusIcon = "<img src='" + loader->iconPath("dialog-ok", -KIconLoader::SizeSmall) + "' />";
        break;
    case Entry::Updateable:
        statusIcon = "<img src='" + loader->iconPath("software-update-available", -KIconLoader::SizeSmall) + "' />";
        break;
    case Entry::Deleted:
        statusIcon = "<img src='" + loader->iconPath("user-trash", -KIconLoader::SizeSmall) + "' />";
        break;
    }

    // precalc the title string
    QString titleString = m_entry->name().representation();
    if (!m_entry->version().isEmpty()) titleString += " v." + Qt::escape(m_entry->version());

    // precalc the string for displaying stars (normal+grayed)
    QString starIconPath = KStandardDirs::locate("data", "knewstuff/pics/ghns_star.png");
    QString starBgIconPath = KStandardDirs::locate("data", "knewstuff/pics/ghns_star_gray.png");

    int starPixels = 11 + 11 * (m_entry->rating() / 10);
    QString starsString = "<div style='width: " + QString::number(starPixels) + "px; background-image: url(" + starIconPath + "); background-repeat: repeat-x;'>&nbsp;</div>";
    int grayPixels = 22 + 22 * (m_entry->rating() / 20);
    starsString = "<div style='width: " + QString::number(grayPixels) + "px;background-image: url(" + starBgIconPath + "); background-repeat: repeat-x;'>" + starsString + "&nbsp;</div>";

    // precalc the string for displaying author (parsing email)
    KNS::Author author = m_entry->author();
    QString authorString = author.name();

    QString emailString = author.email();
    if (!emailString.isEmpty()) {
        authorString = "<a href='mailto:" + Qt::escape(emailString) + "'>"
                       + Qt::escape(authorString) + "</a>";
    }

    // write the HTML code for the current item
    t += //QLatin1String("<table class='contentsHeader' cellspacing='2' cellpadding='0'>")
        statusIcon + Qt::escape(titleString) + "<br />"
        //+   "<span align='right'>" + starsString +  "</span><br />"
        +      Qt::escape(m_entry->summary().representation())
        +   "<br />";

    if (m_entry->rating() > 0) {
        t += i18n("Rating: ") + QString::number(m_entry->rating())
             +   "<br />";
    }

    if (m_entry->downloads() > 0) {
        t += i18n("Downloads: ") + QString::number(m_entry->downloads())
             +   "<br />";
    }

    if (!authorString.isEmpty()) {
        t += "<em>" + authorString + "</em>, ";
    }
    t += KGlobal::locale()->formatDate(m_entry->releaseDate(), KLocale::ShortDate)
         + "<br />" + "</body></html>";

    setText(t);
}