-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpbrowser.cpp
More file actions
70 lines (56 loc) · 1.94 KB
/
helpbrowser.cpp
File metadata and controls
70 lines (56 loc) · 1.94 KB
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
// Copyright 2016 Manfred Dings
#include "helpbrowser.h"
HelpBrowser::HelpBrowser(QSettings *settings, QWidget *parent):
QDialog(parent)
{
msettings = settings;
textBrowser = new QTextBrowser;
homeButton = new QPushButton(tr("H&ome"));
backButton = new QPushButton(tr("Zu&rück"));
closeButton = new QPushButton(tr("&Schließen"));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(homeButton);
buttonLayout->addWidget(backButton);
buttonLayout->addStretch();
buttonLayout->addWidget(closeButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(textBrowser);
setLayout(mainLayout);
connect(homeButton, SIGNAL(clicked()), textBrowser, SLOT(home()));
connect(backButton, SIGNAL(clicked()), textBrowser, SLOT(backward()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect(textBrowser, SIGNAL(sourceChanged(QUrl)),
this, SLOT(updateWindowTitle()));
mpath = directoryOf("help").absolutePath();
textBrowser->setSearchPaths(QStringList() << mpath<< ":/images");
restoreGeometry(msettings->value("helpBrowser/geometry").toByteArray());
}
HelpBrowser::~HelpBrowser()
{
}
void HelpBrowser::showPage(const QString &page)
{
textBrowser->setSource(page);
}
void HelpBrowser::closeEvent(QCloseEvent *event)
{
msettings->setValue("helpBrowser/geometry", saveGeometry());
QDialog::closeEvent(event);
}
void HelpBrowser::updateWindowTitle()
{
setWindowTitle(tr("Hilfe: %1").arg(textBrowser->documentTitle()));
}
QDir HelpBrowser::directoryOf(const QString &subdir)
{
QDir dir(QApplication::applicationDirPath());
if (dir.dirName().toLower() == "debug" ||
dir.dirName().toLower() == "release")
{
dir.cdUp();
dir.cdUp();
}
dir.cd(subdir);
return dir;
}