From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- examples/helpdemo/about.txt | 1 + examples/helpdemo/doc/handbook.png | Bin 0 -> 1060 bytes examples/helpdemo/doc/helpdemo.adp | 27 +++++ examples/helpdemo/doc/index.html | 41 +++++++ examples/helpdemo/doc/logo.png | Bin 0 -> 811 bytes examples/helpdemo/doc/manual.html | 65 ++++++++++ examples/helpdemo/helpdemo.cpp | 119 ++++++++++++++++++ examples/helpdemo/helpdemo.h | 42 +++++++ examples/helpdemo/helpdemo.pro | 15 +++ examples/helpdemo/helpdemobase.ui | 239 +++++++++++++++++++++++++++++++++++++ examples/helpdemo/main.cpp | 11 ++ 11 files changed, 560 insertions(+) create mode 100644 examples/helpdemo/about.txt create mode 100644 examples/helpdemo/doc/handbook.png create mode 100644 examples/helpdemo/doc/helpdemo.adp create mode 100644 examples/helpdemo/doc/index.html create mode 100644 examples/helpdemo/doc/logo.png create mode 100644 examples/helpdemo/doc/manual.html create mode 100644 examples/helpdemo/helpdemo.cpp create mode 100644 examples/helpdemo/helpdemo.h create mode 100644 examples/helpdemo/helpdemo.pro create mode 100644 examples/helpdemo/helpdemobase.ui create mode 100644 examples/helpdemo/main.cpp (limited to 'examples/helpdemo') diff --git a/examples/helpdemo/about.txt b/examples/helpdemo/about.txt new file mode 100644 index 000000000..f47564d56 --- /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 new file mode 100644 index 000000000..3bd2b928b Binary files /dev/null and b/examples/helpdemo/doc/handbook.png differ diff --git a/examples/helpdemo/doc/helpdemo.adp b/examples/helpdemo/doc/helpdemo.adp new file mode 100644 index 000000000..fbc0fc55d --- /dev/null +++ b/examples/helpdemo/doc/helpdemo.adp @@ -0,0 +1,27 @@ + + + + + + HelpExample + Help Example + logo.png + index.html + About Help + ../about.txt + ../../../doc/html + + + +
+ Example Profile + Filename + Hide Sidebar + Open Assistant + Close Assistant + Display + Close +
+
+ +
diff --git a/examples/helpdemo/doc/index.html b/examples/helpdemo/doc/index.html new file mode 100644 index 000000000..9f1fb212c --- /dev/null +++ b/examples/helpdemo/doc/index.html @@ -0,0 +1,41 @@ + + + + Help example + + +

Help example

+ +

+ This example demonstrates how to use TQt Assistant as help system + for your own application. You can control TQt Assistant either directly + using e.g. the open button or indirectly by pressing F1. +

+ +

+ This example provides a context sensitive help, i.e. pressing F1 will + show the help for the item under the mouse cursor. +

+ +

+ In order to run TQt 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 TQt 3.1. Once such a profile has been + specified TQt Assistant can be run with the option -profile + and then the filename of the profile. The HelpDemo example does + this for you if you press the Run TQt Assistant customized for + HelpDemo. +

+ +

+ TQt Assistant can also display arbitrary pages with the + Display button or using the context help (F1), but TQt + Assistant won't be customized for this example application. +

+ + + + diff --git a/examples/helpdemo/doc/logo.png b/examples/helpdemo/doc/logo.png new file mode 100644 index 000000000..16f7d1f3a Binary files /dev/null and b/examples/helpdemo/doc/logo.png differ diff --git a/examples/helpdemo/doc/manual.html b/examples/helpdemo/doc/manual.html new file mode 100644 index 000000000..8410a99d5 --- /dev/null +++ b/examples/helpdemo/doc/manual.html @@ -0,0 +1,65 @@ + + + + How to use this Example + + +

How to use this Example

+

There are three ways to get help in this example: +

+ +





+

Open Assistant Button

+

