This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
HelpWidget.cpp
116 lines (102 loc) · 3.64 KB
/
HelpWidget.cpp
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
/***************************************************************************//**
* @brief Thumbnail me 3.0
* Thumbnail me is a user interface for Movie thumbnailer.
* Generate thumbnails from any movie is now easier !
*
* @file HelpWidget.cpp
* @class HelpWidget
* Cette classe permet la génération du widget "Aide" pour l'utilisateur.
*
* @author Quentin Rousseau\n
* @note Copyright (C) 2011-2012 Quentin Rousseau\n
* License: GNU General Public License version 2 (GPLv2) - http://www.gnu.org/licenses/gpl-2.0.html\n
* Site web: www.thumbnailme.com\n
* Email: quentin.rousseau@thumbnailme.com
*
* @since 3.0
* @version 3.0
* @date 2011-2012
*******************************************************************************/
#include "HelpWidget.h"
#include <QHelpIndexWidget>
#include <QDesktopWidget>
#include <QTimer>
#include "HelpBrowser.h"
#include "defines.h"
#include "QtHelper.h"
/**
*@brief Constructeur.
*@param parent Fenêtre principale de Thumbnail me.
*/
HelpWidget::HelpWidget(QWidget *parent) : QDialog(parent)
{
//this->setWindowFlags(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | Qt::WindowOkButtonHint | Qt::Dialog);
this->setWindowIcon( QIcon(":sprites/help.png") );
this->setWindowModality(Qt::ApplicationModal);
int height = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen()).height();
int width = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen()).width();
this->setMinimumSize((0.55)*width,(0.6)*height);
QGridLayout *layout = new QGridLayout(this);
helpEngine = new QHelpEngine(DOCS_PATH,this);
helpEngine->setupData();
helpEngine->contentWidget()->setDragEnabled(false);
helpEngine->contentWidget()->setFocusPolicy(Qt::NoFocus);
helpBrowser = new HelpBrowser(helpEngine);
helpBrowser->setOpenExternalLinks(true);
QSplitter *helpPanel = new QSplitter(Qt::Horizontal,this);
helpPanel->insertWidget(0, helpEngine->contentWidget());
helpPanel->insertWidget(1, helpBrowser);
helpPanel->setStretchFactor(1, 1);
layout->addWidget(helpPanel);
this->setLayout(layout);
this->retranslate();
QtHelper::centerWidget(this);
/*Connections*/
connect(helpEngine->contentWidget(), SIGNAL(clicked (const QModelIndex &)), helpEngine->contentWidget(), SIGNAL(activated(const QModelIndex &)));
connect(helpEngine->contentWidget(), SIGNAL(linkActivated(const QUrl &)), helpBrowser, SLOT(setSource(const QUrl &)));
QTimer::singleShot(200, this, SLOT(showHomePage()));
}
/**
*@brief Destructeur.
*/
HelpWidget::~HelpWidget()
{
delete helpBrowser;
}
/**
*@brief Slot permettant d'afficher la page d'acceuil.
*/
void HelpWidget::showHomePage()
{
if( helpEngine->contentModel()->isCreatingContents() == true)
return;
if( helpEngine->contentModel()->rowCount() < 1)
return;
QModelIndex index = helpEngine->contentModel()->index(0, 0);
if( index.isValid() == true)
{
QHelpContentItem* item = helpEngine->contentModel()->contentItemAt(index);
if(item)
{
helpEngine->contentWidget()->setCurrentIndex(index);
helpBrowser->setSource(item->url());
}
}
}
/**
*@brief ChangeEvent.
*@param *event Evenement.
*/
void HelpWidget::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange)
retranslate();
QWidget::changeEvent(event);
}
/**
*@brief Fonction de traduction dynamique.
*/
void HelpWidget::retranslate()
{
this->setWindowTitle( tr("Help") );
}