Split horizontal/vertical margin

wilder
Jacopo De Simoi 5 years ago committed by Jacopo De Simoi
parent 26c678e290
commit e212ba35af
  1. 15
      src/terminalDisplay/TerminalDisplay.cpp
  2. 5
      src/terminalDisplay/TerminalDisplay.h

@ -209,7 +209,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
// so the layout is forced to Left-To-Right // so the layout is forced to Left-To-Right
setLayoutDirection(Qt::LeftToRight); setLayoutDirection(Qt::LeftToRight);
_contentRect = QRect(_margin, _margin, 1, 1); _contentRect = QRect(_hmargin, _vmargin, 1, 1);
// create scroll bar for scrolling output up and down // create scroll bar for scrolling output up and down
_scrollBar = new TerminalScrollBar(this); _scrollBar = new TerminalScrollBar(this);
@ -1000,11 +1000,7 @@ void TerminalDisplay::calcGeometry()
contentsRect().height() - headerHeight // height contentsRect().height() - headerHeight // height
); );
_contentRect = contentsRect().adjusted( _contentRect = contentsRect().adjusted(_hmargin, _vmargin, -_hmargin, -_vmargin);
_margin + (_scrollBar->highlightScrolledLines().isEnabled() ? _scrollBar->highlightScrolledLines().HIGHLIGHT_SCROLLED_LINES_WIDTH : 0),
_margin,
-_margin - (_scrollBar->highlightScrolledLines().isEnabled() ? _scrollBar->highlightScrolledLines().HIGHLIGHT_SCROLLED_LINES_WIDTH : 0),
-_margin);
switch (_scrollBar->scrollBarPosition()) { switch (_scrollBar->scrollBarPosition()) {
case Enum::ScrollBarHidden: case Enum::ScrollBarHidden:
@ -1041,8 +1037,8 @@ void TerminalDisplay::calcGeometry()
void TerminalDisplay::setSize(int columns, int lines) void TerminalDisplay::setSize(int columns, int lines)
{ {
const int scrollBarWidth = _scrollBar->isHidden() ? 0 : _scrollBar->sizeHint().width(); const int scrollBarWidth = _scrollBar->isHidden() ? 0 : _scrollBar->sizeHint().width();
const int horizontalMargin = _margin * 2; const int horizontalMargin = _hmargin * 2;
const int verticalMargin = _margin * 2; const int verticalMargin = _vmargin * 2;
QSize newSize = QSize(horizontalMargin + scrollBarWidth + (columns * _terminalFont->fontWidth()), verticalMargin + (lines * _terminalFont->fontHeight())); QSize newSize = QSize(horizontalMargin + scrollBarWidth + (columns * _terminalFont->fontWidth()), verticalMargin + (lines * _terminalFont->fontHeight()));
@ -1077,7 +1073,8 @@ void TerminalDisplay::setMargin(int margin)
if (margin < 0) { if (margin < 0) {
margin = 0; margin = 0;
} }
_margin = margin; _hmargin = margin;
_vmargin = 1;
updateImageSize(); updateImageSize();
} }

@ -754,8 +754,9 @@ private:
bool _trimTrailingSpaces = false; // trim trailing spaces in selected text bool _trimTrailingSpaces = false; // trim trailing spaces in selected text
bool _mouseWheelZoom = false; // enable mouse wheel zooming or not bool _mouseWheelZoom = false; // enable mouse wheel zooming or not
int _margin = 1; // the contents margin int _hmargin = 1; // the contents margin
bool _centerContents = false; // center the contents between margins int _vmargin = 1; // the contents margin
bool _centerContents = false; // center the contents between margins
KMessageWidget *_readOnlyMessageWidget = nullptr; // Message shown at the top when read-only mode gets activated KMessageWidget *_readOnlyMessageWidget = nullptr; // Message shown at the top when read-only mode gets activated

Loading…
Cancel
Save