mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-15 04:22:27 -04:00
Moved help browser from MainPage to a new base class named FloatingHelpBrowser for global usage.
Added FloatingHelpBrowser to the option window (help text not including). The help text can be specified for the ConfigPages in the method "helpText". git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6818 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fa6bc5fe39
commit
a50c899ff3
24 changed files with 225 additions and 67 deletions
|
@ -1,61 +1,18 @@
|
|||
#include <iostream>
|
||||
#include <retroshare-gui/mainpage.h>
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QAbstractButton>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include "common/FloatingHelpBrowser.h"
|
||||
|
||||
MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, flags)
|
||||
{
|
||||
help_browser = NULL ;
|
||||
}
|
||||
|
||||
class MyTextBrowser: public QTextBrowser
|
||||
{
|
||||
public:
|
||||
MyTextBrowser(QWidget *parent,QAbstractButton *bt)
|
||||
: QTextBrowser(parent),button(bt)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void mousePressEvent ( QMouseEvent* )
|
||||
{
|
||||
hide() ;
|
||||
button->setChecked(false) ;
|
||||
}
|
||||
|
||||
protected:
|
||||
QAbstractButton *button ;
|
||||
};
|
||||
|
||||
void MainPage::showHelp(bool b)
|
||||
{
|
||||
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() ;
|
||||
mHelpBrowser = NULL ;
|
||||
}
|
||||
|
||||
void MainPage::registerHelpButton(QAbstractButton *button,const QString& help_html_txt)
|
||||
{
|
||||
if(help_browser == NULL)
|
||||
if (mHelpBrowser == NULL)
|
||||
{
|
||||
help_browser = new MyTextBrowser(this,button) ;
|
||||
|
||||
QGraphicsDropShadowEffect * effect = new QGraphicsDropShadowEffect(help_browser) ;
|
||||
effect->setBlurRadius(30.0);
|
||||
help_browser->setGraphicsEffect(effect);
|
||||
|
||||
help_browser->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)) ;
|
||||
help_browser->hide() ;
|
||||
mHelpBrowser = new FloatingHelpBrowser(this, button) ;
|
||||
}
|
||||
|
||||
help_browser->setHtml("<div align=\"justify\">"+help_html_txt+"</div>") ;
|
||||
|
||||
QObject::connect(button,SIGNAL(toggled(bool)), this, SLOT( showHelp(bool) ) ) ;
|
||||
mHelpBrowser->setHelpText(help_html_txt) ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue