added help system to the MainPage class. Each page can now derive its own help string and show it using a two-states help button. To try it, I have implemented it on the NewsFeed page

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6514 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-07-18 19:32:12 +00:00
parent 7c6a7edfde
commit a07e8d889a
8 changed files with 101 additions and 5 deletions

View file

@ -0,0 +1,35 @@
#include <iostream>
#include <retroshare-gui/mainpage.h>
#include <QGraphicsBlurEffect>
#include <QGraphicsDropShadowEffect>
MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, flags)
{
help_browser = NULL ;
}
void MainPage::showHelp(bool b)
{
if(help_browser == NULL)
{
help_browser = new QTextBrowser(this) ;
help_browser->setHtml(helpHtmlText()) ;
QGraphicsDropShadowEffect * effect = new QGraphicsDropShadowEffect(help_browser) ;
effect->setBlurRadius(30.0);
help_browser->setGraphicsEffect(effect);
help_browser->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)) ;
help_browser->resize(size()*0.5) ;
help_browser->move(width()/2 - help_browser->width()/2,height()/2 - help_browser->height()/2);
help_browser->update() ;
}
std::cerr << "Toggling help to " << b << std::endl;
if(b)
help_browser->show() ;
else
help_browser->hide() ;
}

View file

@ -84,6 +84,7 @@ NewsFeed::NewsFeed(QWidget *parent)
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
connect(helpButton, SIGNAL(toggled(bool)), (MainPage*)this, SLOT(showHelp(bool)));
}
NewsFeed::~NewsFeed()
@ -93,6 +94,25 @@ NewsFeed::~NewsFeed()
}
}
const QString& NewsFeed::helpHtmlText() const
{
static const QString str = tr(
" <h1><img width=\"32\" src=\":/images/64px_help.png\">&nbsp;&nbsp;News Feed</h1> \
<p>The News Feed displays the last events on your network, sorted by the time you received them. \
This gives you a summary of the activity of your friends. \
You can configure which events to show by pressing on <b>Options</b>. </p> \
<p>The various events shown are: \
<ul> \
<li>Connection attempts (useful to make friends with new people and control who's trying to reach you)</li> \
<li>Channel and Forum posts</li> \
<li>New Channels and Forums you can subscribe to</li> \
<li>Private messages from your friends</li> \
</ul> </p> \
") ;
return str ;
}
UserNotify *NewsFeed::getUserNotify(QObject *parent)
{
return new NewsFeedUserNotify(this, parent);

View file

@ -52,6 +52,8 @@ public:
virtual void openChat(std::string peerId);
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
virtual const QString& helpHtmlText() const ;
static void testFeeds(uint notifyFlags);
static void testFeed(FeedNotify *feedNotify);

View file

@ -97,6 +97,29 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="helpButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/64px_help.png</normaloff>:/images/64px_help.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View file

@ -10,6 +10,7 @@
<file>images/help/addafriend.png</file>
<file>images/help/addfriendkey.png</file>
<file>images/help/dhtgreen.png</file>
<file>images/64px_help.png</file>
<file>images/help/natgreen.png</file>
<file>images/help/natred.png</file>
<file>images/attach.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB