2018-12-25 15:34:59 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/MainPage.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright (c) 2006 Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2016-01-19 22:59:11 -05:00
|
|
|
#include <QToolButton>
|
2017-02-25 18:16:36 -05:00
|
|
|
#include <QTimer>
|
2016-01-19 22:59:11 -05:00
|
|
|
|
2013-07-18 15:32:12 -04:00
|
|
|
#include <retroshare-gui/mainpage.h>
|
2013-10-09 05:31:40 -04:00
|
|
|
#include "common/FloatingHelpBrowser.h"
|
2017-02-25 17:52:57 -05:00
|
|
|
#include "gui/settings/rsharesettings.h"
|
2013-07-18 15:32:12 -04:00
|
|
|
|
2014-05-09 22:38:47 -04:00
|
|
|
MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, flags)
|
2013-07-18 15:32:12 -04:00
|
|
|
{
|
2013-10-09 05:31:40 -04:00
|
|
|
mHelpBrowser = NULL ;
|
2014-05-09 22:38:47 -04:00
|
|
|
mIcon = QIcon();
|
|
|
|
mName = "";
|
|
|
|
mHelp = "";
|
2013-07-19 08:18:58 -04:00
|
|
|
}
|
|
|
|
|
2017-02-25 17:52:57 -05:00
|
|
|
void MainPage::registerHelpButton(QToolButton *button, const QString& help_html_text, const QString &code_name)
|
2013-07-18 15:32:12 -04:00
|
|
|
{
|
2017-02-25 17:52:57 -05:00
|
|
|
mHelpCodeName = code_name ;
|
|
|
|
|
2013-10-09 05:31:40 -04:00
|
|
|
if (mHelpBrowser == NULL)
|
|
|
|
mHelpBrowser = new FloatingHelpBrowser(this, button) ;
|
2016-01-19 22:59:11 -05:00
|
|
|
|
|
|
|
float S = QFontMetricsF(button->font()).height() ;
|
|
|
|
button->setIconSize(QSize(S,S)) ;
|
2013-07-18 15:32:12 -04:00
|
|
|
|
2017-02-25 17:52:57 -05:00
|
|
|
mHelpBrowser->setHelpText(help_html_text) ;
|
2013-07-19 08:18:58 -04:00
|
|
|
}
|
2013-07-18 15:32:12 -04:00
|
|
|
|
2017-02-25 17:52:57 -05:00
|
|
|
void MainPage::showEvent(QShowEvent *s)
|
|
|
|
{
|
2017-02-25 18:16:36 -05:00
|
|
|
if(!Settings->getPageAlreadyDisplayed(mHelpCodeName) && mHelpBrowser!=NULL)
|
2017-02-25 17:52:57 -05:00
|
|
|
{
|
2017-02-25 18:16:36 -05:00
|
|
|
// I use a timer to make sure that the GUI is able to process that.
|
|
|
|
QTimer::singleShot(1000, mHelpBrowser,SLOT(show()));
|
2017-02-25 17:52:57 -05:00
|
|
|
|
2017-02-25 18:16:36 -05:00
|
|
|
Settings->setPageAlreadyDisplayed(mHelpCodeName,true);
|
2017-02-25 17:52:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::showEvent(s);
|
|
|
|
}
|