From 1c73d22eef610e83f31eb1823b5d3737defa4fb8 Mon Sep 17 00:00:00 2001 From: drbob Date: Mon, 31 Mar 2008 21:02:12 +0000 Subject: [PATCH] Added check to catch to ChatDialog and PopupChatDialog. Removed Save Check on ChanMsgDialog. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@451 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ChatDialog.cpp | 24 +++++++++++++++++-- retroshare-gui/src/gui/ChatDialog.h | 1 + .../src/gui/chat/PopupChatDialog.cpp | 23 ++++++++++++++++++ retroshare-gui/src/gui/chat/PopupChatDialog.h | 3 ++- retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp | 12 +++++++++- 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/ChatDialog.cpp b/retroshare-gui/src/gui/ChatDialog.cpp index a58de7a56..8ad41c6f4 100644 --- a/retroshare-gui/src/gui/ChatDialog.cpp +++ b/retroshare-gui/src/gui/ChatDialog.cpp @@ -57,6 +57,7 @@ ChatDialog::ChatDialog(QWidget *parent) setWindowIcon(QIcon(QString(":/images/rstray3.png"))); //connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendMsg( ) )); + connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg())); connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) ); @@ -162,8 +163,27 @@ void ChatDialog::insertChat() } } - - +void ChatDialog::checkChat() +{ + /* if at the end of the text -> we can send it! */ + QTextEdit *chatWidget = ui.lineEdit; + std::string txt = chatWidget->toPlainText().toStdString(); + if ('\n' == txt[txt.length()-1]) + { + //std::cerr << "Found found at end of :" << txt << ": should send!"; + //std::cerr << std::endl; + if (txt.length()-1 == txt.find('\n')) /* only if on first line! */ + { + /* should remove last char ... */ + sendMsg(); + } + } + else + { + //std::cerr << "No found in :" << txt << ":"; + //std::cerr << std::endl; + } +} void ChatDialog::sendMsg() { diff --git a/retroshare-gui/src/gui/ChatDialog.h b/retroshare-gui/src/gui/ChatDialog.h index 7a02d44a5..af021252a 100644 --- a/retroshare-gui/src/gui/ChatDialog.h +++ b/retroshare-gui/src/gui/ChatDialog.h @@ -58,6 +58,7 @@ void toggleSendItem( QTreeWidgetItem *item, int col ); void setColor(); void insertSendList(); + void checkChat(); void sendMsg(); void privchat(); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 003aa6859..5f4e5a1d0 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -61,6 +61,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); //connect(ui.chattextEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendChat( ) )); + connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) )); @@ -206,6 +207,28 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci) qsb -> setValue(qsb->maximum()); } +void PopupChatDialog::checkChat() +{ + /* if at the end of the text -> we can send it! */ + QTextEdit *chatWidget = ui.chattextEdit; + std::string txt = chatWidget->toPlainText().toStdString(); + if ('\n' == txt[txt.length()-1]) + { + //std::cerr << "Found found at end of :" << txt << ": should send!"; + //std::cerr << std::endl; + if (txt.length()-1 == txt.find('\n')) /* only if on first line! */ + { + /* should remove last char ... */ + sendChat(); + } + } + else + { + //std::cerr << "No found in :" << txt << ":"; + //std::cerr << std::endl; + } +} + void PopupChatDialog::sendChat() { diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index b7eb84c49..4bea9941f 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -73,7 +73,8 @@ private slots: void setColor(); void getFont(); void setFont(); - + + void checkChat(); void sendChat(); diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp index f64d3f92f..9a5eb40f6 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp @@ -232,6 +232,14 @@ void ChanMsgDialog::channelstreeViewCostumPopupMenu( QPoint point ) void ChanMsgDialog::closeEvent (QCloseEvent * event) { + event->accept(); + return; + + /* We can save to Drafts.... but we'll do this later. + * ... no auto saving for the moment, + */ + +#if 0 if (maybeSave()) { event->accept(); @@ -243,7 +251,9 @@ void ChanMsgDialog::closeEvent (QCloseEvent * event) RshareSettings config; config.saveWidgetInformation(this); - } + } +#endif + } void ChanMsgDialog::deletechannel()