00001 /* 00002 Aseba - an event-based framework for distributed robot control 00003 Copyright (C) 2007--2012: 00004 Stephane Magnenat <stephane at magnenat dot net> 00005 (http://stephane.magnenat.net) 00006 and other contributors, see authors.txt for details 00007 00008 This program is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as published 00010 by the Free Software Foundation, version 3 of the License. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef HELP_VIEWER_H 00022 #define HELP_VIEWER_H 00023 00024 #include <QtHelp/QHelpEngine> 00025 #include <QWidget> 00026 #include <QString> 00027 #include <QPushButton> 00028 #include <QTextBrowser> 00029 00030 namespace Aseba 00031 { 00032 class HelpBrowser; 00033 00034 class HelpViewer: public QWidget 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 HelpViewer(QWidget* parent = 0); 00040 ~HelpViewer(); 00041 00042 enum helpType { 00043 USERMANUAL, 00044 STUDIO, 00045 LANGUAGE 00046 }; 00047 00048 static const QString DEFAULT_LANGUAGE; 00049 00050 void setLanguage(const QString& lang = DEFAULT_LANGUAGE); 00051 void showHelp(helpType type); 00052 00053 protected: 00054 bool selectLanguage(const QString& reqLang); 00055 bool readSettings(); 00056 void writeSettings(); 00057 00058 QHelpEngine *helpEngine; 00059 HelpBrowser* viewer; 00060 QPushButton* previous; 00061 QPushButton* next; 00062 QPushButton* home; 00063 QString language; 00064 bool helpFound; 00065 const QString tmpHelpSubDir; 00066 const QString tmpHelpFileNameHC; 00067 const QString tmpHelpFileNameCH; 00068 00069 protected slots: 00070 void previousClicked(); 00071 void backwardAvailable(bool state); 00072 void nextClicked(); 00073 void forwardAvailable(bool state); 00074 void homeClicked(); 00075 }; 00076 00077 class HelpBrowser: public QTextBrowser 00078 { 00079 public: 00080 HelpBrowser(QHelpEngine* helpEngine, QWidget* parent = 0); 00081 virtual void setSource(const QUrl& url); 00082 virtual QVariant loadResource(int type, const QUrl& url); 00083 00084 protected: 00085 QHelpEngine* helpEngine; 00086 }; 00087 } 00088 00089 #endif // HELP_VIEWER_H 00090