New About window

This commit is contained in:
Piyush मिश्रः 2022-01-26 15:58:44 +05:30
parent 9efe1374e9
commit 0e54bfdffa
6 changed files with 334 additions and 8 deletions

152
Cargo.lock generated
View File

@ -20,6 +20,15 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -43,6 +52,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bumpalo"
version = "3.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
[[package]]
name = "bytemuck"
version = "1.7.3"
@ -403,6 +418,15 @@ dependencies = [
"rayon",
]
[[package]]
name = "js-sys"
version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -602,7 +626,7 @@ dependencies = [
[[package]]
name = "post_maker"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"clap",
"dirs",
@ -616,6 +640,8 @@ dependencies = [
"serde",
"serde_json",
"simplelog",
"textwrap",
"webbrowser",
]
[[package]]
@ -766,6 +792,23 @@ dependencies = [
"redox_syscall",
]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rulinalg"
version = "0.4.2"
@ -846,6 +889,12 @@ dependencies = [
"termcolor",
]
[[package]]
name = "smawk"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043"
[[package]]
name = "strsim"
version = "0.10.0"
@ -877,6 +926,11 @@ name = "textwrap"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
dependencies = [
"smawk",
"unicode-linebreak",
"unicode-width",
]
[[package]]
name = "tiff"
@ -905,6 +959,21 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc"
[[package]]
name = "unicode-linebreak"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a52dcaab0c48d931f7cc8ef826fa51690a08e1ea55117ef26f89864f532383f"
dependencies = [
"regex",
]
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -929,12 +998,93 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2"
[[package]]
name = "web-sys"
version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webbrowser"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a"
dependencies = [
"web-sys",
"widestring",
"winapi",
]
[[package]]
name = "weezl"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e"
[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -1,9 +1,9 @@
[package]
name = "post_maker"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "Post Maker helps you to make post for instagram and other social madia apps easily"
authors = ["Piyush Raj <piyush.raj.kit@gmail.com>"]
description = "Post Maker helps you to make post for Instagram and other Social Media apps easily."
authors = ["PiyushXCoder <https://piyushxcoder.in>"]
license = "GPL-3.0-only"
readme = "README.md"
repository = "https://github.com/PiyushXCoder/post_maker"
@ -22,4 +22,6 @@ rusttype = "0.9"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
lazy_static = "1.4"
dirs = "4.0.0"
dirs = "4.0"
textwrap = "0.14"
webbrowser = "0.5"

170
src/about.rs Normal file
View File

@ -0,0 +1,170 @@
/*
This file is part of Post Maker.
Post Maker is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Post Maker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Post Maker. If not, see <https://www.gnu.org/licenses/>
*/
//! About Window
use crate::{config, globals};
use fltk::{
app, dialog,
enums::{self, Align, Event},
frame::Frame,
group::Flex,
image::SvgImage,
prelude::*,
window::Window,
};
pub(crate) struct About {
pub(crate) win: Window,
pub(crate) repo_link: Frame,
pub(crate) dev_link: Frame,
pub(crate) license_link: Frame,
}
impl About {
pub(crate) fn new() -> Self {
let mut win = Window::new(0, 0, 400, 500, "About Us").center_screen();
win.set_icon(Some(
SvgImage::from_data(globals::ICON.to_str().unwrap()).unwrap(),
));
let link_color = if *globals::THEME == config::Themes::Dark
|| *globals::THEME == config::Themes::HighContrast
{
enums::Color::rgb_color(111, 190, 255)
} else {
enums::Color::rgb_color(16, 71, 151)
};
let mut main_flex = Flex::default().with_size(390, 490).with_pos(5, 5).column();
let mut icon = Frame::default();
let mut img = SvgImage::from_data(globals::ICON_WITH_TEXT.to_str().unwrap()).unwrap();
img.scale(200, 200, true, true);
icon.set_image(Some(img));
let mut description =
Frame::default().with_label(&textwrap::fill(env!("CARGO_PKG_DESCRIPTION"), 50));
description.set_label_size(14);
main_flex.set_size(&description, 50);
main_flex.set_size(
&Frame::default().with_label(&format!("Version: {}", env!("CARGO_PKG_VERSION"))),
30,
);
let mut grp = Flex::default().row();
let mut git = Frame::default()
.with_label("Git:")
.with_align(Align::Right | Align::Inside);
git.set_label_size(13);
grp.set_size(&git, 60);
let mut repo_link = Frame::default()
.with_label(env!("CARGO_PKG_REPOSITORY"))
.with_align(Align::Left | Align::Inside);
repo_link.set_label_color(link_color.clone());
repo_link.set_label_size(13);
grp.end();
main_flex.set_size(&grp, 30);
let mut text = Frame::default()
.with_label("Developed with <3 by PiyushXCoder")
.with_align(Align::Bottom | Align::Inside);
text.set_label_size(13);
main_flex.set_size(&text, 20);
let mut dev_link = Frame::default()
.with_label("https://piyushxcoder.in")
.with_align(Align::Top | Align::Inside);
dev_link.set_label_color(link_color.clone());
dev_link.set_label_size(13);
main_flex.set_size(&dev_link, 20);
let mut license = Frame::default()
.with_label("This program comes with absolutely no warrant.See the")
.with_align(Align::Bottom | Align::Inside);
license.set_label_size(13);
main_flex.set_size(&license, 25);
let mut license_link =
Frame::default().with_label("GNU General Public License, version 3 or later");
license_link.set_label_color(link_color.clone());
license_link.set_label_size(13);
main_flex.set_size(&license_link, 13);
let mut license = Frame::default()
.with_label("for details.")
.with_align(Align::Top | Align::Inside);
license.set_label_size(13);
main_flex.set_size(&license, 25);
main_flex.end();
win.end();
win.make_modal(true);
let mut about = Self {
win,
repo_link,
dev_link,
license_link,
};
about.event();
about
}
pub(crate) fn show(&mut self) {
self.win.show();
while self.win.shown() {
app::wait();
}
}
// Set callbacks of elements
fn event(&mut self) {
// Repository Link
self.repo_link.handle(|_, ev| {
if ev == Event::Push {
if let Err(e) = webbrowser::open(env!("CARGO_PKG_REPOSITORY")) {
dialog::alert_default("Failed to open the link!");
warn!("Failed to open the link!\n{:?}", e);
}
}
true
});
// Developer's Link
self.dev_link.handle(|_, ev| {
if ev == Event::Push {
if let Err(e) = webbrowser::open("https://piyushxcoder.in") {
dialog::alert_default("Failed to open the link!");
warn!("Failed to open the link!\n{:?}", e);
}
}
true
});
// License Link
self.license_link.handle(|_, ev| {
if ev == Event::Push {
if let Err(e) = webbrowser::open("https://www.gnu.org/licenses/gpl-3.0.html") {
dialog::alert_default("Failed to open the link!");
warn!("Failed to open the link!\n{:?}", e);
}
}
true
});
}
}

View File

@ -113,6 +113,9 @@ lazy_static! {
/// Image to use for Window
pub(crate) static ref ICON: OsString = include_str!("../assets/icon.svg").into();
/// Image to use for About
pub(crate) static ref ICON_WITH_TEXT: OsString = include_str!("../assets/icon_with_text.svg").into();
/// Image to use for Reload Button
pub(crate) static ref RELOAD_ICON: OsString = {
let img = include_str!("../assets/reload.svg");

View File

@ -17,6 +17,7 @@
extern crate log;
extern crate simplelog;
mod about;
mod config;
mod config_picker;
mod config_window;

View File

@ -13,6 +13,7 @@
*/
//! Main window where you do all editing
use crate::about::About;
use crate::crop_window::CropWindow;
use crate::draw_thread::*;
use crate::utils;
@ -455,14 +456,13 @@ impl MainWindow {
},
);
let mut about_win = About::new();
self.menubar.add(
"&Help/About...\t",
Shortcut::None,
menu::MenuFlag::Normal,
move |_| {
dialog::alert_default(
"Created with <3 by PiyushXCoder\nhttps://github.com/PiyushXCoder",
);
about_win.show();
},
);
}