mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 10:00:27 +00:00
feat: auto extract archives (#1212)
This commit is contained in:
1 parent
5515a1c48c
commit
0d5c4e8e7f
35 files changed
+950
-40
No files matched your search
@@ -23,7 +23,7 @@ class CreateController extends GetxController
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
advancedTabController = TabController(length: 2, vsync: this);
|
||||
advancedTabController = TabController(length: 3, vsync: this);
|
||||
directDownload.value = Get.find<AppController>()
|
||||
.downloaderConfig
|
||||
.value
|
||||
|
||||
@@ -56,10 +56,13 @@ class CreateView extends GetView<CreateController> {
|
||||
),
|
||||
];
|
||||
final _btTrackerController = TextEditingController();
|
||||
final _archivePasswordController = TextEditingController();
|
||||
|
||||
final _availableSchemes = ["http:", "https:", "magnet:"];
|
||||
|
||||
final _skipVerifyCertController = false.obs;
|
||||
final _autoExtractController = Rxn<bool>();
|
||||
final _deleteAfterExtractController = Rxn<bool>();
|
||||
|
||||
CreateView({Key? key}) : super(key: key);
|
||||
|
||||
@@ -77,6 +80,15 @@ class CreateView extends GetView<CreateController> {
|
||||
final downloadDir = appController.downloaderConfig.value.downloadDir;
|
||||
_pathController.text = renderPathPlaceholders(downloadDir);
|
||||
}
|
||||
// Initialize archive settings from global config if not already set
|
||||
if (_autoExtractController.value == null) {
|
||||
_autoExtractController.value =
|
||||
appController.downloaderConfig.value.archive.autoExtract;
|
||||
}
|
||||
if (_deleteAfterExtractController.value == null) {
|
||||
_deleteAfterExtractController.value =
|
||||
appController.downloaderConfig.value.archive.deleteAfterExtract;
|
||||
}
|
||||
|
||||
final CreateTask? routerParams = Get.rootDelegate.arguments();
|
||||
if (routerParams?.req?.url.isNotEmpty ?? false) {
|
||||
@@ -497,17 +509,20 @@ class CreateView extends GetView<CreateController> {
|
||||
const Divider(),
|
||||
TabBar(
|
||||
controller: controller.advancedTabController,
|
||||
tabs: const [
|
||||
Tab(
|
||||
tabs: [
|
||||
const Tab(
|
||||
text: 'HTTP',
|
||||
),
|
||||
Tab(
|
||||
const Tab(
|
||||
text: 'BitTorrent',
|
||||
),
|
||||
Tab(
|
||||
text: 'archives'.tr,
|
||||
)
|
||||
],
|
||||
),
|
||||
DefaultTabController(
|
||||
length: 2,
|
||||
length: 3,
|
||||
child: ContentSizeTabBarView(
|
||||
controller:
|
||||
controller.advancedTabController,
|
||||
@@ -602,6 +617,63 @@ class CreateView extends GetView<CreateController> {
|
||||
hintText: 'addTrackerHit'.tr,
|
||||
)),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
child: CompactCheckbox(
|
||||
label: 'autoExtract'.tr,
|
||||
value: _autoExtractController
|
||||
.value ?? false,
|
||||
onChanged: (bool? value) {
|
||||
_autoExtractController
|
||||
.value = value ?? false;
|
||||
},
|
||||
textStyle: const TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: _autoExtractController.value ?? false,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
child: TextFormField(
|
||||
controller: _archivePasswordController,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'archivePassword'.tr,
|
||||
hintText: 'archivePasswordHint'.tr,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
child: CompactCheckbox(
|
||||
label: 'deleteAfterExtract'.tr,
|
||||
value: _deleteAfterExtractController
|
||||
.value ?? false,
|
||||
onChanged: (bool? value) {
|
||||
_deleteAfterExtractController
|
||||
.value = value ?? false;
|
||||
},
|
||||
textStyle: const TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -798,7 +870,10 @@ class CreateView extends GetView<CreateController> {
|
||||
Object? parseReqOptsExtra() {
|
||||
return OptsExtraHttp()
|
||||
..connections = int.tryParse(_connectionsController.text) ?? 0
|
||||
..autoTorrent = true;
|
||||
..autoTorrent = true
|
||||
..autoExtract = _autoExtractController.value ?? false
|
||||
..archivePassword = _archivePasswordController.text
|
||||
..deleteAfterExtract = _deleteAfterExtractController.value ?? false;
|
||||
}
|
||||
|
||||
String _hitText() {
|
||||
|
||||
@@ -148,6 +148,46 @@ class SettingView extends GetView<SettingController> {
|
||||
);
|
||||
});
|
||||
|
||||
// Archive auto extract configuration
|
||||
final buildAutoExtract = _buildConfigItem('autoExtract', () {
|
||||
return appController.downloaderConfig.value.archive.autoExtract
|
||||
? 'on'.tr
|
||||
: 'off'.tr;
|
||||
}, (Key key) {
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Switch(
|
||||
value: appController.downloaderConfig.value.archive.autoExtract,
|
||||
onChanged: (bool value) async {
|
||||
appController.downloaderConfig.update((val) {
|
||||
val!.archive.autoExtract = value;
|
||||
});
|
||||
await debounceSave();
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// Archive delete after extract configuration
|
||||
final buildDeleteAfterExtract = _buildConfigItem('deleteAfterExtract', () {
|
||||
return appController.downloaderConfig.value.archive.deleteAfterExtract
|
||||
? 'on'.tr
|
||||
: 'off'.tr;
|
||||
}, (Key key) {
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Switch(
|
||||
value: appController.downloaderConfig.value.archive.deleteAfterExtract,
|
||||
onChanged: (bool value) async {
|
||||
appController.downloaderConfig.update((val) {
|
||||
val!.archive.deleteAfterExtract = value;
|
||||
});
|
||||
await debounceSave();
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// Download categories configuration
|
||||
buildDownloadCategories() {
|
||||
final categories = downloaderCfg.value.extra.downloadCategories
|
||||
@@ -1315,6 +1355,14 @@ class SettingView extends GetView<SettingController> {
|
||||
buildAutoStartup(),
|
||||
]),
|
||||
)),
|
||||
Text('archives'.tr),
|
||||
Card(
|
||||
child: Column(
|
||||
children: _addDivider([
|
||||
buildAutoExtract(),
|
||||
buildDeleteAfterExtract(),
|
||||
]),
|
||||
)),
|
||||
const Text('HTTP'),
|
||||
Card(
|
||||
child: Column(
|
||||
|
||||
Reference in new issue
Block a user