mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
add an option to not use category by default (#397)
This commit is contained in:
parent
5468ed159d
commit
ce143bd25d
@ -10,7 +10,7 @@ import com.abdownloadmanager.desktop.utils.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import com.abdownloadmanager.desktop.pages.settings.ThreadCountLimitation
|
import com.abdownloadmanager.desktop.pages.settings.ThreadCountLimitation
|
||||||
import com.abdownloadmanager.desktop.pages.settings.configurable.FileChecksumConfigurable
|
import com.abdownloadmanager.desktop.pages.settings.configurable.FileChecksumConfigurable
|
||||||
import com.abdownloadmanager.desktop.pages.settings.configurable.widgets.RenderFileChecksumConfig
|
import com.abdownloadmanager.desktop.storage.AppSettingsStorage
|
||||||
import com.abdownloadmanager.shared.utils.mvi.ContainsEffects
|
import com.abdownloadmanager.shared.utils.mvi.ContainsEffects
|
||||||
import com.abdownloadmanager.shared.utils.mvi.supportEffects
|
import com.abdownloadmanager.shared.utils.mvi.supportEffects
|
||||||
import com.abdownloadmanager.resources.Res
|
import com.abdownloadmanager.resources.Res
|
||||||
@ -56,7 +56,8 @@ class AddSingleDownloadComponent(
|
|||||||
KoinComponent,
|
KoinComponent,
|
||||||
ContainsEffects<AddSingleDownloadPageEffects> by supportEffects() {
|
ContainsEffects<AddSingleDownloadPageEffects> by supportEffects() {
|
||||||
|
|
||||||
private val appSettings: AppRepository by inject()
|
private val appSettings: AppSettingsStorage by inject()
|
||||||
|
private val appRepository: AppRepository by inject()
|
||||||
private val client: DownloaderClient by inject()
|
private val client: DownloaderClient by inject()
|
||||||
val downloadSystem: DownloadSystem by inject()
|
val downloadSystem: DownloadSystem by inject()
|
||||||
val iconProvider: FileIconProvider by inject()
|
val iconProvider: FileIconProvider by inject()
|
||||||
@ -95,7 +96,7 @@ class AddSingleDownloadComponent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun useDefaultFolder() {
|
private fun useDefaultFolder() {
|
||||||
setFolder(appSettings.saveLocation.value)
|
setFolder(appRepository.saveLocation.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ class AddSingleDownloadComponent(
|
|||||||
|
|
||||||
|
|
||||||
private val downloadChecker = DownloadUiChecker(
|
private val downloadChecker = DownloadUiChecker(
|
||||||
initialFolder = appSettings.saveLocation.value,
|
initialFolder = appRepository.saveLocation.value,
|
||||||
downloadSystem = downloadSystem,
|
downloadSystem = downloadSystem,
|
||||||
scope = scope,
|
scope = scope,
|
||||||
downloaderClient = client,
|
downloaderClient = client,
|
||||||
@ -150,7 +151,8 @@ class AddSingleDownloadComponent(
|
|||||||
.onEachLatest { onDuplicateStrategy.update { null } }
|
.onEachLatest { onDuplicateStrategy.update { null } }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
combine(
|
combine(
|
||||||
name, credentials.map { it.link }
|
name,
|
||||||
|
credentials.map { it.link },
|
||||||
) { name, link ->
|
) { name, link ->
|
||||||
val category = categoryManager.getCategoryOf(
|
val category = categoryManager.getCategoryOf(
|
||||||
CategoryItem(
|
CategoryItem(
|
||||||
@ -158,11 +160,16 @@ class AddSingleDownloadComponent(
|
|||||||
url = link,
|
url = link,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
val globalUseCategoryByDefault = appSettings.useCategoryByDefault.value
|
||||||
|
val suggestedUseCategory: Boolean
|
||||||
if (category == null) {
|
if (category == null) {
|
||||||
setUseCategory(false)
|
suggestedUseCategory = false
|
||||||
} else {
|
} else {
|
||||||
setSelectedCategory(category)
|
setSelectedCategory(category)
|
||||||
setUseCategory(true)
|
suggestedUseCategory = true
|
||||||
|
}
|
||||||
|
if (globalUseCategoryByDefault) {
|
||||||
|
setUseCategory(suggestedUseCategory)
|
||||||
}
|
}
|
||||||
}.launchIn(scope)
|
}.launchIn(scope)
|
||||||
}
|
}
|
||||||
@ -265,7 +272,7 @@ class AddSingleDownloadComponent(
|
|||||||
describe = {
|
describe = {
|
||||||
if (it == 0L) Res.string.unlimited.asStringSource()
|
if (it == 0L) Res.string.unlimited.asStringSource()
|
||||||
else convertPositiveSpeedToHumanReadable(
|
else convertPositiveSpeedToHumanReadable(
|
||||||
it, appSettings.speedUnit.value
|
it, appRepository.speedUnit.value
|
||||||
).asStringSource()
|
).asStringSource()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -154,6 +154,21 @@ fun ignoreSSLCertificates(appSettingsStorage: AppSettingsStorage): BooleanConfig
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun useCategoryByDefault(appSettingsStorage: AppSettingsStorage): BooleanConfigurable {
|
||||||
|
return BooleanConfigurable(
|
||||||
|
title = Res.string.settings_use_category_by_default.asStringSource(),
|
||||||
|
description = Res.string.settings_use_category_by_default_description.asStringSource(),
|
||||||
|
backedBy = appSettingsStorage.useCategoryByDefault,
|
||||||
|
describe = {
|
||||||
|
if (it) {
|
||||||
|
Res.string.enabled.asStringSource()
|
||||||
|
} else {
|
||||||
|
Res.string.disabled.asStringSource()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun speedUnit(appRepository: AppRepository, scope: CoroutineScope): EnumConfigurable<ConvertSizeConfig> {
|
fun speedUnit(appRepository: AppRepository, scope: CoroutineScope): EnumConfigurable<ConvertSizeConfig> {
|
||||||
return EnumConfigurable(
|
return EnumConfigurable(
|
||||||
title = Res.string.settings_download_speed_unit.asStringSource(),
|
title = Res.string.settings_download_speed_unit.asStringSource(),
|
||||||
@ -487,6 +502,7 @@ class SettingsComponent(
|
|||||||
useAverageSpeedConfig(appRepository),
|
useAverageSpeedConfig(appRepository),
|
||||||
speedLimitConfig(appRepository),
|
speedLimitConfig(appRepository),
|
||||||
threadCountConfig(appRepository),
|
threadCountConfig(appRepository),
|
||||||
|
useCategoryByDefault(appSettings),
|
||||||
dynamicPartDownloadConfig(appRepository),
|
dynamicPartDownloadConfig(appRepository),
|
||||||
autoShowDownloadProgressWindow(appSettings),
|
autoShowDownloadProgressWindow(appSettings),
|
||||||
showDownloadFinishWindow(appSettings),
|
showDownloadFinishWindow(appSettings),
|
||||||
|
@ -35,6 +35,7 @@ data class AppSettingsModel(
|
|||||||
val trackDeletedFilesOnDisk: Boolean = false,
|
val trackDeletedFilesOnDisk: Boolean = false,
|
||||||
val useBitsForSpeed: Boolean = false,
|
val useBitsForSpeed: Boolean = false,
|
||||||
val ignoreSSLCertificates: Boolean = false,
|
val ignoreSSLCertificates: Boolean = false,
|
||||||
|
val useCategoryByDefault: Boolean = true,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val default: AppSettingsModel get() = AppSettingsModel()
|
val default: AppSettingsModel get() = AppSettingsModel()
|
||||||
@ -62,6 +63,7 @@ data class AppSettingsModel(
|
|||||||
val trackDeletedFilesOnDisk = booleanKeyOf("trackDeletedFilesOnDisk")
|
val trackDeletedFilesOnDisk = booleanKeyOf("trackDeletedFilesOnDisk")
|
||||||
val useBitsForSpeed = booleanKeyOf("useBitsForSpeed")
|
val useBitsForSpeed = booleanKeyOf("useBitsForSpeed")
|
||||||
val ignoreSSLCertificates = booleanKeyOf("ignoreSSLCertificates")
|
val ignoreSSLCertificates = booleanKeyOf("ignoreSSLCertificates")
|
||||||
|
val useCategoryByDefault = booleanKeyOf("useCategoryByDefault")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,6 +94,7 @@ data class AppSettingsModel(
|
|||||||
trackDeletedFilesOnDisk = source.get(Keys.trackDeletedFilesOnDisk) ?: default.trackDeletedFilesOnDisk,
|
trackDeletedFilesOnDisk = source.get(Keys.trackDeletedFilesOnDisk) ?: default.trackDeletedFilesOnDisk,
|
||||||
useBitsForSpeed = source.get(Keys.useBitsForSpeed) ?: default.useBitsForSpeed,
|
useBitsForSpeed = source.get(Keys.useBitsForSpeed) ?: default.useBitsForSpeed,
|
||||||
ignoreSSLCertificates = source.get(Keys.ignoreSSLCertificates) ?: default.ignoreSSLCertificates,
|
ignoreSSLCertificates = source.get(Keys.ignoreSSLCertificates) ?: default.ignoreSSLCertificates,
|
||||||
|
useCategoryByDefault = source.get(Keys.useCategoryByDefault) ?: default.useCategoryByDefault,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +120,7 @@ data class AppSettingsModel(
|
|||||||
put(Keys.trackDeletedFilesOnDisk, focus.trackDeletedFilesOnDisk)
|
put(Keys.trackDeletedFilesOnDisk, focus.trackDeletedFilesOnDisk)
|
||||||
put(Keys.useBitsForSpeed, focus.useBitsForSpeed)
|
put(Keys.useBitsForSpeed, focus.useBitsForSpeed)
|
||||||
put(Keys.ignoreSSLCertificates, focus.ignoreSSLCertificates)
|
put(Keys.ignoreSSLCertificates, focus.ignoreSSLCertificates)
|
||||||
|
put(Keys.useCategoryByDefault, focus.useCategoryByDefault)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,4 +170,5 @@ class AppSettingsStorage(
|
|||||||
val trackDeletedFilesOnDisk = from(AppSettingsModel.trackDeletedFilesOnDisk)
|
val trackDeletedFilesOnDisk = from(AppSettingsModel.trackDeletedFilesOnDisk)
|
||||||
val useBitsForSpeed = from(AppSettingsModel.useBitsForSpeed)
|
val useBitsForSpeed = from(AppSettingsModel.useBitsForSpeed)
|
||||||
val ignoreSSLCertificates = from(AppSettingsModel.ignoreSSLCertificates)
|
val ignoreSSLCertificates = from(AppSettingsModel.ignoreSSLCertificates)
|
||||||
|
val useCategoryByDefault = from(AppSettingsModel.useCategoryByDefault)
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,8 @@ settings_global_speed_limiter=Global Speed Limiter
|
|||||||
settings_global_speed_limiter_description=Global download speed limit (0 means unlimited)
|
settings_global_speed_limiter_description=Global download speed limit (0 means unlimited)
|
||||||
settings_show_average_speed=Show Average Speed
|
settings_show_average_speed=Show Average Speed
|
||||||
settings_show_average_speed_description=Download speed in average or precision
|
settings_show_average_speed_description=Download speed in average or precision
|
||||||
|
settings_use_category_by_default=Use category by default
|
||||||
|
settings_use_category_by_default_description=Use category by default when adding a download.
|
||||||
settings_default_download_folder=Default Download Folder
|
settings_default_download_folder=Default Download Folder
|
||||||
settings_default_download_folder_description=When you add new download this location is used by default
|
settings_default_download_folder_description=When you add new download this location is used by default
|
||||||
settings_default_download_folder_describe="{{folder}}" will be used
|
settings_default_download_folder_describe="{{folder}}" will be used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user