Subversion Repositories Scribus

Rev

Rev 73 | Rev 83 | 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();
75 Franz 33
                struct histd his;
3 paul 34
        setIcon(loadIcon("AppIcon.xpm"));
35
    HelpBrowserLayout = new QVBoxLayout( this );
36
    HelpBrowserLayout->setSpacing( 2 );
37
    HelpBrowserLayout->setMargin( 2 );
38
 
39
    Layout13 = new QHBoxLayout;
40
    Layout13->setSpacing( 6 );
41
    Layout13->setMargin( 0 );
42
 
43
    HomeB = new QToolButton( this, "HomeB" );
44
    HomeB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, HomeB->sizePolicy().hasHeightForWidth() ) );
45
    HomeB->setMinimumSize( QSize( 0, 0 ) );
46
    HomeB->setMaximumSize( QSize( 32767, 32767 ) );
47
    HomeB->setText( tr( "" ) );
23 Franz 48
    HomeB->setPixmap(loadIcon("gohome.png"));
3 paul 49
    Layout13->addWidget( HomeB );
50
 
68 Franz 51
    hist = new QPopupMenu( this );
3 paul 52
    BackB = new QToolButton( this, "BackB" );
53
    BackB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, BackB->sizePolicy().hasHeightForWidth() ) );
54
    BackB->setMinimumSize( QSize( 0, 0 ) );
55
    BackB->setMaximumSize( QSize( 32767, 32767 ) );
23 Franz 56
    BackB->setPixmap(loadIcon("back.png"));
68 Franz 57
                BackB->setPopup(hist);
58
                BackB->setPopupDelay(0);
3 paul 59
    Layout13->addWidget( BackB );
60
 
61
    ForwB = new QToolButton( this, "ForwB" );
62
    ForwB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, ForwB->sizePolicy().hasHeightForWidth() ) );
63
    ForwB->setMinimumSize( QSize( 0, 0 ) );
64
    ForwB->setMaximumSize( QSize( 32767, 32767 ) );
23 Franz 65
    ForwB->setPixmap(loadIcon("forward.png"));
3 paul 66
    Layout13->addWidget( ForwB );
67
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
68
    Layout13->addItem( spacer );
69
    HelpBrowserLayout->addLayout( Layout13 );
70
 
71
    Anzeige = new QTextBrowser( this, "Anzeige" );
72
    Anzeige->setFrameShape( QTextBrowser::StyledPanel );
73
        QString pfad = PREL;
74
        QString pfad2;
75
        bool Avail = true;
76
                if (Datei == "")
77
                pfad2 = pfad + "/lib/scribus/doc/"+QString(QTextCodec::locale()).left(2)+"/index.html";
78
                else
79
                        pfad2 = Datei;
80
        QFileInfo fi;
81
        fi = QFileInfo(pfad2);
82
        if (!fi.exists())
83
                {
84
                pfad2 = pfad + "/lib/scribus/doc/en/index.html";
85
                fi = QFileInfo(pfad2);
86
                if (!fi.exists())
87
                        {
73 Franz 88
                        Anzeige->setText("<h2>"+tr("Sorry, no manual available!")+"</h2>");
3 paul 89
                        Avail = false;
90
                        }
91
                }
92
        if (Avail)
68 Franz 93
                        {
3 paul 94
        Anzeige->setSource(pfad2);
75 Franz 95
                        his.Title = Anzeige->documentTitle();
96
                        if (his.Title == "")
97
                                his.Title = pfad2;
98
                        his.Url = pfad2;
99
                        mHistory[hist->insertItem(his.Title)] = his;
68 Franz 100
                        }
3 paul 101
    HelpBrowserLayout->addWidget( Anzeige );
102
 
103
    // signals and slots connections
104
    connect( HomeB, SIGNAL( clicked() ), Anzeige, SLOT( home() ) );
105
    connect( ForwB, SIGNAL( clicked() ), Anzeige, SLOT( forward() ) );
106
    connect( BackB, SIGNAL( clicked() ), Anzeige, SLOT( backward() ) );
68 Franz 107
    connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int)));
108
    connect(Anzeige, SIGNAL(sourceChanged(const QString&)),this, SLOT(sourceChanged(const QString&)));
3 paul 109
}
110
 
68 Franz 111
void HelpBrowser::sourceChanged(const QString& url)
112
{
113
        bool inList = false;
75 Franz 114
        struct histd his;
115
        QString title = "";
116
        title = Anzeige->documentTitle();
117
        if (title == "")
118
                title = url;
119
        QMap<int, histd>::Iterator it;
68 Franz 120
        for (it = mHistory.begin(); it != mHistory.end(); ++it)
121
                {
75 Franz 122
                if (it.data().Title == title)
68 Franz 123
                        inList = true;
75 Franz 124
                }      
125
        if (!inList)
126
                {
127
                his.Title = title;
128
                his.Url = url;
129
                mHistory[hist->insertItem(title)] = his;
68 Franz 130
                }
75 Franz 131
        if (mHistory.count() > 15)
132
                {
133
                int itk = hist->idAt(0);
134
                mHistory.remove(itk);
135
                hist->removeItem(itk);
136
                }
68 Franz 137
}
138
 
139
void HelpBrowser::histChosen(int i)
140
{
141
        if (mHistory.contains(i))
75 Franz 142
                Anzeige->setSource(mHistory[i].Url);
68 Franz 143
}
144