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
3eb8317c
Commit
3eb8317c
authored
Sep 20, 2014
by
Philipp Erhardt
Browse files
Implement toggleable color inversion ('i' key)
parent
4fff3193
Changes
7
Hide whitespace changes
Inline
Side-by-side
doc/katarakt.txt
View file @
3eb8317c
...
...
@@ -91,6 +91,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
*i* ::
Toggle between normal and inverted color rendering
VARIABLES
---------
...
...
share/katarakt.ini
View file @
3eb8317c
...
...
@@ -49,6 +49,7 @@ rotate_left=,
rotate_right
=
.
jump_back
=
Ctrl+O, Alt+Left
jump_forward
=
Ctrl+I, Alt+Right
toggle_invert_colors
=
I
toggle_fullscreen
=
F
close_search
=
Esc
reload
=
R
...
...
src/canvas.cpp
View file @
3eb8317c
...
...
@@ -84,6 +84,7 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
add_action
(
"rotate_right"
,
SLOT
(
rotate_right
()));
add_action
(
"jump_back"
,
SLOT
(
jump_back
()));
add_action
(
"jump_forward"
,
SLOT
(
jump_forward
()));
add_action
(
"toggle_invert_colors"
,
SLOT
(
invert_colors
()));
// prints the string representation of a key
// cerr << QKeySequence(Qt::Key_Equal).toString().toUtf8().constData() << endl;
...
...
@@ -169,6 +170,11 @@ void Canvas::jump_forward() {
}
}
void
Canvas
::
invert_colors
()
{
viewer
->
get_res
()
->
invert_colors
();
update
();
}
Layout
*
Canvas
::
get_layout
()
const
{
return
cur_layout
;
}
...
...
src/canvas.h
View file @
3eb8317c
...
...
@@ -81,6 +81,7 @@ private slots:
void
rotate_right
();
void
jump_back
();
void
jump_forward
();
void
invert_colors
();
private:
void
add_action
(
const
char
*
action
,
const
char
*
slot
);
...
...
src/config.cpp
View file @
3eb8317c
...
...
@@ -68,6 +68,7 @@ CFG::CFG() :
keys
[
"rotate_right"
]
=
QStringList
()
<<
"."
;
keys
[
"jump_back"
]
=
QStringList
()
<<
"Ctrl+O"
<<
"Alt+Left"
;
keys
[
"jump_forward"
]
=
QStringList
()
<<
"Ctrl+I"
<<
"Alt+Right"
;
keys
[
"toggle_invert_colors"
]
=
QStringList
()
<<
"i"
;
// viewer keys
keys
[
"toggle_fullscreen"
]
=
QStringList
()
<<
"F"
;
keys
[
"close_search"
]
=
QStringList
()
<<
"Esc"
;
...
...
src/resourcemanager.cpp
View file @
3eb8317c
...
...
@@ -10,7 +10,8 @@ using namespace std;
//==[ Katarakt Page ]==========================================================
KPage
::
KPage
()
:
links
(
NULL
)
{
links
(
NULL
),
inverted_colors
(
false
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
status
[
i
]
=
0
;
rotation
[
i
]
=
0
;
...
...
@@ -138,11 +139,25 @@ void Worker::run() {
continue
;
}
// invert to current color setting
if
(
res
->
inverted_colors
)
{
img
.
invertPixels
();
}
// put page
res
->
k_page
[
page
].
mutex
.
lock
();
if
(
!
res
->
k_page
[
page
].
img
[
index
].
isNull
())
{
res
->
k_page
[
page
].
img
[
index
]
=
QImage
();
// assign null image
}
// adjust all available images to current color setting
if
(
res
->
k_page
[
page
].
inverted_colors
!=
res
->
inverted_colors
)
{
res
->
k_page
[
page
].
inverted_colors
=
res
->
inverted_colors
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
res
->
k_page
[
page
].
img
[
i
].
invertPixels
();
}
res
->
k_page
[
page
].
thumbnail
.
invertPixels
();
}
res
->
k_page
[
page
].
img
[
index
]
=
img
;
res
->
k_page
[
page
].
status
[
index
]
=
width
;
res
->
k_page
[
page
].
rotation
[
index
]
=
rotation
;
...
...
@@ -182,7 +197,8 @@ void Worker::run() {
ResourceManager
::
ResourceManager
(
QString
file
)
:
doc
(
NULL
),
center_page
(
0
),
rotation
(
0
)
{
rotation
(
0
),
inverted_colors
(
false
)
{
// load config options
CFG
*
config
=
CFG
::
get_instance
();
smooth_downscaling
=
config
->
get_value
(
"smooth_downscaling"
).
toBool
();
...
...
@@ -305,6 +321,13 @@ const KPage *ResourceManager::get_page(int page, int width, int index) {
k_page
[
page
].
rotation
[
index
]
!=
rotation
)
{
enqueue
(
page
,
width
,
index
);
}
if
(
inverted_colors
!=
k_page
[
page
].
inverted_colors
)
{
k_page
[
page
].
inverted_colors
=
inverted_colors
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
k_page
[
page
].
img
[
i
].
invertPixels
();
}
k_page
[
page
].
thumbnail
.
invertPixels
();
}
return
&
k_page
[
page
];
}
...
...
@@ -334,6 +357,7 @@ void ResourceManager::collect_garbage(int keep_min, int keep_max) {
// find the index of the rendered image
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
if
(
!
k_page
[
page
].
img
[
i
].
isNull
())
{
// k_page[page].inverted_colors = inverted_colors;
// scale
k_page
[
page
].
thumbnail
=
k_page
[
page
].
img
[
i
].
scaled
(
QSize
(
thumbnail_size
,
thumbnail_size
),
...
...
@@ -391,6 +415,10 @@ void ResourceManager::unlock_page(int page) const {
k_page
[
page
].
mutex
.
unlock
();
}
void
ResourceManager
::
invert_colors
()
{
inverted_colors
=
!
inverted_colors
;
}
void
ResourceManager
::
enqueue
(
int
page
,
int
width
,
int
index
)
{
requestMutex
.
lock
();
map
<
int
,
pair
<
int
,
int
>
>::
iterator
it
=
requests
.
find
(
page
);
...
...
src/resourcemanager.h
View file @
3eb8317c
...
...
@@ -36,6 +36,7 @@ private:
QMutex
mutex
;
int
status
[
3
];
char
rotation
[
3
];
bool
inverted_colors
;
// img[]s and thumb must be consistent
friend
class
Worker
;
friend
class
ResourceManager
;
...
...
@@ -86,6 +87,7 @@ public:
int
get_rotation
()
const
;
void
rotate
(
int
value
,
bool
relative
=
true
);
void
unlock_page
(
int
page
)
const
;
void
invert_colors
();
void
collect_garbage
(
int
keep_min
,
int
keep_max
);
...
...
@@ -123,6 +125,7 @@ private:
// config options
bool
smooth_downscaling
;
int
thumbnail_size
;
bool
inverted_colors
;
};
#endif
...
...
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