Skip to content

Commit

Permalink
[*] update slint-ui to v1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Jul 18, 2024
1 parent da77cb4 commit cf36a5b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 41 deletions.
23 changes: 9 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rssbox"
version = "0.9.0"
version = "1.0.0"
edition = "2021"

[dependencies]
Expand All @@ -9,47 +9,42 @@ rss = "2.0"
md5 = "0.7"
toml = "0.8"
rand = "0.8"
slint = "1.7"
chrono = "0.4"
anyhow = "1.0"
html2text = "0.6"
webbrowser = "0.8"
serde_json = "1.0"
lazy_static = "1.4"
once_cell = "1.19"
atom_syndication = "0.12"

opml = { version = "1.1", optional = true }
uuid = { version = "1.6", features = ["v4"] }
tokio = { version = "1.35", features = ["full"] }
serde = { version = "1.0", features = ["serde_derive"] }
clap = { version = "4.5", features = ["derive"], optional = true }
reqwest = { version = "0.11", features = ["json", "socks"] }
sqlx = { version = "0.7", features = ["runtime-tokio", "sqlite"] }

opml = { version = "1.1", optional = true }
clap = { version = "4.5", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "android"))'.dependencies]
slint = "1.6"
clipboard = "0.5"
env_logger = "0.10"
platform-dirs = "0.3"
reqwest = { version = "0.11", features = ["json", "socks"] }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13"
terminal-clipboard = "0.4"
slint = { version = "1.6", features = ["backend-android-activity-06"] }
reqwest = { version = "0.11", features = [
"native-tls-vendored",
"json",
"socks",
] }

[build-dependencies]
cmd_lib = "1.9"
slint-build = "1.6"
slint-build = "1.7"

[target.'cfg(target_os = "windows")'.build-dependencies]
embed-resource = "2.4"

[features]
default = []
default = ["slint/backend-android-activity-06", "reqwest/native-tls-vendored"]
desktop = []
tool-gen-rss = ["dep:opml", "dep:clap"]

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

pwd=${shell pwd}
build-evn=SLINT_STYLE=material RUSTFLAGS="--remap-path-prefix $(HOME)=/home --remap-path-prefix $(pwd)=/build"
build-evn=SLINT_STYLE=material
run-evn=RUST_LOG=error,warn,info,debug,sqlx=off,reqwest=off,html2text=off
version=`git describe --tags --abbrev=0`

Expand Down Expand Up @@ -47,6 +47,9 @@ debug-mold:
debug-local:
$(run-evn) ./target/debug/rssbox-desktop

release-local:
$(run-evn) ./target/release/rssbox-desktop

build-desktop-release:
$(build-evn) $(run-evn) cargo build --release --bin rssbox-desktop --features=desktop

Expand Down
5 changes: 2 additions & 3 deletions src/config/conf.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use super::data::{self, Config};
use anyhow::Result;
use log::debug;
use once_cell::sync::Lazy;
use std::{fs, path::PathBuf, sync::Mutex};

lazy_static! {
pub static ref CONFIG: Mutex<Config> = Mutex::new(Config::default());
}
pub static CONFIG: Lazy<Mutex<Config>> = Lazy::new(|| Mutex::new(Config::default()));

#[cfg(not(target_os = "android"))]
use platform_dirs::AppDirs;
Expand Down
5 changes: 2 additions & 3 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use sqlx::migrate::MigrateDatabase;
use sqlx::{
Expand All @@ -20,9 +21,7 @@ pub struct ComEntry {
pub data: String,
}

lazy_static! {
static ref POOL: Mutex<Option<Pool<Sqlite>>> = Mutex::new(None);
}
static POOL: Lazy<Mutex<Option<Pool<Sqlite>>>> = Lazy::new(|| Mutex::new(None));

fn pool() -> Pool<Sqlite> {
POOL.lock().unwrap().clone().unwrap()
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

slint::include_modules!();

#[macro_use]
extern crate lazy_static;

use chrono::Utc;
use slint::{Timer, TimerMode};
use std::{
Expand Down Expand Up @@ -120,13 +117,10 @@ async fn android_main(app: slint::android::AndroidApp) {

#[cfg(not(target_os = "android"))]
pub async fn desktop_main() {
use crate::slint_generatedAppWindow::Theme;

log::debug!("start...");

ui_before().await;
let ui = AppWindow::new().unwrap();
ui.global::<Theme>().set_default_height(800.0);
ui_after(&ui);

let _timer = sync_rss_timer(&ui);
Expand Down
5 changes: 2 additions & 3 deletions ui/appwindow.slint
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { Toast, IconsDialog, IconsDialogSetting, OkCancelDialogV2, Blanket, Lang
export component AppWindow inherits Window {
default-font-size: Theme.default-font-size;
default-font-family: Theme.default-font-family;

// uncomment when building desktop app
// height: Theme.default-height;
preferred-width: Theme.default-height;
preferred-height: Theme.default-height;

background: Theme.base-background;
icon: Icons.brand;
Expand Down
21 changes: 10 additions & 11 deletions ui/panel/bodyer/setting.slint
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,10 @@ component About inherits SettingDetail {
component Help inherits SettingDetail {
title: Logic.tr(Store.is-cn, "帮 助");

Flickable {
SettingDetailInner {
Label {
text: Store.is-cn ? Store.help-dialog.text-cn : Store.help-dialog.text-en;
wrap: word-wrap;
}
SettingDetailInner {
Label {
text: Store.is-cn ? Store.help-dialog.text-cn : Store.help-dialog.text-en;
wrap: word-wrap;
}
}
}
Expand Down Expand Up @@ -890,22 +888,23 @@ export component Setting inherits Rectangle {
body.current-setting-detail-index = SettingDetailIndex.Home;
}
}
}

if !body.visible: Rectangle {
if body.current-setting-detail-index == SettingDetailIndex.About: About {
About {
visible: body.current-setting-detail-index == SettingDetailIndex.About;
back => {
body.current-setting-detail-index = SettingDetailIndex.Home;
}
}

if body.current-setting-detail-index == SettingDetailIndex.Help: Help {
Help {
visible: body.current-setting-detail-index == SettingDetailIndex.Help;
back => {
body.current-setting-detail-index = SettingDetailIndex.Home;
}
}

if body.current-setting-detail-index == SettingDetailIndex.Donate: Donate {
Donate {
visible: body.current-setting-detail-index == SettingDetailIndex.Donate;
back => {
body.current-setting-detail-index = SettingDetailIndex.Home;
}
Expand Down

0 comments on commit cf36a5b

Please sign in to comment.