From 48cdd113712d9e2ebad64426429a9bfdb9b4d14e Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sat, 16 Apr 2011 13:39:42 -0400 Subject: [PATCH] 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 BUG: 174261 FIXED-IN: 4.7 CCMAIL: amand.tihon@alrj.com --- src/EditProfileDialog.cpp | 6 ++++++ src/EditProfileDialog.h | 1 + src/EditProfileDialog.ui | 10 ++++++++++ src/Profile.cpp | 2 ++ src/Profile.h | 4 ++++ src/TerminalDisplay.cpp | 7 ++++--- src/TerminalDisplay.h | 13 ++++++++++++- src/ViewManager.cpp | 2 ++ 8 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index 073ccc4a..747d2776 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -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); diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h index e37c77ef..f14aec6a 100644 --- a/src/EditProfileDialog.h +++ b/src/EditProfileDialog.h @@ -166,6 +166,7 @@ private slots: void togglebidiRendering(bool); void toggleBlinkingCursor(bool); void toggleTripleClickMode(bool); + void toggleUnderlineLinks(bool); void setCursorShape(int); void autoCursorColor(); diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui index 0072f826..efaa0b41 100644 --- a/src/EditProfileDialog.ui +++ b/src/EditProfileDialog.ui @@ -961,6 +961,16 @@ + + + + Text recognized as a link or an email address will be underlined when hovered by the mouse pointer. + + + Underline links + + + diff --git a/src/Profile.cpp b/src/Profile.cpp index 47e45fcf..9636bd48 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -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); diff --git a/src/Profile.h b/src/Profile.h index 8aa6dfce..3879d53b 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -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 */ diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index eb909aa5..11697bbb 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -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(); diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index 38e3e94b..61de0389 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -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; diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 89d019e3..c33e5369 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -867,6 +867,8 @@ void ViewManager::applyProfile(TerminalDisplay* view , const Profile::Ptr info, bool tripleClickMode = info->property(Profile::TripleClickMode); view->setTripleClickMode(tripleClickMode ? TerminalDisplay::SelectForwardsFromCursor : TerminalDisplay::SelectWholeLine); + + view->setUnderlineLinks(info->property(Profile::UnderlineLinksEnabled)); bool bidiEnabled = info->property(Profile::BidiRenderingEnabled); view->setBidiEnabled(bidiEnabled);