added settings variable to allow to always display the help of each tab the first time it is shown

This commit is contained in:
csoler 2017-02-25 23:52:57 +01:00
parent dc51911fce
commit 12246e369b
13 changed files with 49 additions and 16 deletions

View File

@ -188,7 +188,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
</p> \
"
).arg(QString::number(2*S)).arg(QString::number(S)) ;
registerHelpButton(ui.helpButton,help_str) ;
registerHelpButton(ui.helpButton,help_str,"ChatLobbyDialog") ;
}
ChatLobbyWidget::~ChatLobbyWidget()

View File

@ -489,7 +489,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
").arg(QString::number(2*S)).arg(QString::number(S)) ;
registerHelpButton(ui.helpButton,help_str) ;
registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ;
}
TransfersDialog::~TransfersDialog()

View File

@ -169,7 +169,7 @@ QList<int> sizes;
</ul> </p> \
") ;
registerHelpButton(ui.helpButton, hlp_str) ;
registerHelpButton(ui.helpButton, hlp_str,"FriendsDialog") ;
}
FriendsDialog::~FriendsDialog ()

View File

@ -84,7 +84,7 @@ HomePage::HomePage(QWidget *parent) :
<p>Another option is to search the internet for \"Retroshare chat servers\" (independently administrated). These servers allow you to exchange \
certificates with a dedicated Retroshare node, through which\
you will be able to meet other people anonymously.</p> ").arg(QString::number(2*S)).arg(width()*0.5);
registerHelpButton(ui->helpButton,help_str) ;
registerHelpButton(ui->helpButton,help_str,"HomePage") ;
}
HomePage::~HomePage()

View File

@ -358,7 +358,7 @@ IdDialog::IdDialog(QWidget *parent) :
<p>An <b>circle</b> can be restricted to another circle, thereby limiting its visibility to members of that circle \
or even self-restricted, meaning that it is only visible to invited members.</p>") ;
registerHelpButton(ui->helpButton, hlp_str) ;
registerHelpButton(ui->helpButton, hlp_str,"PeopleDialog") ;
// load settings
processSettings(true);

View File

@ -2,6 +2,7 @@
#include <retroshare-gui/mainpage.h>
#include "common/FloatingHelpBrowser.h"
#include "gui/settings/rsharesettings.h"
MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, flags)
{
@ -11,14 +12,27 @@ MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, f
mHelp = "";
}
void MainPage::registerHelpButton(QToolButton *button,const QString& help_html_txt)
void MainPage::registerHelpButton(QToolButton *button, const QString& help_html_text, const QString &code_name)
{
mHelpCodeName = code_name ;
if (mHelpBrowser == NULL)
mHelpBrowser = new FloatingHelpBrowser(this, button) ;
float S = QFontMetricsF(button->font()).height() ;
button->setIconSize(QSize(S,S)) ;
mHelpBrowser->setHelpText(help_html_txt) ;
mHelpBrowser->setHelpText(help_html_text) ;
}
void MainPage::showEvent(QShowEvent *s)
{
if(Settings->getPageFirstTimeDisplay(mHelpCodeName) && mHelpBrowser!=NULL)
{
mHelpBrowser->show();
Settings->setPageFirstTimeDisplay(mHelpCodeName,false);
}
QWidget::showEvent(s);
}

View File

@ -306,7 +306,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
to a channel's owner.</p> \
").arg(QString::number(2*S)).arg(QString::number(S)) ;
registerHelpButton(ui.helpButton,help_str) ;
registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ;
}
MessagesDialog::~MessagesDialog()

View File

@ -124,7 +124,7 @@ NewsFeed::NewsFeed(QWidget *parent) :
QString hlp_str = tr(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;News Feed</h1> \
<p>The News Feed displays the last events on your network, sorted by the time you received them. \
<p>The Log 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: \
@ -136,7 +136,7 @@ QString hlp_str = tr(
</ul> </p> \
") ;
registerHelpButton(ui->helpButton,hlp_str) ;
registerHelpButton(ui->helpButton,hlp_str,"NewFeed") ;
// load settings
processSettings(true);

View File

@ -27,8 +27,8 @@
#include "FloatingHelpBrowser.h"
FloatingHelpBrowser::FloatingHelpBrowser(QWidget *parent, QAbstractButton *button) :
QTextBrowser(parent), mButton(button)
FloatingHelpBrowser::FloatingHelpBrowser(QWidget *parent, QAbstractButton *button)
:QTextBrowser(parent), mButton(button)
{
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
effect->setBlurRadius(30.0);

View File

@ -123,7 +123,7 @@ GxsGroupFrameDialog::~GxsGroupFrameDialog()
void GxsGroupFrameDialog::initUi()
{
registerHelpButton(ui->helpButton, getHelpString()) ;
registerHelpButton(ui->helpButton, getHelpString(),pageName()) ;
ui->titleBarPixmap->setPixmap(QPixmap(icon(ICON_NAME)));
ui->titleBarLabel->setText(text(TEXT_NAME));

View File

@ -1160,3 +1160,14 @@ void RshareSettings::setWebinterfaceAllowAllIps(bool allow_all)
{
setValueToGroup("Webinterface", "allowAllIps", allow_all);
}
bool RshareSettings::getPageFirstTimeDisplay(const QString& page_name)
{
return valueFromGroup("PageDisplayed",page_name,true).toBool();
}
void RshareSettings::setPageFirstTimeDisplay(const QString& page_name,bool b)
{
return setValueToGroup("PageDisplayed",page_name,b);
}

View File

@ -336,6 +336,9 @@ public:
// proxy function that computes the best icon size among sizes passed as array, to match the recommended size on screen.
int computeBestIconSize(int n_sizes, int *sizes, int recommended_size);
bool getPageFirstTimeDisplay(const QString& page_code) ;
void setPageFirstTimeDisplay(const QString& page_code,bool b) ;
protected:
/** Default constructor. */
RshareSettings();

View File

@ -58,16 +58,20 @@ public:
virtual void retranslateUi() {}
virtual UserNotify *getUserNotify(QObject */*parent*/) { return NULL; }
// Overload this to add some help info to the page. The way the info is
// Call this to add some help info to the page. The way the info is
// shown is handled by showHelp() below;
//
void registerHelpButton(QToolButton *button, const QString& help_html_text) ;
void registerHelpButton(QToolButton *button, const QString& help_html_text, const QString &code_name) ;
protected:
virtual void showEvent(QShowEvent *);
private:
FloatingHelpBrowser *mHelpBrowser ;
QIcon mIcon;
QString mName;
QString mHelp;
QString mHelpCodeName;
};
#endif