本文整理汇总了C++中ktexteditor::attribute::Ptr::fontBold方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::fontBold方法的具体用法?C++ Ptr::fontBold怎么用?C++ Ptr::fontBold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::attribute::Ptr
的用法示例。
在下文中一共展示了Ptr::fontBold方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant KateStyleTreeWidgetItem::data( int column, int role ) const
{
if (column == Context) {
switch (role) {
case Qt::ForegroundRole:
if (style()->hasProperty(QTextFormat::ForegroundBrush))
return style()->foreground().color();
break;
case Qt::BackgroundRole:
if (style()->hasProperty(QTextFormat::BackgroundBrush))
return style()->background().color();
break;
case Qt::FontRole:
return style()->font();
break;
}
}
if (role == Qt::CheckStateRole) {
switch (column) {
case Bold:
return toCheckState(style()->fontBold());
case Italic:
return toCheckState(style()->fontItalic());
case Underline:
return toCheckState(style()->fontUnderline());
case StrikeOut:
return toCheckState(style()->fontStrikeOut());
case UseDefaultStyle:
/* can't compare all attributes, currentStyle has always more than defaultStyle (e.g. the item's name),
* so we just compare the important ones:*/
return toCheckState(
currentStyle->foreground() == defaultStyle->foreground()
&& currentStyle->background() == defaultStyle->background()
&& currentStyle->selectedForeground() == defaultStyle->selectedForeground()
&& currentStyle->selectedBackground() == defaultStyle->selectedBackground()
&& currentStyle->fontBold() == defaultStyle->fontBold()
&& currentStyle->fontItalic() == defaultStyle->fontItalic()
&& currentStyle->fontUnderline() == defaultStyle->fontUnderline()
&& currentStyle->fontStrikeOut() == defaultStyle->fontStrikeOut());
}
}
if (role == Qt::DisplayRole) {
switch (column) {
case Foreground:
return style()->foreground();
case SelectedForeground:
return style()->selectedForeground();
case Background:
return style()->background();
case SelectedBackground:
return style()->selectedBackground();
}
}
return QTreeWidgetItem::data(column, role);
}
示例2: setDefaults
void KateHlManager::setDefaults(const QString &schema, KateAttributeList &list,KConfig *cfg)
{
cfg=cfg?cfg:KateHlManager::self()->self()->getKConfig();
KConfigGroup config(cfg,
"Default Item Styles - Schema " + schema);
for (uint z = 0; z < defaultStyles(); z++)
{
QStringList settings;
KTextEditor::Attribute::Ptr p = list.at(z);
settings<<(p->hasProperty(QTextFormat::ForegroundBrush)?QString::number(p->foreground().color().rgb(),16):"");
settings<<(p->hasProperty(KTextEditor::Attribute::SelectedForeground)?QString::number(p->selectedForeground().color().rgb(),16):"");
settings<<(p->hasProperty(QTextFormat::FontWeight)?(p->fontBold()?"1":"0"):"");
settings<<(p->hasProperty(QTextFormat::FontItalic)?(p->fontItalic()?"1":"0"):"");
settings<<(p->hasProperty(QTextFormat::FontStrikeOut)?(p->fontStrikeOut()?"1":"0"):"");
settings<<(p->hasProperty(QTextFormat::FontUnderline)?(p->fontUnderline()?"1":"0"):"");
settings<<(p->hasProperty(QTextFormat::BackgroundBrush)?QString::number(p->background().color().rgb(),16):"-");
settings<<(p->hasProperty(KTextEditor::Attribute::SelectedBackground)?QString::number(p->selectedBackground().color().rgb(),16):"-");
settings<<(p->hasProperty(QTextFormat::FontFamily)?(p->fontFamily()):QString());
settings<<"---";
config.writeEntry(defaultStyleName(z),settings);
}
emit changed();
}
示例3: exportText
void exportText(QString& ret,
const QString& text,
const KTextEditor::Attribute::Ptr& attrib)
{
if ( !attrib || !attrib->hasAnyProperty()) {
ret.append(text);
return;
}
if ( attrib->fontBold() ) {
ret.append("<b>");
}
if ( attrib->fontItalic() ) {
ret.append("<i>");
}
bool writeForeground = attrib->hasProperty(QTextCharFormat::ForegroundBrush);
bool writeBackground = attrib->hasProperty(QTextCharFormat::BackgroundBrush);
if ( writeForeground || writeBackground ) {
ret.append(QString("<span style='%1%2'>")
.arg(writeForeground ? QString(QLatin1String("color:")
+ attrib->foreground().color().name()
+ QLatin1Char(';'))
: QString())
.arg(writeBackground ? QString(QLatin1String("background:")
+ attrib->background().color().name()
+ QLatin1Char(';'))
: QString()));
}
ret.append(text);
if ( writeBackground || writeForeground ) {
ret.append("</span>");
}
if ( attrib->fontItalic() ) {
ret.append("</i>");
}
if ( attrib->fontBold() ) {
ret.append("</b>");
}
}
示例4: exportText
void HTMLExporter::exportText(const QString &text, const KTextEditor::Attribute::Ptr &attrib)
{
if (!attrib || !attrib->hasAnyProperty() || attrib == m_defaultAttribute) {
m_output << text.toHtmlEscaped();
return;
}
if (attrib->fontBold()) {
m_output << "<b>";
}
if (attrib->fontItalic()) {
m_output << "<i>";
}
bool writeForeground = attrib->hasProperty(QTextCharFormat::ForegroundBrush)
&& (!m_defaultAttribute || attrib->foreground().color() != m_defaultAttribute->foreground().color());
bool writeBackground = attrib->hasProperty(QTextCharFormat::BackgroundBrush)
&& (!m_defaultAttribute || attrib->background().color() != m_defaultAttribute->background().color());
if (writeForeground || writeBackground) {
m_output << QStringLiteral("<span style='%1%2'>")
.arg(writeForeground ? QString(QLatin1String("color:") + attrib->foreground().color().name() + QLatin1Char(';')) : QString())
.arg(writeBackground ? QString(QLatin1String("background:") + attrib->background().color().name() + QLatin1Char(';')) : QString());
}
m_output << text.toHtmlEscaped();
if (writeBackground || writeForeground) {
m_output << "</span>";
}
if (attrib->fontItalic()) {
m_output << "</i>";
}
if (attrib->fontBold()) {
m_output << "</b>";
}
}
示例5: changeProperty
void KateStyleTreeWidgetItem::changeProperty( int p )
{
if ( p == Bold )
currentStyle->setFontBold( ! currentStyle->fontBold() );
else if ( p == Italic )
currentStyle->setFontItalic( ! currentStyle->fontItalic() );
else if ( p == Underline )
currentStyle->setFontUnderline( ! currentStyle->fontUnderline() );
else if ( p == StrikeOut )
currentStyle->setFontStrikeOut( ! currentStyle->fontStrikeOut() );
else if ( p == UseDefaultStyle )
toggleDefStyle();
else
setColor( p );
updateStyle ();
treeWidget()->emitChanged();
}
示例6: contextMenuEvent
void KateStyleTreeWidget::contextMenuEvent( QContextMenuEvent * event )
{
KateStyleTreeWidgetItem *i = dynamic_cast<KateStyleTreeWidgetItem*>(itemAt(event->pos()));
if (!i) return;
KMenu m( this );
KTextEditor::Attribute::Ptr currentStyle = i->style();
// the title is used, because the menu obscures the context name when
// displayed on behalf of spacePressed().
QPainter p;
p.setPen(Qt::black);
QIcon cl = brushIcon( i->style()->foreground().color() );
QIcon scl = brushIcon( i->style()->selectedForeground().color() );
QIcon bgcl = brushIcon( i->style()->hasProperty(QTextFormat::BackgroundBrush) ? i->style()->background().color() : viewport()->palette().base().color() );
QIcon sbgcl = brushIcon( i->style()->hasProperty(KTextEditor::Attribute::SelectedBackground) ? i->style()->selectedBackground().color() : viewport()->palette().base().color() );
m.addTitle( i->contextName() );
QAction* a = m.addAction( i18n("&Bold"), this, SLOT(changeProperty()) );
a->setCheckable(true);
a->setChecked( currentStyle->fontBold() );
a->setData(KateStyleTreeWidgetItem::Bold);
a = m.addAction( i18n("&Italic"), this, SLOT(changeProperty()) );
a->setCheckable(true);
a->setChecked( currentStyle->fontItalic() );
a->setData(KateStyleTreeWidgetItem::Italic);
a = m.addAction( i18n("&Underline"), this, SLOT(changeProperty()) );
a->setCheckable(true);
a->setChecked( currentStyle->fontUnderline() );
a->setData(KateStyleTreeWidgetItem::Underline);
a = m.addAction( i18n("S&trikeout"), this, SLOT(changeProperty()) );
a->setCheckable(true);
a->setChecked( currentStyle->fontStrikeOut() );
a->setData(KateStyleTreeWidgetItem::StrikeOut);
m.addSeparator();
a = m.addAction( cl, i18n("Normal &Color..."), this, SLOT(changeProperty()) );
a->setData(KateStyleTreeWidgetItem::Foreground);
a = m.addAction( scl, i18n("&Selected Color..."), this, SLOT(changeProperty()) );
a->setData(KateStyleTreeWidgetItem::SelectedForeground);
a = m.addAction( bgcl, i18n("&Background Color..."), this, SLOT(changeProperty()) );
a->setData(KateStyleTreeWidgetItem::Background);
a = m.addAction( sbgcl, i18n("S&elected Background Color..."), this, SLOT(changeProperty()) );
a->setData(KateStyleTreeWidgetItem::SelectedBackground);
// Unset [some] colors. I could show one only if that button was clicked, but that
// would disable setting this with the keyboard (how many aren't doing just
// that every day? ;)
// ANY ideas for doing this in a nicer way will be warmly wellcomed.
KTextEditor::Attribute::Ptr style = i->style();
if ( style->hasProperty( QTextFormat::BackgroundBrush) || style->hasProperty( KTextEditor::Attribute::SelectedBackground ) )
{
m.addSeparator();
if ( style->hasProperty( QTextFormat::BackgroundBrush) ) {
a = m.addAction( i18n("Unset Background Color"), this, SLOT(unsetColor()) );
a->setData(100);
}
if ( style->hasProperty( KTextEditor::Attribute::SelectedBackground ) ) {
a = m.addAction( i18n("Unset Selected Background Color"), this, SLOT(unsetColor()) );
a->setData(101);
}
}
if ( ! i->isDefault() && ! i->defStyle() ) {
m.addSeparator();
a = m.addAction( i18n("Use &Default Style"), this, SLOT(changeProperty()) );
a->setCheckable(true);
a->setChecked( i->defStyle() );
a->setData(KateStyleTreeWidgetItem::UseDefaultStyle);
}
m.exec( event->globalPos() );
}