Click this button to open TQt Assistant. If it is already open nothing + will happen. The displayed page is the one that was last displayed.

+ +





+

Close Assistant Button

+

Click this button to close TQt Assistant. If it is not running nothing + will happen.

+ +





+

Run TQt Assistant customized for HelpDemo

+

Check this item in order to run TQt Assistant as a customized help tool for + the HelpDemo example. Checking or unchecking has no effect if TQt + Assistant is already running. To apply changes you have to restart + TQt Assistant. Please see the HelpDemo::setAssistantArguments() + function to see how TQt Assistant can be started in customized mode. +

+ +





+

Hide Sidebar on Startup

+

Check this item to run TQt Assistant with the sidebar hidden. + Checking or unchecking has no effect if TQt Assistant is already running. + To apply changes you have to restart TQt Assistant.

+ +





+

Filename

+

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.

+ +





+

Display Button

+

Click this button in order to get the help page which is specified in the file name + line edit displayed. If TQt Assistant is currently not open, it will be + opened automatically.

+ +





+

Close Button

+

Click this button to tquit this example application.

+ + diff --git a/examples/helpdemo/helpdemo.cpp b/examples/helpdemo/helpdemo.cpp new file mode 100644 index 000000000..835d18185 --- /dev/null +++ b/examples/helpdemo/helpdemo.cpp @@ -0,0 +1,119 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "helpdemo.h" + +HelpDemo::HelpDemo( TQWidget *parent, const char *name ) + : HelpDemoBase( parent, name ) +{ + leFileName->setText( "./doc/index.html" ); + assistant = new TQAssistantClient( TQDir( "../../bin" ).absPath(), this ); + widgets.insert( (TQWidget*)openTQAButton, "./doc/manual.html#openqabutton" ); + widgets.insert( (TQWidget*)closeTQAButton, "./doc/manual.html#closeqabutton" ); + widgets.insert( (TQWidget*)checkOnlyExampleDoc, "./doc/manual.html#onlydoc" ); + widgets.insert( (TQWidget*)checkHide, "./doc/manual.html#hide" ); + widgets.insert( (TQWidget*)leFileName, "./doc/manual.html#lineedit" ); + widgets.insert( (TQWidget*)displayButton, "./doc/manual.html#displaybutton" ); + widgets.insert( (TQWidget*)closeButton, "./doc/manual.html#closebutton" ); + + menu = new TQPopupMenu( this ); + + TQAction *helpAction = new TQAction( "Show Help", TQKeySequence(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 TQString&)), + this, SLOT(showAssistantErrors(const TQString&)) ); + closeTQAButton->setEnabled(FALSE); +} + +HelpDemo::~HelpDemo() +{ +} + +void HelpDemo::contextMenuEvent( TQContextMenuEvent *e ) +{ + TQWidget *w = lookForWidget(); + if ( menu->exec( e->globalPos() ) != -1 ) + showHelp( w ); +} + +TQWidget* HelpDemo::lookForWidget() +{ + TQPtrDictIterator it( widgets ); + TQWidget *w; + while ( (w = (TQWidget*)(it.currentKey())) != 0 ) { + ++it; + if ( w->hasMouse() ) + return w; + } + return 0; +} + +void HelpDemo::showHelp() +{ + showHelp( lookForWidget() ); +} + +void HelpDemo::showHelp( TQWidget *w ) +{ + if ( w ) + assistant->showPage( TQString( widgets[w] ) ); + else + assistant->showPage( "./doc/index.html" ); +} + +void HelpDemo::setAssistantArguments() +{ + TQStringList cmdLst; + if ( checkHide->isChecked() ) + cmdLst << "-hideSidebar"; + if ( checkOnlyExampleDoc->isChecked() ) + cmdLst << "-profile" + << TQString("doc") + TQDir::separator() + TQString("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 TQString &err ) +{ + TQMessageBox::critical( this, "Assistant Error", err ); + +} + +void HelpDemo::assistantOpened() +{ + closeTQAButton->setEnabled( TRUE ); + openTQAButton->setEnabled( FALSE ); +} + +void HelpDemo::assistantClosed() +{ + closeTQAButton->setEnabled( FALSE ); + openTQAButton->setEnabled( TRUE ); +} diff --git a/examples/helpdemo/helpdemo.h b/examples/helpdemo/helpdemo.h new file mode 100644 index 000000000..c98f26528 --- /dev/null +++ b/examples/helpdemo/helpdemo.h @@ -0,0 +1,42 @@ +#ifndef HELPDEMO_H +#define HELPDEMO_H + +#include + +#include "helpdemobase.h" + +class TQAssistantClient; +class TQPopupMenu; + +class HelpDemo : public HelpDemoBase +{ + Q_OBJECT + +public: + HelpDemo( TQWidget *parent = 0, const char *name = 0 ); + ~HelpDemo(); + +protected: + void contextMenuEvent( TQContextMenuEvent *e ); + +private slots: + void setAssistantArguments(); + void openAssistant(); + void closeAssistant(); + void displayPage(); + void showAssistantErrors( const TQString &err ); + void assistantOpened(); + void assistantClosed(); + void showHelp(); + +private: + TQWidget* lookForWidget(); + void showHelp( TQWidget *w ); + + TQPtrDict widgets; + TQAssistantClient *assistant; + TQPopupMenu *menu; + +}; + +#endif diff --git a/examples/helpdemo/helpdemo.pro b/examples/helpdemo/helpdemo.pro new file mode 100644 index 000000000..ff62776dc --- /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 000000000..75e4b7237 --- /dev/null +++ b/examples/helpdemo/helpdemobase.ui @@ -0,0 +1,239 @@ + +HelpDemoBase + + + HelpDemoBase + + + + 0 + 0 + 315 + 346 + + + + Help Example + + + + unnamed + + + + layout2 + + + + unnamed + + + + spacer1 + + + Horizontal + + + Expanding + + + + 301 + 20 + + + + + + closeButton + + + &Close + + + Alt+C + + + true + + + + + + + frame5 + + + StyledPanel + + + Sunken + + + + unnamed + + + + openTQAButton + + + &Open Assistant + + + Alt+L + + + true + + + + + displayButton + + + &Display + + + Alt+D + + + true + + + + + checkHide + + + &Hide Sidebar when Opening + + + Alt+H + + + + + closeTQAButton + + + C&lose Assistant + + + Alt+L + + + true + + + + + textLabel3 + + + &Filename: + + + leFileName + + + + + leFileName + + + + + checkOnlyExampleDoc + + + Run TQt Assistant customized for HelpDemo + + + + + + + + + + textEdit1 + + + <p> +This example demonstrates how TQt Assistant can be used as a help system for your application. If the button <i>"Run TQt Assistant customized for HelpDemo"</i> is checked TQt Assistant will be customized for this application. +</p> + + + WidgetWidth + + + true + + + + + spacer2 + + + Vertical + + + Expanding + + + + 31 + 30 + + + + + + + + closeButton + clicked() + HelpDemoBase + close() + + + openTQAButton + clicked() + HelpDemoBase + openAssistant() + + + closeTQAButton + clicked() + HelpDemoBase + closeAssistant() + + + displayButton + clicked() + HelpDemoBase + displayPage() + + + checkOnlyExampleDoc + toggled(bool) + HelpDemoBase + setAssistantArguments() + + + checkHide + toggled(bool) + HelpDemoBase + setAssistantArguments() + + + + displayPage() + openAssistant() + closeAssistant() + setAssistantArguments() + + + diff --git a/examples/helpdemo/main.cpp b/examples/helpdemo/main.cpp new file mode 100644 index 000000000..c044c1797 --- /dev/null +++ b/examples/helpdemo/main.cpp @@ -0,0 +1,11 @@ +#include +#include "helpdemo.h" + +int main( int argc, char ** argv ) +{ + TQApplication a( argc, argv ); + HelpDemo help; + help.show(); + a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( tquit() ) ); + return a.exec(); +} -- cgit v1.2.1