Added Home Page View for easy see own Cert to Copy and Share to Friends

Fixed Share Manager Label layout
Update emotes file
Set radio items font size to stylesheet file
This commit is contained in:
defnax 2016-12-12 21:16:56 +01:00
parent 4933cce278
commit 2e717d35c7
14 changed files with 670 additions and 211 deletions

View File

@ -0,0 +1,137 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2016, defnax
*
* 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 "HomePage.h"
#include "ui_HomePage.h"
#include "gui/notifyqt.h"
#include "gui/msgs/MessageComposer.h"
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <QUrlQuery>
#endif
#include <iostream>
#include <string>
#include <QTime>
#include <QMenu>
#include <QDesktopServices>
#include <QMessageBox>
#include <QFileDialog>
#include <QClipboard>
#include <QTextStream>
#include <QTextCodec>
HomePage::HomePage(QWidget *parent) :
MainPage(parent),
ui(new Ui::HomePage)
{
ui->setupUi(this);
updateOwnCert();
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()));
QMenu *menu = new QMenu();
menu->addAction(CopyAction);
menu->addAction(SaveAction);
menu->addAction(SendAction);
ui->shareButton->setMenu(menu);
}
HomePage::~HomePage()
{
delete ui;
}
void HomePage::updateOwnCert()
{
std::string invite = rsPeers->GetRetroshareInvite(false);
ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str()));
}
static void sendMail(QString sAddress, QString sSubject, QString sBody)
{
#ifdef Q_OS_WIN
/* search and replace the end of lines with: "%0D%0A" */
sBody.replace("\n", "%0D%0A");
#endif
QUrl url = QUrl("mailto:" + sAddress);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QUrlQuery urlQuery;
#else
QUrl &urlQuery(url);
#endif
urlQuery.addQueryItem("subject", sSubject);
urlQuery.addQueryItem("body", sBody);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
url.setQuery(urlQuery);
#endif
std::cerr << "MAIL STRING:" << (std::string)url.toEncoded().constData() << std::endl;
/* pass the url directly to QDesktopServices::openUrl */
QDesktopServices::openUrl (url);
}
void HomePage::runEmailClient()
{
sendMail("", tr("RetroShare Invite"), ui->userCertEdit->toPlainText());
}
void HomePage::copyCert()
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(ui->userCertEdit->toPlainText());
QMessageBox::information(this, "RetroShare", tr("Your Cert is copied to Clipboard, paste and send it to your friend via email or some other way"));
}
void HomePage::saveCert()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."), "", tr("RetroShare Certificate (*.rsc );;All Files (*)"));
if (fileName.isEmpty())
return;
QFile file(fileName);
if (!file.open(QFile::WriteOnly))
return;
//Todo: move save to file to p3Peers::SaveCertificateToFile
QTextStream ts(&file);
ts.setCodec(QTextCodec::codecForName("UTF-8"));
ts << ui->userCertEdit->document()->toPlainText();
}

View File

@ -0,0 +1,64 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2016, defnax
*
* 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 HOMEPAGE_H
#define HOMEPAGE_H
#include <retroshare-gui/mainpage.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rspeers.h>
#include <QWidget>
class QAction;
namespace Ui {
class HomePage;
}
class HomePage : public MainPage
{
Q_OBJECT
public:
explicit HomePage(QWidget *parent);
~HomePage();
virtual QIcon iconPixmap() const { return QPixmap(":/icons/svg/profile.svg") ; } //MainPage
virtual QString pageName() const { return tr("Home") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
private slots:
void updateOwnCert();
void runEmailClient();
void copyCert();
void saveCert();
private:
Ui::HomePage *ui;
};
#endif // HomePage_H

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HomePage</class>
<widget class="QWidget" name="HomePage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>771</width>
<height>560</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="3" column="1">
<widget class="QFrame" name="addFrame">
<layout class="QGridLayout" name="gridLayout_3">
<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>
</layout>
</widget>
</item>
<item row="2" column="0" rowspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>268</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>9</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0">
<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 Retroshare certificate. Copy and share it with your friends</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="shareButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Share your RetroShare Key</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/png/network.png</normaloff>:/icons/png/network.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPlainTextEdit" name="userCertEdit">
<property name="font">
<font>
<family>Courier New</family>
</font>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="tabStopWidth">
<number>80</number>
</property>
<property name="centerOnScroll">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="2" rowspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>288</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/logo/logo_splash.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>RetroShare is an Open Source cross-platform,
private and secure decentralized commmunication platform.
</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
<include location="icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -39,6 +39,7 @@
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "MessengerWindow.h"
#include "HomePage.h"
#include "NetworkDialog.h"
#include "gui/FileTransfer/SearchDialog.h"
#include "gui/FileTransfer/TransfersDialog.h"
@ -341,6 +342,8 @@ void MainWindow::initStackedPage()
/* Create the Main pages and actions */
QActionGroup *grp = new QActionGroup(this);
addPage(homePage = new HomePage(ui->stackPages), grp, NULL);
addPage(newsFeed = new NewsFeed(ui->stackPages), grp, &notify);
addPage(friendsDialog = new FriendsDialog(ui->stackPages), grp, &notify);

View File

@ -60,6 +60,7 @@ class MessagesDialog;
class SharedFilesDialog;
class MessengerWindow;
class PluginsPage;
class HomePage;
//class ChannelFeed;
class BandwidthGraph;
class MainPage;
@ -132,6 +133,7 @@ public:
// NetworkDialog *networkDialog;
// SearchDialog *searchDialog;
HomePage *homePage;
NewsFeed *newsFeed;
FriendsDialog *friendsDialog;
TransfersDialog *transfersDialog;

View File

@ -178,7 +178,14 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<item row="2" column="3">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="StyledLabel" name="labelInstructions">
<property name="palette">
<palette>
@ -261,13 +268,6 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -89,7 +89,7 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
// setOption(HaveHelpButton, true);
// connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));
setPixmap(QWizard::LogoPixmap, QPixmap(":/images/connect/connectFriendLogo.png"));
setPixmap(QWizard::LogoPixmap, QPixmap(":/icons/invite64.png"));
// we have no good pictures for watermarks
// setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/connectFriendWatermark.png"));
@ -121,6 +121,8 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
body += "\n" + GetStartedDialog::GetCutBelowText();
body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite(false).c_str());
ui->userFrame->hide();
updateStylesheet();
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>691</width>
<height>644</height>
<height>522</height>
</rect>
</property>
<property name="windowTitle">
@ -92,33 +92,9 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="userCertLabel">
<property name="text">
<string>The text below is your Retroshare certificate. You have to provide it to your friend</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPlainTextEdit" name="userCertEdit">
<property name="font">
<font>
<family>Courier New</family>
</font>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="tabStopWidth">
<number>80</number>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="userFrame">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QToolButton" name="userCertHelpButton">
@ -273,7 +249,33 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QPlainTextEdit" name="userCertEdit">
<property name="font">
<font>
<family>Courier New</family>
</font>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="tabStopWidth">
<number>80</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="userCertLabel">
<property name="text">
<string>The text below is your Retroshare certificate. You have to provide it to your friend</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="friendCertLabel">
@ -294,6 +296,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This box expects your friend's Retroshare certificate. WARNING: this is different from your friend's PGP key. Do not paste your friend's PGP key here (not even a part of it). It's not going to work.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
@ -301,19 +306,6 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="userCertPasteButton">
<property name="sizePolicy">
@ -527,7 +519,16 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
@ -1544,12 +1545,6 @@ resources.</string>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QLabel</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
@ -1561,6 +1556,12 @@ resources.</string>
<header>gui/common/FriendSelectionWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AvatarWidget</class>
<extends>QLabel</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>DropLineEdit</class>
<extends>QLineEdit</extends>

View File

@ -1,5 +1,17 @@
<RCC>
<qresource prefix="/">
<file>emojione/1f325.png</file>
<file>emojione/1F30D.png</file>
<file>emojione/1F30E.png</file>
<file>emojione/1F30F.png</file>
<file>emojione/1F31A.png</file>
<file>emojione/1F31B.png</file>
<file>emojione/1F31C.png</file>
<file>emojione/1F31D.png</file>
<file>emojione/1F31E.png</file>
<file>emojione/1F31F.png</file>
<file>emojione/1f324.png</file>
<file>emojione/1f326.png</file>
<file>emojione/1F35A.png</file>
<file>emojione/1F35B.png</file>
<file>emojione/1F35C.png</file>

View File

