diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
commit | bd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch) | |
tree | 7a520322212d48ebcb9fbe1087e7fca28b76185c /examples/helpdemo | |
download | qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip |
Add Qt3 development HEAD version
Diffstat (limited to 'examples/helpdemo')
-rw-r--r-- | examples/helpdemo/about.txt | 1 | ||||
-rw-r--r-- | examples/helpdemo/doc/handbook.png | bin | 0 -> 1060 bytes | |||
-rw-r--r-- | examples/helpdemo/doc/helpdemo.adp | 27 | ||||
-rw-r--r-- | examples/helpdemo/doc/index.html | 41 | ||||
-rw-r--r-- | examples/helpdemo/doc/logo.png | bin | 0 -> 811 bytes | |||
-rw-r--r-- | examples/helpdemo/doc/manual.html | 65 | ||||
-rw-r--r-- | examples/helpdemo/helpdemo.cpp | 119 | ||||
-rw-r--r-- | examples/helpdemo/helpdemo.h | 42 | ||||
-rw-r--r-- | examples/helpdemo/helpdemo.pro | 15 | ||||
-rw-r--r-- | examples/helpdemo/helpdemobase.ui | 239 | ||||
-rw-r--r-- | examples/helpdemo/main.cpp | 11 |
11 files changed, 560 insertions, 0 deletions
diff --git a/examples/helpdemo/about.txt b/examples/helpdemo/about.txt new file mode 100644 index 0000000..f47564d --- /dev/null +++ b/examples/helpdemo/about.txt @@ -0,0 +1 @@ +About text for the demo help example. diff --git a/examples/helpdemo/doc/handbook.png b/examples/helpdemo/doc/handbook.png Binary files differnew file mode 100644 index 0000000..3bd2b92 --- /dev/null +++ b/examples/helpdemo/doc/handbook.png diff --git a/examples/helpdemo/doc/helpdemo.adp b/examples/helpdemo/doc/helpdemo.adp new file mode 100644 index 0000000..fbc0fc5 --- /dev/null +++ b/examples/helpdemo/doc/helpdemo.adp @@ -0,0 +1,27 @@ +<!DOCTYPE DCF> + +<assistantconfig version="3.2.0"> + +<profile> + <property name="name">HelpExample</property> + <property name="title">Help Example</property> + <property name="applicationicon">logo.png</property> + <property name="startpage">index.html</property> + <property name="aboutmenutext">About Help</property> + <property name="abouturl">../about.txt</property> + <property name="assistantdocs">../../../doc/html</property> +</profile> + +<DCF ref="index.html" icon="handbook.png" title="Help example"> + <section ref="./manual.html" title="How to use this Example"> + <keyword ref="./manual.html#onlydoc">Example Profile</keyword> + <keyword ref="./manual.html#lineedit">Filename</keyword> + <keyword ref="./manual.html#hide">Hide Sidebar</keyword> + <keyword ref="./manual.html#openqabutton">Open Assistant</keyword> + <keyword ref="./manual.html#closeqabutton">Close Assistant</keyword> + <keyword ref="./manual.html#displaybutton">Display</keyword> + <keyword ref="./manual.html#closebutton">Close</keyword> + </section> +</DCF> + +</assistantconfig> diff --git a/examples/helpdemo/doc/index.html b/examples/helpdemo/doc/index.html new file mode 100644 index 0000000..7b68152 --- /dev/null +++ b/examples/helpdemo/doc/index.html @@ -0,0 +1,41 @@ +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <title>Help example</title> + </head> + <body style="font-size:12pt;font-family:helvetica"> + <p><h2>Help example</h2></p> + + <p> + This example demonstrates how to use Qt Assistant as help system + for your own application. You can control Qt Assistant either directly + using e.g. the open button or indirectly by pressing F1. + </p> + + <p> + This example provides a context sensitive help, i.e. pressing F1 will + show the help for the item under the mouse cursor. + </p> + + <p> + In order to run Qt Assistant as a custom help tool for this + application properly you have to specify a profile. A profile + is a file format similar to the documentation content files + that assistant used up to Qt 3.1. Once such a profile has been + specified Qt Assistant can be run with the option <code>-profile</code> + and then the filename of the profile. The HelpDemo example does + this for you if you press the <i>Run Qt Assistant customized for + HelpDemo</i>. + </p> + + <p> + Qt Assistant can also display arbitrary pages with the + <i>Display</i> button or using the context help (F1), but Qt + Assistant won't be customized for this example application. + </p> + + <ul> + <li><a href="manual.html">How to use this example</a></li> + </ul> + </body> +</html> diff --git a/examples/helpdemo/doc/logo.png b/examples/helpdemo/doc/logo.png Binary files differnew file mode 100644 index 0000000..16f7d1f --- /dev/null +++ b/examples/helpdemo/doc/logo.png diff --git a/examples/helpdemo/doc/manual.html b/examples/helpdemo/doc/manual.html new file mode 100644 index 0000000..7df0e3a --- /dev/null +++ b/examples/helpdemo/doc/manual.html @@ -0,0 +1,65 @@ +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <title>How to use this Example</title> + </head> + <body style="font-size:12pt;font-family:helvetica"> + <p><h2>How to use this Example</h2></p> + <p>There are three ways to get help in this example: + <ul> + <li> + Press F1. Depending where your mouse position is you get either the + help for the item under the mouse cursor or the general help for this + example. + </li> + <li> + Press the right mouse button to invoke a context menu, then click + 'Help'. The displayed help page is choose as described above. + </li> + <li> + Use the buttons to control Qt Assistant directly. For a further + explanation see below. + </li> + </ul> + + <br><br><br><br><br><br> + <p><a name="openqabutton"><h3>Open Assistant Button</h3></a></p> + <p>Click this button to open Qt Assistant. If it is already open nothing + will happen. The displayed page is the one that was last displayed.</p> + + <br><br><br><br><br><br> + <p><a name="closeqabutton"><h3>Close Assistant Button</h3></a></p> + <p>Click this button to close Qt Assistant. If it is not running nothing + will happen.</p> + + <br><br><br><br><br><br> + <p><a name="onlydoc"><h3>Run Qt Assistant customized for HelpDemo</h3></a></p> + <p>Check this item in order to run Qt Assistant as a customized help tool for + the HelpDemo example. Checking or unchecking has no effect if Qt + Assistant is already running. To apply changes you have to restart + Qt Assistant. Please see the <code>HelpDemo::setAssistantArguments()</code> + function to see how Qt Assistant can be started in customized mode. + </p> + + <br><br><br><br><br><br> + <p><a name="hide"><h3>Hide Sidebar on Startup</h3></a></p> + <p>Check this item to run Qt Assistant with the sidebar hidden. + Checking or unchecking has no effect if Qt Assistant is already running. + To apply changes you have to restart Qt Assistant.</p> + + <br><br><br><br><br><br> + <p><a name="lineedit"><h3>Filename</h3></a></p> + <p>Enter the file name of a help page you want to get displayed here. The path + can be specified as an absolute or relative path.</p> + + <br><br><br><br><br><br> + <p><a name="displaybutton"><h3>Display Button</h3></a></p> + <p>Click this button in order to get the help page which is specified in the file name + line edit displayed. If Qt Assistant is currently not open, it will be + opened automatically.</p> + + <br><br><br><br><br><br> + <p><a name="closebutton"><h3>Close Button</h3></a></p> + <p>Click this button to quit this example application.</p> + </body> +</html> diff --git a/examples/helpdemo/helpdemo.cpp b/examples/helpdemo/helpdemo.cpp new file mode 100644 index 0000000..28f8865 --- /dev/null +++ b/examples/helpdemo/helpdemo.cpp @@ -0,0 +1,119 @@ +#include <qassistantclient.h> +#include <qmessagebox.h> +#include <qlineedit.h> +#include <qaction.h> +#include <qpopupmenu.h> +#include <qcheckbox.h> +#include <qprocess.h> +#include <qpushbutton.h> +#include <qdir.h> + +#include "helpdemo.h" + +HelpDemo::HelpDemo( QWidget *parent, const char *name ) + : HelpDemoBase( parent, name ) +{ + leFileName->setText( "./doc/index.html" ); + assistant = new QAssistantClient( QDir( "../../bin" ).absPath(), this ); + widgets.insert( (QWidget*)openQAButton, "./doc/manual.html#openqabutton" ); + widgets.insert( (QWidget*)closeQAButton, "./doc/manual.html#closeqabutton" ); + widgets.insert( (QWidget*)checkOnlyExampleDoc, "./doc/manual.html#onlydoc" ); + widgets.insert( (QWidget*)checkHide, "./doc/manual.html#hide" ); + widgets.insert( (QWidget*)leFileName, "./doc/manual.html#lineedit" ); + widgets.insert( (QWidget*)displayButton, "./doc/manual.html#displaybutton" ); + widgets.insert( (QWidget*)closeButton, "./doc/manual.html#closebutton" ); + + menu = new QPopupMenu( this ); + + QAction *helpAction = new QAction( "Show Help", QKeySequence(tr("F1")), this ); + helpAction->addTo( menu ); + + connect( helpAction, SIGNAL(activated()), this, SLOT(showHelp()) ); + connect( assistant, SIGNAL(assistantOpened()), this, SLOT(assistantOpened()) ); + connect( assistant, SIGNAL(assistantClosed()), this, SLOT(assistantClosed())); + connect( assistant, SIGNAL(error(const QString&)), + this, SLOT(showAssistantErrors(const QString&)) ); + closeQAButton->setEnabled(FALSE); +} + +HelpDemo::~HelpDemo() +{ +} + +void HelpDemo::contextMenuEvent( QContextMenuEvent *e ) +{ + QWidget *w = lookForWidget(); + if ( menu->exec( e->globalPos() ) != -1 ) + showHelp( w ); +} + +QWidget* HelpDemo::lookForWidget() +{ + QPtrDictIterator<char> it( widgets ); + QWidget *w; + while ( (w = (QWidget*)(it.currentKey())) != 0 ) { + ++it; + if ( w->hasMouse() ) + return w; + } + return 0; +} + +void HelpDemo::showHelp() +{ + showHelp( lookForWidget() ); +} + +void HelpDemo::showHelp( QWidget *w ) +{ + if ( w ) + assistant->showPage( QString( widgets[w] ) ); + else + assistant->showPage( "./doc/index.html" ); +} + +void HelpDemo::setAssistantArguments() +{ + QStringList cmdLst; + if ( checkHide->isChecked() ) + cmdLst << "-hideSidebar"; + if ( checkOnlyExampleDoc->isChecked() ) + cmdLst << "-profile" + << QString("doc") + QDir::separator() + QString("helpdemo.adp"); + assistant->setArguments( cmdLst ); +} + +void HelpDemo::openAssistant() +{ + if ( !assistant->isOpen() ) + assistant->openAssistant(); +} + +void HelpDemo::closeAssistant() +{ + if ( assistant->isOpen() ) + assistant->closeAssistant(); +} + +void HelpDemo::displayPage() +{ + assistant->showPage( leFileName->text() ); +} + +void HelpDemo::showAssistantErrors( const QString &err ) +{ + QMessageBox::critical( this, "Assistant Error", err ); + +} + +void HelpDemo::assistantOpened() +{ + closeQAButton->setEnabled( TRUE ); + openQAButton->setEnabled( FALSE ); +} + +void HelpDemo::assistantClosed() +{ + closeQAButton->setEnabled( FALSE ); + openQAButton->setEnabled( TRUE ); +} diff --git a/examples/helpdemo/helpdemo.h b/examples/helpdemo/helpdemo.h new file mode 100644 index 0000000..9916872 --- /dev/null +++ b/examples/helpdemo/helpdemo.h @@ -0,0 +1,42 @@ +#ifndef HELPDEMO_H +#define HELPDEMO_H + +#include <qptrdict.h> + +#include "helpdemobase.h" + +class QAssistantClient; +class QPopupMenu; + +class HelpDemo : public HelpDemoBase +{ + Q_OBJECT + +public: + HelpDemo( QWidget *parent = 0, const char *name = 0 ); + ~HelpDemo(); + +protected: + void contextMenuEvent( QContextMenuEvent *e ); + +private slots: + void setAssistantArguments(); + void openAssistant(); + void closeAssistant(); + void displayPage(); + void showAssistantErrors( const QString &err ); + void assistantOpened(); + void assistantClosed(); + void showHelp(); + +private: + QWidget* lookForWidget(); + void showHelp( QWidget *w ); + + QPtrDict<char> widgets; + QAssistantClient *assistant; + QPopupMenu *menu; + +}; + +#endif diff --git a/examples/helpdemo/helpdemo.pro b/examples/helpdemo/helpdemo.pro new file mode 100644 index 0000000..ff62776 --- /dev/null +++ b/examples/helpdemo/helpdemo.pro @@ -0,0 +1,15 @@ +TEMPLATE = app + +CONFIG += qt warn_on +LIBS += -lqassistantclient +unix { + UI_DIR = .ui + MOC_DIR = .moc + OBJECTS_DIR = .obj +} + +REQUIRES = full-config + +SOURCES += helpdemo.cpp main.cpp +HEADERS += helpdemo.h +FORMS = helpdemobase.ui diff --git a/examples/helpdemo/helpdemobase.ui b/examples/helpdemo/helpdemobase.ui new file mode 100644 index 0000000..35d98ed --- /dev/null +++ b/examples/helpdemo/helpdemobase.ui @@ -0,0 +1,239 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>HelpDemoBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>HelpDemoBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>315</width> + <height>346</height> + </rect> + </property> + <property name="caption"> + <string>Help Example</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="3" column="0"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>301</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>closeButton</cstring> + </property> + <property name="text"> + <string>&Close</string> + </property> + <property name="accel"> + <string>Alt+C</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + <widget class="QFrame" row="1" column="0"> + <property name="name"> + <cstring>frame5</cstring> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>openQAButton</cstring> + </property> + <property name="text"> + <string>&Open Assistant</string> + </property> + <property name="accel"> + <string>Alt+L</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton" row="4" column="3"> + <property name="name"> + <cstring>displayButton</cstring> + </property> + <property name="text"> + <string>&Display</string> + </property> + <property name="accel"> + <string>Alt+D</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>checkHide</cstring> + </property> + <property name="text"> + <string>&Hide Sidebar when Opening</string> + </property> + <property name="accel"> + <string>Alt+H</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>closeQAButton</cstring> + </property> + <property name="text"> + <string>C&lose Assistant</string> + </property> + <property name="accel"> + <string>Alt+L</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>&Filename:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>leFileName</cstring> + </property> + </widget> + <widget class="QLineEdit" row="4" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>leFileName</cstring> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>checkOnlyExampleDoc</cstring> + </property> + <property name="text"> + <string>Run Qt Assistant customized for HelpDemo</string> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + </grid> + </widget> + <widget class="QTextEdit" row="0" column="0"> + <property name="name"> + <cstring>textEdit1</cstring> + </property> + <property name="text"> + <string><p> +This example demonstrates how Qt Assistant can be used as a help system for your application. If the button <i>"Run Qt Assistant customized for HelpDemo"</i> is checked Qt Assistant will be customized for this application. +</p></string> + </property> + <property name="wordWrap"> + <enum>WidgetWidth</enum> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + <spacer row="2" column="0"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>31</width> + <height>30</height> + </size> + </property> + </spacer> + </grid> +</widget> +<connections> + <connection> + <sender>closeButton</sender> + <signal>clicked()</signal> + <receiver>HelpDemoBase</receiver> + <slot>close()</slot> + </connection> + <connection> + <sender>openQAButton</sender> + <signal>clicked()</signal> + <receiver>HelpDemoBase</receiver> + <slot>openAssistant()</slot> + </connection> + <connection> + <sender>closeQAButton</sender> + <signal>clicked()</signal> + <receiver>HelpDemoBase</receiver> + <slot>closeAssistant()</slot> + </connection> + <connection> + <sender>displayButton</sender> + <signal>clicked()</signal> + <receiver>HelpDemoBase</receiver> + <slot>displayPage()</slot> + </connection> + <connection> + <sender>checkOnlyExampleDoc</sender> + <signal>toggled(bool)</signal> + <receiver>HelpDemoBase</receiver> + <slot>setAssistantArguments()</slot> + </connection> + <connection> + <sender>checkHide</sender> + <signal>toggled(bool)</signal> + <receiver>HelpDemoBase</receiver> + <slot>setAssistantArguments()</slot> + </connection> +</connections> +<slots> + <slot>displayPage()</slot> + <slot>openAssistant()</slot> + <slot>closeAssistant()</slot> + <slot>setAssistantArguments()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/examples/helpdemo/main.cpp b/examples/helpdemo/main.cpp new file mode 100644 index 0000000..81a6edc --- /dev/null +++ b/examples/helpdemo/main.cpp @@ -0,0 +1,11 @@ +#include <qapplication.h> +#include "helpdemo.h" + +int main( int argc, char ** argv ) +{ + QApplication a( argc, argv ); + HelpDemo help; + help.show(); + a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); + return a.exec(); +} |