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
Philipp Erhardt
katarakt
Commits
ce41e7a0
Commit
ce41e7a0
authored
Aug 15, 2015
by
Philipp Erhardt
Browse files
Implement copy to clipboard (Ctrl+C)
parent
bf930605
Changes
7
Hide whitespace changes
Inline
Side-by-side
doc/katarakt.txt
View file @
ce41e7a0
...
...
@@ -116,6 +116,8 @@ KEY BINDINGS
Rotate pages left/right.
*\^o*, *^i*, *Alt-Left*, *Alt-Right* ::
Move backward/forward through the jump list. Entries are added automatically when jumping.
*^c* ::
Copy the current selection to the global clipboard.
*m* ::
Manually add the current page to the jump list.
...
...
share/katarakt.ini
View file @
ce41e7a0
...
...
@@ -58,6 +58,7 @@ jump_back=Ctrl+O, Alt+Left
jump_forward
=
Ctrl+I, Alt+Right
mark_jump
=
M
toggle_invert_colors
=
I
copy_to_clipboard
=
Ctrl+C
toggle_fullscreen
=
F
close_search
=
Esc
reload
=
R
...
...
src/config.cpp
View file @
ce41e7a0
...
...
@@ -79,6 +79,7 @@ CFG::CFG() :
keys
[
"jump_forward"
]
=
QStringList
()
<<
"Ctrl+I"
<<
"Alt+Right"
;
keys
[
"mark_jump"
]
=
QStringList
()
<<
"M"
;
keys
[
"toggle_invert_colors"
]
=
QStringList
()
<<
"I"
;
keys
[
"copy_to_clipboard"
]
=
QStringList
()
<<
"Ctrl+C"
;
keys
[
"swap_selection_and_panning_buttons"
]
=
QStringList
()
<<
"V"
;
// viewer keys
keys
[
"toggle_fullscreen"
]
=
QStringList
()
<<
"F"
;
...
...
src/layout/layout.cpp
View file @
ce41e7a0
...
...
@@ -2,7 +2,6 @@
#include
<QImage>
#include
<QDesktopServices>
#include
<QUrl>
#include
<QClipboard>
#include
<QApplication>
#include
"layout.h"
#include
"../viewer.h"
...
...
@@ -215,7 +214,7 @@ bool Layout::select(int px, int py, enum Selection::Mode mode) {
return
true
;
// TODO visible? change?
}
void
Layout
::
copy_selection_text
()
{
void
Layout
::
copy_selection_text
(
QClipboard
::
Mode
mode
)
{
QString
text
;
if
(
selection
.
is_active
())
{
Cursor
from
=
selection
.
get_cursor
(
true
);
...
...
@@ -225,8 +224,7 @@ void Layout::copy_selection_text() {
}
}
QClipboard
*
clipboard
=
QApplication
::
clipboard
();
clipboard
->
setText
(
text
,
QClipboard
::
Selection
);
// TODO copy to clipboard on Ctrl+C
clipboard
->
setText
(
text
,
mode
);
}
void
Layout
::
clear_selection
()
{
...
...
src/layout/layout.h
View file @
ce41e7a0
...
...
@@ -3,6 +3,7 @@
#include
<QPainter>
#include
<QList>
#include
<QClipboard>
#include
<poppler/qt4/poppler-qt4.h>
#include
<map>
#include
"../selection.h"
...
...
@@ -50,7 +51,7 @@ public:
virtual
bool
page_visible
(
int
p
)
const
=
0
;
bool
select
(
int
px
,
int
py
,
enum
Selection
::
Mode
mode
);
void
copy_selection_text
();
void
copy_selection_text
(
QClipboard
::
Mode
mode
=
QClipboard
::
Selection
);
void
clear_selection
();
protected:
...
...
src/viewer.cpp
View file @
ce41e7a0
...
...
@@ -485,6 +485,10 @@ void Viewer::invert_colors() {
beamer
->
update
();
}
void
Viewer
::
copy_to_clipboard
()
{
canvas
->
get_layout
()
->
copy_selection_text
(
QClipboard
::
Clipboard
);
}
void
Viewer
::
toggle_toc
()
{
toc
->
setVisible
(
!
toc
->
isVisible
());
toc
->
setFocus
(
Qt
::
OtherFocusReason
);
// only works if shown
...
...
@@ -609,6 +613,7 @@ void Viewer::setup_keys(QWidget *base) {
add_action
(
base
,
"rotate_left"
,
SLOT
(
rotate_left
()),
this
);
add_action
(
base
,
"rotate_right"
,
SLOT
(
rotate_right
()),
this
);
add_action
(
base
,
"toggle_invert_colors"
,
SLOT
(
invert_colors
()),
this
);
add_action
(
base
,
"copy_to_clipboard"
,
SLOT
(
copy_to_clipboard
()),
this
);
add_action
(
base
,
"toggle_toc"
,
SLOT
(
toggle_toc
()),
this
);
}
...
...
src/viewer.h
View file @
ce41e7a0
...
...
@@ -74,6 +74,7 @@ private slots:
void
rotate_left
();
void
rotate_right
();
void
invert_colors
();
void
copy_to_clipboard
();
void
toggle_toc
();
private:
...
...
Write
Preview
Supports
Markdown
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