Exemplo n.º 1
0
KisPaintOpPreset* KisPaintOpPreset::clone() const
{
    KisPaintOpPreset * preset = new KisPaintOpPreset();
    if (settings()) {
        preset->setSettings(settings()->clone());
    }
    // only valid if we could clone the settings
    preset->setValid(settings());

    preset->setPaintOp(paintOp());
    preset->setName(name());

    return preset;
}
Exemplo n.º 2
0
    virtual QList< KoResource* > resources() {

        QList<KoResource*> serverResources =
            KisPaintOpPresetResourceServerAdapter::resources();

        if (m_paintopID.isEmpty()) {
            return serverResources;
        }

        QList<KoResource*> resources;
        Q_FOREACH (KoResource *resource, serverResources) {
            KisPaintOpPreset *preset = dynamic_cast<KisPaintOpPreset*>(resource);

            if (preset && preset->paintOp().id() == m_paintopID) {
                resources.append(preset);
            }
        }
Exemplo n.º 3
0
void KisPaletteManager::slotAddBrush()
{

    KisPaintOpPreset* newPreset = static_cast<KisPaintOpPreset*>(m_allPresetsView->currentResource());
    int pos = m_resourceManager->addFavoritePreset(newPreset->name());

    QModelIndex index;

    if (pos == -2)
    {
        return; //favorite brush list is full!
    }
    else if (pos == -1) //favorite brush is successfully saved
    {
        updatePaletteView();
    }
}
Exemplo n.º 4
0
void KisPresetDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
    painter->save();
    painter->setRenderHint(QPainter::SmoothPixmapTransform, true);

    if (! index.isValid())
        return;

    KisPaintOpPreset* preset = static_cast<KisPaintOpPreset*>(index.internalPointer());

    QImage preview = preset->image();

    if(preview.isNull()) {
        return;
    }

    QRect paintRect = option.rect.adjusted(1, 1, -1, -1);
    if (!m_showText) {
        painter->drawImage(paintRect.x(), paintRect.y(),
                           preview.scaled(paintRect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    } else {
        QSize pixSize(paintRect.height(), paintRect.height());
        painter->drawImage(paintRect.x(), paintRect.y(),
                           preview.scaled(pixSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));

        painter->drawText(pixSize.width() + 10, option.rect.y() + option.rect.height() - 10, preset->name());
    }
    if (m_useDirtyPresets && preset->isPresetDirty()) {
        const QIcon icon = KisIconUtils::loadIcon(koIconName("dirty-preset"));
        QPixmap pixmap = icon.pixmap(QSize(15,15));
        painter->drawPixmap(paintRect.x() + 3, paintRect.y() + 3, pixmap);
    }

    if (!preset->settings() || !preset->settings()->isValid()) {
        const QIcon icon = KisIconUtils::loadIcon("broken-preset");
        icon.paint(painter, QRect(paintRect.x() + paintRect.height() - 25, paintRect.y() + paintRect.height() - 25, 25, 25));
    }
    if (option.state & QStyle::State_Selected) {
        painter->setCompositionMode(QPainter::CompositionMode_HardLight);
        painter->setOpacity(0.65);
        painter->fillRect(option.rect, option.palette.highlight());
    }
    painter->restore();
}