mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
Fixed choose of the font in PopupChatDialog with the font dialog.
New class RsharePeerSettings and a global variable PeerSettings for read and write settings of a peer (gpg id). Save font and color in PopupChatDialog. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3464 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7c126f24ba
commit
cbdb717e51
12 changed files with 279 additions and 35 deletions
|
@ -250,6 +250,7 @@ HEADERS += rshare.h \
|
||||||
gui/msgs/textformat.h \
|
gui/msgs/textformat.h \
|
||||||
gui/images/retroshare_win.rc.h \
|
gui/images/retroshare_win.rc.h \
|
||||||
gui/settings/rsharesettings.h \
|
gui/settings/rsharesettings.h \
|
||||||
|
gui/settings/RsharePeerSettings.h \
|
||||||
gui/settings/rsettings.h \
|
gui/settings/rsettings.h \
|
||||||
gui/settings/rsettingswin.h \
|
gui/settings/rsettingswin.h \
|
||||||
gui/settings/GeneralPage.h \
|
gui/settings/GeneralPage.h \
|
||||||
|
@ -467,6 +468,7 @@ SOURCES += main.cpp \
|
||||||
gui/common/rwindow.cpp \
|
gui/common/rwindow.cpp \
|
||||||
gui/common/html.cpp \
|
gui/common/html.cpp \
|
||||||
gui/settings/rsharesettings.cpp \
|
gui/settings/rsharesettings.cpp \
|
||||||
|
gui/settings/RsharePeerSettings.cpp \
|
||||||
gui/settings/rsettings.cpp \
|
gui/settings/rsettings.cpp \
|
||||||
gui/settings/rsettingswin.cpp \
|
gui/settings/rsettingswin.cpp \
|
||||||
gui/settings/GeneralPage.cpp \
|
gui/settings/GeneralPage.cpp \
|
||||||
|
|
|
@ -199,7 +199,7 @@ PeersDialog::PeersDialog(QWidget *parent)
|
||||||
pxm.fill(_currentColor);
|
pxm.fill(_currentColor);
|
||||||
ui.colorChatButton->setIcon(pxm);
|
ui.colorChatButton->setIcon(pxm);
|
||||||
|
|
||||||
mCurrentFont.fromString(Settings->valueFromGroup("Chat", QString::fromUtf8("ChatScreenFont")).toString());
|
mCurrentFont.fromString(Settings->getChatScreenFont());
|
||||||
ui.lineEdit->setFont(mCurrentFont);
|
ui.lineEdit->setFont(mCurrentFont);
|
||||||
|
|
||||||
style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC);
|
style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC);
|
||||||
|
@ -1389,10 +1389,7 @@ void PeersDialog::setFont()
|
||||||
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(_currentColor);
|
||||||
Settings->beginGroup("Chat");
|
Settings->setChatScreenFont(mCurrentFont.toString());
|
||||||
Settings->setValue(QString::fromUtf8("ChatScreenFont"), mCurrentFont.toString());
|
|
||||||
Settings->endGroup();
|
|
||||||
|
|
||||||
|
|
||||||
ui.lineEdit->setFocus();
|
ui.lineEdit->setFocus();
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void ChatStyle::styleChanged(int styleType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatStyle::setStylePath(QString stylePath, QString styleVariant)
|
bool ChatStyle::setStylePath(const QString &stylePath, const QString &styleVariant)
|
||||||
{
|
{
|
||||||
m_styleType = TYPE_UNKNOWN;
|
m_styleType = TYPE_UNKNOWN;
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ static QString getBaseDir()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ bool ChatStyle::getAvailableVariants(QString stylePath, QStringList &variants)
|
/*static*/ bool ChatStyle::getAvailableVariants(const QString &stylePath, QStringList &variants)
|
||||||
{
|
{
|
||||||
variants.clear();
|
variants.clear();
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
/* Default destructor */
|
/* Default destructor */
|
||||||
~ChatStyle();
|
~ChatStyle();
|
||||||
|
|
||||||
bool setStylePath(QString stylePath, QString styleVariant);
|
bool setStylePath(const QString &stylePath, const QString &styleVariant);
|
||||||
bool setStyleFromSettings(enumStyleType styleType);
|
bool setStyleFromSettings(enumStyleType styleType);
|
||||||
void loadEmoticons();
|
void loadEmoticons();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod);
|
void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod);
|
||||||
static bool getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles);
|
static bool getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles);
|
||||||
static bool getAvailableVariants(QString stylePath, QStringList &variants);
|
static bool getAvailableVariants(const QString &stylePath, QStringList &variants);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void styleChanged(int styleType);
|
void styleChanged(int styleType);
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include <retroshare/rsstatus.h>
|
#include <retroshare/rsstatus.h>
|
||||||
#include <retroshare/rsiface.h>
|
#include <retroshare/rsiface.h>
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
#include "gui/settings/RsharePeerSettings.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "../RsAutoUpdatePage.h"
|
#include "../RsAutoUpdatePage.h"
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||||
//ui.textBrowser->setOpenExternalLinks ( false );
|
//ui.textBrowser->setOpenExternalLinks ( false );
|
||||||
//ui.textBrowser->setOpenLinks ( false );
|
//ui.textBrowser->setOpenLinks ( false );
|
||||||
|
|
||||||
QString title = tr("RetroShare - ") + QString::fromStdString(name) ;
|
QString title = tr("RetroShare - ") + QString::fromStdString(name);
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
setWindowIcon(QIcon(IMAGE_WINDOW));
|
setWindowIcon(QIcon(IMAGE_WINDOW));
|
||||||
|
@ -173,11 +174,11 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||||
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
||||||
ui.pushtoolsButton->setMenu(toolmenu);
|
ui.pushtoolsButton->setMenu(toolmenu);
|
||||||
|
|
||||||
mCurrentColor = Qt::black;
|
mCurrentColor.setNamedColor(PeerSettings->getPrivateChatColor(dialogId));
|
||||||
mCurrentFont = QFont("Comic Sans MS", 10);
|
mCurrentFont.fromString(PeerSettings->getPrivateChatFont(dialogId));
|
||||||
|
|
||||||
colorChanged(mCurrentColor);
|
colorChanged(mCurrentColor);
|
||||||
setFont();
|
fontChanged(mCurrentFont);
|
||||||
|
|
||||||
pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this );
|
pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this );
|
||||||
connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||||
|
@ -667,10 +668,11 @@ void PopupChatDialog::on_closeInfoFrameButton_clicked()
|
||||||
|
|
||||||
void PopupChatDialog::setColor()
|
void PopupChatDialog::setColor()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this);
|
QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
mCurrentColor = QColor(color);
|
mCurrentColor = QColor(color);
|
||||||
|
PeerSettings->setPrivateChatColor(dialogId, mCurrentColor.name());
|
||||||
colorChanged(mCurrentColor);
|
colorChanged(mCurrentColor);
|
||||||
}
|
}
|
||||||
setFont();
|
setFont();
|
||||||
|
@ -686,25 +688,35 @@ void PopupChatDialog::colorChanged(const QColor &c)
|
||||||
void PopupChatDialog::getFont()
|
void PopupChatDialog::getFont()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this);
|
QFont font = QFontDialog::getFont(&ok, mCurrentFont, this);
|
||||||
|
if (ok) {
|
||||||
|
fontChanged(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::fontChanged(const QFont &font)
|
||||||
|
{
|
||||||
|
mCurrentFont = font;
|
||||||
|
|
||||||
|
ui.textboldButton->setChecked(mCurrentFont.bold());
|
||||||
|
ui.textunderlineButton->setChecked(mCurrentFont.underline());
|
||||||
|
ui.textitalicButton->setChecked(mCurrentFont.italic());
|
||||||
|
|
||||||
setFont();
|
setFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::setFont()
|
void PopupChatDialog::setFont()
|
||||||
{
|
{
|
||||||
|
mCurrentFont.setBold(ui.textboldButton->isChecked());
|
||||||
|
mCurrentFont.setUnderline(ui.textunderlineButton->isChecked());
|
||||||
|
mCurrentFont.setItalic(ui.textitalicButton->isChecked());
|
||||||
|
|
||||||
// mCurrentFont.setBold(ui.textboldButton->isChecked());
|
ui.chattextEdit->setFont(mCurrentFont);
|
||||||
bool flag;
|
ui.chattextEdit->setTextColor(mCurrentColor);
|
||||||
flag=ui.textboldButton->isChecked();
|
|
||||||
mCurrentFont.setBold(flag);
|
|
||||||
mCurrentFont.setUnderline(ui.textunderlineButton->isChecked());
|
|
||||||
mCurrentFont.setItalic(ui.textitalicButton->isChecked());
|
|
||||||
|
|
||||||
ui.chattextEdit->setFont(mCurrentFont);
|
ui.chattextEdit->setFocus();
|
||||||
ui.chattextEdit->setTextColor(mCurrentColor);
|
|
||||||
|
|
||||||
ui.chattextEdit->setFocus();
|
|
||||||
|
|
||||||
|
PeerSettings->setPrivateChatFont(dialogId, mCurrentFont.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
|
@ -115,6 +115,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void colorChanged(const QColor &c);
|
void colorChanged(const QColor &c);
|
||||||
|
void fontChanged(const QFont &font);
|
||||||
void addAttachment(std::string,int flag);
|
void addAttachment(std::string,int flag);
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
|
|
||||||
|
|
|
@ -106,10 +106,10 @@ ChatPage::save(QString &errmsg)
|
||||||
Settings->setValue(QString::fromUtf8("Emoteicons_PrivatChat"), emotePrivatChat());
|
Settings->setValue(QString::fromUtf8("Emoteicons_PrivatChat"), emotePrivatChat());
|
||||||
Settings->setValue(QString::fromUtf8("Emoteicons_GroupChat"), emoteGroupChat());
|
Settings->setValue(QString::fromUtf8("Emoteicons_GroupChat"), emoteGroupChat());
|
||||||
Settings->setValue(QString::fromUtf8("GroupChat_History"), groupchatHistory());
|
Settings->setValue(QString::fromUtf8("GroupChat_History"), groupchatHistory());
|
||||||
Settings->setValue(QString::fromUtf8("ChatScreenFont"), fontTempChat.toString());
|
|
||||||
|
|
||||||
Settings->endGroup();
|
Settings->endGroup();
|
||||||
|
|
||||||
|
Settings->setChatScreenFont(fontTempChat.toString());
|
||||||
|
|
||||||
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
|
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
|
||||||
|
|
||||||
ChatStyleInfo info;
|
ChatStyleInfo info;
|
||||||
|
@ -153,10 +153,10 @@ ChatPage::load()
|
||||||
ui.checkBox_emotegroupchat->setChecked(Settings->value(QString::fromUtf8("Emoteicons_GroupChat"), 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());
|
ui.checkBox_groupchathistory->setChecked(Settings->value(QString::fromUtf8("GroupChat_History"), true).toBool());
|
||||||
|
|
||||||
fontTempChat.fromString(Settings->value(QString::fromUtf8("ChatScreenFont")).toString());
|
|
||||||
|
|
||||||
Settings->endGroup();
|
Settings->endGroup();
|
||||||
|
|
||||||
|
fontTempChat.fromString(Settings->getChatScreenFont());
|
||||||
|
|
||||||
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
|
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
|
||||||
|
|
||||||
ui.labelChatFontPreview->setText(fontTempChat.rawName());
|
ui.labelChatFontPreview->setText(fontTempChat.rawName());
|
||||||
|
|
157
retroshare-gui/src/gui/settings/RsharePeerSettings.cpp
Normal file
157
retroshare-gui/src/gui/settings/RsharePeerSettings.cpp
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
/****************************************************************
|
||||||
|
* This file is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 - 2010, RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
#include <retroshare/rsinit.h>
|
||||||
|
#include <retroshare/rspeers.h>
|
||||||
|
|
||||||
|
#include "RsharePeerSettings.h"
|
||||||
|
|
||||||
|
/** The file in which all settings of he peers will read and written. */
|
||||||
|
#define SETTINGS_FILE (RsInit::RsProfileConfigDirectory() + "/RSPeers.conf")
|
||||||
|
|
||||||
|
/* clean dead gpg id's after these days */
|
||||||
|
#define DAYS_TO_CLEAN 7
|
||||||
|
|
||||||
|
/* Group for general data */
|
||||||
|
#define GROUP_GENERAL "Default"
|
||||||
|
|
||||||
|
/* the one and only global settings object */
|
||||||
|
RsharePeerSettings *PeerSettings = NULL;
|
||||||
|
|
||||||
|
/*static*/ void RsharePeerSettings::Create ()
|
||||||
|
{
|
||||||
|
if (PeerSettings == NULL) {
|
||||||
|
PeerSettings = new RsharePeerSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Default Constructor */
|
||||||
|
RsharePeerSettings::RsharePeerSettings()
|
||||||
|
: QSettings(QString::fromStdString(SETTINGS_FILE), QSettings::IniFormat)
|
||||||
|
{
|
||||||
|
cleanDeadGpgIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsharePeerSettings::cleanDeadGpgIds()
|
||||||
|
{
|
||||||
|
beginGroup(GROUP_GENERAL);
|
||||||
|
QDateTime lastClean = value("lastClean").toDateTime();
|
||||||
|
endGroup();
|
||||||
|
|
||||||
|
QDateTime currentDate = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
if (lastClean.addDays(DAYS_TO_CLEAN) < currentDate) {
|
||||||
|
/* clean */
|
||||||
|
QStringList groups = childGroups();
|
||||||
|
for (QStringList::iterator group = groups.begin(); group != groups.end(); group++) {
|
||||||
|
if (*group == GROUP_GENERAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rsPeers->isGPGAccepted((*group).toStdString()) == false) {
|
||||||
|
remove(*group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
beginGroup(GROUP_GENERAL);
|
||||||
|
setValue("lastClean", currentDate);
|
||||||
|
endGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RsharePeerSettings::getGpgIdOfSslId(const std::string &sslId, std::string &gpgId)
|
||||||
|
|
||||||
|
{
|
||||||
|
std::map<std::string, std::string>::iterator it = m_SslToGpg.find(sslId);
|
||||||
|
if (it != m_SslToGpg.end()) {
|
||||||
|
gpgId = it->second;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsPeerDetails details;
|
||||||
|
if (rsPeers->getPeerDetails(sslId, details) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpgId = details.gpg_id;
|
||||||
|
m_SslToGpg[sslId] = gpgId;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get value of peer */
|
||||||
|
QVariant RsharePeerSettings::get(const std::string &peerId, const QString &key, const QVariant &defaultValue)
|
||||||
|
{
|
||||||
|
QVariant result;
|
||||||
|
|
||||||
|
std::string gpgId;
|
||||||
|
if (getGpgIdOfSslId(peerId, gpgId) == false) {
|
||||||
|
/* gpg id not found */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
beginGroup(QString::fromStdString(gpgId));
|
||||||
|
result = value(key, defaultValue);
|
||||||
|
endGroup();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set value of peer */
|
||||||
|
void RsharePeerSettings::set(const std::string &peerId, const QString &key, const QVariant &value)
|
||||||
|
{
|
||||||
|
std::string gpgId;
|
||||||
|
if (getGpgIdOfSslId(peerId, gpgId) == false) {
|
||||||
|
/* gpg id not found */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beginGroup(QString::fromStdString(gpgId));
|
||||||
|
setValue(key, value);
|
||||||
|
endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RsharePeerSettings::getPrivateChatColor(const std::string &peerId)
|
||||||
|
{
|
||||||
|
return get(peerId, "PrivateChatColor", QColor(Qt::black).name()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsharePeerSettings::setPrivateChatColor(const std::string &peerId, const QString &value)
|
||||||
|
{
|
||||||
|
set(peerId, "PrivateChatColor", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RsharePeerSettings::getPrivateChatFont(const std::string &peerId)
|
||||||
|
{
|
||||||
|
return get(peerId, "PrivateChatFont", QFont("Comic Sans MS", 10).toString()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsharePeerSettings::setPrivateChatFont(const std::string &peerId, const QString &value)
|
||||||
|
{
|
||||||
|
set(peerId, "PrivateChatFont", value);
|
||||||
|
}
|
59
retroshare-gui/src/gui/settings/RsharePeerSettings.h
Normal file
59
retroshare-gui/src/gui/settings/RsharePeerSettings.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/****************************************************************
|
||||||
|
* This file is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 - 2010, RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#ifndef _RSHAREPEERSETTINGS_H
|
||||||
|
#define _RSHAREPEERSETTINGS_H
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
/** Handles saving and restoring RShares's settings for peers */
|
||||||
|
class RsharePeerSettings : public QSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/* create settings object */
|
||||||
|
static void Create ();
|
||||||
|
|
||||||
|
QString getPrivateChatColor(const std::string &peerId);
|
||||||
|
void setPrivateChatColor(const std::string &peerId, const QString &value);
|
||||||
|
|
||||||
|
QString getPrivateChatFont(const std::string &peerId);
|
||||||
|
void setPrivateChatFont(const std::string &peerId, const QString &value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Default constructor. */
|
||||||
|
RsharePeerSettings();
|
||||||
|
|
||||||
|
bool getGpgIdOfSslId(const std::string &sslId, std::string &gpgId);
|
||||||
|
void cleanDeadGpgIds();
|
||||||
|
|
||||||
|
/* get value of peer */
|
||||||
|
QVariant get(const std::string &peerId, const QString &key, const QVariant &defaultValue = QVariant());
|
||||||
|
/* set value of peer */
|
||||||
|
void set(const std::string &peerId, const QString &key, const QVariant &value);
|
||||||
|
|
||||||
|
/* map for fast access of the gpg id to the ssl id */
|
||||||
|
std::map<std::string, std::string> m_SslToGpg;
|
||||||
|
};
|
||||||
|
|
||||||
|
// the one and only global settings object
|
||||||
|
extern RsharePeerSettings *PeerSettings;
|
||||||
|
|
||||||
|
#endif
|
|
@ -299,13 +299,23 @@ void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
|
||||||
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
|
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RshareSettings::getChatScreenFont()
|
||||||
|
{
|
||||||
|
return valueFromGroup("Chat", "ChatScreenFont").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RshareSettings::setChatScreenFont(const QString &font)
|
||||||
|
{
|
||||||
|
setValueToGroup("Chat", "ChatScreenFont", font);
|
||||||
|
}
|
||||||
|
|
||||||
void RshareSettings::getPublicChatStyle(QString &stylePath, QString &styleVariant)
|
void RshareSettings::getPublicChatStyle(QString &stylePath, QString &styleVariant)
|
||||||
{
|
{
|
||||||
stylePath = valueFromGroup("Chat", "StylePublic", ":/qss/chat/public").toString();
|
stylePath = valueFromGroup("Chat", "StylePublic", ":/qss/chat/public").toString();
|
||||||
styleVariant = valueFromGroup("Chat", "StylePublicVariant", "").toString();
|
styleVariant = valueFromGroup("Chat", "StylePublicVariant", "").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RshareSettings::setPublicChatStyle(QString stylePath, QString styleVariant)
|
void RshareSettings::setPublicChatStyle(const QString &stylePath, const QString &styleVariant)
|
||||||
{
|
{
|
||||||
setValueToGroup("Chat", "StylePublic", stylePath);
|
setValueToGroup("Chat", "StylePublic", stylePath);
|
||||||
setValueToGroup("Chat", "StylePublicVariant", styleVariant);
|
setValueToGroup("Chat", "StylePublicVariant", styleVariant);
|
||||||
|
@ -317,7 +327,7 @@ void RshareSettings::getPrivateChatStyle(QString &stylePath, QString &styleVaria
|
||||||
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
|
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RshareSettings::setPrivateChatStyle(QString stylePath, QString styleVariant)
|
void RshareSettings::setPrivateChatStyle(const QString &stylePath, const QString &styleVariant)
|
||||||
{
|
{
|
||||||
setValueToGroup("Chat", "StylePrivate", stylePath);
|
setValueToGroup("Chat", "StylePrivate", stylePath);
|
||||||
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
|
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
|
||||||
|
@ -329,7 +339,7 @@ void RshareSettings::getHistoryChatStyle(QString &stylePath, QString &styleVaria
|
||||||
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
|
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RshareSettings::setHistoryChatStyle(QString stylePath, QString styleVariant)
|
void RshareSettings::setHistoryChatStyle(const QString &stylePath, const QString &styleVariant)
|
||||||
{
|
{
|
||||||
setValueToGroup("Chat", "StyleHistory", stylePath);
|
setValueToGroup("Chat", "StyleHistory", stylePath);
|
||||||
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
|
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
|
||||||
|
|
|
@ -122,15 +122,19 @@ public:
|
||||||
bool getChatSendMessageWithCtrlReturn();
|
bool getChatSendMessageWithCtrlReturn();
|
||||||
void setChatSendMessageWithCtrlReturn(bool bValue);
|
void setChatSendMessageWithCtrlReturn(bool bValue);
|
||||||
|
|
||||||
|
/* chat font */
|
||||||
|
QString getChatScreenFont();
|
||||||
|
void setChatScreenFont(const QString &font);
|
||||||
|
|
||||||
/* chat styles */
|
/* chat styles */
|
||||||
void getPublicChatStyle(QString &stylePath, QString &styleVariant);
|
void getPublicChatStyle(QString &stylePath, QString &styleVariant);
|
||||||
void setPublicChatStyle(QString stylePath, QString styleVariant);
|
void setPublicChatStyle(const QString &stylePath, const QString &styleVariant);
|
||||||
|
|
||||||
void getPrivateChatStyle(QString &stylePath, QString &styleVariant);
|
void getPrivateChatStyle(QString &stylePath, QString &styleVariant);
|
||||||
void setPrivateChatStyle(QString stylePath, QString styleVariant);
|
void setPrivateChatStyle(const QString &stylePath, const QString &styleVariant);
|
||||||
|
|
||||||
void getHistoryChatStyle(QString &stylePath, QString &styleVariant);
|
void getHistoryChatStyle(QString &stylePath, QString &styleVariant);
|
||||||
void setHistoryChatStyle(QString stylePath, QString styleVariant);
|
void setHistoryChatStyle(const QString &stylePath, const QString &styleVariant);
|
||||||
|
|
||||||
//! Save placement, state and size information of a window.
|
//! Save placement, state and size information of a window.
|
||||||
void saveWidgetInformation(QWidget *widget);
|
void saveWidgetInformation(QWidget *widget);
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "gui/StartDialog.h"
|
#include "gui/StartDialog.h"
|
||||||
#include "gui/GenCertDialog.h"
|
#include "gui/GenCertDialog.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
#include "gui/settings/RsharePeerSettings.h"
|
||||||
#include "gui/connect/ConfCertDialog.h"
|
#include "gui/connect/ConfCertDialog.h"
|
||||||
#include "idle/idle.h"
|
#include "idle/idle.h"
|
||||||
|
|
||||||
|
@ -160,6 +161,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* recreate global settings object, now with correct path */
|
/* recreate global settings object, now with correct path */
|
||||||
RshareSettings::Create ();
|
RshareSettings::Create ();
|
||||||
|
RsharePeerSettings::Create();
|
||||||
|
|
||||||
#ifdef MINIMAL_RSGUI
|
#ifdef MINIMAL_RSGUI
|
||||||
MessengerWindow::showYourself();
|
MessengerWindow::showYourself();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue