forked from qt-creator/qt-creator
Revert "Editor: Make line spacing adjustable"
This does not work with text wrapping since there are multiple
QTextLines inside a block but we can not adjust the line hight inside a
block. This needs to be addressed inside Qt.
This reverts commit dc64f3207b
.
Change-Id: If6c28056da9891eeeb75f5939a42f08360013a80
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
2
dist/changes-4.14.0.md
vendored
2
dist/changes-4.14.0.md
vendored
@@ -24,8 +24,6 @@ Help
|
|||||||
Editing
|
Editing
|
||||||
-------
|
-------
|
||||||
|
|
||||||
* Added option to adjust line spacing (QTCREATORBUG-13727)
|
|
||||||
|
|
||||||
### C++
|
### C++
|
||||||
|
|
||||||
* Added refactoring action that creates getters and setters for all class members
|
* Added refactoring action that creates getters and setters for all class members
|
||||||
|
@@ -324,7 +324,7 @@ private:
|
|||||||
{
|
{
|
||||||
QTextCursor tc = m_editor->textCursor();
|
QTextCursor tc = m_editor->textCursor();
|
||||||
m_currentPos = tc.position();
|
m_currentPos = tc.position();
|
||||||
m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height();
|
m_lineSpacing = m_editor->cursorRect(tc).height();
|
||||||
setFont(m_editor->extraArea()->font());
|
setFont(m_editor->extraArea()->font());
|
||||||
|
|
||||||
// Follow geometry of normal line numbers if visible,
|
// Follow geometry of normal line numbers if visible,
|
||||||
|
@@ -45,7 +45,6 @@
|
|||||||
static const char fontFamilyKey[] = "FontFamily";
|
static const char fontFamilyKey[] = "FontFamily";
|
||||||
static const char fontSizeKey[] = "FontSize";
|
static const char fontSizeKey[] = "FontSize";
|
||||||
static const char fontZoomKey[] = "FontZoom";
|
static const char fontZoomKey[] = "FontZoom";
|
||||||
static const char lineSpacingKey[] = "LineSpacing";
|
|
||||||
static const char antialiasKey[] = "FontAntialias";
|
static const char antialiasKey[] = "FontAntialias";
|
||||||
static const char schemeFileNamesKey[] = "ColorSchemes";
|
static const char schemeFileNamesKey[] = "ColorSchemes";
|
||||||
|
|
||||||
@@ -57,13 +56,11 @@ static const bool DEFAULT_ANTIALIAS = true;
|
|||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
// -- FontSettings
|
// -- FontSettings
|
||||||
FontSettings::FontSettings()
|
FontSettings::FontSettings() :
|
||||||
: m_family(defaultFixedFontFamily())
|
m_family(defaultFixedFontFamily()),
|
||||||
, m_fontSize(defaultFontSize())
|
m_fontSize(defaultFontSize()),
|
||||||
, m_fontZoom(100)
|
m_fontZoom(100),
|
||||||
, m_lineSpacing(100)
|
m_antialias(DEFAULT_ANTIALIAS)
|
||||||
, m_antialias(DEFAULT_ANTIALIAS)
|
|
||||||
, m_lineSpacingCache(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +69,10 @@ void FontSettings::clear()
|
|||||||
m_family = defaultFixedFontFamily();
|
m_family = defaultFixedFontFamily();
|
||||||
m_fontSize = defaultFontSize();
|
m_fontSize = defaultFontSize();
|
||||||
m_fontZoom = 100;
|
m_fontZoom = 100;
|
||||||
m_lineSpacing = 100;
|
|
||||||
m_antialias = DEFAULT_ANTIALIAS;
|
m_antialias = DEFAULT_ANTIALIAS;
|
||||||
m_scheme.clear();
|
m_scheme.clear();
|
||||||
clearCaches();
|
m_formatCache.clear();
|
||||||
|
m_textCharFormatCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString settingsGroup()
|
static QString settingsGroup()
|
||||||
@@ -92,12 +89,9 @@ void FontSettings::toSettings(QSettings *s) const
|
|||||||
if (m_fontSize != defaultFontSize() || s->contains(QLatin1String(fontSizeKey)))
|
if (m_fontSize != defaultFontSize() || s->contains(QLatin1String(fontSizeKey)))
|
||||||
s->setValue(QLatin1String(fontSizeKey), m_fontSize);
|
s->setValue(QLatin1String(fontSizeKey), m_fontSize);
|
||||||
|
|
||||||
if (m_fontZoom != 100 || s->contains(QLatin1String(fontZoomKey)))
|
if (m_fontZoom!= 100 || s->contains(QLatin1String(fontZoomKey)))
|
||||||
s->setValue(QLatin1String(fontZoomKey), m_fontZoom);
|
s->setValue(QLatin1String(fontZoomKey), m_fontZoom);
|
||||||
|
|
||||||
if (m_lineSpacing != 100 || s->contains(QLatin1String(lineSpacingKey)))
|
|
||||||
s->setValue(QLatin1String(lineSpacingKey), m_lineSpacing);
|
|
||||||
|
|
||||||
if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey)))
|
if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey)))
|
||||||
s->setValue(QLatin1String(antialiasKey), m_antialias);
|
s->setValue(QLatin1String(antialiasKey), m_antialias);
|
||||||
|
|
||||||
@@ -122,8 +116,7 @@ bool FontSettings::fromSettings(const FormatDescriptions &descriptions, const QS
|
|||||||
|
|
||||||
m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString();
|
m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString();
|
||||||
m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt();
|
m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt();
|
||||||
m_fontZoom = s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt();
|
m_fontZoom= s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt();
|
||||||
m_lineSpacing = s->value(group + QLatin1String(lineSpacingKey), m_lineSpacing).toInt();
|
|
||||||
m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool();
|
m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool();
|
||||||
|
|
||||||
if (s->contains(group + QLatin1String(schemeFileNamesKey))) {
|
if (s->contains(group + QLatin1String(schemeFileNamesKey))) {
|
||||||
@@ -141,12 +134,11 @@ bool FontSettings::fromSettings(const FormatDescriptions &descriptions, const QS
|
|||||||
bool FontSettings::equals(const FontSettings &f) const
|
bool FontSettings::equals(const FontSettings &f) const
|
||||||
{
|
{
|
||||||
return m_family == f.m_family
|
return m_family == f.m_family
|
||||||
&& m_schemeFileName == f.m_schemeFileName
|
&& m_schemeFileName == f.m_schemeFileName
|
||||||
&& m_fontSize == f.m_fontSize
|
&& m_fontSize == f.m_fontSize
|
||||||
&& m_lineSpacing == f.m_lineSpacing
|
&& m_fontZoom == f.m_fontZoom
|
||||||
&& m_fontZoom == f.m_fontZoom
|
&& m_antialias == f.m_antialias
|
||||||
&& m_antialias == f.m_antialias
|
&& m_scheme == f.m_scheme;
|
||||||
&& m_scheme == f.m_scheme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint qHash(const TextStyle &textStyle)
|
uint qHash(const TextStyle &textStyle)
|
||||||
@@ -280,13 +272,6 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettings::clearCaches()
|
|
||||||
{
|
|
||||||
m_formatCache.clear();
|
|
||||||
m_textCharFormatCache.clear();
|
|
||||||
m_lineSpacingCache = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextCharFormat FontSettings::toTextCharFormat(TextStyles textStyles) const
|
QTextCharFormat FontSettings::toTextCharFormat(TextStyles textStyles) const
|
||||||
{
|
{
|
||||||
auto textCharFormatIterator = m_textCharFormatCache.find(textStyles);
|
auto textCharFormatIterator = m_textCharFormatCache.find(textStyles);
|
||||||
@@ -327,7 +312,8 @@ QString FontSettings::family() const
|
|||||||
void FontSettings::setFamily(const QString &family)
|
void FontSettings::setFamily(const QString &family)
|
||||||
{
|
{
|
||||||
m_family = family;
|
m_family = family;
|
||||||
clearCaches();
|
m_formatCache.clear();
|
||||||
|
m_textCharFormatCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,7 +327,8 @@ int FontSettings::fontSize() const
|
|||||||
void FontSettings::setFontSize(int size)
|
void FontSettings::setFontSize(int size)
|
||||||
{
|
{
|
||||||
m_fontSize = size;
|
m_fontSize = size;
|
||||||
clearCaches();
|
m_formatCache.clear();
|
||||||
|
m_textCharFormatCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -357,28 +344,6 @@ void FontSettings::setFontZoom(int zoom)
|
|||||||
m_fontZoom = zoom;
|
m_fontZoom = zoom;
|
||||||
m_formatCache.clear();
|
m_formatCache.clear();
|
||||||
m_textCharFormatCache.clear();
|
m_textCharFormatCache.clear();
|
||||||
m_lineSpacingCache = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal FontSettings::lineSpacing() const
|
|
||||||
{
|
|
||||||
if (qFuzzyIsNull(m_lineSpacingCache)) {
|
|
||||||
auto currentFont = font();
|
|
||||||
currentFont.setPointSize(m_fontSize * m_fontZoom / 100);
|
|
||||||
m_lineSpacingCache = QFontMetricsF(currentFont).lineSpacing() / 100 * m_lineSpacing;
|
|
||||||
}
|
|
||||||
return m_lineSpacingCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FontSettings::relativeLineSpacing() const
|
|
||||||
{
|
|
||||||
return m_lineSpacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FontSettings::setRelativeLineSpacing(int relativeLineSpacing)
|
|
||||||
{
|
|
||||||
m_lineSpacing = relativeLineSpacing;
|
|
||||||
m_lineSpacingCache = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont FontSettings::font() const
|
QFont FontSettings::font() const
|
||||||
@@ -399,7 +364,8 @@ bool FontSettings::antialias() const
|
|||||||
void FontSettings::setAntialias(bool antialias)
|
void FontSettings::setAntialias(bool antialias)
|
||||||
{
|
{
|
||||||
m_antialias = antialias;
|
m_antialias = antialias;
|
||||||
clearCaches();
|
m_formatCache.clear();
|
||||||
|
m_textCharFormatCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -436,7 +402,8 @@ void FontSettings::setColorSchemeFileName(const QString &fileName)
|
|||||||
bool FontSettings::loadColorScheme(const QString &fileName,
|
bool FontSettings::loadColorScheme(const QString &fileName,
|
||||||
const FormatDescriptions &descriptions)
|
const FormatDescriptions &descriptions)
|
||||||
{
|
{
|
||||||
clearCaches();
|
m_formatCache.clear();
|
||||||
|
m_textCharFormatCache.clear();
|
||||||
bool loaded = true;
|
bool loaded = true;
|
||||||
m_schemeFileName = fileName;
|
m_schemeFileName = fileName;
|
||||||
|
|
||||||
@@ -492,7 +459,8 @@ const ColorScheme &FontSettings::colorScheme() const
|
|||||||
void FontSettings::setColorScheme(const ColorScheme &scheme)
|
void FontSettings::setColorScheme(const ColorScheme &scheme)
|
||||||
{
|
{
|
||||||
m_scheme = scheme;
|
m_scheme = scheme;
|
||||||
clearCaches();
|
m_formatCache.clear();
|
||||||
|
m_textCharFormatCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString defaultFontFamily()
|
static QString defaultFontFamily()
|
||||||
|
@@ -75,10 +75,6 @@ public:
|
|||||||
int fontZoom() const;
|
int fontZoom() const;
|
||||||
void setFontZoom(int zoom);
|
void setFontZoom(int zoom);
|
||||||
|
|
||||||
qreal lineSpacing() const;
|
|
||||||
int relativeLineSpacing() const;
|
|
||||||
void setRelativeLineSpacing(int relativeLineSpacing);
|
|
||||||
|
|
||||||
QFont font() const;
|
QFont font() const;
|
||||||
|
|
||||||
bool antialias() const;
|
bool antialias() const;
|
||||||
@@ -104,19 +100,16 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const;
|
void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const;
|
||||||
void clearCaches();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_family;
|
QString m_family;
|
||||||
QString m_schemeFileName;
|
QString m_schemeFileName;
|
||||||
int m_fontSize;
|
int m_fontSize;
|
||||||
int m_fontZoom;
|
int m_fontZoom;
|
||||||
int m_lineSpacing;
|
|
||||||
bool m_antialias;
|
bool m_antialias;
|
||||||
ColorScheme m_scheme;
|
ColorScheme m_scheme;
|
||||||
mutable QHash<TextStyle, QTextCharFormat> m_formatCache;
|
mutable QHash<TextStyle, QTextCharFormat> m_formatCache;
|
||||||
mutable QHash<TextStyles, QTextCharFormat> m_textCharFormatCache;
|
mutable QHash<TextStyles, QTextCharFormat> m_textCharFormatCache;
|
||||||
mutable qreal m_lineSpacingCache;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const FontSettings &f1, const FontSettings &f2) { return f1.equals(f2); }
|
inline bool operator==(const FontSettings &f1, const FontSettings &f2) { return f1.equals(f2); }
|
||||||
|
@@ -31,9 +31,9 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/stringutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/utilsicons.h>
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
@@ -128,11 +128,6 @@ public:
|
|||||||
|
|
||||||
m_ui.antialias->setChecked(m_value.antialias());
|
m_ui.antialias->setChecked(m_value.antialias());
|
||||||
m_ui.zoomSpinBox->setValue(m_value.fontZoom());
|
m_ui.zoomSpinBox->setValue(m_value.fontZoom());
|
||||||
m_ui.lineSpacingSpinBox->setValue(m_value.relativeLineSpacing());
|
|
||||||
m_ui.lineSpacingWarningLabel->setPixmap(Utils::Icons::WARNING.pixmap());
|
|
||||||
m_ui.lineSpacingWarningLabel->setToolTip(tr("A line spacing less than 100% can result in "
|
|
||||||
"overlapping and misaligned graphics."));
|
|
||||||
m_ui.lineSpacingWarningLabel->setVisible(m_value.relativeLineSpacing() < 100);
|
|
||||||
|
|
||||||
m_ui.schemeEdit->setFormatDescriptions(fd);
|
m_ui.schemeEdit->setFormatDescriptions(fd);
|
||||||
m_ui.schemeEdit->setBaseFont(m_value.font());
|
m_ui.schemeEdit->setBaseFont(m_value.font());
|
||||||
@@ -148,8 +143,6 @@ public:
|
|||||||
this, &FontSettingsPageWidget::fontSizeSelected);
|
this, &FontSettingsPageWidget::fontSizeSelected);
|
||||||
connect(m_ui.zoomSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
connect(m_ui.zoomSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||||
this, &FontSettingsPageWidget::fontZoomChanged);
|
this, &FontSettingsPageWidget::fontZoomChanged);
|
||||||
connect(m_ui.lineSpacingSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
|
||||||
this, &FontSettingsPageWidget::lineSpacingChanged);
|
|
||||||
connect(m_ui.antialias, &QCheckBox::toggled,
|
connect(m_ui.antialias, &QCheckBox::toggled,
|
||||||
this, &FontSettingsPageWidget::antialiasChanged);
|
this, &FontSettingsPageWidget::antialiasChanged);
|
||||||
connect(m_ui.schemeComboBox,
|
connect(m_ui.schemeComboBox,
|
||||||
@@ -173,7 +166,6 @@ public:
|
|||||||
void fontSelected(const QFont &font);
|
void fontSelected(const QFont &font);
|
||||||
void fontSizeSelected(int index);
|
void fontSizeSelected(int index);
|
||||||
void fontZoomChanged();
|
void fontZoomChanged();
|
||||||
void lineSpacingChanged(const int &value);
|
|
||||||
void antialiasChanged();
|
void antialiasChanged();
|
||||||
void colorSchemeSelected(int index);
|
void colorSchemeSelected(int index);
|
||||||
void openCopyColorSchemeDialog();
|
void openCopyColorSchemeDialog();
|
||||||
@@ -425,12 +417,6 @@ void FontSettingsPageWidget::fontZoomChanged()
|
|||||||
m_value.setFontZoom(m_ui.zoomSpinBox->value());
|
m_value.setFontZoom(m_ui.zoomSpinBox->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::lineSpacingChanged(const int &value)
|
|
||||||
{
|
|
||||||
m_value.setRelativeLineSpacing(value);
|
|
||||||
m_ui.lineSpacingWarningLabel->setVisible(value < 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FontSettingsPageWidget::antialiasChanged()
|
void FontSettingsPageWidget::antialiasChanged()
|
||||||
{
|
{
|
||||||
m_value.setAntialias(m_ui.antialias->isChecked());
|
m_value.setAntialias(m_ui.antialias->isChecked());
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>752</width>
|
<width>639</width>
|
||||||
<height>306</height>
|
<height>306</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -17,23 +17,40 @@
|
|||||||
<string>Font</string>
|
<string>Font</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="5">
|
<item row="0" column="4">
|
||||||
<widget class="QComboBox" name="sizeComboBox">
|
<widget class="QLabel" name="sizeLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>1</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="editable">
|
<property name="text">
|
||||||
<bool>true</bool>
|
<string>Size:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QFontComboBox" name="fontComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="7">
|
<item row="0" column="7">
|
||||||
|
<widget class="QLabel" name="zoomLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="familyLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Family:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="6">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@@ -49,7 +66,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="14">
|
<item row="0" column="9">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@@ -62,19 +79,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
|
||||||
<widget class="QLabel" name="sizeLabel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Size:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="3">
|
<item row="1" column="0" colspan="3">
|
||||||
<widget class="QCheckBox" name="antialias">
|
<widget class="QCheckBox" name="antialias">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -82,32 +86,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="9">
|
|
||||||
<widget class="QSpinBox" name="zoomSpinBox">
|
|
||||||
<property name="suffix">
|
|
||||||
<string>%</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>3000</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>100</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="8">
|
|
||||||
<widget class="QLabel" name="zoomLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Zoom:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -124,61 +102,41 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="12">
|
<item row="0" column="8">
|
||||||
<widget class="QSpinBox" name="lineSpacingSpinBox">
|
<widget class="QSpinBox" name="zoomSpinBox">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string>%</string>
|
<string>%</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>50</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>3000</number>
|
<number>3000</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>100</number>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="familyLabel">
|
<widget class="QFontComboBox" name="fontComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="5">
|
||||||
|
<widget class="QComboBox" name="sizeComboBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>1</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="editable">
|
||||||
<string>Family:</string>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="11">
|
|
||||||
<widget class="QLabel" name="lineSpacingLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Line spacing:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="10">
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Preferred</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="13">
|
|
||||||
<widget class="QLabel" name="lineSpacingWarningLabel"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -242,7 +200,6 @@
|
|||||||
<tabstop>fontComboBox</tabstop>
|
<tabstop>fontComboBox</tabstop>
|
||||||
<tabstop>sizeComboBox</tabstop>
|
<tabstop>sizeComboBox</tabstop>
|
||||||
<tabstop>zoomSpinBox</tabstop>
|
<tabstop>zoomSpinBox</tabstop>
|
||||||
<tabstop>lineSpacingSpinBox</tabstop>
|
|
||||||
<tabstop>antialias</tabstop>
|
<tabstop>antialias</tabstop>
|
||||||
<tabstop>schemeComboBox</tabstop>
|
<tabstop>schemeComboBox</tabstop>
|
||||||
<tabstop>copyButton</tabstop>
|
<tabstop>copyButton</tabstop>
|
||||||
|
@@ -24,13 +24,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "textdocumentlayout.h"
|
#include "textdocumentlayout.h"
|
||||||
|
|
||||||
#include "fontsettings.h"
|
|
||||||
#include "textdocument.h"
|
#include "textdocument.h"
|
||||||
#include "texteditorsettings.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
@@ -630,9 +625,6 @@ void TextDocumentLayout::updateMarksBlock(const QTextBlock &block)
|
|||||||
QRectF TextDocumentLayout::blockBoundingRect(const QTextBlock &block) const
|
QRectF TextDocumentLayout::blockBoundingRect(const QTextBlock &block) const
|
||||||
{
|
{
|
||||||
QRectF boundingRect = QPlainTextDocumentLayout::blockBoundingRect(block);
|
QRectF boundingRect = QPlainTextDocumentLayout::blockBoundingRect(block);
|
||||||
if (boundingRect.isNull())
|
|
||||||
return boundingRect;
|
|
||||||
boundingRect.setHeight(TextEditorSettings::fontSettings().lineSpacing());
|
|
||||||
if (TextBlockUserData *userData = textUserData(block))
|
if (TextBlockUserData *userData = textUserData(block))
|
||||||
boundingRect.adjust(0, 0, 0, userData->additionalAnnotationHeight());
|
boundingRect.adjust(0, 0, 0, userData->additionalAnnotationHeight());
|
||||||
return boundingRect;
|
return boundingRect;
|
||||||
|
@@ -1107,9 +1107,9 @@ void TextEditorWidget::print(QPrinter *printer)
|
|||||||
delete dlg;
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int foldBoxWidth()
|
static int foldBoxWidth(const QFontMetrics &fm)
|
||||||
{
|
{
|
||||||
const int lineSpacing = TextEditorSettings::fontSettings().lineSpacing();
|
const int lineSpacing = fm.lineSpacing();
|
||||||
return lineSpacing + lineSpacing % 2 + 1;
|
return lineSpacing + lineSpacing % 2 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3606,9 +3606,9 @@ QRect TextEditorWidgetPrivate::foldBox()
|
|||||||
QRectF br = q->blockBoundingGeometry(begin).translated(q->contentOffset());
|
QRectF br = q->blockBoundingGeometry(begin).translated(q->contentOffset());
|
||||||
QRectF er = q->blockBoundingGeometry(end).translated(q->contentOffset());
|
QRectF er = q->blockBoundingGeometry(end).translated(q->contentOffset());
|
||||||
|
|
||||||
return QRect(m_extraArea->width() - foldBoxWidth(),
|
return QRect(m_extraArea->width() - foldBoxWidth(q->fontMetrics()),
|
||||||
int(br.top()),
|
int(br.top()),
|
||||||
foldBoxWidth(),
|
foldBoxWidth(q->fontMetrics()),
|
||||||
int(er.bottom() - br.top()));
|
int(er.bottom() - br.top()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4089,9 +4089,7 @@ bool TextEditorWidgetPrivate::updateAnnotationBounds(TextBlockUserData *blockUse
|
|||||||
{
|
{
|
||||||
const bool additionalHeightNeeded = annotationsVisible
|
const bool additionalHeightNeeded = annotationsVisible
|
||||||
&& m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines;
|
&& m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines;
|
||||||
const int additionalHeight = additionalHeightNeeded
|
const int additionalHeight = additionalHeightNeeded ? q->fontMetrics().lineSpacing() : 0;
|
||||||
? TextEditorSettings::fontSettings().lineSpacing()
|
|
||||||
: 0;
|
|
||||||
if (blockUserData->additionalAnnotationHeight() == additionalHeight)
|
if (blockUserData->additionalAnnotationHeight() == additionalHeight)
|
||||||
return false;
|
return false;
|
||||||
blockUserData->setAdditionalAnnotationHeight(additionalHeight);
|
blockUserData->setAdditionalAnnotationHeight(additionalHeight);
|
||||||
@@ -4132,7 +4130,7 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data,
|
|||||||
return mark1->priority() > mark2->priority();
|
return mark1->priority() > mark2->priority();
|
||||||
});
|
});
|
||||||
|
|
||||||
const qreal itemOffset = blockData.boundingRect.height();
|
const qreal itemOffset = q->fontMetrics().lineSpacing();
|
||||||
const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2;
|
const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2;
|
||||||
const qreal minimalContentWidth = q->fontMetrics().horizontalAdvance('X')
|
const qreal minimalContentWidth = q->fontMetrics().horizontalAdvance('X')
|
||||||
* m_displaySettings.m_minimalAnnotationContent;
|
* m_displaySettings.m_minimalAnnotationContent;
|
||||||
@@ -5027,7 +5025,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
|
|||||||
int markWidth = 0;
|
int markWidth = 0;
|
||||||
|
|
||||||
if (d->m_marksVisible) {
|
if (d->m_marksVisible) {
|
||||||
markWidth += documentLayout->maxMarkWidthFactor * TextEditorSettings::fontSettings().lineSpacing() + 2;
|
markWidth += documentLayout->maxMarkWidthFactor * fm.lineSpacing() + 2;
|
||||||
|
|
||||||
// if (documentLayout->doubleMarkCount)
|
// if (documentLayout->doubleMarkCount)
|
||||||
// markWidth += fm.lineSpacing() / 3;
|
// markWidth += fm.lineSpacing() / 3;
|
||||||
@@ -5042,7 +5040,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
|
|||||||
space += 4;
|
space += 4;
|
||||||
|
|
||||||
if (d->m_codeFoldingVisible)
|
if (d->m_codeFoldingVisible)
|
||||||
space += foldBoxWidth();
|
space += foldBoxWidth(fm);
|
||||||
|
|
||||||
if (viewportMargins() != QMargins{isLeftToRight() ? space : 0, 0, isLeftToRight() ? 0 : space, 0})
|
if (viewportMargins() != QMargins{isLeftToRight() ? space : 0, 0, isLeftToRight() ? 0 : space, 0})
|
||||||
d->slotUpdateExtraAreaWidth(space);
|
d->slotUpdateExtraAreaWidth(space);
|
||||||
@@ -5068,9 +5066,9 @@ struct Internal::ExtraAreaPaintEventData
|
|||||||
, selectionStart(editor->textCursor().selectionStart())
|
, selectionStart(editor->textCursor().selectionStart())
|
||||||
, selectionEnd(editor->textCursor().selectionEnd())
|
, selectionEnd(editor->textCursor().selectionEnd())
|
||||||
, fontMetrics(d->m_extraArea->font())
|
, fontMetrics(d->m_extraArea->font())
|
||||||
, lineSpacing(TextEditorSettings::fontSettings().lineSpacing())
|
, lineSpacing(fontMetrics.lineSpacing())
|
||||||
, markWidth(d->m_marksVisible ? lineSpacing : 0)
|
, markWidth(d->m_marksVisible ? lineSpacing : 0)
|
||||||
, collapseColumnWidth(d->m_codeFoldingVisible ? foldBoxWidth() : 0)
|
, collapseColumnWidth(d->m_codeFoldingVisible ? foldBoxWidth(fontMetrics) : 0)
|
||||||
, extraAreaWidth(d->m_extraArea->width() - collapseColumnWidth)
|
, extraAreaWidth(d->m_extraArea->width() - collapseColumnWidth)
|
||||||
, currentLineNumberFormat(
|
, currentLineNumberFormat(
|
||||||
editor->textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER))
|
editor->textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER))
|
||||||
@@ -5194,7 +5192,7 @@ void TextEditorWidgetPrivate::paintCodeFolding(QPainter &painter,
|
|||||||
bool hovered = blockNumber >= extraAreaHighlightFoldBlockNumber
|
bool hovered = blockNumber >= extraAreaHighlightFoldBlockNumber
|
||||||
&& blockNumber <= extraAreaHighlightFoldEndBlockNumber;
|
&& blockNumber <= extraAreaHighlightFoldEndBlockNumber;
|
||||||
|
|
||||||
int boxWidth = foldBoxWidth();
|
int boxWidth = foldBoxWidth(data.fontMetrics);
|
||||||
if (hovered) {
|
if (hovered) {
|
||||||
int itop = qRound(blockBoundingRect.top());
|
int itop = qRound(blockBoundingRect.top());
|
||||||
int ibottom = qRound(blockBoundingRect.bottom());
|
int ibottom = qRound(blockBoundingRect.bottom());
|
||||||
@@ -5567,10 +5565,8 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
|||||||
if (cursor.positionInBlock() == cursor.block().length()-1)
|
if (cursor.positionInBlock() == cursor.block().length()-1)
|
||||||
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
||||||
int block = cursor.blockNumber();
|
int block = cursor.blockNumber();
|
||||||
if (block == blockCount() - 1) {
|
if (block == blockCount() - 1)
|
||||||
block += (e->pos().y() - cursorRect().center().y())
|
block += (e->pos().y() - cursorRect().center().y()) / QFontMetricsF(font()).lineSpacing();
|
||||||
/ TextEditorSettings::fontSettings().lineSpacing();
|
|
||||||
}
|
|
||||||
d->enableBlockSelection(block, column, block, column);
|
d->enableBlockSelection(block, column, block, column);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -5620,11 +5616,8 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e)
|
|||||||
if (cursor.positionInBlock() == cursor.block().length()-1)
|
if (cursor.positionInBlock() == cursor.block().length()-1)
|
||||||
column += (e->pos().x() - cursorRect(cursor).center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
column += (e->pos().x() - cursorRect(cursor).center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
||||||
int block = cursor.blockNumber();
|
int block = cursor.blockNumber();
|
||||||
if (block == blockCount() - 1) {
|
if (block == blockCount() - 1)
|
||||||
block += (e->pos().y() - cursorRect(cursor).center().y())
|
block += (e->pos().y() - cursorRect(cursor).center().y()) / QFontMetricsF(font()).lineSpacing();
|
||||||
/ TextEditorSettings::fontSettings().lineSpacing();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->m_inBlockSelectionMode) {
|
if (d->m_inBlockSelectionMode) {
|
||||||
d->m_blockSelection.positionBlock = block;
|
d->m_blockSelection.positionBlock = block;
|
||||||
d->m_blockSelection.positionColumn = column;
|
d->m_blockSelection.positionColumn = column;
|
||||||
@@ -5798,7 +5791,7 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos)
|
|||||||
const int highlightBlockNumber = d->extraAreaHighlightFoldedBlockNumber;
|
const int highlightBlockNumber = d->extraAreaHighlightFoldedBlockNumber;
|
||||||
d->extraAreaHighlightFoldedBlockNumber = -1;
|
d->extraAreaHighlightFoldedBlockNumber = -1;
|
||||||
|
|
||||||
if (pos.x() > extraArea()->width() - foldBoxWidth()) {
|
if (pos.x() > extraArea()->width() - foldBoxWidth(fontMetrics())) {
|
||||||
d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber();
|
d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber();
|
||||||
} else if (d->m_displaySettings.m_highlightBlocks) {
|
} else if (d->m_displaySettings.m_highlightBlocks) {
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
@@ -5841,7 +5834,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
int dist = (e->pos() - d->m_markDragStart).manhattanLength();
|
int dist = (e->pos() - d->m_markDragStart).manhattanLength();
|
||||||
if (dist > QApplication::startDragDistance()) {
|
if (dist > QApplication::startDragDistance()) {
|
||||||
d->m_markDragging = true;
|
d->m_markDragging = true;
|
||||||
const int height = TextEditorSettings::fontSettings().lineSpacing() - 1;
|
const int height = fontMetrics().lineSpacing() - 1;
|
||||||
const int width = int(.5 + height * d->m_dragMark->widthFactor());
|
const int width = int(.5 + height * d->m_dragMark->widthFactor());
|
||||||
d->m_markDragCursor = QCursor(d->m_dragMark->icon().pixmap({height, width}));
|
d->m_markDragCursor = QCursor(d->m_dragMark->icon().pixmap({height, width}));
|
||||||
d->m_dragMark->setVisible(false);
|
d->m_dragMark->setVisible(false);
|
||||||
@@ -5859,7 +5852,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
|
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
int boxWidth = foldBoxWidth();
|
int boxWidth = foldBoxWidth(fontMetrics());
|
||||||
if (d->m_codeFoldingVisible && e->pos().x() > extraArea()->width() - boxWidth) {
|
if (d->m_codeFoldingVisible && e->pos().x() > extraArea()->width() - boxWidth) {
|
||||||
if (!cursor.block().next().isVisible()) {
|
if (!cursor.block().next().isVisible()) {
|
||||||
d->toggleBlockVisible(cursor.block());
|
d->toggleBlockVisible(cursor.block());
|
||||||
@@ -6386,7 +6379,7 @@ void TextEditorWidgetPrivate::adjustScrollBarRanges()
|
|||||||
{
|
{
|
||||||
if (!m_highlightScrollBarController)
|
if (!m_highlightScrollBarController)
|
||||||
return;
|
return;
|
||||||
const double lineSpacing = TextEditorSettings::fontSettings().lineSpacing();
|
const double lineSpacing = QFontMetricsF(q->font()).lineSpacing();
|
||||||
if (lineSpacing == 0)
|
if (lineSpacing == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user