- Settings 'Size' section: 8 col x 4 row grid, 31 buttons labeled a:b (a splits H, b splits W); top-left cell empty placeholder (no 1:1 — title bar double click already maximizes) - Click resizes the window to work.width/b x work.height/a of the display's work area (screen_retriever visibleSize, taskbar excluded); position unchanged, no selection state tracking - minimumSize 400x300 -> 160x100 (4:8 cell needs it) - Settings file-properties rows left-aligned (were centered under path)
52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
import 'dart:io';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:window_manager/window_manager.dart';
|
||
import 'app.dart';
|
||
import 'services/image_manager.dart';
|
||
import 'services/window_persistence.dart';
|
||
|
||
void main(List<String> args) async {
|
||
WidgetsFlutterBinding.ensureInitialized();
|
||
|
||
ImageManager.configureCache();
|
||
|
||
await windowManager.ensureInitialized();
|
||
|
||
// Restore saved window position/size or use defaults
|
||
final saved = WindowPersistence.restore();
|
||
final defaultSize = const Size(1280, 800);
|
||
|
||
final windowOptions = WindowOptions(
|
||
size: saved?.size ?? defaultSize,
|
||
minimumSize: const Size(160, 100),
|
||
backgroundColor: Colors.transparent,
|
||
titleBarStyle: TitleBarStyle.hidden,
|
||
);
|
||
|
||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||
if (saved != null) {
|
||
final position = await WindowPersistence.cascadePosition(
|
||
previousPosition: saved.position,
|
||
previousSize: saved.size,
|
||
);
|
||
await windowManager.setPosition(position);
|
||
await windowManager.setSize(saved.size);
|
||
} else {
|
||
await windowManager.center();
|
||
}
|
||
await windowManager.setResizable(true);
|
||
await windowManager.show();
|
||
await windowManager.focus();
|
||
|
||
// Açılış konumunu hemen kaydet — sıradaki pencere güncel referans okusun
|
||
final pos = await windowManager.getPosition();
|
||
final size = await windowManager.getSize();
|
||
WindowPersistence.saveSync(position: pos, size: size);
|
||
});
|
||
|
||
// Extract file paths from command-line arguments
|
||
final filePaths = args.where((a) => !a.startsWith('-') && a != Platform.script.path).toList();
|
||
|
||
runApp(ImajViewerApp(initialFiles: filePaths));
|
||
}
|