@ -144,6 +144,16 @@
"emojione/people2.png"|":zzz:":"emojione/1F4A4.png";
"emojione/people2.png"|":eyeglasses:":"emojione/1F453.png";
"emojione/people2.png"|":crown:":"emojione/1F451.png";
"emojione/people2.png"|":womans_hat:":"emojione/1F452.png";
"emojione/people2.png"|":necktie:":"emojione/1F454.png";
"emojione/people2.png"|":shirt:":"emojione/1F455.png";
"emojione/people2.png"|":jeans:":"emojione/1F456.png";
"emojione/people2.png"|":dress:":"emojione/1F457.png";
"emojione/people2.png"|":kimono:":"emojione/1F458.png";
"emojione/people2.png"|":bikini:":"emojione/1F459.png";
"emojione/people2.png"|":high_heel:":"emojione/1F460.png";
"emojione/people2.png"|":sandal:":"emojione/1F461.png";
"emojione/people2.png"|":boot:":"emojione/1F462.png";
"emojione/people2.png"|":lipstick:":"emojione/1F484.png";
"emojione/people2.png"|":ring:":"emojione/1F48D.png";
"emojione/people2.png"|":closed_umbrella:":"emojione/1F302.png";
@ -265,6 +275,9 @@
"emojione/nature.png"|":crescent_moon:":"emojione/1F319.png";
"emojione/nature.png"|":sunny:":"emojione/2600.png";
"emojione/nature.png"|":partly_sunny:":"emojione/26C5.png";
"emojione/nature.png"|":white_sun_small_cloud:":"emojione/1f324.png";
"emojione/nature.png"|":white_sun_cloud:":"emojione/1f325.png";
"emojione/nature.png"|":white_sun_rain_cloud:":"emojione/1f326.png";
"emojione/nature.png"|":cloud:":"emojione/2601.png";
"emojione/nature.png"|":cloud_rain:":"emojione/1F327.png";
"emojione/nature.png"|":cloud_snow:":"emojione/1F328.png";
@ -322,10 +335,14 @@
"emojione/objects.png"|":bomb:":"emojione/1F4A3.png";
"emojione/objects.png"|":hole:":"emojione/1F573.png";
"emojione/objects.png"|":shopping_bags:":"emojione/1F6CD.png";
"emojione/objects.png"|":barber:":"emojione/1F488.png";
"emojione/objects.png"|":syringe:":"emojione/1F489.png";
"emojione/objects.png"|":pill:":"emojione/1F48A.png";
"emojione/objects.png"|":hourglass:":"emojione/231B.png";
"emojione/objects.png"|":hourglass_flowing_sand:":"emojione/23F3.png";
"emojione/objects.png"|":watch:":"emojione/231A.png";
"emojione/objects.png"|":alarm_clock:":"emojione/23F0.png";
"emojione/objects.png"|":thermometer:":"emojione/1F321.png";
"emojione/objects.png"|":iphone:":"emojione/1F4F1.png";
"emojione/objects.png"|":calling:":"emojione/1F4F2.png";
"emojione/objects.png"|":ribbon:":"emojione/1F380.png";

View File

@ -54,6 +54,7 @@
<file>icons/help_64.png</file>
<file>icons/information_128.png</file>
<file>icons/internet_128.png</file>
<file>icons/invite64.png</file>
<file>icons/knews_128.png</file>
<file>icons/knews_red_128.png</file>
<file>icons/konversation_128.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -658,3 +658,26 @@ GenCertDialog QPushButton#genButton:disabled {
font: bold;
color: black;
}
ConnectFriendWizard QRadioButton {
font-size: 16px;
}
ConnectFriendWizard QPlainTextEdit#friendCertEdit {
border: 2px solid #0099cc;
border-radius: 6px;
background: white;
}
HomePage QPlainTextEdit#userCertEdit {
border: 2px solid #0099cc;
border-radius: 6px;
background: white;
}
HomePage QPlainTextEdit#friendCertEdit {
border: 2px solid #0099cc;
border-radius: 6px;
background: white;
}

View File

@ -335,6 +335,7 @@ HEADERS += rshare.h \
control/eventtype.h \
gui/QuickStartWizard.h \
gui/StartDialog.h \
gui/HomePage.h\
gui/NetworkDialog.h \
gui/GenCertDialog.h \
gui/linetypes.h \
@ -581,6 +582,7 @@ HEADERS += rshare.h \
# gui/channels/ChannelUserNotify.h \
FORMS += gui/StartDialog.ui \
gui/HomePage.ui\
gui/GenCertDialog.ui \
gui/AboutDialog.ui \
gui/QuickStartWizard.ui \
@ -701,6 +703,7 @@ SOURCES += main.cpp \
gui/AboutDialog.cpp \
gui/QuickStartWizard.cpp \
gui/StartDialog.cpp \
gui/HomePage.cpp\
gui/GenCertDialog.cpp \
gui/NetworkDialog.cpp \
gui/mainpagestack.cpp \