Skip to content

Commit

Permalink
Create config mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Barafu committed Oct 21, 2024
1 parent e4b649e commit ee3931f
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@
"program": "${workspaceFolder}/src-tauri/target/debug/dream_spinner.exe",
"preLaunchTask": "Project: cargo build devel"
},
{
"type": "lldb",
"name": "Tauri Development Settings",
"request": "launch",
"program": "${workspaceFolder}/src-tauri/target/debug/dream_spinner.exe",
"args": ["/c"],
"preLaunchTask": "Project: cargo build devel"
},
{
"type": "lldb",
"name": "Tauri Release",
"request": "launch",
"program": "${workspaceFolder}/src-tauri/target/release/dream_spinner.exe",
"preLaunchTask": "Project: full release"
},
{
"type": "lldb",
"name": "Tauri Release Settings",
"request": "launch",
"program": "${workspaceFolder}/src-tauri/target/release/dream_spinner.exe",
"args": ["/c"],
"preLaunchTask": "Project: full release"
}
]
}
4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ incremental = true # Compile your binary in smaller steps.

[profile.release]
codegen-units = 1 # Allows LLVM to perform better optimization.
lto = true # Enables link-time-optimizations.
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
lto = false # Enables link-time-optimizations.
opt-level = 2 # Prioritizes small binary size. Use `3` if you prefer speed.
panic = "abort" # Higher performance by disabling panic handlers.
strip = true # Ensures debug symbols are removed.

2 changes: 1 addition & 1 deletion src-tauri/src/dream_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl DreamRunner {
Ok(s)
}

pub fn initialise(&mut self) -> Result<()> {
pub fn launch(&mut self) -> Result<()> {
use std::result::Result::Ok; // Block anyhow's Result for the `context` macro
const FULLSCREEN: bool = true;
const RUNNER_PAGE: &str = "index.html";
Expand Down
7 changes: 5 additions & 2 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mod app_settings;
mod dream_runner;
mod parse_cli;
mod settings_window;

use anyhow::Result;

Expand All @@ -28,12 +29,14 @@ pub fn run() -> Result<()> {

fn show_dream() -> Result<()> {
let mut dr = dream_runner::DreamRunner::new()?;
dr.initialise()?;
dr.launch()?;
Ok(())
}

fn show_config() -> Result<()> {
todo!();
let mut sw = settings_window::SettingsWindow::new();
sw.launch()?;
Ok(())
}

fn show_preview(_handle: usize) -> Result<()> {
Expand Down
32 changes: 32 additions & 0 deletions src-tauri/src/settings_window.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use anyhow::Result;

#[derive(Debug)]
pub struct SettingsWindow {}

impl SettingsWindow {
pub fn new() -> Self {
SettingsWindow {}
}

pub fn launch(&mut self) -> Result<()> {
const SETTINGS_PAGE: &str = "/src/settings.html";
use std::result::Result::Ok; // Block anyhow's Result for the `context` macro
tauri::Builder::default()
.setup(move |app| {
// Build the settings window
let _window = tauri::WebviewWindowBuilder::new(
app,
"primary",
tauri::WebviewUrl::App(SETTINGS_PAGE.into()),
)
.visible(true)
.build()?;
std::result::Result::Ok(())
})
.plugin(tauri_plugin_process::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");

Ok(())
}
}
14 changes: 14 additions & 0 deletions src/settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="#" />
<title>DreamSpinner Settings</title>
<script type="module" src="/src/settings.ts" defer></script>
</head>

<body>
<h1>Settings</h1>
</body>
</html>
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.addEventListener("DOMContentLoaded", () => {});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
Expand Down

0 comments on commit ee3931f

Please sign in to comment.