Sketchfab Exporter: Update panel Rename
Bumped version to 1.2.3 As a part of the task T50726: Update the Panel rename code to more generic one Use tuple imports for bpy.types No other functional changes
This commit is contained in:
parent
e0bc0e758b
commit
9bde6ff5ac
|
@ -19,7 +19,7 @@
|
|||
bl_info = {
|
||||
"name": "Sketchfab Exporter",
|
||||
"author": "Bart Crouch",
|
||||
"version": (1, 2, 2),
|
||||
"version": (1, 2, 3),
|
||||
"blender": (2, 7, 0),
|
||||
"location": "Tools > File I/O tab",
|
||||
"description": "Upload your model to Sketchfab",
|
||||
|
@ -41,6 +41,13 @@ from bpy.props import (
|
|||
BoolProperty,
|
||||
PointerProperty,
|
||||
)
|
||||
from bpy.types import (
|
||||
Operator,
|
||||
Panel,
|
||||
AddonPreferences,
|
||||
PropertyGroup,
|
||||
)
|
||||
|
||||
|
||||
SKETCHFAB_API_URL = "https://api.sketchfab.com"
|
||||
SKETCHFAB_API_MODELS_URL = SKETCHFAB_API_URL + "/v1/models"
|
||||
|
@ -76,6 +83,7 @@ class _SketchfabState:
|
|||
self.report_message = ""
|
||||
self.report_type = ''
|
||||
|
||||
|
||||
sf_state = _SketchfabState()
|
||||
del _SketchfabState
|
||||
|
||||
|
@ -178,7 +186,7 @@ def upload(filepath, filename):
|
|||
|
||||
|
||||
# operator to export model to sketchfab
|
||||
class ExportSketchfab(bpy.types.Operator):
|
||||
class ExportSketchfab(Operator):
|
||||
"""Upload your model to Sketchfab"""
|
||||
bl_idname = "export.sketchfab"
|
||||
bl_label = "Upload"
|
||||
|
@ -284,7 +292,7 @@ class ExportSketchfab(bpy.types.Operator):
|
|||
|
||||
|
||||
# user interface
|
||||
class VIEW3D_PT_sketchfab(bpy.types.Panel):
|
||||
class VIEW3D_PT_sketchfab(Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'TOOLS'
|
||||
bl_category = "File I/O"
|
||||
|
@ -331,7 +339,7 @@ class VIEW3D_PT_sketchfab(bpy.types.Panel):
|
|||
|
||||
|
||||
# property group containing all properties for the user interface
|
||||
class SketchfabProps(bpy.types.PropertyGroup):
|
||||
class SketchfabProps(PropertyGroup):
|
||||
description = StringProperty(
|
||||
name="Description",
|
||||
description="Description of the model (optional)",
|
||||
|
@ -386,7 +394,7 @@ class SketchfabProps(bpy.types.PropertyGroup):
|
|||
)
|
||||
|
||||
|
||||
class SketchfabEmailToken(bpy.types.Operator):
|
||||
class SketchfabEmailToken(Operator):
|
||||
bl_idname = "wm.sketchfab_email_token"
|
||||
bl_label = "Enter your email to get a sketchfab token"
|
||||
|
||||
|
@ -426,34 +434,51 @@ def terminate(filepath):
|
|||
os.rmdir(os.path.dirname(filepath))
|
||||
|
||||
|
||||
## Addons Preferences Update Panel
|
||||
def update_panel(self, context):
|
||||
try:
|
||||
bpy.utils.unregister_class(VIEW3D_PT_sketchfab)
|
||||
except:
|
||||
pass
|
||||
VIEW3D_PT_sketchfab.bl_category = context.user_preferences.addons[__name__].preferences.category
|
||||
bpy.utils.register_class(VIEW3D_PT_sketchfab)
|
||||
# Add-ons Preferences Update Panel
|
||||
|
||||
class SfabAddonPreferences(bpy.types.AddonPreferences):
|
||||
# Define Panel classes for updating
|
||||
panels = (
|
||||
VIEW3D_PT_sketchfab,
|
||||
)
|
||||
|
||||
|
||||
def update_panel(self, context):
|
||||
message = "Sketchfab Exporter: Updating Panel locations has failed"
|
||||
try:
|
||||
for panel in panels:
|
||||
if "bl_rna" in panel.__dict__:
|
||||
bpy.utils.unregister_class(panel)
|
||||
|
||||
for panel in panels:
|
||||
panel.bl_category = context.user_preferences.addons[__name__].preferences.category
|
||||
bpy.utils.register_class(panel)
|
||||
|
||||
except Exception as e:
|
||||
print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
|
||||
pass
|
||||
|
||||
|
||||
class SfabAddonPreferences(AddonPreferences):
|
||||
# this must match the addon name, use '__package__'
|
||||
# when defining this in a submodule of a python package.
|
||||
bl_idname = __name__
|
||||
|
||||
category = bpy.props.StringProperty(
|
||||
category = StringProperty(
|
||||
name="Tab Category",
|
||||
description="Choose a name for the category of the panel",
|
||||
default="File I/O",
|
||||
update=update_panel)
|
||||
update=update_panel
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
layout = self.layout
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.label(text="Tab Category:")
|
||||
col.prop(self, "category", text="")
|
||||
|
||||
|
||||
# registration
|
||||
classes = (
|
||||
ExportSketchfab,
|
||||
|
@ -475,6 +500,7 @@ def register():
|
|||
bpy.app.handlers.load_post.append(load_token)
|
||||
update_panel(None, bpy.context)
|
||||
|
||||
|
||||
def unregister():
|
||||
for cls in classes:
|
||||
bpy.utils.unregister_class(cls)
|
||||
|
|
Loading…
Reference in New Issue