1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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 );
}
|