Last active
August 29, 2015 14:22
-
-
Save anongit/7dd65997f604096ac469 to your computer and use it in GitHub Desktop.
Patches for Konsole 2.14.2 (KDE 4.14.2) and 15.08.0 (KF 5.12.0) to add customizable margins. Original patch: https://git.reviewboard.kde.org/r/109891/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ee719ac4af813f1474c2c215a1c01a0f517c2011 Mon Sep 17 00:00:00 2001 | |
From: anongit <anongit@users.noreply.github.com> | |
Date: Mon, 3 Aug 2015 20:46:53 +0500 | |
Subject: [PATCH] Add customizable display's contents margins | |
--- | |
src/EditProfileDialog.cpp | 10 +++++++++ | |
src/EditProfileDialog.h | 1 + | |
src/EditProfileDialog.ui | 57 ++++++++++++++++++++++++++++++++--------------- | |
src/Profile.cpp | 2 ++ | |
src/Profile.h | 8 +++++++ | |
src/ViewManager.cpp | 2 +- | |
6 files changed, 61 insertions(+), 19 deletions(-) | |
diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp | |
index 62b72f3..2e90af8 100644 | |
--- a/src/EditProfileDialog.cpp | |
+++ b/src/EditProfileDialog.cpp | |
@@ -1094,6 +1094,12 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile) | |
connect(_ui->lineSpacingSpinner, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::lineSpacingChanged); | |
+ // margins | |
+ const int margin = profile->margin(); | |
+ _ui->margin->setValue(margin); | |
+ | |
+ connect(_ui->margin, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::marginChanged); | |
+ | |
// cursor options | |
if (profile->useCustomCursorColor()) | |
_ui->customCursorColorButton->setChecked(true); | |
@@ -1156,6 +1162,10 @@ void EditProfileDialog::lineSpacingChanged(int spacing) | |
{ | |
updateTempProfileProperty(Profile::LineSpacing, spacing); | |
} | |
+void EditProfileDialog::marginChanged(int value) | |
+{ | |
+ updateTempProfileProperty(Profile::Margin, value); | |
+} | |
void EditProfileDialog::toggleBlinkingCursor(bool enable) | |
{ | |
updateTempProfileProperty(Profile::BlinkingCursorEnabled, enable); | |
diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h | |
index 5fed35d..3d13ec6 100644 | |
--- a/src/EditProfileDialog.h | |
+++ b/src/EditProfileDialog.h | |
@@ -170,6 +170,7 @@ private slots: | |
void toggleFlowControl(bool); | |
void togglebidiRendering(bool); | |
void lineSpacingChanged(int); | |
+ void marginChanged(int); | |
void toggleBlinkingCursor(bool); | |
void setCursorShape(int); | |
diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui | |
index dc5af01..9f9d326 100644 | |
--- a/src/EditProfileDialog.ui | |
+++ b/src/EditProfileDialog.ui | |
@@ -1107,24 +1107,45 @@ | |
<item> | |
<layout class="QHBoxLayout" name="horizontalLayout"> | |
<item> | |
- <widget class="QLabel" name="lineSpacingLabel"> | |
- <property name="text"> | |
- <string>Line Spacing:</string> | |
- </property> | |
- </widget> | |
- </item> | |
- <item> | |
- <widget class="QSpinBox" name="lineSpacingSpinner"> | |
- <property name="toolTip"> | |
- <string>The number of pixels between two lines</string> | |
- </property> | |
- <property name="minimum"> | |
- <number>0</number> | |
- </property> | |
- <property name="maximum"> | |
- <number>5</number> | |
- </property> | |
- </widget> | |
+ <layout class="QGridLayout"> | |
+ <item row="0" column="0"> | |
+ <widget class="QLabel" name="lineSpacingLabel"> | |
+ <property name="text"> | |
+ <string>Line Spacing:</string> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="0" column="1" colspan="1"> | |
+ <widget class="QSpinBox" name="lineSpacingSpinner"> | |
+ <property name="toolTip"> | |
+ <string>The number of pixels between two lines</string> | |
+ </property> | |
+ <property name="minimum"> | |
+ <number>0</number> | |
+ </property> | |
+ <property name="maximum"> | |
+ <number>5</number> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="1" column="0"> | |
+ <widget class="QLabel" name="marginLabel"> | |
+ <property name="text"> | |
+ <string>Margin Size:</string> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="1" column="1" colspan="1"> | |
+ <widget class="QSpinBox" name="margin"> | |
+ <property name="toolTip"> | |
+ <string>The minimum number of pixels between the window edges and the terminal's contents</string> | |
+ </property> | |
+ <property name="maximum"> | |
+ <number>99</number> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ </layout> | |
</item> | |
<item> | |
<spacer name="horizontalSpacer_11"> | |
diff --git a/src/Profile.cpp b/src/Profile.cpp | |
index 666cc4f..960cac1 100644 | |
--- a/src/Profile.cpp | |
+++ b/src/Profile.cpp | |
@@ -78,6 +78,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = { | |
, { AntiAliasFonts, "AntiAliasFonts" , APPEARANCE_GROUP , QVariant::Bool } | |
, { BoldIntense, "BoldIntense", APPEARANCE_GROUP, QVariant::Bool } | |
, { LineSpacing , "LineSpacing" , APPEARANCE_GROUP , QVariant::Int } | |
+ , { Margin , "Margin" , APPEARANCE_GROUP , QVariant::Int } | |
// Keyboard | |
, { KeyBindings , "KeyBindings" , KEYBOARD_GROUP , QVariant::String } | |
@@ -185,6 +186,7 @@ FallbackProfile::FallbackProfile() | |
setProperty(BlinkingCursorEnabled, false); | |
setProperty(BidiRenderingEnabled, true); | |
setProperty(LineSpacing, 0); | |
+ setProperty(Margin, 1); | |
setProperty(CursorShape, Enum::BlockCursor); | |
setProperty(UseCustomCursorColor, false); | |
setProperty(CustomCursorColor, QColor(Qt::black)); | |
diff --git a/src/Profile.h b/src/Profile.h | |
index 8061b97..8f62732 100644 | |
--- a/src/Profile.h | |
+++ b/src/Profile.h | |
@@ -163,6 +163,9 @@ public: | |
/** (int) Specifies the pixels between the terminal lines. | |
*/ | |
LineSpacing, | |
+ /** (int) Specifies the contents margin. | |
+ */ | |
+ Margin, | |
/** (bool) Specifies whether the cursor blinks ( in a manner similar | |
* to text editing applications ) | |
*/ | |
@@ -408,6 +411,11 @@ public: | |
return property<bool>(Profile::BidiRenderingEnabled); | |
} | |
+ /** Convenience method for property<int>(Profile::Margin) */ | |
+ int margin() const { | |
+ return property<int>(Profile::Margin); | |
+ } | |
+ | |
/** Convenience method for property<bool>(Profile::LineSpacing) */ | |
int lineSpacing() const { | |
return property<int>(Profile::LineSpacing); | |
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp | |
index ed3ece2..49c1b18 100644 | |
--- a/src/ViewManager.cpp | |
+++ b/src/ViewManager.cpp | |
@@ -823,7 +823,7 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr | |
view->setMiddleClickPasteMode(Enum::PasteFromClipboard); | |
// margin/center - these are hard-fixed ATM | |
- view->setMargin(1); | |
+ view->setMargin(profile->margin()); | |
view->setCenterContents(false); | |
// cursor shape | |
-- | |
2.4.6 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ecc22e4364dbfeae7a107297d03dc32b9b27c98c Mon Sep 17 00:00:00 2001 | |
From: anongit <anongit@users.noreply.github.com> | |
Date: Sat, 6 Jun 2015 02:06:26 +0500 | |
Subject: [PATCH] Add customizable display's contents margins | |
--- | |
src/EditProfileDialog.cpp | 10 +++++ | |
src/EditProfileDialog.h | 1 + | |
src/EditProfileDialog.ui | 97 ++++++++++++++++++++++++++++++----------------- | |
src/Profile.cpp | 3 ++ | |
src/Profile.h | 8 ++++ | |
src/ViewManager.cpp | 2 +- | |
6 files changed, 85 insertions(+), 36 deletions(-) | |
diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp | |
index 97c2fd7..932ee6b 100644 | |
--- a/src/EditProfileDialog.cpp | |
+++ b/src/EditProfileDialog.cpp | |
@@ -1110,6 +1110,12 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile) | |
connect(_ui->cursorShapeCombo, SIGNAL(activated(int)), this, SLOT(setCursorShape(int))); | |
+ // margins | |
+ const int margin = profile->margin(); | |
+ _ui->margin->setValue(margin); | |
+ | |
+ connect(_ui->margin, SIGNAL(valueChanged(int)), this, SLOT(marginChanged(int))); | |
+ | |
// encoding options | |
QAction* codecAction = new KCodecAction(this); | |
_ui->selectEncodingButton->setMenu(codecAction->menu()); | |
@@ -1155,6 +1161,10 @@ void EditProfileDialog::lineSpacingChanged(int spacing) | |
{ | |
updateTempProfileProperty(Profile::LineSpacing, spacing); | |
} | |
+void EditProfileDialog::marginChanged(int value) | |
+{ | |
+ updateTempProfileProperty(Profile::Margin, value); | |
+} | |
void EditProfileDialog::toggleBlinkingCursor(bool enable) | |
{ | |
updateTempProfileProperty(Profile::BlinkingCursorEnabled, enable); | |
diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h | |
index a72c01e..9bf94e0 100644 | |
--- a/src/EditProfileDialog.h | |
+++ b/src/EditProfileDialog.h | |
@@ -171,6 +171,7 @@ private slots: | |
void togglebidiRendering(bool); | |
void lineSpacingChanged(int); | |
void toggleBlinkingCursor(bool); | |
+ void marginChanged(int); | |
void setCursorShape(int); | |
void autoCursorColor(); | |
diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui | |
index e2314e8..52cb14b 100644 | |
--- a/src/EditProfileDialog.ui | |
+++ b/src/EditProfileDialog.ui | |
@@ -1105,41 +1105,68 @@ | |
</widget> | |
</item> | |
<item> | |
- <layout class="QHBoxLayout" name="horizontalLayout"> | |
- <item> | |
- <widget class="QLabel" name="lineSpacingLabel"> | |
- <property name="text"> | |
- <string>Line Spacing:</string> | |
- </property> | |
- </widget> | |
- </item> | |
- <item> | |
- <widget class="KIntSpinBox" name="lineSpacingSpinner"> | |
- <property name="toolTip"> | |
- <string>The number of pixels between two lines</string> | |
- </property> | |
- <property name="minimum"> | |
- <number>0</number> | |
- </property> | |
- <property name="maximum"> | |
- <number>5</number> | |
- </property> | |
- </widget> | |
- </item> | |
- <item> | |
- <spacer name="horizontalSpacer_11"> | |
- <property name="orientation"> | |
- <enum>Qt::Horizontal</enum> | |
- </property> | |
- <property name="sizeHint" stdset="0"> | |
- <size> | |
- <width>40</width> | |
- <height>20</height> | |
- </size> | |
- </property> | |
- </spacer> | |
- </item> | |
- </layout> | |
+ <layout class="QHBoxLayout"> | |
+ <item> | |
+ <layout class="QGridLayout"> | |
+ <item row="0" column="0"> | |
+ <widget class="QLabel" name="lineSpacingLabel"> | |
+ <property name="text"> | |
+ <string>Line Spacing:</string> | |
+ </property> | |
+ <property name="alignment"> | |
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="0" column="1" colspan="1"> | |
+ <widget class="KIntSpinBox" name="lineSpacingSpinner"> | |
+ <property name="toolTip"> | |
+ <string>The number of pixels between two lines</string> | |
+ </property> | |
+ <property name="minimum"> | |
+ <number>0</number> | |
+ </property> | |
+ <property name="maximum"> | |
+ <number>5</number> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="1" column="0"> | |
+ <widget class="QLabel" name="marginLabel"> | |
+ <property name="text"> | |
+ <string>Margin Size:</string> | |
+ </property> | |
+ <property name="alignment"> | |
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ <item row="1" column="1" colspan="1"> | |
+ <widget class="KIntSpinBox" name="margin"> | |
+ <property name="toolTip"> | |
+ <string>The minimum number of pixels between the window edges and the terminal's contents</string> | |
+ </property> | |
+ <property name="maximum"> | |
+ <number>99</number> | |
+ </property> | |
+ </widget> | |
+ </item> | |
+ </layout> | |
+ </item> | |
+ <item> | |
+ <spacer> | |
+ <property name="orientation"> | |
+ <enum>Qt::Horizontal</enum> | |
+ </property> | |
+ <property name="sizeHint" stdset="0"> | |
+ <size> | |
+ <width>40</width> | |
+ <height>20</height> | |
+ </size> | |
+ </property> | |
+ </spacer> | |
+ </item> | |
+ </layout> | |
</item> | |
</layout> | |
</widget> | |
diff --git a/src/Profile.cpp b/src/Profile.cpp | |
index 90a8a33..b952b48 100644 | |
--- a/src/Profile.cpp | |
+++ b/src/Profile.cpp | |
@@ -78,6 +78,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = { | |
, { AntiAliasFonts, "AntiAliasFonts" , APPEARANCE_GROUP , QVariant::Bool } | |
, { BoldIntense, "BoldIntense", APPEARANCE_GROUP, QVariant::Bool } | |
, { LineSpacing , "LineSpacing" , APPEARANCE_GROUP , QVariant::Int } | |
+ , { Margin , "Margin" , APPEARANCE_GROUP , QVariant::Int } | |
// Keyboard | |
, { KeyBindings , "KeyBindings" , KEYBOARD_GROUP , QVariant::String } | |
@@ -190,6 +191,8 @@ FallbackProfile::FallbackProfile() | |
setProperty(CustomCursorColor, Qt::black); | |
setProperty(BellMode, Enum::NotifyBell); | |
+ setProperty(Margin, 1); | |
+ | |
setProperty(DefaultEncoding, QString(QTextCodec::codecForLocale()->name())); | |
setProperty(AntiAliasFonts, true); | |
setProperty(BoldIntense, true); | |
diff --git a/src/Profile.h b/src/Profile.h | |
index 97548bd..3a99f5d 100644 | |
--- a/src/Profile.h | |
+++ b/src/Profile.h | |
@@ -163,6 +163,9 @@ public: | |
* Ctrl+Q) have any effect. Also known as Xon/Xoff | |
*/ | |
FlowControlEnabled, | |
+ /** (int) Specifies the contents margin. | |
+ */ | |
+ Margin, | |
/** (int) Specifies the pixels between the terminal lines. | |
*/ | |
LineSpacing, | |
@@ -411,6 +414,11 @@ public: | |
return property<bool>(Profile::BidiRenderingEnabled); | |
} | |
+ /** Convenience method for property<int>(Profile::Margin) */ | |
+ int margin() const { | |
+ return property<int>(Profile::Margin); | |
+ } | |
+ | |
/** Convenience method for property<bool>(Profile::LineSpacing) */ | |
int lineSpacing() const { | |
return property<int>(Profile::LineSpacing); | |
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp | |
index 697ec99..040051e 100644 | |
--- a/src/ViewManager.cpp | |
+++ b/src/ViewManager.cpp | |
@@ -854,7 +854,7 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr | |
view->setMiddleClickPasteMode(Enum::PasteFromClipboard); | |
// margin/center - these are hard-fixed ATM | |
- view->setMargin(1); | |
+ view->setMargin(profile->margin()); | |
view->setCenterContents(false); | |
// cursor shape | |
-- | |
2.1.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment