Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 392c7d0f authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg

Remove dead code in TerminalDisplay

Summary:
A lot of methods that no one called, a lot of methods that the
only calee could be removed to a direct call.

Reviewers: #konsole, hindenburg, ngraham

Reviewed By: #konsole, hindenburg

Subscribers: sandsmark, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D18520
parent 7c831e18
......@@ -71,6 +71,8 @@
#include "Session.h"
#include "WindowSystemInfo.h"
#include "IncrementalSearchBar.h"
#include "Profile.h"
#include "ViewManager.h" // for colorSchemeForProfile. // TODO: Rewrite this.
using namespace Konsole;
......@@ -2981,7 +2983,7 @@ void TerminalDisplay::wheelEvent(QWheelEvent* ev)
const int modifiers = ev->modifiers();
// ctrl+<wheel> for zooming, like in konqueror and firefox
if (((modifiers & Qt::ControlModifier) != 0u) && mouseWheelZoom()) {
if (((modifiers & Qt::ControlModifier) != 0u) && _mouseWheelZoom) {
_scrollWheelState.addWheelEvent(ev);
int steps = _scrollWheelState.consumeLegacySteps(ScrollState::DEFAULT_ANGLE_SCROLL_LINE);
......@@ -4220,3 +4222,66 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event)
return false;
}
void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
{
// load color scheme
ColorEntry table[TABLE_COLORS];
_colorScheme = ViewManager::colorSchemeForProfile(profile);
_colorScheme->getColorTable(table, randomSeed());
setColorTable(table);
setOpacity(_colorScheme->opacity());
setWallpaper(_colorScheme->wallpaper());
// load font
_antialiasText = profile->antiAliasFonts();
_boldIntense = profile->boldIntense();
_useFontLineCharacters = profile->useFontLineCharacters();
setVTFont(profile->font());
// set scroll-bar position
setScrollBarPosition(Enum::ScrollBarPositionEnum(profile->property<int>(Profile::ScrollBarPosition)));
setScrollFullPage(profile->property<bool>(Profile::ScrollFullPage));
// show hint about terminal size after resizing
_showTerminalSizeHint = profile->showTerminalSizeHint();
_dimWhenInactive = profile->dimWhenInactive();
// terminal features
setBlinkingCursorEnabled(profile->blinkingCursorEnabled());
setBlinkingTextEnabled(profile->blinkingTextEnabled());
_tripleClickMode = Enum::TripleClickModeEnum(profile->property<int>(Profile::TripleClickMode));
setAutoCopySelectedText(profile->autoCopySelectedText());
_ctrlRequiredForDrag = profile->property<bool>(Profile::CtrlRequiredForDrag);
_dropUrlsAsText = profile->property<bool>(Profile::DropUrlsAsText);
_bidiEnabled = profile->bidiRenderingEnabled();
setLineSpacing(uint(profile->lineSpacing()));
_trimLeadingSpaces = profile->property<bool>(Profile::TrimLeadingSpacesInSelectedText);
_trimTrailingSpaces = profile->property<bool>(Profile::TrimTrailingSpacesInSelectedText);
_openLinksByDirectClick = profile->property<bool>(Profile::OpenLinksByDirectClickEnabled);
_urlHintsModifiers = Qt::KeyboardModifiers(profile->property<int>(Profile::UrlHintsModifiers));
_reverseUrlHints = profile->property<bool>(Profile::ReverseUrlHints);
setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum(profile->property<int>(Profile::MiddleClickPasteMode)));
setCopyTextAsHTML(profile->property<bool>(Profile::CopyTextAsHTML));
// margin/center
setMargin(profile->property<int>(Profile::TerminalMargin));
setCenterContents(profile->property<bool>(Profile::TerminalCenter));
// cursor shape
setKeyboardCursorShape(Enum::CursorShapeEnum(profile->property<int>(Profile::CursorShape)));
// cursor color
// an invalid QColor is used to inform the view widget to
// draw the cursor using the default color( matching the text)
setKeyboardCursorColor(profile->useCustomCursorColor() ? profile->customCursorColor() : QColor());
// word characters
setWordCharacters(profile->wordCharacters());
// bell mode
setBellMode(profile->property<int>(Profile::BellMode));
// mouse wheel zoom
_mouseWheelZoom = profile->mouseWheelZoomEnabled();
setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling));
}
......@@ -33,6 +33,7 @@
#include "ColorScheme.h"
#include "Enumeration.h"
#include "ScrollState.h"
#include "Profile.h"
class QDrag;
class QDragEnterEvent;
......@@ -53,6 +54,7 @@ class FilterChain;
class TerminalImageFilterChain;
class SessionController;
class IncrementalSearchBar;
/**
* A widget which displays output from a terminal emulation and sends input keypresses and mouse activity
* to the terminal.
......@@ -71,6 +73,8 @@ public:
explicit TerminalDisplay(QWidget *parent = nullptr);
~TerminalDisplay() Q_DECL_OVERRIDE;
void applyProfile(const Profile::Ptr& profile);
/** Returns the terminal color palette used by the display. */
const ColorEntry *colorTable() const;
/** Sets the terminal color palette used by the display. */
......@@ -97,10 +101,6 @@ public:
* is shown on the left or right side of the display.
*/
void setScrollBarPosition(Enum::ScrollBarPositionEnum position);
Enum::ScrollBarPositionEnum scrollBarPosition() const
{
return _scrollbarLocation;
}
/**
* Sets the current position and range of the display's scroll bar.
......@@ -150,97 +150,10 @@ public:
/** Specifies whether or not the cursor can blink. */
void setBlinkingCursorEnabled(bool blink);
/** Returns true if the cursor is allowed to blink or false otherwise. */
bool blinkingCursorEnabled() const
{
return _allowBlinkingCursor;
}
/** Specifies whether or not text can blink. */
void setBlinkingTextEnabled(bool blink);
void setControlDrag(bool enable)
{
_ctrlRequiredForDrag = enable;
}
bool ctrlRequiredForDrag() const
{
return _ctrlRequiredForDrag;
}
void setDropUrlsAsText(bool enable)
{
_dropUrlsAsText = enable;
}
bool getDropUrlsAsText() const
{
return _dropUrlsAsText;
}
/** Sets how the text is selected when the user triple clicks within the display. */
void setTripleClickMode(Enum::TripleClickModeEnum mode)
{
_tripleClickMode = mode;
}
/** See setTripleClickSelectionMode() */
Enum::TripleClickModeEnum tripleClickMode() const
{
return _tripleClickMode;
}
/**
* Specifies whether links and email addresses should be opened when
* clicked with the mouse. Defaults to false.
*/
void setOpenLinksByDirectClick(bool value)
{
_openLinksByDirectClick = value;
}
/**
* Returns true if links and email addresses should be opened when
* clicked with the mouse.
*/
bool getOpenLinksByDirectClick() const
{
return _openLinksByDirectClick;
}
/**
* Sets whether leading spaces should be trimmed in selected text.
*/
void setTrimLeadingSpaces(bool enabled)
{
_trimLeadingSpaces = enabled;
}
/**
* Returns true if leading spaces should be trimmed in selected text.
*/
bool trimLeadingSpaces() const
{
return _trimLeadingSpaces;
}
/**
* Sets whether trailing spaces should be trimmed in selected text.
*/
void setTrimTrailingSpaces(bool enabled)
{
_trimTrailingSpaces = enabled;
}
/**
* Returns true if trailing spaces should be trimmed in selected text.
*/
bool trimTrailingSpaces() const
{
return _trimTrailingSpaces;
}
void setLineSpacing(uint);
uint lineSpacing() const;
......@@ -354,16 +267,6 @@ public:
* of a word ( in addition to letters and numbers ).
*/
void setWordCharacters(const QString &wc);
/**
* Returns the characters which are considered part of a word for the
* purpose of selecting words in the display with the mouse.
*
* @see setWordCharacters()
*/
QString wordCharacters() const
{
return _wordCharacters;
}
/**
* Sets the type of effect used to alert the user when a 'bell' occurs in the
......@@ -384,25 +287,6 @@ public:
/** Play a visual bell for prompt or warning. */
void visualBell();
/**
* Specified whether zoom terminal on Ctrl+mousewheel is enabled or not.
* Defaults to enabled.
*/
void setMouseWheelZoom(bool value)
{
_mouseWheelZoom = value;
}
/**
* Returns the whether zoom terminal on Ctrl+mousewheel is enabled.
*
* See setMouseWheelZoom()
*/
bool mouseWheelZoom()
{
return _mouseWheelZoom;
}
/** Returns the font used to draw characters in the display */
QFont getVTFont()
{
......@@ -424,114 +308,6 @@ public:
/** Reset the font size */
void resetFontSize();
/**
* Specified whether anti-aliasing of text in the terminal display
* is enabled or not. Defaults to enabled.
*/
void setAntialias(bool value)
{
_antialiasText = value;
}
/**
* Returns true if anti-aliasing of text in the terminal is enabled.
*/
bool antialias() const
{
return _antialiasText;
}
/**
* Specifies whether characters with intense colors should be rendered
* as bold. Defaults to true.
*/
void setBoldIntense(bool value)
{
_boldIntense = value;
}
/**
* Returns true if characters with intense colors are rendered in bold.
*/
bool getBoldIntense() const
{
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
* is being resized.
*/
void setShowTerminalSizeHint(bool on)
{
_showTerminalSizeHint = on;
}
/**
* Returns whether or not the current height and width of
* the terminal in lines and columns is displayed whilst the widget
* is being resized.
*/
bool showTerminalSizeHint() const
{
return _showTerminalSizeHint;
}
/**
* Sets the status of the BiDi rendering inside the terminal display.
* Defaults to disabled.
*/
void setBidiEnabled(bool set)
{
_bidiEnabled = set;
}
/**
* Returns the status of the BiDi rendering in this widget.
*/
bool isBidiEnabled() const
{
return _bidiEnabled;
}
/**
* Sets the modifiers that shows URL hints when they are pressed
* Defaults to disabled.
*/
void setUrlHintsModifiers(int modifiers)
{
_urlHintsModifiers = Qt::KeyboardModifiers(modifiers);
}
void setReverseUrlHintsEnabled(bool set)
{
_reverseUrlHints = set;
}
bool isReverseUrlHintsEnabled() const
{
return _reverseUrlHints;
}
/**
* Sets the terminal screen section which is displayed in this widget.
* When updateImage() is called, the display fetches the latest character image from the
......@@ -691,10 +467,16 @@ public Q_SLOTS:
void setCenterContents(bool enable);
/**
* Sets whether the background should change when the window loses focus
* Return the current color scheme
*/
void setDimWhenInactive(bool shouldDim) {
_dimWhenInactive = shouldDim;
ColorScheme const *colorScheme() const
{
return _colorScheme;
}
Enum::ScrollBarPositionEnum scrollBarPosition() const
{
return _scrollbarLocation;
}
// Used to show/hide the message widget
......@@ -1018,6 +800,7 @@ private:
QRgb _blendColor;
ColorScheme const* _colorScheme;
ColorSchemeWallpaper::Ptr _wallpaper;
// list of filters currently applied to the display. used for links and
......
......@@ -790,71 +790,9 @@ bool ViewManager::profileHasBlurEnabled(const Profile::Ptr &profile)
void ViewManager::applyProfileToView(TerminalDisplay *view, const Profile::Ptr &profile)
{
Q_ASSERT(profile);
view->applyProfile(profile);
emit updateWindowIcon();
// load color scheme
ColorEntry table[TABLE_COLORS];
const ColorScheme *colorScheme = colorSchemeForProfile(profile);
colorScheme->getColorTable(table, view->randomSeed());
view->setColorTable(table);
view->setOpacity(colorScheme->opacity());
view->setWallpaper(colorScheme->wallpaper());
emit blurSettingChanged(colorScheme->blur());
// load font
view->setAntialias(profile->antiAliasFonts());
view->setBoldIntense(profile->boldIntense());
view->setUseFontLineCharacters(profile->useFontLineCharacters());
view->setVTFont(profile->font());
// set scroll-bar position
view->setScrollBarPosition(Enum::ScrollBarPositionEnum(profile->property<int>(Profile::ScrollBarPosition)));
view->setScrollFullPage(profile->property<bool>(Profile::ScrollFullPage));
// show hint about terminal size after resizing
view->setShowTerminalSizeHint(profile->showTerminalSizeHint());
view->setDimWhenInactive(profile->dimWhenInactive());
// terminal features
view->setBlinkingCursorEnabled(profile->blinkingCursorEnabled());
view->setBlinkingTextEnabled(profile->blinkingTextEnabled());
view->setTripleClickMode(Enum::TripleClickModeEnum(profile->property<int>(Profile::TripleClickMode)));
view->setAutoCopySelectedText(profile->autoCopySelectedText());
view->setControlDrag(profile->property<bool>(Profile::CtrlRequiredForDrag));
view->setDropUrlsAsText(profile->property<bool>(Profile::DropUrlsAsText));
view->setBidiEnabled(profile->bidiRenderingEnabled());
view->setLineSpacing(profile->lineSpacing());
view->setTrimLeadingSpaces(profile->property<bool>(Profile::TrimLeadingSpacesInSelectedText));
view->setTrimTrailingSpaces(profile->property<bool>(Profile::TrimTrailingSpacesInSelectedText));
view->setOpenLinksByDirectClick(profile->property<bool>(Profile::OpenLinksByDirectClickEnabled));
view->setUrlHintsModifiers(profile->property<int>(Profile::UrlHintsModifiers));
view->setReverseUrlHintsEnabled(profile->property<bool>(Profile::ReverseUrlHints));
view->setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum(profile->property<int>(Profile::MiddleClickPasteMode)));
view->setCopyTextAsHTML(profile->property<bool>(Profile::CopyTextAsHTML));
// margin/center
view->setMargin(profile->property<int>(Profile::TerminalMargin));
view->setCenterContents(profile->property<bool>(Profile::TerminalCenter));
// cursor shape
view->setKeyboardCursorShape(Enum::CursorShapeEnum(profile->property<int>(Profile::CursorShape)));
// cursor color
// an invalid QColor is used to inform the view widget to
// draw the cursor using the default color( matching the text)
view->setKeyboardCursorColor(profile->useCustomCursorColor() ? profile->customCursorColor() : QColor());
// word characters
view->setWordCharacters(profile->wordCharacters());
// bell mode
view->setBellMode(profile->property<int>(Profile::BellMode));
// mouse wheel zoom
view->setMouseWheelZoom(profile->mouseWheelZoomEnabled());
view->setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling));
emit blurSettingChanged(view->colorScheme()->blur());
}
void ViewManager::updateViewsForSession(Session *session)
......
......@@ -80,12 +80,6 @@ public:
*/
void createView(TabbedViewContainer *tabWidget, Session *session);
/**
* Applies the view-specific settings associated with specified @p profile
* to the terminal display @p view.
*/
void applyProfileToView(TerminalDisplay *view, const Profile::Ptr &profile);
/**
* Return the main widget for the view manager which
* holds all of the views managed by this ViewManager instance.
......@@ -198,6 +192,10 @@ public:
*/
TabbedViewContainer *activeContainer();
void applyProfileToView(TerminalDisplay *view, const Profile::Ptr &profile);
static const ColorScheme *colorSchemeForProfile(const Profile::Ptr &profile);
Q_SIGNALS:
/** Emitted when the last view is removed from the view manager */
void empty();
......@@ -391,7 +389,6 @@ private:
Q_DISABLE_COPY(ViewManager)
void createView(Session *session, TabbedViewContainer *container, int index);
static const ColorScheme *colorSchemeForProfile(const Profile::Ptr &profile);
void setupActions();
......
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