Skip to content

Commit d8e5827

Browse files
committed
Allow to set the size of thumbnails
The command line arguments are compatible with dragon. Note that for zsh completion of the size number, we use the "(single unquoted space)" action, which is a dummy action (it doesn't make any sense to autocomplete numbers). This implements one part of #10
1 parent f2c8e02 commit d8e5827

File tree

7 files changed

+26
-5
lines changed

7 files changed

+26
-5
lines changed

assets/completions/bash-completion/completions/blobdrop

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _blobdrop() {
1111
-p --persistent
1212
-P --prefix
1313
-R --remote
14+
-s --thumb-size
1415
-t --ontop
1516
-x --auto-quit
1617
"

assets/completions/fish/vendor_completions.d/blobdrop.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ complete -c blobdrop -s '-k' -l 'keep' -d 'keep dropped files'
88
complete -c blobdrop -s '-p' -l 'persistent' -d 'disable autohiding during drag'
99
complete -c blobdrop -s '-P' -l 'prefix' -d 'remote prefix' -xa "(__fish_print_hostnames)"
1010
complete -c blobdrop -s '-R' -l 'remote' -d 'enable ssh remote transparency'
11+
complete -c blobdrop -s '-s' -l 'thumb-size' -d 'set thumbnail size' -x
1112
complete -c blobdrop -s '-t' -l 'ontop' -d 'keep window on top'
1213
complete -c blobdrop -s '-x' -l 'auto-quit' -d 'autoquit behaviour' -xa "never\t'do not autoquit' first\t'after first drag' all\t'after all items have been dragged'"

assets/completions/zsh/site-functions/_blobdrop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#compdef blobdrop
22

33
_blobdrop() {
4-
_arguments {-h,--help}'[show help]' {-v,--version}'[show version]' {-b,--frameless}'[show frameless window]' {-c,--cursor}'[spawn window at mouse cursor]' {-f,--frontend}'[selects frontend]:arg:((auto\:"automatic" gui\:"show window" immediate\:"drag immediately" notify\:"drag from notification" clipboard\:"copy to clipboard" stdout\:"print OSC8 link"))' {-i,--intercept}'[intercept another DnD]' {-k,--keep}'[keep dropped files]' {-p,--persistent}'[disable autohiding during drag]' {-P,--prefix}'[specify remote prefix]:arg:_hosts' {-R,--remote}'[enable ssh network transparency]' {-t,--ontop}'[keep window on top]' {-x,--auto-quit}'[autoquit behaviour]:num:((never\:"do not autoquit" first\:"after first drag" all\:"after all items have been dragged"))' '*: arg:_files'
4+
_arguments {-h,--help}'[show help]' {-v,--version}'[show version]' {-b,--frameless}'[show frameless window]' {-c,--cursor}'[spawn window at mouse cursor]' {-f,--frontend}'[selects frontend]:arg:((auto\:"automatic" gui\:"show window" immediate\:"drag immediately" notify\:"drag from notification" clipboard\:"copy to clipboard" stdout\:"print OSC8 link"))' {-i,--intercept}'[intercept another DnD]' {-k,--keep}'[keep dropped files]' {-p,--persistent}'[disable autohiding during drag]' {-P,--prefix}'[specify remote prefix]:arg:_hosts' {-R,--remote}'[enable ssh network transparency]' {-s,--thumb-size}'[thumbnail size]:num: ' {-t,--ontop}'[keep window on top]' {-x,--auto-quit}'[autoquit behaviour]:arg:((never\:"do not autoquit" first\:"after first drag" all\:"after all items have been dragged"))' '*: arg:_files'
55
return 0
66
}
77

doc/man/man1/blobdrop.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ blobdrop \- Quickly drag and drop files from the terminal
88
[\-hvbcikpRt]
99
[\-f \fIOPT\fP]
1010
[\-P \fIOPT\fP]
11+
[\-s \fIOPT\fP]
1112
[\-x \fIOPT\fP]
1213
.I FILES
1314

@@ -63,6 +64,9 @@ Enable ssh remote transparency. This sets the URI scheme to
6364
.B sftp://
6465
and the username, hostname and port based on heuristics, thus making it possible to drag and drop across a forwarded X11 session from a remote host. DnD requires trusted X11 forwarding (ssh -Y). In case of the heuristic failing, the \-\-prefix option can be used to manually set a value.
6566
.TP
67+
.B \-s, \-\-thumb\-size \fIOPT\fP
68+
Sets the size of the thumbnail for listed images. The default size is 64.
69+
.TP
6670
.B \-t, \-\-ontop
6771
Keep the window on top of other windows.
6872
.TP

src/getopts.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ bool parse(const QStringList &args) {
5151
QCommandLineOption remote_opt(QStringList() << "R"
5252
<< "remote",
5353
"Enable ssh remote transparency.");
54+
QCommandLineOption thumbnailsize_opt(QStringList() << "s"
55+
<< "thumb-size",
56+
"Set thumbnail size (default 64)",
57+
"size");
5458
QCommandLineOption ontop_opt(QStringList() << "t"
5559
<< "ontop",
5660
"Keep the window on top of other windows.");
@@ -59,7 +63,7 @@ bool parse(const QStringList &args) {
5963
"The amount of drags after which the program should automatically close. Must be one of:" + QString::fromStdString(auto_quit_descr) + " (all is default)",
6064
"behaviour");
6165

62-
p.addOptions({frameless_opt, cursor_opt, frontend_opt, intercept_opt, keep_opt, persistent_opt, prefix_opt, remote_opt, ontop_opt, auto_quit_opt});
66+
p.addOptions({frameless_opt, cursor_opt, frontend_opt, intercept_opt, keep_opt, persistent_opt, prefix_opt, remote_opt, thumbnailsize_opt, ontop_opt, auto_quit_opt});
6367
p.process(args);
6468

6569
if (p.isSet(auto_quit_opt)) {
@@ -72,6 +76,15 @@ bool parse(const QStringList &args) {
7276
Settings::get()->auto_quit_behavior = static_cast<Settings::AutoQuitBehavior>(choice);
7377
}
7478
Settings::get()->remote = p.isSet(remote_opt);
79+
if (p.isSet(thumbnailsize_opt)) {
80+
const auto v = p.value(thumbnailsize_opt).toInt();
81+
if (v) {
82+
Settings::get()->thumbnail_size = v;
83+
} else {
84+
std::cerr << "Thumbnail size must be an integer." << std::endl;
85+
return false;
86+
}
87+
}
7588
if (p.isSet(prefix_opt)) {
7689
if (!Settings::get()->remote) {
7790
std::cerr << "This option has no effect if remote support is not enabled" << std::endl;

src/qml/PathView.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ ListView {
2323
visible: false
2424
icon.name: "emblem-documents-symbolic"
2525
icon.color: "transparent"
26-
width: 64
27-
height: 64
26+
width: Settings.thumbnailSize
27+
height: Settings.thumbnailSize
2828
}
2929
DragArea {
3030
anchors.fill: parent
@@ -48,7 +48,7 @@ ListView {
4848
}
4949
}
5050
delegate: Item {
51-
height: 64
51+
height: Settings.thumbnailSize
5252
width: ListView.view.width
5353
Pane {
5454
id: pane

src/settings.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Settings : public QObject {
1414
Q_PROPERTY(bool needsGui READ needs_gui NOTIFY hideGuiChanged)
1515
Q_PROPERTY(bool spawnOnCursor MEMBER spawn_on_cursor CONSTANT)
1616
Q_PROPERTY(bool intercept MEMBER intercept CONSTANT)
17+
Q_PROPERTY(int thumbnailSize MEMBER thumbnail_size CONSTANT)
1718
public:
1819
enum class AutoQuitBehavior {
1920
Never,
@@ -45,6 +46,7 @@ class Settings : public QObject {
4546
bool suppress_always_on_bottom = false;
4647
bool spawn_on_cursor = false;
4748
bool intercept = false;
49+
int thumbnail_size = 64;
4850
bool remote = false;
4951
signals:
5052
void alwaysOnBottomChanged(bool alwaysOnBottom);

0 commit comments

Comments
 (0)