# HG changeset patch
# User Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
# Date 1394060219 -18000
# Branch gui-release
# Node ID a08804b3a044648dabb71208bf119fdfc15ee4d4
# Parent  89bd70fae066c90426e587fc5364906d373fc58e
changeset:   18548:a2d5c1144e89
branch:      gui-release
tag:         buffer
tag:         qbase
tag:         qtip
tag:         tip
parent:      18540:89bd70fae066
user:        Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com>
summary:     Adds history buffer size preference. Bugfix for bug#41474

diff -r 89bd70fae066 -r a08804b3a044 libgui/qterminal/libqterminal/QTerminal.cc
--- a/libgui/qterminal/libqterminal/QTerminal.cc	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/qterminal/libqterminal/QTerminal.cc	Thu Mar 06 03:56:59 2014 +0500
@@ -118,4 +118,5 @@
     (cursorUseForegroundColor,
      settings->value ("terminal/color_c",
                       QVariant (colors.at (3))).value<QColor> ());
+  setScrollBufferSize (settings->value ("terminal/history_buffer",1000).toInt() );
 }
diff -r 89bd70fae066 -r a08804b3a044 libgui/qterminal/libqterminal/QTerminal.h
--- a/libgui/qterminal/libqterminal/QTerminal.h	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/qterminal/libqterminal/QTerminal.h	Thu Mar 06 03:56:59 2014 +0500
@@ -80,7 +80,8 @@
 
   virtual void setCursorColor (bool useForegroundColor,
                                const QColor& color) = 0;
-
+  virtual void setScrollBufferSize(int value=1000) = 0;
+  
 signals:
 
   void report_status_message (const QString&);
diff -r 89bd70fae066 -r a08804b3a044 libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp
--- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp	Thu Mar 06 03:56:59 2014 +0500
@@ -69,13 +69,23 @@
     m_terminalModel = new TerminalModel(m_kpty);
     m_terminalModel->setAutoClose(true);
     m_terminalModel->setCodec(QTextCodec::codecForName("UTF-8"));
-    m_terminalModel->setHistoryType(HistoryTypeBuffer(1000));
+    m_terminalModel->setHistoryType(HistoryTypeBuffer (1000));
     m_terminalModel->setDarkBackground(true);
     m_terminalModel->setKeyBindings("");
     m_terminalModel->run();
     m_terminalModel->addView(m_terminalView);
     connectToPty();
 }
+void QUnixTerminalImpl::setScrollBufferSize(int value)
+{
+  if (value > 0)
+    {
+      m_terminalModel->clearHistory ();
+      m_terminalModel->setHistoryType (HistoryTypeBuffer ( value ));
+    }
+  else
+    m_terminalModel->setHistoryType (HistoryTypeNone ());
+}
 
 void QUnixTerminalImpl::connectToPty()
 {
@@ -208,4 +218,4 @@
 QString QUnixTerminalImpl::selectedText ()
 {
   return m_terminalView->selectedText ();
-}
+}
\ No newline at end of file
diff -r 89bd70fae066 -r a08804b3a044 libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h
--- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h	Thu Mar 06 03:56:59 2014 +0500
@@ -47,7 +47,7 @@
     void setForegroundColor (const QColor& color);
     void setSelectionColor (const QColor& color);
     void setCursorColor (bool useForegroundColor, const QColor& color);
-
+    void setScrollBufferSize(int value);
     QString selectedText();
 
 public slots:
diff -r 89bd70fae066 -r a08804b3a044 libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp
--- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp	Thu Mar 06 03:56:59 2014 +0500
@@ -1559,4 +1559,4 @@
 {
   QString selection = d->getSelection ();
   return selection;
-}
+}
\ No newline at end of file
diff -r 89bd70fae066 -r a08804b3a044 libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h
--- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h	Thu Mar 06 03:56:59 2014 +0500
@@ -60,7 +60,6 @@
   void setForegroundColor (const QColor& color);
   void setSelectionColor (const QColor& color);
   void setCursorColor (bool useForegoundColor, const QColor& color);
-
   QString selectedText ();
 
 public slots:
diff -r 89bd70fae066 -r a08804b3a044 libgui/src/settings-dialog.cc
--- a/libgui/src/settings-dialog.cc	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/src/settings-dialog.cc	Thu Mar 06 03:56:59 2014 +0500
@@ -191,6 +191,8 @@
     settings->value ("terminal/fontName","Courier New").toString ()) );
   ui->terminal_fontSize->setValue (
     settings->value ("terminal/fontSize", 10).toInt ());
+  ui->terminal_history_buffer->setValue (
+     settings->value ("terminal/history_buffer",1000).toInt ());
 
   // file browser
   ui->showFileSize->setChecked (
@@ -626,6 +628,8 @@
                       ui->terminal_cursorUseForegroundColor->isChecked ());
   settings->setValue ("terminal/focus_after_command",
                       ui->terminal_focus_command->isChecked ());
+  settings->setValue ("terminal/history_buffer",
+                      ui->terminal_history_buffer->value() );
 
   // the cursor
   QString cursorType;
diff -r 89bd70fae066 -r a08804b3a044 libgui/src/settings-dialog.ui
--- a/libgui/src/settings-dialog.ui	Tue Mar 04 10:49:31 2014 -0500
+++ b/libgui/src/settings-dialog.ui	Thu Mar 06 03:56:59 2014 +0500
@@ -32,7 +32,7 @@
       </size>
      </property>
      <property name="currentIndex">
-      <number>1</number>
+      <number>3</number>
      </property>
      <widget class="QWidget" name="tab_general">
       <property name="enabled">
@@ -1255,6 +1255,62 @@
                  </item>
                 </layout>
                </item>
+              <item row="2" column="2">
+                <layout class="QHBoxLayout" name="horizontalLayout_5">
+                 <property name="topMargin">
+                  <number>0</number>
+               </property>
+                 <item>
+                  <widget class="QSpinBox" name="terminal_history_buffer">
+                   <property name="minimum">
+                    <number>0</number>
+                   </property>
+                   <property name="maximum">
+                    <number>5000</number>
+                   </property>
+                   <property name="singleStep">
+                    <number>20</number>
+                   </property>
+                   <property name="value">
+                    <number>1000</number>
+                   </property>
+                 </widget>
+                 </item>
+                 <item>
+                  <widget class="QLabel" name="label_20">
+                   <property name="text">
+                    <string>(Changing buffer size clears history)</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item>
+                  <spacer name="horizontalSpacer_16">
+                   <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>
+               <item row="2" column="0">
+                <widget class="QLabel" name="label_19">
+                 <property name="minimumSize">
+                  <size>
+                   <width>100</width>
+                   <height>20</height>
+                  </size>
+                 </property>
+                 <property name="text">
+                  <string>History buffer Size</string>
+                 </property>
+                </widget>
+               </item>
                <item row="0" column="1">
                 <spacer name="horizontalSpacer_28">
                  <property name="orientation">
@@ -1271,19 +1327,12 @@
                  </property>
                 </spacer>
                </item>
-               <item row="1" column="3">
-                <spacer name="horizontalSpacer_26">
-                 <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>
              <item>
@@ -1340,6 +1389,9 @@
              <property name="orientation">
               <enum>Qt::Vertical</enum>
              </property>
+             <property name="sizeType">
+              <enum>QSizePolicy::Expanding</enum>
+             </property>
              <property name="sizeHint" stdset="0">
               <size>
                <width>20</width>
