fixed conflicts in merging upstream/master to v0.6-FTEncryption

This commit is contained in:
mr-alice 2016-11-01 14:23:13 +01:00
commit 8c7c7647b0
173 changed files with 2701 additions and 13742 deletions

View file

@ -25,16 +25,16 @@
#include <QMenu>
#include <algorithm>
#include "gui/Circles/CreateCircleDialog.h"
#include "gui/gxs/GxsIdDetails.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
#include "gui/common/AvatarDefs.h"
#include "gui/Circles/CreateCircleDialog.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/Identity/IdDialog.h"
#include "gui/Identity/IdEditDialog.h"
#include <algorithm>
//#define DEBUG_CREATE_CIRCLE_DIALOG 1
#define CREATECIRCLEDIALOG_CIRCLEINFO 2
@ -258,8 +258,9 @@ void CreateCircleDialog::addMember()
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
QString idtype = item->text(RSCIRCLEID_COL_IDTYPE);
QString nickname = item->text(RSCIRCLEID_COL_NICKNAME);
QIcon icon = item->icon(RSCIRCLEID_COL_NICKNAME);
addMember(keyId, idtype, nickname);
addMember(keyId, idtype, nickname, icon);
}
void CreateCircleDialog::addMember(const RsGxsIdGroup &idGroup)
@ -267,15 +268,27 @@ void CreateCircleDialog::addMember(const RsGxsIdGroup &idGroup)
QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString());
QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str());
QString idtype = tr("Anon Id");
QPixmap pixmap ;
if(idGroup.mImage.mSize == 0 || !pixmap.loadFromData(idGroup.mImage.mData, idGroup.mImage.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId)));
if (idGroup.mPgpKnown){
RsPeerDetails details;
rsPeers->getGPGDetails(idGroup.mPgpId, details);
idtype = QString::fromUtf8(details.name.c_str());
}//if (idGroup.mPgpKnown)
addMember(keyId, idtype, nickname);
addMember(keyId, idtype, nickname, QIcon(pixmap));
}
void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname )
{
QIcon icon;
addMember(keyId, idtype, nickname, icon);
}
void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname, const QIcon& icon)
{
QTreeWidget *tree = ui.treeWidget_membership;
@ -293,9 +306,9 @@ void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype,
QTreeWidgetItem *member = new QTreeWidgetItem();
member->setText(RSCIRCLEID_COL_NICKNAME, nickname);
member->setIcon(RSCIRCLEID_COL_NICKNAME, icon);
member->setText(RSCIRCLEID_COL_KEYID, keyId);
member->setText(RSCIRCLEID_COL_IDTYPE, idtype);
//member->setIcon(RSCIRCLEID_COL_NICKNAME, pixmap);
tree->addTopLevelItem(member);
@ -317,14 +330,19 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails)
QString nickname = QString::fromUtf8(gxs_details.mNickname.c_str());
QString idtype = tr("Anon Id");
addMember(keyId, idtype, nickname);
QPixmap pixmap ;
if(gxs_details.mAvatar.mSize == 0 || !pixmap.loadFromData(gxs_details.mAvatar.mData, gxs_details.mAvatar.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(gxs_details.mId));
addMember(keyId, idtype, nickname, QIcon(pixmap));
}//if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details))
}//for (itUnknownPeers it = cirDetails.mUnknownPeers.begin()
typedef std::set<RsPgpId>::const_iterator itAllowedPeers;
for (itAllowedPeers it = cirDetails.mAllowedNodes.begin() ; it != cirDetails.mAllowedNodes.end() ; ++it )
{
{
RsPgpId gpg_id = *it;
RsPeerDetails details ;
if(!gpg_id.isNull() && rsPeers->getGPGDetails(gpg_id,details)) {
@ -333,7 +351,10 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails)
QString nickname = QString::fromUtf8(details.name.c_str());
QString idtype = tr("PGP Identity");
addMember(keyId, idtype, nickname);
QPixmap avatar;
AvatarDefs::getAvatarFromGpgId(gpg_id, avatar);
addMember(keyId, idtype, nickname, QIcon(avatar));
}//if(!gpg_id.isNull() && rsPeers->getGPGDetails(gpg_id,details))
}//for (itAllowedPeers it = cirDetails.mAllowedPeers.begin()
@ -756,7 +777,7 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked();
//bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked();
RsGxsIdGroup data;
RsGxsIdGroup idGroup;
std::vector<RsGxsIdGroup> datavector;
std::vector<RsGxsIdGroup>::iterator vit;
if (!rsIdentity->getGroupData(token, datavector)) {
@ -765,67 +786,68 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
return;
}
for(vit = datavector.begin(); vit != datavector.end(); ++vit)
{
data = (*vit);
for(vit = datavector.begin(); vit != datavector.end(); ++vit)
{
idGroup = (*vit);
/* do filtering */
bool ok = false;
if (acceptAnonymous)
ok = true;
else if (acceptAllPGP)
ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
else if (data.mPgpKnown)
ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
/* do filtering */
bool ok = false;
if (acceptAnonymous)
ok = true;
else if (acceptAllPGP)
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
else if (idGroup.mPgpKnown)
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
if (!ok) {
if (!ok) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId;
std::cerr << std::endl;
std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId;
std::cerr << std::endl;
#endif
continue;
}
continue;
}
QString keyId = QString::fromStdString(data.mMeta.mGroupId.toStdString());
QString nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str());
QString idtype = tr("Anon Id");
QPixmap pixmap ;
QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString());
QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str());
QString idtype = tr("Anon Id");
if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
QPixmap pixmap ;
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
if (data.mPgpKnown) {
RsPeerDetails details;
rsPeers->getGPGDetails(data.mPgpId, details);
idtype = QString::fromUtf8(details.name.c_str());
}
else
idtype = tr("PGP Linked Id");
}
if(idGroup.mImage.mSize == 0 || !pixmap.loadFromData(idGroup.mImage.mData, idGroup.mImage.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId))) ;
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
item->setIcon(RSCIRCLEID_COL_NICKNAME, QIcon(pixmap));
item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item);
if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
if (idGroup.mPgpKnown) {
RsPeerDetails details;
rsPeers->getGPGDetails(idGroup.mPgpId, details);
idtype = QString::fromUtf8(details.name.c_str());
}
else
idtype = tr("PGP Linked Id");
// External Circle.
if (mIsExistingCircle)
{
// check if its in the circle.
}
// We use an explicit cast
//
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
item->setIcon(RSCIRCLEID_COL_NICKNAME, QIcon(pixmap));
item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item);
if ( mCircleGroup.mInvitedMembers.find(RsGxsId(data.mMeta.mGroupId)) != mCircleGroup.mInvitedMembers.end()) /* found it */
addMember(keyId, idtype, nickname);
}
}
// External Circle.
if (mIsExistingCircle)
{
// check if its in the circle.
// We use an explicit cast
//
if ( mCircleGroup.mInvitedMembers.find(RsGxsId(idGroup.mMeta.mGroupId)) != mCircleGroup.mInvitedMembers.end()) /* found it */
addMember(keyId, idtype, nickname, QIcon(pixmap));
}
}
}
void CreateCircleDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)

View file

@ -41,6 +41,7 @@ public:
void editNewId(bool isExternal);
void editExistingId(const RsGxsGroupId &circleId, const bool &clearList = true, bool readonly=true);
void addMember(const QString &keyId, const QString &idtype, const QString &nickname, const QIcon &icon);
void addMember(const QString &keyId, const QString &idtype, const QString &nickname);
void addMember(const RsGxsIdGroup &idGroup);
void addCircle(const RsGxsCircleDetails &cirDetails);

View file

@ -54,7 +54,7 @@
#define IMAGE_NETWORK2 ":/icons/png/netgraph.png"
#define IMAGE_PEERS ":/icons/png/keyring.png"
#define IMAGE_IDENTITY ":/images/identity/identities_32.png"
#define IMAGE_CIRCLES ":/icons/png/circles.png"
//#define IMAGE_CIRCLES ":/icons/png/circles.png"
/******
* #define FRIENDS_DEBUG 1

View file

@ -42,6 +42,7 @@ public:
const QString idtype() const { return _idtype; }
const QString nickname() const { return _nickname; }
const QString gxsId() const { return _gxsId; }
const QImage avatar() const { return _avatar; }
signals:
void addButtonClicked();

View file

@ -557,7 +557,7 @@ void PeopleDialog::addToCircleInt()
std::map<RsPgpId,IdentityWidget *>::iterator itIdFound;
if((itIdFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) {
IdentityWidget *idWidget = itIdFound->second;
dlg.addMember(idWidget->keyId(), idWidget->idtype(), idWidget->nickname());
dlg.addMember(idWidget->keyId(), idWidget->idtype(), idWidget->nickname(), QIcon(QPixmap::fromImage(idWidget->avatar())) );
}//if((itFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end())
dlg.editExistingId(circle->groupInfo().mGroupId, false,false);
@ -769,7 +769,7 @@ void PeopleDialog::fl_flowLayoutItemDroppedInt(QList<FlowLayoutItem *>flListItem
IdentityWidget* idDest = qobject_cast<IdentityWidget*>(dest);
if (idDest) {
if (idDest->havePGPDetail()){
dlg.addMember(idDest->keyId(), idDest->idtype(), idDest->nickname());
dlg.addMember(idDest->keyId(), idDest->idtype(), idDest->nickname(), QIcon(QPixmap::fromImage(idDest->avatar())) );
}//if (idDest->havePGPDetail())
}//if (idDest)
@ -790,7 +790,7 @@ void PeopleDialog::fl_flowLayoutItemDroppedInt(QList<FlowLayoutItem *>flListItem
} else {//if (cirDropped)
IdentityWidget* idDropped = qobject_cast<IdentityWidget*>(flCurs);
if (idDropped){
dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname());
dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname(), QIcon(QPixmap::fromImage(idDropped->avatar())) );
}//if (idDropped)
}//else (cirDropped)
@ -980,7 +980,7 @@ void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event)
IdentityWidget* idDropped = qobject_cast<IdentityWidget*>(flCurs);
if (idDropped){
if (idDropped->havePGPDetail()){
dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname());
dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname(), QIcon(QPixmap::fromImage(idDropped->avatar())) );
atLeastOne = true;
}//if (idDropped->havePGPDetail())
}//if (idDropped)
@ -1015,7 +1015,7 @@ void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event)
IdentityWidget* idDropped = qobject_cast<IdentityWidget*>(flCurs);
if (idDropped){
if (idDropped->havePGPDetail()){
dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname());
dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname(), QIcon(QPixmap::fromImage(idDropped->avatar())) );
atLeastOne = true;
}//if (idDropped->havePGPDetail())

View file

@ -13,8 +13,17 @@
<property name="windowTitle">
<string>Submit Post</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<layout class="QGridLayout" name="PostedCreatePostDialogGLayout">
<property name="leftMargin">
<number>0</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">
@ -31,14 +40,14 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame">
<widget class="QFrame" name="mainFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="mainFrameGLayout">
<item row="0" column="0" colspan="3">
<widget class="StyledLabel" name="info_label">
<property name="palette">
@ -120,7 +129,7 @@
</widget>
</item>
<item row="1" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="titleGLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="titleEdit"/>
</item>
@ -144,9 +153,9 @@
</layout>
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="signedHLayout">
<item>
<spacer name="spacer_2">
<spacer name="signedHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -162,7 +171,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="signedLabel">
<property name="text">
<string>Signed by: </string>
</property>
@ -183,12 +192,12 @@
</widget>
</item>
<item>
<widget class="QTextEdit" name="notesTextEdit"/>
<widget class="MimeTextEdit" name="notesTextEdit"/>
</item>
</layout>
</item>
<item row="4" column="0">
<spacer name="horizontalSpacer">
<spacer name="buttonHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -235,6 +244,11 @@
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
@ -246,9 +260,7 @@
<header>gui/common/StyledLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>

View file

@ -543,7 +543,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
}
return QVariant();
}
QVariant FlatStyle_RDM::sortRole(const QModelIndex& index,const DirDetails& details,int coln) const
QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& details,int coln) const
{
/*
* Person: name, id, 0, 0;

View file

@ -790,9 +790,10 @@ QString RetroShareLink::toString() const
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
url.setQuery(urlQuery);
return url.toString(QUrl::EncodeSpaces | QUrl::EncodeUnicode);
#else
return url.toString().replace(" ","%20");//Seems to be already done with Qt4 but to be sure.
#endif
return url.toString();
}
QString RetroShareLink::niceName() const

View file

@ -290,13 +290,14 @@ void SharedFilesDialog::showEvent(QShowEvent *)
{
if(model!=NULL)
{
std::set<std::string> expanded_indexes ;
saveExpandedPaths(expanded_indexes);
std::set<std::string> expanded_indexes,selected_indexes ;
saveExpandedPathsAndSelection(expanded_indexes,selected_indexes);
model->setVisible(true) ;
model->update() ;
restoreExpandedPaths(expanded_indexes);
restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes);
}
}
RemoteSharedFilesDialog::~RemoteSharedFilesDialog()
@ -393,8 +394,9 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
showProperColumns() ;
std::set<std::string> expanded_indexes ;
saveExpandedPaths(expanded_indexes);
std::set<std::string> expanded_indexes,selected_indexes ;
saveExpandedPathsAndSelection(expanded_indexes,selected_indexes);
if(isVisible())
{
@ -408,7 +410,7 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
ui.dirTreeView->setModel(proxyModel);
ui.dirTreeView->update();
restoreExpandedPaths(expanded_indexes);
restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes);
QHeaderView * header = ui.dirTreeView->header () ;
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive);
@ -885,7 +887,7 @@ void SharedFilesDialog::preModDirectories(bool local)
flat_model->preMods();
}
void SharedFilesDialog::saveExpandedPaths(std::set<std::string>& expanded_indexes)
void SharedFilesDialog::saveExpandedPathsAndSelection(std::set<std::string>& expanded_indexes, std::set<std::string>& selected_indexes)
{
if(ui.dirTreeView->model() == NULL)
return ;
@ -896,11 +898,12 @@ void SharedFilesDialog::saveExpandedPaths(std::set<std::string>& expanded_indexe
for(int row = 0; row < ui.dirTreeView->model()->rowCount(); ++row)
{
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
recursSaveExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes);
recursSaveExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes,selected_indexes);
}
}
void SharedFilesDialog::restoreExpandedPaths(const std::set<std::string>& expanded_indexes)
void SharedFilesDialog::restoreExpandedPathsAndSelection(const std::set<std::string>& expanded_indexes, const std::set<std::string>& selected_indexes)
{
if(ui.dirTreeView->model() == NULL)
return ;
@ -915,18 +918,23 @@ void SharedFilesDialog::restoreExpandedPaths(const std::set<std::string>& expand
for(int row = 0; row < ui.dirTreeView->model()->rowCount(); ++row)
{
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes);
recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes,selected_indexes);
}
QItemSelection selection ;
ui.dirTreeView->blockSignals(false) ;
}
void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const std::string& path,std::set<std::string>& exp)
void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const std::string& path,std::set<std::string>& exp,std::set<std::string>& sel)
{
std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString();
#ifdef DEBUG_SHARED_FILES_DIALOG
std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl;
#endif
if(ui.dirTreeView->selectionModel()->selection().contains(index))
sel.insert(local_path) ;
if(ui.dirTreeView->isExpanded(index))
{
#ifdef DEBUG_SHARED_FILES_DIALOG
@ -936,7 +944,7 @@ void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const s
exp.insert(local_path) ;
for(int row=0;row<ui.dirTreeView->model()->rowCount(index);++row)
recursSaveExpandedItems(index.child(row,0),local_path,exp) ;
recursSaveExpandedItems(index.child(row,0),local_path,exp,sel) ;
}
#ifdef DEBUG_SHARED_FILES_DIALOG
else
@ -944,12 +952,14 @@ void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const s
#endif
}
void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, const std::string &path, const std::set<std::string>& exp)
void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, const std::string &path, const std::set<std::string>& exp, const std::set<std::string> &sel)
{
std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString();
#ifdef DEBUG_SHARED_FILES_DIALOG
std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl;
#endif
if(sel.find(local_path) != sel.end())
ui.dirTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
if(exp.find(local_path) != exp.end())
{
@ -959,7 +969,7 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con
ui.dirTreeView->setExpanded(index,true) ;
for(int row=0;row<ui.dirTreeView->model()->rowCount(index);++row)
recursRestoreExpandedItems(index.child(row,0),local_path,exp) ;
recursRestoreExpandedItems(index.child(row,0),local_path,exp,sel) ;
}
}
@ -969,8 +979,9 @@ void SharedFilesDialog::postModDirectories(bool local)
if (isRemote() == local) {
return;
}
std::set<std::string> expanded_indexes;
saveExpandedPaths(expanded_indexes) ;
std::set<std::string> expanded_indexes,selected_indexes;
saveExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
#ifdef DEBUG_SHARED_FILES_DIALOG
std::cerr << "Saving expanded items. " << expanded_indexes.size() << " items found" << std::endl;
#endif
@ -980,7 +991,7 @@ void SharedFilesDialog::postModDirectories(bool local)
flat_model->postMods();
ui.dirTreeView->update() ;
restoreExpandedPaths(expanded_indexes) ;
restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
if (ui.filterPatternLineEdit->text().isEmpty() == false)
FilterItems();

View file

@ -94,10 +94,10 @@ protected:
Ui::SharedFilesDialog ui;
virtual void processSettings(bool bLoad) = 0;
void recursRestoreExpandedItems(const QModelIndex& index,const std::string& path,const std::set<std::string>& exp);
void recursSaveExpandedItems(const QModelIndex& index, const std::string &path, std::set<std::string> &exp);
void saveExpandedPaths(std::set<std::string>& paths) ;
void restoreExpandedPaths(const std::set<std::string>& paths) ;
void recursRestoreExpandedItems(const QModelIndex& index,const std::string& path,const std::set<std::string>& exp,const std::set<std::string>& sel);
void recursSaveExpandedItems(const QModelIndex& index, const std::string &path, std::set<std::string> &exp, std::set<std::string>& sel);
void saveExpandedPathsAndSelection(std::set<std::string>& paths, std::set<std::string>& selected_indexes) ;
void restoreExpandedPathsAndSelection(const std::set<std::string>& paths, const std::set<std::string>& selected_indexes) ;
protected:
//now context menu are created again every time theu are called ( in some

View file

@ -21,18 +21,19 @@
****************************************************************/
#include <QApplication>
#include <QMenu>
#include <QKeyEvent>
#include <QScrollBar>
#include <QBuffer>
#include <QColorDialog>
#include <QFontDialog>
#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
#include <QTextStream>
#include <QTextCodec>
#include <QTimer>
#include <QTextDocumentFragment>
#include <QToolTip>
#include <QScrollBar>
#include <QStringListModel>
#include <QTextCodec>
#include <QTextDocumentFragment>
#include <QTextStream>
#include <QTimer>
#include <QToolTip>
#include "ChatWidget.h"
#include "ui_ChatWidget.h"
@ -157,6 +158,8 @@ ChatWidget::ChatWidget(QWidget *parent) :
connect(ui->actionQuote, SIGNAL(triggered()), this, SLOT(quote()));
connect(ui->actionDropPlacemark, SIGNAL(triggered()), this, SLOT(dropPlacemark()));
connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage()));
connect(ui->actionShow_Hidden_Images, SIGNAL(triggered()), ui->textBrowser, SLOT(showImages()));
ui->actionShow_Hidden_Images->setIcon(ui->textBrowser->getBlockedImage());
connect(ui->hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
@ -196,9 +199,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->actionSendAsPlainText->setChecked(Settings->getChatSendAsPlainTextByDef());
ui->textBrowser->setImageBlockWidget(ui->imageBlockWidget);
ui->textBrowser->resetImagesStatus(Settings->getChatLoadEmbeddedImages());//Need to be called after setImageBlockWidget
ui->imageBlockWidget->setAutoHide(true);
ui->textBrowser->resetImagesStatus(Settings->getChatLoadEmbeddedImages());
ui->textBrowser->installEventFilter(this);
ui->textBrowser->viewport()->installEventFilter(this);
ui->chatTextEdit->installEventFilter(this);
@ -581,6 +582,12 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
if (!anchors.isEmpty()){
toolTipText = anchors.at(0);
}
if (toolTipText.isEmpty() && !ui->textBrowser->getShowImages()){
QString imageStr;
if (ui->textBrowser->checkImage(helpEvent->pos(), imageStr)) {
toolTipText = imageStr;
}
}
}
if (!toolTipText.isEmpty()){
QToolTip::showText(helpEvent->globalPos(), toolTipText);
@ -1016,9 +1023,11 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
contextMnu->addAction(ui->actionQuote);
contextMnu->addAction(ui->actionDropPlacemark);
QTextCursor cursor = ui->textBrowser->cursorForPosition(point);
if(ImageUtil::checkImage(cursor))
if(ui->textBrowser->checkImage(point))
{
if (! ui->textBrowser->getShowImages())
contextMnu->addAction(ui->actionShow_Hidden_Images);
ui->actionSave_image->setData(point);
contextMnu->addAction(ui->actionSave_image);
}

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>667</width>
<height>323</height>
<height>334</height>
</rect>
</property>
<layout class="QGridLayout">
@ -206,16 +206,6 @@ border-image: url(:/images/closepressed.png)
</layout>
</widget>
</item>
<item>
<widget class="RSImageBlockWidget" name="imageBlockWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QSplitter" name="chatVSplitter">
<property name="orientation">
@ -989,6 +979,11 @@ border-image: url(:/images/closepressed.png)
<string>Don't replace tag with Emote Icon.</string>
</property>
</action>
<action name="actionShow_Hidden_Images">
<property name="text">
<string>Show Hidden Images</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@ -1017,17 +1012,10 @@ border-image: url(:/images/closepressed.png)
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
<customwidget>
<class>RSImageBlockWidget</class>
<extends>QWidget</extends>
<header>gui/common/RSImageBlockWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../emojione.qrc"/>
<include location="../images.qrc"/>
<include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -167,7 +167,7 @@ void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
PopupChatDialog::closeEvent(e) ;
}
QString PopupDistantChatDialog::getPeerName(const ChatId &id) const
QString PopupDistantChatDialog::getPeerName(const ChatId &/*id*/) const
{
DistantChatPeerInfo tinfo;

View file

@ -52,7 +52,9 @@ ElidedLabel::ElidedLabel(const QString &text, QWidget *parent)
, mElided(false)
, mOnlyPlainText(false)
, mContent(text)
, mTextColor(QColor())
{
setStyleSheet("background-color: rgba(0,0,0,0%)");
mRectElision = QRect();
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
@ -62,7 +64,9 @@ ElidedLabel::ElidedLabel(QWidget *parent)
, mElided(false)
, mOnlyPlainText(false)
, mContent("")
, mTextColor(QColor())
{
setStyleSheet("background-color: rgba(0,0,0,0%)");
mRectElision = QRect();
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
@ -94,7 +98,7 @@ void ElidedLabel::paintEvent(QPaintEvent *event)
QFontMetrics fontMetrics = painter.fontMetrics();
QRect cr = contentsRect();
cr.adjust(margin(), margin(), -margin(), -margin());
bool didElide = false;
QChar ellipsisChar(0x2026);//= "…"
int lineSpacing = fontMetrics.lineSpacing();
@ -225,3 +229,11 @@ void ElidedLabel::mousePressEvent(QMouseEvent *ev)
}
QLabel::mousePressEvent(ev);
}
void ElidedLabel::setTextColor(const QColor &color)
{
QPalette tmpPalette = palette();
tmpPalette.setColor(foregroundRole(), color);
setPalette(tmpPalette);
mTextColor = color;
}

View file

@ -53,6 +53,7 @@ class ElidedLabel : public QLabel
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY(bool isElided READ isElided)
Q_PROPERTY(bool isOnlyPlainText READ isOnlyPlainText WRITE setOnlyPlainText)
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
public:
ElidedLabel(const QString &text, QWidget *parent = 0);
@ -62,6 +63,9 @@ public:
bool isElided() const { return mElided; }
bool isOnlyPlainText() const { return mOnlyPlainText; }
QColor textColor() const { return mTextColor; }
void setTextColor(const QColor &color);
public slots:
void setText(const QString &text);
void setOnlyPlainText(const bool &value);
@ -79,6 +83,7 @@ private:
bool mOnlyPlainText;
QString mContent;
QRect mRectElision;
QColor mTextColor;
};
#endif // ELIDEDLABEL_H

View file

@ -34,6 +34,7 @@
#include "util/HandleRichText.h"
static QHash<QString, QString> Smileys;
static QVector<QString> order;
void Emoticons::load()
{
@ -115,6 +116,7 @@ void Emoticons::load()
} else {
Smileys.insert(smcode, smfile);
}
order.append(smcode);
}
}
@ -174,15 +176,15 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s
x = 0;
y = 0;
QHashIterator<QString, QString> i(Smileys);
QVectorIterator<QString> i(order);
while(i.hasNext())
{
i.next();
QString key = i.next();
QPushButton *smButton = new QPushButton("", smWidget);
smButton->setGeometry(x*buttonWidth, y*buttonHeight, buttonWidth, buttonHeight);
smButton->setIconSize(QSize(buttonWidth, buttonHeight));
smButton->setIcon(QPixmap(i.value()));
smButton->setToolTip(i.key());
smButton->setIcon(QPixmap(Smileys.value(key)));
smButton->setToolTip(key);
smButton->setStyleSheet("QPushButton:hover {border: 3px solid white; border-radius: 2px;}");
smButton->setFlat(true);
++x;

View file

@ -510,6 +510,7 @@ static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, Elided
if (!widget) {
widget = new QWidget;
widget->setAttribute(Qt::WA_TranslucentBackground);
nameLabel = new ElidedLabel(widget);
textLabel = new ElidedLabel(widget);

View file

@ -18,20 +18,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QMenu>
#include <QToolButton>
#include <QLabel>
#include <QMovie>
#include "retroshare/rsgxsflags.h"
#include "GroupTreeWidget.h"
#include "ui_GroupTreeWidget.h"
#include "RSItemDelegate.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QMovie>
#include <QToolButton>
#include "retroshare/rsgxsflags.h"
#include "PopularityDefs.h"
#include "gui/settings/rsharesettings.h"
#include "RSItemDelegate.h"
#include "RSTreeWidgetItem.h"
#include "gui/common/ElidedLabel.h"
#include "gui/settings/rsharesettings.h"
#include "util/QtVersion.h"
#include <stdint.h>
@ -55,6 +57,9 @@
#define FILTER_NAME_INDEX 0
#define FILTER_DESC_INDEX 1
Q_DECLARE_METATYPE(ElidedLabel*)
Q_DECLARE_METATYPE(QLabel*)
GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
QWidget(parent), ui(new Ui::GroupTreeWidget)
{
@ -116,6 +121,38 @@ GroupTreeWidget::~GroupTreeWidget()
delete ui;
}
static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, ElidedLabel *&nameLabel, QLabel *&waitLabel)
{
QWidget *widget = treeWidget->itemWidget(item, COLUMN_NAME);
if (!widget) {
widget = new QWidget;
widget->setAttribute(Qt::WA_TranslucentBackground);
nameLabel = new ElidedLabel(widget);
waitLabel = new QLabel(widget);
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
waitLabel->setMovie(movie);
waitLabel->setHidden(true);
widget->setProperty("nameLabel", qVariantFromValue(nameLabel));
widget->setProperty("waitLabel", qVariantFromValue(waitLabel));
QHBoxLayout *layout = new QHBoxLayout;
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(nameLabel);
layout->addWidget(waitLabel);
widget->setLayout(layout);
treeWidget->setItemWidget(item, COLUMN_NAME, widget);
} else {
nameLabel = widget->property("nameLabel").value<ElidedLabel*>();
waitLabel = widget->property("waitLabel").value<QLabel*>();
}
}
void GroupTreeWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
@ -229,7 +266,7 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton)
actionSortByLastPost = displayMenu->addAction(QIcon(), tr("Sort by Last Post"), this, SLOT(sort()));
actionSortByLastPost->setCheckable(true);
actionSortByLastPost->setActionGroup(actionGroup);
actionSortByPosts = displayMenu->addAction(QIcon(), tr("Sort by Posts"), this, SLOT(sort()));
actionSortByPosts->setCheckable(true);
actionSortByPosts->setActionGroup(actionGroup);
@ -255,6 +292,11 @@ void GroupTreeWidget::updateColors()
}
item->setForeground(COLUMN_NAME, brush);
ElidedLabel *nameLabel = NULL;
QLabel *waitLabel = NULL;
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
nameLabel->setTextColor(brush.color());
}
}
@ -293,21 +335,27 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc
{
QFont font;
QTreeWidgetItem *item = new QTreeWidgetItem();
ui->treeWidget->addTopLevelItem(item);
ElidedLabel *nameLabel = NULL;
QLabel *waitLabel = NULL;
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
nameLabel->setText(name);
item->setData(COLUMN_DATA, ROLE_NAME, name);
font = item->font(COLUMN_NAME);
font.setBold(true);
item->setText(COLUMN_NAME, name);
item->setData(COLUMN_DATA, ROLE_NAME, name);
item->setFont(COLUMN_NAME, font);
nameLabel->setFont(font);
item->setIcon(COLUMN_NAME, icon);
int S = QFontMetricsF(font).height();
int S = QFontMetricsF(font).height();
item->setSizeHint(COLUMN_NAME, QSize(S*1.1, S*1.1));
item->setSizeHint(COLUMN_NAME, QSize(S*1.1, S*1.1));
item->setForeground(COLUMN_NAME, QBrush(textColorCategory()));
nameLabel->setTextColor(textColorCategory());
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_CATEGORY);
ui->treeWidget->addTopLevelItem(item);
item->setExpanded(expand);
return item;
@ -334,114 +382,119 @@ QString GroupTreeWidget::itemIdAt(QPoint &point)
void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList)
{
if (categoryItem == NULL) {
return;
}
if (categoryItem == NULL) {
return;
}
QString filterText = ui->filterLineEdit->text();
QString filterText = ui->filterLineEdit->text();
/* Iterate all items */
QList<GroupItemInfo>::const_iterator it;
for (it = itemList.begin(); it != itemList.end(); ++it) {
const GroupItemInfo &itemInfo = *it;
/* Iterate all items */
QList<GroupItemInfo>::const_iterator it;
for (it = itemList.begin(); it != itemList.end(); ++it) {
const GroupItemInfo &itemInfo = *it;
QTreeWidgetItem *item = NULL;
QTreeWidgetItem *item = NULL;
/* Search exisiting item */
int childCount = categoryItem->childCount();
for (int child = 0; child < childCount; ++child) {
QTreeWidgetItem *childItem = categoryItem->child(child);
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
/* Found child */
item = childItem;
break;
}
}
/* Search exisiting item */
int childCount = categoryItem->childCount();
for (int child = 0; child < childCount; ++child) {
QTreeWidgetItem *childItem = categoryItem->child(child);
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
/* Found child */
item = childItem;
break;
}
}
if (item == NULL) {
item = new RSTreeWidgetItem(compareRole);
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
categoryItem->addChild(item);
}
if (item == NULL) {
item = new RSTreeWidgetItem(compareRole);
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
categoryItem->addChild(item);
}
item->setText(COLUMN_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
ElidedLabel *nameLabel = NULL;
QLabel *waitLabel = NULL;
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
/* Set last post */
qlonglong lastPost = itemInfo.lastpost.toTime_t();
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
nameLabel->setText(itemInfo.name);
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
/* Set visible posts */
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
/* Set last post */
qlonglong lastPost = itemInfo.lastpost.toTime_t();
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
/* Set icon */
if (ui->treeWidget->itemWidget(item, COLUMN_NAME)) {
/* Item is waiting, save icon in role */
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
} else {
item->setIcon(COLUMN_NAME, itemInfo.icon);
}
/* Set visible posts */
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
/* Set popularity */
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
/* Set icon */
if (waitLabel->isVisible()) {
/* Item is waiting, save icon in role */
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
} else {
item->setIcon(COLUMN_NAME, itemInfo.icon);
}
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
/* Set popularity */
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
/* Set tooltip */
if (itemInfo.adminKey)
tooltip += "\n" + tr("You are admin (modify names and description using Edit menu)");
else if (itemInfo.publishKey)
tooltip += "\n" + tr("You have been granted as publisher (you can post here!)");
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
{
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
tooltip += "\n" + tr("Subscribe to download and read messages") ;
}
/* Set tooltip */
if (itemInfo.adminKey)
tooltip += "\n" + tr("You are admin (modify names and description using Edit menu)");
else if (itemInfo.publishKey)
tooltip += "\n" + tr("You have been granted as publisher (you can post here!)");
item->setToolTip(COLUMN_NAME, tooltip);
item->setToolTip(COLUMN_POPULARITY, tooltip);
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
{
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
tooltip += "\n" + tr("Subscribe to download and read messages") ;
}
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
item->setToolTip(COLUMN_NAME, tooltip);
item->setToolTip(COLUMN_POPULARITY, tooltip);
/* Set color */
QBrush brush;
if (itemInfo.publishKey) {
brush = QBrush(textColorPrivateKey());
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
} else {
brush = ui->treeWidget->palette().color(QPalette::Text);
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
}
item->setForeground(COLUMN_NAME, brush);
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
/* Calculate score */
calculateScore(item, filterText);
}
/* Set color */
QBrush brush;
if (itemInfo.publishKey) {
brush = QBrush(textColorPrivateKey());
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
} else {
brush = ui->treeWidget->palette().color(QPalette::Text);
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
}
item->setForeground(COLUMN_NAME, brush);
nameLabel->setTextColor(brush.color());
/* Remove all items not in list */
int child = 0;
int childCount = categoryItem->childCount();
while (child < childCount) {
QString id = categoryItem->child(child)->data(COLUMN_DATA, ROLE_ID).toString();
/* Calculate score */
calculateScore(item, filterText);
}
for (it = itemList.begin(); it != itemList.end(); ++it) {
if (it->id == id) {
break;
}
}
/* Remove all items not in list */
int child = 0;
int childCount = categoryItem->childCount();
while (child < childCount) {
QString id = categoryItem->child(child)->data(COLUMN_DATA, ROLE_ID).toString();
if (it == itemList.end()) {
delete(categoryItem->takeChild(child));
childCount = categoryItem->childCount();
} else {
++child;
}
}
for (it = itemList.begin(); it != itemList.end(); ++it) {
if (it->id == id) {
break;
}
}
resort(categoryItem);
if (it == itemList.end()) {
delete(categoryItem->takeChild(child));
childCount = categoryItem->childCount();
} else {
++child;
}
}
resort(categoryItem);
}
void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
@ -449,19 +502,22 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
if (item == NULL) {
return;
}
ElidedLabel *nameLabel = NULL;
QLabel *waitLabel = NULL;
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
QString name = item->data(COLUMN_DATA, ROLE_NAME).toString();
QFont font = item->font(COLUMN_NAME);
QFont font = nameLabel->font();
if (unreadCount) {
name += QString(" (%1)").arg(unreadCount);
name = QString("(%1) ").arg(unreadCount) + name;
font.setBold(true);
} else {
font.setBold(false);
}
item->setText(COLUMN_NAME, name);
item->setFont(COLUMN_NAME, font);
nameLabel->setText(name);
nameLabel->setFont(font);
}
QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id)
@ -507,9 +563,11 @@ bool GroupTreeWidget::setWaiting(const QString &id, bool wait)
return false;
}
QWidget *w = ui->treeWidget->itemWidget(item, COLUMN_NAME);
ElidedLabel *nameLabel = NULL;
QLabel *waitLabel = NULL;
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
if (wait) {
if (w) {
if (waitLabel->isVisible()) {
/* Allready waiting */
} else {
/* Save icon in role */
@ -519,21 +577,19 @@ bool GroupTreeWidget::setWaiting(const QString &id, bool wait)
/* Create empty icon of the same size */
QPixmap pixmap(ui->treeWidget->iconSize());
pixmap.fill(Qt::transparent);
item->setIcon(COLUMN_NAME, QIcon(pixmap));
QLabel *label = new QLabel(this);
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
label->setMovie(movie);
ui->treeWidget->setItemWidget(item, COLUMN_NAME, label);
movie->start();
/* Show waitLabel and hide nameLabel */
nameLabel->setHidden(true);
waitLabel->setVisible(true);
waitLabel->movie()->start();
}
} else {
if (w) {
ui->treeWidget->setItemWidget(item, COLUMN_NAME, NULL);
delete(w);
if (waitLabel->isVisible()) {
/* Show nameLabel and hide waitLabel */
waitLabel->movie()->stop();
waitLabel->setHidden(true);
nameLabel->setVisible(true);
/* Set icon saved in role */
item->setIcon(COLUMN_NAME, item->data(COLUMN_DATA, ROLE_SAVED_ICON).value<QIcon>());

View file

@ -393,10 +393,12 @@ void RSGraphWidget::paintData()
paintLine(points, getColor(i));
}
if(_maxValue > 0.0f)
{
if(_flags & RSGRAPH_FLAGS_LOG_SCALE_Y)
_y_scale = _rec.height()*0.8 / log(_maxValue) ;
else
_y_scale = _rec.height()*0.8/_maxValue ;
}
}
/** Returns a list of points on the bandwidth graph based on the supplied set

View file

@ -1,8 +1,9 @@
#include <iostream>
#include <QDir>
#include <QDesktopServices>
#include <QDir>
#include <QPainter>
#include <QTextDocumentFragment>
#include "RSTextBrowser.h"
#include "RSImageBlockWidget.h"
@ -19,7 +20,7 @@ RSTextBrowser::RSTextBrowser(QWidget *parent) :
mImageBlockWidget = NULL;
mLinkClickActive = true;
highliter = new RsSyntaxHighlighter(this);
highlighter = new RsSyntaxHighlighter(this);
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
}
@ -73,6 +74,23 @@ void RSTextBrowser::paintEvent(QPaintEvent *event)
painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, mPlaceholderText);
}
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
QPainter painter(viewport());
QPen pen = painter.pen();
pen.setWidth(2);
pen.setColor(QColor(qRgba(255,0,0,128)));
painter.setPen(pen);
painter.drawRect(mCursorRectStart);
pen.setColor(QColor(qRgba(0,255,0,128)));
painter.setPen(pen);
painter.drawRect(mCursorRectLeft);
pen.setColor(QColor(qRgba(0,0,255,128)));
painter.setPen(pen);
painter.drawRect(mCursorRectRight);
pen.setColor(QColor(qRgba(0,0,0,128)));
painter.setPen(pen);
painter.drawRect(mCursorRectEnd);
#endif
}
QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
@ -103,6 +121,11 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
if (mImageBlockWidget)
mImageBlockWidget->show();
return getBlockedImage();
}
QPixmap RSTextBrowser::getBlockedImage()
{
return QPixmap(":/images/imageblocked_24.png");
}
@ -159,3 +182,61 @@ void RSTextBrowser::activateLinkClick(bool active)
{
mLinkClickActive = active;
}
/**
* @brief RSTextBrowser::checkImage
* @param pos where to check if image is shown in viewport coordinate
* @param imageStr return html source of cursor
* @return True if an image is under cursor
*/
bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr)
{
//Get text cursor under pos. But if pos is under text browser end line this return last cursor.
QTextCursor cursor = cursorForPosition(pos);
//First get rect of cursor (could be at left or right of image)
QRect cursorRectStart = cursorRect(cursor);
//Second get text
cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1);//To get character just before
QRect cursorRectLeft = cursorRect(cursor);
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2);
QRect cursorRectRight = cursorRect(cursor);
imageStr = cursor.selection().toHtml();
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
mCursorRectStart = cursorRectStart;
mCursorRectLeft = cursorRectLeft;
mCursorRectRight = cursorRectRight;
std::cerr << "cursorRect LTRB :" << cursorRectStart.left() << ";" << cursorRectStart.top() << ";" << cursorRectStart.right() << ";" << cursorRectStart.bottom() << std::endl;
std::cerr << "cursorRectLeft :" << cursorRectLeft.left() << ";" << cursorRectLeft.top() << ";" << cursorRectLeft.right() << ";" << cursorRectLeft.bottom() << std::endl;
std::cerr << "cursorRectRight :" << cursorRectRight.left() << ";" << cursorRectRight.top() << ";" << cursorRectRight.right() << ";" << cursorRectRight.bottom() << std::endl;
std::cerr << "pos XY :" << pos.x() << ";" << pos.y() << std::endl;
#endif
QRect cursorRectEnd = cursorRectStart;
//Finally set left with right of precedent character.
if (cursorRectEnd.top() < cursorRectLeft.bottom())
{
cursorRectEnd.setLeft(cursorRectLeft.right());
} else {
//Image on new line
cursorRectEnd.setLeft(0);
}
//And set Right with left of next character.
if (cursorRectEnd.bottom() > cursorRectRight.top())
{
cursorRectEnd.setRight(cursorRectRight.left());
} else {
//New line after Image.
}
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
mCursorRectEnd = cursorRectEnd;
std::cerr << "final cursorRect:" << cursorRectEnd.left() << ";" << cursorRectEnd.top() << ";" << cursorRectEnd.right() << ";" << cursorRectEnd.bottom() << std::endl;
viewport()->update();
#endif
//If pos is on text rect
if (cursorRectEnd.contains(pos))
{
return imageStr.indexOf("base64,") != -1;
}
return false;
}

