mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
fixed font handling for chat config page (Patch from HM)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7826 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
64c8048981
commit
bef921f70c
@ -122,6 +122,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts()));
|
||||
|
||||
connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint)));
|
||||
|
||||
@ -235,7 +236,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
|
||||
currentFont.fromString(PeerSettings->getPrivateChatFont(chatId));
|
||||
|
||||
colorChanged();
|
||||
setColorAndFont();
|
||||
setColorAndFont(true);
|
||||
|
||||
// load style
|
||||
PeerSettings->getStyle(chatId, "ChatWidget", style);
|
||||
@ -780,7 +781,7 @@ void ChatWidget::pasteText(const QString& S)
|
||||
{
|
||||
//std::cerr << "In paste link" << std::endl;
|
||||
ui->chatTextEdit->insertHtml(S);
|
||||
setColorAndFont();
|
||||
setColorAndFont(false);
|
||||
}
|
||||
|
||||
void ChatWidget::pasteCreateMsgLink()
|
||||
@ -831,7 +832,7 @@ void ChatWidget::chatCharFormatChanged()
|
||||
// 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();
|
||||
setColorAndFont(false);
|
||||
}
|
||||
|
||||
inChatCharFormatChanged = false;
|
||||
@ -1136,7 +1137,7 @@ void ChatWidget::chooseColor()
|
||||
currentColor = QColor(color);
|
||||
PeerSettings->setPrivateChatColor(chatId, currentColor.name());
|
||||
colorChanged();
|
||||
setColorAndFont();
|
||||
setColorAndFont(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1163,10 +1164,24 @@ void ChatWidget::resetFont()
|
||||
setFont();
|
||||
}
|
||||
|
||||
void ChatWidget::setColorAndFont()
|
||||
void ChatWidget::resetFonts()
|
||||
{
|
||||
currentFont.fromString(Settings->getChatScreenFont());
|
||||
setColorAndFont(true);
|
||||
PeerSettings->setPrivateChatFont(chatId, currentFont.toString());
|
||||
}
|
||||
|
||||
void ChatWidget::setColorAndFont(bool both)
|
||||
{
|
||||
|
||||
ui->chatTextEdit->setFont(currentFont);
|
||||
QStringList fontdata=currentFont.toString().split(",");
|
||||
QString stylesheet="font-family: '"+fontdata[0]+"'; font-size: "+fontdata[1]+"pt;";
|
||||
if (currentFont.bold()) stylesheet+=" font-weight: bold;";
|
||||
if (currentFont.italic()) stylesheet+=" font-style: italic;";
|
||||
if (currentFont.underline()) stylesheet+=" text-decoration: underline;";
|
||||
if (both) ui->textBrowser->setStyleSheet(stylesheet);
|
||||
ui->chatTextEdit->setStyleSheet(stylesheet);
|
||||
ui->chatTextEdit->setTextColor(currentColor);
|
||||
|
||||
ui->chatTextEdit->setFocus();
|
||||
@ -1174,7 +1189,7 @@ void ChatWidget::setColorAndFont()
|
||||
|
||||
void ChatWidget::setFont()
|
||||
{
|
||||
setColorAndFont();
|
||||
setColorAndFont(false);
|
||||
PeerSettings->setPrivateChatFont(chatId, currentFont.toString());
|
||||
}
|
||||
|
||||
|
@ -160,6 +160,7 @@ private slots:
|
||||
void chooseColor();
|
||||
void chooseFont();
|
||||
void resetFont();
|
||||
void resetFonts();
|
||||
void setFont();
|
||||
|
||||
void updateLenOfChatTextEdit();
|
||||
@ -178,7 +179,7 @@ private:
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
void colorChanged();
|
||||
void setColorAndFont();
|
||||
void setColorAndFont(bool both);
|
||||
void processSettings(bool load);
|
||||
|
||||
void completeNickname(bool reverse);
|
||||
|
@ -1020,6 +1020,16 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyQt::notifyChatFontChanged()
|
||||
{
|
||||
{
|
||||
QMutexLocker m(&_mutex) ;
|
||||
if(!_enabled)
|
||||
return ;
|
||||
}
|
||||
|
||||
emit chatFontChanged();
|
||||
}
|
||||
void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType)
|
||||
{
|
||||
{
|
||||
|
@ -84,6 +84,7 @@ class NotifyQt: public QObject, public NotifyClient
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result) ;
|
||||
|
||||
/* Notify from GUI */
|
||||
void notifyChatFontChanged();
|
||||
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||
|
||||
void testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
@ -139,6 +140,7 @@ class NotifyQt: public QObject, public NotifyClient
|
||||
void chatLobbyTimeShift(int time_shift) ;
|
||||
|
||||
/* Notify from GUI */
|
||||
void chatFontChanged();
|
||||
void chatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||
void settingsChanged();
|
||||
void disableAllChanged(bool disableAll) const;
|
||||
|
@ -127,6 +127,7 @@ ChatPage::save(QString &/*errmsg*/)
|
||||
Settings->endGroup();
|
||||
|
||||
Settings->setChatScreenFont(fontTempChat.toString());
|
||||
NotifyQt::getInstance()->notifyChatFontChanged();
|
||||
|
||||
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
|
||||
|
||||
@ -245,8 +246,11 @@ ChatPage::load()
|
||||
ui.publicChatSaveCount->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_PUBLIC));
|
||||
ui.privateChatSaveCount->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_PRIVATE));
|
||||
ui.lobbyChatSaveCount->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_LOBBY));
|
||||
|
||||
ui.labelChatFontPreview->setText(fontTempChat.rawName());
|
||||
|
||||
// using fontTempChat.rawname() does not always work!
|
||||
// see http://doc.qt.digia.com/qt-maemo/qfont.html#rawName
|
||||
QStringList fontname = fontTempChat.toString().split(",");
|
||||
ui.labelChatFontPreview->setText(fontname[0]);
|
||||
ui.labelChatFontPreview->setFont(fontTempChat);
|
||||
|
||||
ui.max_storage_period->setValue(rsHistory->getMaxStorageDuration()/86400) ;
|
||||
@ -298,7 +302,10 @@ void ChatPage::on_pushButtonChangeChatFont_clicked()
|
||||
QFont font = QFontDialog::getFont(&ok, fontTempChat, this);
|
||||
if (ok) {
|
||||
fontTempChat = font;
|
||||
ui.labelChatFontPreview->setText(fontTempChat.rawName());
|
||||
// using fontTempChat.rawname() does not always work!
|
||||
// see http://doc.qt.digia.com/qt-maemo/qfont.html#rawName
|
||||
QStringList fontname = fontTempChat.toString().split(",");
|
||||
ui.labelChatFontPreview->setText(fontname[0]);
|
||||
ui.labelChatFontPreview->setFont(fontTempChat);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user