Commit 80fe9db9 authored by Philipp Erhardt's avatar Philipp Erhardt
Browse files

Improve config, update man page

parent 39a25a24
......@@ -16,9 +16,9 @@ DESCRIPTION
-----------
It's a PDF viewer. It views PDFs.
There are currently three layouts. The 'presentation layout' is very simple and
only supports scrolling on a per page basis. As the name suggests the current
page is displayed in the center and zoomed to fit the window. It is active by
There are currently three layouts. The 'single layout' is very simple and only
supports scrolling on a per page basis. As the name suggests the current page
is displayed in the center and zoomed to fit the window. It is active by
default.
The 'grid layout' is much more advanced and offers continuous (smooth, per
......@@ -39,15 +39,17 @@ OPTIONS
Start on page 'NUM'.
*-f*, *--fullscreen* ::
Start in fullscreen mode.
*-q*, *--quit* ::
Quit on initialization failure.
*-h*, *--help* ::
Print help and exit.
*--write-defaults* 'FILE'::
*-q*, *--quit* 'true'|'false'::
If true, quit on initialization failure. If false, show the window even if
an error occured. Overrides the config option *quit_on_init_fail*.
*-s*, *--single-instance* 'true'|'false'::
If true, prevents opening the same document twice and focuses the existing
instance. Overrides the config option *single_instance_per_file*.
*--write-default-config* 'FILE'::
Write the built-in default configuration to 'FILE' and exit. Hint: on unix
systems, you can use '--write-defaults /dev/stdout' to print the defaults.
*--single-instance* 'true'|'false'::
Sets *single_instance_per_file* for the present katarakt instance only.
*-h*, *--help* ::
Print help and exit.
CONFIGURATION
-------------
......@@ -55,18 +57,19 @@ Variables and key bindings can be changed by modifying the katarakt.ini file.
By default it is read from '$XDG_CONFIG_HOME'.
Variables must be listed under the section "[Settings]", keys under section
"[Keys]". For a list of all variables with a short explanation see below.
"[Keys]". Settings that are not present in the config file use the built-in
default. For a list of all variables with a short explanation see below.
KEY BINDINGS
------------
*q* ::
Quit *katarakt*.
*1* ::
Switch to 'presentation layout'. Views a single page at a time, scaled to
fit the screen.
Switch to 'single layout'. Views a single page at a time, scaled to fit the
screen.
*2* ::
Switch to 'grid layout'. Views pages in a continuous fashion, scaled to fit
the width. Supports columns.
the window width. Supports zooming and multiple columns.
*3* ::
Switch to 'presenter layout'. Views the current page and a smaller preview
of the next page. Also, opens a second window that shows only the current
......@@ -77,7 +80,8 @@ KEY BINDINGS
*\^u*, *^d* ::
Scroll up/down half the screen.
*BackSpace*, *Space*, *\^b*, *^f* ::
Scroll up/down the screen. By default scrolls 90% to create an overlapping region.
Scroll up/down the screen. By default scrolls 90% to create an overlapping
region.
*PgUp*, *PgDown* ::
Scroll up/down one page. Kind of swaps the pages in place.
......@@ -85,28 +89,6 @@ KEY BINDINGS
Go to the first/last page.
*^g* ::
Show 'goto page' bar.
*f* ::
Toggle fullscreen.
*t* ::
Toggle the page number display in the bottom right corner.
*r* ::
Reload the document. This can also be achieved by sending SIGUSR1 to the
process. *katarakt* reloads automatically if the opened file has changed.
*o* ::
Open a different document; shows a file dialog.
*s* ::
Show a file dialog to save the current document.
*F9* ::
Toggle the table of contents.
*-*, *+*, *=* ::
Adjust zoom level ('grid layout' only).
*z* ::
Reset zoom level to default, i.e. fit width ('grid layout' only).
*[*, *]* ::
Adjust column count ('grid layout' only).
*{*, *}* ::
Adjust the column the first page will be displayed in. Useful for reading
in a book layout with a cover page ('grid layout' only).
*/* ::
Show the search bar. Hitting *Esc* will hide the results, searching for an
empty string will clear them. If the search term contains an uppercase
......@@ -117,70 +99,96 @@ KEY BINDINGS
Focus next/previous search hit.
*\^n*, *^N* ::
Focus next/previous search hit that is currently not visible.
*,*, *.* ::
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.
*\^o*, *^i*, *Alt-Left*, *Alt-Right* ::
Move backward/forward through the jump list. Entries are added
automatically when jumping.
*m* ::
Manually add the current page to the jump list.
*-*, *+*, *=* ::
Adjust zoom level ('grid layout' only).
*z* ::
Reset zoom level to default, i.e. fit width ('grid layout' only).
*[*, *]* ::
Adjust column count ('grid layout' only).
*{*, *}* ::
Adjust the column the first page will be displayed in. Useful for reading
in a book layout with a cover page ('grid layout' only).
*,*, *.* ::
Rotate pages left/right.
*t* ::
Toggle the page number display in the bottom right corner.
*i* ::
Toggle between normal and inverted color rendering.
*^c* ::
Copy the current selection to the global clipboard.
*v* ::
Swap the mouse buttons for selection and panning.
Swap the mouse buttons for selection and panning. The the left mouse
button's current operation is indicated by the mouse cursor.
*f* ::
Toggle fullscreen.
*r* ::
Reload the document. This can also be achieved by sending SIGUSR1 to the
process. *katarakt* reloads automatically if the opened file has changed.
*o* ::
Open a different document; shows a file dialog.
*s* ::
Show a file dialog to save the current document.
*F9* ::
Toggle the table of contents.
VARIABLES
---------
'string' *default_layout* ::
single: The layout on startup. Possible values: 'single', 'grid',
'presenter'.
'string' *background_color* ::
0xDF000000: Background color in ARGB Format. Alpha only works when using a compositor.
0xDF202020: Background color in ARGB Format. Alpha only works when using a
compositor.
'string' *background_color_fullscreen* ::
0xFF000000: Fullscreen background color in ARGB Format.
'string' *default_layout* ::
presentation: The layout on startup. Possible values: 'presentation', 'grid', 'presenter'.
'int' *mouse_wheel_factor* ::
120: QT delta for turning the mouse wheel 1 click.
'string' *unrendered_page_color* ::
0x80808080: Color that gets drawn instead of a page that hasn't been
rendered yet.
'int' *click_link_button* ::
1: The mouse button used for clicking links. Buttons 1-5 are supported.
'int' *drag_view_button* ::
2: The mouse button used for scrolling the view.
Double-clicking this button centers the view around the location of the
click. This is especially useful when using many columns to get an
overview. Resets the column count to 1.
'int' *select_text_button* ::
1: The mouse button used for text selection. Double- and triple-clicking
are supported to select with word/line granularity.
'int' *smooth_scroll_delta* ::
30: Pixel offset when moving around.
'float' *screen_scroll_factor* ::
0.9: Factor for scrolling the screen. Should be \<= 1 to create an overlapping region.
'string' *page_overlay_text* ::
Page %1/%2: The text in the bottom right corner.
0.9: Factor for scrolling the screen. Should be \<= 1 to create an
overlapping region.
'float' *jump_padding* ::
0.2: Distance from the border of the screen to keep for jump targets, e.g.
search hits. Moves the view so that search hits are centered more.
'int' *rect_margin* ::
2: Number of pixels search rects are expanded by.
'int' *useless_gap* ::
2: Gap between two pages in 'grid layout' in pixels.
'int' *min_page_width* ::
150: Pages can not be smaller than this.
'int' *min_zoom* ::
-14: Smallest zoom value.
'int' *max_zoom* ::
30: Biggest zoom value.
'float' *zoom_factor* ::
0.05: Influences the number of steps between min and max.
'int' *prefetch_count* ::
3: Number of pages exceeding the currently visible ones to render, back- and forwards respectively.
'float' *search_padding* ::
0.2: Factor of the area on the screen to display search hits in. Moves search hits towards the center.
'bool' *smooth_downscaling* ::
true: Enables the higher quality downsampling filter.
'int' *thumbnail_size* ::
32: One dimension of square thumbnails saved at run-time for every page that was once rendered.
'int' *rect_expansion* ::
2: Number of pixels search rects are expanded by.
'int' *min_page_width* ::
50: Pages can not be smaller than this.
'bool' *quit_on_init_fail* ::
false: Quit katarakt if the document fails to open.
false: If true, quit katarakt if the document fails to open.
'bool' *single_instance_per_file* ::
If set and katarakt is called with a file that is already shown in another
katarakt instance, then the other katarakt window is activated instead.
'string' *icon_theme* ::
The name of your icon theme. Fill in if auto detection fails.
false: If set and katarakt is called with a file that is already shown in
another katarakt instance, then the other katarakt window is activated
instead.
'string' *stylesheet* ::
See link:http://doc.qt.io/qt-4.8/stylesheet.html[]. It can be overridden
via Qt's *-stylesheet* command line option. The following example changes
......@@ -196,15 +204,22 @@ GotoLine {
border-right: 1px solid black;
}"
----
'string' *page_overlay_text* ::
Page %1/%2: The text in the bottom right corner.
'string' *icon_theme* ::
The name of your icon theme. Fill in if auto detection fails.
'int' *click_link_button* ::
1: The mouse button used for clicking links. Buttons 1-5 are supported.
'int' *drag_view_button* ::
2: The mouse button used for scrolling the view. Double-clicking this
button centers the view around the location of the click.
'int' *select_text_button* ::
1: The mouse button used for text selection. Double- and triple-clicking
are supported to select with word/line granularity.
'int' *prefetch_count* ::
4: Number of pages exceeding the currently visible ones to render, back-
and forwards respectively.
'int' *mouse_wheel_factor* ::
120: QT delta for turning the mouse wheel 1 click. Shouldn't need to be
touched.
'bool' *thumbnail_filter* ::
true: Enables the higher quality downsampling filter for thumbnails.
'int' *thumbnail_size* ::
32: One dimension of square thumbnails saved at run-time for every page
that was once rendered.
COMMUNITY
---------
......
......@@ -12,13 +12,13 @@ DEFINES += "POPPLER_VERSION_MICRO=`pkg-config --modversion poppler-qt4 | cut -d
QMAKE_CXXFLAGS_DEBUG += -DDEBUG
# Input
HEADERS += src/layout/layout.h src/layout/presentationlayout.h src/layout/gridlayout.h src/layout/presenterlayout.h \
HEADERS += src/layout/layout.h src/layout/singlelayout.h src/layout/gridlayout.h src/layout/presenterlayout.h \
src/viewer.h src/canvas.h src/resourcemanager.h src/grid.h src/search.h src/gotoline.h src/config.h \
src/download.h src/util.h src/kpage.h src/worker.h src/beamerwindow.h src/toc.h src/splitter.h src/selection.h \
src/dbus/source_correlate.h src/dbus/dbus.h
SOURCES += src/main.cpp \
src/layout/layout.cpp src/layout/presentationlayout.cpp src/layout/gridlayout.cpp src/layout/presenterlayout.cpp \
src/layout/layout.cpp src/layout/singlelayout.cpp src/layout/gridlayout.cpp src/layout/presenterlayout.cpp \
src/viewer.cpp src/canvas.cpp src/resourcemanager.cpp src/grid.cpp src/search.cpp src/gotoline.cpp src/config.cpp \
src/download.cpp src/util.cpp src/kpage.cpp src/worker.cpp src/beamerwindow.cpp src/toc.cpp src/splitter.cpp \
src/selection.cpp src/dbus/source_correlate.cpp src/dbus/dbus.cpp
......
[Settings]
background_color=0xDF000000
default_layout=single
background_color=0xDF202020
background_color_fullscreen=0xFF000000
default_layout=presentation
mouse_wheel_factor=120
unrendered_page_color=0x80808080
click_link_button=1
drag_view_button=2
select_text_button=1
smooth_scroll_delta=30
screen_scroll_factor=0.9
page_overlay_text=Page %1/%2
jump_padding=0.2
rect_margin=2
useless_gap=2
min_page_width=150
min_zoom=-14
max_zoom=30
zoom_factor=0.05
prefetch_count=3
search_padding=0.2
smooth_downscaling=true
thumbnail_size=32
rect_expansion=2
min_page_width=50
presenter_slide_ratio=0.67
quit_on_init_fail=false
icon_theme=
stylesheet=
click_link_button=1
drag_view_button=2
select_text_button=1
single_instance_per_file=false
stylesheet=
page_overlay_text=Page %1/%2
icon_theme=
prefetch_count=4
mouse_wheel_factor=120
thumbnail_filter=true
thumbnail_size=32
[Keys]
set_presentation_layout=1
set_grid_layout=2
set_presenter_layout=3
page_up=PgUp
page_down=PgDown
page_first=Home, G
page_last=End, Shift+G
top=Home, G
bottom=End, Shift+G
goto_page=Ctrl+G
half_screen_up=Ctrl+U
half_screen_down=Ctrl+D
screen_up=Backspace, Ctrl+B
......@@ -40,33 +40,35 @@ smooth_up=Up, K
smooth_down=Down, J
smooth_left=Left, H
smooth_right=Right, L
zoom_in="=", +
zoom_out=-
reset_zoom=Z
columns_inc=]
columns_dec=[
offset_inc=}
offset_dec={
toggle_overlay=T
quit=Q, "W,E,E,E"
search=/
search_backward=?
next_hit=N
previous_hit=Shift+N
next_invisible_hit=Ctrl+N
previous_invisible_hit=Ctrl+Shift+N
focus_goto=Ctrl+G
rotate_left=","
rotate_right=.
jump_back=Ctrl+O, Alt+Left
jump_forward=Ctrl+I, Alt+Right
mark_jump=M
toggle_invert_colors=I
set_single_layout=1
set_grid_layout=2
set_presenter_layout=3
zoom_in="=", +
zoom_out=-
reset_zoom=Z
increase_columns=]
decrease_columns=[
increase_offset=}
decrease_offset={
rotate_left=","
rotate_right=.
toggle_overlay=T
quit=Q, "W,E,E,E"
close_search=Esc
invert_colors=I
copy_to_clipboard=Ctrl+C
swap_selection_and_panning_buttons=V
toggle_fullscreen=F
close_search=Esc
reload=R
open=O
save=S
toggle_toc=F9
swap_selection_and_panning_buttons=V
......@@ -3,7 +3,7 @@
#include "canvas.h"
#include "config.h"
#include "resourcemanager.h"
#include "layout/presentationlayout.h"
#include "layout/singlelayout.h"
#include <QResizeEvent>
#include <QApplication>
#include <iostream>
......@@ -17,12 +17,12 @@ BeamerWindow::BeamerWindow(Viewer *v, QWidget *parent) :
valid(false) {
setFocusPolicy(Qt::StrongFocus);
layout = new PresentationLayout(viewer, 0);
layout = new SingleLayout(viewer, 0);
CFG *config = CFG::get_instance();
mouse_wheel_factor = config->get_value("mouse_wheel_factor").toInt();
mouse_wheel_factor = config->get_value("Settings/mouse_wheel_factor").toInt();
switch (config->get_value("click_link_button").toInt()) {
switch (config->get_value("Settings/click_link_button").toInt()) {
case 1: click_link_button = Qt::LeftButton; break;
case 2: click_link_button = Qt::RightButton; break;
case 3: click_link_button = Qt::MidButton; break;
......
......@@ -11,7 +11,7 @@
#include "canvas.h"
#include "viewer.h"
#include "layout/layout.h"
#include "layout/presentationlayout.h"
#include "layout/singlelayout.h"
#include "layout/gridlayout.h"
#include "layout/presenterlayout.h"
#include "resourcemanager.h"
......@@ -36,7 +36,7 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
{
bool ok;
unsigned int color = config->get_value("background_color").toString().toUInt(&ok, 16);
unsigned int color = config->get_value("Settings/background_color").toString().toUInt(&ok, 16);
if (ok) {
background.setRgba(color);
} else {
......@@ -45,16 +45,16 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
}
{
bool ok;
unsigned int color = config->get_value("background_color_fullscreen").toString().toUInt(&ok, 16);
unsigned int color = config->get_value("Settings/background_color_fullscreen").toString().toUInt(&ok, 16);
if (ok) {
background_fullscreen.setRgba(color);
} else {
cerr << "failed to parse background_color_fullscreen" << endl;
}
}
mouse_wheel_factor = config->get_value("mouse_wheel_factor").toInt();
mouse_wheel_factor = config->get_value("Settings/mouse_wheel_factor").toInt();
switch (config->get_value("click_link_button").toInt()) {
switch (config->get_value("Settings/click_link_button").toInt()) {
case 1: click_link_button = Qt::LeftButton; break;
case 2: click_link_button = Qt::RightButton; break;
case 3: click_link_button = Qt::MidButton; break;
......@@ -63,7 +63,7 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
default: click_link_button = Qt::NoButton;
}
switch (config->get_value("drag_view_button").toInt()) {
switch (config->get_value("Settings/drag_view_button").toInt()) {
case 1: drag_view_button = Qt::LeftButton; break;
case 2: drag_view_button = Qt::RightButton; break;
case 3: drag_view_button = Qt::MidButton; break;
......@@ -72,7 +72,7 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
default: drag_view_button = Qt::NoButton;
}
switch (config->get_value("select_text_button").toInt()) {
switch (config->get_value("Settings/select_text_button").toInt()) {
case 1: select_text_button = Qt::LeftButton; break;
case 2: select_text_button = Qt::RightButton; break;
case 3: select_text_button = Qt::MidButton; break;
......@@ -81,22 +81,17 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
default: select_text_button = Qt::NoButton;
}
presentation_layout = new PresentationLayout(viewer, 0);
single_layout = new SingleLayout(viewer, 0);
grid_layout = new GridLayout(viewer, 0);
presenter_layout = new PresenterLayout(viewer, 1); // TODO add config string
presenter_layout = new PresenterLayout(viewer, 1);
QString default_layout = config->get_value("default_layout").toString();
QString default_layout = config->get_value("Settings/default_layout").toString();
if (default_layout == "grid") {
cur_layout = grid_layout;
} else if (default_layout == "presenter") {
cur_layout = presenter_layout;
} else { // "presentation" and everything else
cur_layout = presentation_layout;
}
// apply start option
if (viewer->get_res()->is_valid()) {
cur_layout->scroll_page(config->get_tmp_value("start_page").toInt(), false);
} else { // "single" and everything else
cur_layout = single_layout;
}
setup_keys(this);
......@@ -135,7 +130,7 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
Canvas::~Canvas() {
delete page_overlay;
delete goto_line;
delete presentation_layout;
delete single_layout;
delete grid_layout;
delete presenter_layout;
}
......@@ -151,12 +146,14 @@ void Canvas::reload(bool clamp) {
}
void Canvas::setup_keys(QWidget *base) {
add_action(base, "set_presentation_layout", SLOT(set_presentation_layout()), this);
add_action(base, "set_grid_layout", SLOT(set_grid_layout()), this);
add_action(base, "set_presenter_layout", SLOT(set_presenter_layout()), this);
add_action(base, "toggle_overlay", SLOT(toggle_overlay()), this);
add_action(base, "focus_goto", SLOT(focus_goto()), this);
add_action(base, "swap_selection_and_panning_buttons", SLOT(swap_selection_and_panning_buttons()), this);
add_action(base, "Keys/goto_page", SLOT(focus_goto()), this);
add_action(base, "Keys/set_single_layout", SLOT(set_single_layout()), this);
add_action(base, "Keys/set_grid_layout", SLOT(set_grid_layout()), this);
add_action(base, "Keys/set_presenter_layout", SLOT(set_presenter_layout()), this);
add_action(base, "Keys/toggle_overlay", SLOT(toggle_overlay()), this);
add_action(base, "Keys/swap_selection_and_panning_buttons", SLOT(swap_selection_and_panning_buttons()), this);
}
Layout *Canvas::get_layout() const {
......@@ -164,7 +161,7 @@ Layout *Canvas::get_layout() const {
}
void Canvas::update_page_overlay() {
QString overlay_text = CFG::get_instance()->get_value("page_overlay_text").toString()
QString overlay_text = CFG::get_instance()->get_value("Settings/page_overlay_text").toString()
.arg(cur_layout->get_page() + 1)
.arg(viewer->get_res()->get_page_count());
page_overlay->setText(overlay_text);
......@@ -290,7 +287,7 @@ void Canvas::wheelEvent(QWheelEvent *event) {
}
void Canvas::mouseDoubleClickEvent(QMouseEvent * event) {
if (click_link_button != Qt::NoButton && event->button() == drag_view_button) {
if (drag_view_button != Qt::NoButton && event->button() == drag_view_button) {
cur_layout->goto_page_at(event->x(), event->y());
}
if (select_text_button != Qt::NoButton && event->button() == select_text_button) {
......@@ -309,9 +306,9 @@ void Canvas::resizeEvent(QResizeEvent *event) {
}
// primitive actions
void Canvas::set_presentation_layout() {
presentation_layout->activate(cur_layout);
cur_layout = presentation_layout;
void Canvas::set_single_layout() {
single_layout->activate(cur_layout);
cur_layout = single_layout;
update();
viewer->get_beamer()->hide();
viewer->show_progress(false);
......
......@@ -13,7 +13,7 @@
class Viewer;
class Layout;
class PresentationLayout;
class SingleLayout;
class GridLayout;
class PresenterLayout;
class GotoLine;
......@@ -58,7 +58,7 @@ private slots:
void goto_page();
// primitive actions
void set_presentation_layout();
void set_single_layout();
void set_grid_layout();
void set_presenter_layout();
......@@ -74,7 +74,7 @@ private:
Viewer *viewer;
Layout *cur_layout;
PresentationLayout *presentation_layout;
SingleLayout *single_layout;
GridLayout *grid_layout;
PresenterLayout *presenter_layout;
......
#include "config.h"
#include <QHashIterator>
#include <QVectorIterator>
#include <iostream>
using namespace std;
CFG::CFG() :
......@@ -14,94 +18,90 @@ CFG::CFG(const char* file) :
}
void CFG::init_defaults() {
settings.beginGroup("Settings");
// canvas options
defaults["background_color"] = "0xDF000000";
defaults["background_color_fullscreen"] = "0xFF000000";
defaults["default_layout"] = "presentation";
defaults["mouse_wheel_factor"] = 120; // (qt-)delta for turning the mouse wheel 1 click
defaults["smooth_scroll_delta"] = 30; // pixel scroll offset
defaults["screen_scroll_factor"] = 0.9; // creates overlap for scrolling 1 screen down, should be <= 1
defaults["page_overlay_text"] = "Page %1/%2";
// layout options
defaults["useless_gap"] = 2;
defaults["min_page_width"] = 150;
defaults["min_zoom"] = -14;
defaults["max_zoom"] = 30;
defaults["zoom_factor"] = 0.05;
defaults["prefetch_count"] = 3;
defaults["search_padding"] = 0.2; // must be <= 0.5
// resourcemanager options
defaults["smooth_downscaling"] = true; // filter when creating thumbnail image
defaults["thumbnail_size"] = 32;
// search options
defaults["rect_expansion"] = 2;
// viewer options
defaults["quit_on_init_fail"] = false;
defaults["single_instance_per_file"] = false;
defaults["icon_theme"] = "";
defaults["stylesheet"] = "";
// mouse buttons
defaults["click_link_button"] = 1;
defaults["drag_view_button"] = 2;
defaults["select_text_button"] = 1;
settings.endGroup();
// settings
// canvas
vd.push_back("Settings/default_layout"); defaults[vd.back()] = "single";
vd.push_back("Settings/background_color"); defaults[vd.back()] = "0xDF202020";
vd.push_back("Settings/background_color_fullscreen"); defaults[vd.back()] = "0xFF000000";
vd.push_back("Settings/unren