Subversion Repositories Scribus

Rev

Rev 23 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 paul 1
/****************************************************************************
2
** Form implementation generated from reading ui file 'Help.ui'
3
**
4
** Created: Tue Jul 3 21:51:52 2001
5
**      by:  The User Interface Compiler (uic)
6
**
7
** WARNING! All changes made in this file will be lost!
8
****************************************************************************/
9
#include "helpbrowser.h"
10
#include "helpbrowser.moc"
11
#include <qvariant.h>
12
#include <qtooltip.h>
13
#include <qimage.h>
14
#include <qpixmap.h>
15
#include <qtextcodec.h>
16
#include <qfileinfo.h>
17
#include <config.h>
18
extern QPixmap loadIcon(QString nam);
19
 
20
/*
21
 *  Constructs a HelpBrowser which is a child of 'parent', with the
22
 *  name 'name' and widget flags set to 'f'
23
 *
24
 *  The dialog will by default be modeless, unless you set 'modal' to
25
 *  TRUE to construct a modal dialog.
26
 */
27
HelpBrowser::HelpBrowser( QWidget* parent, QString Capt, QString Datei )
28
    : QWidget( parent, "Help", WType_TopLevel | WDestructiveClose )
29
{
30
    resize( 547, 450 );
31
    setCaption( Capt );
68 Franz 32
                mHistory.clear();
3 paul 33
        setIcon(loadIcon("AppIcon.xpm"));
34
    HelpBrowserLayout = new QVBoxLayout( this );
35
    HelpBrowserLayout->setSpacing( 2 );
36
    HelpBrowserLayout->setMargin( 2 );
37
 
38
    Layout13 = new QHBoxLayout;
39
    Layout13->setSpacing( 6 );
40
    Layout13->setMargin( 0 );
41
 
42
    HomeB = new QToolButton( this, "HomeB" );
43
    HomeB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, HomeB->sizePolicy().hasHeightForWidth() ) );
44
    HomeB->setMinimumSize( QSize( 0, 0 ) );
45
    HomeB->setMaximumSize( QSize( 32767, 32767 ) );
46
    HomeB->setText( tr( "" ) );
23 Franz 47
    HomeB->setPixmap(loadIcon("gohome.png"));
3 paul 48
    Layout13->addWidget( HomeB );
49
 
68 Franz 50
    hist = new QPopupMenu( this );
3 paul 51
    BackB = new QToolButton( this, "BackB" );
52
    BackB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, BackB->sizePolicy().hasHeightForWidth() ) );
53
    BackB->setMinimumSize( QSize( 0, 0 ) );
54
    BackB->setMaximumSize( QSize( 32767, 32767 ) );
23 Franz 55
    BackB->setPixmap(loadIcon("back.png"));
68 Franz 56
                BackB->setPopup(hist);
57
                BackB->setPopupDelay(0);
3 paul 58
    Layout13->addWidget( BackB );
59
 
60
    ForwB = new QToolButton( this, "ForwB" );
61
    ForwB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, ForwB->sizePolicy().hasHeightForWidth() ) );
62
    ForwB->setMinimumSize( QSize( 0, 0 ) );
63
    ForwB->setMaximumSize( QSize( 32767, 32767 ) );
23 Franz 64
    ForwB->setPixmap(loadIcon("forward.png"));
3 paul 65
    Layout13->addWidget( ForwB );
66
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
67
    Layout13->addItem( spacer );
68
    HelpBrowserLayout->addLayout( Layout13 );
69
 
70
    Anzeige = new QTextBrowser( this, "Anzeige" );
71
    Anzeige->setFrameShape( QTextBrowser::StyledPanel );
72
        QString pfad = PREL;
73
        QString pfad2;
74
        bool Avail = true;
75
                if (Datei == "")
76
                pfad2 = pfad + "/lib/scribus/doc/"+QString(QTextCodec::locale()).left(2)+"/index.html";
77
                else
78
                        pfad2 = Datei;
79
        QFileInfo fi;
80
        fi = QFileInfo(pfad2);
81
        if (!fi.exists())
82
                {
83
                pfad2 = pfad + "/lib/scribus/doc/en/index.html";
84
                fi = QFileInfo(pfad2);
85
                if (!fi.exists())
86
                        {
87
                        Anzeige->setText("<h2>"+tr("Sorry, no Manual available!")+"</h2>");
88
                        Avail = false;
89
                        }
90
                }
91
        if (Avail)
68 Franz 92
                        {
3 paul 93
        Anzeige->setSource(pfad2);
68 Franz 94
                        mHistory[hist->insertItem(pfad2)] = pfad2;
95
                        }
3 paul 96
    HelpBrowserLayout->addWidget( Anzeige );
97
 
98
    // signals and slots connections
99
    connect( HomeB, SIGNAL( clicked() ), Anzeige, SLOT( home() ) );
100
    connect( ForwB, SIGNAL( clicked() ), Anzeige, SLOT( forward() ) );
101
    connect( BackB, SIGNAL( clicked() ), Anzeige, SLOT( backward() ) );
68 Franz 102
    connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int)));
103
    connect(Anzeige, SIGNAL(sourceChanged(const QString&)),this, SLOT(sourceChanged(const QString&)));
3 paul 104
}
105
 
68 Franz 106
void HelpBrowser::sourceChanged(const QString& url)
107
{
108
        bool inList = false;
109
        QMap<int, QString>::Iterator it;
110
        for (it = mHistory.begin(); it != mHistory.end(); ++it)
111
                {
112
                if (it.data() == url)
113
                        inList = true;
114
                }
115
        if (!inList)
116
                mHistory[hist->insertItem(url)] = url;
117
}
118
 
119
void HelpBrowser::histChosen(int i)
120
{
121
        if (mHistory.contains(i))
122
                Anzeige->setSource(mHistory[i]);
123
}
124