Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
- Missing workspace name causing error
  • Loading branch information
schroef committed Oct 31, 2023
1 parent 0c35965 commit 2b18458
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ assignees: schroef

---

**Describe your request**
**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
All notable changes to this project will be documented in this file.
# Changelog

## v0.2.5
## 2023-10-31
### Added
- missing workspace names causing error when switching

## v0.2.4
## 2023-05-09
### Added
- shortcut for 3 button enum, handy for laptop users

## [0.2.3] - 2022-09-23
### Added
- Opening prefs operator shows addon expanded
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Keepmode will store the object interaction mode. So for example when your in mod

> Some limitations are currently present due to Beta containing some bugs
!['Look UI'](https://raw.githubusercontent.com/wiki/schroef/quickswitch/images/quickswitch-v023.png?v20220923)
!['Look UI'](https://raw.githubusercontent.com/wiki/schroef/quickswitch/images/quickswitch-v025.png?v20231031)

> Choose either Pie menu or WM menu
Expand All @@ -20,7 +20,7 @@ Keepmode will store the object interaction mode. So for example when your in mod
| **OS** | **Blender** |
| ------------- | ------------- |
| OSX | Blender 2.80+ |
| Windows | Not Tested |
| Windows | Blender 2.80+ |
| Linux | Not Tested |


Expand Down
98 changes: 73 additions & 25 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@
### Added
## - Opening prefs operator shows addon expanded

## v0.2.4
## 2023-05-09
### Added
## - shortcut for 3 button enum, handy for laptop users

## v0.2.5
## 2023-10-31
### Added
## - missing workspace names

"""
TODO
Expand All @@ -180,7 +190,7 @@
"description": "QuickSwitch is a little helper to make it easier to switch render engines & workspaces",
"location": "3D VIEW > Quick Switch (see hotkeys)",
"author": "Rombout Versluijs",
"version": (0, 2, 2),
"version": (0, 2, 5),
"blender": (2, 80, 0),
"wiki_url": "https://github.com/schroef/quickswitch",
"tracker_url": "https://github.com/schroef/quickswitch/issues",
Expand Down Expand Up @@ -314,6 +324,9 @@ class QS_defaultWSSmodes(PropertyGroup):
Rendering : StringProperty(
name = "Rendering",
default='OBJECT')
Video_Editing : StringProperty(
name = "Video_Editing",
default='OBJECT')
Animation : StringProperty(
name = "Animation",
default='POSE')
Expand All @@ -330,6 +343,7 @@ class QS_defaultWSSmodes(PropertyGroup):
@persistent
def on_scene_update(scene):
context = bpy.context
# print("PERSISTENT update %s" % context.active_object)
scene = context.scene
ws = context.workspace
# settings = scene["qsWSsmode"]
Expand All @@ -345,6 +359,7 @@ def on_scene_update(scene):
settings.Texture_Paint = 'TEXTURE_PAINT'
settings.Shading = 'OBJECT'
settings.Animation = 'POSE'
settings.Video_Editing = 'OBJECT'
settings.Rendering = 'OBJECT'
settings.Compositing = 'OBJECT'
settings.Scripting = 'OBJECT'
Expand Down Expand Up @@ -417,21 +432,21 @@ def on_scene_update(scene):
# return

def ViewPort(wsn):
""" Return position, rotation data about a given view for the first space attached to it """
global viewLoc, distance, matrix, rotation
""" Return position, rotation data about a given view for the first space attached to it """
global viewLoc, distance, matrix, rotation

for i, area in enumerate(bpy.context.screen.areas):
if area.type == 'VIEW_3D':
wsp = bpy.context.window.workspace
rv3d = area.spaces[0].region_3d
viewLoc = rv3d.view_location
distance = rv3d.view_distance
matrix = rv3d.view_matrix
rotation = rv3d.view_rotation
#camera_pos = self.camera_position(matrix)
#rotation = rotation[0],rotation[1],rotation[2],rotation[3]
#return view_Loc, rotation, distance #camera_pos,
# print("Vloc: %s | Dist %s | Mtrx %s | Rot %s" % (viewLoc, distance, matrix, rotation))
for i, area in enumerate(bpy.context.screen.areas):
if area.type == 'VIEW_3D':
wsp = bpy.context.window.workspace
rv3d = area.spaces[0].region_3d
viewLoc = rv3d.view_location
distance = rv3d.view_distance
matrix = rv3d.view_matrix
rotation = rv3d.view_rotation
#camera_pos = self.camera_position(matrix)
#rotation = rotation[0],rotation[1],rotation[2],rotation[3]
#return view_Loc, rotation, distance #camera_pos,
# print("Vloc: %s | Dist %s | Mtrx %s | Rot %s" % (viewLoc, distance, matrix, rotation))


class QS_Store3DView(PropertyGroup):
Expand Down Expand Up @@ -669,7 +684,7 @@ def draw(self, context):
kc = wm.keyconfigs.user
km = kc.keymaps['Screen']

icons = [('Layout','VIEW3D'),('Modeling','VIEW3D'),('Sculpting','SCULPTMODE_HLT'),('UV Editing','UV'),('Texture Paint','IMAGE'),('Shading','SHADING_RENDERED'),('Animation','RENDER_ANIMATION'),('Rendering','RENDER_STILL'),('Compositing','NODE_COMPOSITING'),('Scripting','CONSOLE'),('Default','WORKSPACE')]
icons = [('Layout','VIEW3D'),('Modeling','VIEW3D'),('Sculpting','SCULPTMODE_HLT'),('UV Editing','UV'),('Texture Paint','IMAGE'),('Shading','SHADING_RENDERED'),('Animation','RENDER_ANIMATION'),('Video Editing','SEQUENCE'),('Rendering','RENDER_STILL'),('Compositing','NODE_COMPOSITING'),('Scripting','CONSOLE'),('Default','WORKSPACE')]

for i in range(0,8):
kmi = get_hotkey_entry_item(km, 'qs.workspace_set_layout', 'WorkspaceSwitcher'+str(i), 'layoutname')
Expand Down Expand Up @@ -718,7 +733,7 @@ def draw(self, context):
#for i in range(0,len(get_names_workspaces(self, context))):
# layout.operator("qs.workspace_set_layout", text='{}'.format(get_names_workspaces(self, context)[i][1]), icon='SEQ_SPLITVIEW').wslayoutMenu=get_names_workspaces(self, context)[i][1]

icons = [('Layout','VIEW3D'),('Modeling','VIEW3D'),('Sculpting','SCULPTMODE_HLT'),('UV Editing','GROUP_UVS'),('Texture Paint','IMAGE'),('Shading','SHADING_RENDERED'),('Animation','RENDER_ANIMATION'),('Rendering','RENDER_STILL'),('Compositing','NODE_COMPOSITING'),('Scripting','CONSOLE'),('Default','WORKSPACE')]
icons = [('Layout','VIEW3D'),('Modeling','VIEW3D'),('Sculpting','SCULPTMODE_HLT'),('UV Editing','GROUP_UVS'),('Texture Paint','IMAGE'),('Shading','SHADING_RENDERED'),('Animation','RENDER_ANIMATION'),('Video Editing','SEQUENCE'),('Rendering','RENDER_STILL'),('Compositing','NODE_COMPOSITING'),('Scripting','CONSOLE'),('Default','WORKSPACE')]

## Custom order
for i in range(0,len(get_names_workspaces(self, context))):
Expand Down Expand Up @@ -774,7 +789,7 @@ def execute(self,context):
# https://blender.stackexchange.com/questions/230698/question-about-managing-the-preferences-window-python
# Show expanded
import addon_utils
module_name = "node_presets"
module_name = "quickswitch"
bpy.ops.preferences.addon_expand(module=module_name)# get_addon_name() it is a small function that returns the name of the addon (For my convenience)
bpy.ops.preferences.addon_show(module=module_name) # Show my addon pref

Expand All @@ -793,11 +808,18 @@ def execute(self,context):
break
else:
wsN = ws.name
# print(type(wsN))
# wsN.replace("\s", "_")
# wsN.replace('/\s/g', '_')
wsN = wsN.replace(' ','_')
# print(wsN)
#print(ws.name)
if wsN == 'UV Editing':
wsN = 'UV_Editing'
if wsN == 'Texture Paint':
wsN = 'Texture_Paint'
# if wsN == 'UV Editing':
# wsN = 'UV_Editing'
# if wsN == 'Texture Paint':
# wsN = 'Texture_Paint'
# if wsN == 'Video Editting':
# wsN = 'Video_Editting'

# Set interaction mode
ws.object_mode = scene.qsWSsmode[wsN]
Expand Down Expand Up @@ -994,7 +1016,32 @@ def ui_add_menu(self, context):
row.operator(QD_OT_Sync_ViewData.bl_idname, icon="UV_SYNC_SELECT",text="")
# row.operator(QD_OT_Sync_ViewData.bl_idname, icon="UV_SYNC_SELECT")
row.operator(QD_OT_Reset_ViewData.bl_idname, icon="LOOP_BACK", text="")




class V3D_OT_EmuThreeButton(bpy.types.Operator):
"""Tooltip"""
bl_idname = "view3d.toggle_emuthreebutton"
bl_label = "Toggle Emulate 3 Button Mouse"

def execute(self, context):
bpy.ops.wm.context_toggle(data_path = "preferences.inputs.use_mouse_emulate_3_button")
return {'FINISHED'}


def Header_MT_EmuThreeButton(self, context):
layout = self.layout
prefs = context.preferences
row = layout.row()
row.operator("view3d.toggle_emuthreebutton",text="",icon='MOUSE_MMB', depress=(getattr(prefs.inputs,"use_mouse_emulate_3_button")))
# layout.prop(prefs.inputs, "use_mouse_emulate_3_button",text="", icon='MOUSE_MMB', toggle=True)
# this cant be added to quick favs nor shirtcut added
# op = layout.operator("wm.context_toggle",text="", icon='MOUSE_MMB')
# op.data_path = "preferences.inputs.use_mouse_emulate_3_button"




########################################################


Expand Down Expand Up @@ -1096,6 +1143,7 @@ def draw(self, context):
QS_MT_WorkspaceSwitchMenu,
QS_OT_SetWorkspace,
QS_OT_path_open,
V3D_OT_EmuThreeButton,
]

def register():
Expand All @@ -1114,14 +1162,14 @@ def register():
bpy.app.handlers.depsgraph_update_pre.append(on_scene_update)
# bpy.app.handlers.depsgraph_update_pre.append(on_ws_switch)
bpy.types.VIEW3D_PT_view3d_properties.prepend(ui_add_menu)

bpy.types.VIEW3D_HT_header.append(Header_MT_EmuThreeButton)


def unregister():
bpy.app.handlers.depsgraph_update_pre.remove(on_scene_update)
# bpy.app.handlers.depsgraph_update_pre.remove(on_ws_switch)
bpy.types.VIEW3D_PT_view3d_properties.remove(ui_add_menu)

bpy.types.VIEW3D_HT_header.remove(Header_MT_EmuThreeButton)
# handle the keymap
for km, kmi in addon_keymaps:
print("QS: %s - %s" % (km,kmi))
Expand Down

0 comments on commit 2b18458

Please sign in to comment.