Skip to content

Commit 580d3a1

Browse files
committed
Allow to show only icons in the gui window
This brings us more close to dragon compatibility. Note that the command line argument is not completely compatible, the "-i" flag is already taken, so we have to opt for "-I" instead. The long-form argument "--icon-only" is identical at least. The implementation is a bit hacky, since we manually adapt the size of the window for now if the flag is present. Ideally the layout would automatically dictate the size in a bottom-up way. In the future we can also add an option to use the original image size as dimensions for the thumbnail. Perhaps "--thumb-size 0" could be used for this purpose. Right now depending on the image sizes, the default thumbnail size of 64 can be a whacky in combination with this flag. Closes #10
1 parent d8e5827 commit 580d3a1

File tree

8 files changed

+19
-5
lines changed

8 files changed

+19
-5
lines changed

assets/completions/bash-completion/completions/blobdrop

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ _blobdrop() {
77
-c --cursor
88
-f --frontend
99
-i --intercept
10+
-I --icon-only
1011
-k --keep
1112
-p --persistent
1213
-P --prefix

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

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ complete -c blobdrop -s '-b' -l 'frameless' -d 'show frameless window'
44
complete -c blobdrop -s '-c' -l 'cursor' -d 'spawn window at mouse cursor'
55
complete -c blobdrop -s '-f' -l 'frontend' -d 'selects frontend' -xa "auto\t'automatic' gui\t'show window' immediate\t'drag immediately' notify\t'drag from notification' clipboard\t'copy to clipboard' stdout\t'print OSC8 link'"
66
complete -c blobdrop -s '-i' -l 'intercept' -d 'intercept another DnD'
7+
complete -c blobdrop -s '-I' -l 'icon-only' -d 'only show icons'
78
complete -c blobdrop -s '-k' -l 'keep' -d 'keep dropped files'
89
complete -c blobdrop -s '-p' -l 'persistent' -d 'disable autohiding during drag'
910
complete -c blobdrop -s '-P' -l 'prefix' -d 'remote prefix' -xa "(__fish_print_hostnames)"

assets/completions/zsh/site-functions/_blobdrop

+1-1
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]' {-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'
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]' {-I,--icon-only}'[only show icons]' {-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

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ blobdrop \- Quickly drag and drop files from the terminal
55

66
.SH SYNOPSIS
77
.B blobdrop
8-
[\-hvbcikpRt]
8+
[\-hvbciIkpRt]
99
[\-f \fIOPT\fP]
1010
[\-P \fIOPT\fP]
1111
[\-s \fIOPT\fP]
@@ -50,6 +50,11 @@ frontend to intercept another drag and drop operation. Once an element is droppe
5050
.B \-\-frontend
5151
option determines the frontend of the outgoing converted drag and drop event.
5252
.TP
53+
.B \-I, \-\-icon-only
54+
Show only the thumbnail icons in windows. This option has no effect if a frontend other than the
55+
.B gui
56+
frontend is active.
57+
.TP
5358
.B \-k, \-\-keep
5459
When using sink mode, keep dropped files around by default.
5560
.TP

src/getopts.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ bool parse(const QStringList &args) {
3838
QCommandLineOption intercept_opt(QStringList() << "i"
3939
<< "intercept",
4040
"Intercept another drag and drop.");
41+
QCommandLineOption icononly_opt(QStringList() << "I"
42+
<< "icon-only",
43+
"Only show icons.");
4144
QCommandLineOption keep_opt(QStringList() << "k"
4245
<< "keep",
4346
"Keep dropped files around in sink mode.");
@@ -46,7 +49,7 @@ bool parse(const QStringList &args) {
4649
"Do not auto-hide the window while dragging.");
4750
QCommandLineOption prefix_opt(QStringList() << "P"
4851
<< "prefix",
49-
"Specify a remote prefix",
52+
"Specify a remote prefix.",
5053
"prefix");
5154
QCommandLineOption remote_opt(QStringList() << "R"
5255
<< "remote",
@@ -63,7 +66,7 @@ bool parse(const QStringList &args) {
6366
"The amount of drags after which the program should automatically close. Must be one of:" + QString::fromStdString(auto_quit_descr) + " (all is default)",
6467
"behaviour");
6568

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});
69+
p.addOptions({frameless_opt, cursor_opt, frontend_opt, intercept_opt, icononly_opt, keep_opt, persistent_opt, prefix_opt, remote_opt, thumbnailsize_opt, ontop_opt, auto_quit_opt});
6770
p.process(args);
6871

6972
if (p.isSet(auto_quit_opt)) {
@@ -116,6 +119,7 @@ bool parse(const QStringList &args) {
116119
Settings::get()->frameless = p.isSet(frameless_opt);
117120
Settings::get()->spawn_on_cursor = p.isSet(cursor_opt);
118121
Settings::get()->intercept = p.isSet(intercept_opt);
122+
Settings::get()->icon_only = p.isSet(icononly_opt);
119123

120124
// add all trailing arguments to the path list
121125
std::ranges::for_each(p.positionalArguments(), [](auto i) { PathRegistry::get()->add_path(i.toStdString()); });

src/qml/Main.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ApplicationWindow {
99
visible: Settings.needsGui
1010
flags: Qt.Dialog | (Settings.alwaysOnTop ? Qt.WindowStaysOnTopHint : 0) | (Settings.alwaysOnBottom ? Qt.WindowStaysOnBottomHint : 0) | (Settings.frameless ? Qt.FramelessWindowHint : 0)
1111
title: Stdin.closed ? "Blobdrop" : "Reading from stdin..."
12-
width: 400
12+
width: Settings.iconOnly ? Settings.thumbnailSize + 16 : 400
1313
height: Math.max(48, Math.min(800, pathView.count ? pathView.contentHeight + 2 * pathView.anchors.topMargin : 350))
1414
Material.theme: Material.System
1515
Material.primary: Material.Green

src/qml/PathView.qml

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ListView {
8585
verticalAlignment: Text.AlignVCenter
8686
horizontalAlignment: Text.AlignHCenter
8787
wrapMode: Text.Wrap
88+
visible: !Settings.iconOnly
8889
ToolTip.text: path
8990
ToolTip.visible: dragArea.containsMouse && (count > 1)
9091
ToolTip.delay: 1500

src/settings.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Settings : public QObject {
1515
Q_PROPERTY(bool spawnOnCursor MEMBER spawn_on_cursor CONSTANT)
1616
Q_PROPERTY(bool intercept MEMBER intercept CONSTANT)
1717
Q_PROPERTY(int thumbnailSize MEMBER thumbnail_size CONSTANT)
18+
Q_PROPERTY(bool iconOnly MEMBER icon_only CONSTANT)
1819
public:
1920
enum class AutoQuitBehavior {
2021
Never,
@@ -47,6 +48,7 @@ class Settings : public QObject {
4748
bool spawn_on_cursor = false;
4849
bool intercept = false;
4950
int thumbnail_size = 64;
51+
bool icon_only = false;
5052
bool remote = false;
5153
signals:
5254
void alwaysOnBottomChanged(bool alwaysOnBottom);

0 commit comments

Comments
 (0)