gui implementations

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2025 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-13 21:32:56 +00:00
parent 54c7f8b81a
commit 442577d9fc
8 changed files with 368 additions and 198 deletions

View File

@ -87,6 +87,9 @@ NetworkDialog::NetworkDialog(QWidget *parent)
_settings = new RshareSettings();
connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.connecttreeWidget, SIGNAL( itemSelectionChanged()), ui.unvalidGPGkeyWidget, SLOT( clearSelection() ) );
connect( ui.unvalidGPGkeyWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.unvalidGPGkeyWidget, SIGNAL( itemSelectionChanged()), ui.connecttreeWidget, SLOT( clearSelection() ) );
/* create a single connect dialog */
connectdialog = new ConnectDialog();
@ -120,7 +123,29 @@ NetworkDialog::NetworkDialog(QWidget *parent)
headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(4, Qt::AlignVCenter);
ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
/* hide the Tree +/- */
ui.unvalidGPGkeyWidget -> setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */
ui.unvalidGPGkeyWidget->header()->setResizeMode (0, QHeaderView::Custom);
ui.unvalidGPGkeyWidget->header()->setResizeMode (1, QHeaderView::Interactive);
ui.unvalidGPGkeyWidget->header()->setResizeMode (2, QHeaderView::Interactive);
ui.unvalidGPGkeyWidget->header()->setResizeMode (3, QHeaderView::Interactive);
ui.unvalidGPGkeyWidget->header()->setResizeMode (4, QHeaderView::Interactive);
ui.unvalidGPGkeyWidget->header()->resizeSection ( 0, 25 );
ui.unvalidGPGkeyWidget->header()->resizeSection ( 1, 200 );
ui.unvalidGPGkeyWidget->header()->resizeSection ( 2, 200 );
ui.unvalidGPGkeyWidget->header()->resizeSection ( 3, 200 );
// set header text aligment
ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(4, Qt::AlignVCenter);
//ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
QString version = "-";
@ -173,7 +198,7 @@ NetworkDialog::NetworkDialog(QWidget *parent)
void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
{
std::cerr << "NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
QTreeWidgetItem *wi = getCurrentNeighbour();
if (!wi)
return;
@ -193,7 +218,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
if(peer_id != rsPeers->getGPGOwnId())
{
if(detail.ownsign)
if(detail.accept_connection)
{
denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), this );
@ -341,11 +366,7 @@ void NetworkDialog::insertConnect()
std::list<std::string> neighs; //these are GPG ids
std::list<std::string>::iterator it;
if (ui.showUnvalidKeys->isChecked()) {
rsPeers->getGPGAllList(neighs);
} else {
rsPeers->getGPGValidList(neighs);
}
/* get a link to the table */
QTreeWidget *connectWidget = ui.connecttreeWidget;
@ -360,7 +381,8 @@ void NetworkDialog::insertConnect()
RsPeerDetails ownGPGDetails ;
rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
QList<QTreeWidgetItem *> items;
QList<QTreeWidgetItem *> validItems;
QList<QTreeWidgetItem *> unvalidItems;
for(it = neighs.begin(); it != neighs.end(); it++)
{
if (*it == rsPeers->getGPGOwnId()) {
@ -413,7 +435,7 @@ void NetworkDialog::insertConnect()
*/
QColor backgrndcolor;
if (detail.ownsign)
if (detail.accept_connection)
{
item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
backgrndcolor=Qt::green;
@ -423,7 +445,7 @@ void NetworkDialog::insertConnect()
if (detail.hasSignedMe)
{
backgrndcolor=Qt::magenta;
item -> setIcon(0,(QIcon(IMAGE_TRUSTED)));
item -> setIcon(0,(QIcon(IMAGE_DENIED)));
for(int k=0;k<8;++k)
item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."))) ;
}
@ -440,7 +462,11 @@ void NetworkDialog::insertConnect()
item -> setBackground(i,QBrush(backgrndcolor));
/* add to the list */
items.append(item);
if (detail.accept_connection || detail.validLvl >= 3) {
validItems.append(item);
} else {
unvalidItems.append(item);
}
}
@ -457,41 +483,44 @@ void NetworkDialog::insertConnect()
self_item->setBackground(i,QBrush(Qt::green));
}
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
items.append(self_item);
validItems.append(self_item);
/* remove old items ??? */
connectWidget->clear();
connectWidget->setColumnCount(5);
ui.unvalidGPGkeyWidget->clear();
ui.unvalidGPGkeyWidget->setColumnCount(5);
/* add the items in! */
connectWidget->insertTopLevelItems(0, items);
if (newSelect)
{
connectWidget->insertTopLevelItems(0, validItems);
ui.unvalidGPGkeyWidget->insertTopLevelItems(0, unvalidItems);
if (newSelect) {
connectWidget->setCurrentItem(newSelect);
ui.unvalidGPGkeyWidget->setCurrentItem(newSelect);
}
connectWidget->sortItems( 1, Qt::AscendingOrder );
ui.unvalidGPGkeyWidget->sortItems( 1, Qt::AscendingOrder );
if (ui.showUnvalidKeys->isChecked()) {
ui.unvalidGPGkeyWidget->show();
} else {
ui.unvalidGPGkeyWidget->hide();
}
connectWidget->update(); /* update display */
ui.unvalidGPGkeyWidget->update(); /* update display */
}
QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
{
/* get the current, and extract the Id */
/* get a link to the table */
QTreeWidget *connectWidget = ui.connecttreeWidget;
QTreeWidgetItem *item = connectWidget -> currentItem();
if (!item)
{
#ifdef NET_DEBUG
std::cerr << "Invalid Current Item" << std::endl;
#endif
return NULL;
if (ui.connecttreeWidget->selectedItems().size() != 0) {
return ui.connecttreeWidget -> currentItem();
} else if (ui.unvalidGPGkeyWidget->selectedItems().size() != 0) {
return ui.unvalidGPGkeyWidget->currentItem();
}
/* Display the columns of this item. */
return item;
return NULL;
}
/* Utility Fns */

View File

@ -64,6 +64,7 @@ private slots:
void peerdetails();
/** Create the context popup menu and it's submenus */
void connecttreeWidgetCostumPopupMenu( QPoint point );
//void unvalidGPGkeyWidgetCostumPopupMenu( QPoint point );
/** Called when user clicks "Load Cert" to choose location of a Cert file */
void loadcert();

View File

@ -222,7 +222,7 @@ subcontrol-position: bottom right;
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QTabWidget" name="tabBottom">
<property name="maximumSize">
<size>
@ -402,6 +402,47 @@ subcontrol-position: bottom right;
</widget>
</widget>
</item>
<item row="2" column="0">
<widget class="QTreeWidget" name="unvalidGPGkeyWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string/>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>GPG key validity</string>
</property>
</column>
<column>
<property name="text">
<string>Did peer authenticated me</string>
</property>
</column>
<column>
<property name="text">
<string>Cert Id</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -213,7 +213,12 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
exportfriendAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Export Friend" ), this );
connect( exportfriendAct , SIGNAL( triggered() ), this, SLOT( exportfriend() ) );
QTreeWidgetItem *c = getCurrentPeer();
if (c->type() == 0) {
removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Deny Friend" ), this );
} else {
removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Remove Friend Location" ), this );
}
connect( removefriendAct , SIGNAL( triggered() ), this, SLOT( removefriend() ) );
@ -310,7 +315,7 @@ void PeersDialog::insertPeers()
if (list.size() == 1) {
gpg_item = list.front();
} else {
gpg_item = new QTreeWidgetItem(0);
gpg_item = new QTreeWidgetItem(0); //set type to 0 for custom popup menu
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
}
@ -360,7 +365,7 @@ void PeersDialog::insertPeers()
}
}
if (newChild) {
sslItem = new QTreeWidgetItem(1);
sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu
}
RsPeerDetails sslDetail;

View File

@ -142,10 +142,10 @@ void TrustView::update()
std::list<std::string> neighs;
// if(!rsPeers->getOthersList(neighs))
if(!rsPeers->getGPGAllList(neighs))
return ;
// neighs.push_back(rsPeers->getPGPOwnId()) ;
neighs.push_back(rsPeers->getGPGOwnId()) ;
trustTableTW->setSortingEnabled(false) ;

View File

@ -48,6 +48,8 @@ ConfCertDialog::ConfCertDialog(QWidget *parent, Qt::WFlags flags)
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
connect(ui.make_friend_button, SIGNAL(clicked()), this, SLOT(makeFriend()));
connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend()));
connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey()));
ui.applyButton->setToolTip(tr("Apply and Close"));
@ -171,36 +173,56 @@ void ConfCertDialog::loadDialog()
ui.groupBox->hide();
}
if (detail.gpg_id == rsPeers->getGPGOwnId()) {
ui.make_friend_button->hide();
ui.signGPGKeyCheckBox->hide();
ui.signKeyButton->hide();
ui.denyFriendButton->hide();
ui.web_of_trust_label->hide();
ui.radioButton_trust_fully->hide();
ui.radioButton_trust_marginnaly->hide();
ui.radioButton_trust_never->hide();
ui.is_signing_me->hide();
ui.signersBox->setTitle(tr("Your key is signed by : "));
} else {
ui.make_friend_button->show();
ui.signGPGKeyCheckBox->show();
ui.signKeyButton->show();
ui.denyFriendButton->show();
ui.web_of_trust_label->show();
ui.radioButton_trust_fully->show();
ui.radioButton_trust_marginnaly->show();
ui.radioButton_trust_never->show();
ui.is_signing_me->show();
ui.signersBox->setTitle(tr("Peer key is signed by : "));
if (detail.accept_connection) {
ui.make_friend_button->hide();
ui.denyFriendButton->show();
ui.signGPGKeyCheckBox->hide();
//connection already accepted, propose to sign gpg key
if (!detail.ownsign) {
ui.signGPGKeyCheckBox->setChecked(true);
ui.signGPGKeyCheckBox->hide();
ui.signed_already_label->setText(tr("Peer is already a friend"));
ui.make_friend_button->setText(tr("Sign GPG key"));
ui.make_friend_button->show();
ui.signKeyButton->show();
} else {
ui.signGPGKeyCheckBox->hide();
ui.signed_already_label->setText(tr("Peer is a friend and GPG key is signed"));
ui.signed_already_label->show();
ui.make_friend_button->hide();
ui.signKeyButton->hide();
}
} else {
ui.make_friend_button->show();
ui.make_friend_button->setText(tr("Make Friend"));
ui.denyFriendButton->hide();
ui.signKeyButton->hide();
if (!detail.ownsign) {
ui.signGPGKeyCheckBox->show();
ui.signGPGKeyCheckBox->setChecked(true);
} else {
ui.signGPGKeyCheckBox->hide();
}
ui.signed_already_label->hide();
}
if (detail.hasSignedMe) {
ui.is_signing_me->setText(tr("Peer has authenticated me as a friend and did sign my GPG key"));
} else {
ui.is_signing_me->setText(tr("Peer has not authenticated me as a friend and did not sign my GPG key"));
}
//web of trust
@ -231,6 +253,13 @@ void ConfCertDialog::loadDialog()
}
}
if (detail.hasSignedMe) {
ui.is_signing_me->setText(tr("Peer has authenticated me as a friend and did sign my GPG key"));
} else {
ui.is_signing_me->setText(tr("Peer has not authenticated me as a friend and did not sign my GPG key"));
}
}
ui.signers->clear() ;
for(std::list<std::string>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) {
RsPeerDetails signerDetail;
@ -292,8 +321,7 @@ void ConfCertDialog::applyDialog()
closeinfodlg();
}
void ConfCertDialog::makeFriend()
{
void ConfCertDialog::makeFriend() {
std::string gpg_id = rsPeers->getGPGId(mId);
if (ui.signGPGKeyCheckBox->isChecked()) {
rsPeers->signGPGCertificate(gpg_id);
@ -303,3 +331,16 @@ void ConfCertDialog::makeFriend()
rsPeers->addFriend(mId, gpg_id);
loadDialog();
}
void ConfCertDialog::denyFriend() {
std::string gpg_id = rsPeers->getGPGId(mId);
rsPeers->setAcceptToConnectGPGCertificate(gpg_id, false);
loadDialog();
}
void ConfCertDialog::signGPGKey() {
std::string gpg_id = rsPeers->getGPGId(mId);
rsPeers->signGPGCertificate(gpg_id);
loadDialog();
}

View File

@ -69,6 +69,8 @@ private slots:
void closeinfodlg();
void applyDialog();
void makeFriend();
void denyFriend();
void signGPGKey();
private:

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<width>512</width>
<height>529</height>
</rect>
</property>
@ -21,7 +21,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
@ -254,63 +254,22 @@
</attribute>
<layout class="QVBoxLayout" name="_9">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="title">
<string>GPG Key signing settings</string>
</property>
<layout class="QVBoxLayout" name="_10">
<layout class="QHBoxLayout" name="friendAndSignLayout">
<item>
<widget class="QLabel" name="is_signing_me">
<widget class="QPushButton" name="denyFriendButton">
<property name="text">
<string>Peer has signed my GPG key</string>
<string>Deny Friend</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Peer key is already signed by :</string>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
<layout class="QVBoxLayout" name="_11">
<item>
<widget class="QTextBrowser" name="signers"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="signed_already_label">
<property name="maximumSize">
<property name="iconSize">
<size>
<width>450</width>
<height>50</height>
<width>15</width>
<height>15</height>
</size>
</property>
<property name="text">
<string>Not filled</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="signGPGKeyCheckBox">
<property name="text">
<string>Sign GPG key (Default)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -318,31 +277,75 @@
<property name="text">
<string>Make Friends</string>
</property>
</widget>
</item>
</layout>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-friend24.png</normaloff>:/images/add-friend24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>15</width>
<height>15</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="enabled">
<bool>true</bool>
<widget class="QCheckBox" name="signGPGKeyCheckBox">
<property name="text">
<string>Sign GPG key</string>
</property>
<property name="minimumSize">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/dauthed.png</normaloff>:/images/dauthed.png</iconset>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>50</height>
<width>15</width>
<height>15</height>
</size>
</property>
<property name="font">
<font>
<kerning>true</kerning>
</font>
<property name="checked">
<bool>true</bool>
</property>
<property name="title">
<string>GPG Web of Trust</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="signKeyButton">
<property name="text">
<string>Sign GPG Key</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/dauthed.png</normaloff>:/images/dauthed.png</iconset>
</property>
<property name="iconSize">
<size>
<width>15</width>
<height>15</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="wotLayout">
<item>
<widget class="QLabel" name="web_of_trust_label">
<property name="text">
@ -350,13 +353,8 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioButton_trust_never">
<property name="toolTip">
<string>Your trust in this peer is none, it means he is known to improperly sign other keys.</string>
</property>
<property name="text">
<string>None</string>
</property>
@ -364,26 +362,79 @@
</item>
<item>
<widget class="QRadioButton" name="radioButton_trust_marginnaly">
<property name="toolTip">
<string>Your trust in this peer is marginal, it means he understands the implications of key signing and properly check keys before signing them.</string>
</property>
<property name="text">
<string>Marginnaly</string>
<string>Marginal</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_trust_fully">
<property name="toolTip">
<string>Your trust in this peer is full, it means he has an excellent understanding of key signing, and his signature on a key would be as good as your own.</string>
</property>
<property name="text">
<string>Fully</string>
<string>Full</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="title">
<string>GPG Key</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="_10">
<item>
<widget class="QLabel" name="is_signing_me">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Peer has signed my GPG key</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="signersBox">
<property name="title">
<string>Peer key is signed by :</string>
</property>
<layout class="QVBoxLayout" name="_11">
<item>
<widget class="QTextBrowser" name="signers"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>