added storing and loading Chat Font

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2903 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-05-14 12:42:31 +00:00
parent bed286030e
commit 47de2af50c
5 changed files with 98 additions and 19 deletions

View File

@ -168,7 +168,8 @@ PeersDialog::PeersDialog(QWidget *parent)
pxm.fill(_currentColor);
ui.colorChatButton->setIcon(pxm);
mCurrentFont = QFont("Comic Sans MS", 11);
RshareSettings settings;
mCurrentFont.fromString(settings.value(QString::fromUtf8("ChatScreenFont")).toString());
ui.lineEdit->setFont(mCurrentFont);
setChatInfo(tr("Welcome to RetroShare's group chat."),
@ -176,7 +177,6 @@ PeersDialog::PeersDialog(QWidget *parent)
QStringList him;
RshareSettings settings;
if (settings.value(QString::fromUtf8("GroupChat_History"), true).toBool())
{
historyKeeper.getMessages(him, "", "THIS", 8);

View File

@ -40,13 +40,6 @@ ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
//connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
//connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs()));
//loadPublicKey();
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -56,7 +49,6 @@ ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags)
void
ChatPage::closeEvent (QCloseEvent * event)
{
QWidget::closeEvent(event);
}
@ -65,13 +57,13 @@ bool
ChatPage::save(QString &errmsg)
{
RshareSettings settings;
settings.setValue(QString::fromUtf8("Emoteicons_PrivatChat"), emotePrivatChat());
settings.setValue(QString::fromUtf8("Emoteicons_GroupChat"), emoteGroupChat());
settings.setValue(QString::fromUtf8("GroupChat_History"), groupchatHistory());
settings.setValue(QString::fromUtf8("ChatScreenFont"), fontTempChat.toString());
return true;
return true;
}
/** Loads the settings for this page */
@ -81,11 +73,13 @@ ChatPage::load()
RshareSettings settings;
ui.checkBox_emoteprivchat->setChecked(settings.value(QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool());
ui.checkBox_emotegroupchat->setChecked(settings.value(QString::fromUtf8("Emoteicons_GroupChat"), true).toBool());
ui.checkBox_groupchathistory->setChecked(settings.value(QString::fromUtf8("GroupChat_History"), true).toBool());
fontTempChat.fromString(settings.value(QString::fromUtf8("ChatScreenFont")).toString());
ui.labelChatFontPreview->setText(fontTempChat.rawName());
ui.labelChatFontPreview->setFont(fontTempChat);
}
bool ChatPage::emotePrivatChat() const {
@ -102,3 +96,14 @@ bool ChatPage::groupchatHistory() const {
if(ui.checkBox_groupchathistory->isChecked()) return true;
return ui.checkBox_groupchathistory->isChecked();
}
void ChatPage::on_pushButtonChangeChatFont_clicked()
{
bool ok;
QFont font = QFontDialog::getFont(&ok, fontTempChat, this);
if (ok) {
fontTempChat = font;
ui.labelChatFontPreview->setText(fontTempChat.rawName());
ui.labelChatFontPreview->setFont(fontTempChat);
}
}

View File

@ -42,18 +42,18 @@ class ChatPage : public ConfigPage
bool save(QString &errmsg);
/** Loads the settings for this page */
void load();
bool emotePrivatChat() const;
bool emoteGroupChat() const;
bool groupchatHistory() const;
private slots:
QFont fontTempChat;
private slots:
void on_pushButtonChangeChatFont_clicked();
private:
void closeEvent (QCloseEvent * event);
/** Qt Designer generated object */
Ui::ChatPage ui;

View File

@ -516,6 +516,79 @@
</property>
</widget>
</item>
<item row="0" column="1" rowspan="4">
<widget class="QGroupBox" name="groupBoxIRCColors">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="title">
<string>Chat Font</string>
</property>
<layout class="QGridLayout" name="gridLayout_47">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>2</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="pushButtonChangeChatFont">
<property name="text">
<string>Change Chat Font</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelChatFont">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Chat Font:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelChatFontPreview">
<property name="text">
<string>Font Preview</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_emotegroupchat">
<property name="text">

View File

@ -119,6 +119,7 @@ void RshareSettings::initSettings()
setDefault(SETTING_CHAT_FLAGS, defChat);
setDefault(SETTING_NOTIFY_FLAGS, defNotify);
setDefault(QString::fromUtf8("ChatScreenFont"), QFont("Comic Sans MS", 11).toString());
}
/** Gets/sets the currently saved chat avatar. */