Skip to content

Commit

Permalink
added qtmultimedia subnamespace enums
Browse files Browse the repository at this point in the history
  • Loading branch information
therecipe committed Dec 18, 2015
1 parent 83fd9e9 commit b08e88b
Show file tree
Hide file tree
Showing 30 changed files with 992 additions and 22 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
* https://mirror.synyx.de/apache/ant/binaries/apache-ant-1.9.6-bin.tar.bz2
* https://mirror.synyx.de/apache/ant/binaries/apache-ant-1.9.6-bin.tar.gz

6. Install Java SE Development Kit (linux only: install in `/opt/jdk/`)
6. Install Java SE Development Kit (Linux: install in `/opt/jdk/`)
* https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

7. Install and test
Expand All @@ -120,26 +120,26 @@
package main

import (
"os"
"os"

"github.com/therecipe/qt/widgets"
"github.com/therecipe/qt/widgets"
)

func main() {
widgets.NewQApplication(len(os.Args), os.Args)
widgets.NewQApplication(len(os.Args), os.Args)

var btn = widgets.NewQPushButton2("Hello World", nil)
btn.Resize2(180, 44)
btn.ConnectClicked(func(flag bool) {
widgets.QMessageBox_Information(nil, "OK", "You Clicked me!", widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
})
var btn = widgets.NewQPushButton2("Hello World", nil)
btn.Resize2(180, 44)
btn.ConnectClicked(func(flag bool) {
widgets.QMessageBox_Information(nil, "OK", "You Clicked me!", widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
})

var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.Layout().AddWidget(btn)
window.Show()
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.Layout().AddWidget(btn)
window.Show()

widgets.QApplication_Exec()
widgets.QApplication_Exec()
}
```
Expand Down
6 changes: 3 additions & 3 deletions internal/binding/converter/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ func goEnum(inter interface{}, value string) string {
return strings.Replace(outE, ":", "_", -1)
}

switch inter.(type) {
switch deduced := inter.(type) {
case *parser.Function:
{
inter.(*parser.Function).Access = "unsupported_goEnum"
deduced.Access = "unsupported_goEnum"
}

case *parser.Enum:
{
inter.(*parser.Enum).Access = "unsupported_goEnum"
deduced.Access = "unsupported_goEnum"
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/binding/converter/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ func cppOutput(name string, value string, f *parser.Function) string {
{
return fmt.Sprintf("%v.internalPointer()", name)
}
case "QIcon", "QUrl", "QJSValue", "QScriptValue", "QVariant", "QStringRef", "QDateTime", "QTimeZone", "QRegularExpressionMatchIterator", "QRegularExpressionMatch", "QRegularExpression", "QDir", "QByteArray", "QEasingCurve", "QCommandLineOption", "QRegExp", "QJsonObject", "QJsonArray", "QJsonDocument", "QRegion", "QBrush", "QColor":

case "QMediaContent", "QIcon", "QUrl", "QJSValue", "QScriptValue", "QVariant", "QStringRef", "QDateTime", "QTimeZone", "QRegularExpressionMatchIterator", "QRegularExpressionMatch", "QRegularExpression", "QDir", "QByteArray", "QEasingCurve", "QCommandLineOption", "QRegExp", "QJsonObject", "QJsonArray", "QJsonDocument", "QRegion", "QBrush", "QColor":
{
return fmt.Sprintf("new %v(%v)", value, name)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/binding/parser/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (m *Module) prepare() {
}

//Register Subnamespace
if m.Project == "QtCore" {
if m.Project == "QtCore" || m.Project == "QtMultimedia" {
if m.Namespace.SubNamespace != nil {
for _, e := range m.Namespace.SubNamespace.Enums {
e.register(m.Project)
Expand Down
1 change: 1 addition & 0 deletions internal/binding/templater/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func ManualWeakLink(c *parser.Class) {
case "QtGui":
{
subclass.WeakLink["QtWidgets"] = true
subclass.WeakLink["QtMultimedia"] = true
}

case "QtMultimedia":
Expand Down
2 changes: 1 addition & 1 deletion internal/binding/templater/template_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func GoTemplate(c *parser.Class) (o string) {

if c.Name != "Qt" {
if c.Name != "Qt" && c.Name != "QMultimedia" && c.Name != "QAudio" {

o += fmt.Sprintf("type %v struct {\n", c.Name)
if c.Bases == "" {
Expand Down
7 changes: 7 additions & 0 deletions internal/binding/templater/templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func isBlocked(f *parser.Function) bool {
}
}

for _, n := range []string{"QAccessibleInterface::state", "QAccessibleWidget::state"} {
if f.Fullname == n {
f.Access = "unsupported_isBlocked"
return true
}
}

//Android Only
for _, blockedAndroid := range []string{"setAsDockMenu", "setSelect"} {
if f.Name == blockedAndroid {
Expand Down
58 changes: 56 additions & 2 deletions internal/examples/widgets/video_player/video_player.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"fmt"
"os"

"github.com/therecipe/qt/core"
Expand Down Expand Up @@ -49,6 +50,7 @@ func newVideoPlayer() *widgets.QWidget {
positionsSlider.ConnectSliderMoved(setPosition)

errorLabel = widgets.NewQLabel(nil, 0)
errorLabel.SetTextFormat(core.Qt__RichText)
errorLabel.SetSizePolicy2(widgets.QSizePolicy__Preferred, widgets.QSizePolicy__Maximum)

var controlLayout = widgets.NewQHBoxLayout()
Expand Down Expand Up @@ -123,7 +125,59 @@ func setPosition(position int) {
mediaPlayer.SetPosition(int64(position))
}

func handleError(_ multimedia.QMediaPlayer__Error) {
func handleError(err multimedia.QMediaPlayer__Error) {
playButton.SetEnabled(false)
errorLabel.SetText("Error: " + mediaPlayer.ErrorString())

var errString = mediaPlayer.ErrorString()

if errString == "" {
switch err {
case multimedia.QMediaPlayer__NoError:
{
errString = "QMediaPlayer::NoError"
}

case multimedia.QMediaPlayer__ResourceError:
{
errString = "QMediaPlayer::ResourceError"
}

case multimedia.QMediaPlayer__FormatError:
{
errString = "QMediaPlayer::FormatError"
}

case multimedia.QMediaPlayer__NetworkError:
{
errString = "QMediaPlayer::NetworkError"
}

case multimedia.QMediaPlayer__AccessDeniedError:
{
errString = "QMediaPlayer::AccessDeniedError"
}

case multimedia.QMediaPlayer__ServiceMissingError:
{
errString = "QMediaPlayer::ServiceMissingError"
}
}
}

errorLabel.SetText(fmt.Sprintf("File: %v<br>Error: %v<br>Supported MIME-Types: %v %v %v %v %v %v",
mediaPlayer.CurrentMedia().CanonicalUrl().ToString(0),
errString,
hasSupport("video/avi"),
hasSupport("video/mp4"),
hasSupport("video/x-flv"),
hasSupport("video/3gpp"),
hasSupport("video/x-ms-wmv"),
hasSupport("video/x-matroska")))
}

func hasSupport(mimeType string) string {
if multimedia.QMediaPlayer_HasSupport(mimeType, make([]string, 0), 0) >= multimedia.QMultimedia__MaybeSupported {
return mimeType + "=<font color=\"green\">true</font>"
}
return mimeType + "=<font color=\"red\">false</font>"
}
Loading

0 comments on commit b08e88b

Please sign in to comment.