feat: initial implementation of qsv Easy installer for Windows

This commit is contained in:
rzmk 2025-04-16 12:38:57 -04:00
commit f52c2e04fc
No known key found for this signature in database
39 changed files with 6712 additions and 0 deletions

7
src-tauri/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas

5838
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

28
src-tauri/Cargo.toml Normal file
View file

@ -0,0 +1,28 @@
[package]
name = "qsv-easy-installer"
version = "0.1.0"
description = "An easy installer for Windows devices to download the latest release of qsv and access it from PATH."
authors = ["datHere"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "qsv_easy_installer_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
tempfile = "3.19.1"
zip = "2.6.1"
winreg = "0.55.0"

3
src-tauri/build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View file

@ -0,0 +1,10 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"opener:default"
]
}

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
src-tauri/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

56
src-tauri/src/lib.rs Normal file
View file

@ -0,0 +1,56 @@
use tauri::Manager;
use tempfile::tempfile;
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
#[tauri::command]
fn run_path_update(app_handle: tauri::AppHandle) {
// Get app local data dir path
let app_local_data_dir = app_handle.path().app_local_data_dir().unwrap();
// Download qsv to bin dir if it doesn't exist and overwrite any existing qsv
// Get the version of qsv
let latest_release_endpoint = "https://api.github.com/repos/dathere/qsv/releases/latest";
let client = reqwest::blocking::Client::new();
let res = client
.get(latest_release_endpoint)
.header(reqwest::header::USER_AGENT, "qsv easy installer")
.send()
.unwrap()
.json::<serde_json::Value>()
.unwrap();
let release_version = res.get("name").unwrap().as_str().unwrap();
// Download the zip file temporarily then extract the relevant qsvp file (we use qsvp instead of qsv for the broadest compatibility)
let zip_download_url = format!("https://github.com/dathere/qsv/releases/download/{release_version}/qsv-{release_version}-x86_64-pc-windows-msvc.zip");
let mut temp_zip_file = tempfile().unwrap();
reqwest::blocking::get(zip_download_url)
.unwrap()
.copy_to(&mut temp_zip_file)
.unwrap();
let mut zip = zip::ZipArchive::new(temp_zip_file).unwrap();
let mut qsvp = zip.by_name("qsvp.exe").unwrap();
// Create a bin folder in app_local_data_dir if it doesn't exist
let bin_dir = app_local_data_dir.join("bin");
if !std::path::Path::exists(&bin_dir) {
std::fs::create_dir(&bin_dir).unwrap();
}
// Write qsvp.exe to bin/qsv.exe
let mut qsv_file = std::fs::File::create(bin_dir.join("qsv.exe")).unwrap();
std::io::copy(&mut qsvp, &mut qsv_file).unwrap();
// Add the bin dir to PATH
let bin_dir_str = bin_dir.to_str().unwrap();
// Get the current PATH
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let (reg_key, _) = hkcu.create_subkey("Environment").unwrap();
let path_var: String = reg_key.get_value("Path").unwrap();
// Add bin dir to PATH
let updated_path_var = format!("{bin_dir_str};{path_var}");
reg_key.set_value("Path", &updated_path_var).unwrap();
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![run_path_update])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

6
src-tauri/src/main.rs Normal file
View file

@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
qsv_easy_installer_lib::run()
}

35
src-tauri/tauri.conf.json Normal file
View file

@ -0,0 +1,35 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "qsv-easy-installer",
"version": "0.1.0",
"identifier": "com.qsv-easy-installer.app",
"build": {
"beforeDevCommand": "bun run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "bun run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "qsv Easy installer for Windows",
"width": 800,
"height": 600
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}