mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
incorporated changed from defnax
This commit is contained in:
parent
87ede7eff5
commit
39f4878244
@ -284,6 +284,10 @@ void FriendSelectionWidget::secured_fillList()
|
||||
std::set<RsGxsId> gxsIdsSelected;
|
||||
if (mShowTypes & SHOW_GXS)
|
||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
||||
|
||||
std::set<RsGxsId> gxsIdsSelected2;
|
||||
if (mShowTypes & SHOW_CONTACTS)
|
||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected2,true);
|
||||
|
||||
// remove old items
|
||||
ui->friendList->clear();
|
||||
@ -525,6 +529,7 @@ void FriendSelectionWidget::secured_fillList()
|
||||
// iterate through gpg ids
|
||||
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt)
|
||||
{
|
||||
|
||||
// we fill the not assigned gpg ids
|
||||
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
|
||||
continue;
|
||||
@ -570,6 +575,61 @@ void FriendSelectionWidget::secured_fillList()
|
||||
setSelected(mListModus, gxsItem, true);
|
||||
}
|
||||
}
|
||||
if(mShowTypes & SHOW_CONTACTS)
|
||||
{
|
||||
// iterate through gpg ids
|
||||
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt)
|
||||
{
|
||||
|
||||
// we fill the not assigned gpg ids
|
||||
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
|
||||
continue;
|
||||
|
||||
// add equal too, its no problem
|
||||
filledIds.push_back((*gxsIt).toStdString());
|
||||
|
||||
RsIdentityDetails detail;
|
||||
if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail))
|
||||
continue; /* BAD */
|
||||
|
||||
QList<QIcon> icons ;
|
||||
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
|
||||
QIcon identicon = icons.front() ;
|
||||
|
||||
if(detail.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
|
||||
{
|
||||
|
||||
// make a widget per friend
|
||||
gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS);
|
||||
|
||||
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
||||
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
||||
|
||||
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||
gxsItem->setIcon(COLUMN_NAME, identicon);
|
||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||
|
||||
gxsItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
|
||||
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
|
||||
//TODO: online state for gxs items
|
||||
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STATE, 1);
|
||||
gxsItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
|
||||
|
||||
if (mListModus == MODUS_CHECK)
|
||||
gxsItem->setCheckState(0, Qt::Unchecked);
|
||||
|
||||
ui->friendList->addTopLevelItem(gxsItem);
|
||||
|
||||
gxsItem->setExpanded(true);
|
||||
|
||||
emit itemAdded(IDTYPE_GXS, QString::fromStdString(detail.mId.toStdString()), gxsItem);
|
||||
|
||||
if (std::find(gxsIdsSelected.begin(), gxsIdsSelected.end(), detail.mId) != gxsIdsSelected.end())
|
||||
setSelected(mListModus, gxsItem, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (groupIt != groupInfoList.end()) {
|
||||
++groupIt;
|
||||
} else {
|
||||
|
@ -65,7 +65,8 @@ public:
|
||||
SHOW_GPG = 2,
|
||||
SHOW_SSL = 4,
|
||||
SHOW_NON_FRIEND_GPG = 8,
|
||||
SHOW_GXS =16
|
||||
SHOW_GXS =16,
|
||||
SHOW_CONTACTS =32
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(ShowTypes, ShowType)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,79 +1,81 @@
|
||||
/****************************************************************
|
||||
* RetroShare 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 _CHATPAGE_H
|
||||
#define _CHATPAGE_H
|
||||
|
||||
#include <retroshare-gui/configpage.h>
|
||||
#include "ui_ChatPage.h"
|
||||
|
||||
class ChatPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
ChatPage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
|
||||
/** Default Destructor */
|
||||
~ChatPage() {}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
virtual bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
virtual void load();
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/chat_24.png") ; }
|
||||
virtual QString pageName() const { return tr("Chat") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void on_historyComboBoxVariant_currentIndexChanged(int index);
|
||||
void on_privateComboBoxVariant_currentIndexChanged(int index);
|
||||
void on_publicComboBoxVariant_currentIndexChanged(int index);
|
||||
void on_pushButtonChangeChatFont_clicked();
|
||||
void on_publicList_currentRowChanged(int currentRow);
|
||||
void on_privateList_currentRowChanged(int currentRow);
|
||||
void on_historyList_currentRowChanged(int currentRow);
|
||||
|
||||
void on_cbSearch_WithoutLimit_toggled(bool);
|
||||
void on_btSearch_FoundColor_clicked();
|
||||
|
||||
|
||||
private:
|
||||
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);
|
||||
void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser);
|
||||
|
||||
QFont fontTempChat;
|
||||
|
||||
QString publicStylePath;
|
||||
QString publicStyleVariant;
|
||||
QString privateStylePath;
|
||||
QString privateStyleVariant;
|
||||
QString historyStylePath;
|
||||
QString historyStyleVariant;
|
||||
|
||||
QRgb rgbChatSearchFoundColor;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ChatPage ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
/****************************************************************
|
||||
* RetroShare 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 _CHATPAGE_H
|
||||
#define _CHATPAGE_H
|
||||
|
||||
#include <retroshare-gui/configpage.h>
|
||||
#include "ui_ChatPage.h"
|
||||
|
||||
class ChatPage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
ChatPage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
|
||||
/** Default Destructor */
|
||||
~ChatPage() {}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
virtual bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
virtual void load();
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/chat_24.png") ; }
|
||||
virtual QString pageName() const { return tr("Chat") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void on_historyComboBoxVariant_currentIndexChanged(int index);
|
||||
void on_privateComboBoxVariant_currentIndexChanged(int index);
|
||||
void on_publicComboBoxVariant_currentIndexChanged(int index);
|
||||
void on_pushButtonChangeChatFont_clicked();
|
||||
void on_publicList_currentRowChanged(int currentRow);
|
||||
void on_privateList_currentRowChanged(int currentRow);
|
||||
void on_historyList_currentRowChanged(int currentRow);
|
||||
|
||||
void on_cbSearch_WithoutLimit_toggled(bool);
|
||||
void on_btSearch_FoundColor_clicked();
|
||||
|
||||
void distantChatComboBoxChanged(int);
|
||||
|
||||
|
||||
private:
|
||||
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);
|
||||
void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser);
|
||||
|
||||
QFont fontTempChat;
|
||||
|
||||
QString publicStylePath;
|
||||
QString publicStyleVariant;
|
||||
QString privateStylePath;
|
||||
QString privateStyleVariant;
|
||||
QString historyStylePath;
|
||||
QString historyStyleVariant;
|
||||
|
||||
QRgb rgbChatSearchFoundColor;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ChatPage ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,8 +20,43 @@
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Distant Chat</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="distantChatcomboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Everyone</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Contacts</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Nobody</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="distantchatlabel">
|
||||
<property name="text">
|
||||
<string>Accept encrypted distant chat from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
@ -203,7 +238,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
|
@ -1,239 +1,269 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006, crypton
|
||||
*
|
||||
* 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 "rshare.h"
|
||||
#include "rsharesettings.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
#include "MessagePage.h"
|
||||
#include "gui/common/TagDefs.h"
|
||||
#include <algorithm>
|
||||
#include "NewTag.h"
|
||||
|
||||
MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_pTags = new MsgTagType;
|
||||
|
||||
connect (ui.addpushButton, SIGNAL(clicked(bool)), this, SLOT (addTag()));
|
||||
connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag()));
|
||||
connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag()));
|
||||
connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag()));
|
||||
connect (ui.encryptedMsgs_CB, SIGNAL(toggled(bool)), this, SLOT (toggleEnableEncryptedDistantMsgs(bool)));
|
||||
|
||||
connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int)));
|
||||
|
||||
ui.editpushButton->setEnabled(false);
|
||||
ui.deletepushButton->setEnabled(false);
|
||||
|
||||
ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB);
|
||||
ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW);
|
||||
|
||||
//ui.encryptedMsgs_CB->setEnabled(false) ;
|
||||
}
|
||||
|
||||
MessagePage::~MessagePage()
|
||||
{
|
||||
delete(m_pTags);
|
||||
}
|
||||
|
||||
void MessagePage::toggleEnableEncryptedDistantMsgs(bool b)
|
||||
{
|
||||
rsMail->enableDistantMessaging(b) ;
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
MessagePage::save(QString &/*errmsg*/)
|
||||
{
|
||||
Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
|
||||
Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
|
||||
Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());
|
||||
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
|
||||
// check for changed tags
|
||||
std::list<uint32_t>::iterator changedTagId;
|
||||
for (changedTagId = m_changedTagIds.begin(); changedTagId != m_changedTagIds.end(); ++changedTagId) {
|
||||
if (*changedTagId == Tag->first) {
|
||||
if (Tag->second.first.empty()) {
|
||||
// delete tag
|
||||
rsMail->removeMessageTagType(Tag->first);
|
||||
continue;
|
||||
}
|
||||
|
||||
rsMail->setMessageTagType(Tag->first, Tag->second.first, Tag->second.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void
|
||||
MessagePage::load()
|
||||
{
|
||||
ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate());
|
||||
ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages());
|
||||
ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen()));
|
||||
|
||||
ui.encryptedMsgs_CB->setChecked(rsMail->distantMessagingEnabled()) ;
|
||||
// fill items
|
||||
rsMail->getMessageTagTypes(*m_pTags);
|
||||
fillTags();
|
||||
}
|
||||
|
||||
// fill tags
|
||||
void MessagePage::fillTags()
|
||||
{
|
||||
ui.tags_listWidget->clear();
|
||||
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
|
||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||
|
||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::UserRole, Tag->first);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::addTag()
|
||||
{
|
||||
NewTag TagDlg(*m_pTags);
|
||||
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
Tag = m_pTags->types.find(TagDlg.m_nId);
|
||||
if (Tag != m_pTags->types.end()) {
|
||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||
|
||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
|
||||
|
||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::editTag()
|
||||
{
|
||||
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
|
||||
if (pItemWidget == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
|
||||
if (nId == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NewTag TagDlg(*m_pTags, nId);
|
||||
TagDlg.setWindowTitle(tr("Edit Tag"));
|
||||
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
Tag = m_pTags->types.find(TagDlg.m_nId);
|
||||
if (Tag != m_pTags->types.end()) {
|
||||
if (Tag->first >= RS_MSGTAGTYPE_USER) {
|
||||
pItemWidget->setText(QString::fromStdString(Tag->second.first));
|
||||
}
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::deleteTag()
|
||||
{
|
||||
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
|
||||
if (pItemWidget == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
|
||||
if (nId == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nId < RS_MSGTAGTYPE_USER) {
|
||||
// can't delete standard tag item
|
||||
return;
|
||||
}
|
||||
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
Tag = m_pTags->types.find(nId);
|
||||
if (Tag != m_pTags->types.end()) {
|
||||
// erase the text for later delete
|
||||
Tag->second.first.erase();
|
||||
}
|
||||
|
||||
ui.tags_listWidget->removeItemWidget(pItemWidget);
|
||||
delete (pItemWidget);
|
||||
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), nId) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(nId);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::defaultTag()
|
||||
{
|
||||
rsMail->resetMessageStandardTagTypes(*m_pTags);
|
||||
|
||||
// add all standard items to changed list
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
|
||||
if (Tag->first < RS_MSGTAGTYPE_USER) {
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), Tag->first) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(Tag->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fillTags();
|
||||
}
|
||||
|
||||
void MessagePage::currentRowChangedTag(int row)
|
||||
{
|
||||
QListWidgetItem *pItemWidget = ui.tags_listWidget->item(row);
|
||||
|
||||
bool bEditEnable = false;
|
||||
bool bDeleteEnable = false;
|
||||
|
||||
if (pItemWidget) {
|
||||
bEditEnable = true;
|
||||
|
||||
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
|
||||
|
||||
if (nId >= RS_MSGTAGTYPE_USER) {
|
||||
bDeleteEnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
ui.editpushButton->setEnabled(bEditEnable);
|
||||
ui.deletepushButton->setEnabled(bDeleteEnable);
|
||||
}
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006, crypton
|
||||
*
|
||||
* 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 "rshare.h"
|
||||
#include "rsharesettings.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
#include "MessagePage.h"
|
||||
#include "gui/common/TagDefs.h"
|
||||
#include <algorithm>
|
||||
#include "NewTag.h"
|
||||
|
||||
MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_pTags = new MsgTagType;
|
||||
|
||||
connect (ui.addpushButton, SIGNAL(clicked(bool)), this, SLOT (addTag()));
|
||||
connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag()));
|
||||
connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag()));
|
||||
connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag()));
|
||||
//connect (ui.encryptedMsgs_CB, SIGNAL(toggled(bool)), this, SLOT (toggleEnableEncryptedDistantMsgs(bool)));
|
||||
|
||||
connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int)));
|
||||
|
||||
ui.editpushButton->setEnabled(false);
|
||||
ui.deletepushButton->setEnabled(false);
|
||||
|
||||
ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB);
|
||||
ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW);
|
||||
|
||||
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantMsgsComboBoxChanged(int)));
|
||||
|
||||
|
||||
//ui.encryptedMsgs_CB->setEnabled(false) ;
|
||||
}
|
||||
|
||||
MessagePage::~MessagePage()
|
||||
{
|
||||
delete(m_pTags);
|
||||
}
|
||||
|
||||
void MessagePage::toggleEnableEncryptedDistantMsgs(bool b)
|
||||
{
|
||||
rsMail->enableDistantMessaging(b) ;
|
||||
}
|
||||
|
||||
void MessagePage::distantMsgsComboBoxChanged(int i)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0: rsMail->enableDistantMessaging(true) ;
|
||||
break ;
|
||||
|
||||
case 1: ;
|
||||
break ;
|
||||
|
||||
case 2: rsMail->enableDistantMessaging(false) ;
|
||||
break ;
|
||||
|
||||
|
||||
default: ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
MessagePage::save(QString &/*errmsg*/)
|
||||
{
|
||||
Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
|
||||
Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
|
||||
Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());
|
||||
|
||||
// state of distant Message combobox
|
||||
Settings->setValue("DistantMessages", ui.comboBox->currentIndex());
|
||||
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
|
||||
// check for changed tags
|
||||
std::list<uint32_t>::iterator changedTagId;
|
||||
for (changedTagId = m_changedTagIds.begin(); changedTagId != m_changedTagIds.end(); ++changedTagId) {
|
||||
if (*changedTagId == Tag->first) {
|
||||
if (Tag->second.first.empty()) {
|
||||
// delete tag
|
||||
rsMail->removeMessageTagType(Tag->first);
|
||||
continue;
|
||||
}
|
||||
|
||||
rsMail->setMessageTagType(Tag->first, Tag->second.first, Tag->second.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void
|
||||
MessagePage::load()
|
||||
{
|
||||
ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate());
|
||||
ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages());
|
||||
ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen()));
|
||||
|
||||
//ui.encryptedMsgs_CB->setChecked(rsMail->distantMessagingEnabled()) ;
|
||||
|
||||
// state of filter combobox
|
||||
int index = Settings->value("DistantMessages", 0).toInt();
|
||||
ui.comboBox->setCurrentIndex(index);
|
||||
|
||||
// fill items
|
||||
rsMail->getMessageTagTypes(*m_pTags);
|
||||
fillTags();
|
||||
}
|
||||
|
||||
// fill tags
|
||||
void MessagePage::fillTags()
|
||||
{
|
||||
ui.tags_listWidget->clear();
|
||||
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
|
||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||
|
||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::UserRole, Tag->first);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::addTag()
|
||||
{
|
||||
NewTag TagDlg(*m_pTags);
|
||||
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
Tag = m_pTags->types.find(TagDlg.m_nId);
|
||||
if (Tag != m_pTags->types.end()) {
|
||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||
|
||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
|
||||
|
||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::editTag()
|
||||
{
|
||||
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
|
||||
if (pItemWidget == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
|
||||
if (nId == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NewTag TagDlg(*m_pTags, nId);
|
||||
TagDlg.setWindowTitle(tr("Edit Tag"));
|
||||
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
Tag = m_pTags->types.find(TagDlg.m_nId);
|
||||
if (Tag != m_pTags->types.end()) {
|
||||
if (Tag->first >= RS_MSGTAGTYPE_USER) {
|
||||
pItemWidget->setText(QString::fromStdString(Tag->second.first));
|
||||
}
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::deleteTag()
|
||||
{
|
||||
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
|
||||
if (pItemWidget == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
|
||||
if (nId == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nId < RS_MSGTAGTYPE_USER) {
|
||||
// can't delete standard tag item
|
||||
return;
|
||||
}
|
||||
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
Tag = m_pTags->types.find(nId);
|
||||
if (Tag != m_pTags->types.end()) {
|
||||
// erase the text for later delete
|
||||
Tag->second.first.erase();
|
||||
}
|
||||
|
||||
ui.tags_listWidget->removeItemWidget(pItemWidget);
|
||||
delete (pItemWidget);
|
||||
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), nId) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(nId);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePage::defaultTag()
|
||||
{
|
||||
rsMail->resetMessageStandardTagTypes(*m_pTags);
|
||||
|
||||
// add all standard items to changed list
|
||||
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
|
||||
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
|
||||
if (Tag->first < RS_MSGTAGTYPE_USER) {
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), Tag->first) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(Tag->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fillTags();
|
||||
}
|
||||
|
||||
void MessagePage::currentRowChangedTag(int row)
|
||||
{
|
||||
QListWidgetItem *pItemWidget = ui.tags_listWidget->item(row);
|
||||
|
||||
bool bEditEnable = false;
|
||||
bool bDeleteEnable = false;
|
||||
|
||||
if (pItemWidget) {
|
||||
bEditEnable = true;
|
||||
|
||||
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
|
||||
|
||||
if (nId >= RS_MSGTAGTYPE_USER) {
|
||||
bDeleteEnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
ui.editpushButton->setEnabled(bEditEnable);
|
||||
ui.deletepushButton->setEnabled(bDeleteEnable);
|
||||
}
|
||||
|
@ -1,70 +1,72 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006, crypton
|
||||
*
|
||||
* 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 MESSAGEPAGE_H
|
||||
#define MESSAGEPAGE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <retroshare-gui/configpage.h>
|
||||
#include "ui_MessagePage.h"
|
||||
|
||||
#include "gui/msgs/MessageInterface.h"
|
||||
|
||||
class MessagePage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MessagePage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
|
||||
~MessagePage();
|
||||
|
||||
/** Saves the changes on this page */
|
||||
virtual bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
virtual void load();
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/evolution.png") ; }
|
||||
virtual QString pageName() const { return tr("Message") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
|
||||
private slots:
|
||||
void addTag();
|
||||
void editTag();
|
||||
void deleteTag();
|
||||
void defaultTag();
|
||||
|
||||
void currentRowChangedTag(int row);
|
||||
void toggleEnableEncryptedDistantMsgs(bool) ;
|
||||
|
||||
private:
|
||||
void fillTags();
|
||||
|
||||
/* Pointer for not include of rsmsgs.h */
|
||||
MsgTagType *m_pTags;
|
||||
std::list<uint32_t> m_changedTagIds;
|
||||
|
||||
Ui::MessagePage ui;
|
||||
};
|
||||
|
||||
#endif // !MESSAGEPAGE_H
|
||||
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006, crypton
|
||||
*
|
||||
* 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 MESSAGEPAGE_H
|
||||
#define MESSAGEPAGE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <retroshare-gui/configpage.h>
|
||||
#include "ui_MessagePage.h"
|
||||
|
||||
#include "gui/msgs/MessageInterface.h"
|
||||
|
||||
class MessagePage : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MessagePage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
|
||||
~MessagePage();
|
||||
|
||||
/** Saves the changes on this page */
|
||||
virtual bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
virtual void load();
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/evolution.png") ; }
|
||||
virtual QString pageName() const { return tr("Message") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
|
||||
private slots:
|
||||
void addTag();
|
||||
void editTag();
|
||||
void deleteTag();
|
||||
void defaultTag();
|
||||
|
||||
void currentRowChangedTag(int row);
|
||||
void toggleEnableEncryptedDistantMsgs(bool) ;
|
||||
void distantMsgsComboBoxChanged(int);
|
||||
|
||||
|
||||
private:
|
||||
void fillTags();
|
||||
|
||||
/* Pointer for not include of rsmsgs.h */
|
||||
MsgTagType *m_pTags;
|
||||
std::list<uint32_t> m_changedTagIds;
|
||||
|
||||
Ui::MessagePage ui;
|
||||
};
|
||||
|
||||
#endif // !MESSAGEPAGE_H
|
||||
|
||||
|
@ -59,21 +59,30 @@
|
||||
<property name="title">
|
||||
<string>Distant messages:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="justify">The link below allows people in the network to send encrypted messages to you, using tunnels. To do that, they need your public PGP key, which they will get using the Retroshare discovery system. </p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Everyone</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Contacts</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Nobody</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="encryptedMsgs_CB">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Accept encrypted distant messages from everyone</string>
|
||||
<string>Accept encrypted distant messages from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user