[desktop] Fix merge issues

This commit is contained in:
Vladimir Stoilov
2024-09-05 11:21:19 +03:00
parent 701505ae75
commit 8c6eb04292
7 changed files with 291 additions and 402 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,7 @@ tauri-plugin-log = "2.0.0-rc"
tauri-plugin-window-state = "2.0.0-rc"
tauri-cli = "2.0.0-rc.8"
clap = { version = "4" }
clap_lex = "0.7.2"
# General
serde_json = "1.0"

File diff suppressed because one or more lines are too long

View File

@@ -3072,3 +3072,4 @@
]
}
}
}

View File

@@ -3072,3 +3072,4 @@
]
}
}
}

View File

@@ -13,8 +13,8 @@ mod service;
mod xdg;
// App modules
mod config;
mod cli;
mod config;
mod portmaster;
mod traymenu;
mod window;
@@ -126,32 +126,8 @@ fn main() {
let cli_args = cli::parse(std::env::args());
let mut cli = CliArguments {
data: None,
log: LOG_LEVEL.to_string(),
background: false,
with_prompts: false,
with_notifications: false,
};
if let Some(data) = matches.get_one::<String>("data") {
cli.data = Some(data.to_string());
}
if let Some(log) = matches.get_one::<String>("log") {
cli.log = log.to_string();
}
if let Some(value) = matches.get_one::<bool>("with_prompts") {
cli.with_prompts = *value;
}
if let Some(value) = matches.get_one::<bool>("with_notifications") {
cli.with_notifications = *value;
}
#[cfg(target_os = "linux")]
let log_target = if let Some(data_dir) = cli.data {
let log_target = if let Some(data_dir) = cli_args.data {
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Folder {
path: Path::new(&format!("{}/logs/app2", data_dir)).into(),
file_name: None,
@@ -168,17 +144,6 @@ fn main() {
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout)
};
let mut log_level = LOG_LEVEL;
match cli.log.as_ref() {
"off" => log_level = LevelFilter::Off,
"error" => log_level = LevelFilter::Error,
"warn" => log_level = LevelFilter::Warn,
"info" => log_level = LevelFilter::Info,
"debug" => log_level = LevelFilter::Debug,
"trace" => log_level = LevelFilter::Trace,
_ => {}
}
let app = tauri::Builder::default()
// Shell plugin for open_external support
.plugin(tauri_plugin_shell::init())

View File

@@ -1,18 +1,18 @@
use std::ops::Deref;
use std::sync::atomic::AtomicBool;
use std::sync::{Mutex, RwLock};
use std::sync::RwLock;
use std::{collections::HashMap, sync::atomic::Ordering};
use log::{debug, error};
use tauri::menu::{Menu, MenuItemKind};
use tauri::tray::{MouseButton, MouseButtonState};
use tauri::Runtime;
use tauri::{
image::Image,
menu::{MenuBuilder, MenuItemBuilder, PredefinedMenuItem, SubmenuBuilder},
tray::{TrayIcon, TrayIconBuilder},
Wry,
};
use tauri::{Manager, Runtime};
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
use crate::config;
@@ -91,13 +91,6 @@ fn get_red_icon() -> &'static [u8] {
const DARK_RED_ICON: &'static [u8] =
include_bytes!("../../../../assets/data/icons/pm_dark_red_64.png");
match get_theme_mode() {
const DARK_RED_ICON: &'static [u8] =
include_bytes!("../../../../assets/data/icons/pm_dark_red_64.png");
let mode = dark_light::detect();
match mode {
const DARK_RED_ICON: &[u8] = include_bytes!("../../../../assets/data/icons/pm_dark_red_64.png");
let mode = dark_light::detect();
match mode {
dark_light::Mode::Light => DARK_RED_ICON,
_ => LIGHT_RED_ICON,
}
@@ -142,10 +135,7 @@ pub fn setup_tray_menu(
.enabled(false)
.build(app)
.unwrap();
{
let mut button_ref = SPN_STATUS.lock()?;
*button_ref = Some(spn_status.clone());
}
// Setup SPN button
let spn_button = MenuItemBuilder::with_id(SPN_BUTTON_KEY, "Enable SPN")
.build(app)
@@ -496,7 +486,9 @@ pub async fn tray_handler(cli: PortAPI, app: tauri::AppHandle) {
}
}
}
update_spn_ui_state(false);
if let Some(menu) = app.menu() {
update_spn_ui_state(menu, false);
}
update_icon_color(&icon, IconColor::Red);
}
@@ -564,7 +556,6 @@ fn save_theme(app: &tauri::AppHandle, mode: dark_light::Mode) {
if let Some(menu) = app.menu() {
update_spn_ui_state(menu, false);
}
_ = icon.set_icon(Some(Image::from_bytes(get_red_icon()).unwrap()));
}
fn update_spn_ui_state<R: Runtime>(menu: Menu<R>, enabled: bool) {