本文整理汇总了C++中ktexteditor::attribute::Ptr::selectedForeground方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::selectedForeground方法的具体用法?C++ Ptr::selectedForeground怎么用?C++ Ptr::selectedForeground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::attribute::Ptr
的用法示例。
在下文中一共展示了Ptr::selectedForeground方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setColor
void KateStyleTreeWidgetItem::setColor( int column )
{
QColor c; // use this
QColor d; // default color
if ( column == Foreground)
{
c = currentStyle->foreground().color();
d = defaultStyle->foreground().color();
}
else if ( column == SelectedForeground )
{
c = currentStyle->selectedForeground().color();
d = defaultStyle->selectedForeground().color();
}
else if ( column == Background )
{
c = currentStyle->background().color();
d = defaultStyle->background().color();
}
else if ( column == SelectedBackground )
{
c = currentStyle->selectedBackground().color();
d = defaultStyle->selectedBackground().color();
}
if ( KColorDialog::getColor( c, d, treeWidget() ) != QDialog::Accepted) return;
bool def = ! c.isValid();
// if set default, and the attrib is set in the default style use it
// else if set default, unset it
// else set the selected color
switch (column)
{
case Foreground:
if ( def )
{
if ( defaultStyle->hasProperty(QTextFormat::ForegroundBrush) )
currentStyle->setForeground( defaultStyle->foreground());
else
currentStyle->clearProperty(QTextFormat::ForegroundBrush);
}
else
currentStyle->setForeground( c );
break;
case SelectedForeground:
if ( def )
{
if ( defaultStyle->hasProperty(KTextEditor::Attribute::SelectedForeground) )
currentStyle->setSelectedForeground( defaultStyle->selectedForeground());
else
currentStyle->clearProperty(KTextEditor::Attribute::SelectedForeground);
}
else
currentStyle->setSelectedForeground( c );
break;
case Background:
if ( def )
{
if ( defaultStyle->hasProperty(QTextFormat::BackgroundBrush) )
currentStyle->setBackground( defaultStyle->background());
else
currentStyle->clearProperty(QTextFormat::BackgroundBrush);
}
else
currentStyle->setBackground( c );
break;
case SelectedBackground:
if ( def )
{
if ( defaultStyle->hasProperty(KTextEditor::Attribute::SelectedBackground) )
currentStyle->setSelectedBackground( defaultStyle->selectedBackground());
else
currentStyle->clearProperty(KTextEditor::Attribute::SelectedBackground);
}
else
currentStyle->setSelectedBackground( c );
break;
}
//FIXME
//repaint();
}
示例3: updateStyle
void KateStyleTreeWidgetItem::updateStyle()
{
// nothing there, not update it, will crash
if (!actualStyle)
return;
if ( currentStyle->hasProperty(QTextFormat::FontWeight) )
{
if ( currentStyle->fontWeight() != actualStyle->fontWeight())
actualStyle->setFontWeight( currentStyle->fontWeight() );
}
else actualStyle->clearProperty( QTextFormat::FontWeight );
if ( currentStyle->hasProperty(QTextFormat::FontItalic) )
{
if ( currentStyle->fontItalic() != actualStyle->fontItalic())
actualStyle->setFontItalic( currentStyle->fontItalic() );
}
else actualStyle->clearProperty( QTextFormat::FontItalic );
if ( currentStyle->hasProperty(QTextFormat::FontStrikeOut) )
{
if ( currentStyle->fontStrikeOut() != actualStyle->fontStrikeOut())
actualStyle->setFontStrikeOut( currentStyle->fontStrikeOut() );
}
else actualStyle->clearProperty( QTextFormat::FontStrikeOut );
if ( currentStyle->hasProperty(QTextFormat::FontUnderline) )
{
if ( currentStyle->fontUnderline() != actualStyle->fontUnderline())
actualStyle->setFontUnderline( currentStyle->fontUnderline() );
}
else actualStyle->clearProperty( QTextFormat::FontUnderline );
if ( currentStyle->hasProperty(KTextEditor::Attribute::Outline) )
{
if ( currentStyle->outline() != actualStyle->outline())
actualStyle->setOutline( currentStyle->outline() );
}
else actualStyle->clearProperty( KTextEditor::Attribute::Outline );
if ( currentStyle->hasProperty(QTextFormat::ForegroundBrush) )
{
if ( currentStyle->foreground() != actualStyle->foreground())
actualStyle->setForeground( currentStyle->foreground() );
}
else actualStyle->clearProperty( QTextFormat::ForegroundBrush );
if ( currentStyle->hasProperty(KTextEditor::Attribute::SelectedForeground) )
{
if ( currentStyle->selectedForeground() != actualStyle->selectedForeground())
actualStyle->setSelectedForeground( currentStyle->selectedForeground() );
}
else actualStyle->clearProperty( KTextEditor::Attribute::SelectedForeground );
if ( currentStyle->hasProperty(QTextFormat::BackgroundBrush) )
{
if ( currentStyle->background() != actualStyle->background())
actualStyle->setBackground( currentStyle->background() );
}
else actualStyle->clearProperty( QTextFormat::BackgroundBrush );
if ( currentStyle->hasProperty(KTextEditor::Attribute::SelectedBackground) )
{
if ( currentStyle->selectedBackground() != actualStyle->selectedBackground())
actualStyle->setSelectedBackground( currentStyle->selectedBackground() );
}
else actualStyle->clearProperty( KTextEditor::Attribute::SelectedBackground );
}
示例4: 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();
}