fixed context menu in Home->cert

This commit is contained in:
csoler 2018-09-18 21:20:55 +02:00
parent f2514d13e2
commit 3c61190b4f
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 85 additions and 50 deletions

View File

@ -22,6 +22,8 @@
#include "HomePage.h" #include "HomePage.h"
#include "ui_HomePage.h" #include "ui_HomePage.h"
#include "retroshare/rsinit.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "gui/msgs/MessageComposer.h" #include "gui/msgs/MessageComposer.h"
#include "gui/connect/ConnectFriendWizard.h" #include "gui/connect/ConnectFriendWizard.h"
@ -55,36 +57,32 @@ HomePage::HomePage(QWidget *parent) :
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addFriend())); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addFriend()));
connect(ui->LoadCertFileButton, SIGNAL(clicked()), this, SLOT(loadCert())); connect(ui->LoadCertFileButton, SIGNAL(clicked()), this, SLOT(loadCert()));
QAction *CopyAction = new QAction(QIcon(),tr("Copy your Cert to Clipboard"), this);
connect(CopyAction, SIGNAL(triggered()), this, SLOT(copyCert()));
QAction *SaveAction = new QAction(QIcon(),tr("Save your Cert into a File"), this);
connect(SaveAction, SIGNAL(triggered()), this, SLOT(saveCert()));
QAction *SendAction = new QAction(QIcon(),tr("Send via Email"), this);
connect(SendAction, SIGNAL(triggered()), this, SLOT(runEmailClient()));
QAction *WebMailAction = new QAction(QIcon(),tr("Invite via WebMail"), this); QAction *WebMailAction = new QAction(QIcon(),tr("Invite via WebMail"), this);
connect(WebMailAction, SIGNAL(triggered()), this, SLOT(webMail())); connect(WebMailAction, SIGNAL(triggered()), this, SLOT(webMail()));
QAction *RecAction = new QAction(QIcon(),tr("Recommend friends to each others"), this); QAction *RecAction = new QAction(QIcon(),tr("Recommend friends to each others"), this);
connect(RecAction, SIGNAL(triggered()), this, SLOT(recommendFriends())); connect(RecAction, SIGNAL(triggered()), this, SLOT(recommendFriends()));
QAction *SendAction = new QAction(QIcon(),tr("Send via Email"), this);
connect(SendAction, SIGNAL(triggered()), this, SLOT(runEmailClient()));
QMenu *menu = new QMenu(); QMenu *menu = new QMenu();
menu->addAction(CopyAction);
menu->addAction(SaveAction);
menu->addAction(SendAction); menu->addAction(SendAction);
menu->addAction(WebMailAction); menu->addAction(WebMailAction);
menu->addAction(RecAction); menu->addAction(RecAction);
ui->shareButton->setMenu(menu); ui->shareButton->setMenu(menu);
QObject::connect(ui->userCertEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(certContextMenu(QPoint)));
connect(ui->runStartWizard_PB,SIGNAL(clicked()), this,SLOT(runStartWizard())) ; connect(ui->runStartWizard_PB,SIGNAL(clicked()), this,SLOT(runStartWizard())) ;
connect(ui->openwebhelp,SIGNAL(clicked()), this,SLOT(openWebHelp())) ; connect(ui->openwebhelp,SIGNAL(clicked()), this,SLOT(openWebHelp())) ;
ui->runStartWizard_PB->hide(); // until future rework ui->runStartWizard_PB->hide(); // until future rework
ui->LoadCertFileButton->hide(); // duplicates functionality => not good. ui->LoadCertFileButton->hide(); // duplicates functionality => not good.
mIncludeAllIPs = false;
int S = QFontMetricsF(font()).height(); int S = QFontMetricsF(font()).height();
QString help_str = tr( QString help_str = tr(
" <h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Welcome to Retroshare!</h1>\ " <h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Welcome to Retroshare!</h1>\
@ -100,6 +98,37 @@ HomePage::HomePage(QWidget *parent) :
registerHelpButton(ui->helpButton,help_str,"HomePage") ; registerHelpButton(ui->helpButton,help_str,"HomePage") ;
} }
void HomePage::certContextMenu(QPoint point)
{
QMenu menu(this) ;
QAction *CopyAction = new QAction(QIcon(),tr("Copy your Cert to Clipboard"), this);
connect(CopyAction, SIGNAL(triggered()), this, SLOT(copyCert()));
QAction *SaveAction = new QAction(QIcon(),tr("Save your Cert into a File"), this);
connect(SaveAction, SIGNAL(triggered()), this, SLOT(saveCert()));
menu.addAction(CopyAction);
menu.addAction(SaveAction);
if(!RsAccounts::isHiddenNode())
{
QAction *includeIPsAct = new QAction(QIcon(), mIncludeAllIPs? tr("Include only current IP"):tr("Include all your known IPs"),this);
connect(includeIPsAct, SIGNAL(triggered()), this, SLOT(toggleIncludeAllIPs()));
includeIPsAct->setCheckable(true);
menu.addAction(includeIPsAct);
}
menu.exec(QCursor::pos());
}
void HomePage::toggleIncludeAllIPs()
{
mIncludeAllIPs = !mIncludeAllIPs;
updateOwnCert();
}
HomePage::~HomePage() HomePage::~HomePage()
{ {
delete ui; delete ui;
@ -107,7 +136,7 @@ HomePage::~HomePage()
void HomePage::updateOwnCert() void HomePage::updateOwnCert()
{ {
bool include_extra_locators = false; bool include_extra_locators = mIncludeAllIPs;
RsPeerDetails detail; RsPeerDetails detail;

View File

@ -48,6 +48,7 @@ public:
virtual QString helpText() const { return ""; } //MainPage virtual QString helpText() const { return ""; } //MainPage
private slots: private slots:
void certContextMenu(QPoint);
void updateOwnCert(); void updateOwnCert();
void runEmailClient(); void runEmailClient();
void copyCert(); void copyCert();
@ -58,10 +59,12 @@ private slots:
void runStartWizard() ; void runStartWizard() ;
void openWebHelp() ; void openWebHelp() ;
void recommendFriends(); void recommendFriends();
void toggleIncludeAllIPs();
private: private:
Ui::HomePage *ui; Ui::HomePage *ui;
bool mIncludeAllIPs;
}; };

View File

@ -25,6 +25,41 @@
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>2</number> <number>2</number>
</property> </property>
<item row="1" column="2">
<widget class="QLabel" name="userCertLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>The text below is your own Retroshare certificate. Send it to your friends</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="helpButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4"> <item row="2" column="0" colspan="4">
<widget class="QPlainTextEdit" name="userCertEdit"> <widget class="QPlainTextEdit" name="userCertEdit">
<property name="font"> <property name="font">
@ -32,6 +67,9 @@
<family>Courier New</family> <family>Courier New</family>
</font> </font>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="whatsThis"> <property name="whatsThis">
<string/> <string/>
</property> </property>
@ -84,41 +122,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QToolButton" name="helpButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="userCertLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>The text below is your own Retroshare certificate. Send it to your friends</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="1" column="1" colspan="2"> <item row="1" column="1" colspan="2">

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>760</width> <width>1157</width>
<height>538</height> <height>873</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -1618,8 +1618,8 @@ resources.</string>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>