void ParagraphBulletsNumbers::styleChanged(int index)
{
    KoListStyle::Style style = m_mapping[index];
    bool showLetterSynchronization = false;

    if (style == KoListStyle::ImageItem) {
        widget.startValue->setValue(1);
        widget.startValue->setEnabled(false);
        widget.levels->setValue(1);
        widget.levels->setEnabled(false);
        widget.insertImage->setEnabled(true);
        widget.imageHeight->setEnabled(true);
        widget.imageWidth->setEnabled(true);

        if (widget.imageHeight->value() == 0 && widget.imageWidth->value() == 0) {
            widget.imageHeight->setValue(m_fontSize);
            widget.imageWidth->setValue(m_fontSize);
        }
    } else if (!KoListStyle::isNumberingStyle(style)) {
        widget.startValue->setCounterType(KoListStyle::DecimalItem);
        widget.startValue->setValue(1);
        widget.startValue->setEnabled(false);
        widget.levels->setValue(1);
        widget.levels->setEnabled(false);
        widget.insertImage->setEnabled(false);
        widget.imageHeight->setEnabled(false);
        widget.imageWidth->setEnabled(false);
        widget.imageHeight->setValue(0);
        widget.imageWidth->setValue(0);
    } else {
        switch (style) {
        case KoListStyle::AlphaLowerItem:
        case KoListStyle::UpperAlphaItem:
            showLetterSynchronization = true;
            // fall through
        default:
            widget.levels->setEnabled(true);
            widget.startValue->setEnabled(true);
            widget.startValue->setCounterType(style);
            int value = widget.startValue->value();
            widget.startValue->setValue(value + 1);
            widget.startValue->setValue(value); // surely to trigger a change event.
            widget.insertImage->setEnabled(false);
            widget.imageHeight->setEnabled(false);
            widget.imageWidth->setEnabled(false);
        }
        widget.imageHeight->setValue(0);
        widget.imageWidth->setValue(0);
    }

    widget.customCharacter->setEnabled(style == KoListStyle::CustomCharItem && index != m_blankCharIndex);
    widget.letterSynchronization->setVisible(showLetterSynchronization);
    widget.listPropertiesPane->setEnabled(style != KoListStyle::None);
    recalcPreview();
}
Example #2
0
ParagraphBulletsNumbers::ParagraphBulletsNumbers(QWidget *parent)
        : QWidget(parent),
        m_alignmentMode(false),
        m_imageCollection(0),
        m_data(0),
        m_fontSize(0)
{
    widget.setupUi(this);

    widget.alignment->addItem(i18nc("Automatic horizontal alignment", "Auto"));
    widget.alignment->addItem(i18nc("Text alignment", "Left"));
    widget.alignment->addItem(i18nc("Text alignment", "Right"));
    widget.alignment->addItem(i18nc("Text alignment", "Centered"));

    widget.labelFollowedBy->addItem(i18nc("Tab follows the bullet or number", "Tab Stop"));
    widget.labelFollowedBy->addItem(i18nc("Space", "Space"));
    widget.labelFollowedBy->addItem(i18nc("None", "Nothing"));

    widget.doubleSpinBox->setSingleStep(0.05);
    widget.doubleSpinBox_2->setSingleStep(0.05);
    widget.doubleSpinBox_3->setSingleStep(0.05);

    connect(widget.labelFollowedBy,SIGNAL(currentIndexChanged(int)),this,SLOT(labelFollowedByIndexChanged(int)));
    connect(widget.listTypes, SIGNAL(currentRowChanged(int)), this, SLOT(styleChanged(int)));
    connect(widget.customCharacter, SIGNAL(clicked(bool)), this, SLOT(customCharButtonPressed()));
    connect(widget.letterSynchronization, SIGNAL(toggled(bool)), widget.startValue, SLOT(setLetterSynchronization(bool)));
    connect(widget.prefix, SIGNAL(textChanged(QString)), this, SLOT(recalcPreview()));
    connect(widget.suffix, SIGNAL(textChanged(QString)), this, SLOT(recalcPreview()));
    connect(widget.depth, SIGNAL(valueChanged(int)), this, SLOT(recalcPreview()));
    connect(widget.levels, SIGNAL(valueChanged(int)), this, SLOT(recalcPreview()));
    connect(widget.startValue, SIGNAL(valueChanged(int)), this, SLOT(recalcPreview()));
    connect(widget.insertImage, SIGNAL(clicked()), this, SLOT(selectListImage()));
    connect(widget.imageHeight, SIGNAL(valueChanged(double)), this, SLOT(recalcPreview()));
    connect(widget.imageWidth, SIGNAL(valueChanged(double)), this, SLOT(recalcPreview()));
    connect(widget.restartNumbering, SIGNAL(clicked()), this, SLOT(recalcPreview()));
}
Example #3
0
void ParagraphBulletsNumbers::styleChanged(int index)
{
    KoListStyle::LabelType labelType = m_mapping[index];
    bool showLetterSynchronization = false;

    if (labelType == KoListStyle::ImageLabelType) {
        widget.startValue->setValue(1);
        widget.startValue->setEnabled(false);
        widget.levels->setValue(1);
        widget.levels->setEnabled(false);
        widget.insertImage->setEnabled(true);
        widget.imageHeight->setEnabled(true);
        widget.imageWidth->setEnabled(true);

        if (widget.imageHeight->value() == 0 && widget.imageWidth->value() == 0) {
            widget.imageHeight->setValue(m_fontSize);
            widget.imageWidth->setValue(m_fontSize);
        }
    } else if (!KoListStyle::isNumberingStyle(labelType)) {
        //widget.startValue->setNumberFormat();
        widget.startValue->setValue(1);
        widget.startValue->setEnabled(false);
        widget.levels->setValue(1);
        widget.levels->setEnabled(false);
        widget.insertImage->setEnabled(false);
        widget.imageHeight->setEnabled(false);
        widget.imageWidth->setEnabled(false);
        widget.imageHeight->setValue(0);
        widget.imageWidth->setValue(0);
    } else {
        widget.levels->setEnabled(true);
        widget.startValue->setEnabled(true);
        //widget.startValue->setNumberFormat();
        int value = widget.startValue->value();
        widget.startValue->setValue(value + 1);
        widget.startValue->setValue(value); // surely to trigger a change event.
        widget.insertImage->setEnabled(false);
        widget.imageHeight->setEnabled(false);
        widget.imageWidth->setEnabled(false);
        widget.imageHeight->setValue(0);
        widget.imageWidth->setValue(0);
    }

    widget.customCharacter->setEnabled(labelType == KoListStyle::BulletCharLabelType && index != m_blankCharIndex);
    widget.letterSynchronization->setVisible(showLetterSynchronization);
    widget.listPropertiesPane->setEnabled(labelType != KoListStyle::None);
    recalcPreview();
}
void ParagraphBulletsNumbers::setDisplay(KoParagraphStyle *style, int level)
{
    KoListStyle *listStyle = style->listStyle();
    widget.listPropertiesPane->setEnabled(listStyle != 0);
    widget.customCharacter->setText("-");
    if (listStyle == 0) {
        widget.listTypes->setCurrentRow(0);
        return;
    }

    KoListLevelProperties llp = listStyle->levelProperties(level);
    m_previousLevel = llp.level();
    widget.prefix->setText(llp.listItemPrefix());
    widget.suffix->setText(llp.listItemSuffix());
    widget.letterSynchronization->setChecked(llp.letterSynchronization());
    KoListStyle::Style s = llp.style();
    foreach(int row, m_mapping.keys()) {
        if (m_mapping[row] == s) {
            widget.listTypes->setCurrentRow(row);
            break;
        }
    }
    int align;
    if (llp.alignment() == (Qt::AlignLeft | Qt::AlignAbsolute))
        align = 1;
    else if (llp.alignment() == (Qt::AlignRight | Qt::AlignAbsolute))
        align = 2;
    else if (llp.alignment() == Qt::AlignCenter)
        align = 3;
    else
        align = 0;

    widget.alignment->setCurrentIndex(align);
    widget.depth->setValue(llp.level());
    widget.levels->setValue(llp.displayLevel());
    widget.startValue->setValue(llp.startValue());
    if (s == KoListStyle::CustomCharItem)
        widget.customCharacter->setText(llp.bulletCharacter());

    if (s == KoListStyle::ImageItem) {
        m_data = llp.bulletImage();
        widget.imageHeight->setValue(llp.height());
        widget.imageWidth->setValue(llp.width());
    } else {
        m_data = 0;
        widget.imageHeight->setValue(0);
        widget.imageWidth->setValue(0);
    }

    if(llp.alignmentMode()==false) {//for list-level-position-and-space-mode=label-width-and-position disable the following options
        widget.label_8->setEnabled(false);
        widget.label_9->setEnabled(false);
        widget.label_10->setEnabled(false);
        widget.label_11->setEnabled(false);

        widget.labelFollowedBy->setEnabled(false);
        widget.doubleSpinBox->setEnabled(false);
        widget.doubleSpinBox_2->setEnabled(false);
        widget.doubleSpinBox_3->setEnabled(false);
    } else {
        m_alignmentMode=true;
        switch(llp.labelFollowedBy()) {
        case KoListStyle::ListTab:
            widget.doubleSpinBox->setEnabled(true);
            widget.labelFollowedBy->setCurrentIndex(0);
            widget.doubleSpinBox->setValue(KoUnit::toCentimeter(llp.tabStopPosition()));
            break;
        case KoListStyle::Space:
            widget.doubleSpinBox->setEnabled(false);
            widget.labelFollowedBy->setCurrentIndex(1);
            break;
        case KoListStyle::Nothing:
            widget.doubleSpinBox->setEnabled(false);
            widget.labelFollowedBy->setCurrentIndex(2);
            break;
        default:
            Q_ASSERT(false);
        }

        widget.doubleSpinBox_2->setValue(KoUnit::toCentimeter(llp.margin()));
        widget.doubleSpinBox_3->setValue(KoUnit::toCentimeter(llp.margin())+KoUnit::toCentimeter(llp.textIndent()));
    }

    // *** features not in GUI;
    // character style
    // relative bullet size (percent)
    // minimum label width
    recalcPreview();
}