diff --git a/.gitignore b/.gitignore index 48f0f62..61cc91c 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ app.*.map.json *.deb *.tar.gz *.exe -!dist/imajviewer_1.4.2_amd64.deb +!dist/imajviewer_1.5.0_amd64.deb !dist/imajviewer_setup_1.1.0.exe deb/usr/lib/imajviewer/ release/ diff --git a/CHANGELOG.md b/CHANGELOG.md index f91bb5f..9d2c5bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to imajViewer are documented in this file. ## [Unreleased] +## [1.5.0] - 2026-10-12 + +### Added +- Fill/fit mode (double-click) is now persisted in `window.json` and restored on the next launch + and when switching images, instead of always resetting to fill. + ## [1.4.2] - 2026-10-12 ### Fixed diff --git a/dist/imajviewer_1.4.2_amd64.deb b/dist/imajviewer_1.5.0_amd64.deb similarity index 60% rename from dist/imajviewer_1.4.2_amd64.deb rename to dist/imajviewer_1.5.0_amd64.deb index f74aa20..ab72ab3 100644 Binary files a/dist/imajviewer_1.4.2_amd64.deb and b/dist/imajviewer_1.5.0_amd64.deb differ diff --git a/lib/services/window_persistence.dart b/lib/services/window_persistence.dart index 568ab9a..bbfa81e 100644 --- a/lib/services/window_persistence.dart +++ b/lib/services/window_persistence.dart @@ -15,28 +15,59 @@ class WindowPersistence { return File('$dir/window.json'); } + /// Görüntü ekran modu: true = pencereyi kapla (cover), false = sığdır (contain). + /// Anahtar yoksa/bozuksa true (eski davranış). + static bool get filled { + final v = _read()?['filled']; + return v is bool ? v : true; + } + + /// Sadece modu günceller; x/y/w/h korunur. + static void saveFilled(bool value) => _write({'filled': value}); + /// Save window rect synchronously (safe to call before destroy). static void saveSync({ required Offset position, required Size size, }) { - final file = _configFile; - file.parent.createSync(recursive: true); - file.writeAsStringSync(jsonEncode({ + _write({ 'x': position.dx.toInt(), 'y': position.dy.toInt(), 'width': size.width.toInt(), 'height': size.height.toInt(), - })); + }); + } + + /// Dosyayı oku (yok/bozuksa null). + static Map? _read() { + final file = _configFile; + if (!file.existsSync()) return null; + try { + return jsonDecode(file.readAsStringSync()) as Map; + } catch (_) { + return null; + } + } + + /// Verilen anahtarları yaz; dosyadaki diğer anahtarlar korunur. + static void _write(Map values) { + try { + final file = _configFile; + file.parent.createSync(recursive: true); + final data = _read() ?? {}; + data.addAll(values); + file.writeAsStringSync(jsonEncode(data)); + } catch (_) { + // Disk hatası uygulamayı durdurmasın. + } } /// Restore saved window rect. Returns null if no saved config. static ({Offset position, Size size})? restore() { - final file = _configFile; - if (!file.existsSync()) return null; + final data = _read(); + if (data == null) return null; try { - final data = jsonDecode(file.readAsStringSync()) as Map; final x = (data['x'] as num?)?.toDouble() ?? 0; final y = (data['y'] as num?)?.toDouble() ?? 0; final w = (data['width'] as num?)?.toDouble() ?? 1280; diff --git a/lib/widgets/image_canvas.dart b/lib/widgets/image_canvas.dart index f9c02a6..b8172d6 100644 --- a/lib/widgets/image_canvas.dart +++ b/lib/widgets/image_canvas.dart @@ -6,6 +6,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import '../l10n/app_localizations.dart'; import '../services/crop_save_service.dart'; +import '../services/window_persistence.dart'; class ImageCanvas extends StatefulWidget { final String filePath; @@ -15,7 +16,7 @@ class ImageCanvas extends StatefulWidget { } class ImageCanvasState extends State { - bool _isFilled = true; + bool _isFilled = WindowPersistence.filled; final GlobalKey _imageKey = GlobalKey(); double _tx = 0, _ty = 0, _sc = 1.0; Size _vpSize = Size.zero; @@ -199,7 +200,7 @@ class ImageCanvasState extends State { } void _resetView() { - _tx = 0; _ty = 0; _sc = 1.0; _isFilled = true; + _tx = 0; _ty = 0; _sc = 1.0; _isFilled = WindowPersistence.filled; _angle = 0; _contrast = 1.0; _saturation = 1.0; _brightness = 0; _usingFullRes = false; _imageSize = Size.zero; @@ -209,6 +210,7 @@ class ImageCanvasState extends State { void _toggleFillFit() { _isFilled = !_isFilled; _tx = 0; _ty = 0; _sc = 1.0; _angle = 0; _contrast = 1.0; _saturation = 1.0; _brightness = 0; + WindowPersistence.saveFilled(_isFilled); _markRenderDirty(); } diff --git a/pubspec.yaml b/pubspec.yaml index 513845e..08ede65 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: imajviewer description: "Ultra-lightweight image viewer for Linux and Windows." publish_to: 'none' -version: 1.4.2+10 +version: 1.5.0+11 msix_config: display_name: ImajViewer