From d0a20d8c18fdf686a3169aadad6040937e0e8949 Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Wed, 15 Feb 2023 17:02:18 +0900 Subject: [PATCH 1/2] improved files ui --- src/app/files/files.component.html | 62 ++++++++++------- src/app/files/files.component.scss | 24 +++---- src/app/files/files.component.ts | 107 ++++++++++++++++++++++++----- 3 files changed, 138 insertions(+), 55 deletions(-) diff --git a/src/app/files/files.component.html b/src/app/files/files.component.html index 9997a1ea..43114a0e 100644 --- a/src/app/files/files.component.html +++ b/src/app/files/files.component.html @@ -1,19 +1,39 @@ -
-
-
@@ -27,17 +47,9 @@
- + + {{items.length}} {{items.length === 1 ? 'item' : 'items'}} +
-
+ diff --git a/src/app/files/files.component.scss b/src/app/files/files.component.scss index 78614db1..4fb8dca1 100644 --- a/src/app/files/files.component.scss +++ b/src/app/files/files.component.scss @@ -1,14 +1,14 @@ -.stat-bar { - height: 40px; - +.breadcrumb-bar { nav { - min-width: 100%; + width: fit-content; + --bs-breadcrumb-divider: ''; } +} + +.stat-bar { + height: 30px; .breadcrumb { - width: max-content; - min-width: 100%; - padding: 4px 8px; flex-wrap: nowrap; align-items: center; } @@ -16,12 +16,8 @@ .breadcrumb-item { position: relative; } +} - .breadcrumb-item + .breadcrumb-item::before { - height: 100%; - display: flex; - flex-direction: row; - align-items: center; - justify-content: center; - } +.loading, .loading * { + cursor: progress; } diff --git a/src/app/files/files.component.ts b/src/app/files/files.component.ts index f2ad73d7..baf8048e 100644 --- a/src/app/files/files.component.ts +++ b/src/app/files/files.component.ts @@ -1,4 +1,4 @@ -import {Component, OnDestroy, OnInit} from '@angular/core'; +import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core'; import {DeviceManagerService} from "../core/services"; import {Device, FileItem, FileSession} from "../types"; import {BehaviorSubject, Observable, Subject, Subscription} from "rxjs"; @@ -17,7 +17,7 @@ class FilesState { public breadcrumb: string[]; constructor(public dir: string, public items?: FileItem[], public error?: Error) { - this.breadcrumb = dir.split('/'); + this.breadcrumb = dir === '/' ? [''] : dir.split('/'); } } @@ -29,7 +29,7 @@ class FilesState { export class FilesComponent implements OnInit, OnDestroy { device: Device | null = null; session: FileSession | null = null; - pwd: string | null = null; + history?: HistoryStack; home: string | null = null; files$: Observable; @@ -54,7 +54,8 @@ export class FilesComponent implements OnInit, OnDestroy { if (selected) { this.home = await this.homeDir(); } - await this.cd(this.home ?? '/media/developer', true); + this.history = new HistoryStack(this.home ?? '/media/developer'); + await this.cd(this.home ?? '/media/developer'); }); } @@ -66,7 +67,7 @@ export class FilesComponent implements OnInit, OnDestroy { return (this.selectedItems?.length ?? 0) > 0; } - async cd(dir: string, showProgress = false): Promise { + async cd(dir: string, pushHistory: boolean = false): Promise { if (!this.device) return; console.log('cd', dir); this.filesSubject.next(new FilesState(dir)); @@ -77,11 +78,29 @@ export class FilesComponent implements OnInit, OnDestroy { this.filesSubject.next(new FilesState(dir, undefined, e as Error)); return; } - this.pwd = dir; + if (pushHistory) { + this.history?.push(dir); + } this.filesSubject.next(new FilesState(dir, list.sort(this.compareName), undefined)); this.selectedItems = null; } + async navBack(): Promise { + const path = this.history?.back(); + if (!path) { + return; + } + await this.cd(path); + } + + async navForward(): Promise { + const path = this.history?.forward(); + if (!path) { + return; + } + await this.cd(path); + } + async homeDir(): Promise { const def = '/media/developer'; if (!this.device) return def; @@ -104,10 +123,11 @@ export class FilesComponent implements OnInit, OnDestroy { } async openItem(file: FileItem): Promise { - if (!this.pwd) return; + const cwd = this.history?.current; + if (!cwd) return; switch (file.type) { case 'd': { - await this.cd(path.join(this.pwd, file.filename), true); + await this.cd(path.join(cwd, file.filename), true); break; } case '-': { @@ -121,7 +141,8 @@ export class FilesComponent implements OnInit, OnDestroy { } private async openFile(file: FileItem) { - if (!this.pwd || !this.device) return; + const cwd = this.history?.current; + if (!cwd || !this.device) return; const progress = ProgressDialogComponent.open(this.modalService); let result = false; let tempPath: string | null = null; @@ -145,7 +166,8 @@ export class FilesComponent implements OnInit, OnDestroy { } async downloadFiles(files: FileItem[] | null): Promise { - if (!this.pwd || !this.device) return; + const cwd = this.history?.current; + if (!cwd || !this.device) return; if (!files || !files.length) return; if (files.length == 1) { return await this.downloadFile(files[0]); @@ -178,7 +200,8 @@ export class FilesComponent implements OnInit, OnDestroy { } async removeFiles(files: FileItem[] | null): Promise { - if (!this.pwd || !this.device) return; + const cwd = this.history?.current; + if (!cwd || !this.device) return; if (!files || !files.length) return; const answer = await MessageDialogComponent.open(this.modalService, { title: 'Are you sure to delete selected files?', @@ -209,12 +232,13 @@ export class FilesComponent implements OnInit, OnDestroy { break; } } - await this.cd(this.pwd, false); + await this.cd(cwd); progress.dismiss(); } private async downloadFile(file: FileItem): Promise { - if (!this.pwd || !this.device) return; + const cwd = this.history?.current; + if (!cwd || !this.device) return; const returnValue = await showSaveDialog({defaultPath: file.filename}); if (!returnValue) return; const progress = ProgressDialogComponent.open(this.modalService); @@ -236,12 +260,13 @@ export class FilesComponent implements OnInit, OnDestroy { } async uploadFiles(): Promise { - if (!this.pwd || !this.device) return; + const cwd = this.history?.current; + if (!cwd || !this.device) return; const returnValue = await showOpenDialog({multiple: true}); if (!returnValue) return; const progress = ProgressDialogComponent.open(this.modalService); try { - await this.session!.uploadBatch(Array.isArray(returnValue) ? returnValue : [returnValue], this.pwd, async (name, e) => { + await this.session!.uploadBatch(Array.isArray(returnValue) ? returnValue : [returnValue], cwd, async (name, e) => { const result = await MessageDialogComponent.open(this.modalService, { title: `Failed to upload file ${name}`, message: e.message ?? String(e), @@ -253,7 +278,7 @@ export class FilesComponent implements OnInit, OnDestroy { if (result == null) throw e; return result; }); - await this.cd(this.pwd, false); + await this.cd(cwd); } finally { progress.dismiss(); } @@ -265,3 +290,53 @@ export class FilesComponent implements OnInit, OnDestroy { } } + +class HistoryStack { + private stack: string[] = []; + private cursor: number; + + constructor(initial: string) { + this.stack.push(initial); + this.cursor = 0; + } + + get current(): string { + return this.stack[this.cursor]; + } + + get canForward(): boolean { + return this.cursor < this.stack.length - 1; + } + + get canBack(): boolean { + return this.cursor > 0; + } + + push(path: string) { + this.stack.splice(this.cursor + 1); + this.stack.push(path); + if (this.stack.length > 10) { + this.stack.splice(0, this.stack.length - 10); + this.cursor = 9; + } else { + this.cursor += 1; + } + } + + back(): string | null { + if (this.cursor == 0) { + return null; + } + this.cursor -= 1; + return this.stack[this.cursor] ?? null; + } + + forward(): string | null { + if (this.cursor >= this.stack.length - 1) { + return null; + } + this.cursor += 1; + return this.stack[this.cursor] ?? null; + } + +} From 944fee939539cb754ba42604fe2c28a5166c8c15 Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Wed, 15 Feb 2023 17:47:57 +0900 Subject: [PATCH 2/2] refocus window if launched again --- src-tauri/Cargo.lock | 144 +++++++++++++++++++++++++++----------- src-tauri/Cargo.toml | 1 + src-tauri/src/main.rs | 22 ++++-- src-tauri/tauri.conf.json | 9 ++- 4 files changed, 125 insertions(+), 51 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ddc55043..ec653448 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -24,7 +24,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cipher", "cpufeatures", ] @@ -78,6 +78,7 @@ name = "app" version = "0.1.0" dependencies = [ "async-trait", + "dialog", "env_logger", "file-mode", "hex", @@ -449,6 +450,12 @@ dependencies = [ "smallvec", ] +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -461,7 +468,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7fc89c7c5b9e7a02dfe45cd2367bae382f9ed31c61ca8debe5f827c420a2f08" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cipher", "cpufeatures", ] @@ -594,7 +601,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -603,7 +610,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -613,7 +620,7 @@ version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -757,6 +764,16 @@ dependencies = [ "syn", ] +[[package]] +name = "dialog" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736bab36d647d14c985725a57a4110a1182c6852104536cd42f1c97e96d29bf0" +dependencies = [ + "dirs 2.0.2", + "rpassword", +] + [[package]] name = "digest" version = "0.9.0" @@ -777,6 +794,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +dependencies = [ + "cfg-if 0.1.10", + "dirs-sys", +] + [[package]] name = "dirs" version = "4.0.0" @@ -792,7 +819,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-sys-next", ] @@ -804,7 +831,7 @@ checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -815,7 +842,7 @@ checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -880,7 +907,7 @@ version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -925,7 +952,7 @@ checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -978,7 +1005,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "windows-sys 0.45.0", @@ -1248,7 +1275,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -1259,7 +1286,7 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.11.0+wasi-snapshot-preview1", ] @@ -1301,7 +1328,7 @@ dependencies = [ "gobject-sys", "libc", "system-deps 6.0.3", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1699,7 +1726,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1805,6 +1832,16 @@ dependencies = [ "treediff", ] +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "kuchiki" version = "0.8.1" @@ -1860,7 +1897,7 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1869,7 +1906,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "generator", "scoped-tls", "serde", @@ -2030,7 +2067,7 @@ checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ "autocfg", "bitflags", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset", "pin-utils", @@ -2058,7 +2095,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ "overload", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2202,7 +2239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", @@ -2313,7 +2350,7 @@ version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", @@ -2520,7 +2557,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" dependencies = [ "autocfg", - "cfg-if", + "cfg-if 1.0.0", "libc", "log", "wepoll-ffi", @@ -2544,7 +2581,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "opaque-debug", "universal-hash", @@ -2777,7 +2814,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2841,6 +2878,17 @@ dependencies = [ "windows 0.37.0", ] +[[package]] +name = "rpassword" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37473170aedbe66ffa3ad3726939ba677d83c646ad4fd99e5b4bc38712f45ec" +dependencies = [ + "kernel32-sys", + "libc", + "winapi 0.2.8", +] + [[package]] name = "russh" version = "0.36.1" @@ -2884,7 +2932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3fdf036c2216b554053d19d4af45c1722d13b00ac494ea19825daf4beac034e" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2901,7 +2949,7 @@ dependencies = [ "cbc", "ctr", "data-encoding", - "dirs", + "dirs 4.0.0", "ed25519-dalek", "futures", "hmac", @@ -3188,7 +3236,7 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest 0.10.6", ] @@ -3200,7 +3248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest 0.9.0", "opaque-debug", @@ -3212,7 +3260,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest 0.10.6", ] @@ -3269,7 +3317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3653,12 +3701,12 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "fastrand", "libc", "redox_syscall", "remove_dir_all", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3713,7 +3761,7 @@ version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "once_cell", ] @@ -3862,7 +3910,7 @@ version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3952,7 +4000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" dependencies = [ "tempfile", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -4120,7 +4168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi", + "winapi 0.3.9", "winapi-util", ] @@ -4152,7 +4200,7 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -4177,7 +4225,7 @@ version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -4316,6 +4364,12 @@ dependencies = [ "cc", ] +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.9" @@ -4326,6 +4380,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -4338,7 +4398,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -4553,7 +4613,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -4658,7 +4718,7 @@ dependencies = [ "async-trait", "byteorder", "derivative", - "dirs", + "dirs 4.0.0", "enumflags2", "event-listener", "futures-core", @@ -4675,7 +4735,7 @@ dependencies = [ "static_assertions", "tracing", "uds_windows", - "winapi", + "winapi 0.3.9", "zbus_macros", "zbus_names", "zvariant", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 4091410e..50374bcb 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -34,6 +34,7 @@ sha2 = "0.10.6" hex = "0.4.3" file-mode = "0.1.2" posix-errors = "1.2.1" +dialog = "0.3.0" [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e51d954a..4ab12145 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -7,18 +7,23 @@ extern crate core; use crate::device_manager::DeviceManager; use crate::session_manager::SessionManager; +use dialog::DialogBox; +use tauri::Manager; mod device_manager; -mod plugins; -mod session_manager; mod error; +mod plugins; mod remote_files; +mod session_manager; fn main() { env_logger::init(); - tauri::Builder::default() + let result = tauri::Builder::default() .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { - println!("{}, {argv:?}, {cwd}", app.package_info().name); + if let Some(wnd) = app.get_window("main") { + wnd.unminimize().unwrap_or(()); + wnd.set_focus().unwrap_or(()); + } })) .plugin(plugins::device::plugin("device-manager")) .plugin(plugins::cmd::plugin("remote-command")) @@ -27,6 +32,11 @@ fn main() { .plugin(plugins::devmode::plugin("dev-mode")) .manage(DeviceManager::default()) .manage(SessionManager::default()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + .run(tauri::generate_context!()); + if let Err(e) = result { + dialog::Message::new("Unexpected error occurred") + .title("webOS Dev Manager") + .show() + .expect("Unexpected error occurred while processing unexpected error :("); + } } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cbcae72e..b079ba9a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -81,11 +81,14 @@ }, "windows": [ { - "fullscreen": false, + "label": "main", + "title": "webOS Dev Manager", + "width": 1024, "height": 720, + "minWidth": 800, + "minHeight": 600, "resizable": true, - "title": "webOS Dev Manager", - "width": 1024 + "fullscreen": false } ] }