diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..381b74d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +result + +.direnv/ diff --git a/README b/README index b4af270..429bba2 100644 --- a/README +++ b/README @@ -1,3 +1,13 @@ +# Scanner Image Extractor + +This is a fork of [Scanner Image Extractor](http://www.dominik-ruess.de/scannerExtract). + +It uses the nix build system and slight modification to the code to make it compile. +This flake also bundles the program into a self-contained AppImage to be run anywhere. + +# Original README + + /*********************************************************************** * This file is part of Scanned Image Extractor. * diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8e098fd --- /dev/null +++ b/flake.lock @@ -0,0 +1,128 @@ +{ + "nodes": { + "appimage-runtime": { + "flake": false, + "locked": { + "lastModified": 1652289700, + "narHash": "sha256-uxQBDy/JA7uEboTOUmGaZ2FAKY/0dQ9c0A0N8+J+a7I=", + "owner": "AppImageCrafters", + "repo": "appimage-runtime", + "rev": "6500a1ef68e039caba2ebab1c7ed74c2ea9e67a5", + "type": "github" + }, + "original": { + "owner": "AppImageCrafters", + "repo": "appimage-runtime", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nix-appimage": { + "inputs": { + "appimage-runtime": "appimage-runtime", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "squashfuse": "squashfuse" + }, + "locked": { + "lastModified": 1695276866, + "narHash": "sha256-/BBbYIoDhIPcVwhvau/g4lzrjTnudeRLW5qaTu7LAVs=", + "owner": "ralismark", + "repo": "nix-appimage", + "rev": "17dd6001ec228ea0b8505d6904fc5796d3de5012", + "type": "github" + }, + "original": { + "owner": "ralismark", + "repo": "nix-appimage", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1659526864, + "narHash": "sha256-XFzXrc1+6DZb9hBgHfEzfwylPUSqVFJbQPs8eOgYufU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "478f3cbc8448b5852539d785fbfe9a53304133be", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.05", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706371002, + "narHash": "sha256-dwuorKimqSYgyu8Cw6ncKhyQjUDOyuXoxDTVmAXq88s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c002c6aa977ad22c60398daaa9be52f2203d0006", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-appimage": "nix-appimage", + "nixpkgs": "nixpkgs_2" + } + }, + "squashfuse": { + "flake": false, + "locked": { + "lastModified": 1655253282, + "narHash": "sha256-RIhDXzpmrYUOwj5OYzjWKJw0cwE+L3t/9pIkg/hFXA0=", + "owner": "vasi", + "repo": "squashfuse", + "rev": "d1d7ddafb765098b34239eacaf2f9abee1fbc27c", + "type": "github" + }, + "original": { + "owner": "vasi", + "repo": "squashfuse", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 4d6bbd4..6f666ad 100644 --- a/flake.nix +++ b/flake.nix @@ -1,38 +1,71 @@ { - description = ""; + description = "A tool for efficiently extracting rectangular photographs."; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nix-appimage.url = "github:ralismark/nix-appimage"; }; outputs = { self, nixpkgs, + nix-appimage, }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; in { - packages.${system} = { - default = pkgs.stdenvNoCC.mkDerivation { - name = "scannerExtract"; + packages.${system} = let + name = "scannedImageExtractor"; + in { + default = pkgs.gccStdenv.mkDerivation { + inherit name; src = ./.; - buildInputs = with pkgs; [ - opencv3 + nativeBuildInputs = with pkgs; [ + cmake + opencv2 liblbfgs - qt6.full + qt5.full + libsForQt5.qt5.wrapQtAppsHook ]; + dontUseCmakeConfigure = true; buildPhase = '' - mkdir $out - cd $out - cmake $src/scannerExtract/ -DCMAKE_BUILD_TYPE=release + cmake scannerExtract -DCMAKE_BUILD_TYPE=release -DOPENCV2=1 make - # (make install) ''; + + installPhase = '' + install -m 555 ${name} -Dt $out/bin + ''; + }; + + appImage = let + src = nix-appimage.bundlers.${system}.default self.packages.${system}.default; + in + pkgs.stdenvNoCC.mkDerivation { + inherit name src; + + dontUnpack = true; + dontBuild = true; + + installPhase = '' + install -m 555 $src -D $out/${name}.AppImage + ''; + }; + }; + + devShells = { + default = pkgs.mkShellNoCC { + packages = with pkgs; [ + cmake + opencv2 + liblbfgs + gt5.full + + appimage-run + ]; }; }; }; } -# http://www.dominik-ruess.de/scannerExtract/ - diff --git a/module_misc/translation.cpp b/module_misc/translation.cpp index b31421c..4d37bf6 100644 --- a/module_misc/translation.cpp +++ b/module_misc/translation.cpp @@ -1,5 +1,5 @@ #include -#include +// #include #include #include diff --git a/scannerExtract/mainwindow.cpp b/scannerExtract/mainwindow.cpp index f2fb891..e01edbe 100644 --- a/scannerExtract/mainwindow.cpp +++ b/scannerExtract/mainwindow.cpp @@ -774,7 +774,7 @@ void MainWindow::noRotation() { QObject* item = i.next(); QRadioButton* b = dynamic_cast( item ); - if (b > 0 && b->isChecked()) { + if (b != 0 && b->isChecked()) { b->setAutoExclusive(false); b->setChecked(false); b->setAutoExclusive(true); @@ -788,7 +788,7 @@ void MainWindow::noAspect() while (i.hasNext()) { QRadioButton* b = dynamic_cast( i.next()); - if (b > 0 && b->isChecked()) { + if (b != 0 && b->isChecked()) { b->setAutoExclusive(false); b->setChecked(false); b->setAutoExclusive(true);