Skip to content

Commit

Permalink
0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Apr 29, 2023
1 parent 95e9be5 commit 5243b2e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 35 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/tauri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}

- uses: actions/[email protected]
with:
path: |
Expand All @@ -42,18 +43,35 @@ jobs:
key:
${{ runner.os }}-cargo-${{
hashFiles('./src-tauri/Cargo.toml') }}

- uses: actions/[email protected]
id: download
with:
name: .-node-18-dist
- uses: jossef/action-set-json-field@v2

- uses: jossef/[email protected]
with:
file: ./src-tauri/tauri.conf.json
field: build.distDir
value: ${{steps.download.outputs.download-path}}\dist

- uses: actions-rs/[email protected]
with:
command: build
args:
--release --all-features --manifest-path
./src-tauri/Cargo.toml

- uses: actions/[email protected]
with:
name:
.-tauri-${{ matrix.toolchain
}}-${{runner.os}}-target-release
path: ./src-tauri/target/release/*.exe

- uses: actions/[email protected]
with:
name:
.-tauri-${{ matrix.toolchain
}}-${{runner.os}}-target-release-bundle-msi
path: ./src-tauri/target/release/bundle/msi/*.msi
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.0.5

- Fixes scale when using multiple monitors

# 0.0.4

- Adds multi-monitor setup
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "roundedcorners-app",
"version": "0.0.4",
"type": "module",
"version": "0.0.5",
"repository": {
"type": "git",
"url": "https://github.com/roundedcorners/app.git"
Expand Down
8 changes: 2 additions & 6 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "roundedcorners"
version = "0.0.4"
version = "0.0.5"

[build-dependencies]
tauri-build = { version = "1.2.1", features = [] }
Expand All @@ -9,11 +9,7 @@ tauri-build = { version = "1.2.1", features = [] }
regex = "1.8.1"
serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96"
tauri = { version = "1.2.4", features = [
"system-tray",
"window-set-ignore-cursor-events",
"window-set-position"
] }
tauri = { version = "1.2.4", features = ["system-tray", "window-set-ignore-cursor-events", "window-set-position"] }
tauri-plugin-store = { git = "https://github.com/roundedcorners/plugins-workspace", branch = "dev" }

[features]
Expand Down
77 changes: 52 additions & 25 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ fn main() {
StoreBuilder::new(app.app_handle(), PathBuf::from("settings.json")).build();

if let Err(_e) = store.load() {
store.save().unwrap();
store.save().expect("Error! Could not initialize settings.");
};

store.load().unwrap();
store.load().expect("Error! Could not get settings.");

for (key, value) in defaults {
if let None = store.get(key.as_ref()) {
Expand All @@ -73,12 +73,12 @@ fn main() {
.as_object()
.and_then(|object| object.values().next())),
)
.unwrap();
.expect("Error! Could not set defaults.");
}
}

store.save().unwrap();
store.load().unwrap();
store.save().expect("Error! Could not save settings.");
store.load().expect("Error! Could not get settings.");

let mut init_script = String::from(r#"window.settings = {};"#);

Expand All @@ -102,9 +102,21 @@ fn main() {
.build()
.expect("Error! Failed to create a sample window.");

for monitor in sample_window.available_monitors().unwrap() {
let label =
Regex::new(r"[^a-zA-Z0-9\s]").unwrap().replace_all(monitor.name().unwrap(), "");
let scale_factor: f64 = sample_window
.primary_monitor()
.expect("Error! No monitors found.")
.expect("Error! Could not get primary monitor.")
.scale_factor();

for monitor in
sample_window.available_monitors().expect("Error! Failed to get monitors.")
{
let label = Regex::new(r"[^a-zA-Z0-9\s]")
.unwrap()
.replace_all(monitor.name().expect("Error! Could not get monitor name."), "");

let monitor_size = monitor.size().to_logical::<i32>(scale_factor);
let monitor_position = monitor.position().to_logical::<i32>(scale_factor);

let window =
WindowBuilder::new(app, label, tauri::WindowUrl::App("index.html".into()))
Expand All @@ -120,23 +132,23 @@ fn main() {
.title("")
.transparent(true)
.visible(false)
.inner_size(monitor.size().width.into(), monitor.size().height.into())
.position(monitor.position().x.into(), monitor.position().y.into())
.inner_size(monitor_size.width.into(), monitor_size.height.into())
.position(monitor_position.x.into(), monitor_position.y.into())
.initialization_script(&init_script)
.build()
.expect("Error! Failed to create a window.");

window.set_cursor_grab(false).unwrap();
window.set_cursor_grab(false).expect("Error! Could not set cursor grab.");

if let Some(hidden) = store.get("hidden") {
if hidden != true {
window.show().unwrap();
window.show().expect("Error! Could not show window");
}
}
}

sample_window.hide().unwrap();
sample_window.close().unwrap();
sample_window.hide().expect("Error! Could not hide sample window");
sample_window.close().expect("Error! Could not close sample window");

Ok(())
})
Expand All @@ -159,7 +171,7 @@ fn main() {
let mut store =
StoreBuilder::new(app.app_handle(), PathBuf::from("settings.json")).build();

store.load().unwrap();
store.load().expect("Error! Could not get settings.");

let mut size = match store.get("size") {
Some(size) => size.as_i64().unwrap_or(23),
Expand Down Expand Up @@ -189,38 +201,53 @@ fn main() {
_ => {}
}

store.insert("size".to_string(), json!(size)).unwrap();
store.insert("mode".to_string(), json!(mode)).unwrap();
store.insert("hidden".to_string(), json!(hidden)).unwrap();
store
.insert("size".to_string(), json!(size))
.expect("Error! Could not preserve size.");
store
.insert("mode".to_string(), json!(mode))
.expect("Error! Could not preserve mode.");
store
.insert("hidden".to_string(), json!(hidden))
.expect("Error! Could not preserve display.");

store.save().unwrap();
store.save().expect("Error! Could not save settings.");

app.windows().into_iter().for_each(|(_label, window)| {
if let Some(size) = store.get("size") {
window
.emit(
"size",
Payload { message: Message::Size(size.as_i64().unwrap()) },
Payload {
message: Message::Size(
size.as_i64()
.expect("Error! Could not get size from settings."),
),
},
)
.unwrap();
.expect("Error! Could not set size to window.");
}

if let Some(mode) = store.get("mode") {
window
.emit(
"mode",
Payload {
message: Message::Mode(mode.as_str().unwrap().to_owned()),
message: Message::Mode(
mode.as_str()
.expect("Error! Could not get mode from settings.")
.to_owned(),
),
},
)
.unwrap();
.expect("Error! Could not set mode to window.");
}

if let Some(hidden) = store.get("hidden") {
if hidden == true {
window.hide().unwrap();
window.hide().expect("Error! Could not hide windows.");
} else {
window.show().unwrap();
window.show().expect("Error! Could not show windows.");
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "Rounded Corners",
"version": "0.0.4"
"version": "0.0.5"
},
"tauri": {
"allowlist": {
Expand Down

0 comments on commit 5243b2e

Please sign in to comment.