Added modified patch from AC

- don't remove color and font when the last char is deleted from the chat text entry box

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5095 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-04-12 23:00:39 +00:00
parent 722bade918
commit f2f5d60a8a
4 changed files with 44 additions and 4 deletions

View File

@ -82,6 +82,7 @@ FriendsDialog::FriendsDialog(QWidget *parent)
}
last_status_send_time = 0 ;
inChatCharFormatChanged = false;
connect( ui.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage()));
connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar()));
@ -116,6 +117,8 @@ FriendsDialog::FriendsDialog(QWidget *parent)
connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));
connect(ui.lineEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
// reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear
connect(ui.lineEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged()));
connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
@ -276,6 +279,23 @@ void FriendsDialog::contextMenu(QPoint /*point*/)
delete(contextMnu);
}
void FriendsDialog::chatCharFormatChanged()
{
if (inChatCharFormatChanged) {
return;
}
inChatCharFormatChanged = true;
// Reset font and color before inserting a character if edit box is empty
// (color info disappears when the user deletes all text)
if (ui.lineEdit->toPlainText().isEmpty()) {
setColorAndFont();
}
inChatCharFormatChanged = false;
}
void FriendsDialog::updateDisplay()
{
}
@ -494,8 +514,6 @@ void FriendsDialog::sendMsg()
// QTextEdit::clear() does not reset the CharFormat if document contains hyperlinks that have been accessed.
ui.lineEdit->setCurrentCharFormat(QTextCharFormat ());
setColorAndFont();
/* redraw send list */
insertSendList();
}

View File

@ -74,6 +74,7 @@ protected:
private slots:
void pasteLink() ;
void contextMenu(QPoint) ;
void chatCharFormatChanged();
void on_actionClear_Chat_History_triggered();
void on_actionDelete_Chat_History_triggered();
@ -138,6 +139,7 @@ private:
QWidget *newsFeed;
QColor newsFeedTabColor;
QString newsFeedText;
bool inChatCharFormatChanged;
/** Qt Designer generated object */
Ui::FriendsDialog ui;

View File

@ -61,6 +61,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
peerStatus = 0;
isChatLobby = false;
firstShow = true;
inChatCharFormatChanged = false;
lastStatusSendTime = 0 ;
@ -86,6 +87,8 @@ ChatWidget::ChatWidget(QWidget *parent) :
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
connect(ui->chattextEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
// reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear
connect(ui->chattextEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged()));
ui->infoframe->setVisible(false);
ui->statusmessagelabel->hide();
@ -368,6 +371,23 @@ void ChatWidget::contextMenu(QPoint /*point*/)
delete(contextMnu);
}
void ChatWidget::chatCharFormatChanged()
{
if (inChatCharFormatChanged) {
return;
}
inChatCharFormatChanged = true;
// Reset font and color before inserting a character if edit box is empty
// (color info disappears when the user deletes all text)
if (ui->chattextEdit->toPlainText().isEmpty()) {
setColorAndFont();
}
inChatCharFormatChanged = false;
}
void ChatWidget::resetStatusBar()
{
ui->statusLabel->clear();
@ -422,8 +442,6 @@ void ChatWidget::sendChat()
// 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.
chatWidget->setCurrentCharFormat(QTextCharFormat ());
setColorAndFont();
}
void ChatWidget::on_closeInfoFrameButton_clicked()

View File

@ -98,6 +98,7 @@ protected:
private slots:
void pasteLink();
void contextMenu(QPoint);
void chatCharFormatChanged();
void fileHashingFinished(QList<HashedFile> hashedFiles);
@ -149,6 +150,7 @@ private:
RSStyle style;
bool firstShow;
bool inChatCharFormatChanged;
Ui::ChatWidget *ui;
};