forked from Grivel-l/CustomBar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.go
33 lines (29 loc) · 1017 Bytes
/
audio.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
package main
// #include "./palib.h"
import "C"
import (
"unsafe"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
"github.com/jakejarrett/CustomBar/structs"
)
func initAudio(ctx unsafe.Pointer, config structs.VolumeConfig) {
var filter *core.QObject
var wheelEvent *gui.QWheelEvent
texts["audio"] = widgets.NewQLabel(nil, 0)
texts["audio"].SetAlignment(core.Qt__AlignCenter)
texts["audio"].SetStyleSheet("color: white")
if (config.Scroll) {
filter = core.NewQObject(nil)
filter.ConnectEventFilter(func (watched *core.QObject, event *core.QEvent) bool {
if (event.Type() == core.QEvent__Wheel) {
wheelEvent = gui.NewQWheelEventFromPointer(event.Pointer())
C.update_volume(ctx, C.int(wheelEvent.AngleDelta().Y()))
}
return false
})
texts["audio"].SetEnabled(true)
texts["audio"].InstallEventFilter(filter)
}
}