-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingleselect.go
159 lines (101 loc) · 3.29 KB
/
singleselect.go
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package main
import (
"github.com/therecipe/qt/widgets"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/core"
"io/ioutil"
"strings"
)
var (
comboVideo *widgets.QComboBox
comboSub *widgets.QComboBox
VideoTypeFilters = `mkv,avi,mp4,wmv,flv`
SubTypeFilters = `srt,ass`
VideoTypeFilter, SubTypeFilter []string
)
func init() {
VideoTypeFilter = strings.Split(VideoTypeFilters,`,`)
SubTypeFilter = strings.Split(SubTypeFilters,`,`)
}
func NewSingleSelect() *widgets.QWidget {
var singleSelect = widgets.NewQWidget(nil, 0)
singleSelect.SetLayout(sss_ui())
return singleSelect
}
func sss_ui() *widgets.QVBoxLayout {
var vlayoutPanel = widgets.NewQVBoxLayout()
var hlayoutPanel1 = widgets.NewQHBoxLayout()
var hlayoutPanel2 = widgets.NewQHBoxLayout()
comboVideo = widgets.NewQComboBox(nil)
var btnVideosPath = widgets.NewQPushButton3(gui.NewQIcon5(":/icons/folder.png"), "", nil)
btnVideosPath.SetMaximumWidth(30)
hlayoutPanel1.AddWidget(comboVideo, 0, 0)
hlayoutPanel1.AddWidget(btnVideosPath, 0, 0)
vlayoutPanel.AddLayout(hlayoutPanel1, 0)
comboSub = widgets.NewQComboBox(nil)
var btnSubPath = widgets.NewQPushButton3(gui.NewQIcon5(":/icons/folder.png"), "", nil)
btnSubPath.SetMaximumWidth(30)
hlayoutPanel2.AddWidget(comboSub, 0, 0)
hlayoutPanel2.AddWidget(btnSubPath, 0, 0)
vlayoutPanel.AddLayout(hlayoutPanel2, 0)
var spacerPushUp = widgets.NewQSpacerItem(1, 1, widgets.QSizePolicy__Minimum, widgets.QSizePolicy__MinimumExpanding)
vlayoutPanel.AddItem(spacerPushUp)
btnVideosPath.ConnectClicked(func(_ bool) { singleSelect_vDialog() })
btnSubPath.ConnectClicked(func(_ bool) { singleSelect_sDialog() })
return vlayoutPanel
}
func singleSelect_vDialog() {
fd := widgets.NewQFileDialog(window, core.Qt__Dialog)
d := fd.GetExistingDirectory(window, `Open Directory`, core.QDir_Root().RootPath(), widgets.QFileDialog__DontUseNativeDialog)
if d == `` { return }
files, err := ioutil.ReadDir(d)
if err != nil {
println(err)
}
var s []string
for _, file := range files {
fn := file.Name()
if extwithin(fn, VideoTypeFilter) {
s = append(s, fn)
}
}
comboVideo.AddItems(s)
}
func singleSelect_sDialog() {
fd := widgets.NewQFileDialog(window, core.Qt__Dialog)
d := fd.GetExistingDirectory(window, `Open Directory`, core.QDir_Root().RootPath(), widgets.QFileDialog__DontUseNativeDialog)
if d == `` { return }
files, err := ioutil.ReadDir(d)
if err != nil {
println(err)
}
var s []string
for _, file := range files {
fn := file.Name()
if extwithin(fn, SubTypeFilter) {
s = append(s, fn)
}
}
comboSub.AddItems(s)
}
func extwithin(s string, c []string) bool {
st := strings.Split(s, `.`)
s = st[len(st)-1]
for _, str := range c {
if str == s { return true }
}
return false
}
func within(s string, c []string) bool {
for _, str := range c {
if str == s { return true }
}
return false
}
/**/
//self.populatecombo("theme", self.comboTheme, self.ThemeDir, "Theme")
//comboTheme.setCurrentIndex(self.comboTheme.findText(self.ThemeFile))
//comboTheme.currentIndexChanged.connect(self.settheme)
//self.populatecombo("theme", self.comboTheme, self.ThemeDir, "Theme")
//comboTheme.setCurrentIndex(self.comboTheme.findText(self.ThemeFile))
//comboTheme.currentIndexChanged.connect(self.settheme)