Skip to content
GitLab
Menu
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
73f16fb6
Commit
73f16fb6
authored
Jul 13, 2020
by
Shubham .
Browse files
Add Find in Page text functionality
parent
9bac6817
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
73f16fb6
...
...
@@ -38,6 +38,7 @@
#include <QLineEdit>
#include <QModelIndex>
#include <QPushButton>
#include <QShortcut>
#include <QStandardPaths>
#include <QStackedWidget>
#include <QToolButton>
...
...
@@ -114,35 +115,39 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
QLabel
*
label
=
new
QLabel
(
this
);
label
->
setText
(
i18n
(
"Find:"
));
QLineEdit
*
findText
=
new
QLineEdit
(
this
);
findText
->
setPlaceholderText
(
i18nc
(
"@info:placeholder"
,
"Search..."
));
findText
->
setClearButtonEnabled
(
true
);
m_
findText
=
new
QLineEdit
(
this
);
m_
findText
->
setPlaceholderText
(
i18nc
(
"@info:placeholder"
,
"Search..."
));
m_
findText
->
setClearButtonEnabled
(
true
);
QToolButton
*
next
=
new
QToolButton
(
this
);
next
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"
arrow-down
"
)));
next
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"
go-down-search
"
)));
next
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Jump to next match"
));
QToolButton
*
previous
=
new
QToolButton
(
this
);
previous
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"
arrow-up
"
)));
previous
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"
go-up-search
"
)));
previous
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Jump to previous match"
));
QToolButton
*
matchCase
=
new
QToolButton
(
this
);
next
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"format-text-superscript"
)));
next
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Match case sensitive"
));
m_
matchCase
=
new
QToolButton
(
this
);
m_matchCase
->
setIcon
(
QIcon
::
fromTheme
(
QLatin1String
(
"format-text-superscript"
)));
m_matchCase
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Match case sensitive"
));
// Create a layout
QHBoxLayout
*
lout
=
new
QHBoxLayout
(
this
);
lout
->
addWidget
(
hideButton
);
lout
->
addWidget
(
label
);
lout
->
addWidget
(
findText
);
lout
->
addWidget
(
m_
findText
);
lout
->
addWidget
(
next
);
lout
->
addWidget
(
previous
);
lout
->
addWidget
(
matchCase
);
lout
->
addWidget
(
m_
matchCase
);
QWidget
*
findPageWidgetContainer
=
new
QWidget
(
this
);
findPageWidgetContainer
->
setLayout
(
lout
);
findPageWidgetContainer
->
hide
();
auto
closeFindBarShortcut
=
new
QShortcut
(
QKeySequence
(
Qt
::
Key_F3
),
this
);
closeFindBarShortcut
->
setContext
(
Qt
::
WidgetWithChildrenShortcut
);
connect
(
closeFindBarShortcut
,
&
QShortcut
::
activated
,
findPageWidgetContainer
,
&
QWidget
::
hide
);
////////////////////////////////////////////////////////
static
bool
qthelpRegistered
=
false
;
...
...
@@ -214,13 +219,13 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
connect
(
m_search
,
&
QLineEdit
::
returnPressed
,
this
,
&
DocumentationPanelWidget
::
returnPressed
);
connect
(
m_search
->
completer
(),
QOverload
<
const
QModelIndex
&>::
of
(
&
QCompleter
::
activated
),
this
,
&
DocumentationPanelWidget
::
returnPressed
);
connect
(
hideButton
,
&
QToolButton
::
clicked
,
this
,
[
=
]{
findPageWidgetContainer
->
hide
(
);
}
);
/*
connect(m
atchCase, &QAbstractButton::toggl
ed, this, &DocumentationPanelWidget::
emitDataChanged);
connect(
findT
ext, &Q
LineEdit::returnPress
ed, this, &DocumentationPanelWidget::search
Next
);
connect(previous, &QToolButton::clicked, this, &DocumentationPanelWidget::search
Previous
);
connect(
next, &QTool
Button::
click
ed, this, &DocumentationPanelWidget::search
Next);*/
//
connect
statements for Find in Page text widget
connect
(
hideButton
,
&
QToolButton
::
clicked
,
findPageWidgetContainer
,
&
QWidget
::
hide
);
connect
(
m_findText
,
&
QLineEdit
::
returnPressed
,
this
,
&
DocumentationPanelWidget
::
searchForward
);
connect
(
m
_findText
,
&
QLineEdit
::
textEdit
ed
,
this
,
&
DocumentationPanelWidget
::
searchForward
);
// for highlighting found string in real time
connect
(
n
ext
,
&
Q
ToolButton
::
click
ed
,
this
,
&
DocumentationPanelWidget
::
search
Forward
);
connect
(
previous
,
&
QToolButton
::
clicked
,
this
,
&
DocumentationPanelWidget
::
search
Backward
);
connect
(
m_matchCase
,
&
QAbstract
Button
::
toggl
ed
,
this
,
&
DocumentationPanelWidget
::
search
Forward
);
setSession
(
session
);
}
...
...
@@ -232,6 +237,8 @@ DocumentationPanelWidget::~DocumentationPanelWidget()
delete
m_displayArea
;
delete
m_index
;
delete
m_search
;
delete
m_findText
;
delete
m_matchCase
;
}
void
DocumentationPanelWidget
::
setSession
(
Cantor
::
Session
*
session
)
...
...
@@ -284,6 +291,18 @@ void DocumentationPanelWidget::refreshIndexWidget()
m_index
->
activateCurrentItem
();
}
void
DocumentationPanelWidget
::
searchForward
()
{
m_matchCase
->
isChecked
()
?
m_textBrowser
->
findText
(
m_findText
->
text
(),
QWebEnginePage
::
FindCaseSensitively
)
:
m_textBrowser
->
findText
(
m_findText
->
text
());
}
void
DocumentationPanelWidget
::
searchBackward
()
{
m_matchCase
->
isChecked
()
?
m_textBrowser
->
findText
(
m_findText
->
text
(),
QWebEnginePage
::
FindCaseSensitively
|
QWebEnginePage
::
FindBackward
)
:
m_textBrowser
->
findText
(
m_findText
->
text
(),
QWebEnginePage
::
FindBackward
);
}
void
DocumentationPanelWidget
::
loadDocumentation
()
{
const
QString
&
backend
=
backendName
();
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
73f16fb6
...
...
@@ -36,6 +36,7 @@ class QHelpEngine;
class
QHelpIndexWidget
;
class
QLineEdit
;
class
QStackedWidget
;
class
QToolButton
;
class
QUrl
;
class
QWebEngineView
;
...
...
@@ -66,13 +67,21 @@ class DocumentationPanelWidget : public QWidget
void
returnPressed
();
void
refreshIndexWidget
();
// SLOTS for Find in Page widget
void
searchForward
();
void
searchBackward
();
private:
QHelpEngine
*
m_engine
=
nullptr
;
QWebEngineView
*
m_textBrowser
=
nullptr
;
QStackedWidget
*
m_displayArea
=
nullptr
;
QHelpIndexWidget
*
m_index
=
nullptr
;
QLineEdit
*
m_search
=
nullptr
;
QString
m_backend
;
// member variables for find in page text widget
QLineEdit
*
m_search
=
nullptr
;
// for searching through keywords
QLineEdit
*
m_findText
=
nullptr
;
// for find in page text widget
QToolButton
*
m_matchCase
=
nullptr
;
};
// class for handling of custom url scheme ie. qthelp:// inside QWebEngineView
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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