void FriendsDialog::sendMsg() { QTextEdit *lineWidget = ui.lineEdit; if (lineWidget->toPlainText().isEmpty()) { // nothing to send return; } QString text; RsHtml::optimizeHtml(lineWidget, text); std::wstring message = text.toStdWString(); #ifdef FRIENDS_DEBUG std::string msg(message.begin(), message.end()); std::cerr << "FriendsDialog::sendMsg(): " << msg << std::endl; #endif rsMsgs->sendPublicChat(message); ui.lineEdit->clear(); // workaround for Qt bug - http://bugreports.qt.nokia.com/browse/QTBUG-2533 // QTextEdit::clear() does not reset the CharFormat if document contains hyperlinks that have been accessed. ui.lineEdit->setCurrentCharFormat(QTextCharFormat ()); /* redraw send list */ insertSendList(); }
void PeersDialog::sendMsg() { QTextEdit *lineWidget = ui.lineEdit; ChatInfo ci; //ci.msg = lineWidget->Text().toStdWString(); ci.msg = lineWidget->toHtml().toStdWString(); ci.chatflags = RS_CHAT_PUBLIC; //historyKeeper.addMessage("THIS", "ALL", lineWidget->toHtml() ); std::string msg(ci.msg.begin(), ci.msg.end()); #ifdef PEERS_DEBUG std::cerr << "PeersDialog::sendMsg(): " << msg << std::endl; #endif rsMsgs -> ChatSend(ci); ui.lineEdit->clear(); setFont(); /* redraw send list */ insertSendList(); }