2013-07-18 19:32:12 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <retroshare-gui/mainpage.h>
|
|
|
|
#include <QGraphicsBlurEffect>
|
2013-08-29 22:02:04 +00:00
|
|
|
#include <QAbstractButton>
|
2013-07-18 19:32:12 +00:00
|
|
|
#include <QGraphicsDropShadowEffect>
|
|
|
|
|
|
|
|
MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, flags)
|
|
|
|
{
|
|
|
|
help_browser = NULL ;
|
|
|
|
}
|
|
|
|
|
2013-08-28 20:14:37 +00:00
|
|
|
class MyTextBrowser: public QTextBrowser
|
|
|
|
{
|
|
|
|
public:
|
2013-08-29 22:02:04 +00:00
|
|
|
MyTextBrowser(QWidget *parent,QAbstractButton *bt)
|
2013-08-28 20:14:37 +00:00
|
|
|
: QTextBrowser(parent),button(bt)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-29 22:02:04 +00:00
|
|
|
virtual void mousePressEvent ( QMouseEvent* )
|
2013-08-28 20:14:37 +00:00
|
|
|
{
|
|
|
|
hide() ;
|
|
|
|
button->setChecked(false) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-08-29 22:02:04 +00:00
|
|
|
QAbstractButton *button ;
|
2013-08-28 20:14:37 +00:00
|
|
|
};
|
2013-07-18 19:32:12 +00:00
|
|
|
|
|
|
|
void MainPage::showHelp(bool b)
|
2013-07-19 12:18:58 +00:00
|
|
|
{
|
|
|
|
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() ;
|
|
|
|
}
|
|
|
|
|
2013-08-29 22:02:04 +00:00
|
|
|
void MainPage::registerHelpButton(QAbstractButton *button,const QString& help_html_txt)
|
2013-07-18 19:32:12 +00:00
|
|
|
{
|
|
|
|
if(help_browser == NULL)
|
|
|
|
{
|
2013-08-28 20:14:37 +00:00
|
|
|
help_browser = new MyTextBrowser(this,button) ;
|
2013-07-18 19:32:12 +00:00
|
|
|
|
|
|
|
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() ;
|
2013-07-19 12:18:58 +00:00
|
|
|
}
|
2013-07-18 19:32:12 +00:00
|
|
|
|
2013-07-19 18:36:09 +00:00
|
|
|
help_browser->setHtml("<div align=\"justify\">"+help_html_txt+"</div>") ;
|
2013-07-19 12:18:58 +00:00
|
|
|
|
|
|
|
QObject::connect(button,SIGNAL(toggled(bool)), this, SLOT( showHelp(bool) ) ) ;
|
|
|
|
}
|
2013-07-18 19:32:12 +00:00
|
|
|
|