View file

@ -4,6 +4,8 @@
#include <QTextBrowser>
#include "util/RsSyntaxHighlighter.h"
//#define RSTEXTBROWSER_CHECKIMAGE_DEBUG 1
class RSImageBlockWidget;
class RSTextBrowser : public QTextBrowser
@ -18,16 +20,20 @@ public:
void setPlaceholderText(const QString &text);
void setImageBlockWidget(RSImageBlockWidget *widget);
void resetImagesStatus(bool load);
QPixmap getBlockedImage();
bool checkImage(QPoint pos, QString &imageStr);
bool checkImage(QPoint pos) {QString imageStr; return checkImage(pos, imageStr); }
void activateLinkClick(bool active);
virtual QVariant loadResource(int type, const QUrl &name);
QColor textColorQuote() const { return highliter->textColorQuote();}
QColor textColorQuote() const { return highlighter->textColorQuote();}
bool getShowImages() const { return mShowImages; }
public slots:
void showImages();
void setTextColorQuote(QColor textColorQuote) { highliter->setTextColorQuote(textColorQuote);}
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
private slots:
void linkClicked(const QUrl &url);
@ -41,7 +47,13 @@ private:
bool mShowImages;
RSImageBlockWidget *mImageBlockWidget;
bool mLinkClickActive;
RsSyntaxHighlighter *highliter;
RsSyntaxHighlighter *highlighter;
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
QRect mCursorRectStart;
QRect mCursorRectLeft;
QRect mCursorRectRight;
QRect mCursorRectEnd;
#endif
};
#endif // RSTEXTBROWSER_H

View file

@ -25,19 +25,24 @@
/** Constructor */
StyledElidedLabel::StyledElidedLabel(QWidget *parent)
: ElidedLabel(parent)
: ElidedLabel(parent), _lastFactor(-1)
{
}
StyledElidedLabel::StyledElidedLabel(const QString &text, QWidget *parent)
: ElidedLabel(text, parent)
: ElidedLabel(text, parent), _lastFactor(-1)
{
}
void StyledElidedLabel::setFontSizeFactor(int factor)
{
QFont f = font();
qreal fontSize = factor * f.pointSizeF() / 100;
f.setPointSizeF(fontSize);
setFont(f);
int newFactor = factor;
if (factor > 0) {
if (_lastFactor > 0) newFactor = 100 + factor - _lastFactor;
_lastFactor = factor;
QFont f = font();
qreal fontSize = newFactor * f.pointSizeF() / 100;
f.setPointSizeF(fontSize);
setFont(f);
}
}

View file

@ -34,6 +34,9 @@ public:
StyledElidedLabel(const QString &text, QWidget *parent = NULL);
void setFontSizeFactor(int factor);
private:
int _lastFactor;
};
#endif

View file

@ -418,19 +418,21 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId;
std::cerr << std::endl;
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL);
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL) ;
QString text;
{
QDateTime qtime;
qtime.setTime_t(comment.mMeta.mPublishTs);
QDateTime qtime ;
qtime.setTime_t(comment.mMeta.mPublishTs) ;
text = qtime.toString("yyyy-MM-dd hh:mm:ss");
item->setText(PCITEM_COLUMN_DATE, text);
text = qtime.toString("yyyy-MM-dd hh:mm:ss") ;
item->setText(PCITEM_COLUMN_DATE, text) ;
item->setToolTip(PCITEM_COLUMN_DATE, text) ;
}
text = QString::fromUtf8(comment.mComment.c_str());
item->setText(PCITEM_COLUMN_COMMENT, text);
item->setToolTip(PCITEM_COLUMN_COMMENT, text);
RsGxsId authorId = comment.mMeta.mAuthorId;
item->setId(authorId, PCITEM_COLUMN_AUTHOR, false);

View file

@ -13,9 +13,9 @@
<property name="windowTitle">
<string>Make Comment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="GxsCreateCommentDialogVLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
@ -26,11 +26,11 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="mainVLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="signedHLayout">
<item>
<spacer name="horizontalSpacer">
<spacer name="signedHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -43,7 +43,7 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item>
<widget class="QLabel" name="subjectLabel">
<widget class="QLabel" name="signedLabel">
<property name="text">
<string>Signed by</string>
</property>
@ -55,7 +55,7 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<widget class="QTextEdit" name="commentTextEdit"/>
<widget class="MimeTextEdit" name="commentTextEdit"/>
</item>
</layout>
</item>
@ -72,6 +72,11 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>

View file

@ -195,7 +195,7 @@ bool GxsIdChooser::isInConstraintSet(const RsGxsId& id) const
return mConstraintIdsSet.find(id) != mConstraintIdsSet.end() ;
}
void GxsIdChooser::setEntryEnabled(int indx,bool enabled)
void GxsIdChooser::setEntryEnabled(int indx,bool /*enabled*/)
{
removeItem(indx) ;

View file

@ -59,7 +59,7 @@ void GxsMessageFramePostWidget::groupIdChanged()
fillComplete();
}
QString GxsMessageFramePostWidget::groupName(bool withUnreadCount)
QString GxsMessageFramePostWidget::groupName(bool /*withUnreadCount*/)
{
QString name = groupId().isNull () ? tr("No name") : mGroupName;

View file

@ -20,8 +20,17 @@
<iconset resource="../images.qrc">
<normaloff>:/images/logo/logo_16.png</normaloff>:/images/logo/logo_16.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="margin">
<layout class="QGridLayout" name="CreateGxsChannelMsgGLayout">
<property name="leftMargin">
<number>0</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">
@ -31,14 +40,14 @@
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_2">
<widget class="QFrame" name="mainFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<layout class="QGridLayout" name="mainFrameGLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="mouseTracking">
@ -53,15 +62,15 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="channelPostTab">
<attribute name="title">
<string>Channel Post</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<layout class="QGridLayout" name="channelPostTabGLayout">
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="channelNameHLayout">
<item>
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="channelNameLabel">
<property name="font">
<font>
<weight>75</weight>
@ -86,9 +95,9 @@
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="channelAttachGLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="channelAttachLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
@ -157,15 +166,15 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="messageGBox">
<property name="title">
<string>Message</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="messageGBoxVLayout">
<item>
<layout class="QHBoxLayout">
<layout class="QHBoxLayout" name="subjectHLayout">
<item>
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="subjectLabel">
<property name="font">
<font>
<weight>75</weight>
@ -183,14 +192,14 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<widget class="QTextEdit" name="msgEdit"/>
<widget class="MimeTextEdit" name="msgEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<widget class="QWidget" name="attachmentsTab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/attachment.png</normaloff>:/images/attachment.png</iconset>
@ -198,9 +207,9 @@ p, li { white-space: pre-wrap; }
<attribute name="title">
<string>Attachments</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<layout class="QGridLayout" name="attachmentsTabGLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="attachmentsPixLabel">
<property name="text">
<string/>
</property>
@ -210,7 +219,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="attachmentsLabel">
<property name="maximumSize">
<size>
<width>16777215</width>
@ -229,7 +238,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="0" column="2">
<spacer>
<spacer name="attachmentsHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -281,7 +290,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="QScrollArea" name="scrollArea">
<widget class="QScrollArea" name="attachmentsScrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
@ -293,7 +302,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<width>523</width>
<height>24</height>
</rect>
</property>
@ -303,11 +312,20 @@ p, li { white-space: pre-wrap; }
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="scrollAreaWidgetContentsVLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
@ -324,7 +342,7 @@ p, li { white-space: pre-wrap; }
<property name="toolTip">
<string>Drag and Drop Files from Search Results</string>
</property>
<layout class="QGridLayout" name="gridLayout_3"/>
<layout class="QGridLayout" name="fileFrameGLayout"/>
</widget>
</item>
</layout>
@ -336,7 +354,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="buttonHLayout">
<item>
<widget class="QCheckBox" name="generateCheckBox">
<property name="text">
@ -378,10 +396,14 @@ p, li { white-space: pre-wrap; }
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -517,8 +517,7 @@ void GxsForumThreadWidget::contextMenuTextBrowser(QPoint point)
contextMnu->addSeparator();
QTextCursor cursor = ui->postText->cursorForPosition(point);
if(ImageUtil::checkImage(cursor))
if(ui->postText->checkImage(point))
{
ui->actionSave_image->setData(point);
contextMnu->addAction(ui->actionSave_image);

View file

@ -486,7 +486,7 @@ void ServerPage::addPeerToIPTable(QTableWidget *table,int row,const BanListPeer&
void ServerPage::toggleGroupIps(bool b) { rsBanList->enableAutoRange(b) ; }
void ServerPage::setGroupIpLimit(int n) { rsBanList->setAutoRangeLimit(n) ; }
void ServerPage::ipFilterContextMenu(const QPoint& point)
void ServerPage::ipFilterContextMenu(const QPoint& /*point*/)
{
QMenu contextMenu(this) ;
int row = ui.filteredIpsTable->currentRow();
@ -604,7 +604,7 @@ void ServerPage::ipWhiteListContextMenu(const QPoint& /* point */)
if(item == NULL)
return ;
bool status = item->data(Qt::UserRole).toBool();
//bool status = item->data(Qt::UserRole).toBool();
contextMenu.addAction(tr("Remove"),this,SLOT(removeWhiteListedIp()));

View file

@ -789,7 +789,10 @@ bool RshareSettings::getRetroShareProtocol()
}
}
#elif defined(Q_OS_LINUX)
QFile desktop("/usr/share/applications/RetroShare06.desktop");
QFile desktop("/usr/share/applications/retroshare06.desktop");
if (!desktop.exists()) {
desktop.setFileName("/usr/share/applications/RetroShare06.desktop");
}
if (desktop.exists()) {
desktop.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in(&desktop);
@ -799,7 +802,7 @@ bool RshareSettings::getRetroShareProtocol()
}
desktop.close();
if (lines.contains("Exec=" + getAppPathForProtocol()))
if (lines.contains("MimeType=x-scheme-handler/retroshare"))
if (lines.contains("MimeType=x-scheme-handler/retroshare;"))
return true;
}
#else