Exemplo n.º 1
0
void StyleSheetEditorDialog::slotAddGradient(const QString &property)
{
    bool ok;
    const QGradient grad = QtGradientViewDialog::getGradient(&ok, m_core->gradientManager(), this);
    if (ok)
        insertCssProperty(property, QtGradientUtils::styleSheetCode(grad));
}
Exemplo n.º 2
0
void StyleSheetEditorDialog::slotAddFont()
{
    bool ok;
    QFont font = QFontDialog::getFont(&ok, this);
    if (ok) {
        QString fontStr;
        if (font.weight() != QFont::Normal) {
            fontStr += QString::number(font.weight());
            fontStr += QLatin1Char(' ');
        }

        switch (font.style()) {
        case QFont::StyleItalic:
            fontStr += QLatin1String("italic ");
            break;
        case QFont::StyleOblique:
            fontStr += QLatin1String("oblique ");
            break;
        default:
            break;
        }
        fontStr += QString::number(font.pointSize());
        fontStr += QLatin1String("pt \"");
        fontStr += font.family();
        fontStr += QLatin1Char('"');

        insertCssProperty(QLatin1String("font"), fontStr);
        QString decoration;
        if (font.underline())
            decoration += QLatin1String("underline");
        if (font.strikeOut()) {
            if (!decoration.isEmpty())
                decoration += QLatin1Char(' ');
            decoration += QLatin1String("line-through");
        }
        insertCssProperty(QLatin1String("text-decoration"), decoration);
    }
}
Exemplo n.º 3
0
void StyleSheetEditorDialog::slotAddColor(const QString &property)
{
    const QColor color = QColorDialog::getColor(0xffffffff, this, QString(), QColorDialog::ShowAlphaChannel);
    if (!color.isValid())
        return;

    QString colorStr;

    if (color.alpha() == 255) {
        colorStr = QString(QLatin1String("rgb(%1, %2, %3)")).arg(
                color.red()).arg(color.green()).arg(color.blue());
    } else {
        colorStr = QString(QLatin1String("rgba(%1, %2, %3, %4)")).arg(
                color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha());
    }

    insertCssProperty(property, colorStr);
}
Exemplo n.º 4
0
void StyleSheetEditorDialog::slotAddColor(const QString &property)
{
    bool ok;
    QRgb rgba = QColorDialog::getRgba(0xffffffff, &ok, this);
    if (!ok)
        return;

    QColor color;
    color.setRgba(rgba);
    QString colorStr;

    if (color.alpha() == 255) {
        colorStr = QString("rgb(%1, %2, %3)").arg(
                color.red()).arg(color.green()).arg(color.blue());
    } else {
        colorStr = QString("rgba(%1, %2, %3, %4)").arg(
                color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha());
    }

    insertCssProperty(property, colorStr);
}
Exemplo n.º 5
0
void StyleSheetEditorDialog::slotAddResource(const QString &property)
{
    const QString path = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), QString(), this);
    if (!path.isEmpty())
        insertCssProperty(property, QString(QLatin1String("url(%1)")).arg(path));
}