本文整理汇总了C++中settings::Manager::getThemeVal方法的典型用法代码示例。如果您正苦于以下问题:C++ Manager::getThemeVal方法的具体用法?C++ Manager::getThemeVal怎么用?C++ Manager::getThemeVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings::Manager
的用法示例。
在下文中一共展示了Manager::getThemeVal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blinkCode
void ScCodeEditor::blinkCode( const QTextCursor & c )
{
if( !c.document() || !c.hasSelection() ) return;
Settings::Manager *settings = Main::settings();
QTextCharFormat evalCodeTextFormat = settings->getThemeVal("evaluatedCode");
QTextDocument *doc = c.document();
int startPos = c.selectionStart();
int endPos = c.selectionEnd();
QTextBlock startBlock = doc->findBlock(startPos);
QTextBlock endBlock = doc->findBlock(endPos);
startPos -= startBlock.position();
endPos -= endBlock.position();
// Get the bounds of visible blocks within the cursor's selection:
QTextBlock block = firstVisibleBlock();
int idx = block.blockNumber();
int sidx = startBlock.blockNumber();
QTextBlock firstBlock, lastBlock;
firstBlock = lastBlock = block;
QRectF geom = blockBoundingGeometry(block).translated(contentOffset());
qreal top = geom.top();
qreal bottom = top;
qreal width=0;
while(block.isValid() && bottom < viewport()->rect().height())
{
if(block.isVisible())
{
QTextLayout *l = block.layout();
QRectF r = l->boundingRect();
bottom += r.height();
if(idx < sidx) {
// Block not within the selection. Will skip it.
top = bottom;
}
else {
// Block within the selection.
width = qMax(width, l->maximumWidth() + r.left());
}
}
if(block == endBlock) break;
block = block.next();
++idx;
if(top == bottom)
firstBlock = block;
}
lastBlock = block;
if(bottom == top) {
//qDebug("no visible block.");
return;
}
// Construct a pixmap to render the code on:
QPixmap pix( QSize(qCeil(width), qCeil(bottom - top)) );
pix.fill(QColor(0,0,0,0));
// Render the visible blocks:
QPainter painter(&pix);
QVector<QTextLayout::FormatRange> selections;
block = firstBlock;
int y=0;
while( block.isValid() )
{
if (block.isVisible())
{
QRectF blockRect = block.layout()->boundingRect();
// Use extra char formatting to hide code outside of selection
// and modify the appearance of selected code:
QTextLayout::FormatRange range;
selections.clear();
int start = 0;
if(block == startBlock) {
range.start = 0;
range.length = startPos;
range.format.setForeground(QColor(0,0,0,0));
range.format.setBackground(Qt::NoBrush);
selections.append(range);
start = startPos;
}
range.start = start;
range.length = (block == endBlock ? endPos : block.length() - 1) - range.start;
range.format = evalCodeTextFormat;
selections.append(range);
//.........这里部分代码省略.........