[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:18:01 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=f180756

The following commit has been merged in the master branch:
commit f1807567da8e3487ec0fb726f9cd29a27017fd6b
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Fri Sep 24 02:06:36 2010 +0000

    Input Text Edit box resizes whilst typing.
    
    svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1178837
---
 lib/chattextedit.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/chattextedit.h   | 13 ++++++++++---
 lib/chatwindow.ui    | 15 ++++++++++++++-
 3 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/lib/chattextedit.cpp b/lib/chattextedit.cpp
index 885cd2d..9a87d2e 100644
--- a/lib/chattextedit.cpp
+++ b/lib/chattextedit.cpp
@@ -2,6 +2,9 @@
 #include <QMenu>
 #include <QContextMenuEvent>
 #include <QAction>
+#include <QDebug>
+#include <QTimer>
+
 
 class ChatTextEditPrivate
 {
@@ -11,6 +14,13 @@ class ChatTextEditPrivate
 ChatTextEdit::ChatTextEdit(QWidget *parent) :
     QTextEdit(parent)
 {
+    setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); // no need for horizontal scrollbar with this
+    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+    setMinimumHeight(0);
+
+    connect(this, SIGNAL(textChanged()), SLOT(recalculateSize()));
 }
 
 void ChatTextEdit::setFontBold(bool isBold)
@@ -32,3 +42,42 @@ void ChatTextEdit::contextMenuEvent(QContextMenuEvent *event)
     menu->exec(event->globalPos());
     delete menu;
 }
+
+//Size code based on LineEdit in PSI
+//Justin Karneges, Michail Pishchagin
+
+QSize ChatTextEdit::minimumSizeHint() const
+{
+    QSize sh = QTextEdit::minimumSizeHint();
+    sh.setHeight(fontMetrics().height() + 1);
+    sh += QSize(0, QFrame::lineWidth() * 2);
+    return sh;
+}
+
+QSize ChatTextEdit::sizeHint() const
+{
+    QSize sh = QTextEdit::sizeHint();
+    sh.setHeight(int(document()->size().height()));
+    sh += QSize(0, (QFrame::lineWidth() * 2) + 1);
+    ((QTextEdit*)this)->setMaximumHeight(sh.height());
+
+    return sh;
+}
+
+void ChatTextEdit::resizeEvent(QResizeEvent* e)
+{
+        QTextEdit::resizeEvent(e);
+        QTimer::singleShot(0, this, SLOT(updateScrollBar()));
+}
+
+void ChatTextEdit::recalculateSize()
+{
+        updateGeometry();
+        QTimer::singleShot(0, this, SLOT(updateScrollBar()));
+}
+
+void ChatTextEdit::updateScrollBar()
+{
+        setVerticalScrollBarPolicy(sizeHint().height() > height() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
+        ensureCursorVisible();
+}
diff --git a/lib/chattextedit.h b/lib/chattextedit.h
index e43e8e0..115f47c 100644
--- a/lib/chattextedit.h
+++ b/lib/chattextedit.h
@@ -9,11 +9,18 @@ class ChatTextEdit : public QTextEdit
 public:
     explicit ChatTextEdit(QWidget *parent = 0);
 
-signals:
-
+    // reimplemented
+    QSize minimumSizeHint() const;
+    QSize sizeHint() const;
 
 protected:
-    void contextMenuEvent(QContextMenuEvent *e);
+    // reimplemented
+    void resizeEvent(QResizeEvent*);
+    void contextMenuEvent(QContextMenuEvent *);
+
+private slots:
+    void recalculateSize();
+    void updateScrollBar();
 
 public slots:
     /** wraps setFontWeight to a simple on/off bold) */
diff --git a/lib/chatwindow.ui b/lib/chatwindow.ui
index 90b04c5..06704e7 100644
--- a/lib/chatwindow.ui
+++ b/lib/chatwindow.ui
@@ -86,7 +86,20 @@
     </widget>
    </item>
    <item>
-    <widget class="ChatTextEdit" name="sendMessageBox"/>
+    <widget class="ChatTextEdit" name="sendMessageBox">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Sunken</enum>
+     </property>
+    </widget>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list