Commit cc2f552d authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Add a new option in the profile: Vertical line at Column

This patch introduces a new profile option, a vertical
line at a specific column, to help writting emails, and
git commits in editors that doesn't support line columns
such as nano
parent faceafcc
......@@ -105,7 +105,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { BidiRenderingEnabled , "BidiRenderingEnabled" , TERMINAL_GROUP , QVariant::Bool }
, { BlinkingCursorEnabled , "BlinkingCursorEnabled" , TERMINAL_GROUP , QVariant::Bool }
, { BellMode , "BellMode" , TERMINAL_GROUP , QVariant::Int }
, { VerticalLine, "VerticalLine", TERMINAL_GROUP, QVariant::Bool }
, { VerticalLineAtChar, "VerticalLineAtChar", TERMINAL_GROUP, QVariant::Int }
// Cursor
, { UseCustomCursorColor , "UseCustomCursorColor" , CURSOR_GROUP , QVariant::Bool}
, { CursorShape , "CursorShape" , CURSOR_GROUP , QVariant::Int}
......@@ -233,6 +234,8 @@ void Profile::useFallback()
setProperty(TabColor, QColor(QColor::Invalid));
setProperty(AllowEscapedLinks, true);
setProperty(EscapedLinksSchema, QStringLiteral("http://;https://;file://"));
setProperty(VerticalLine, false);
setProperty(VerticalLineAtChar, 80);
// Fallback should not be shown in menus
setHidden(true);
}
......
......@@ -319,6 +319,10 @@ public:
* some weird ones like git:// and ssh:// but if the user wants he can enable.
*/
EscapedLinksSchema,
/** Use Vertical Line At */
VerticalLine,
/** Vertical Line Pixel at */
VerticalLineAtChar
};
Q_ENUM(Property)
......@@ -669,6 +673,16 @@ public:
return property<QString>(Profile::MenuIndex);
}
bool verticalLine() const
{
return property<bool>(Profile::VerticalLine);
}
int verticalLineAtChar() const
{
return property<int>(Profile::VerticalLineAtChar);
}
int menuIndexAsInt() const;
/** Return a list of all properties names and their type
......
......@@ -471,47 +471,55 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="miscTabLayout" columnstretch="0,0">
<layout class="QGridLayout" name="miscTabLayout" columnstretch="0,0,0">
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label">
<property name="text">
<string>Window:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="dimWhenInactiveCheckbox">
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="showTerminalSizeHintButton">
<property name="toolTip">
<string>Indicate whether the window is active by dimming the colors</string>
<string>Show terminal size in columns and lines in the center of window after resizing</string>
</property>
<property name="text">
<string>Darken</string>
<string>Show hint for terminal size after resizing</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="dimLabel">
<property name="text">
<string>Darkening strength:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="dimValue">
<property name="maximum">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Inactive Terminals:</string>
......@@ -521,7 +529,7 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<item row="0" column="0" colspan="3">
<widget class="QGroupBox" name="contentsGroup">
<property name="title">
<string comment="@title:group">Terminal contents</string>
......@@ -663,7 +671,17 @@
</layout>
</widget>
</item>
<item row="6" column="1">
<item row="4" column="1" colspan="2">
<widget class="QCheckBox" name="dimWhenInactiveCheckbox">
<property name="toolTip">
<string>Indicate whether the window is active by dimming the colors</string>
</property>
<property name="text">
<string>Darken</string>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
......@@ -680,40 +698,46 @@
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="showTerminalSizeHintButton">
<property name="toolTip">
<string>Show terminal size in columns and lines in the center of window after resizing</string>
<item row="1" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="text">
<string>Show hint for terminal size after resizing</string>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="dimLabel">
<widget class="QCheckBox" name="displayVerticalLine">
<property name="text">
<string>Darkening strength:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string>Display Vertical line at column:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="dimValue">
<property name="maximum">
<number>255</number>
</property>
<widget class="QSpinBox" name="displayVerticalLineAtColumn"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</item>
......
......@@ -784,6 +784,14 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr &profile)
_appearanceUi->dimLabel->setEnabled(profile->dimWhenInactive());
connect(_appearanceUi->dimValue, &QSlider::valueChanged,
this, &Konsole::EditProfileDialog::setDimValue);
_appearanceUi->displayVerticalLine->setChecked(profile->verticalLine());
connect(_appearanceUi->displayVerticalLine, &QCheckBox::toggled,
this, &EditProfileDialog::setVerticalLine);
_appearanceUi->displayVerticalLineAtColumn->setValue(profile->verticalLineAtChar());
connect(_appearanceUi->displayVerticalLineAtColumn, QOverload<int>::of(&QSpinBox::valueChanged),
this, &EditProfileDialog::setVerticalLineColumn);
}
void EditProfileDialog::setAntialiasText(bool enable)
......@@ -804,6 +812,15 @@ void EditProfileDialog::linkEscapeSequenceTextsChanged()
{
updateTempProfileProperty(Profile::EscapedLinksSchema, _mouseUi->linkEscapeSequenceTexts->text());
}
void EditProfileDialog::setVerticalLine(bool value)
{
updateTempProfileProperty(Profile::VerticalLine, value);
}
void EditProfileDialog::setVerticalLineColumn(int value)
{
updateTempProfileProperty(Profile::VerticalLineAtChar, value);
}
void EditProfileDialog::setBoldIntense(bool enable)
{
......
......@@ -144,7 +144,8 @@ private Q_SLOTS:
void saveColorScheme(const ColorScheme &scheme, bool isNewScheme);
void removeColorScheme();
void gotNewColorSchemes(const KNS3::Entry::List &changedEntries);
void setVerticalLine(bool);
void setVerticalLineColumn(int);
void toggleBlinkingCursor(bool);
void setCursorShape(int);
void autoCursorColor();
......
......@@ -1345,6 +1345,14 @@ void TerminalDisplay::paintEvent(QPaintEvent* pe)
drawBackground(paint, rect, getBackgroundColor(), true /* use opacity setting */);
}
if (_displayVerticalLine) {
const int x = (_fontWidth/2) + (_fontWidth * _displayVerticalLineAtChar);
const QColor lineColor = getForegroundColor();
paint.setPen(lineColor);
paint.drawLine(QPoint(x, 0), QPoint(x, height()));
}
// only turn on text anti-aliasing, never turn on normal antialiasing
// set https://bugreports.qt.io/browse/QTBUG-66036
paint.setRenderHint(QPainter::TextAntialiasing, _antialiasText);
......@@ -4147,6 +4155,9 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
// mouse wheel zoom
_mouseWheelZoom = profile->mouseWheelZoomEnabled();
_displayVerticalLine = profile->verticalLine();
_displayVerticalLineAtChar = profile->verticalLineAtChar();
setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling));
_dimValue = profile->dimValue();
}
......
......@@ -915,6 +915,8 @@ private:
static const int HIGHLIGHT_SCROLLED_LINES_WIDTH = 3;
bool _hasCompositeFocus;
bool _displayVerticalLine;
int _displayVerticalLineAtChar;
QSharedPointer<HotSpot> _currentlyHoveredHotspot;
};
......
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