Removed dialog FriendRequest and use ConnectFriendWizard instead.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5482 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-08-28 23:39:11 +00:00
parent 51e0f5e679
commit e49854ee25
11 changed files with 220 additions and 710 deletions

View File

@ -64,6 +64,8 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
/* add stylesheet to title */
QList<int> ids = pageIds();
for (QList<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
@ -119,6 +121,17 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
}
}
void ConnectFriendWizard::setGpgId(const std::string &gpgId, bool friendRequest)
{
if (!rsPeers->getPeerDetails(gpgId, peerDetails)) {
setField("errorMessage", tr("Cannot get peer details of gpg key %1").arg(QString::fromStdString(gpgId)));
setStartId(Page_ErrorMessage);
return;
}
setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
}
ConnectFriendWizard::~ConnectFriendWizard()
{
delete ui;

View File

@ -31,6 +31,7 @@ public:
~ConnectFriendWizard();
void setCertificate(const QString &certificate, bool friendRequest);
void setGpgId(const std::string &gpgId, bool friendRequest);
virtual bool validateCurrentPage();
virtual int nextId() const;

View File

@ -557,7 +557,7 @@ background: white;
</font>
</property>
<property name="text">
<string>You have a friend request .</string>
<string notr="true">You have a friend request from</string>
</property>
</widget>
</item>

View File

@ -1,141 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012, RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "FriendRequest.h"
#include <QMessageBox>
#include <QDateTime>
#include <QMenu>
#include <QClipboard>
#include <QMap>
#include <iostream>
#include <retroshare/rspeers.h>
#include <retroshare/rsdisc.h>
#include <retroshare/rsmsgs.h>
#include "gui/help/browser/helpbrowser.h"
#include "gui/common/PeerDefs.h"
#include "gui/common/StatusDefs.h"
#include "gui/RetroShareLink.h"
#include "gui/notifyqt.h"
#include "gui/common/AvatarDefs.h"
/* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss"
/** Default constructor */
FriendRequest::FriendRequest(const std::string& id, QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags), mId(id)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
ui.headerFrame->setHeaderImage(QPixmap(":/images/user/user_request48.png"));
ui.headerFrame->setHeaderText(tr("Friend Request"));
setAttribute(Qt::WA_DeleteOnClose, true);
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close()));
load();
}
/** Destructor. */
FriendRequest::~FriendRequest()
{
}
void FriendRequest::load()
{
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(mId, detail))
{
QMessageBox::information(this,
tr("RetroShare"),
tr("Error : cannot get peer details."));
close();
return;
}
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
ui.peerid->setText(QString::fromStdString(detail.id));
ui.avatar->setId(mId, false);
}
void FriendRequest::applyDialog()
{
std::cerr << "FriendRequest::applyDialog() called" << std::endl ;
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(mId, detail))
{
if (!rsPeers->getGPGDetails(mId, detail)) {
QMessageBox::information(this,
tr("RetroShare"),
tr("Error : cannot get peer details."));
close();
return;
}
}
makeFriend();
close();
}
void FriendRequest::makeFriend()
{
std::string gpg_id = rsPeers->getGPGId(mId);
if (ui.signGPGKeyCheckBox->isChecked()) {
rsPeers->signGPGCertificate(gpg_id);
}
rsPeers->addFriend(mId, gpg_id);
emit configChanged();
}
void FriendRequest::denyFriend()
{
std::string gpg_id = rsPeers->getGPGId(mId);
rsPeers->removeFriend(gpg_id);
emit configChanged();
}
void FriendRequest::signGPGKey()
{
std::string gpg_id = rsPeers->getGPGId(mId);
if (!rsPeers->signGPGCertificate(gpg_id)) {
QMessageBox::warning ( NULL,
tr("Signature Failure"),
tr("Maybe password is wrong"),
QMessageBox::Ok);
}
emit configChanged();
}

View File

@ -1,61 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012, 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 _FRIENDREQUEST_H
#define _FRIENDREQUEST_H
#include <QDialog>
#include "ui_FriendRequest.h"
class FriendRequest : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
FriendRequest(const std::string& id, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
~FriendRequest();
signals:
void configChanged();
private:
void load();
private slots:
void applyDialog();
void makeFriend();
void denyFriend();
void signGPGKey();
private:
std::string mId;
/** Qt Designer generated object */
Ui::FriendRequest ui;
};
#endif

View File

