From a4de3feb16df7f18559587ebf78f115d88acc022 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Mon, 18 Jul 2016 21:34:11 -0400 Subject: [PATCH] Add option to use the selected font's line characters Konsole has builtin code to manually write out line characters. There are certain reasons why this might not be desired. This adds a profile option to use the fonts line characters. The default is as-is today using the builtin code. BUG: 364992 --- src/EditProfileDialog.cpp | 9 +++++++++ src/EditProfileDialog.h | 1 + src/EditProfileDialog.ui | 10 ++++++++++ src/Profile.cpp | 2 ++ src/Profile.h | 8 ++++++++ src/TerminalDisplay.cpp | 3 ++- src/TerminalDisplay.h | 16 ++++++++++++++++ src/ViewManager.cpp | 1 + 8 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index dbc54b91c..a85cd5b3e 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -447,6 +447,10 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile) _ui->boldIntenseButton->setChecked(profile->boldIntense()); connect(_ui->boldIntenseButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::setBoldIntense); + + _ui->useFontLineCharactersButton->setChecked(profile->useFontLineCharacters()); + connect(_ui->useFontLineCharactersButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::useFontLineCharacters); + _ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled()); connect(_ui->enableMouseWheelZoomButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::toggleMouseWheelZoom); } @@ -474,6 +478,11 @@ void EditProfileDialog::setBoldIntense(bool enable) preview(Profile::BoldIntense, enable); updateTempProfileProperty(Profile::BoldIntense, enable); } +void EditProfileDialog::useFontLineCharacters(bool enable) +{ + preview(Profile::UseFontLineCharacters, enable); + updateTempProfileProperty(Profile::UseFontLineCharacters, enable); +} void EditProfileDialog::toggleMouseWheelZoom(bool enable) { updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable); diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h index 64e32638b..1195c1400 100644 --- a/src/EditProfileDialog.h +++ b/src/EditProfileDialog.h @@ -126,6 +126,7 @@ private slots: void showAllFontsButtonWarning(bool enable); void setAntialiasText(bool enable); void setBoldIntense(bool enable); + void useFontLineCharacters(bool enable); void showFontDialog(); void newColorScheme(); void editColorScheme(); diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui index 7b86c6fb4..1acec377b 100644 --- a/src/EditProfileDialog.ui +++ b/src/EditProfileDialog.ui @@ -613,6 +613,16 @@ + + + + Use the selected font for line characters instead of the builtin code + + + Use line characters contained in font + + + diff --git a/src/Profile.cpp b/src/Profile.cpp index c58eacd54..06fe5b1ec 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -78,6 +78,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = { , { ColorScheme , "colors" , 0 , QVariant::String } , { AntiAliasFonts, "AntiAliasFonts" , APPEARANCE_GROUP , QVariant::Bool } , { BoldIntense, "BoldIntense", APPEARANCE_GROUP, QVariant::Bool } + , { UseFontLineCharacters, "UseFontLineChararacters", APPEARANCE_GROUP, QVariant::Bool } , { LineSpacing , "LineSpacing" , APPEARANCE_GROUP , QVariant::Int } // Keyboard @@ -199,6 +200,7 @@ FallbackProfile::FallbackProfile() setProperty(DefaultEncoding, QString(QTextCodec::codecForLocale()->name())); setProperty(AntiAliasFonts, true); setProperty(BoldIntense, true); + setProperty(UseFontLineCharacters, false); setProperty(WordCharacters, ":@-./_~?&=%+#"); diff --git a/src/Profile.h b/src/Profile.h index 37a0559b4..de74afade 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -223,6 +223,9 @@ public: /** (bool) Whether character with intense colors should be rendered * in bold font or just in bright color. */ BoldIntense, + /** (bool) Whether to use font's line characters instead of the + * builtin code. */ + UseFontLineCharacters, /** (bool) Whether new sessions should be started in the same * directory as the currently active session. */ @@ -479,6 +482,11 @@ public: return property(Profile::BoldIntense); } + /** Convenience method for property(Profile::UseFontLineCharacters)*/ + bool useFontLineCharacters() const { + return property(Profile::UseFontLineCharacters); + } + /** Convenience method for property(Profile::StartInCurrentSessionDir) */ bool startInCurrentSessionDir() const { return property(Profile::StartInCurrentSessionDir); diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index c7fb3c648..4f28837da 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -375,6 +375,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent) , _filterUpdateRequired(true) , _cursorShape(Enum::BlockCursor) , _antialiasText(true) + , _useFontLineCharacters(false) , _printerFriendly(false) , _sessionController(0) , _trimTrailingSpaces(false) @@ -854,7 +855,7 @@ void TerminalDisplay::drawCharacters(QPainter& painter, } // draw text - if (isLineCharString(text)) { + if (isLineCharString(text) && !_useFontLineCharacters) { drawLineCharString(painter, rect.x(), rect.y(), text, style); } else { // Force using LTR as the document layout for the terminal area, because diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index 7f09a5291..93c98abbc 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -414,6 +414,21 @@ public: return _boldIntense; } + /** + * Specifies whether line characters will be displayed using font instead + * of builtin code. + * as bold. Defaults to false. + */ + void setUseFontLineCharacters(bool value) { + _useFontLineCharacters = value; + } + /** + * Returns true if font line characters will be used. + */ + bool getFontLineCharacters() const { + return _useFontLineCharacters; + } + /** * Sets whether or not the current height and width of the * terminal in lines and columns is displayed whilst the widget @@ -920,6 +935,7 @@ private: InputMethodData _inputMethodData; bool _antialiasText; // do we anti-alias or not + bool _useFontLineCharacters; bool _printerFriendly; // are we currently painting to a printer in black/white mode diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index da2ccd97b..90ef863bd 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -777,6 +777,7 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr // load font view->setAntialias(profile->antiAliasFonts()); view->setBoldIntense(profile->boldIntense()); + view->setUseFontLineCharacters(profile->useFontLineCharacters()); view->setVTFont(profile->font()); // set scroll-bar position