Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 3610f69

Browse files
committed
Added release check.
1 parent 2453d9e commit 3610f69

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "icy_view"
3-
version = "0.4.3"
3+
version = "0.5.0"
44
edition = "2021"
55
description = "A fast ansi art viewer."
66
authors = ["Mike Krüger <mkrueger@posteo.de>"]
@@ -26,13 +26,16 @@ once_cell = "1.16.0"
2626
rust-embed = "8.0.0"
2727
egui-modal = "0.2.4"
2828
egui-notify = "0.10.0"
29-
29+
lazy_static = "1.4.0"
30+
3031
image = { version = "0.24", features = ["jpeg", "png", "gif", "bmp"] }
3132
view_library = { path ="./view_library" }
3233
icy_engine = { git = "https://github.com/mkrueger/icy_engine.git" }
3334
icy_engine_egui = { git ="https://github.com/mkrueger/icy_engine_egui" }
3435
#icy_engine = { path ="../icy_engine" }
3536
#icy_engine_egui = { path ="../icy_engine_egui" }
37+
github_release_check = "0.2.1"
38+
semver = "1.0.20"
3639

3740
[build-dependencies]
3841
winres = "0.1"

src/main.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ use std::path::PathBuf;
55
use clap::Parser;
66
use eframe::egui;
77
use view_library::MainWindow;
8+
use semver::Version;
9+
10+
lazy_static::lazy_static! {
11+
static ref VERSION: Version = Version::parse( env!("CARGO_PKG_VERSION")).unwrap();
12+
static ref DEFAULT_TITLE: String = format!("iCY VIEW {}", *crate::VERSION);
13+
}
14+
15+
lazy_static::lazy_static! {
16+
static ref LATEST_VERSION: Version = {
17+
let github = github_release_check::GitHub::new().unwrap();
18+
if let Ok(latest) = github.get_latest_version("mkrueger/icy_view") {
19+
latest
20+
} else {
21+
VERSION.clone()
22+
}
23+
};
24+
}
25+
826
#[derive(Parser, Debug)]
927
pub struct Cli {
1028
path: Option<PathBuf>,
@@ -21,13 +39,17 @@ fn main() {
2139
..Default::default()
2240
};
2341
eframe::run_native(
24-
&format!("iCY VIEW {}", env!("CARGO_PKG_VERSION")),
42+
&DEFAULT_TITLE,
2543
options,
2644
Box::new(|cc| {
2745
let gl = cc.gl.as_ref().expect("You need to run eframe with the glow backend");
2846
egui_extras::install_image_loaders(&cc.egui_ctx);
2947

3048
let mut fd = MainWindow::new(gl, args.path);
49+
if *VERSION < *LATEST_VERSION {
50+
fd.file_view.upgrade_version = Some(LATEST_VERSION.to_string());
51+
}
52+
3153
let cmd = fd.file_view.refresh();
3254
fd.handle_command(cmd);
3355
Box::new(fd)

view_library/i18n/de/view_library.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ menu-item-auto-scroll=Automatisches Scrollen
1010
menu-item-scroll-speed-slow=Langsam scrollen
1111
menu-item-scroll-speed-medium=Mittel scrollen
1212
menu-item-scroll-speed-fast=Schnell scrollen
13+
menu-upgrade_version=Neue Version { $version }
1314
1415
tooltip-refresh=Neu laden
1516
tooltip-reset-filter-button=Filter zurücksetzen

view_library/i18n/en/view_library.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ menu-item-auto-scroll=Auto scroll
1010
menu-item-scroll-speed-slow=Slow speed
1111
menu-item-scroll-speed-medium=Medium speed
1212
menu-item-scroll-speed-fast=Fast speed
13+
menu-upgrade_version=Upgrade to { $version }
1314
1415
tooltip-refresh=Refresh
1516
tooltip-reset-filter-button=Reset filter

view_library/src/ui/file_view.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub struct FileView {
101101
pub scroll_pos: Option<usize>,
102102
/// Files in directory.
103103
pub files: Vec<FileEntry>,
104+
pub upgrade_version: Option<String>,
104105

105106
pub auto_scroll_enabled: bool,
106107
pub scroll_speed: usize,
@@ -139,6 +140,7 @@ impl FileView {
139140
filter: String::new(),
140141
auto_scroll_enabled: true,
141142
scroll_speed: 1,
143+
upgrade_version: None
142144
}
143145
}
144146

@@ -172,6 +174,12 @@ impl FileView {
172174
if response.clicked() {
173175
self.filter.clear();
174176
}
177+
if let Some(ver) = &self.upgrade_version {
178+
ui.hyperlink_to(
179+
fl!(crate::LANGUAGE_LOADER, "menu-upgrade_version", version=ver.clone()),
180+
"https://github.com/mkrueger/icy_view/releases/latest",
181+
);
182+
}
175183
});
176184

177185
ui.horizontal(|ui| {

0 commit comments

Comments
 (0)