Skip to content

Commit

Permalink
Add new downloader settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 committed Sep 16, 2023
1 parent 3d84e56 commit d3c418b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class LauncherViewModel {
val downloadAsCbz = config.asStateFlow { it.downloadAsCbz }
val downloadsPath = config.asStateFlow { it.downloadsPath }
val autoDownloadNewChapters = config.asStateFlow { it.autoDownloadNewChapters }
val excludeEntryWithUnreadChapters = config.asStateFlow { it.excludeEntryWithUnreadChapters }
val autoDownloadAheadLimit = config.asStateFlow { it.autoDownloadAheadLimit }

// Updater
val excludeUnreadChapters = config.asStateFlow { it.excludeUnreadChapters }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class ServerConfig(
val downloadAsCbz: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val downloadsPath: MutableStateFlow<String> by OverrideConfigValue(StringConfigAdapter)
val autoDownloadNewChapters: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val excludeEntryWithUnreadChapters: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val autoDownloadAheadLimit: MutableStateFlow<Int> by OverrideConfigValue(IntConfigAdapter)

// updater
val excludeUnreadChapters: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
Expand Down
26 changes: 26 additions & 0 deletions src/main/kotlin/suwayomi/tachidesk/launcher/ui/Downloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ import suwayomi.tachidesk.launcher.KeyListenerEvent
import suwayomi.tachidesk.launcher.LauncherViewModel
import suwayomi.tachidesk.launcher.actions
import suwayomi.tachidesk.launcher.bind
import suwayomi.tachidesk.launcher.changes
import suwayomi.tachidesk.launcher.jCheckBox
import suwayomi.tachidesk.launcher.jSpinner
import suwayomi.tachidesk.launcher.jTextArea
import suwayomi.tachidesk.launcher.jTextField
import suwayomi.tachidesk.launcher.jbutton
import suwayomi.tachidesk.launcher.jpanel
import suwayomi.tachidesk.launcher.keyListener
import javax.swing.JFileChooser
import javax.swing.SpinnerNumberModel
import javax.swing.UIManager
import kotlin.io.path.Path
import kotlin.io.path.createDirectories
Expand Down Expand Up @@ -97,4 +100,27 @@ fun Downloader(vm: LauncherViewModel, scope: CoroutineScope) = jpanel(
.flowOn(Dispatchers.Default)
.launchIn(scope)
}.bind(CC().wrap())

jCheckBox("Exclude unread entries", selected = vm.excludeEntryWithUnreadChapters.value) {
toolTipText = "Ignore automatic chapter downloads of entries with unread chapters." // todo improve
actions()
.onEach {
vm.excludeEntryWithUnreadChapters.value = isSelected
}
.flowOn(Dispatchers.Default)
.launchIn(scope)
}.bind(CC().wrap())

jTextArea("Download ahead limit") {
isEditable = false
}.bind()
jSpinner(SpinnerNumberModel(vm.autoDownloadAheadLimit.value.coerceAtLeast(0), 0, Int.MAX_VALUE, 1)) {
toolTipText = "0 to disable it - How many unread downloaded chapters should be available - If the limit is reached, new chapters won't be downloaded automatically"
changes()
.onEach {
vm.autoDownloadAheadLimit.value = (value as Int)
}
.flowOn(Dispatchers.Default)
.launchIn(scope)
}.bind(CC().grow().spanX().wrap())
}

0 comments on commit d3c418b

Please sign in to comment.