Sfoglia il codice sorgente

tools: add configurable thumbnail cache max size

Part-of: #162
Daniele Bartolini 1 anno fa
parent
commit
4d344085a7

+ 5 - 6
tools/level_editor/level_editor.vala

@@ -670,6 +670,10 @@ public class LevelEditorApplication : Gtk.Application
 		_editor.disconnected.connect(on_runtime_disconnected);
 		_editor.disconnected_unexpected.connect(on_editor_disconnected_unexpected);
 
+		_preferences_dialog = new PreferencesDialog(_editor);
+		_preferences_dialog.delete_event.connect(_preferences_dialog.hide_on_delete);
+		_preferences_dialog.decode(_settings);
+
 		_resource_preview = new RuntimeInstance(_subprocess_launcher, "resource_preview");
 		_resource_preview.message_received.connect(on_message_received);
 		_resource_preview.connected.connect(on_runtime_connected);
@@ -710,16 +714,13 @@ public class LevelEditorApplication : Gtk.Application
 		_project_store = new ProjectStore(_project);
 
 		// Widgets
-		_preferences_dialog = new PreferencesDialog(_editor);
-		_preferences_dialog.delete_event.connect(_preferences_dialog.hide_on_delete);
-
 		_combo = new Gtk.ComboBoxText();
 		_combo.append("editor", "Editor");
 		_combo.append("game", "Game");
 		_combo.set_active_id("editor");
 
 		_console_view = new ConsoleView(_project, _combo, _preferences_dialog);
-		_thumbnail_cache = new ThumbnailCache(_project, _thumbnail, 32*1024*1024);
+		_thumbnail_cache = new ThumbnailCache(_project, _thumbnail, (uint)_preferences_dialog._thumbnail_cache_max_size.value * 1024 * 1024);
 		_project_browser = new ProjectBrowser(_project_store, _thumbnail_cache);
 		_level_treeview = new LevelTreeView(_database, _level);
 		_level_layers_treeview = new LevelLayersTreeView(_database, _level);
@@ -901,8 +902,6 @@ public class LevelEditorApplication : Gtk.Application
 		_main_stack.add_named(_panel_new_project, "panel_new_project");
 		_main_stack.add_named(_main_vbox, "main_vbox");
 
-		_preferences_dialog.decode(_settings);
-
 		// Delete expired logs
 		if (_preferences_dialog._log_delete_after_days.value != 0) {
 			try {

+ 5 - 0
tools/level_editor/preferences_dialog.vala

@@ -31,6 +31,7 @@ public class PreferencesDialog : Gtk.Dialog
 	public EntryDouble _undo_redo_max_size;
 	public EntryDouble _log_delete_after_days;
 	public EntryDouble _console_max_lines;
+	public EntryDouble _thumbnail_cache_max_size;
 	public PropertyGridSet _system_set;
 
 	// External Tools page.
@@ -128,12 +129,14 @@ public class PreferencesDialog : Gtk.Dialog
 		_undo_redo_max_size = new EntryDouble(8, 1, 2048);
 		_log_delete_after_days = new EntryDouble(10, 0, 90);
 		_console_max_lines = new EntryDouble(256, 10, 1024);
+		_thumbnail_cache_max_size = new EntryDouble(32, 1, 128);
 
 		cv = new PropertyGrid();
 		cv.column_homogeneous = true;
 		cv.add_row("Undo/Redo max size (MiB)", _undo_redo_max_size);
 		cv.add_row("Delete logs older than (days)", _log_delete_after_days);
 		cv.add_row("Console max lines", _console_max_lines);
+		cv.add_row("Thumbnail cache max size (MiB)", _thumbnail_cache_max_size);
 		_system_set.add_property_grid(cv, "Memory and Limits");
 
 		// External tools page.
@@ -203,6 +206,7 @@ public class PreferencesDialog : Gtk.Dialog
 		_undo_redo_max_size.value         = (preferences.has_key("undo_redo_max_size") ? (double)preferences["undo_redo_max_size"] : _undo_redo_max_size.value);
 		_log_delete_after_days.value      = preferences.has_key("log_expiration") ? (double)preferences["log_expiration"] : _log_delete_after_days.value;
 		_console_max_lines.value          = preferences.has_key("console_max_lines") ? (double)preferences["console_max_lines"] : _console_max_lines.value;
+		_thumbnail_cache_max_size.value   = (preferences.has_key("thumbnail_cache_max_size") ? (double)preferences["thumbnail_cache_max_size"] : _thumbnail_cache_max_size.value);
 
 		if (preferences.has_key("theme"))
 			_theme_combo.value = (string)preferences["theme"];
@@ -273,6 +277,7 @@ public class PreferencesDialog : Gtk.Dialog
 		preferences["log_expiration"] = _log_delete_after_days.value;
 		preferences["console_max_lines"] = _console_max_lines.value;
 		preferences["theme"]          = _theme_combo.value;
+		preferences["thumbnail_cache_max_size"] = _thumbnail_cache_max_size.value;
 
 		// External tools.
 		string app;