Fixed font handling in PeersDialog.

Fixed Qt bug in PeersDialog and PopupChatDialog with a workaround.
- QTextEdit::clear() does not reset the CharFormat if document contains hyperlinks that have been accessed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3652 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-10-08 00:07:44 +00:00
parent f430fee12d
commit 0e063f9a1b
3 changed files with 50 additions and 37 deletions

View File

@ -174,14 +174,11 @@ PeersDialog::PeersDialog(QWidget *parent)
ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png"))); ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png")));
_currentColor = Qt::black; mCurrentColor = Qt::black;
QPixmap pxm(16,16);
pxm.fill(_currentColor);
ui.colorChatButton->setIcon(pxm);
mCurrentFont.fromString(Settings->getChatScreenFont()); mCurrentFont.fromString(Settings->getChatScreenFont());
ui.lineEdit->setFont(mCurrentFont);
colorChanged(mCurrentColor);
fontChanged(mCurrentFont);
style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC); style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC);
@ -203,8 +200,6 @@ PeersDialog::PeersDialog(QWidget *parent)
grpchatmenu->addAction(ui.actionMessageHistory); grpchatmenu->addAction(ui.actionMessageHistory);
ui.menuButton->setMenu(grpchatmenu); ui.menuButton->setMenu(grpchatmenu);
_underline = false;
QMenu *menu = new QMenu(); QMenu *menu = new QMenu();
menu->addAction(ui.actionAdd_Friend); menu->addAction(ui.actionAdd_Friend);
menu->addAction(ui.actionAdd_Group); menu->addAction(ui.actionAdd_Group);
@ -1499,6 +1494,10 @@ void PeersDialog::sendMsg()
rsMsgs->sendPublicChat(message); rsMsgs->sendPublicChat(message);
ui.lineEdit->clear(); 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 ());
setFont(); setFont();
/* redraw send list */ /* redraw send list */
@ -1598,22 +1597,39 @@ void PeersDialog::insertSendList()
void PeersDialog::setColor() void PeersDialog::setColor()
{ {
bool ok; bool ok;
QRgb color = QColorDialog::getRgba(ui.lineEdit->textColor().rgba(), &ok, this); QRgb color = QColorDialog::getRgba(ui.lineEdit->textColor().rgba(), &ok, this);
if (ok) { if (ok) {
_currentColor = QColor(color); mCurrentColor = QColor(color);
QPixmap pxm(16,16); colorChanged(mCurrentColor);
pxm.fill(_currentColor);
ui.colorChatButton->setIcon(pxm);
} }
setFont(); setFont();
} }
void PeersDialog::colorChanged(const QColor &c)
{
QPixmap pxm(16,16);
pxm.fill(mCurrentColor);
ui.colorChatButton->setIcon(pxm);
}
void PeersDialog::getFont() void PeersDialog::getFont()
{ {
bool ok; bool ok;
mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this); mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this);
if (ok) {
fontChanged(mCurrentFont);
}
}
void PeersDialog::fontChanged(const QFont &font)
{
mCurrentFont = font;
ui.textboldChatButton->setChecked(mCurrentFont.bold());
ui.textunderlineChatButton->setChecked(mCurrentFont.underline());
ui.textitalicChatButton->setChecked(mCurrentFont.italic());
setFont(); setFont();
} }
@ -1623,20 +1639,12 @@ void PeersDialog::setFont()
mCurrentFont.setUnderline(ui.textunderlineChatButton->isChecked()); mCurrentFont.setUnderline(ui.textunderlineChatButton->isChecked());
mCurrentFont.setItalic(ui.textitalicChatButton->isChecked()); mCurrentFont.setItalic(ui.textitalicChatButton->isChecked());
ui.lineEdit->setFont(mCurrentFont); ui.lineEdit->setFont(mCurrentFont);
ui.lineEdit->setTextColor(_currentColor); ui.lineEdit->setTextColor(mCurrentColor);
Settings->setChatScreenFont(mCurrentFont.toString()); Settings->setChatScreenFont(mCurrentFont.toString());
ui.lineEdit->setFocus(); ui.lineEdit->setFocus();
} }
void PeersDialog::underline()
{
_underline = !_underline;
ui.lineEdit->setFontUnderline(_underline);
}
// Update Chat Info information // Update Chat Info information
void PeersDialog::setChatInfo(QString info, QColor color) void PeersDialog::setChatInfo(QString info, QColor color)
{ {

View File

@ -144,7 +144,6 @@ private slots:
void setFont(); void setFont();
void getFont(); void getFont();
void underline();
void changeAvatarClicked(); void changeAvatarClicked();
void getAvatar(); void getAvatar();
@ -175,6 +174,9 @@ private:
void processSettings(bool bLoad); void processSettings(bool bLoad);
void addChatMsg(bool incoming, bool history, QString &name, QDateTime &recvTime, QString &message); void addChatMsg(bool incoming, bool history, QString &name, QDateTime &recvTime, QString &message);
void colorChanged(const QColor &c);
void fontChanged(const QFont &font);
class QLabel *iconLabel, *textLabel; class QLabel *iconLabel, *textLabel;
class QWidget *widget; class QWidget *widget;
class QWidgetAction *widgetAction; class QWidgetAction *widgetAction;
@ -201,8 +203,7 @@ private:
IMHistoryKeeper historyKeeper; IMHistoryKeeper historyKeeper;
ChatStyle style; ChatStyle style;
QColor _currentColor; QColor mCurrentColor;
bool _underline;
time_t last_status_send_time ; time_t last_status_send_time ;
QFont mCurrentFont; /* how the text will come out */ QFont mCurrentFont; /* how the text will come out */

View File

@ -761,6 +761,10 @@ void PopupChatDialog::sendChat()
} }
chatWidget->clear(); chatWidget->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.
chatWidget->setCurrentCharFormat(QTextCharFormat ());
setFont(); setFont();
/* redraw send list */ /* redraw send list */