refactor: Use is_some_and
This commit is contained in:
parent
1a39751402
commit
bc9aff5068
5 changed files with 33 additions and 33 deletions
|
|
@ -653,8 +653,12 @@ impl FrameBufferExt for ArcSwap<FrameBuffer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_timeout(&self, elapsed: Duration) -> bool {
|
fn frame_timeout(&self, elapsed: Duration) -> bool {
|
||||||
if let Some(next_frame) = self.load().images.get(1) {
|
if self
|
||||||
if elapsed >= next_frame.delay {
|
.load()
|
||||||
|
.images
|
||||||
|
.get(1)
|
||||||
|
.is_some_and(|next_frame| elapsed >= next_frame.delay)
|
||||||
|
{
|
||||||
self.rcu(|tiling_store| {
|
self.rcu(|tiling_store| {
|
||||||
let mut new_store = (**tiling_store).clone();
|
let mut new_store = (**tiling_store).clone();
|
||||||
new_store.images.pop_front();
|
new_store.images.pop_front();
|
||||||
|
|
@ -662,7 +666,6 @@ impl FrameBufferExt for ArcSwap<FrameBuffer> {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,9 @@ impl GPSCoord {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(min_) = min {
|
if min.is_some_and(|min_| deg.denom > 1 && min_.num == 0) {
|
||||||
if deg.denom > 1 && min_.num == 0 {
|
|
||||||
min = None;
|
min = None;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Some((
|
Some((
|
||||||
deg.to_f64(),
|
deg.to_f64(),
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,13 @@ impl ImageMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn f_number(&self) -> Option<String> {
|
pub fn f_number(&self) -> Option<String> {
|
||||||
if let Some(exif) = &self.exif {
|
if let Some(field) = self
|
||||||
if let Some(field) = exif.get_field(exif::Tag::FNumber, exif::In::PRIMARY) {
|
.exif
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|exif| exif.get_field(exif::Tag::FNumber, exif::In::PRIMARY))
|
||||||
|
{
|
||||||
return Some(format!("ƒ\u{2215}{}", field.display_value()));
|
return Some(format!("ƒ\u{2215}{}", field.display_value()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -345,11 +345,12 @@ impl LpImageView {
|
||||||
fn navigate_to_file(&self, new_file: &gio::File) {
|
fn navigate_to_file(&self, new_file: &gio::File) {
|
||||||
let sliding_view = self.sliding_view();
|
let sliding_view = self.sliding_view();
|
||||||
|
|
||||||
if let Some(current_file) = self.current_file() {
|
if self
|
||||||
if new_file.equal(¤t_file) {
|
.current_file()
|
||||||
|
.is_some_and(|current_file| current_file.equal(new_file))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let Some(new_index) = self.model().index_of(new_file) else {
|
let Some(new_index) = self.model().index_of(new_file) else {
|
||||||
log::warn!("Could not navigate to file {}", new_file.uri());
|
log::warn!("Could not navigate to file {}", new_file.uri());
|
||||||
|
|
|
||||||
|
|
@ -699,15 +699,13 @@ impl LpWindow {
|
||||||
.current_page()
|
.current_page()
|
||||||
.map(|page| page.image());
|
.map(|page| page.image());
|
||||||
|
|
||||||
if let Some(image) = image {
|
if image.is_some_and(|img| img.image_size() > (0, 0)) {
|
||||||
if image.image_size() > (0, 0) {
|
|
||||||
log::debug!("Showing window because image size is ready");
|
log::debug!("Showing window because image size is ready");
|
||||||
// this let's the window determine the default size from LpImage's natural size
|
// this let's the window determine the default size from LpImage's natural size
|
||||||
self.set_default_size(-1, -1);
|
self.set_default_size(-1, -1);
|
||||||
self.present();
|
self.present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn image_error(&self) {
|
pub fn image_error(&self) {
|
||||||
if self.is_visible() {
|
if self.is_visible() {
|
||||||
|
|
@ -716,13 +714,11 @@ impl LpWindow {
|
||||||
|
|
||||||
let current_page = self.imp().image_view.current_page();
|
let current_page = self.imp().image_view.current_page();
|
||||||
|
|
||||||
if let Some(page) = current_page {
|
if current_page.is_some_and(|page| page.image().error().is_some()) {
|
||||||
if page.image().error().is_some() {
|
|
||||||
log::debug!("Showing window because loading image failed");
|
log::debug!("Showing window because loading image failed");
|
||||||
self.present();
|
self.present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn on_zoom_status_changed(&self) {
|
fn on_zoom_status_changed(&self) {
|
||||||
let can_zoom_out = self
|
let can_zoom_out = self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue