summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkgs/simple/flameshot-once/config.nix111
-rw-r--r--pkgs/simple/flameshot-once/default.nix28
2 files changed, 139 insertions, 0 deletions
diff --git a/pkgs/simple/flameshot-once/config.nix b/pkgs/simple/flameshot-once/config.nix
index 2d8a9dc7..3738dc1e 100644
--- a/pkgs/simple/flameshot-once/config.nix
+++ b/pkgs/simple/flameshot-once/config.nix
@@ -1,5 +1,39 @@
{ config, lib, mylib, pkgs, ... }:
+let
+ toHexchar = builtins.elemAt mylib.hexchars;
+
+ # Encode integer to C-escaped string of bytes, little endian / LSB 0
+ le = rec {
+ x1 = i: let
+ i0 = lib.mod i 16;
+ i1 = i / 16;
+ in
+ if i == 0 then
+ "\\0"
+ else if i < 16 then
+ "\\x${toHexchar i0}"
+ else
+ "\\x${toHexchar i1}${toHexchar i0}";
+
+ x2 = i: let
+ i0 = lib.mod i 256;
+ i1 = i / 256;
+ in
+ "${x1 i1}${x1 i0}";
+
+ x4 = i: let
+ i0 = lib.mod i 65536;
+ i1 = i / 65536;
+ in
+ "${x2 i1}${x2 i0}";
+ };
+
+ toQList = t: xs:
+ assert t == "int";
+ "QList<${t}>${le.x4 0}${le.x1 (builtins.length xs)}${lib.concatMapStrings le.x4 xs}";
+in
+
{
options = {
imgur = lib.mkOption {
@@ -73,6 +107,83 @@
'';
type = lib.types.nullOr lib.types.bool;
};
+ buttons = let
+ buttonTypes = {
+ # Generated with:
+ # nix-shell -p flameshot-once.dev --run get-buttonTypes
+ TYPE_PENCIL = 0;
+ TYPE_DRAWER = 1;
+ TYPE_ARROW = 2;
+ TYPE_SELECTION = 3;
+ TYPE_RECTANGLE = 4;
+ TYPE_CIRCLE = 5;
+ TYPE_MARKER = 6;
+ TYPE_MOVESELECTION = 8;
+ TYPE_UNDO = 9;
+ TYPE_COPY = 10;
+ TYPE_SAVE = 11;
+ TYPE_EXIT = 12;
+ TYPE_IMAGEUPLOADER = 13;
+ TYPE_OPEN_APP = 14;
+ TYPE_PIXELATE = 15;
+ TYPE_REDO = 16;
+ TYPE_PIN = 17;
+ TYPE_TEXT = 18;
+ TYPE_CIRCLECOUNT = 19;
+ TYPE_SIZEINCREASE = 20;
+ TYPE_SIZEDECREASE = 21;
+ TYPE_INVERT = 22;
+ TYPE_ACCEPT = 23;
+ TYPE_CANCEL = 24;
+ };
+ iterableButtonTypes = [
+ # Generated with:
+ # nix-shell -p flameshot-once.dev --run get-iterableButtonTypes
+ "TYPE_ACCEPT"
+ "TYPE_ARROW"
+ "TYPE_CIRCLE"
+ "TYPE_CIRCLECOUNT"
+ "TYPE_COPY"
+ "TYPE_DRAWER"
+ "TYPE_EXIT"
+ "TYPE_IMAGEUPLOADER"
+ "TYPE_INVERT"
+ "TYPE_MARKER"
+ "TYPE_MOVESELECTION"
+ "TYPE_OPEN_APP"
+ "TYPE_PENCIL"
+ "TYPE_PIN"
+ "TYPE_PIXELATE"
+ "TYPE_RECTANGLE"
+ "TYPE_REDO"
+ "TYPE_SAVE"
+ "TYPE_SELECTION"
+ "TYPE_SIZEDECREASE"
+ "TYPE_SIZEINCREASE"
+ "TYPE_TEXT"
+ "TYPE_UNDO"
+ ];
+ in lib.mkOption {
+ # apply :: [int] -> str
+ # where str is readable by QSettingsPrivate::stringToVariant[1]
+ #
+ # [1]: https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qsettings.cpp?id=ab9f5a9#n454
+ apply = names:
+ if names != null then let
+ values = map (name: buttonTypes.${name}) names;
+ in
+ # 127 11
+ ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" values})''
+ else
+ null;
+ description = ''
+ Configure which buttons to show after drawing a selection
+ '';
+ type =
+ lib.types.nullOr
+ (lib.types.listOf
+ (lib.types.enum iterableButtonTypes));
+ };
captureActiveMonitor = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
};
diff --git a/pkgs/simple/flameshot-once/default.nix b/pkgs/simple/flameshot-once/default.nix
index 20a69c74..68a1ed6f 100644
--- a/pkgs/simple/flameshot-once/default.nix
+++ b/pkgs/simple/flameshot-once/default.nix
@@ -76,6 +76,34 @@ pkgs.symlinkJoin {
}
// {
dev = pkgs.write "flameshot-once-tools" {
+ "/bin/get-buttonTypes" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ indent=$(${placeholder "out"}/bin/indent-of buttonTypes)
+ src=${cfg.package.src}/src/tools/capturetool.h
+ ${pkgs.coreutils}/bin/cat "$src" |
+ ${pkgs.gnused}/bin/sed -nr '
+ s/^\s*(TYPE_\S+)\s*=\s*([0-9]+),/\1 = \2;/p
+ ' |
+ ${placeholder "out"}/bin/prefix " $indent"
+ '';
+ };
+ "/bin/get-iterableButtonTypes" = {
+ executable = true;
+ text = /* sh */ ''
+ #! ${pkgs.dash}/bin/dash
+ indent=$(${placeholder "out"}/bin/indent-of iterableButtonTypes)
+ src=${cfg.package.src}/src/widgets/capture/capturetoolbutton.cpp
+ ${pkgs.coreutils}/bin/cat "$src" |
+ ${pkgs.gnused}/bin/sed -n '/\<iterableButtonTypes = {/,/^}/p' |
+ ${pkgs.gcc}/bin/cpp -DENABLE_IMGUR |
+ ${pkgs.coreutils}/bin/tr , \\n |
+ ${pkgs.gnused}/bin/sed -rn 's/^ *CaptureTool::(TYPE_[A-Z_]+).*/"\1"/p' |
+ ${pkgs.coreutils}/bin/sort |
+ ${placeholder "out"}/bin/prefix " $indent"
+ '';
+ };
"/bin/get-recognizedGeneralOptions" = {
executable = true;
text = /* sh */ ''