[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [konsole] src: Allow profile to set margin and center flag
From:       Kurt Hindenburg <kurt.hindenburg () gmail ! com>
Date:       2016-09-17 2:01:16
Message-ID: E1bl4wO-0005ev-1C () code ! kde ! org
[Download RAW message or body]

Git commit 8e5a5b1ec1fb68e359319c9ce23a43c0434b836a by Kurt Hindenburg.
Committed on 17/09/2016 at 01:57.
Pushed by hindenburg into branch 'master'.

Allow profile to set margin and center flag

These 2 were hard coded - this allow them to be set in the profile.
There is currently no UI for these; add these to profile:

[General]
TerminalMargin=1
TerminalCenter=false

Thanks to Josef Kufner jk frozen doe net for patch

It appears the center flag doesn't work and perhaps hasn't for a long
time.

BUG: 346450

M  +4    -0    src/Profile.cpp
M  +14   -0    src/Profile.h
M  +3    -0    src/TerminalDisplay.cpp
M  +3    -3    src/ViewManager.cpp

http://commits.kde.org/konsole/8e5a5b1ec1fb68e359319c9ce23a43c0434b836a

diff --git a/src/Profile.cpp b/src/Profile.cpp
index a8cec60..b3a50e0 100644
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -71,6 +71,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
     , { SilenceSeconds, "SilenceSeconds" , GENERAL_GROUP , QVariant::Int }
     , { TerminalColumns, "TerminalColumns" , GENERAL_GROUP , QVariant::Int }
     , { TerminalRows, "TerminalRows" , GENERAL_GROUP , QVariant::Int }
+    , { TerminalMargin, "TerminalMargin" , GENERAL_GROUP , QVariant::Int }
+    , { TerminalCenter, "TerminalCenter" , GENERAL_GROUP , QVariant::Bool }
 
     // Appearance
     , { Font , "Font" , APPEARANCE_GROUP , QVariant::Font }
@@ -164,6 +166,8 @@ FallbackProfile::FallbackProfile()
     setProperty(SilenceSeconds, 10);
     setProperty(TerminalColumns, 80);
     setProperty(TerminalRows, 24);
+    setProperty(TerminalMargin, 1);
+    setProperty(TerminalCenter, false);
     setProperty(MouseWheelZoomEnabled, true);
 
     setProperty(KeyBindings, "default");
diff --git a/src/Profile.h b/src/Profile.h
index 84a0acc..3e3aebf 100644
--- a/src/Profile.h
+++ b/src/Profile.h
@@ -248,6 +248,10 @@ public:
          * In future, the format might be #.#.# to account for levels
          */
         MenuIndex,
+	/** (int) Margin width in pixels */
+	TerminalMargin,
+	/** (bool) Center terminal when there is a margin */
+	TerminalCenter,
         /** (bool) If true, mouse wheel scroll with Ctrl key pressed
          * increases/decreases the terminal font size.
          */
@@ -505,6 +509,16 @@ public:
         return property<int>(Profile::TerminalRows);
     }
 
+    /** Convenience method for property<int>(Profile::TerminalMargin) */
+    int terminalMargin() const {
+        return property<int>(Profile::TerminalMargin);
+    }
+
+    /** Convenience method for property<bool>(Profile::TerminalCenter) */
+    bool terminalCenter() const {
+        return property<bool>(Profile::TerminalCenter);
+    }
+
     /** Convenience method for property<QString>(Profile::MenuIndex) */
     QString menuIndex() const {
         return property<QString>(Profile::MenuIndex);
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index 3c4364c2d..edbdc43 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -1898,6 +1898,9 @@ void TerminalDisplay::hideEvent(QHideEvent*)
 
 void TerminalDisplay::setMargin(int margin)
 {
+    if (margin < 0) {
+        margin = 0;
+    }
     _margin = margin;
     updateImageSize();
 }
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index ba3b72e..e31041c 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -821,9 +821,9 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
     else if (middleClickPasteMode == Enum::PasteFromClipboard)
         view->setMiddleClickPasteMode(Enum::PasteFromClipboard);
 
-    // margin/center - these are hard-fixed ATM
-    view->setMargin(1);
-    view->setCenterContents(false);
+    // margin/center
+    view->setMargin(profile->property<int>(Profile::TerminalMargin));
+    view->setCenterContents(profile->property<bool>(Profile::TerminalCenter));
 
     // cursor shape
     int cursorShape = profile->property<int>(Profile::CursorShape);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic