diff --git a/plugins/FeedReader/gui/FeedReaderConfig.h b/plugins/FeedReader/gui/FeedReaderConfig.h index ccd831b5d..27a678d87 100644 --- a/plugins/FeedReader/gui/FeedReaderConfig.h +++ b/plugins/FeedReader/gui/FeedReaderConfig.h @@ -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(); diff --git a/plugins/VOIP/gui/AudioInputConfig.h b/plugins/VOIP/gui/AudioInputConfig.h index 8ca757763..ee118f509 100644 --- a/plugins/VOIP/gui/AudioInputConfig.h +++ b/plugins/VOIP/gui/AudioInputConfig.h @@ -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(); diff --git a/retroshare-gui/src/gui/MainPage.cpp b/retroshare-gui/src/gui/MainPage.cpp index d60118446..58a2c35a4 100644 --- a/retroshare-gui/src/gui/MainPage.cpp +++ b/retroshare-gui/src/gui/MainPage.cpp @@ -1,61 +1,18 @@ -#include #include -#include -#include -#include +#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("
"+help_html_txt+"
") ; - - QObject::connect(button,SIGNAL(toggled(bool)), this, SLOT( showHelp(bool) ) ) ; + mHelpBrowser->setHelpText(help_html_txt) ; } diff --git a/retroshare-gui/src/gui/common/FloatingHelpBrowser.cpp b/retroshare-gui/src/gui/common/FloatingHelpBrowser.cpp new file mode 100644 index 000000000..01d4b9dde --- /dev/null +++ b/retroshare-gui/src/gui/common/FloatingHelpBrowser.cpp @@ -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 +#include +#include + +#include + +#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("
" + helpText + "
"); +} diff --git a/retroshare-gui/src/gui/common/FloatingHelpBrowser.h b/retroshare-gui/src/gui/common/FloatingHelpBrowser.h new file mode 100644 index 000000000..4389e169f --- /dev/null +++ b/retroshare-gui/src/gui/common/FloatingHelpBrowser.h @@ -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 + +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 diff --git a/retroshare-gui/src/gui/settings/AppearancePage.h b/retroshare-gui/src/gui/settings/AppearancePage.h index 7fc9b8322..7d5d21c87 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.h +++ b/retroshare-gui/src/gui/settings/AppearancePage.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); diff --git a/retroshare-gui/src/gui/settings/ChatPage.h b/retroshare-gui/src/gui/settings/ChatPage.h index fac3e30d5..793aec362 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.h +++ b/retroshare-gui/src/gui/settings/ChatPage.h @@ -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 - diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h index 635a576bc..248fd1ddb 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.h +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -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(); diff --git a/retroshare-gui/src/gui/settings/DirectoriesPage.h b/retroshare-gui/src/gui/settings/DirectoriesPage.h index e59213c6c..05ab24398 100755 --- a/retroshare-gui/src/gui/settings/DirectoriesPage.h +++ b/retroshare-gui/src/gui/settings/DirectoriesPage.h @@ -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() ; diff --git a/retroshare-gui/src/gui/settings/ForumPage.h b/retroshare-gui/src/gui/settings/ForumPage.h index 50b4d7102..0ae1d8c46 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.h +++ b/retroshare-gui/src/gui/settings/ForumPage.h @@ -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; diff --git a/retroshare-gui/src/gui/settings/GeneralPage.h b/retroshare-gui/src/gui/settings/GeneralPage.h index d9d8c0f34..ba7cf3728 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.h +++ b/retroshare-gui/src/gui/settings/GeneralPage.h @@ -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() ; diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index 21c0f8ca1..477952d38 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -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: diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index 6b4bfe5f9..f6ac574a2 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -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(); diff --git a/retroshare-gui/src/gui/settings/PluginsPage.h b/retroshare-gui/src/gui/settings/PluginsPage.h index 896e50c80..0a280ae5d 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.h +++ b/retroshare-gui/src/gui/settings/PluginsPage.h @@ -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: diff --git a/retroshare-gui/src/gui/settings/RelayPage.h b/retroshare-gui/src/gui/settings/RelayPage.h index 09a9b7855..4dfb70c4a 100644 --- a/retroshare-gui/src/gui/settings/RelayPage.h +++ b/retroshare-gui/src/gui/settings/RelayPage.h @@ -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(); diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index df474e251..84a3a1d63 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -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(); diff --git a/retroshare-gui/src/gui/settings/SoundPage.h b/retroshare-gui/src/gui/settings/SoundPage.h index 6a31fcbdd..dca157bc2 100644 --- a/retroshare-gui/src/gui/settings/SoundPage.h +++ b/retroshare-gui/src/gui/settings/SoundPage.h @@ -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); diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index 69f410774..a10538168 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -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) ; diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index c1daa9027..0cd512b4b 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -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(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. */ diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 8940efc45..8e9305b82 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -26,6 +26,8 @@ #include #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; }; diff --git a/retroshare-gui/src/gui/settings/settings.ui b/retroshare-gui/src/gui/settings/settings.ui index 15d1b6509..ddfc02e74 100755 --- a/retroshare-gui/src/gui/settings/settings.ui +++ b/retroshare-gui/src/gui/settings/settings.ui @@ -84,19 +84,6 @@ - - - - - 24 - 24 - - - - true - - - @@ -117,7 +104,37 @@ - + + + + + 24 + 24 + + + + true + + + + + + + Qt::NoFocus + + + + :/images/64px_help.png:/images/64px_help.png + + + true + + + true + + + + Qt::Horizontal diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 9b5f8c6ce..4606972c1 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -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 \ diff --git a/retroshare-gui/src/retroshare-gui/configpage.h b/retroshare-gui/src/retroshare-gui/configpage.h index 8a4aa4545..2b9f1199d 100644 --- a/retroshare-gui/src/retroshare-gui/configpage.h +++ b/retroshare-gui/src/retroshare-gui/configpage.h @@ -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*/) { diff --git a/retroshare-gui/src/retroshare-gui/mainpage.h b/retroshare-gui/src/retroshare-gui/mainpage.h index 7a677f6d6..b6daf2c60 100644 --- a/retroshare-gui/src/retroshare-gui/mainpage.h +++ b/retroshare-gui/src/retroshare-gui/mainpage.h @@ -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