library UI manager cleaned
This commit is contained in:
@@ -11690,3 +11690,323 @@ This makes the interface more functional and user-friendly, as users can now dir
|
||||
|
||||
---
|
||||
|
||||
_**User**_
|
||||
|
||||
good, let's replace that path with a short path that shows the first field of the path only, e.g. \\NAS\, \\NEXUS, A:\, // (for relative paths)
|
||||
|
||||
---
|
||||
|
||||
_**Assistant**_
|
||||
|
||||
Great idea! Let me update the UI to show a short, abbreviated path that displays just the first part of the file path. This will make it much cleaner while still giving users useful location information.
|
||||
|
||||
|
||||
---
|
||||
|
||||
<details><summary>Edit file: ui.py</summary>
|
||||
|
||||
undefined
|
||||
|
||||
**Chunk 1**
|
||||
Lines added: 5, lines removed: 1
|
||||
|
||||
```diff
|
||||
@@ -203,6 +203,10 @@
|
||||
info_box.label(text="Status: OK", icon='FILE_BLEND')
|
||||
|
||||
- # Replace path display with Open Blend button
|
||||
+ # Show abbreviated path and Open Blend button
|
||||
row = info_box.row()
|
||||
+ # Display abbreviated path (first part only)
|
||||
+ short_path = self.get_short_path(selected_lib.filepath)
|
||||
+ row.label(text=f"Location: {short_path}", icon='FILE_FOLDER')
|
||||
+ # Open Blend button
|
||||
row.operator("dlm.open_linked_file", text="Open Blend", icon='FILE_BLEND').filepath = selected_lib.filepath
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
Now I need to add the `get_short_path` method to the panel class. Let me add it:
|
||||
|
||||
|
||||
---
|
||||
|
||||
<details><summary>Edit file: ui.py</summary>
|
||||
|
||||
undefined
|
||||
|
||||
**Chunk 1**
|
||||
Lines added: 31, lines removed: undefined
|
||||
|
||||
```diff
|
||||
@@ -118,4 +118,35 @@
|
||||
bl_label = "Dynamic Link Manager"
|
||||
|
||||
+ def get_short_path(self, filepath):
|
||||
+ """Extract a short, readable path from a full filepath"""
|
||||
+ if not filepath:
|
||||
+ return "Unknown"
|
||||
+
|
||||
+ # Handle relative paths
|
||||
+ if filepath.startswith("//"):
|
||||
+ return "// (relative)"
|
||||
+
|
||||
+ # Handle Windows network paths
|
||||
+ if filepath.startswith("\\\\"):
|
||||
+ # Extract server name (e.g., \\NAS\ or \\NEXUS\)
|
||||
+ parts = filepath.split("\\")
|
||||
+ if len(parts) >= 3:
|
||||
+ return f"\\\\{parts[2]}\\"
|
||||
+ return "\\\\ (network)"
|
||||
+
|
||||
+ # Handle Windows drive paths
|
||||
+ if len(filepath) >= 2 and filepath[1] == ':':
|
||||
+ return f"{filepath[:2]}\\"
|
||||
+
|
||||
+ # Handle Unix-style paths
|
||||
+ if filepath.startswith("/"):
|
||||
+ parts = filepath.split("/")
|
||||
+ if len(parts) >= 2:
|
||||
+ return f"/{parts[1]}/"
|
||||
+ return "/ (root)"
|
||||
+
|
||||
+ # Fallback
|
||||
+ return "Unknown"
|
||||
+
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
Perfect! Now the UI will show much cleaner, abbreviated paths. Here's what the `get_short_path` method does:
|
||||
|
||||
## **Path Abbreviation Examples:**
|
||||
|
||||
- **Relative paths**: `//` → `// (relative)`
|
||||
- **Windows network paths**: `\\NAS\amazon\...` → `\\NAS\`
|
||||
- **Windows network paths**: `\\NEXUS\assets\...` → `\\NEXUS\`
|
||||
- **Windows drive paths**: `A:\1 Amazon_Active_Projects\...` → `A:\`
|
||||
- **Unix paths**: `/home/user/...` → `/home/`
|
||||
- **Unknown/empty**: → `Unknown`
|
||||
|
||||
## **Benefits:**
|
||||
|
||||
1. **Cleaner UI**: Much shorter text that fits better in the panel
|
||||
2. **Useful information**: Still shows the key location (server, drive, or relative path)
|
||||
3. **Consistent formatting**: All paths are displayed in a uniform way
|
||||
4. **Better readability**: Users can quickly identify the general location without long paths
|
||||
|
||||
Now the third column will show something like "Location: \\NAS\" or "Location: A:\" instead of the full, long file path, making the interface much cleaner while maintaining the useful location information.
|
||||
|
||||
---
|
||||
|
||||
_**User**_
|
||||
|
||||
no, I meant in the third column. the blend info section should have the full path.
|
||||
|
||||
---
|
||||
|
||||
_**Assistant**_
|
||||
|
||||
Ah, I understand now! You want to keep the full path in the blend info section (the details panel at the bottom), but modify the third column in the main library list to show abbreviated paths. Let me fix this:
|
||||
|
||||
|
||||
---
|
||||
|
||||
Model failed to call the tool with correct arguments.
|
||||
|
||||
---
|
||||
|
||||
<details><summary>Edit file: ui.py</summary>
|
||||
|
||||
undefined
|
||||
|
||||
**Chunk 1**
|
||||
Lines added: 2, lines removed: 5
|
||||
|
||||
```diff
|
||||
@@ -234,10 +234,7 @@
|
||||
info_box.label(text="Status: OK", icon='FILE_BLEND')
|
||||
|
||||
- # Show abbreviated path and Open Blend button
|
||||
+ # Show full path and Open Blend button
|
||||
row = info_box.row()
|
||||
- # Display abbreviated path (first part only)
|
||||
- short_path = self.get_short_path(selected_lib.filepath)
|
||||
- row.label(text=f"Location: {short_path}", icon='FILE_FOLDER')
|
||||
- # Open Blend button
|
||||
+ row.label(text=f"Path: {selected_lib.filepath}", icon='FILE_FOLDER')
|
||||
row.operator("dlm.open_linked_file", text="Open Blend", icon='FILE_BLEND').filepath = selected_lib.filepath
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
Now I need to modify the UIList to show abbreviated paths in the third column of the main library list. Let me check the UIList class:
|
||||
|
||||
|
||||
---
|
||||
|
||||
<details>
|
||||
<summary>Grep search for "class DYNAMICLINK_UL_library_list" • **3** files</summary>
|
||||
|
||||
| File | Line | Match |
|
||||
|------|------|-------|
|
||||
| `file:///t%3A/Dynamic-Link-Manager/ui.py` | L19 | `class DYNAMICLINK_UL_library_list(UIList):` |
|
||||
| `file:///t%3A/Dynamic-Link-Manager/.specstory/history/2025-08-20_22-43Z-creating-a-blender-extension-for-asset-replacement.md` | L6929 | `+ class DYNAMICLINK_UL_library_list(UIList):` |
|
||||
| `file:///t%3A/Dynamic-Link-Manager/ui.py` | L19 | `class DYNAMICLINK_UL_library_list(UIList):` |
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
Read file: ui.py
|
||||
|
||||
---
|
||||
|
||||
Perfect! Now I can see the UIList class. I need to modify the third column to use the abbreviated path instead of the truncated full path. Let me update it:
|
||||
|
||||
|
||||
---
|
||||
|
||||
<details><summary>Edit file: ui.py</summary>
|
||||
|
||||
undefined
|
||||
|
||||
**Chunk 1**
|
||||
Lines added: 24, lines removed: 5
|
||||
|
||||
```diff
|
||||
@@ -35,10 +35,29 @@
|
||||
layout.label(text="OK", icon='FILE_BLEND')
|
||||
|
||||
- # File path (FMT-style truncated)
|
||||
+ # File path (abbreviated)
|
||||
layout.scale_x = 0.3
|
||||
- path_text = item.filepath
|
||||
- if len(path_text) > 30:
|
||||
- path_text = "..." + path_text[-27:]
|
||||
- layout.label(text=path_text, icon='FILE_FOLDER')
|
||||
+ # Get the panel instance to call get_short_path
|
||||
+ panel = context.space_data.region_3d
|
||||
+ if hasattr(panel, 'get_short_path'):
|
||||
+ short_path = panel.get_short_path(item.filepath)
|
||||
+ else:
|
||||
+ # Fallback to simple abbreviation
|
||||
+ path_text = item.filepath
|
||||
+ if path_text.startswith("\\\\"):
|
||||
+ # Network path: show server name
|
||||
+ parts = path_text.split("\\")
|
||||
+ if len(parts) >= 3:
|
||||
+ short_path = f"\\\\{parts[2]}\\"
|
||||
+ else:
|
||||
+ short_path = "\\\\ (network)"
|
||||
+ elif len(path_text) >= 2 and path_text[1] == ':':
|
||||
+ # Drive path: show drive letter
|
||||
+ short_path = f"{path_text[:2]}\\"
|
||||
+ elif path_text.startswith("//"):
|
||||
+ # Relative path
|
||||
+ short_path = "// (relative)"
|
||||
+ else:
|
||||
+ short_path = path_text[:15] + "..." if len(path_text) > 15 else path_text
|
||||
+ layout.label(text=short_path, icon='FILE_FOLDER')
|
||||
|
||||
elif self.layout_type in {'GRID'}:
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
Actually, let me simplify this approach. Since the UIList doesn't have direct access to the panel methods, let me create a simpler solution that just shows the abbreviated path directly:
|
||||
|
||||
|
||||
---
|
||||
|
||||
<details><summary>Edit file: ui.py</summary>
|
||||
|
||||
undefined
|
||||
|
||||
**Chunk 1**
|
||||
Lines added: 16, lines removed: 22
|
||||
|
||||
```diff
|
||||
@@ -37,26 +37,20 @@
|
||||
# File path (abbreviated)
|
||||
layout.scale_x = 0.3
|
||||
- # Get the panel instance to call get_short_path
|
||||
- panel = context.space_data.region_3d
|
||||
- if hasattr(panel, 'get_short_path'):
|
||||
- short_path = panel.get_short_path(item.filepath)
|
||||
- else:
|
||||
- # Fallback to simple abbreviation
|
||||
- path_text = item.filepath
|
||||
- if path_text.startswith("\\\\"):
|
||||
- # Network path: show server name
|
||||
- parts = path_text.split("\\")
|
||||
- if len(parts) >= 3:
|
||||
- short_path = f"\\\\{parts[2]}\\"
|
||||
- else:
|
||||
- short_path = "\\\\ (network)"
|
||||
- elif len(path_text) >= 2 and path_text[1] == ':':
|
||||
- # Drive path: show drive letter
|
||||
- short_path = f"{path_text[:2]}\\"
|
||||
- elif path_text.startswith("//"):
|
||||
- # Relative path
|
||||
- short_path = "// (relative)"
|
||||
- else:
|
||||
- short_path = path_text[:15] + "..." if len(path_text) > 15 else path_text
|
||||
+ path_text = item.filepath
|
||||
+ if path_text.startswith("\\\\"):
|
||||
+ # Network path: show server name
|
||||
+ parts = path_text.split("\\")
|
||||
+ if len(parts) >= 3:
|
||||
+ short_path = f"\\\\{parts[2]}\\"
|
||||
+ else:
|
||||
+ short_path = "\\\\ (network)"
|
||||
+ elif len(path_text) >= 2 and path_text[1] == ':':
|
||||
+ # Drive path: show drive letter
|
||||
+ short_path = f"{path_text[:2]}\\"
|
||||
+ elif path_text.startswith("//"):
|
||||
+ # Relative path
|
||||
+ short_path = "// (relative)"
|
||||
+ else:
|
||||
+ short_path = path_text[:15] + "..." if len(path_text) > 15 else path_text
|
||||
layout.label(text=short_path, icon='FILE_FOLDER')
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
Perfect! Now I've implemented exactly what you wanted:
|
||||
|
||||
## **What Changed:**
|
||||
|
||||
1. **Main Library List (Third Column)**: Now shows abbreviated paths like:
|
||||
- `\\NAS\` for network paths
|
||||
- `A:\` for drive paths
|
||||
- `// (relative)` for relative paths
|
||||
- Shortened paths for other cases
|
||||
|
||||
2. **Blend Info Section (Bottom)**: Still shows the full path for complete information
|
||||
|
||||
## **Result:**
|
||||
|
||||
- **List View**: Clean, abbreviated paths that give quick location info
|
||||
- **Detail Panel**: Full path when you need complete information
|
||||
- **Best of both worlds**: Quick overview + detailed info when needed
|
||||
|
||||
Now the third column in the main library list will be much cleaner and easier to read, showing just the essential location information (like `\\NAS\` or `A:\`), while the detailed info panel at the bottom still provides the complete file path for users who need it.
|
||||
|
||||
---
|
||||
|
||||
|
||||
57
ui.py
57
ui.py
@@ -34,12 +34,25 @@ class DYNAMICLINK_UL_library_list(UIList):
|
||||
else:
|
||||
layout.label(text="OK", icon='FILE_BLEND')
|
||||
|
||||
# File path (FMT-style truncated)
|
||||
# File path (abbreviated)
|
||||
layout.scale_x = 0.3
|
||||
path_text = item.filepath
|
||||
if len(path_text) > 30:
|
||||
path_text = "..." + path_text[-27:]
|
||||
layout.label(text=path_text, icon='FILE_FOLDER')
|
||||
if path_text.startswith("\\\\"):
|
||||
# Network path: show server name
|
||||
parts = path_text.split("\\")
|
||||
if len(parts) >= 3:
|
||||
short_path = f"\\\\{parts[2]}\\"
|
||||
else:
|
||||
short_path = "\\\\ (network)"
|
||||
elif len(path_text) >= 2 and path_text[1] == ':':
|
||||
# Drive path: show drive letter
|
||||
short_path = f"{path_text[:2]}\\"
|
||||
elif path_text.startswith("//"):
|
||||
# Relative path
|
||||
short_path = "// (relative)"
|
||||
else:
|
||||
short_path = path_text[:15] + "..." if len(path_text) > 15 else path_text
|
||||
layout.label(text=short_path, icon='FILE_FOLDER')
|
||||
|
||||
elif self.layout_type in {'GRID'}:
|
||||
layout.alignment = 'CENTER'
|
||||
@@ -117,6 +130,37 @@ class DLM_PT_main_panel(Panel):
|
||||
bl_category = 'Dynamic Link Manager'
|
||||
bl_label = "Dynamic Link Manager"
|
||||
|
||||
def get_short_path(self, filepath):
|
||||
"""Extract a short, readable path from a full filepath"""
|
||||
if not filepath:
|
||||
return "Unknown"
|
||||
|
||||
# Handle relative paths
|
||||
if filepath.startswith("//"):
|
||||
return "// (relative)"
|
||||
|
||||
# Handle Windows network paths
|
||||
if filepath.startswith("\\\\"):
|
||||
# Extract server name (e.g., \\NAS\ or \\NEXUS\)
|
||||
parts = filepath.split("\\")
|
||||
if len(parts) >= 3:
|
||||
return f"\\\\{parts[2]}\\"
|
||||
return "\\\\ (network)"
|
||||
|
||||
# Handle Windows drive paths
|
||||
if len(filepath) >= 2 and filepath[1] == ':':
|
||||
return f"{filepath[:2]}\\"
|
||||
|
||||
# Handle Unix-style paths
|
||||
if filepath.startswith("/"):
|
||||
parts = filepath.split("/")
|
||||
if len(parts) >= 2:
|
||||
return f"/{parts[1]}/"
|
||||
return "/ (root)"
|
||||
|
||||
# Fallback
|
||||
return "Unknown"
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
layout.operator("preferences.addon_show", text="", icon='PREFERENCES').module = __package__
|
||||
@@ -202,7 +246,10 @@ class DLM_PT_main_panel(Panel):
|
||||
else:
|
||||
info_box.label(text="Status: OK", icon='FILE_BLEND')
|
||||
|
||||
# Replace path display with Open Blend button
|
||||
# Show full path and Open Blend button
|
||||
row = info_box.row()
|
||||
row.label(text=f"Path: {selected_lib.filepath}", icon='FILE_FOLDER')
|
||||
|
||||
row = info_box.row()
|
||||
row.operator("dlm.open_linked_file", text="Open Blend", icon='FILE_BLEND').filepath = selected_lib.filepath
|
||||
|
||||
|
||||
Reference in New Issue
Block a user