mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 11:43:43 +00:00
cleanup
This commit is contained in:
parent
38f41de240
commit
72195bda1b
@ -310,18 +310,22 @@ impl People {
|
||||
// Finish this later (spawn)
|
||||
let apubkeyhex = pubkeyhex.to_owned();
|
||||
tokio::spawn(async move {
|
||||
let size = AVATAR_SIZE * GLOBALS.pixels_per_point_times_100.load(std::sync::atomic::Ordering::Relaxed) / 100;
|
||||
let size = AVATAR_SIZE
|
||||
* GLOBALS
|
||||
.pixels_per_point_times_100
|
||||
.load(std::sync::atomic::Ordering::Relaxed)
|
||||
/ 100;
|
||||
if let Ok(image) = image::load_from_memory(&bytes) {
|
||||
// Note: we can't use egui_extras::image::load_image_bytes because we
|
||||
// need to force a resize
|
||||
let image = image.resize(
|
||||
size,
|
||||
size,
|
||||
image::imageops::FilterType::CatmullRom,
|
||||
); // DynamicImage
|
||||
let image =
|
||||
image.resize(size, size, image::imageops::FilterType::CatmullRom); // DynamicImage
|
||||
let image_buffer = image.into_rgba8(); // RgbaImage (ImageBuffer)
|
||||
let color_image = ColorImage::from_rgba_unmultiplied(
|
||||
[image_buffer.width() as usize, image_buffer.height() as usize],
|
||||
[
|
||||
image_buffer.width() as usize,
|
||||
image_buffer.height() as usize,
|
||||
],
|
||||
image_buffer.as_flat_samples().as_slice(),
|
||||
);
|
||||
GLOBALS.people.avatars_temp.insert(apubkeyhex, color_image);
|
||||
|
@ -111,15 +111,15 @@ impl Settings {
|
||||
"light_mode" => settings.light_mode = numstr_to_bool(row.1),
|
||||
"set_client_tag" => settings.set_client_tag = numstr_to_bool(row.1),
|
||||
"override_dpi" => {
|
||||
if row.1=="" {
|
||||
if row.1.is_empty() {
|
||||
settings.override_dpi = DEFAULT_OVERRIDE_DPI;
|
||||
} else {
|
||||
settings.override_dpi = match row.1.parse::<u32>() {
|
||||
Ok(number) => Some(number),
|
||||
_ => DEFAULT_OVERRIDE_DPI
|
||||
_ => DEFAULT_OVERRIDE_DPI,
|
||||
};
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -166,14 +166,13 @@ impl Settings {
|
||||
self.pow,
|
||||
bool_to_numstr(self.offline),
|
||||
bool_to_numstr(self.light_mode),
|
||||
bool_to_numstr(self.set_client_tag)
|
||||
bool_to_numstr(self.set_client_tag),
|
||||
))?;
|
||||
|
||||
// Save override dpi
|
||||
if let Some(ref dpi) = self.override_dpi {
|
||||
let mut stmt = db.prepare(
|
||||
"REPLACE INTO SETTINGS (key, value) VALUES ('override_dpi', ?)",
|
||||
)?;
|
||||
let mut stmt =
|
||||
db.prepare("REPLACE INTO SETTINGS (key, value) VALUES ('override_dpi', ?)")?;
|
||||
stmt.execute((&dpi,))?;
|
||||
} else {
|
||||
// Otherwise delete any such setting
|
||||
|
@ -1,9 +1,9 @@
|
||||
use super::{GossipUi, Page};
|
||||
use crate::AVATAR_SIZE_F32;
|
||||
use crate::comms::ToOverlordMessage;
|
||||
use crate::feed::FeedKind;
|
||||
use crate::globals::{Globals, GLOBALS};
|
||||
use crate::ui::widgets::CopyButton;
|
||||
use crate::AVATAR_SIZE_F32;
|
||||
use eframe::egui;
|
||||
use egui::{
|
||||
Align, Color32, Context, Frame, Image, Label, Layout, RichText, ScrollArea, SelectableLabel,
|
||||
@ -444,18 +444,11 @@ fn render_post_actual(
|
||||
} else {
|
||||
app.placeholder_avatar.clone()
|
||||
};
|
||||
let size = AVATAR_SIZE_F32 * GLOBALS.pixels_per_point_times_100.load(Ordering::Relaxed) as f32 / 100.0;
|
||||
let size = AVATAR_SIZE_F32
|
||||
* GLOBALS.pixels_per_point_times_100.load(Ordering::Relaxed) as f32
|
||||
/ 100.0;
|
||||
if ui
|
||||
.add(
|
||||
Image::new(
|
||||
&avatar,
|
||||
Vec2 {
|
||||
x: size,
|
||||
y: size,
|
||||
},
|
||||
)
|
||||
.sense(Sense::click()),
|
||||
)
|
||||
.add(Image::new(&avatar, Vec2 { x: size, y: size }).sense(Sense::click()))
|
||||
.clicked()
|
||||
{
|
||||
app.set_page(Page::Person(event.pubkey.into()));
|
||||
|
@ -103,7 +103,6 @@ impl Drop for GossipUi {
|
||||
|
||||
impl GossipUi {
|
||||
fn new(cctx: &eframe::CreationContext<'_>) -> Self {
|
||||
|
||||
let settings = GLOBALS.settings.blocking_read().clone();
|
||||
|
||||
if let Some(dpi) = settings.override_dpi {
|
||||
@ -120,7 +119,7 @@ impl GossipUi {
|
||||
// Set global pixels_per_point_times_100, used for image scaling.
|
||||
GLOBALS.pixels_per_point_times_100.store(
|
||||
(cctx.egui_ctx.pixels_per_point() * 100.0) as u32,
|
||||
Ordering::Relaxed
|
||||
Ordering::Relaxed,
|
||||
);
|
||||
|
||||
if !settings.light_mode {
|
||||
@ -164,7 +163,7 @@ impl GossipUi {
|
||||
let current_dpi = (cctx.egui_ctx.pixels_per_point() * 72.0) as u32;
|
||||
let (override_dpi, override_dpi_value): (bool, u32) = match settings.override_dpi {
|
||||
Some(v) => (true, v),
|
||||
None => (false, current_dpi)
|
||||
None => (false, current_dpi),
|
||||
};
|
||||
|
||||
GossipUi {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use super::{GossipUi, Page};
|
||||
use crate::AVATAR_SIZE_F32;
|
||||
use crate::comms::ToOverlordMessage;
|
||||
use crate::db::DbPerson;
|
||||
use crate::globals::GLOBALS;
|
||||
use crate::AVATAR_SIZE_F32;
|
||||
use eframe::egui;
|
||||
use egui::{Context, Image, RichText, ScrollArea, Sense, Ui, Vec2};
|
||||
use std::sync::atomic::Ordering;
|
||||
@ -73,18 +73,11 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
} else {
|
||||
app.placeholder_avatar.clone()
|
||||
};
|
||||
let size = AVATAR_SIZE_F32 * GLOBALS.pixels_per_point_times_100.load(Ordering::Relaxed) as f32 / 100.0;
|
||||
let size = AVATAR_SIZE_F32
|
||||
* GLOBALS.pixels_per_point_times_100.load(Ordering::Relaxed) as f32
|
||||
/ 100.0;
|
||||
if ui
|
||||
.add(
|
||||
Image::new(
|
||||
&avatar,
|
||||
Vec2 {
|
||||
x: size,
|
||||
y: size,
|
||||
},
|
||||
)
|
||||
.sense(Sense::click()),
|
||||
)
|
||||
.add(Image::new(&avatar, Vec2 { x: size, y: size }).sense(Sense::click()))
|
||||
.clicked()
|
||||
{
|
||||
app.set_page(Page::Person(person.pubkey.clone()));
|
||||
|
Loading…
Reference in New Issue
Block a user