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
Utilities
Konsole
Commits
75b70fcb
Commit
75b70fcb
authored
Jun 15, 2021
by
Tomaz Canabrava
Browse files
Drag Drop files from konsole to other softwares
parent
a66d2e23
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/filterHotSpots/FileFilterHotspot.cpp
View file @
75b70fcb
...
...
@@ -18,6 +18,8 @@
#include <QMouseEvent>
#include <QKeyEvent>
#include <QRegularExpression>
#include <QDrag>
#include <QMimeData>
#include <KIO/ApplicationLauncherJob>
#include <KIO/OpenUrlJob>
...
...
@@ -28,6 +30,7 @@
#include <KMessageBox>
#include <KShell>
#include "konsoledebug.h"
#include "KonsoleSettings.h"
#include "profile/Profile.h"
...
...
@@ -300,8 +303,33 @@ void FileFilterHotSpot::mouseLeaveEvent(TerminalDisplay *td, QMouseEvent *ev)
stopThumbnailGeneration
();
}
void
Konsole
::
FileFilterHotSpot
::
keyPressEvent
(
Konsole
::
TerminalDisplay
*
td
,
QKeyEvent
*
ev
)
void
FileFilterHotSpot
::
keyPressEvent
(
Konsole
::
TerminalDisplay
*
td
,
QKeyEvent
*
ev
)
{
HotSpot
::
keyPressEvent
(
td
,
ev
);
requestThumbnail
(
ev
->
modifiers
(),
QCursor
::
pos
());
}
bool
FileFilterHotSpot
::
hasDragOperation
()
const
{
return
true
;
}
void
FileFilterHotSpot
::
startDrag
()
{
auto
*
drag
=
new
QDrag
(
this
);
auto
*
mimeData
=
new
QMimeData
();
mimeData
->
setUrls
({
QUrl
::
fromLocalFile
(
_filePath
)});
auto
lowerFilePath
=
_filePath
.
toLower
();
if
(
lowerFilePath
.
endsWith
(
QStringLiteral
(
"png"
))
||
lowerFilePath
.
endsWith
(
QStringLiteral
(
"jpg"
))
||
lowerFilePath
.
endsWith
(
QStringLiteral
(
"jpeg"
)))
{
mimeData
->
setImageData
(
QImage
(
_filePath
));
}
drag
->
setMimeData
(
mimeData
);
Qt
::
DropAction
result
=
drag
->
exec
(
Qt
::
CopyAction
);
qDebug
()
<<
"result"
<<
result
;
}
src/filterHotSpots/FileFilterHotspot.h
View file @
75b70fcb
...
...
@@ -49,6 +49,9 @@ public:
void
requestThumbnail
(
Qt
::
KeyboardModifiers
modifiers
,
const
QPoint
&
pos
);
void
thumbnailRequested
();
bool
hasDragOperation
()
const
override
;
void
startDrag
()
override
;
static
void
stopThumbnailGeneration
();
void
mouseEnterEvent
(
TerminalDisplay
*
td
,
QMouseEvent
*
ev
)
override
;
...
...
src/filterHotSpots/HotSpot.cpp
View file @
75b70fcb
...
...
@@ -185,3 +185,13 @@ void HotSpot::debug() {
qDebug
()
<<
type
();
qDebug
()
<<
_startLine
<<
_endLine
<<
_startColumn
<<
_endColumn
;
}
bool
Konsole
::
HotSpot
::
hasDragOperation
()
const
{
return
false
;
}
void
Konsole
::
HotSpot
::
startDrag
()
{
}
src/filterHotSpots/HotSpot.h
View file @
75b70fcb
...
...
@@ -92,6 +92,9 @@ public:
*/
virtual
QList
<
QAction
*>
actions
();
virtual
bool
hasDragOperation
()
const
;
virtual
void
startDrag
();
/**
* Setups a menu with actions for the hotspot.
*/
...
...
src/terminalDisplay/TerminalDisplay.cpp
View file @
75b70fcb
...
...
@@ -1165,6 +1165,11 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev)
processFilters
();
_filterChain
->
mouseMoveEvent
(
this
,
ev
,
charLine
,
charColumn
);
auto
hotSpotClick
=
_filterChain
->
hotSpotAt
(
charLine
,
charColumn
);
if
(
hotSpotClick
&&
hotSpotClick
->
hasDragOperation
()
&&
ev
->
modifiers
()
&
Qt
::
Modifier
::
ALT
)
{
hotSpotClick
->
startDrag
();
return
;
}
if
(
ev
->
button
()
==
Qt
::
LeftButton
)
{
// request the software keyboard, if any
...
...
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