Commit 9d188aac authored by Edwin Pujols's avatar Edwin Pujols Committed by Tomaz Canabrava
Browse files

terminalDisplay: Remove unused `fixedFont` code.

The `fixedFont` related code is currently not effectual. So with this
commit I remove it.
parent c695c9b2
......@@ -78,10 +78,6 @@
using namespace Konsole;
#define REPCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
"abcdefgjijklmnopqrstuvwxyz" \
"0123456789./+@"
inline int TerminalDisplay::loc(int x, int y) const {
if (y < 0 || y > _lines) {
qDebug() << "Y: " << y << "Lines" << _lines;
......@@ -332,7 +328,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
connect(this, &TerminalDisplay::drawBackground, _terminalPainter, &TerminalPainter::drawBackground);
connect(this, &TerminalDisplay::drawCharacters, _terminalPainter, &TerminalPainter::drawCharacters);
connect(this, &TerminalDisplay::drawInputMethodPreeditString, _terminalPainter, &TerminalPainter::drawInputMethodPreeditString);
auto ldrawBackground = [this](QPainter &painter,
const QRect &rect, const QColor &backgroundColor, bool useOpacitySetting) {
emit drawBackground(painter, rect, backgroundColor, useOpacitySetting);
......@@ -444,7 +440,7 @@ void TerminalDisplay::setWallpaper(const ColorSchemeWallpaper::Ptr &p)
_wallpaper = p;
}
void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount)
void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount)
{
_screenWindow->scrollBy(mode, amount, _scrollBar->scrollFullPage());
_screenWindow->setTrackOutput(_screenWindow->atEndOfOutput());
......@@ -2891,7 +2887,6 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
void TerminalDisplay::printScreen()
{
auto lprintContent = [this](QPainter &painter, bool friendly) {
QPoint columnLines(_usedLines, _usedColumns);
auto lfontget = [this]() { return _terminalFont->getVTFont(); };
auto lfontset = [this](const QFont &f) { _terminalFont->setVTFont(f); };
......
......@@ -20,16 +20,10 @@
#include <QFont>
#include <QFontMetrics>
#define REPCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
"abcdefgjijklmnopqrstuvwxyz" \
"0123456789./+@"
namespace Konsole
{
TerminalFont::TerminalFont(QWidget *parent)
: QWidget(parent)
, m_fixedFont(true)
, m_lineSpacing(0)
, m_fontHeight(1)
, m_fontWidth(1)
......@@ -40,8 +34,8 @@ namespace Konsole
, m_profile(nullptr)
{
}
void TerminalFont::applyProfile(const Profile::Ptr &profile)
void TerminalFont::applyProfile(const Profile::Ptr &profile)
{
m_profile = profile;
m_antialiasText = profile->antiAliasFonts();
......@@ -50,7 +44,7 @@ namespace Konsole
m_lineSpacing = uint(profile->lineSpacing());
setVTFont(profile->font());
}
void TerminalFont::setVTFont(const QFont &f)
{
QFont newFont(f);
......@@ -129,20 +123,20 @@ namespace Konsole
qobject_cast<QWidget*>(parent())->setFont(newFont);
fontChange(newFont);
}
QFont TerminalFont::getVTFont() const
{
return qobject_cast<QWidget*>(parent())->font();
}
void TerminalFont::increaseFontSize()
void TerminalFont::increaseFontSize()
{
QFont font = qobject_cast<QWidget*>(parent())->font();
font.setPointSizeF(font.pointSizeF() + 1);
setVTFont(font);
}
void TerminalFont::decreaseFontSize()
void TerminalFont::decreaseFontSize()
{
const qreal MinimumFontSize = 6;
......@@ -150,11 +144,11 @@ namespace Konsole
font.setPointSizeF(qMax(font.pointSizeF() - 1, MinimumFontSize));
setVTFont(font);
}
void TerminalFont::resetFontSize()
void TerminalFont::resetFontSize()
{
const qreal MinimumFontSize = 6;
TerminalDisplay *display = qobject_cast<TerminalDisplay*>(parent());
QFont font = display->font();
Profile::Ptr currentProfile = SessionManager::instance()->sessionProfile(display->sessionController()->session());
......@@ -162,28 +156,18 @@ namespace Konsole
font.setPointSizeF(qMax(defaultFontSize, MinimumFontSize));
setVTFont(font);
}
void TerminalFont::setLineSpacing(uint i)
void TerminalFont::setLineSpacing(uint i)
{
m_lineSpacing = i;
fontChange(qobject_cast<QWidget*>(parent())->font());
}
uint TerminalFont::lineSpacing() const
{
return m_lineSpacing;
}
bool TerminalFont::fixedFont() const
{
return m_fixedFont;
}
void TerminalFont::setFixedFont(const bool fixedFont)
{
m_fixedFont = fixedFont;
}
int TerminalFont::fontHeight() const
{
return m_fontHeight;
......@@ -198,7 +182,7 @@ namespace Konsole
{
return m_fontAscent;
}
bool TerminalFont::boldIntense() const
{
return m_boldIntense;
......@@ -208,48 +192,27 @@ namespace Konsole
{
return m_antialiasText;
}
bool TerminalFont::useFontLineCharacters() const
{
return m_useFontLineCharacters;
}
void TerminalFont::fontChange(const QFont &)
void TerminalFont::fontChange(const QFont &)
{
QFontMetrics fm(qobject_cast<QWidget*>(parent())->font());
m_fontHeight = fm.height() + m_lineSpacing;
Q_ASSERT(m_fontHeight > 0);
/* TODO: When changing the three deprecated width() below
* consider the info in
* https://phabricator.kde.org/D23144 comments
* horizontalAdvance() was added in Qt 5.11 (which should be the
* minimum for 20.04 or 20.08 KDE Applications release)
*/
// waba TerminalDisplay 1.123:
// "Base character width on widest ASCII character. This prevents too wide
// characters in the presence of double wide (e.g. Japanese) characters."
// Get the width from representative normal width characters
m_fontWidth = qRound((static_cast<double>(fm.horizontalAdvance(QStringLiteral(REPCHAR))) / static_cast<double>(qstrlen(REPCHAR))));
m_fixedFont = true;
const int fw = fm.horizontalAdvance(QLatin1Char(REPCHAR[0]));
for (unsigned int i = 1; i < qstrlen(REPCHAR); i++) {
if (fw != fm.horizontalAdvance(QLatin1Char(REPCHAR[i]))) {
m_fixedFont = false;
break;
}
}
m_fontWidth = fm.horizontalAdvance(QLatin1Char('M'));
if (m_fontWidth < 1) {
m_fontWidth = 1;
}
m_fontAscent = fm.ascent();
qobject_cast<TerminalDisplay*>(parent())->propagateSize();
update();
}
......
......@@ -37,9 +37,6 @@ namespace Konsole
void setLineSpacing(uint);
uint lineSpacing() const;
bool fixedFont() const;
void setFixedFont(const bool);
int fontHeight() const;
int fontWidth() const;
int fontAscent() const;
......@@ -51,7 +48,6 @@ namespace Konsole
void fontChange(const QFont &);
private:
bool m_fixedFont;
uint m_lineSpacing;
int m_fontHeight;
int m_fontWidth;
......
......@@ -61,8 +61,9 @@ namespace Konsole
}
}
void TerminalPainter::drawContents(Character *image, QPainter &paint, const QRect &rect, bool printerFriendly, int imageSize, bool bidiEnabled,
QVector<LineProperty> lineProperties)
void TerminalPainter::drawContents(Character *image, QPainter &paint, const QRect &rect,
bool printerFriendly, int imageSize, bool bidiEnabled,
QVector<LineProperty> lineProperties)
{
const auto display = qobject_cast<TerminalDisplay*>(sender());
......@@ -191,13 +192,6 @@ namespace Konsole
len++; // Adjust for trailing part of multi-column character
}
const bool save__fixedFont = display->terminalFont()->fixedFont();
if (lineDraw) {
display->terminalFont()->setFixedFont(false);
}
if (doubleWidth) {
display->terminalFont()->setFixedFont(false);
}
univec.resize(p);
QMatrix textScale;
......@@ -245,8 +239,6 @@ namespace Konsole
display->terminalColor()->colorTable());
}
display->terminalFont()->setFixedFont(save__fixedFont);
paint.setWorldTransform(QTransform(textScale.inverted()), true);
if (y < lineProperties.size() - 1) {
......@@ -260,7 +252,7 @@ namespace Konsole
}
}
}
void TerminalPainter::drawCurrentResultRect(QPainter &painter, QRect searchResultRect)
{
const auto display = qobject_cast<TerminalDisplay*>(sender());
......@@ -268,7 +260,7 @@ namespace Konsole
if (display->screenWindow()->currentResultLine() == -1) {
return;
}
searchResultRect.setRect(0, display->contentRect().top() + (display->screenWindow()->currentResultLine() - display->screenWindow()->currentLine()) * display->terminalFont()->fontHeight(),
display->columns() * display->terminalFont()->fontWidth(), display->terminalFont()->fontHeight());
painter.fillRect(searchResultRect, QColor(0, 0, 255, 80));
......@@ -353,9 +345,9 @@ namespace Konsole
// draw text
drawCharacters(painter, rect, text, style, characterColor);
}
void TerminalPainter::drawPrinterFriendlyTextFragment(QPainter &painter, const QRect &rect, const QString &text,
const Character *style)
const Character *style)
{
Character print_style = *style;
print_style.foregroundColor = CharacterColor(COLOR_SPACE_RGB, 0x00000000);
......@@ -363,9 +355,9 @@ namespace Konsole
drawCharacters(painter, rect, text, &print_style, QColor());
}
void TerminalPainter::drawBackground(QPainter &painter, const QRect &rect, const QColor &backgroundColor,
bool useOpacitySetting)
bool useOpacitySetting)
{
const auto display = qobject_cast<TerminalDisplay*>(sender());
......@@ -389,9 +381,9 @@ namespace Konsole
painter.fillRect(rect, backgroundColor);
}
}
void TerminalPainter::drawCursor(QPainter &painter, const QRect &rect, const QColor &foregroundColor,
const QColor &backgroundColor, QColor &characterColor)
const QColor &backgroundColor, QColor &characterColor)
{
const auto display = qobject_cast<TerminalDisplay*>(sender());
......@@ -437,9 +429,9 @@ namespace Konsole
painter.drawLine(line);
}
}
void TerminalPainter::drawCharacters(QPainter &painter, const QRect &rect, const QString &text,
const Character *style, const QColor &characterColor)
const Character *style, const QColor &characterColor)
{
const auto display = qobject_cast<TerminalDisplay*>(sender());
......@@ -452,7 +444,7 @@ namespace Konsole
}
static constexpr int MaxFontWeight = 99;
const int normalWeight = display->font().weight();
const int boldWeight = qMin(normalWeight + 26, MaxFontWeight);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment