Esempio n. 1
0
QPixmap UtilityIconPainting::blendOverLayTopRight(const QString& mainIconStr, const QString& overlayIconStr) {

    QPixmap pixmap;
    QString keyStr = mainIconStr + overlayIconStr;

    if (UtilityIconPainting::getInstance()->textIconMap.contains(keyStr)) {

        pixmap = UtilityIconPainting::getInstance()->textIconMap.value(keyStr);

    }
    else {

        KIcon overlayIcon = KIcon(overlayIconStr);

        if (!overlayIcon.isNull()) {

            pixmap = KIconLoader::global()->loadIcon(mainIconStr, KIconLoader::Small, KIconLoader::SizeSmall);

            QPixmap overlayPixmap = KIconLoader::global()->loadIcon(overlayIconStr, KIconLoader::Small, KIconLoader::SizeSmall);
            overlayPixmap = overlayPixmap.scaled(10, 10, Qt::IgnoreAspectRatio, Qt::FastTransformation);

            QPainter p(&pixmap);
            p.drawPixmap(6, 0, overlayPixmap);
            p.end();

            UtilityIconPainting::getInstance()->textIconMap.insert(keyStr, pixmap);
        }

    }


    return pixmap;
}
Esempio n. 2
0
void ConfigForm::on_iconBtn_clicked()
{
    KIconDialog dlg;
    KIcon icon = KIcon(dlg.getIcon());
    if (!icon.name().isEmpty()) {
        this->ui->iconBtn->setIcon(icon);
        this->cfg->setSettings(Config::ICON, icon.name());
    }
}
Esempio n. 3
0
PeopleSideBarWidget::PeopleSideBarWidget(QWidget* parent, TagModel* model,
        SearchModificationHelper* searchModificationHelper)
    : SidebarWidget(parent), d(new PeopleSideBarWidgetPriv)
{
    setObjectName("People Sidebar");

    d->tagModel = model;
    d->searchModificationHelper = searchModificationHelper;

    QVBoxLayout* layout = new QVBoxLayout;
    QHBoxLayout* hlay = new QHBoxLayout;

    d->tagFolderView = new TagFolderView(this, model);
    d->tagFolderView->setConfigGroup(getConfigGroup());
    d->tagFolderView->setExpandNewCurrentItem(true);
    d->tagFolderView->setAlbumManagerCurrentAlbum(true);

    d->tagFolderView->filteredModel()->listOnlyTagsWithProperty("person");
    d->tagFolderView->filteredModel()->setFilterBehavior(AlbumFilterModel::StrictFiltering);

    d->tagSearchBar  = new SearchTextBar(this, "DigikamViewPeopleSearchBar");
    d->tagSearchBar->setHighlightOnResult(true);
    d->tagSearchBar->setModel(d->tagFolderView->filteredModel(),
                              AbstractAlbumModel::AlbumIdRole, AbstractAlbumModel::AlbumTitleRole);
    d->tagSearchBar->setFilterModel(d->tagFolderView->albumFilterModel());

    d->rescanButton = new QPushButton;
    d->rescanButton->setText("Scan collection for faces");

    QString s("user-identity");
    KIcon* icon       = new KIcon(s);
    QPixmap personPix = icon->pixmap(QSize(48, 48));
    d->personIcon = new QLabel;
    d->personIcon->setPixmap(personPix);

    d->textLabel = new QLabel("People Tags");

    hlay->addWidget(d->personIcon);
    hlay->addWidget(d->textLabel);

    layout->addLayout(hlay);
    layout->addWidget(d->rescanButton);
    layout->addWidget(d->tagFolderView);
    layout->addWidget(d->tagSearchBar);

    setLayout(layout);

    connect(d->tagFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
            this, SIGNAL(signalFindDuplicatesInAlbum(Album*)));

    connect(d->rescanButton, SIGNAL(pressed()),
            this, SIGNAL( signalDetectFaces() ) );
}
Esempio n. 4
0
IconLabel::IconLabel(const KIcon &icon, QWidget *parent)
        : QLabel(parent)
{
    QPixmap pixmapIcon = icon.pixmap(16);
    setFixedSize(16, 16);
    setPixmap(pixmapIcon);
}
void WindowPreview::updateTask(::TaskManager::TaskChanges changes) {
	bool doUpdate = false;
	QSize oldSize = size();

	if (changes & TaskManager::IconChanged) {
		const KIcon icon(m_task->icon());

		if (m_toolTip->previewsAvailable() && (m_task->type() == Task::StartupItem || m_task->type() == Task::LauncherItem)) {
			m_previewSize = icon.pixmap(BIG_ICON_SIZE).size();
		}
	
		switch (m_toolTip->applet()->previewLayout()) {
		case Applet::NewPreviewLayout:
			m_icon = icon.pixmap(BIG_ICON_SIZE);
			break;
		case Applet::ClassicPreviewLayout:
		default:
			m_icon = icon.pixmap(SMALL_ICON_SIZE);
		}
		
		doUpdate = true;
	}

	if (changes & TaskManager::NameChanged) {
		m_taskNameLabel->setText(m_task->text());
		doUpdate = true;
	}

	if (changes & TaskManager::GeometryChanged) {
		setPreviewSize();
		doUpdate = true;
	}

	if (changes & TaskManager::NameChanged) {
		m_taskNameLabel->setText(m_task->text());
		doUpdate = true;
	}
	
	if (doUpdate) {
		updateTheme();

		if (size() != oldSize) {
			emit sizeChanged();
		}
	}
}
Esempio n. 6
0
KIcon GlobalApplet::makeOverlayIcon( const KIcon& icon, const QList<KIcon> &overlayIconsBottom,
                                     const QSize& overlaySize, int iconExtend )
{
    Q_ASSERT( !icon.isNull() );

    QPixmap pixmap = icon.pixmap( iconExtend );
    if ( pixmap.isNull() ) {
        kDebug() << "pixmap is Null";
        return icon;
    }

    QPainter p( &pixmap );
    int x = 0, xStep = iconExtend / overlayIconsBottom.count();
    foreach( const KIcon &overlayIcon, overlayIconsBottom ) {
        p.drawPixmap( QPoint( x, iconExtend - overlaySize.height() ), overlayIcon.pixmap( overlaySize ) );
        x += xStep;
    }
Esempio n. 7
0
void KexiLinkButton::updateIcon(const KIcon &icon)
{
    if (!d->usesForegroundColor)
        return;
    QColor c(palette().color(foregroundRole()));
    QPixmap pixmap(icon.pixmap(iconSize()));
    KexiUtils::replaceColors(&pixmap, c);
    KPushButton::setIcon(KIcon(pixmap));
}
Esempio n. 8
0
void StarRating::setSize(int size) {
    int px = (size < Small) ? Small : size;
    QSize sz = QSize(px, px);
    KIcon icon = KIcon("rating");
    m_starNormal = icon.pixmap(sz);
    m_starSize = m_starNormal.size().width(); //maybe we didn't get the full size
    sz = QSize(m_starSize, m_starSize);
    m_starInactive = icon.pixmap(sz, QIcon::Disabled);

    m_starHover = QPixmap(sz);
    QColor transBlack = Qt::black;
    transBlack.setAlpha(100);
    m_starHover.fill(transBlack);
    QPainter p(&m_starHover);
    p.setCompositionMode(QPainter::CompositionMode_SourceIn);
    p.drawPixmap(QPoint(0,0), m_starNormal);
    p.end();
}
Esempio n. 9
0
QPixmap UtilityIconPainting::blendOverLayEmblem(const QString& overlayIconStr, const QPixmap* pixmap) {

    QPixmap finalIcon;

    KIcon overlayIcon = KIcon(overlayIconStr);

    if (!overlayIcon.isNull() && pixmap) {

        QPixmap warningPixmap = overlayIcon.pixmap(8, 8);

        finalIcon = pixmap->copy();
        QPainter p(&finalIcon);
        p.drawPixmap(KIconLoader::SizeSmall / 2, KIconLoader::SizeSmall  / 2, warningPixmap);
        p.end();

    }

    return finalIcon;

}
void DefaultFilterModel::addFilter(const QString &caption, const Filter &filter, const KIcon &icon)
{
    QList<QStandardItem *> newRow;
    QStandardItem *item = new QStandardItem(caption);
    item->setData(qVariantFromValue<Filter>(filter));
    if (!icon.isNull()) {
        item->setIcon(icon);
    }
    item->setData(filter.first, FilterTypeRole);
    item->setData(filter.second, FilterDataRole);

    newRow << item;
    appendRow(newRow);
}
Esempio n. 11
0
void EditDeleteDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
    int y = option.rect.y();

    //use normal painting, sizeHint has ensured that we have enough room for both text and icons.
    QStyledItemDelegate::paint( painter, option, index );

    int iconOffset = option.rect.width() - ( MARGIN * 3 + ICON_WIDTH * 2 );

    if ( option.state & QStyle::State_Selected )
    {
        //paint our custom stuff in the leftover space
        //but only if this is the item that the mouse is over...

        const KIcon editIcon( "configure" );
        const KIcon deleteIcon( "edit-delete" );

        QPixmap editPixmap = editIcon.pixmap( ICON_WIDTH, ICON_WIDTH );
        QPixmap deletePixmap = deleteIcon.pixmap( ICON_WIDTH, ICON_WIDTH );

        painter->drawPixmap( iconOffset + MARGIN, y, ICON_WIDTH, ICON_WIDTH, editPixmap );
        painter->drawPixmap( iconOffset + MARGIN *2 + ICON_WIDTH, y, ICON_WIDTH, ICON_WIDTH, deletePixmap );
    }
}
Esempio n. 12
0
KIcon GlobalApplet::makeOverlayIcon( const KIcon &icon, const KIcon &overlayIcon,
                                     const QSize &overlaySize, int iconExtend )
{
    QPixmap pixmap = icon.pixmap( iconExtend ), pixmapOverlay = overlayIcon.pixmap( overlaySize );
    QPainter p( &pixmap );
    p.drawPixmap( QPoint( iconExtend - overlaySize.width(), iconExtend - overlaySize.height() ), pixmapOverlay );
    p.end();
    KIcon resultIcon = KIcon();
    resultIcon.addPixmap( pixmap, QIcon::Normal );

    KIconEffect iconEffect;
    pixmap = iconEffect.apply( pixmap, KIconLoader::Small, KIconLoader::ActiveState );
    resultIcon.addPixmap( pixmap, QIcon::Selected );
    resultIcon.addPixmap( pixmap, QIcon::Active );

    return resultIcon;
}
Esempio n. 13
0
void TitleWidget::setIcon( MainIconDisplay iconType )
{
    Q_ASSERT( m_icon );

    KIcon icon;
    KIconEffect iconEffect;
    QPixmap pixmap;
    int iconExtend = m_icon->size().width();

    // Create an icon of the given type.
    switch ( iconType ) {
    case DepartureListErrorIcon: {
        // Create an icon to be shown on errors with a departure/arrival board
        QList<KIcon> overlays;
        if ( m_settings->departureArrivalListType() == DepartureList ) {
            // Use a public transport stop icon with a house and an arrow away from it
            // to indicate that a departure list is shown
            overlays << KIcon("go-home") << KIcon("go-next");
        } else {
            // Use a public transport stop icon with a house and an arrow towards it
            // to indicate that an arrival list is shown
            overlays << KIcon("go-next") << KIcon("go-home");
        }
        icon = GlobalApplet::makeOverlayIcon( KIcon("public-transport-stop"),
                overlays, QSize(iconExtend / 2, iconExtend / 2), iconExtend );
        pixmap = icon.pixmap( iconExtend );
        pixmap = iconEffect.apply( pixmap, KIconLoader::Small, KIconLoader::DisabledState );
        icon = KIcon();
        icon.addPixmap( pixmap, QIcon::Normal );
        break;
    }
    case DepartureListOkIcon: {
        // Create an icon to be shown for departure/arrival boards without errors.
        // This icon is the same as the departure error icon, but without the icon effect
        QList<KIcon> overlays;
        if ( m_settings->departureArrivalListType() == DepartureList ) {
            overlays << KIcon("go-home") << KIcon("go-next");
        } else {
            overlays << KIcon("go-next") << KIcon("go-home");
        }
        icon = GlobalApplet::makeOverlayIcon( KIcon("public-transport-stop"), overlays,
                QSize( iconExtend / 2, iconExtend / 2 ), iconExtend );
        break;
    }
    case JourneyListOkIcon:
        // Create an icon to be shown for journey lists without errors.
        // This icon is the same as the journey error icon, but without the icon effect
        icon = GlobalApplet::makeOverlayIcon( KIcon("public-transport-stop"),
                QList<KIcon>() << KIcon("go-home")
                    << KIcon("go-next-view") << KIcon("public-transport-stop"),
                QSize(iconExtend / 3, iconExtend / 3), iconExtend );
        break;

    case JourneyListErrorIcon:
        // Create an icon to be shown on errors with a journey list
        icon = GlobalApplet::makeOverlayIcon( KIcon("public-transport-stop"),
                QList<KIcon>() << KIcon("go-home")
                    << KIcon("go-next-view") << KIcon("public-transport-stop"),
                QSize(iconExtend / 3, iconExtend / 3), iconExtend );
        pixmap = icon.pixmap( iconExtend );
        pixmap = iconEffect.apply( pixmap, KIconLoader::Small, KIconLoader::DisabledState );
        icon = KIcon();
        icon.addPixmap( pixmap, QIcon::Normal );
        break;

    case AbortJourneySearchIcon:
        // Create an icon to be shown for the journey search
        icon = KIcon("edit-delete");
        break;

    case GoBackIcon:
        // Create an icon to be used for "go back" functionality
        icon = KIcon("arrow-left");
        break;
    }

    m_icon->setIcon( icon );
}
Esempio n. 14
0
void EventDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const
{
    QPixmap icon;
    QString text = idx.data(Qt::DisplayRole).toString();
    QDateTime time = idx.data(QZeitgeist::LogModel::TimeRole).toDateTime();

    QStyle *style = QApplication::style();

    style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);

    QRect baseRect = option.rect.adjusted(5, 5, -5, -5);

    QRect iconRect(baseRect);
    QRect descRect(baseRect);

    iconRect.setWidth(iconRect.width()/3);
    descRect.setX(iconRect.right());

    QIcon::Mode mode = QIcon::Normal;
    if (option.state == QStyle::State_Active)
        mode = QIcon::Active;
    if (option.state == QStyle::State_Selected)
        mode = QIcon::Selected;

    painter->save();
    painter->setOpacity(0.4);

    QString url(idx.data(QZeitgeist::LogModel::URLRole).toString());
    QPixmap overlay;
    if (!m_iconCache.contains(url)) {
      icon = idx.data(QZeitgeist::LogModel::ThumbnailRole).value<QPixmap>();
      if (icon.isNull()) {
          KIcon kicon = KIcon(QUrl(idx.data(QZeitgeist::LogModel::ActorRole).toString()).authority().section(".desktop", 0, 0));
          icon = kicon.pixmap(iconRect.size());
      } else {
          icon = icon.scaled(iconRect.size(), Qt::KeepAspectRatio);
          KIcon kicon = KIcon(QUrl(idx.data(QZeitgeist::LogModel::ActorRole).toString()).authority().section(".desktop", 0, 0));
          QPainter overlayPainter(&icon);
          QRect overlayRect(QPoint(0, 0), iconRect.size());
          int iconSize = qMin(overlayRect.width(), overlayRect.height());
          overlayRect.setX(iconSize/2);
          overlayRect.setY(iconSize/2);
          kicon.paint(&overlayPainter, overlayRect, Qt::AlignCenter, QIcon::Active);
      }
      m_iconCache[url] = icon;
    } else {
      icon = m_iconCache[url];
    }

    painter->drawPixmap(iconRect, icon);
    
    //icon.paint(painter, iconRect, Qt::AlignCenter, mode);

    painter->setOpacity(1);
    QFont font;
    font.setBold(true);
    font.setPixelSize(15);
    painter->setFont(font);

    painter->drawText(baseRect, Qt::AlignLeft | Qt::TextWordWrap, text);
    painter->restore();

    painter->drawText(baseRect, Qt::AlignRight | Qt::AlignBottom, time.toString(Qt::SystemLocaleShortDate));
}