fix: link session status icons to session header

This commit is contained in:
Fabian 2021-07-12 14:55:41 +02:00
parent a82d263f05
commit 41c7c569ca
2 changed files with 18 additions and 5 deletions

View File

@ -61,6 +61,7 @@ def register():
from . import operators from . import operators
from . import handlers from . import handlers
from . import ui from . import ui
from . import icons
from . import preferences from . import preferences
from . import addon_updater_ops from . import addon_updater_ops
@ -70,6 +71,7 @@ def register():
operators.register() operators.register()
handlers.register() handlers.register()
ui.register() ui.register()
icons.register()
except ModuleNotFoundError as e: except ModuleNotFoundError as e:
raise Exception(module_error_msg) raise Exception(module_error_msg)
logging.error(module_error_msg) logging.error(module_error_msg)
@ -91,6 +93,7 @@ def unregister():
from . import operators from . import operators
from . import handlers from . import handlers
from . import ui from . import ui
from . import icons
from . import preferences from . import preferences
from . import addon_updater_ops from . import addon_updater_ops
@ -99,6 +102,7 @@ def unregister():
presence.unregister() presence.unregister()
addon_updater_ops.unregister() addon_updater_ops.unregister()
ui.unregister() ui.unregister()
icons.unregister()
handlers.unregister() handlers.unregister()
operators.unregister() operators.unregister()
preferences.unregister() preferences.unregister()

View File

@ -17,6 +17,7 @@
import bpy import bpy
import bpy.utils.previews
from .utils import get_preferences, get_expanded_icon, get_folder_size, get_state_str from .utils import get_preferences, get_expanded_icon, get_folder_size, get_state_str
from replication.constants import (ADDED, ERROR, FETCHED, from replication.constants import (ADDED, ERROR, FETCHED,
@ -71,19 +72,26 @@ class SESSION_PT_settings(bpy.types.Panel):
def draw_header(self, context): def draw_header(self, context):
layout = self.layout layout = self.layout
settings = get_preferences()
from multi_user import icons
offline_icon = icons.icons_col["session_status_offline"]
waiting_icon = icons.icons_col["session_status_waiting"]
online_icon = icons.icons_col["session_status_online"]
if session and session.state != STATE_INITIAL: if session and session.state != STATE_INITIAL:
cli_state = session.state cli_state = session.state
state = session.state state = session.state
connection_icon = "KEYTYPE_MOVING_HOLD_VEC" connection_icon = offline_icon
if state == STATE_ACTIVE: if state == STATE_ACTIVE:
connection_icon = 'PROP_ON' connection_icon = online_icon
else: else:
connection_icon = 'PROP_CON' connection_icon = waiting_icon
layout.label(text=f"Session - {get_state_str(cli_state)}", icon=connection_icon) layout.label(text=f"{str(settings.server_name)} - {get_state_str(cli_state)}", icon_value=connection_icon.icon_id)
else: else:
layout.label(text=f"Session - v{__version__}",icon="PROP_OFF") layout.label(text=f"Multi-user - v{__version__}", icon="ANTIALIASED")
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@ -668,6 +676,7 @@ classes = (
VIEW3D_PT_overlay_session, VIEW3D_PT_overlay_session,
) )
preview_collections = {}
register, unregister = bpy.utils.register_classes_factory(classes) register, unregister = bpy.utils.register_classes_factory(classes)