aboutsummaryrefslogtreecommitdiffhomepage
path: root/Types
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-02-28 21:53:04 -0700
committerSean Whitton <spwhitton@spwhitton.name>2017-02-28 21:53:04 -0700
commit0f4a73c745602fc2a3f837e7c6e829eff44de68a (patch)
tree9cf389724f2adc9ba5cb07954856f9211c04a49b /Types
parent7ac129947a5ec83e6ab6cd0650c91f3955d09047 (diff)
downloadsscan-0f4a73c745602fc2a3f837e7c6e829eff44de68a.tar.gz
put command into scansess & rework
Diffstat (limited to 'Types')
-rw-r--r--Types/State.hs49
1 files changed, 38 insertions, 11 deletions
diff --git a/Types/State.hs b/Types/State.hs
index 1230e31..9d11019 100644
--- a/Types/State.hs
+++ b/Types/State.hs
@@ -56,22 +56,37 @@ type DPI = Int
data OutputFormat = PDF | PNG
deriving (Eq, Show)
--- | An active multi-page scanning session
+-- | An active scanning session
data ScanSess = ScanSess
- FilePath -- ^ session's tmpdir
- Int -- ^ total pages scanner thus far
+ -- | An action requested by the user, that has not yet been
+ -- fulfilled
+ Command
+ -- | The number of pages scanned so far in this scanning session
+ Int
+ -- | Temporary directory containing pages scanned in this scanning
+ -- session, if any have been scanned, and the session is multi-page
+ (Maybe FilePath)
-- | An sscan operation selected by the user in the UI
data Command
- = NextPage -- ^ scan first page or another page
- | FinalPage -- ^ scan final page (might be the first page)
- | Finalise -- ^ make the previous scanned page the final page of the document
- | Abort -- ^ abandon the current scan session
- | Quit -- ^ quit sscan
+ -- | Scan an additional page, or the first page, of a multi-page
+ -- scanning session.
+ = NextPage
+ -- | Scan the final page of a multi-page scanning session, or the
+ -- first page of a single-page scanning session
+ | FinalPage
+ -- | End a multi-page scanning session without scanning anymore
+ -- pages, i.e., consider the most recently scanned page the final
+ -- page
+ | Finalise
+ -- | Abandon the current scanning session. Delete its tmpdir.
+ | Abort
-- | Application state
data St =
- St { _stScanSess :: Maybe ScanSess
+ --
+ St { _stScanSess :: Maybe ScanSess -- ^ Nothing indicates user
+ -- wants to quit sscan
, _stOCR :: Bool -- ^ whether to use OCRmyPDF
, _stColour :: Colour
, _stPaper :: Paper -- ^ currently selected paper size
@@ -79,9 +94,9 @@ data St =
, _stDPI :: DPI
, _stOutFormat :: OutputFormat
, _stOutdir :: FilePath -- ^ where to save final PDFs
- , _stCommand :: Command
}
--- other device-specific scanimage options the old script supported: --swdespeck; --color-filter; --depth
+-- other device-specific scanimage options the old script supported:
+-- --swdespeck; --color-filter; --depth
makeLenses ''St
@@ -96,3 +111,15 @@ updateSt st f = ifScanSess st st (f st)
resetScanSess :: St -> St
resetScanSess st = st & stScanSess .~ Nothing
+
+setScanSessDir :: FilePath -> St -> St
+setScanSessDir dir st = case st^.stScanSess of
+ Nothing -> st
+ Just (ScanSess c p _) ->
+ st & stScanSess .~ (Just $ ScanSess c p (Just dir))
+
+incrementPages :: St -> St
+incrementPages st = case st^.stScanSess of
+ Nothing -> st
+ Just (ScanSess c p d) ->
+ st & stScanSess .~ (Just $ ScanSess c (p+1) d)