Skip to content

Commit

Permalink
some code refactoring for better naming, reset option, remvoing unnec…
Browse files Browse the repository at this point in the history
…essary code ...
  • Loading branch information
Aranuvir committed Aug 21, 2018
1 parent 957b32d commit 8c767ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions makehuman/core/mhmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def __init__(self):
'guiTheme': 'makehuman',
'restoreWindowSize': True,
'windowGeometry': '',
'tagsMode': 'OR'
'tagFilterMode': 'OR'
}
else:
self._default_settings = {
Expand All @@ -258,7 +258,7 @@ def __init__(self):
'preloadTargets': False,
'restoreWindowSize': True,
'windowGeometry': '',
'tagsMode': 'OR'
'tagFilterMode': 'OR'
}

self._settings = dict(self._default_settings)
Expand Down
6 changes: 3 additions & 3 deletions makehuman/lib/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def onClicked(self, event):

class TagFilter(gui.GroupBox):
def __init__(self):
super(TagFilter, self).__init__('Tag filter [Mode : ' + self.convertModes(mh.getSetting('tagsMode')) + ']')
super(TagFilter, self).__init__('Tag Filter [Mode : ' + self.convertModes(mh.getSetting('tagFilterMode')) + ']')
self.tags = set()
self.selectedTags = set()
self.tagToggles = []
Expand All @@ -294,7 +294,7 @@ def onClicked(event):

def onShow(self, event):
super(TagFilter, self).onShow(event)
self.setTitle('Tag filter [Mode : ' + self.convertModes(mh.getSetting('tagsMode')) + ']')
self.setTitle('Tag Filter [Mode : ' + self.convertModes(mh.getSetting('tagFilterMode')) + ']')

def showTags(self):
if self.tagToggles:
Expand Down Expand Up @@ -340,7 +340,7 @@ def filterActive(self):
return len(self.getSelectedTags()) > 0

def filter(self, items):
mode = mh.getSetting('tagsMode')
mode = mh.getSetting('tagFilterMode')
if not self.filterActive():
for item in items:
item.setHidden(False)
Expand Down
32 changes: 18 additions & 14 deletions makehuman/plugins/5_settings_0_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ def updateSliderImages(selected):
self.rel_weight = weightBox.addWidget(gui.RadioButton(weights, 'Relative Weight', not gui3d.app.getSetting('real_weight')))
self.real_weight = weightBox.addWidget(gui.RadioButton(weights, 'Real Weight', gui3d.app.getSetting('real_weight')))

tagsModes = []
tagsBox = self.addLeftWidget(gui.GroupBox('Tag Filter Mode'))
self.or_mode = tagsBox.addWidget(gui.RadioButton(tagsModes, 'OR', gui3d.app.getSetting('tagsMode') == 'OR'), 0, 0)
self.and_mode = tagsBox.addWidget(gui.RadioButton(tagsModes, 'AND', gui3d.app.getSetting('tagsMode') == 'AND'), 0, 1)
self.nor_mode = tagsBox.addWidget(gui.RadioButton(tagsModes, 'NOT OR', gui3d.app.getSetting('tagsMode') == 'NOR'), 1, 0)
self.nand_mode = tagsBox.addWidget(gui.RadioButton(tagsModes, 'NOT AND', gui3d.app.getSetting('tagsMode') == 'NAND'), 1, 1)
tagFilter = []
self.tagFilterBox = self.addLeftWidget(gui.GroupBox('Tag Filter Mode'))
self.or_mode = self.tagFilterBox.addWidget(gui.RadioButton(tagFilter, 'OR', gui3d.app.getSetting('tagFilterMode') == 'OR'), 0, 0)
self.and_mode = self.tagFilterBox.addWidget(gui.RadioButton(tagFilter, 'AND', gui3d.app.getSetting('tagFilterMode') == 'AND'), 0, 1)
self.nor_mode = self.tagFilterBox.addWidget(gui.RadioButton(tagFilter, 'NOT OR', gui3d.app.getSetting('tagFilterMode') == 'NOR'), 1, 0)
self.nand_mode = self.tagFilterBox.addWidget(gui.RadioButton(tagFilter, 'NOT AND', gui3d.app.getSetting('tagFilterMode') == 'NAND'), 1, 1)


startupBox = self.addLeftWidget(gui.GroupBox('Startup'))
Expand Down Expand Up @@ -208,19 +208,19 @@ def onClicked(event):

@self.and_mode.mhEvent
def onClicked(event):
gui3d.app.setSetting('tagsMode', 'AND')
gui3d.app.setSetting('tagFilterMode', 'AND')

@self.or_mode.mhEvent
def onClicked(event):
gui3d.app.setSetting('tagsMode', 'OR')
gui3d.app.setSetting('tagFilterMode', 'OR')

@self.nor_mode.mhEvent
def onClicked(event):
gui3d.app.setSetting('tagsMode', 'NOR')
gui3d.app.setSetting('tagFilterMode', 'NOR')

@self.nand_mode.mhEvent
def onClicked(event):
gui3d.app.setSetting('tagsMode', 'NAND')
gui3d.app.setSetting('tagFilterMode', 'NAND')

self.updateGui()

Expand All @@ -231,19 +231,15 @@ def updateGui(self):
use_metric = gui3d.app.getSetting('units') == 'metric'
if use_metric:
self.metric.setChecked(True)
gui3d.app.setSetting('units', 'metric')
else:
self.imperial.setChecked(True)
gui3d.app.setSetting('units', 'imperial')
gui3d.app.loadGrid()

use_real_weight = gui3d.app.getSetting('real_weight')
if use_real_weight:
self.real_weight.setChecked(True)
gui3d.app.setSetting('real_weight', True)
else:
self.rel_weight.setChecked(True)
gui3d.app.setSetting('real_weight', False)

lang = gui3d.app.getSetting('language')
for radioBtn in self.languageBox.children:
Expand All @@ -255,6 +251,14 @@ def updateGui(self):
if radioBtn.theme == theme:
radioBtn.updateButton(True)

convmodes = {'NOR': 'NOT OR',
'NAND': 'NOT AND'}
mode = convmodes.get(gui3d.app.getSetting('tagFilterMode'), gui3d.app.getSetting('tagFilterMode'))

for radioBtn in self.tagFilterBox.children:
radioBtn.setChecked(radioBtn.getLabel() == mode)


def onShow(self, event):
gui3d.TaskView.onShow(self, event)

Expand Down

0 comments on commit 8c767ad

Please sign in to comment.