Example #1
0
void ParagraphSettingsDialog::slotApply()
{
    emit startMacro(i18n("Paragraph Settings\n"));
    KoParagraphStyle chosenStyle;
    m_paragraphGeneral->save(&chosenStyle);
    QTextBlockFormat format;
    chosenStyle.applyStyle(format);
    m_cursor->mergeBlockFormat(format);
    if (chosenStyle.listStyle()) {
        ChangeListCommand *cmd = new ChangeListCommand(*m_cursor, chosenStyle.listStyle(), 0, ChangeListCommand::MergeWithAdjacentList);
        m_tool->addCommand(cmd);
    } else {
        QTextList *list = m_cursor->block().textList();
        if (list) { // then remove it.
            list->remove(m_cursor->block());
        }
    }
    emit stopMacro();
}
void TextEditWidget::sl_ListButton_Toggled(bool toggle) {
	QTextCursor cursor = this->textField->textCursor();
	if (toggle) {
		if (cursor.currentList()) {
			WARNING("Wrong button state");
			return;
		}
		QTextListFormat format;
		format.setStyle(QTextListFormat::ListDisc);
		cursor.createList(format);
	} else {
		QTextList *textList = cursor.currentList();
		if (!cursor.currentList()) {
			WARNING("Wrong button state");
			return;
		}
		QTextBlock block = cursor.block();
		textList->remove(block);
		QTextBlockFormat format = block.blockFormat();
		format.setIndent(0);
		cursor.setBlockFormat(format);
	}
}