Commit 48cdd113 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Add profile option to disable underlining links.

Add a configuration item that allows disabling of the underlined links
on mouse hover. The option is profile specific and defaults to the previous
behaviour where links are underlined on hover.

Patch by Amand Tihon <amand.tihon@alrj.com>

BUG: 174261
FIXED-IN: 4.7
CCMAIL: amand.tihon@alrj.com
parent b88dfb40
......@@ -1000,6 +1000,8 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
SLOT(toggleBlinkingCursor(bool)) },
{ _ui->tripleClickMode , Profile::TripleClickMode ,
SLOT(toggleTripleClickMode(bool)) },
{ _ui->underlineLinksButton , Profile::UnderlineLinksEnabled,
SLOT(toggleUnderlineLinks(bool)) },
{ _ui->enableBidiRenderingButton , Profile::BidiRenderingEnabled ,
SLOT(togglebidiRendering(bool)) },
{ 0 , 0 , 0 }
......@@ -1076,6 +1078,10 @@ void EditProfileDialog::toggleBlinkingCursor(bool enable)
{
_tempProfile->setProperty(Profile::BlinkingCursorEnabled,enable);
}
void EditProfileDialog::toggleUnderlineLinks(bool enable)
{
_tempProfile->setProperty(Profile::UnderlineLinksEnabled,enable);
}
void EditProfileDialog::toggleTripleClickMode(bool enable)
{
_tempProfile->setProperty(Profile::TripleClickMode,enable);
......
......@@ -166,6 +166,7 @@ private slots:
void togglebidiRendering(bool);
void toggleBlinkingCursor(bool);
void toggleTripleClickMode(bool);
void toggleUnderlineLinks(bool);
void setCursorShape(int);
void autoCursorColor();
......
......@@ -961,6 +961,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="underlineLinksButton">
<property name="toolTip">
<string>Text recognized as a link or an email address will be underlined when hovered by the mouse pointer.</string>
</property>
<property name="text">
<string>Underline links</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -113,6 +113,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] =
// Interaction
, { WordCharacters , "WordCharacters" , INTERACTION_GROUP , QVariant::String }
, { TripleClickMode , "TripleClickSelectsFromCursor" , INTERACTION_GROUP , QVariant::Bool }
, { UnderlineLinksEnabled , "UnderlineLinksEnabled" , INTERACTION_GROUP , QVariant::Bool }
// Encoding
, { DefaultEncoding , "DefaultEncoding" , ENCODING_GROUP , QVariant::String }
......@@ -173,6 +174,7 @@ FallbackProfile::FallbackProfile()
setProperty(FlowControlEnabled,true);
setProperty(AllowProgramsToResizeWindow,true);
setProperty(BlinkingTextEnabled,true);
setProperty(UnderlineLinksEnabled,true);
setProperty(BlinkingCursorEnabled,false);
setProperty(BidiRenderingEnabled,false);
......
......@@ -178,6 +178,10 @@ public:
* selects whole line.
*/
TripleClickMode,
/** (bool) If true, text that matches a link or an email address is underlined when
* hovered by the mouse pointer.
*/
UnderlineLinksEnabled,
/** (String) Default text codec */
DefaultEncoding,
/** (bool) Whether fonts should be aliased or not */
......
......@@ -316,6 +316,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
,_allowBlinkingText(true)
,_ctrlDrag(true)
,_tripleClickMode(SelectWholeLine)
,_underlineLinks(true)
,_isFixedSize(false)
,_possibleTripleClick(false)
,_resizeWidget(0)
......@@ -1289,7 +1290,7 @@ void TerminalDisplay::paintFilters(QPainter& painter)
Filter::HotSpot* spot = iter.next();
QRegion region;
if ( spot->type() == Filter::HotSpot::Link ) {
if ( _underlineLinks && spot->type() == Filter::HotSpot::Link ) {
QRect r;
if (spot->startLine()==spot->endLine()) {
r.setCoords( spot->startColumn()*_fontWidth + 1 + scrollBarWidth,
......@@ -1353,7 +1354,7 @@ void TerminalDisplay::paintFilters(QPainter& painter)
endColumn*_fontWidth - 1 + scrollBarWidth,
(line+1)*_fontHeight - 1 );
// Underline link hotspots
if ( spot->type() == Filter::HotSpot::Link )
if ( _underlineLinks && spot->type() == Filter::HotSpot::Link )
{
QFontMetrics metrics(font());
......@@ -1782,7 +1783,7 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev)
// handle filters
// change link hot-spot appearance on mouse-over
Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine,charColumn);
if ( spot && spot->type() == Filter::HotSpot::Link)
if ( _underlineLinks && spot && spot->type() == Filter::HotSpot::Link)
{
QRegion previousHotspotArea = _mouseOverHotspotArea;
_mouseOverHotspotArea = QRegion();
......
......@@ -177,6 +177,17 @@ public:
void setTripleClickMode(TripleClickMode mode) { _tripleClickMode = mode; }
/** See setTripleClickSelectionMode() */
TripleClickMode tripleClickMode() { return _tripleClickMode; }
/**
* Specifies whether links and email addresses should be underlined when
* hovered by the mouse. Defaults to true.
*/
void setUnderlineLinks(bool value) { _underlineLinks = value; }
/**
* Returns true if links and email addresses should be underlined when
* hovered by the mouse.
*/
bool getUnderlineLinks() { return _underlineLinks; }
void setLineSpacing(uint);
uint lineSpacing() const;
......@@ -746,6 +757,7 @@ private:
bool _allowBlinkingText; // allow text to blink
bool _ctrlDrag; // require Ctrl key for drag
TripleClickMode _tripleClickMode;
bool _underlineLinks; // Underline URL and hosts on mouse hover
bool _isFixedSize; //Columns / lines are locked.
QTimer* _blinkTimer; // active when hasBlinker
QTimer* _blinkCursorTimer; // active when hasBlinkingCursor
......@@ -757,7 +769,6 @@ private:
bool _possibleTripleClick; // is set in mouseDoubleClickEvent and deleted
// after QApplication::doubleClickInterval() delay
QLabel* _resizeWidget;
QTimer* _resizeTimer;
......
......@@ -867,6 +867,8 @@ void ViewManager::applyProfile(TerminalDisplay* view , const Profile::Ptr info,
bool tripleClickMode = info->property<bool>(Profile::TripleClickMode);
view->setTripleClickMode(tripleClickMode ? TerminalDisplay::SelectForwardsFromCursor : TerminalDisplay::SelectWholeLine);
view->setUnderlineLinks(info->property<bool>(Profile::UnderlineLinksEnabled));
bool bidiEnabled = info->property<bool>(Profile::BidiRenderingEnabled);
view->setBidiEnabled(bidiEnabled);
......
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