Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Utilities
Konsole
Commits
65cbe19c
Commit
65cbe19c
authored
Jul 19, 2020
by
Tomaz Canabrava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move hotSpot region code to HotSpot
parent
f9889eb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
26 deletions
+42
-26
src/filterHotSpots/HotSpot.cpp
src/filterHotSpots/HotSpot.cpp
+35
-0
src/filterHotSpots/HotSpot.h
src/filterHotSpots/HotSpot.h
+4
-0
src/widgets/TerminalDisplay.cpp
src/widgets/TerminalDisplay.cpp
+3
-26
No files found.
src/filterHotSpots/HotSpot.cpp
View file @
65cbe19c
...
...
@@ -72,3 +72,38 @@ void HotSpot::setType(Type type)
{
_type
=
type
;
}
QPair
<
QRegion
,
QRect
>
HotSpot
::
region
(
int
fontWidth
,
int
fontHeight
,
int
columns
,
QRect
terminalDisplayRect
)
const
{
QRegion
region
;
QRect
r
;
const
int
top
=
terminalDisplayRect
.
top
();
const
int
left
=
terminalDisplayRect
.
left
();
if
(
startLine
()
==
endLine
())
{
r
.
setCoords
(
startColumn
()
*
fontWidth
+
left
,
startLine
()
*
fontHeight
+
top
,
(
endColumn
())
*
fontWidth
+
left
-
1
,
(
endLine
()
+
1
)
*
fontHeight
+
top
-
1
);
region
|=
r
;
}
else
{
r
.
setCoords
(
startColumn
()
*
fontWidth
+
left
,
startLine
()
*
fontHeight
+
top
,
(
columns
)
*
fontWidth
+
left
-
1
,
(
startLine
()
+
1
)
*
fontHeight
+
top
-
1
);
region
|=
r
;
for
(
int
line
=
startLine
()
+
1
;
line
<
endLine
()
;
line
++
)
{
r
.
setCoords
(
0
*
fontWidth
+
left
,
line
*
fontHeight
+
top
,
(
columns
)
*
fontWidth
+
left
-
1
,
(
line
+
1
)
*
fontHeight
+
top
-
1
);
region
|=
r
;
}
r
.
setCoords
(
0
*
fontWidth
+
left
,
endLine
()
*
fontHeight
+
top
,
(
endColumn
())
*
fontWidth
+
left
-
1
,
(
endLine
()
+
1
)
*
fontHeight
+
top
-
1
);
region
|=
r
;
}
return
{
region
,
r
};
}
src/filterHotSpots/HotSpot.h
View file @
65cbe19c
...
...
@@ -24,6 +24,8 @@
#include <QObject>
#include <QList>
#include <QRegion>
#include <QRect>
class
QAction
;
class
QMenu
;
...
...
@@ -100,6 +102,8 @@ public:
* Setups a menu with actions for the hotspot.
*/
virtual
void
setupMenu
(
QMenu
*
menu
);
QPair
<
QRegion
,
QRect
>
region
(
int
fontWidth
,
int
fontHeight
,
int
columns
,
QRect
terminalDisplayRect
)
const
;
protected:
/** Sets the type of a hotspot. This should only be set once */
void
setType
(
Type
type
);
...
...
src/widgets/TerminalDisplay.cpp
View file @
65cbe19c
...
...
@@ -1437,32 +1437,9 @@ void TerminalDisplay::paintFilters(QPainter& painter)
for
(
const
auto
&
spot
:
spots
)
{
QRegion
region
;
if
(
spot
->
type
()
==
HotSpot
::
Link
||
spot
->
type
()
==
HotSpot
::
EMailAddress
||
spot
->
type
()
==
HotSpot
::
EscapedUrl
)
{
QRect
r
;
if
(
spot
->
startLine
()
==
spot
->
endLine
())
{
r
.
setCoords
(
spot
->
startColumn
()
*
_fontWidth
+
_contentRect
.
left
(),
spot
->
startLine
()
*
_fontHeight
+
_contentRect
.
top
(),
(
spot
->
endColumn
())
*
_fontWidth
+
_contentRect
.
left
()
-
1
,
(
spot
->
endLine
()
+
1
)
*
_fontHeight
+
_contentRect
.
top
()
-
1
);
region
|=
r
;
}
else
{
r
.
setCoords
(
spot
->
startColumn
()
*
_fontWidth
+
_contentRect
.
left
(),
spot
->
startLine
()
*
_fontHeight
+
_contentRect
.
top
(),
(
_columns
)
*
_fontWidth
+
_contentRect
.
left
()
-
1
,
(
spot
->
startLine
()
+
1
)
*
_fontHeight
+
_contentRect
.
top
()
-
1
);
region
|=
r
;
for
(
int
line
=
spot
->
startLine
()
+
1
;
line
<
spot
->
endLine
()
;
line
++
)
{
r
.
setCoords
(
0
*
_fontWidth
+
_contentRect
.
left
(),
line
*
_fontHeight
+
_contentRect
.
top
(),
(
_columns
)
*
_fontWidth
+
_contentRect
.
left
()
-
1
,
(
line
+
1
)
*
_fontHeight
+
_contentRect
.
top
()
-
1
);
region
|=
r
;
}
r
.
setCoords
(
0
*
_fontWidth
+
_contentRect
.
left
(),
spot
->
endLine
()
*
_fontHeight
+
_contentRect
.
top
(),
(
spot
->
endColumn
())
*
_fontWidth
+
_contentRect
.
left
()
-
1
,
(
spot
->
endLine
()
+
1
)
*
_fontHeight
+
_contentRect
.
top
()
-
1
);
region
|=
r
;
}
QPair
<
QRegion
,
QRect
>
spotRegion
=
spot
->
region
(
_fontWidth
,
_fontHeight
,
_columns
,
_contentRect
);
region
=
spotRegion
.
first
;
QRect
r
=
spotRegion
.
second
;
if
(
_showUrlHint
&&
spot
->
type
()
==
HotSpot
::
Link
)
{
if
(
urlNumber
>=
0
&&
urlNumber
<
10
)
{
...
...
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