Skip to content

Commit

Permalink
ExplorerCreateFile 0.5: added some defaults
Browse files Browse the repository at this point in the history
fixing #67
  • Loading branch information
ewerybody committed Feb 13, 2022
1 parent a39fc36 commit a094130
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ExplorerCreateFile/a2_local_element_file_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import a2ahk
import a2util
import a2ctrl
from a2ctrl import Icons
Expand All @@ -22,6 +21,10 @@ def __init__(self, *args):
self.editor.ui.item_editor_layout.setStretch(0, 1)
self.editor.ui.item_editor_layout.setStretch(1, 4)
self.editor.ignore_default_values = False
if not self.user_cfg:
self.editor.set_data(a2util.json_read(os.path.join(THIS_DIR, 'defaults.json')))
self.check()

self.editor.set_data(self.user_cfg)
self.editor.data_changed.connect(self.delayed_check)
self.main_layout.addWidget(self.editor)
Expand Down Expand Up @@ -52,7 +55,6 @@ def __init__(self, *args):
encoding_combo = a2combo.A2Combo(self)
encoding_combo.setEditable(True)
encoding_combo.addItems(ENCODINGS)
icon_size = self.a2.win.style.get('icon_size_small')
encoding_help = QtWidgets.QToolButton(autoRaise=True, icon=Icons.help)
encoding_help.clicked.connect(_encoding_docs)
combo_lyt = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -97,7 +99,7 @@ def element_name():

@staticmethod
def element_icon():
return a2ctrl.Icons.inst().check
return a2ctrl.Icons.check


def get_settings(module_key, cfg, db_dict, user_cfg):
Expand Down
2 changes: 1 addition & 1 deletion ExplorerCreateFile/a2module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"typ": "nfo",
"url": "https://github.com/ewerybody/a2.modules/tree/master/ExplorerCreateFile#explorercreatefile",
"version": "0.4"
"version": "0.5"
},
{
"children": [
Expand Down
24 changes: 24 additions & 0 deletions ExplorerCreateFile/defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Autohotkey": {
"ext": ".ahk",
"file_name": "ahk_script",
"content": "#SingleInstance, Force\nSendMode, Input\nSetWorkingDir, %A_ScriptDir%",
"encoding": "UTF-8 (with BOM)",
"ask": true
},
"Python": {
"ext": ".py",
"file_name": "__init__",
"content": "def main():\n pass\n\nif __name__ == '__main__':\n main()",
"ask": true
},
"Text": {
"ext": ".txt",
"file_name": "readme",
"encoding": "UTF-8 (Raw)",
"ask": true
},
".any": {
"ask": true
}
}

0 comments on commit a094130

Please sign in to comment.