Skip to content

Commit

Permalink
Allow to show only icons in the gui window
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vimpostor committed Oct 3, 2024
1 parent d8e5827 commit 580d3a1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions assets/completions/bash-completion/completions/blobdrop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ _blobdrop() {
-c --cursor
-f --frontend
-i --intercept
-I --icon-only
-k --keep
-p --persistent
-P --prefix
Expand Down
1 change: 1 addition & 0 deletions assets/completions/fish/vendor_completions.d/blobdrop.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ complete -c blobdrop -s '-b' -l 'frameless' -d 'show frameless window'
complete -c blobdrop -s '-c' -l 'cursor' -d 'spawn window at mouse cursor'
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'"
complete -c blobdrop -s '-i' -l 'intercept' -d 'intercept another DnD'
complete -c blobdrop -s '-I' -l 'icon-only' -d 'only show icons'
complete -c blobdrop -s '-k' -l 'keep' -d 'keep dropped files'
complete -c blobdrop -s '-p' -l 'persistent' -d 'disable autohiding during drag'
complete -c blobdrop -s '-P' -l 'prefix' -d 'remote prefix' -xa "(__fish_print_hostnames)"
Expand Down
2 changes: 1 addition & 1 deletion assets/completions/zsh/site-functions/_blobdrop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#compdef blobdrop

_blobdrop() {
_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'
_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'
return 0
}

Expand Down
7 changes: 6 additions & 1 deletion doc/man/man1/blobdrop.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ blobdrop \- Quickly drag and drop files from the terminal

.SH SYNOPSIS
.B blobdrop
[\-hvbcikpRt]
[\-hvbciIkpRt]
[\-f \fIOPT\fP]
[\-P \fIOPT\fP]
[\-s \fIOPT\fP]
Expand Down Expand Up @@ -50,6 +50,11 @@ frontend to intercept another drag and drop operation. Once an element is droppe
.B \-\-frontend
option determines the frontend of the outgoing converted drag and drop event.
.TP
.B \-I, \-\-icon-only
Show only the thumbnail icons in windows. This option has no effect if a frontend other than the
.B gui
frontend is active.
.TP
.B \-k, \-\-keep
When using sink mode, keep dropped files around by default.
.TP
Expand Down
8 changes: 6 additions & 2 deletions src/getopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ bool parse(const QStringList &args) {
QCommandLineOption intercept_opt(QStringList() << "i"
<< "intercept",
"Intercept another drag and drop.");
QCommandLineOption icononly_opt(QStringList() << "I"
<< "icon-only",
"Only show icons.");
QCommandLineOption keep_opt(QStringList() << "k"
<< "keep",
"Keep dropped files around in sink mode.");
Expand All @@ -46,7 +49,7 @@ bool parse(const QStringList &args) {
"Do not auto-hide the window while dragging.");
QCommandLineOption prefix_opt(QStringList() << "P"
<< "prefix",
"Specify a remote prefix",
"Specify a remote prefix.",
"prefix");
QCommandLineOption remote_opt(QStringList() << "R"
<< "remote",
Expand All @@ -63,7 +66,7 @@ bool parse(const QStringList &args) {
"The amount of drags after which the program should automatically close. Must be one of:" + QString::fromStdString(auto_quit_descr) + " (all is default)",
"behaviour");

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});
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});
p.process(args);

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

// add all trailing arguments to the path list
std::ranges::for_each(p.positionalArguments(), [](auto i) { PathRegistry::get()->add_path(i.toStdString()); });
Expand Down
2 changes: 1 addition & 1 deletion src/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ApplicationWindow {
visible: Settings.needsGui
flags: Qt.Dialog | (Settings.alwaysOnTop ? Qt.WindowStaysOnTopHint : 0) | (Settings.alwaysOnBottom ? Qt.WindowStaysOnBottomHint : 0) | (Settings.frameless ? Qt.FramelessWindowHint : 0)
title: Stdin.closed ? "Blobdrop" : "Reading from stdin..."
width: 400
width: Settings.iconOnly ? Settings.thumbnailSize + 16 : 400
height: Math.max(48, Math.min(800, pathView.count ? pathView.contentHeight + 2 * pathView.anchors.topMargin : 350))
Material.theme: Material.System
Material.primary: Material.Green
Expand Down
1 change: 1 addition & 0 deletions src/qml/PathView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ListView {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
visible: !Settings.iconOnly
ToolTip.text: path
ToolTip.visible: dragArea.containsMouse && (count > 1)
ToolTip.delay: 1500
Expand Down
2 changes: 2 additions & 0 deletions src/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Settings : public QObject {
Q_PROPERTY(bool spawnOnCursor MEMBER spawn_on_cursor CONSTANT)
Q_PROPERTY(bool intercept MEMBER intercept CONSTANT)
Q_PROPERTY(int thumbnailSize MEMBER thumbnail_size CONSTANT)
Q_PROPERTY(bool iconOnly MEMBER icon_only CONSTANT)
public:
enum class AutoQuitBehavior {
Never,
Expand Down Expand Up @@ -47,6 +48,7 @@ class Settings : public QObject {
bool spawn_on_cursor = false;
bool intercept = false;
int thumbnail_size = 64;
bool icon_only = false;
bool remote = false;
signals:
void alwaysOnBottomChanged(bool alwaysOnBottom);
Expand Down

0 comments on commit 580d3a1

Please sign in to comment.