mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 15:09:33 -05: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
@ -48,6 +48,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/FeedReader.png") ; }
|
||||
virtual QString pageName() const { return tr("FeedReader") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void useProxyToggled();
|
||||
|
@ -70,6 +70,7 @@ class AudioInputConfig : public ConfigPage
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/talking_on.svg") ; }
|
||||
virtual QString pageName() const { return tr("VOIP") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void loadSettings();
|
||||
|
@ -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) ;
|
||||
}
|
||||
|
||||
|
97
retroshare-gui/src/gui/common/FloatingHelpBrowser.cpp
Normal file
97
retroshare-gui/src/gui/common/FloatingHelpBrowser.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2013, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QAbstractButton>
|
||||
#include <QShowEvent>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "FloatingHelpBrowser.h"
|
||||
|
||||
FloatingHelpBrowser::FloatingHelpBrowser(QWidget *parent, QAbstractButton *button) :
|
||||
QTextBrowser(parent), mButton(button)
|
||||
{
|
||||
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
|
||||
effect->setBlurRadius(30.0);
|
||||
setGraphicsEffect(effect);
|
||||
|
||||
setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
|
||||
hide();
|
||||
|
||||
connect(this, SIGNAL(textChanged()), this, SLOT(textChanged()));
|
||||
|
||||
if (mButton) {
|
||||
connect(mButton, SIGNAL(toggled(bool)), this, SLOT(showHelp(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
void FloatingHelpBrowser::showEvent(QShowEvent */*event*/)
|
||||
{
|
||||
if (mButton) {
|
||||
mButton->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FloatingHelpBrowser::hideEvent(QHideEvent */*event*/)
|
||||
{
|
||||
if (mButton) {
|
||||
mButton->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void FloatingHelpBrowser::mousePressEvent(QMouseEvent */*event*/)
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void FloatingHelpBrowser::textChanged()
|
||||
{
|
||||
if (mButton) {
|
||||
mButton->setVisible(!document()->isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
void FloatingHelpBrowser::showHelp(bool state)
|
||||
{
|
||||
QWidget *p = parentWidget();
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
|
||||
resize(p->size() * 0.5);
|
||||
move(p->width() / 2 - width() / 2, p->height() / 2 - height() / 2);
|
||||
update();
|
||||
|
||||
std::cerr << "Toggling help to " << state << std::endl;
|
||||
|
||||
setVisible(state);
|
||||
}
|
||||
|
||||
void FloatingHelpBrowser::setHelpText(const QString &helpText)
|
||||
{
|
||||
if (helpText.isEmpty()) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
setHtml("<div align=\"justify\">" + helpText + "</div>");
|
||||
}
|
57
retroshare-gui/src/gui/common/FloatingHelpBrowser.h
Normal file
57
retroshare-gui/src/gui/common/FloatingHelpBrowser.h
Normal file
@ -0,0 +1,57 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2013, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef FLOATINGHELPBROWSER_H
|
||||
#define FLOATINGHELPBROWSER_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
|
||||
class QAbstractButton;
|
||||
|
||||
class FloatingHelpBrowser : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FloatingHelpBrowser(QWidget *parent, QAbstractButton *button);
|
||||
|
||||
void setHelpText(const QString &helpText);
|
||||
|
||||
public slots:
|
||||
void showHelp(bool state);
|
||||
|
||||
private slots:
|
||||
void textChanged();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void hideEvent(QHideEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
protected:
|
||||
using QTextBrowser::setHtml;
|
||||
using QTextBrowser::setText;
|
||||
|
||||
private:
|
||||
QAbstractButton *mButton;
|
||||
};
|
||||
|
||||
#endif // FLOATINGHELPBROWSER_H
|
@ -40,6 +40,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/looknfeel.png") ; }
|
||||
virtual QString pageName() const { return tr("Appearance") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void loadStyleSheet(int index);
|
||||
|
@ -42,6 +42,7 @@ class ChatPage : public ConfigPage
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/chat_24.png") ; }
|
||||
virtual QString pageName() const { return tr("Chat") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void on_historyComboBoxVariant_currentIndexChanged(int index);
|
||||
@ -80,4 +81,3 @@ class ChatPage : public ConfigPage
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -41,6 +41,7 @@ class CryptoPage : public ConfigPage
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/encrypted32.png") ; }
|
||||
virtual QString pageName() const { return tr("Profile") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
virtual void load();
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/folder_doments.png") ; }
|
||||
virtual QString pageName() const { return tr("Directories") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void editDirectories() ;
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/konversation.png") ; }
|
||||
virtual QString pageName() const { return tr("Forum") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private:
|
||||
Ui::ForumPage ui;
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/kcmsystem24.png") ; }
|
||||
virtual QString pageName() const { return tr("General") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
public slots:
|
||||
void runStartWizard() ;
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/evolution.png") ; }
|
||||
virtual QString pageName() const { return tr("Message") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
|
||||
private slots:
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/status_unknown.png") ; }
|
||||
virtual QString pageName() const { return tr("Notify") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void notifyToggled();
|
||||
|
@ -39,6 +39,7 @@ class PluginsPage : public ConfigPage
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/extension_32.png") ; }
|
||||
virtual QString pageName() const { return tr("Plugins") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
|
||||
public slots:
|
||||
|
@ -42,6 +42,7 @@ class RelayPage: public ConfigPage
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/server_24x24.png") ; }
|
||||
virtual QString pageName() const { return tr("Relay") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
public slots:
|
||||
void updateRelayOptions();
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/server_24x24.png") ; }
|
||||
virtual QString pageName() const { return tr("Server") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
public slots:
|
||||
void updateStatus();
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/sound.png") ; }
|
||||
virtual QString pageName() const { return tr("Sound") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
private slots:
|
||||
void eventChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
@ -42,6 +42,7 @@ class TransferPage: public ConfigPage
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/ktorrent32.png") ; }
|
||||
virtual QString pageName() const { return tr("Transfer") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
public slots:
|
||||
void updateQueueSize(int) ;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "PluginsPage.h"
|
||||
#include "rsharesettings.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/FloatingHelpBrowser.h"
|
||||
|
||||
#define IMAGE_GENERAL ":/images/kcmsystem24.png"
|
||||
|
||||
@ -55,6 +56,9 @@ RSettingsWin::RSettingsWin(QWidget *parent)
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
setModal(false);
|
||||
|
||||
/* Initialize help browser */
|
||||
mHelpBrowser = new FloatingHelpBrowser(this, helpButton);
|
||||
|
||||
initStackedWidget();
|
||||
|
||||
connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int)));
|
||||
@ -160,9 +164,12 @@ RSettingsWin::setNewPage(int page)
|
||||
{
|
||||
ConfigPage *pagew = dynamic_cast<ConfigPage*>(stackedWidget->widget(page)) ;
|
||||
|
||||
mHelpBrowser->hide();
|
||||
|
||||
if(pagew == NULL)
|
||||
{
|
||||
std::cerr << "Error in RSettingsWin::setNewPage(): widget is not a ConfigPage!" << std::endl;
|
||||
mHelpBrowser->clear();
|
||||
return ;
|
||||
}
|
||||
pageName->setText(pagew->pageName());
|
||||
@ -170,6 +177,8 @@ RSettingsWin::setNewPage(int page)
|
||||
|
||||
stackedWidget->setCurrentIndex(page);
|
||||
listWidget->setCurrentRow(page);
|
||||
|
||||
mHelpBrowser->setHelpText(pagew->helpText());
|
||||
}
|
||||
|
||||
/** Saves changes made to settings. */
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <retroshare-gui/configpage.h>
|
||||
#include "ui_settings.h"
|
||||
|
||||
class FloatingHelpBrowser;
|
||||
|
||||
class RSettingsWin: public QDialog, private Ui::Settings
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -56,6 +58,7 @@ private:
|
||||
void initStackedWidget();
|
||||
|
||||
private:
|
||||
FloatingHelpBrowser *mHelpBrowser;
|
||||
static RSettingsWin *_instance;
|
||||
static int lastPage;
|
||||
};
|
||||
|
@ -84,19 +84,6 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pageicon">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="pageName">
|
||||
<property name="sizePolicy">
|
||||
@ -117,7 +104,37 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pageicon">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="helpButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -457,6 +457,7 @@ HEADERS += rshare.h \
|
||||
gui/common/HeaderFrame.h \
|
||||
gui/common/MimeTextEdit.h \
|
||||
gui/common/UIStateHelper.h \
|
||||
gui/common/FloatingHelpBrowser.h \
|
||||
gui/style/RSStyle.h \
|
||||
gui/style/StyleDialog.h \
|
||||
gui/MessagesDialog.h \
|
||||
@ -738,6 +739,7 @@ SOURCES += main.cpp \
|
||||
gui/common/HeaderFrame.cpp \
|
||||
gui/common/MimeTextEdit.cpp \
|
||||
gui/common/UIStateHelper.cpp \
|
||||
gui/common/FloatingHelpBrowser.cpp \
|
||||
gui/style/RSStyle.cpp \
|
||||
gui/style/StyleDialog.cpp \
|
||||
gui/settings/rsharesettings.cpp \
|
||||
|
@ -49,6 +49,10 @@ class ConfigPage : public QWidget
|
||||
//
|
||||
virtual QString pageName() const = 0 ;
|
||||
|
||||
// Text to be used to display in the help browser
|
||||
//
|
||||
virtual QString helpText() const = 0;
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent * /*event*/)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
class UserNotify;
|
||||
class QAbstractButton ;
|
||||
class FloatingHelpBrowser;
|
||||
|
||||
class MainPage : public QWidget
|
||||
{
|
||||
@ -45,11 +46,8 @@ class MainPage : public QWidget
|
||||
//
|
||||
void registerHelpButton(QAbstractButton *button, const QString& help_html_text) ;
|
||||
|
||||
private slots:
|
||||
void showHelp(bool b) ;
|
||||
|
||||
private:
|
||||
QTextBrowser *help_browser ;
|
||||
FloatingHelpBrowser *mHelpBrowser ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user