@ -1,284 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FriendRequest</class>
<widget class="QDialog" name="FriendRequest">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<height>294</height>
</rect>
</property>
<property name="windowTitle">
<string>Friend Request</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="avatarFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0" colspan="2">
<widget class="AvatarWidget" name="avatar">
<property name="minimumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Peer Info</string>
</property>
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QLabel" name="label_name">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_id">
<property name="text">
<string>Peer ID</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="peerid">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">
border: 2px solid #CCCCCC;
border-radius:6px;
background: white;
</string>
</property>
<property name="text">
<string>You have a friend request.</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QCheckBox" name="signGPGKeyCheckBox">
<property name="text">
<string>Sign GPG Key</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>6</number>
</property>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>175</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="styleSheet">
<string notr="true">QToolButton, QPushButton, QComboBox {
border-image: url(:/images/btn_26.png) 4;
border-width: 4;
padding: 0px 6px;
font-size: 12px;
}
QToolButton:hover, QPushButton:hover, QComboBox:hover {
border-image: url(:/images/btn_26_hover.png) 4;
}</string>
</property>
<property name="text">
<string>Cancel</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="applyButton">
<property name="toolTip">
<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;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Accept Request and Close&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet">
<string notr="true">QToolButton, QPushButton, QComboBox {
border-image: url(:/images/btn_blue.png) 4;
border-width: 4;
padding: 0px 6px;
font-size: 12px;
color: white;
}
QToolButton:hover, QPushButton:hover, QComboBox:hover {
border-image: url(:/images/btn_blue_hover.png) 4;
}</string>
</property>
<property name="text">
<string>Confirm</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="Line" name="line">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QLabel</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -29,7 +29,7 @@
#include "gui/msgs/MessageComposer.h"
#include "gui/common/StatusDefs.h"
#include "gui/connect/ConfCertDialog.h"
#include "gui/connect/FriendRequest.h"
#include "gui/connect/ConnectFriendWizard.h"
#include "gui/common/AvatarDefs.h"
#include "gui/notifyqt.h"
@ -330,9 +330,10 @@ void SecurityItem::friendRequest()
std::cerr << "SecurityItem::friendReguest()";
std::cerr << std::endl;
#endif
FriendRequest *frDlg = new FriendRequest(mGpgId);
frDlg->show();
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
connectFriendWizard->setGpgId(mGpgId, true);
connectFriendWizard->show();
}
void SecurityItem::peerDetails()

View File

@ -19,7 +19,7 @@
#include "FriendRequestToaster.h"
#include "gui/FriendsDialog.h"
#include "gui/connect/FriendRequest.h"
#include "gui/connect/ConnectFriendWizard.h"
#include "util/WidgetBackgroundImage.h"
#include <retroshare/rspeers.h>
@ -61,7 +61,9 @@ FriendRequestToaster::FriendRequestToaster(const std::string &gpgId, const QStri
void FriendRequestToaster::friendrequestButtonSlot()
{
FriendRequest *frDlg = new FriendRequest(mGpgId);
frDlg->show();
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
connectFriendWizard->setGpgId(mGpgId, true);
connectFriendWizard->show();
hide();
}

File diff suppressed because it is too large Load Diff

View File

@ -311,7 +311,6 @@ HEADERS += rshare.h \
gui/channels/ShareKey.h \
gui/channels/ChannelUserNotify.h \
gui/connect/ConfCertDialog.h \
gui/connect/FriendRequest.h \
gui/msgs/MessageComposer.h \
gui/msgs/MessageWindow.h \
gui/msgs/MessageWidget.h \
@ -462,7 +461,6 @@ FORMS += gui/StartDialog.ui \
gui/chat/CreateLobbyDialog.ui \
gui/ChatLobbyWidget.ui \
gui/connect/ConfCertDialog.ui \
gui/connect/FriendRequest.ui \
gui/connect/ConnectFriendWizard.ui \
gui/msgs/MessageComposer.ui \
gui/msgs/MessageWindow.ui\
@ -607,7 +605,6 @@ SOURCES += main.cpp \
gui/chat/ChatStyle.cpp \
gui/chat/ChatUserNotify.cpp \
gui/connect/ConfCertDialog.cpp \
gui/connect/FriendRequest.cpp \
gui/msgs/MessageComposer.cpp \
gui/msgs/MessageWidget.cpp \
gui/msgs/MessageWindow.cpp \