ParagraphIndentSpacing::ParagraphIndentSpacing(QWidget *parent)
        : QWidget(parent),
        m_fontMetricsChecked(false)
{
    widget.setupUi(this);

    connect(widget.first, SIGNAL(valueChangedPt(qreal)), this, SLOT(firstLineMarginChanged(qreal)));
    connect(widget.left, SIGNAL(valueChangedPt(qreal)), this, SLOT(leftMarginChanged(qreal)));
    connect(widget.right, SIGNAL(valueChangedPt(qreal)), this, SLOT(rightMarginChanged(qreal)));

    // Keep order in sync with lineSpacingType() and display()
    widget.lineSpacing->addItem(i18nc("Line spacing value", "Single"));
    widget.lineSpacing->addItem(i18nc("Line spacing value", "1.5 Lines"));
    widget.lineSpacing->addItem(i18nc("Line spacing value", "Double"));
    widget.lineSpacing->addItem(i18nc("Line spacing type", "Proportional"));    // called Proportional like in OO
    widget.lineSpacing->addItem(i18nc("Line spacing type", "Additional"));    // normal distance + absolute value
    widget.lineSpacing->addItem(i18nc("Line spacing type", "Fixed"));
    widget.lineSpacing->addItem(i18nc("Line spacing type", "At least"));

    connect(widget.first, SIGNAL(valueChangedPt(qreal)), this, SLOT(firstIndentValueChanged()));
    connect(widget.left, SIGNAL(valueChangedPt(qreal)), this, SLOT(leftMarginValueChanged()));
    connect(widget.right, SIGNAL(valueChangedPt(qreal)), this, SLOT(rightMarginValueChanged()));
    connect(widget.after, SIGNAL(valueChangedPt(qreal)), this, SLOT(bottomMarginValueChanged()));
    connect(widget.before, SIGNAL(valueChangedPt(qreal)), this, SLOT(topMarginValueChanged()));
    connect(widget.lineSpacing, SIGNAL(currentIndexChanged(int)), this, SLOT(lineSpacingChanged(int)));
    connect(widget.useFont, SIGNAL(toggled(bool)), this, SLOT(useFontMetrices(bool)));
    connect(widget.autoTextIndent, SIGNAL(stateChanged(int)), this, SLOT(autoTextIndentChanged(int)));
    connect(widget.proportional, SIGNAL(valueChanged(int)), this, SLOT(spacingPercentChanged()));
    connect(widget.custom, SIGNAL(valueChangedPt(qreal)), this, SLOT(spacingValueChanged()));
    lineSpacingChanged(0);
}
ParagraphGeneral::ParagraphGeneral(QWidget *parent)
        : QWidget(parent),
        m_blockSignals(false),
        m_nameHidden(false),
        m_style(0)
{
    widget.setupUi(this);

//Disable for now
    //inherit style
    widget.label_3->setVisible(false);
    widget.inheritStyle->setVisible(false);
    //use named charStyle
    widget.useCharacterStyle->setVisible(false);
    widget.label_4->setVisible(false);
    widget.characterStyle->setVisible(false);
    //include in TOC
    widget.inToc->setVisible(false);
//
    m_paragraphIndentSpacing = new ParagraphIndentSpacing(this);
    widget.tabs->addTab(m_paragraphIndentSpacing, i18n("Indent/Spacing"));
    connect(m_paragraphIndentSpacing, SIGNAL(firstLineMarginChanged(qreal)),
            widget.preview, SLOT(setFirstLineMargin(qreal)));
    connect(m_paragraphIndentSpacing, SIGNAL(leftMarginChanged(qreal)),
            widget.preview, SLOT(setLeftMargin(qreal)));
    connect(m_paragraphIndentSpacing, SIGNAL(rightMarginChanged(qreal)),
            widget.preview, SLOT(setRightMargin(qreal)));
    connect(m_paragraphIndentSpacing, SIGNAL(lineSpacingChanged(qreal,qreal,qreal,int,bool)),
            widget.preview, SLOT(setLineSpacing(qreal,qreal,qreal,int,bool)));

    m_paragraphLayout = new ParagraphLayout(this);
    widget.tabs->addTab(m_paragraphLayout, i18n("General Layout"));
    connect(m_paragraphLayout, SIGNAL(horizontalAlignmentChanged(Qt::Alignment)), this, SLOT(horizontalAlignmentChanged(Qt::Alignment)));

    m_paragraphBulletsNumbers = new ParagraphBulletsNumbers(this);
    widget.tabs->addTab(m_paragraphBulletsNumbers, i18n("Bullets/Numbers"));
    connect(m_paragraphBulletsNumbers, SIGNAL(bulletListItemChanged(const QString&)),
        this, SLOT(bulletListItemChanged(const QString&)));

    m_paragraphDecorations = new ParagraphDecorations(this);
    widget.tabs->addTab(m_paragraphDecorations, i18n("Decorations"));
    connect(m_paragraphDecorations, SIGNAL(backgroundColorChanged(const QColor&)),
        this, SLOT(backgroundColorChanged(const QColor&)));

    widget.preview->setText(QString("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."));

    connect(widget.name, SIGNAL(textChanged(const QString &)), this, SIGNAL(nameChanged(const QString&)));
    connect(widget.name, SIGNAL(textChanged(const QString &)), this, SLOT(setName(const QString&)));
}