miqt: initial string-replacement
This commit is contained in:
parent
2331915a06
commit
8b2dc3582c
1
go.mod
1
go.mod
@ -13,6 +13,7 @@ require (
|
|||||||
github.com/iawia002/annie v0.0.0-20200204103259-9f6dfcb99250
|
github.com/iawia002/annie v0.0.0-20200204103259-9f6dfcb99250
|
||||||
github.com/kr/pretty v0.1.0
|
github.com/kr/pretty v0.1.0
|
||||||
github.com/kr/text v0.1.0
|
github.com/kr/text v0.1.0
|
||||||
|
github.com/mappu/miqt v0.8.0
|
||||||
github.com/mattn/go-colorable v0.1.5-0.20200110010445-c742d6fb21c2
|
github.com/mattn/go-colorable v0.1.5-0.20200110010445-c742d6fb21c2
|
||||||
github.com/mattn/go-isatty v0.0.13-0.20200128103942-cb30d6282491
|
github.com/mattn/go-isatty v0.0.13-0.20200128103942-cb30d6282491
|
||||||
github.com/mattn/go-runewidth v0.0.9-0.20200125155203-588506649b41
|
github.com/mattn/go-runewidth v0.0.9-0.20200125155203-588506649b41
|
||||||
|
95
go.sum
Normal file
95
go.sum
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403 h1:EtZwYyLbkEcIt+B//6sujwRCnHuTEK3qiSypAX5aJeM=
|
||||||
|
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403/go.mod h1:mM6WvakkX2m+NgMiPCfFFjwfH4KzENC07zeGEqq9U7s=
|
||||||
|
github.com/PuerkitoBio/goquery v1.4.1/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA=
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE=
|
||||||
|
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||||
|
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||||
|
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||||
|
github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE=
|
||||||
|
github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY=
|
||||||
|
github.com/cheggaaa/pb v1.0.25/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
|
||||||
|
github.com/cheggaaa/pb v1.0.29-0.20200109123023-ca7ab1060666 h1:tO394WyRLqG49Q3FppxM2faIEmfQr9CskCSTSn+U7Ko=
|
||||||
|
github.com/cheggaaa/pb v1.0.29-0.20200109123023-ca7ab1060666/go.mod h1:PBkXrnkhxrT3qj4OESIfx9o/zmjrmFkc9yeqFYw9jq4=
|
||||||
|
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:Yg2hDs4b13Evkpj42FU2idX2cVXVFqQSheXYKM86Qsk=
|
||||||
|
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:MgJyK38wkzZbiZSKeIeFankxxSA8gayko/nr5x5bgBA=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
|
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
|
||||||
|
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/iawia002/annie v0.0.0-20200204103259-9f6dfcb99250 h1:IZJE5ZDZ4U2/puWuzfIRNSvojGPBqUD7X9bkuKBnivg=
|
||||||
|
github.com/iawia002/annie v0.0.0-20200204103259-9f6dfcb99250/go.mod h1:/ZM33vgEEB5VC+ydO99vblxVSmwB6SmUPmmh4n48MNk=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/mappu/miqt v0.8.0 h1:W+QH38lygRR51Mg6MW6AonTvL8tv7JWjPgjxWDYnT7Q=
|
||||||
|
github.com/mappu/miqt v0.8.0/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
|
||||||
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
|
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
|
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
|
github.com/mattn/go-colorable v0.1.5-0.20200110010445-c742d6fb21c2 h1:oxHkMbW6mNrluWUANb84Krt1FplkJSPcZ8kjBz5YUJY=
|
||||||
|
github.com/mattn/go-colorable v0.1.5-0.20200110010445-c742d6fb21c2/go.mod h1:l9CmQB24hKkW0gbg7til/3lFbpP670ZTph0l1cdk7w8=
|
||||||
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||||
|
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||||
|
github.com/mattn/go-isatty v0.0.13-0.20200128103942-cb30d6282491 h1:jygFUAtCyqjM5JGFNAWcXLqlXArQqxDZ3DqQer1BIik=
|
||||||
|
github.com/mattn/go-isatty v0.0.13-0.20200128103942-cb30d6282491/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
|
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
|
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
|
github.com/mattn/go-runewidth v0.0.9-0.20200125155203-588506649b41 h1:AkInqmD1OrueaAKIWH0RWU+irX4nL1oqScB++w2CAlU=
|
||||||
|
github.com/mattn/go-runewidth v0.0.9-0.20200125155203-588506649b41/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
|
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||||
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||||
|
github.com/rs/zerolog v1.16.0/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I=
|
||||||
|
github.com/rs/zerolog v1.17.3-0.20200115210151-505b18daf2bb h1:rJzTcLide54ae4FDjZT9qo83mGAfEPmsQCf3A3KK2II=
|
||||||
|
github.com/rs/zerolog v1.17.3-0.20200115210151-505b18daf2bb/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/rylio/ytdl v0.6.2/go.mod h1:F0WX8szfQ00mhmfla+0xVJp483SBV4VO/ByUaNioNSM=
|
||||||
|
github.com/rylio/ytdl v0.6.3-0.20200102153401-9eb9d2cc8513 h1:nn7eVqgdJnh/ZJkb5dxF5rTvQmUAS3nEJdJ3xfgWJvM=
|
||||||
|
github.com/rylio/ytdl v0.6.3-0.20200102153401-9eb9d2cc8513/go.mod h1:F0WX8szfQ00mhmfla+0xVJp483SBV4VO/ByUaNioNSM=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
||||||
|
github.com/tidwall/gjson v1.4.0 h1:w6iOJZt9BJOzz4VD9CSnRCX/oleCsAZWi+1FFzZA+SA=
|
||||||
|
github.com/tidwall/gjson v1.4.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
||||||
|
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
|
||||||
|
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
|
||||||
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
|
github.com/tidwall/pretty v1.0.1 h1:WE4RBSZ1x6McVVC8S/Md+Qse8YUv6HRObAx6ke00NY8=
|
||||||
|
github.com/tidwall/pretty v1.0.1/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
|
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
|
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
|
||||||
|
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191104094858-e8c54fb511f6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200107162124-548cf772de50/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
|
||||||
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3-0.20191230102452-929e72ca90de h1:aYKJLPSrddB2N7/6OKyFqJ337SXpo61bBuvO5p1+7iY=
|
||||||
|
golang.org/x/text v0.3.3-0.20191230102452-929e72ca90de/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
88
main.go
88
main.go
@ -18,9 +18,7 @@ import (
|
|||||||
"github.com/cloudfoundry-attic/jibber_jabber"
|
"github.com/cloudfoundry-attic/jibber_jabber"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/therecipe/qt/core"
|
qt "github.com/mappu/miqt/qt6"
|
||||||
"github.com/therecipe/qt/gui"
|
|
||||||
"github.com/therecipe/qt/widgets"
|
|
||||||
|
|
||||||
"github.com/iawia002/annie/config"
|
"github.com/iawia002/annie/config"
|
||||||
"github.com/iawia002/annie/downloader"
|
"github.com/iawia002/annie/downloader"
|
||||||
@ -76,8 +74,8 @@ type GUIConfig struct {
|
|||||||
// GetDestinationFolder attempts to retrieve (if not yet) and returns the
|
// GetDestinationFolder attempts to retrieve (if not yet) and returns the
|
||||||
// configured destination folder.
|
// configured destination folder.
|
||||||
func (c *GUIConfig) GetDestinationFolder() string {
|
func (c *GUIConfig) GetDestinationFolder() string {
|
||||||
fallback := util.DefaultDownloadsFolder()
|
fallback := DefaultDownloadsFolder()
|
||||||
val := settings.Value("destinationFolder", core.NewQVariant12(fallback)).ToString()
|
val := settings.Value("destinationFolder", qt.NewQVariant12(fallback)).ToString()
|
||||||
c.DestinationFolder = val
|
c.DestinationFolder = val
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
@ -86,7 +84,7 @@ func (c *GUIConfig) GetDestinationFolder() string {
|
|||||||
// configured value of whether playlist download is enabled.
|
// configured value of whether playlist download is enabled.
|
||||||
func (c *GUIConfig) GetPlaylistEnabled() bool {
|
func (c *GUIConfig) GetPlaylistEnabled() bool {
|
||||||
fallback := true
|
fallback := true
|
||||||
val := settings.Value("playlistEnabled", core.NewQVariant9(fallback)).ToBool()
|
val := settings.Value("playlistEnabled", qt.NewQVariant9(fallback)).ToBool()
|
||||||
c.PlaylistEnabled = val
|
c.PlaylistEnabled = val
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
@ -94,14 +92,14 @@ func (c *GUIConfig) GetPlaylistEnabled() bool {
|
|||||||
// SetDestinationFolder sets and persists the configured destination folder.
|
// SetDestinationFolder sets and persists the configured destination folder.
|
||||||
func (c *GUIConfig) SetDestinationFolder(val string) {
|
func (c *GUIConfig) SetDestinationFolder(val string) {
|
||||||
c.DestinationFolder = val
|
c.DestinationFolder = val
|
||||||
go func() { settings.SetValue("destinationFolder", core.NewQVariant12(val)) }()
|
go func() { settings.SetValue("destinationFolder", qt.NewQVariant12(val)) }()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPlaylistEnabled sets and persists the configured value of whether playlist
|
// SetPlaylistEnabled sets and persists the configured value of whether playlist
|
||||||
// download is enabled.
|
// download is enabled.
|
||||||
func (c *GUIConfig) SetPlaylistEnabled(val bool) {
|
func (c *GUIConfig) SetPlaylistEnabled(val bool) {
|
||||||
c.PlaylistEnabled = val
|
c.PlaylistEnabled = val
|
||||||
go func() { settings.SetValue("playlistEnabled", core.NewQVariant9(val)) }()
|
go func() { settings.SetValue("playlistEnabled", qt.NewQVariant9(val)) }()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadGUIConfig loads config values from persisted settings if possible, or
|
// LoadGUIConfig loads config values from persisted settings if possible, or
|
||||||
@ -113,7 +111,7 @@ func LoadGUIConfig() *GUIConfig {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
var settings *core.QSettings
|
var settings *qt.QSettings
|
||||||
var guiConfig *GUIConfig
|
var guiConfig *GUIConfig
|
||||||
|
|
||||||
var locales = map[string]map[string]string{
|
var locales = map[string]map[string]string{
|
||||||
@ -257,7 +255,7 @@ func download(videoURL string) bool {
|
|||||||
|
|
||||||
// PlainTextEdit extends QPlainTextEdit.
|
// PlainTextEdit extends QPlainTextEdit.
|
||||||
type PlainTextEdit struct {
|
type PlainTextEdit struct {
|
||||||
widgets.QPlainTextEdit
|
qt.QPlainTextEdit
|
||||||
|
|
||||||
_ func() `constructor:"init"`
|
_ func() `constructor:"init"`
|
||||||
|
|
||||||
@ -279,10 +277,10 @@ func (p *PlainTextEdit) addLine(line string) {
|
|||||||
userScrolledBack := currentScroll != scrollBar.Maximum()
|
userScrolledBack := currentScroll != scrollBar.Maximum()
|
||||||
|
|
||||||
cursor := p.TextCursor()
|
cursor := p.TextCursor()
|
||||||
cursor.MovePosition(gui.QTextCursor__End, gui.QTextCursor__MoveAnchor, 1)
|
cursor.MovePosition(qt.QTextCursor__End, qt.QTextCursor__MoveAnchor, 1)
|
||||||
if p.carriageReturnInAction {
|
if p.carriageReturnInAction {
|
||||||
// Remove last line.
|
// Remove last line.
|
||||||
cursor.Select(gui.QTextCursor__LineUnderCursor)
|
cursor.Select(qt.QTextCursor__LineUnderCursor)
|
||||||
cursor.RemoveSelectedText()
|
cursor.RemoveSelectedText()
|
||||||
}
|
}
|
||||||
p.carriageReturnInAction = false
|
p.carriageReturnInAction = false
|
||||||
@ -373,77 +371,77 @@ func init() {
|
|||||||
_, index, _ := matcher.Match(language.Make(userLang))
|
_, index, _ := matcher.Match(language.Make(userLang))
|
||||||
locale = locales[availableLangs[index]]
|
locale = locales[availableLangs[index]]
|
||||||
|
|
||||||
core.QCoreApplication_SetOrganizationName(appAuthor)
|
qt.QCoreApplication_SetOrganizationName(appAuthor)
|
||||||
core.QCoreApplication_SetOrganizationDomain(appAuthorDomain)
|
qt.QCoreApplication_SetOrganizationDomain(appAuthorDomain)
|
||||||
|
|
||||||
settings = core.NewQSettings5(nil)
|
settings = qt.NewQSettings5(nil)
|
||||||
guiConfig = LoadGUIConfig()
|
guiConfig = LoadGUIConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func initAboutWindow() *widgets.QDialog {
|
func initAboutWindow() *qt.QDialog {
|
||||||
w := widgets.NewQDialog(nil, 0)
|
w := qt.NewQDialog(nil, 0)
|
||||||
label := widgets.NewQLabel2(about, nil, 0)
|
label := qt.NewQLabel2(about, nil, 0)
|
||||||
label.SetOpenExternalLinks(true)
|
label.SetOpenExternalLinks(true)
|
||||||
layout := widgets.NewQVBoxLayout()
|
layout := qt.NewQVBoxLayout()
|
||||||
layout.AddWidget(label, 0, 0)
|
layout.AddWidget(label, 0, 0)
|
||||||
w.SetLayout(layout)
|
w.SetLayout(layout)
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
widgets.NewQApplication(len(os.Args), os.Args)
|
qt.NewQApplication(len(os.Args), os.Args)
|
||||||
|
|
||||||
window := widgets.NewQMainWindow(nil, 0)
|
window := qt.NewQMainWindow(nil, 0)
|
||||||
window.SetWindowTitle(appName)
|
window.SetWindowTitle(appName)
|
||||||
window.ConnectCloseEvent(func(*gui.QCloseEvent) {
|
window.ConnectCloseEvent(func(*qt.QCloseEvent) {
|
||||||
settings.SetValue("_geometry", core.NewQVariant13(window.SaveGeometry()))
|
settings.SetValue("_geometry", qt.NewQVariant13(window.SaveGeometry()))
|
||||||
settings.SetValue("_windowState", core.NewQVariant13(window.SaveState(0)))
|
settings.SetValue("_windowState", qt.NewQVariant13(window.SaveState(0)))
|
||||||
})
|
})
|
||||||
|
|
||||||
window.RestoreGeometry(settings.Value("_geometry", core.NewQVariant()).ToByteArray())
|
window.RestoreGeometry(settings.Value("_geometry", qt.NewQVariant()).ToByteArray())
|
||||||
window.RestoreState(settings.Value("_windowState", core.NewQVariant()).ToByteArray(), 0)
|
window.RestoreState(settings.Value("_windowState", qt.NewQVariant()).ToByteArray(), 0)
|
||||||
|
|
||||||
centralWidget := widgets.NewQWidget(window, 0)
|
centralWidget := qt.NewQWidget(window, 0)
|
||||||
window.SetCentralWidget(centralWidget)
|
window.SetCentralWidget(centralWidget)
|
||||||
|
|
||||||
menuBar := window.MenuBar()
|
menuBar := window.MenuBar()
|
||||||
applicationMenu := menuBar.AddMenu2(tr("Application"))
|
applicationMenu := menuBar.AddMenu2(tr("Application"))
|
||||||
aboutWindow := initAboutWindow()
|
aboutWindow := initAboutWindow()
|
||||||
aboutAction := applicationMenu.AddAction(tr("About"))
|
aboutAction := applicationMenu.AddAction(tr("About"))
|
||||||
aboutAction.SetMenuRole(widgets.QAction__AboutRole)
|
aboutAction.SetMenuRole(qt.QAction__AboutRole)
|
||||||
aboutAction.ConnectTriggered(func(bool) {
|
aboutAction.ConnectTriggered(func(bool) {
|
||||||
aboutWindow.Show()
|
aboutWindow.Show()
|
||||||
aboutWindow.Raise()
|
aboutWindow.Raise()
|
||||||
})
|
})
|
||||||
|
|
||||||
urlLineEdit := widgets.NewQLineEdit(nil)
|
urlLineEdit := qt.NewQLineEdit(nil)
|
||||||
|
|
||||||
folderLineEdit := widgets.NewQLineEdit2(guiConfig.DestinationFolder, nil)
|
folderLineEdit := qt.NewQLineEdit2(guiConfig.DestinationFolder, nil)
|
||||||
folderLineEdit.SetReadOnly(true)
|
folderLineEdit.SetReadOnly(true)
|
||||||
folderLineEdit.SetMinimumWidth(250)
|
folderLineEdit.SetMinimumWidth(250)
|
||||||
folderButton := widgets.NewQPushButton2(tr("Pick another folder"), nil)
|
folderButton := qt.NewQPushButton2(tr("Pick another folder"), nil)
|
||||||
folderDialog := widgets.NewQFileDialog2(nil, tr("Destination folder"), guiConfig.DestinationFolder, "")
|
folderDialog := qt.NewQFileDialog2(nil, tr("Destination folder"), guiConfig.DestinationFolder, "")
|
||||||
folderDialog.SetFileMode(widgets.QFileDialog__DirectoryOnly)
|
folderDialog.SetFileMode(qt.QFileDialog__DirectoryOnly)
|
||||||
folderButton.ConnectClicked(func(bool) {
|
folderButton.ConnectClicked(func(bool) {
|
||||||
if folderDialog.Exec() != int(widgets.QDialog__Accepted) {
|
if folderDialog.Exec() != int(qt.QDialog__Accepted) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
destinationFolder := core.QDir_ToNativeSeparators(folderDialog.SelectedFiles()[0])
|
destinationFolder := qt.QDir_ToNativeSeparators(folderDialog.SelectedFiles()[0])
|
||||||
folderLineEdit.SetText(destinationFolder)
|
folderLineEdit.SetText(destinationFolder)
|
||||||
guiConfig.SetDestinationFolder(destinationFolder)
|
guiConfig.SetDestinationFolder(destinationFolder)
|
||||||
})
|
})
|
||||||
folderHBoxLayout := widgets.NewQHBoxLayout()
|
folderHBoxLayout := qt.NewQHBoxLayout()
|
||||||
folderHBoxLayout.AddWidget(folderLineEdit, 1, 0)
|
folderHBoxLayout.AddWidget(folderLineEdit, 1, 0)
|
||||||
folderHBoxLayout.AddWidget(folderButton, 0, 0)
|
folderHBoxLayout.AddWidget(folderButton, 0, 0)
|
||||||
|
|
||||||
playlistCheckBox := widgets.NewQCheckBox(nil)
|
playlistCheckBox := qt.NewQCheckBox(nil)
|
||||||
playlistCheckBox.SetChecked(guiConfig.PlaylistEnabled)
|
playlistCheckBox.SetChecked(guiConfig.PlaylistEnabled)
|
||||||
playlistCheckBox.ConnectToggled(func(checked bool) {
|
playlistCheckBox.ConnectToggled(func(checked bool) {
|
||||||
guiConfig.SetPlaylistEnabled(checked)
|
guiConfig.SetPlaylistEnabled(checked)
|
||||||
})
|
})
|
||||||
|
|
||||||
inputFormLayout := widgets.NewQFormLayout(nil)
|
inputFormLayout := qt.NewQFormLayout(nil)
|
||||||
inputFormLayout.SetFieldGrowthPolicy(widgets.QFormLayout__AllNonFixedFieldsGrow)
|
inputFormLayout.SetFieldGrowthPolicy(qt.QFormLayout__AllNonFixedFieldsGrow)
|
||||||
inputFormLayout.AddRow3(tr("Video URL"), urlLineEdit)
|
inputFormLayout.AddRow3(tr("Video URL"), urlLineEdit)
|
||||||
inputFormLayout.AddRow4(tr("Destination folder"), folderHBoxLayout)
|
inputFormLayout.AddRow4(tr("Destination folder"), folderHBoxLayout)
|
||||||
inputFormLayout.AddRow3(tr("Download playlists"), playlistCheckBox)
|
inputFormLayout.AddRow3(tr("Download playlists"), playlistCheckBox)
|
||||||
@ -452,14 +450,14 @@ func main() {
|
|||||||
outputTextEdit.SetReadOnly(true)
|
outputTextEdit.SetReadOnly(true)
|
||||||
outputTextEdit.SetMinimumHeight(400)
|
outputTextEdit.SetMinimumHeight(400)
|
||||||
outputTextEdit.SetMinimumWidth(1000)
|
outputTextEdit.SetMinimumWidth(1000)
|
||||||
outputTextEdit.SetLineWrapMode(widgets.QPlainTextEdit__NoWrap)
|
outputTextEdit.SetLineWrapMode(qt.QPlainTextEdit__NoWrap)
|
||||||
monospaceFont := gui.NewQFont2("Courier", -1, -1, false)
|
monospaceFont := qt.NewQFont2("Courier", -1, -1, false)
|
||||||
monospaceFont.SetStyleHint(gui.QFont__Monospace, 0)
|
monospaceFont.SetStyleHint(qt.QFont__Monospace, 0)
|
||||||
outputTextEdit.SetFont(monospaceFont)
|
outputTextEdit.SetFont(monospaceFont)
|
||||||
output := newOutputBuffer(outputTextEdit)
|
output := newOutputBuffer(outputTextEdit)
|
||||||
output.addLine(tr("Awaiting user input"))
|
output.addLine(tr("Awaiting user input"))
|
||||||
|
|
||||||
downloadButton := widgets.NewQPushButton2(tr("Download"), nil)
|
downloadButton := qt.NewQPushButton2(tr("Download"), nil)
|
||||||
downloadButton.ConnectClicked(func(bool) {
|
downloadButton.ConnectClicked(func(bool) {
|
||||||
url := strings.TrimSpace(urlLineEdit.Text())
|
url := strings.TrimSpace(urlLineEdit.Text())
|
||||||
if len(url) > 0 {
|
if len(url) > 0 {
|
||||||
@ -498,7 +496,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
layout := widgets.NewQVBoxLayout()
|
layout := qt.NewQVBoxLayout()
|
||||||
layout.AddLayout(inputFormLayout, 0)
|
layout.AddLayout(inputFormLayout, 0)
|
||||||
layout.AddWidget(downloadButton, 0, 0)
|
layout.AddWidget(downloadButton, 0, 0)
|
||||||
layout.AddWidget(outputTextEdit, 1, 0)
|
layout.AddWidget(outputTextEdit, 1, 0)
|
||||||
@ -515,5 +513,5 @@ func main() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
widgets.QApplication_Exec()
|
qt.QApplication_Exec()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user