本文整理汇总了C++中Theme::foregroundMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ Theme::foregroundMargin方法的具体用法?C++ Theme::foregroundMargin怎么用?C++ Theme::foregroundMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Theme
的用法示例。
在下文中一共展示了Theme::foregroundMargin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadTheme
void Document::loadTheme(const Theme& theme)
{
m_text->document()->blockSignals(true);
// Update colors
QColor color = theme.foregroundColor();
color.setAlpha(theme.foregroundOpacity() * 2.55f);
m_text->setStyleSheet(
QString("QTextEdit { background: rgba(%1, %2, %3, %4); color: %5; selection-background-color: %6; selection-color: %7; padding: %8px; }")
.arg(color.red())
.arg(color.green())
.arg(color.blue())
.arg(color.alpha())
.arg(theme.textColor().name())
.arg(theme.textColor().name())
.arg(theme.foregroundColor().name())
.arg(theme.foregroundPadding())
);
if (m_highlighter->misspelledColor() != theme.misspelledColor()) {
m_highlighter->setMisspelledColor(theme.misspelledColor());
}
// Update text
QFont font = theme.textFont();
font.setStyleStrategy(m_text->font().styleStrategy());
if (m_text->font() != font) {
m_text->setFont(font);
}
m_text->setCursorWidth(!m_block_cursor ? 1 : m_text->fontMetrics().averageCharWidth());
int margin = theme.foregroundMargin();
m_layout->setColumnMinimumWidth(0, margin);
m_layout->setColumnMinimumWidth(2, margin);
if (theme.foregroundPosition() < 3) {
m_text->setFixedWidth(theme.foregroundWidth());
switch (theme.foregroundPosition()) {
case 0:
m_layout->setColumnStretch(0, 0);
m_layout->setColumnStretch(2, 1);
break;
case 2:
m_layout->setColumnStretch(0, 1);
m_layout->setColumnStretch(2, 0);
break;
case 1:
default:
m_layout->setColumnStretch(0, 1);
m_layout->setColumnStretch(2, 1);
break;
};
} else {
m_text->setMinimumWidth(theme.foregroundWidth());
m_text->setMaximumWidth(maximumSize().height());
m_layout->setColumnStretch(0, 0);
m_layout->setColumnStretch(2, 0);
}
centerCursor(true);
m_text->document()->blockSignals(false);
}
示例2: loadTheme
void Document::loadTheme(const Theme& theme)
{
m_text->document()->blockSignals(true);
m_block_default_format.clear();
for(int i=0;i<theme.definedDefaultFormatsForBlocks().length();i++)
m_block_default_format.insert(theme.definedDefaultFormatsForBlocks()[i],theme.defaultFormatForBlock(theme.definedDefaultFormatsForBlocks()[i]));
// Update colors
QString contrast = (qGray(theme.textColor().rgb()) > 127) ? "black" : "white";
QColor color = theme.foregroundColor();
color.setAlpha(theme.foregroundOpacity() * 2.55f);
m_text->setStyleSheet(
QString("Editor { background: rgba(%1, %2, %3, %4); color: %5; selection-background-color: %6; selection-color: %7; padding: %8px; border-radius: %9px; }")
.arg(color.red())
.arg(color.green())
.arg(color.blue())
.arg(color.alpha())
.arg(theme.textColor().name())
.arg(theme.textColor().name())
.arg(contrast)
.arg(theme.foregroundPadding())
.arg(theme.foregroundRounding())
);
if (m_highlighter->misspelledColor() != theme.misspelledColor()) {
m_highlighter->setMisspelledColor(theme.misspelledColor());
}
// Update text
QFont font = theme.textFont();
font.setStyleStrategy(m_text->font().styleStrategy());
if (m_text->font() != font) {
m_text->setFont(font);
}
m_text->setCursorWidth(!m_block_cursor ? 1 : m_text->fontMetrics().averageCharWidth());
int margin = theme.foregroundMargin();
m_layout->setColumnMinimumWidth(0, margin);
m_layout->setColumnMinimumWidth(2, margin);
if (theme.foregroundPosition() < 3) {
m_text->setFixedWidth(theme.foregroundWidth());
switch (theme.foregroundPosition()) {
case 0:
m_layout->setColumnStretch(0, 0);
m_layout->setColumnStretch(2, 1);
break;
case 2:
m_layout->setColumnStretch(0, 1);
m_layout->setColumnStretch(2, 0);
break;
case 1:
default:
m_layout->setColumnStretch(0, 1);
m_layout->setColumnStretch(2, 1);
break;
};
} else {
m_text->setMinimumWidth(theme.foregroundWidth());
m_text->setMaximumWidth(maximumSize().height());
m_layout->setColumnStretch(0, 0);
m_layout->setColumnStretch(2, 0);
}
cleanUpDocument(false);
centerCursor(true);
m_text->document()->blockSignals(false);
m_highlighter->rehighlight();
}
示例3: file
//.........这里部分代码省略.........
connect(m_shadow, SIGNAL(clicked()), this, SLOT(renderPreview()));
m_shadow_color = new ColorButton(m_shadow);
m_shadow_color->setColor(m_theme.shadowColor());
connect(m_shadow_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));
m_shadow_radius = new QSpinBox(m_shadow);
m_shadow_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
m_shadow_radius->setSuffix(tr(" pixels"));
m_shadow_radius->setRange(theme.shadowRadius().minimumValue(), theme.shadowRadius().maximumValue());
m_shadow_radius->setValue(m_theme.shadowRadius());
connect(m_shadow_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
m_shadow_offset = new QSpinBox(m_shadow);
m_shadow_offset->setCorrectionMode(QSpinBox::CorrectToNearestValue);
m_shadow_offset->setSuffix(tr(" pixels"));
m_shadow_offset->setRange(theme.shadowOffset().minimumValue(), theme.shadowOffset().maximumValue());
m_shadow_offset->setValue(m_theme.shadowOffset());
connect(m_shadow_offset, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
QFormLayout* shadow_layout = new QFormLayout(m_shadow);
shadow_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
shadow_layout->addRow(tr("Color:"), m_shadow_color);
shadow_layout->addRow(tr("Radius:"), m_shadow_radius);
shadow_layout->addRow(tr("Vertical Offset:"), m_shadow_offset);
// Create margins group
QGroupBox* margins_group = new QGroupBox(tr("Margins"), contents);
m_foreground_margin = new QSpinBox(margins_group);
m_foreground_margin->setCorrectionMode(QSpinBox::CorrectToNearestValue);
m_foreground_margin->setSuffix(tr(" pixels"));
m_foreground_margin->setRange(theme.foregroundMargin().minimumValue(), theme.foregroundMargin().maximumValue());
m_foreground_margin->setValue(m_theme.foregroundMargin());
connect(m_foreground_margin, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
m_foreground_padding = new QSpinBox(margins_group);
m_foreground_padding->setCorrectionMode(QSpinBox::CorrectToNearestValue);
m_foreground_padding->setSuffix(tr(" pixels"));
m_foreground_padding->setRange(theme.foregroundPadding().minimumValue(), theme.foregroundPadding().maximumValue());
m_foreground_padding->setValue(m_theme.foregroundPadding());
connect(m_foreground_padding, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
QFormLayout* margins_layout = new QFormLayout(margins_group);
margins_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
margins_layout->addRow(tr("Window:"), m_foreground_margin);
margins_layout->addRow(tr("Page:"), m_foreground_padding);
// Create line spacing group
QGroupBox* line_spacing = new QGroupBox(tr("Line Spacing"), contents);
m_line_spacing_type = new QComboBox(line_spacing);
m_line_spacing_type->setEditable(false);
m_line_spacing_type->addItems(QStringList() << tr("Single") << tr("1.5 Lines") << tr("Double") << tr("Proportional"));
m_line_spacing_type->setCurrentIndex(3);
m_line_spacing = new QSpinBox(line_spacing);
m_line_spacing->setSuffix(QLocale().percent());
m_line_spacing->setRange(theme.lineSpacing().minimumValue(), theme.lineSpacing().maximumValue());
m_line_spacing->setValue(m_theme.lineSpacing());
m_line_spacing->setEnabled(false);
switch (m_theme.lineSpacing()) {
case 100: m_line_spacing_type->setCurrentIndex(0); break;