forked from xtoolbox/pcad2kicad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.lua
82 lines (75 loc) · 2.34 KB
/
script.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- XToolBox initial script
function log(...)
local r = ""
for k,v in pairs({...}) do
r = r .. " " .. tostring(v)
end
logEdit:append(r)
end
require("pcad_lib")
class "PCadView"(QFrame)
function PCadView:__init()
QFrame.__init(self)
self.fileName = QLineEdit("Miscellaneous Devices LC.lia")
self.btnParse = QPushButton("Convert to KiCad footprint")
self.textLibName = QLineEdit{
placeHolderText = "Use lib name in the lia file"
}
self.status = QLabel("")
self.btnSelectFile = QPushButton("Load PCAD lib")
self.textLibPath = QLineEdit{
placeHolderText = "Use the lia file path"
}
self.btnLibPath = QPushButton("Set ouput path")
self.layout = QVBoxLayout{
QHBoxLayout{
QLabel("PCAD lib:"),
self.fileName,
self.btnSelectFile,
},
QHBoxLayout{
QLabel("Ouput library name:"),
self.textLibName,
},
QHBoxLayout{
QLabel("Output library path"),
self.textLibPath,
self.btnLibPath
},
self.btnParse,
QHBoxLayout{
QLabel("Current Progress:"), self.status, QLabel(""), strech = "0,0,1"
},
}
function progress(cur, total)
self.status.text = tostring(cur) .. "/"..total
self:startTimer(1)
coroutine.yield()
end
function log_info(...)
log(...)
self:startTimer(1)
coroutine.yield()
end
self.btnSelectFile.clicked = function()
local r = QCommonDlg.getOpenFileName("Select the pcad library file", "", "PCAD lib (*.lia);;All files (*)")
if r ~= "" then self.fileName.text = r end
end
self.btnLibPath.clicked = function()
local r = QCommonDlg.getDir("Set kicad library output path")
if r ~= "" then self.textLibPath.text = r end
if pcad_contimue then pcad_contimue() end
end
self.btnParse.clicked = function()
self.co = coroutine.create(function()
parse_pcad_lib(self.fileName.text, self.textLibName.text, self.textLibPath.text, progress, log_info)
end)
coroutine.resume(self.co)
end
self.eventFilter = QTimerEvent.filter(function(obj, evt)
self:killTimer(evt.timerId)
coroutine.resume(self.co)
end)
end
local dd = PCadView()
mdiArea:addSubWindow(dd):show()