Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
ead06a7b
Commit
ead06a7b
authored
Jul 13, 2020
by
Shubham .
Browse files
Add zoom in, zoom out functionality
parent
ab42ef6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
ead06a7b
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include
<QLineEdit>
#include
<QLineEdit>
#include
<QModelIndex>
#include
<QModelIndex>
#include
<QPushButton>
#include
<QPushButton>
#include
<QShortcut>
#include
<QStandardPaths>
#include
<QStandardPaths>
#include
<QStackedWidget>
#include
<QStackedWidget>
#include
<QToolButton>
#include
<QToolButton>
...
@@ -89,6 +90,12 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
...
@@ -89,6 +90,12 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
findPage
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Find in text of current documentation page"
));
findPage
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Find in text of current documentation page"
));
findPage
->
setShortcut
(
QKeySequence
(
/*Qt::CTRL + */
Qt
::
Key_F3
));
findPage
->
setShortcut
(
QKeySequence
(
/*Qt::CTRL + */
Qt
::
Key_F3
));
QPushButton
*
resetZoom
=
new
QPushButton
(
this
);
resetZoom
->
setEnabled
(
false
);
resetZoom
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"zoom-fit-best"
)));
resetZoom
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Reset zoom level to 100%"
));
//resetZoom->setShortcut(QKeySequence(/*Qt::CTRL + */Qt::Key_F3));
m_textBrowser
=
new
QWebEngineView
(
this
);
m_textBrowser
=
new
QWebEngineView
(
this
);
m_displayArea
->
addWidget
(
m_textBrowser
);
m_displayArea
->
addWidget
(
m_textBrowser
);
...
@@ -107,6 +114,18 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
...
@@ -107,6 +114,18 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
m_search
->
completer
()
->
setCompletionMode
(
QCompleter
::
UnfilteredPopupCompletion
);
m_search
->
completer
()
->
setCompletionMode
(
QCompleter
::
UnfilteredPopupCompletion
);
m_search
->
completer
()
->
setCaseSensitivity
(
Qt
::
CaseInsensitive
);
m_search
->
completer
()
->
setCaseSensitivity
(
Qt
::
CaseInsensitive
);
// Add zoom in, zoom out behaviour on SHIFT++ and SHIFT--
auto
zoomIn
=
new
QShortcut
(
QKeySequence
(
Qt
::
SHIFT
+
Qt
::
Key_Plus
),
this
);
zoomIn
->
setContext
(
Qt
::
WidgetWithChildrenShortcut
);
connect
(
zoomIn
,
&
QShortcut
::
activated
,
this
,
[
=
]{
m_textBrowser
->
setZoomFactor
(
m_textBrowser
->
zoomFactor
()
+
0.1
);
});
auto
zoomOut
=
new
QShortcut
(
QKeySequence
(
Qt
::
SHIFT
+
Qt
::
Key_Minus
),
this
);
zoomOut
->
setContext
(
Qt
::
WidgetWithChildrenShortcut
);
connect
(
zoomOut
,
&
QShortcut
::
activated
,
this
,
[
=
]{
m_textBrowser
->
setZoomFactor
(
m_textBrowser
->
zoomFactor
()
-
0.1
);
});
// Add the Find in Page widget at the bottom, add all the widgets into a layout so that we can hide it
// Add the Find in Page widget at the bottom, add all the widgets into a layout so that we can hide it
QToolButton
*
hideButton
=
new
QToolButton
(
this
);
QToolButton
*
hideButton
=
new
QToolButton
(
this
);
...
@@ -175,6 +194,7 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
...
@@ -175,6 +194,7 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
layout
->
addWidget
(
m_search
,
0
,
2
);
layout
->
addWidget
(
m_search
,
0
,
2
);
layout
->
addWidget
(
seperator
,
0
,
3
);
layout
->
addWidget
(
seperator
,
0
,
3
);
layout
->
addWidget
(
findPage
,
0
,
4
);
layout
->
addWidget
(
findPage
,
0
,
4
);
layout
->
addWidget
(
resetZoom
,
0
,
5
);
layout
->
addWidget
(
m_displayArea
,
1
,
0
,
2
,
0
);
layout
->
addWidget
(
m_displayArea
,
1
,
0
,
2
,
0
);
//TODO QHelpIndexWidget::linkActivated is obsolete, use QHelpIndexWidget::documentActivated instead
//TODO QHelpIndexWidget::linkActivated is obsolete, use QHelpIndexWidget::documentActivated instead
...
@@ -194,11 +214,13 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
...
@@ -194,11 +214,13 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
{
{
findPage
->
setEnabled
(
false
);
findPage
->
setEnabled
(
false
);
home
->
setEnabled
(
false
);
home
->
setEnabled
(
false
);
resetZoom
->
setEnabled
(
false
);
}
}
else
else
{
{
findPage
->
setEnabled
(
true
);
findPage
->
setEnabled
(
true
);
home
->
setEnabled
(
true
);
home
->
setEnabled
(
true
);
resetZoom
->
setEnabled
(
true
);
}
}
});
});
...
@@ -213,6 +235,10 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
...
@@ -213,6 +235,10 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
m_findText
->
setFocus
();
m_findText
->
setFocus
();
});
});
connect
(
resetZoom
,
&
QPushButton
::
clicked
,
[
=
]{
m_textBrowser
->
setZoomFactor
(
1.0
);
});
connect
(
m_engine
->
contentWidget
(),
&
QHelpContentWidget
::
linkActivated
,
this
,
&
DocumentationPanelWidget
::
displayHelp
);
connect
(
m_engine
->
contentWidget
(),
&
QHelpContentWidget
::
linkActivated
,
this
,
&
DocumentationPanelWidget
::
displayHelp
);
connect
(
m_index
,
&
QHelpIndexWidget
::
linkActivated
,
this
,
&
DocumentationPanelWidget
::
displayHelp
);
connect
(
m_index
,
&
QHelpIndexWidget
::
linkActivated
,
this
,
&
DocumentationPanelWidget
::
displayHelp
);
connect
(
m_search
,
&
QLineEdit
::
returnPressed
,
this
,
&
DocumentationPanelWidget
::
returnPressed
);
connect
(
m_search
,
&
QLineEdit
::
returnPressed
,
this
,
&
DocumentationPanelWidget
::
returnPressed
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment