/*! \internal Initialized the style sheet to the basic Qt style. */ void QStyleSheet::init() { styles.setAutoDelete( TRUE ); nullstyle = new QStyleSheetItem( this, QString::fromLatin1("") ); QStyleSheetItem* style; style = new QStyleSheetItem( this, "qml" ); // compatibility style->setDisplayMode( QStyleSheetItem::DisplayBlock ); style = new QStyleSheetItem( this, QString::fromLatin1("qt") ); style->setDisplayMode( QStyleSheetItem::DisplayBlock ); style = new QStyleSheetItem( this, QString::fromLatin1("a") ); style->setAnchor( TRUE ); style = new QStyleSheetItem( this, QString::fromLatin1("em") ); style->setFontItalic( TRUE ); style = new QStyleSheetItem( this, QString::fromLatin1("i") ); style->setFontItalic( TRUE ); style = new QStyleSheetItem( this, QString::fromLatin1("big") ); style->setLogicalFontSizeStep( 1 ); style = new QStyleSheetItem( this, QString::fromLatin1("large") ); // compatibility style->setLogicalFontSizeStep( 1 ); style = new QStyleSheetItem( this, QString::fromLatin1("small") ); style->setLogicalFontSizeStep( -1 ); style = new QStyleSheetItem( this, QString::fromLatin1("strong") ); style->setFontWeight( QFont::Bold); style = new QStyleSheetItem( this, QString::fromLatin1("b") ); style->setFontWeight( QFont::Bold); style = new QStyleSheetItem( this, QString::fromLatin1("h1") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(6); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 18); style-> setMargin(QStyleSheetItem::MarginBottom, 12); style = new QStyleSheetItem( this, QString::fromLatin1("h2") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(5); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 16); style-> setMargin(QStyleSheetItem::MarginBottom, 12); style = new QStyleSheetItem( this, QString::fromLatin1("h3") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(4); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 14); style-> setMargin(QStyleSheetItem::MarginBottom, 12); style = new QStyleSheetItem( this, QString::fromLatin1("h4") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(3); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginVertical, 12); style = new QStyleSheetItem( this, QString::fromLatin1("h5") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(2); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 12); style-> setMargin(QStyleSheetItem::MarginBottom, 4); style = new QStyleSheetItem( this, QString::fromLatin1("p") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginVertical, 12); style->setSelfNesting( FALSE ); style = new QStyleSheetItem( this, QString::fromLatin1("center") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setAlignment( AlignCenter ); style = new QStyleSheetItem( this, QString::fromLatin1("twocolumn") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setNumberOfColumns( 2 ); style = new QStyleSheetItem( this, QString::fromLatin1("multicol") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); (void) new QStyleSheetItem( this, QString::fromLatin1("font") ); style = new QStyleSheetItem( this, QString::fromLatin1("ul") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setListStyle( QStyleSheetItem::ListDisc ); style-> setMargin(QStyleSheetItem::MarginVertical, 12); style->setMargin( QStyleSheetItem::MarginLeft, 40 ); style = new QStyleSheetItem( this, QString::fromLatin1("ol") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setListStyle( QStyleSheetItem::ListDecimal ); style-> setMargin(QStyleSheetItem::MarginVertical, 12); style->setMargin( QStyleSheetItem::MarginLeft, 40 ); style = new QStyleSheetItem( this, QString::fromLatin1("li") ); style->setDisplayMode(QStyleSheetItem::DisplayListItem); style->setSelfNesting( FALSE ); style = new QStyleSheetItem( this, QString::fromLatin1("code") ); style->setFontFamily( QString::fromLatin1("courier") ); style = new QStyleSheetItem( this, QString::fromLatin1("tt") ); style->setFontFamily( QString::fromLatin1("courier") ); new QStyleSheetItem(this, QString::fromLatin1("img")); new QStyleSheetItem(this, QString::fromLatin1("br")); new QStyleSheetItem(this, QString::fromLatin1("hr")); style = new QStyleSheetItem(this, QString::fromLatin1("sub")); style->setVerticalAlignment( QStyleSheetItem::VAlignSub ); style = new QStyleSheetItem(this, QString::fromLatin1("sup")); style->setVerticalAlignment( QStyleSheetItem::VAlignSuper ); style = new QStyleSheetItem( this, QString::fromLatin1("pre") ); style->setFontFamily( QString::fromLatin1("courier") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setWhiteSpaceMode(QStyleSheetItem::WhiteSpacePre); style = new QStyleSheetItem( this, QString::fromLatin1("blockquote") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setMargin(QStyleSheetItem::MarginHorizontal, 40 ); style = new QStyleSheetItem( this, QString::fromLatin1("head") ); style->setDisplayMode(QStyleSheetItem::DisplayNone); style = new QStyleSheetItem( this, QString::fromLatin1("body") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style = new QStyleSheetItem( this, QString::fromLatin1("div") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock) ; new QStyleSheetItem( this, QString::fromLatin1("span") ); style = new QStyleSheetItem( this, QString::fromLatin1("dl") ); style-> setMargin(QStyleSheetItem::MarginVertical, 8); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style = new QStyleSheetItem( this, QString::fromLatin1("dt") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setContexts(QString::fromLatin1("dl") ); style = new QStyleSheetItem( this, QString::fromLatin1("dd") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setMargin(QStyleSheetItem::MarginLeft, 30); style->setContexts(QString::fromLatin1("dt dl") ); style = new QStyleSheetItem( this, QString::fromLatin1("u") ); style->setFontUnderline( TRUE); style = new QStyleSheetItem( this, QString::fromLatin1("s") ); style->setFontStrikeOut( TRUE); style = new QStyleSheetItem( this, QString::fromLatin1("nobr") ); style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap ); // compatibily with some minor 3.0.x Qt versions that had an // undocumented <wsp> tag. ### Remove 3.1 style = new QStyleSheetItem( this, QString::fromLatin1("wsp") ); style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpacePre ); // tables new QStyleSheetItem( this, QString::fromLatin1("table") ); style = new QStyleSheetItem( this, QString::fromLatin1("tr") ); style->setContexts(QString::fromLatin1("table")); style = new QStyleSheetItem( this, QString::fromLatin1("td") ); style->setContexts(QString::fromLatin1("tr")); style = new QStyleSheetItem( this, QString::fromLatin1("th") ); style->setFontWeight( QFont::Bold ); style->setAlignment( Qt::AlignCenter ); style->setContexts(QString::fromLatin1("tr")); new QStyleSheetItem( this, QString::fromLatin1("html") ); }
/*! \internal Initialized the style sheet to the basic Qt style. */ void QStyleSheet::init() { styles.setAutoDelete( TRUE ); nullstyle = new QStyleSheetItem( this, QString::fromLatin1("") ); QStyleSheetItem* style; style = new QStyleSheetItem( this, "qml" ); // compatibility style->setDisplayMode( QStyleSheetItem::DisplayBlock ); style = new QStyleSheetItem( this, QString::fromLatin1("qt") ); style->setDisplayMode( QStyleSheetItem::DisplayBlock ); //style->setMargin( QStyleSheetItem::MarginAll, 4 ); style = new QStyleSheetItem( this, QString::fromLatin1("a") ); style->setAnchor( TRUE ); style = new QStyleSheetItem( this, QString::fromLatin1("em") ); style->setFontItalic( TRUE ); style = new QStyleSheetItem( this, QString::fromLatin1("i") ); style->setFontItalic( TRUE ); style = new QStyleSheetItem( this, QString::fromLatin1("big") ); style->setLogicalFontSizeStep( 1 ); style = new QStyleSheetItem( this, QString::fromLatin1("large") ); // compatibility style->setLogicalFontSizeStep( 1 ); style = new QStyleSheetItem( this, QString::fromLatin1("small") ); style->setLogicalFontSizeStep( -1 ); style = new QStyleSheetItem( this, QString::fromLatin1("strong") ); style->setFontWeight( QFont::Bold); style = new QStyleSheetItem( this, QString::fromLatin1("b") ); style->setFontWeight( QFont::Bold); style = new QStyleSheetItem( this, QString::fromLatin1("h1") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(6); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 12); style-> setMargin(QStyleSheetItem::MarginBottom, 6); style = new QStyleSheetItem( this, QString::fromLatin1("h2") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(5); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 10); style-> setMargin(QStyleSheetItem::MarginBottom, 5); style = new QStyleSheetItem( this, QString::fromLatin1("h3") ); style->setFontWeight( QFont::Bold); style->setLogicalFontSize(4); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginTop, 8); style-> setMargin(QStyleSheetItem::MarginBottom, 4); style = new QStyleSheetItem( this, QString::fromLatin1("p") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginVertical, 4); style->setSelfNesting( FALSE ); style = new QStyleSheetItem( this, QString::fromLatin1("center") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setAlignment( AlignCenter ); style = new QStyleSheetItem( this, QString::fromLatin1("twocolumn") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setNumberOfColumns( 2 ); style = new QStyleSheetItem( this, QString::fromLatin1("multicol") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); (void) new QStyleSheetItem( this, QString::fromLatin1("font") ); style = new QStyleSheetItem( this, QString::fromLatin1("ul") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style-> setMargin(QStyleSheetItem::MarginVertical, 4); style = new QStyleSheetItem( this, QString::fromLatin1("ol") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setListStyle( QStyleSheetItem::ListDecimal ); style-> setMargin(QStyleSheetItem::MarginVertical, 4); style = new QStyleSheetItem( this, QString::fromLatin1("li") ); style->setDisplayMode(QStyleSheetItem::DisplayListItem); style->setSelfNesting( FALSE ); style->setContexts(QString::fromLatin1("ol ul")); style-> setMargin(QStyleSheetItem::MarginVertical, 4); style = new QStyleSheetItem( this, QString::fromLatin1("code") ); style->setFontFamily( QString::fromLatin1("courier") ); style = new QStyleSheetItem( this, QString::fromLatin1("tt") ); style->setFontFamily( QString::fromLatin1("courier") ); new QStyleSheetItem(this, QString::fromLatin1("img")); new QStyleSheetItem(this, QString::fromLatin1("br")); new QStyleSheetItem(this, QString::fromLatin1("hr")); style = new QStyleSheetItem( this, QString::fromLatin1("pre") ); style->setFontFamily( QString::fromLatin1("courier") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setWhiteSpaceMode(QStyleSheetItem::WhiteSpacePre); style = new QStyleSheetItem( this, QString::fromLatin1("blockquote") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setMargin(QStyleSheetItem::MarginHorizontal, 40 ); style = new QStyleSheetItem( this, QString::fromLatin1("head") ); style->setDisplayMode(QStyleSheetItem::DisplayNone); style = new QStyleSheetItem( this, QString::fromLatin1("div") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style = new QStyleSheetItem( this, QString::fromLatin1("dl") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style = new QStyleSheetItem( this, QString::fromLatin1("dt") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setContexts(QString::fromLatin1("dl") ); style = new QStyleSheetItem( this, QString::fromLatin1("dd") ); style->setDisplayMode(QStyleSheetItem::DisplayBlock); style->setMargin(QStyleSheetItem::MarginLeft, 30); style->setContexts(QString::fromLatin1("dt dl") ); style = new QStyleSheetItem( this, QString::fromLatin1("u") ); style->setFontUnderline( TRUE); style = new QStyleSheetItem( this, QString::fromLatin1("nobr") ); style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap ); // tables style = new QStyleSheetItem( this, QString::fromLatin1("table") ); style = new QStyleSheetItem( this, QString::fromLatin1("tr") ); style->setContexts(QString::fromLatin1("table")); style = new QStyleSheetItem( this, QString::fromLatin1("td") ); style->setContexts(QString::fromLatin1("tr")); style = new QStyleSheetItem( this, QString::fromLatin1("th") ); style->setFontWeight( QFont::Bold ); style->setAlignment( Qt::AlignCenter ); style->setContexts(QString::fromLatin1("tr")); style = new QStyleSheetItem( this, QString::fromLatin1("html") ); }
void CSSConfig::slotPreview() { QStyleSheetItem *h1 = new QStyleSheetItem(QStyleSheet::defaultSheet(), "h1"); QStyleSheetItem *h2 = new QStyleSheetItem(QStyleSheet::defaultSheet(), "h2"); QStyleSheetItem *h3 = new QStyleSheetItem(QStyleSheet::defaultSheet(), "h3"); QStyleSheetItem *text = new QStyleSheetItem(QStyleSheet::defaultSheet(), "p"); // Fontsize int bfs = customDialog->basefontsize->currentText().toInt(); text->setFontSize(bfs); if (customDialog->dontScale->isChecked()) { h1->setFontSize(bfs); h2->setFontSize(bfs); h3->setFontSize(bfs); } else { h1->setFontSize(static_cast<int>(bfs * 1.8)); h2->setFontSize(static_cast<int>(bfs * 1.6)); h3->setFontSize(static_cast<int>(bfs * 1.4)); } // Colors QColor back, fore; if (customDialog->blackOnWhite->isChecked()) { back = Qt::white; fore = Qt::black; } else if (customDialog->whiteOnBlack->isChecked()) { back = Qt::black; fore = Qt::white; } else { back = customDialog->backgroundColor->color(); fore = customDialog->foregroundColor->color(); } h1->setColor(fore); h2->setColor(fore); h3->setColor(fore); text->setColor(fore); // Fonts h1->setFontFamily(customDialog->fontFamily->currentText()); h2->setFontFamily(customDialog->fontFamily->currentText()); h3->setFontFamily(customDialog->fontFamily->currentText()); text->setFontFamily(customDialog->fontFamily->currentText()); // Show the preview PreviewDialog *dlg = new PreviewDialog(this, 0, true); dlg->preview->setPaper(back); dlg->preview->viewport()->setFont(QFont(KGlobalSettings::generalFont().family(), bfs)); dlg->exec(); delete dlg; }