Fixed name/app name issues. They are now separate.
This commit is contained in:
parent
4adf5e11fa
commit
14def4e8e9
5 changed files with 55 additions and 10 deletions
|
|
@ -71,6 +71,8 @@ class Setting(object):
|
||||||
self.button_callback = kwargs.pop('button_callback', None)
|
self.button_callback = kwargs.pop('button_callback', None)
|
||||||
self.description = kwargs.pop('description', '')
|
self.description = kwargs.pop('description', '')
|
||||||
self.values = kwargs.pop('values', [])
|
self.values = kwargs.pop('values', [])
|
||||||
|
self.filter = kwargs.pop('filter', '(?s).*')
|
||||||
|
self.filter_action = kwargs.pop('filter_action', 'None')
|
||||||
|
|
||||||
self.set_extra_attributes_from_keyword_args(**kwargs)
|
self.set_extra_attributes_from_keyword_args(**kwargs)
|
||||||
|
|
||||||
|
|
@ -81,6 +83,12 @@ class Setting(object):
|
||||||
|
|
||||||
self.get_file_information_from_url()
|
self.get_file_information_from_url()
|
||||||
|
|
||||||
|
def filter_name(self, text):
|
||||||
|
action = unicode
|
||||||
|
if hasattr(unicode, self.filter_action):
|
||||||
|
action = getattr(unicode, self.filter_action)
|
||||||
|
return action(unicode(text))
|
||||||
|
|
||||||
def get_file_information_from_url(self):
|
def get_file_information_from_url(self):
|
||||||
if hasattr(self, 'url'):
|
if hasattr(self, 'url'):
|
||||||
self.file_name = self.url.split('/')[-1]
|
self.file_name = self.url.split('/')[-1]
|
||||||
|
|
@ -289,7 +297,7 @@ class CommandBase(object):
|
||||||
|
|
||||||
def project_name(self):
|
def project_name(self):
|
||||||
return (self._project_name or
|
return (self._project_name or
|
||||||
os.path.basename(os.path.dirname(self.project_dir())))
|
os.path.basename(os.path.abspath(self.project_dir())))
|
||||||
|
|
||||||
def get_setting(self, name):
|
def get_setting(self, name):
|
||||||
for setting_group in (self.settings['setting_groups'] +
|
for setting_group in (self.settings['setting_groups'] +
|
||||||
|
|
@ -864,7 +872,14 @@ if __name__ == '__main__':
|
||||||
command_base._output_dir = (args.output_dir or
|
command_base._output_dir = (args.output_dir or
|
||||||
os.path.join(args.project_dir, 'output'))
|
os.path.join(args.project_dir, 'output'))
|
||||||
|
|
||||||
command_base._project_name = args.name if not callable(args.name) else args.name()
|
if args.app_name is None:
|
||||||
|
args.app_name = command_base.project_name()
|
||||||
|
|
||||||
|
if args.name is not None:
|
||||||
|
setting = command_base.get_setting('name')
|
||||||
|
args.name = setting.filter_name(args.name if not callable(args.name) else args.name())
|
||||||
|
|
||||||
|
command_base._project_name = args.app_name if not callable(args.app_name) else args.app_name()
|
||||||
|
|
||||||
if not args.title:
|
if not args.title:
|
||||||
args.title = command_base.project_name()
|
args.title = command_base.project_name()
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@
|
||||||
0.12.0-alpha2
|
0.12.0-alpha2
|
||||||
0.12.0-alpha1
|
0.12.0-alpha1
|
||||||
0.12.0
|
0.12.0
|
||||||
0.11.6
|
|
||||||
0.11.5
|
|
||||||
0.11.4
|
|
||||||
0.11.3
|
0.11.3
|
||||||
0.11.2
|
0.11.2
|
||||||
0.11.1
|
0.11.1
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,17 @@ linux_64_dir_prefix = 'node-webkit-v{}-linux-x64'
|
||||||
file_types='*.html *.php *.htm'
|
file_types='*.html *.php *.htm'
|
||||||
description='Main html file relative to the project directory.'
|
description='Main html file relative to the project directory.'
|
||||||
[[[name]]]
|
[[[name]]]
|
||||||
display_name='App Name'
|
display_name='Name'
|
||||||
required=True
|
required=True
|
||||||
type='string'
|
type='string'
|
||||||
|
description='The name in the internal package.json. Must be alpha-numeric with no spaces.'
|
||||||
|
filter='[a-z0-9_\-\.]+'
|
||||||
|
filter_action='lower'
|
||||||
|
[[[app_name]]]
|
||||||
|
display_name='App Name'
|
||||||
|
required=False
|
||||||
|
type='string'
|
||||||
|
description='The name that your executable or app will have when exported.'
|
||||||
[[[description]]]
|
[[[description]]]
|
||||||
default_value=''
|
default_value=''
|
||||||
type='string'
|
type='string'
|
||||||
|
|
@ -308,7 +316,7 @@ linux_64_dir_prefix = 'node-webkit-v{}-linux-x64'
|
||||||
|
|
||||||
|
|
||||||
[order]
|
[order]
|
||||||
application_setting_order="""['main', 'name', 'node-main', 'description', 'version', 'keywords',
|
application_setting_order="""['main', 'name', 'app_name', 'node-main', 'description', 'version', 'keywords',
|
||||||
'user-agent', 'chromium-args',
|
'user-agent', 'chromium-args',
|
||||||
'node-remote', 'js-flags', 'inject-js-start', 'inject-js-end',
|
'node-remote', 'js-flags', 'inject-js-start', 'inject-js-end',
|
||||||
'additional_trust_anchors', 'snapshot',
|
'additional_trust_anchors', 'snapshot',
|
||||||
|
|
|
||||||
31
main.py
31
main.py
|
|
@ -16,6 +16,23 @@ from PySide.QtCore import QUrl, QFile, QIODevice, QCoreApplication
|
||||||
from command_line import CWD, CommandBase
|
from command_line import CWD, CommandBase
|
||||||
|
|
||||||
|
|
||||||
|
class Validator(QtGui.QRegExpValidator):
|
||||||
|
def __init__(self, regex, action, parent=None):
|
||||||
|
self.exp = regex
|
||||||
|
self.action = unicode
|
||||||
|
if hasattr(unicode, action):
|
||||||
|
self.action = getattr(unicode, action)
|
||||||
|
reg = QtCore.QRegExp(regex)
|
||||||
|
super(Validator, self).__init__(reg, parent)
|
||||||
|
|
||||||
|
def validate(self, text, pos):
|
||||||
|
result = super(Validator, self).validate(text, pos)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def fixup(self, text):
|
||||||
|
return ''.join(re.findall(self.exp, self.action(unicode(text))))
|
||||||
|
|
||||||
|
|
||||||
class BackgroundThread(QtCore.QThread):
|
class BackgroundThread(QtCore.QThread):
|
||||||
def __init__(self, widget, method_name, parent=None):
|
def __init__(self, widget, method_name, parent=None):
|
||||||
QtCore.QThread.__init__(self, parent)
|
QtCore.QThread.__init__(self, parent)
|
||||||
|
|
@ -478,7 +495,7 @@ class MainWindow(QtGui.QWidget, CommandBase):
|
||||||
return children
|
return children
|
||||||
|
|
||||||
def project_name(self):
|
def project_name(self):
|
||||||
return self.find_child_by_name('name').text()
|
return self.find_child_by_name('app_name').text()
|
||||||
|
|
||||||
def browse_dir(self):
|
def browse_dir(self):
|
||||||
self.update_json = False
|
self.update_json = False
|
||||||
|
|
@ -499,10 +516,17 @@ class MainWindow(QtGui.QWidget, CommandBase):
|
||||||
if files:
|
if files:
|
||||||
setting_input.setText(files[0].replace(self.project_dir() + os.path.sep, ''))
|
setting_input.setText(files[0].replace(self.project_dir() + os.path.sep, ''))
|
||||||
|
|
||||||
app_name_input = self.find_child_by_name('name')
|
app_name_input = self.find_child_by_name('app_name')
|
||||||
|
name_input = self.find_child_by_name('name')
|
||||||
|
name_setting = self.get_setting('name')
|
||||||
title_input = self.find_child_by_name('title')
|
title_input = self.find_child_by_name('title')
|
||||||
|
|
||||||
|
if not name_input.text():
|
||||||
|
name_input.setText(name_setting.filter_name(proj_name))
|
||||||
|
|
||||||
if not app_name_input.text():
|
if not app_name_input.text():
|
||||||
app_name_input.setText(proj_name)
|
app_name_input.setText(proj_name)
|
||||||
|
|
||||||
if not title_input.text():
|
if not title_input.text():
|
||||||
title_input.setText(proj_name)
|
title_input.setText(proj_name)
|
||||||
|
|
||||||
|
|
@ -614,6 +638,7 @@ class MainWindow(QtGui.QWidget, CommandBase):
|
||||||
setting = self.get_setting(name)
|
setting = self.get_setting(name)
|
||||||
|
|
||||||
text = QtGui.QLineEdit()
|
text = QtGui.QLineEdit()
|
||||||
|
text.setValidator(Validator(setting.filter, setting.filter_action))
|
||||||
text.setObjectName(setting.name)
|
text.setObjectName(setting.name)
|
||||||
|
|
||||||
text.textChanged.connect(self.call_with_object('setting_changed',
|
text.textChanged.connect(self.call_with_object('setting_changed',
|
||||||
|
|
@ -833,7 +858,7 @@ class MainWindow(QtGui.QWidget, CommandBase):
|
||||||
setting.type == 'string' or
|
setting.type == 'string' or
|
||||||
setting.type == 'folder'):
|
setting.type == 'folder'):
|
||||||
val_str = self.convert_val_to_str(setting.value)
|
val_str = self.convert_val_to_str(setting.value)
|
||||||
setting_field.setText(val_str)
|
setting_field.setText(setting.filter_name(val_str))
|
||||||
if setting.type == 'check':
|
if setting.type == 'check':
|
||||||
setting_field.setChecked(setting.value)
|
setting_field.setChecked(setting.value)
|
||||||
if setting.type == 'list':
|
if setting.type == 'list':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue