diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 9756c0319..57730fb4d 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -542,15 +542,9 @@ Enum::CursorShapeEnum TerminalDisplay::keyboardCursorShape() const { return _cursorShape; } -void TerminalDisplay::setKeyboardCursorColor(bool useForegroundColor, const QColor& color) +void TerminalDisplay::setKeyboardCursorColor(const QColor& color) { - if (useForegroundColor) { - // use an invalid color to indicate that the foreground color of - // the current character should be used to draw the cursor - _cursorColor = QColor(); - } else { - _cursorColor = color; - } + _cursorColor = color; } QColor TerminalDisplay::keyboardCursorColor() const { diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index 4ce55cc3e..f086ca088 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -209,14 +209,14 @@ public: * The keyboard cursor defaults to using the foreground color of the character * underneath it. * - * @param useForegroundColor If true, the cursor color will change to match - * the foreground color of the character underneath it as it is moved, in this - * case, the @p color parameter is ignored and the color of the character - * under the cursor is inverted to ensure that it is still readable. - * @param color The color to use to draw the cursor. This is only taken into - * account if @p useForegroundColor is false. + * @param color By default, the widget uses the color of the + * character under the cursor to draw the cursor, and inverts the + * color of that character to make sure it is still readable. If @p + * color is a valid QColor, the widget uses that color to draw the + * cursor. If @p color is not an valid QColor, the widget falls back + * to the default behavior. */ - void setKeyboardCursorColor(bool useForegroundColor , const QColor& color); + void setKeyboardCursorColor(const QColor& color); /** * Returns the color of the keyboard cursor, or an invalid color if the keyboard @@ -796,7 +796,7 @@ private: Enum::CursorShapeEnum _cursorShape; - // custom cursor color. if this is invalid then the foreground + // cursor color. If it is invalid (by default) then the foreground // color of the character under the cursor is used QColor _cursorColor; diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 062b17055..5699f30bc 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -826,10 +826,14 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr view->setKeyboardCursorShape(Enum::UnderlineCursor); // cursor color - bool useCustomColor = profile->useCustomCursorColor(); - const QColor& cursorColor = profile->customCursorColor(); - - view->setKeyboardCursorColor(!useCustomColor, cursorColor); + if ( profile->useCustomCursorColor() ) { + const QColor& cursorColor = profile->customCursorColor(); + view->setKeyboardCursorColor(cursorColor); + } else { + // an invalid QColor is used to inform the view widget to + // draw the cursor using the default color( matching the text) + view->setKeyboardCursorColor(QColor()); + } // word characters view->setWordCharacters(profile->wordCharacters());