Subversion Repositories Scribus

Rev

Rev 112 | Rev 161 | 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>
128 Franz 17
 
18
#if (_MSC_VER >= 1200)
19
 #include "win-config.h"
20
#else
21
 #include "config.h"
22
#endif
23
 
3 paul 24
extern QPixmap loadIcon(QString nam);
25
 
26
/*
27
 *  Constructs a HelpBrowser which is a child of 'parent', with the
28
 *  name 'name' and widget flags set to 'f'
29
 *
30
 *  The dialog will by default be modeless, unless you set 'modal' to
31
 *  TRUE to construct a modal dialog.
32
 */
33
HelpBrowser::HelpBrowser( QWidget* parent, QString Capt, QString Datei )
34
    : QWidget( parent, "Help", WType_TopLevel | WDestructiveClose )
35
{
36
    resize( 547, 450 );
37
    setCaption( Capt );
68 Franz 38
                mHistory.clear();
75 Franz 39
                struct histd his;
83 Franz 40
        setIcon(loadIcon("AppIcon.png"));
3 paul 41
    HelpBrowserLayout = new QVBoxLayout( this );
42
    HelpBrowserLayout->setSpacing( 2 );
43
    HelpBrowserLayout->setMargin( 2 );
44
 
45
    Layout13 = new QHBoxLayout;
46
    Layout13->setSpacing( 6 );
47
    Layout13->setMargin( 0 );
48
 
49
    HomeB = new QToolButton( this, "HomeB" );
50
    HomeB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, HomeB->sizePolicy().hasHeightForWidth() ) );
51
    HomeB->setMinimumSize( QSize( 0, 0 ) );
52
    HomeB->setMaximumSize( QSize( 32767, 32767 ) );
53
    HomeB->setText( tr( "" ) );
23 Franz 54
    HomeB->setPixmap(loadIcon("gohome.png"));
3 paul 55
    Layout13->addWidget( HomeB );
56
 
68 Franz 57
    hist = new QPopupMenu( this );
3 paul 58
    BackB = new QToolButton( this, "BackB" );
59
    BackB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, BackB->sizePolicy().hasHeightForWidth() ) );
60
    BackB->setMinimumSize( QSize( 0, 0 ) );
61
    BackB->setMaximumSize( QSize( 32767, 32767 ) );
23 Franz 62
    BackB->setPixmap(loadIcon("back.png"));
68 Franz 63
                BackB->setPopup(hist);
64
                BackB->setPopupDelay(0);
3 paul 65
    Layout13->addWidget( BackB );
66
 
67
    ForwB = new QToolButton( this, "ForwB" );
68
    ForwB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, ForwB->sizePolicy().hasHeightForWidth() ) );
69
    ForwB->setMinimumSize( QSize( 0, 0 ) );
70
    ForwB->setMaximumSize( QSize( 32767, 32767 ) );
23 Franz 71
    ForwB->setPixmap(loadIcon("forward.png"));
3 paul 72
    Layout13->addWidget( ForwB );
73
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
74
    Layout13->addItem( spacer );
75
    HelpBrowserLayout->addLayout( Layout13 );
76
 
77
    Anzeige = new QTextBrowser( this, "Anzeige" );
78
    Anzeige->setFrameShape( QTextBrowser::StyledPanel );
79
        QString pfad = PREL;
80
        QString pfad2;
81
        bool Avail = true;
82
                if (Datei == "")
83
                pfad2 = pfad + "/lib/scribus/doc/"+QString(QTextCodec::locale()).left(2)+"/index.html";
84
                else
85
                        pfad2 = Datei;
86
        QFileInfo fi;
87
        fi = QFileInfo(pfad2);
88
        if (!fi.exists())
89
                {
90
                pfad2 = pfad + "/lib/scribus/doc/en/index.html";
91
                fi = QFileInfo(pfad2);
92
                if (!fi.exists())
93
                        {
112 Franz 94
                        Anzeige->setText("<h2>"+ tr("Sorry, no manual available!")+"</h2>");
3 paul 95
                        Avail = false;
96
                        }
97
                }
98
        if (Avail)
68 Franz 99
                        {
3 paul 100
        Anzeige->setSource(pfad2);
75 Franz 101
                        his.Title = Anzeige->documentTitle();
102
                        if (his.Title == "")
103
                                his.Title = pfad2;
104
                        his.Url = pfad2;
105
                        mHistory[hist->insertItem(his.Title)] = his;
68 Franz 106
                        }
3 paul 107
    HelpBrowserLayout->addWidget( Anzeige );
108
 
109
    // signals and slots connections
110
    connect( HomeB, SIGNAL( clicked() ), Anzeige, SLOT( home() ) );
111
    connect( ForwB, SIGNAL( clicked() ), Anzeige, SLOT( forward() ) );
112
    connect( BackB, SIGNAL( clicked() ), Anzeige, SLOT( backward() ) );
68 Franz 113
    connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int)));
114
    connect(Anzeige, SIGNAL(sourceChanged(const QString&)),this, SLOT(sourceChanged(const QString&)));
3 paul 115
}
116
 
68 Franz 117
void HelpBrowser::sourceChanged(const QString& url)
118
{
119
        bool inList = false;
75 Franz 120
        struct histd his;
121
        QString title = "";
122
        title = Anzeige->documentTitle();
123
        if (title == "")
124
                title = url;
125
        QMap<int, histd>::Iterator it;
68 Franz 126
        for (it = mHistory.begin(); it != mHistory.end(); ++it)
127
                {
75 Franz 128
                if (it.data().Title == title)
68 Franz 129
                        inList = true;
75 Franz 130
                }      
131
        if (!inList)
132
                {
133
                his.Title = title;
134
                his.Url = url;
135
                mHistory[hist->insertItem(title)] = his;
68 Franz 136
                }
75 Franz 137
        if (mHistory.count() > 15)
138
                {
139
                int itk = hist->idAt(0);
140
                mHistory.remove(itk);
141
                hist->removeItem(itk);
142
                }
68 Franz 143
}
144
 
145
void HelpBrowser::histChosen(int i)
146
{
147
        if (mHistory.contains(i))
75 Franz 148
                Anzeige->setSource(mHistory[i].Url);
68 Franz 149
}
150