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

List:       kde-devel
Subject:    KIT patch...
From:       Whitehawk Stormchaser <zerokode () gmx ! net>
Date:       2002-12-02 23:50:40
[Download RAW message or body]

Greetings!
Neil: Here is the patch for KIt; It now allows the multi-line text with 
ctrl+enter as next line and fixed the output, which the one-line service 
didn't know how to handle right...

Have fun!
~W
-- 
fortune:
Nobody can be exactly like me.  Sometimes even I have trouble doing it.
-- Tallulah Bankhead
---------------------
KDE XMame Wrapper: The KMameleon Project
http://designs.stormspirit.net/kmameleon/

["kit_patched.diff" (text/x-diff)]

? kit_patched.diff
Index: tmessage.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kit/tmessage.cpp,v
retrieving revision 1.37
diff -u -r1.37 tmessage.cpp
--- tmessage.cpp	2002/11/06 21:30:24	1.37
+++ tmessage.cpp	2002/12/02 23:50:48
@@ -19,6 +19,8 @@
 #include <kpopupmenu.h>
 #include <kmessagebox.h>
 #include <klocale.h>
+#include <ktextedit.h>
+#include <kdebug.h>
 #include <qtextcodec.h>
 #include <qvbox.h>
 
@@ -202,11 +204,13 @@
 	QHBox *bottomRow = new QHBox(centralWidget);
 	editFore = new KColorButton(bottomRow);
 	editBack = new KColorButton(bottomRow);
-	edit = new KLineEdit(bottomRow);
-	bottomRow->setMinimumHeight(edit->sizeHint().height());
-	bottomRow->setMaximumHeight(edit->sizeHint().height());
-	editFore->setMaximumWidth(edit->sizeHint().height());
-	editBack->setMaximumWidth(edit->sizeHint().height());
+	edit = new KTextEdit(bottomRow);
+	edit->setMaximumHeight (40);
+	edit->setMaximumWidth (32767);
+	bottomRow->setMinimumHeight( 0/*edit->sizeHint().height()*/ );
+	bottomRow->setMaximumHeight(40/*edit->sizeHint().height()*/);
+	editFore->setMaximumWidth(25/*edit->sizeHint().height()*/);
+	editBack->setMaximumWidth(25/*edit->sizeHint().height()*/);
 	connect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
 	connect( editFore, SIGNAL(changed(const QColor &)), this, SLOT(forePressed2(const QColor &)) );
 	connect( editBack, SIGNAL(changed(const QColor &)), this, SLOT(backPressed2(const QColor &)) );
@@ -284,34 +288,43 @@
 // * class TMessage -- protected slots
 void TMessage::send(void)
 {
-	// avoid doubles
-	disconnect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
 	QString message = edit->text();
-	edit->clear();
-	connect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
-	// don't send empty messages
-	if(message == "") return;
-	// turn into AOL-HTML
-	if(isICQ)
+	if (message.stripWhiteSpace() !="" && ! lBreak)
 	{
-		emit messageOut(message, name, false);
-		updateHTML(message, myName, "FF0000", false);
+		// avoid doubles
+		disconnect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
+		edit->clear();
+		connect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
+		// don't send empty messages
+		if(message == "") return;
+		// turn into AOL-HTML
+		if(isICQ)
+		{
+			emit messageOut(message, name, false);
+			updateHTML(message, myName, "FF0000", false);
+		}
+		else
+		{
+			QString aolHTML;
+			aolHTML.sprintf("<HTML><BODY BGCOLOR=\"#%02X%02X%02X\"><FONT COLOR=\"#%02X%02X%02X\">",
+				back.red(), back.green(), back.blue(), fore.red(), fore.green(), fore.blue());
+			if(bold) aolHTML += "<B>";
+			aolHTML += parser(message);
+			if(bold) aolHTML += "</B>";
+			aolHTML += "</FONT></BODY></HTML>";
+			emit messageOut(aolHTML, name, false);
+			updateHTML(aolHTML, myName, "FF0000", false);
+		}
+		// press on
+		if(useSound)
+			KNotifyClient::event("Message Sent");
 	}
-	else
+	else if (message.stripWhiteSpace() =="" && ! lBreak)
 	{
-		QString aolHTML;
-		aolHTML.sprintf("<HTML><BODY BGCOLOR=\"#%02X%02X%02X\"><FONT COLOR=\"#%02X%02X%02X\">",
-			back.red(), back.green(), back.blue(), fore.red(), fore.green(), fore.blue());
-		if(bold) aolHTML += "<B>";
-		aolHTML += message;
-		if(bold) aolHTML += "</B>";
-		aolHTML += "</FONT></BODY></HTML>";
-		emit messageOut(aolHTML, name, false);
-		updateHTML(aolHTML, myName, "FF0000", false);
+		disconnect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
+		edit->clear();
+		connect(edit, SIGNAL(returnPressed()), this, SLOT(send()) );
 	}
-	// press on
-	if(useSound)
-		KNotifyClient::event("Message Sent");
 }
 void TMessage::sendAuto(void)
 {
@@ -543,6 +556,25 @@
 void TMessage::urlClicked(const QString &url)
 {
 	kapp->invokeBrowser(url);
+}
+
+void TMessage::keyPressEvent(QKeyEvent * ev)
+{
+        if (ev->key() == 4129)
+                lBreak = true;
+}
+
+void TMessage::keyReleaseEvent(QKeyEvent * ev)
+{
+        if (ev->key() == 4129)
+                lBreak = false;
+}
+
+QString TMessage::parser(QString str)
+{
+	QString tmp;
+	tmp = str.replace("\n","<br>");
+	return tmp;
 }
 
 #include "tmessage.moc"
Index: tmessage.h
===================================================================
RCS file: /home/kde/kdenetwork/kit/tmessage.h,v
retrieving revision 1.7
diff -u -r1.7 tmessage.h
--- tmessage.h	2001/06/24 01:24:01	1.7
+++ tmessage.h	2002/12/02 23:50:48
@@ -15,6 +15,7 @@
 class KAction;
 class KToggleAction;
 class KLineEdit;
+class KTextEdit;
 class QVBox;
 
 class TMessage : public KMainWindow
@@ -74,10 +75,12 @@
 	void openLogFile(void);
 	void initializeHTML(void);
 	void updateHTML(QString, QString, QString, bool);
+	QString parser(QString);
 
 	QVBox *centralWidget;
 	KHTMLPart *htmlpart;
-	KLineEdit *edit;
+//	KLineEdit *edit;
+	KTextEdit * edit;
 	KColorButton *editFore, *editBack;
 	KAction *aClear, *aClose, *aInfo, *aWarning, *aAnonWarning, *aFore, *aBack;
 	KToggleAction *aLogging, *aTimestamping, *aSound, *aBold, *aICQ;
@@ -93,6 +96,11 @@
 	QString conversationBuffer;
 	int conversationLength;
 	bool useSound;
+	bool lBreak;
+
+protected slots:
+	void keyReleaseEvent(QKeyEvent * );
+	void keyPressEvent(QKeyEvent * );
 };
 
 #endif

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

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

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