本文整理汇总了C++中Theme::spacingAboveParagraph方法的典型用法代码示例。如果您正苦于以下问题:C++ Theme::spacingAboveParagraph方法的具体用法?C++ Theme::spacingAboveParagraph怎么用?C++ Theme::spacingAboveParagraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Theme
的用法示例。
在下文中一共展示了Theme::spacingAboveParagraph方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
//.........这里部分代码省略.........
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;
case 150: m_line_spacing_type->setCurrentIndex(1); break;
case 200: m_line_spacing_type->setCurrentIndex(2); break;
default: m_line_spacing->setEnabled(true); break;
}
connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(lineSpacingChanged(int)));
connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(renderPreview()));
connect(m_line_spacing, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
QFormLayout* line_spacing_layout = new QFormLayout(line_spacing);
line_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
line_spacing_layout->addRow(tr("Type:"), m_line_spacing_type);
line_spacing_layout->addRow(tr("Height:"), m_line_spacing);
// Create paragraph spacing group
QGroupBox* paragraph_spacing = new QGroupBox(tr("Paragraph Spacing"), contents);
m_tab_width = new QSpinBox(paragraph_spacing);
m_tab_width->setSuffix(tr(" pixels"));
m_tab_width->setRange(theme.tabWidth().minimumValue(), theme.tabWidth().maximumValue());
m_tab_width->setValue(m_theme.tabWidth());
connect(m_tab_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
m_spacing_above_paragraph = new QSpinBox(paragraph_spacing);
m_spacing_above_paragraph->setSuffix(tr(" pixels"));
m_spacing_above_paragraph->setRange(theme.spacingAboveParagraph().minimumValue(), theme.spacingAboveParagraph().maximumValue());
m_spacing_above_paragraph->setValue(m_theme.spacingAboveParagraph());
connect(m_spacing_above_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
m_spacing_below_paragraph = new QSpinBox(paragraph_spacing);
m_spacing_below_paragraph->setSuffix(tr(" pixels"));
m_spacing_below_paragraph->setRange(theme.spacingBelowParagraph().minimumValue(), theme.spacingBelowParagraph().maximumValue());
m_spacing_below_paragraph->setValue(m_theme.spacingBelowParagraph());
connect(m_spacing_below_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));
m_indent_first_line = new QCheckBox(tr("Indent first line"), paragraph_spacing);
m_indent_first_line->setChecked(m_theme.indentFirstLine());
connect(m_indent_first_line, SIGNAL(toggled(bool)), this, SLOT(renderPreview()));
QFormLayout* paragraph_spacing_layout = new QFormLayout(paragraph_spacing);
paragraph_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
paragraph_spacing_layout->addRow(tr("Tab Width:"), m_tab_width);
paragraph_spacing_layout->addRow(tr("Above:"), m_spacing_above_paragraph);
paragraph_spacing_layout->addRow(tr("Below:"), m_spacing_below_paragraph);
paragraph_spacing_layout->addRow("", m_indent_first_line);
// Create preview
m_preview_text = new QTextEdit;
m_preview_text->setFrameStyle(QFrame::NoFrame);
m_preview_text->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_preview_text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QFile file(":/lorem.txt");
if (file.open(QFile::ReadOnly)) {
m_preview_text->setPlainText(QString::fromLatin1(file.readAll()));
file.close();
}
示例2: renderPreview
void ThemeDialog::renderPreview(QImage preview, const QRect& foreground, const Theme& theme)
{
m_load_color = QtConcurrent::run(averageImage, theme.backgroundImage(), theme.backgroundColor());
// Position preview text
int padding = theme.foregroundPadding();
int x = foreground.x() + padding;
int y = foreground.y() + padding + theme.spacingAboveParagraph();
int width = foreground.width() - (padding * 2);
int height = foreground.height() - (padding * 2) - theme.spacingAboveParagraph();
m_preview_text->setGeometry(x, y, width, height);
// Set colors
QColor text_color = theme.textColor();
text_color.setAlpha(255);
QPalette p = m_preview_text->palette();
p.setBrush(QPalette::Base, preview.copy(x, y, width, height));
p.setColor(QPalette::Text, text_color);
p.setColor(QPalette::Highlight, text_color);
p.setColor(QPalette::HighlightedText, (qGray(text_color.rgb()) > 127) ? Qt::black : Qt::white);
m_preview_text->setPalette(p);
// Set spacings
int tab_width = theme.tabWidth();
QTextBlockFormat block_format;
block_format.setLineHeight(theme.lineSpacing(), (theme.lineSpacing() == 100) ? QTextBlockFormat::SingleHeight : QTextBlockFormat::ProportionalHeight);
block_format.setTextIndent(tab_width * theme.indentFirstLine());
block_format.setTopMargin(theme.spacingAboveParagraph());
block_format.setBottomMargin(theme.spacingBelowParagraph());
m_preview_text->textCursor().mergeBlockFormat(block_format);
for (int i = 0, count = m_preview_text->document()->allFormats().count(); i < count; ++i) {
QTextFormat& f = m_preview_text->document()->allFormats()[i];
if (f.isBlockFormat()) {
f.merge(block_format);
}
}
m_preview_text->setTabStopWidth(tab_width);
m_preview_text->document()->setIndentWidth(tab_width);
// Set font
m_preview_text->setFont(theme.textFont());
// Render text
m_preview_text->render(&preview, m_preview_text->pos());
// Create zoomed text cutout
int x2 = (x >= 24) ? (x - 24) : 0;
int y2 = (y >= 24) ? (y - 24) : 0;
QImage text_cutout = preview.copy(x2, y2, 162, 110);
// Create preview icon
m_preview_icon = QImage(":/shadow.png").convertToFormat(QImage::Format_ARGB32_Premultiplied);
{
QPainter painter(&m_preview_icon);
painter.drawImage(9, 9, preview.scaled(240, 135, Qt::KeepAspectRatio, Qt::SmoothTransformation));
painter.fillRect(20, 32, 85, 59, QColor(0, 0, 0, 32));
painter.fillRect(21, 33, 83, 57, Qt::white);
int x3 = (x >= 24) ? (x - 12 + theme.tabWidth()) : 12 + theme.tabWidth();
int y3 = (y >= 24) ? (y - 6) : 0;
painter.drawImage(22, 34, preview, x3, y3, 81, 55);
}
// Create preview pixmap
preview = preview.scaled(480, 270, Qt::KeepAspectRatio, Qt::SmoothTransformation);
{
QPainter painter(&preview);
painter.setPen(Qt::NoPen);
painter.fillRect(22, 46, 170, 118, QColor(0, 0, 0, 32));
painter.fillRect(24, 48, 166, 114, Qt::white);
painter.drawImage(26, 50, text_cutout);
}
m_preview->setPixmap(QPixmap::fromImage(preview));
}