Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Babyfut
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PR-Baby-A18
Babyfut
Commits
4cfbe44c
Commit
4cfbe44c
authored
Dec 10, 2018
by
Antoine Lima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto-translating software
parent
9ab100f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
20 deletions
+61
-20
babyfut.py
babyfut.py
+3
-9
core/module.py
core/module.py
+7
-6
translations/babyfut_fr.ts
translations/babyfut_fr.ts
+16
-1
ui/mainwin.py
ui/mainwin.py
+35
-4
No files found.
babyfut.py
View file @
4cfbe44c
...
...
@@ -11,7 +11,7 @@ import sys
import
logging
from
os.path
import
dirname
,
abspath
,
join
from
PyQt5
import
Qt
Widgets
,
Qt
Core
from
PyQt5
import
QtCore
from
PyQt5.QtWidgets
import
QMainWindow
,
QApplication
def
getContent
(
path
):
...
...
@@ -28,11 +28,10 @@ def getMainWin():
return
None
if
__name__
==
'__main__'
:
print
(
__package__
)
__package__
=
'Babyfut'
from
Babyfut.ui.mainwin
import
MainWin
from
Babyfut.modules
import
GameModule
from
Babyfut.core.player
import
Side
from
Babyfut.core.settings
import
Settings
from
Babyfut.core.input
import
GPIOThread
from
Babyfut.core.database
import
Database
from
Babyfut.core.replay
import
Replay
as
ReplayThread
...
...
@@ -41,12 +40,7 @@ if __name__=='__main__':
#logging.basicConfig(filename='babyfoot.log', level=logging.DEBUG)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
lang
=
Settings
[
'ui.language'
]
qtTranslator
=
QtCore
.
QTranslator
()
if
lang
!=
'en'
and
qtTranslator
.
load
(
"translations/babyfut_{}.qm"
.
format
(
lang
)):
app
.
installTranslator
(
qtTranslator
)
app
=
QApplication
(
sys
.
argv
)
myapp
=
MainWin
()
if
ReplayThread
.
isCamAvailable
():
...
...
core/module.py
View file @
4cfbe44c
...
...
@@ -15,11 +15,11 @@ class Module(QWidget):
self
.
mainwin
=
parent
self
.
ui
=
widget
self
.
ui
.
setupUi
(
self
)
def
switchModule
(
self
,
new_type
):
curmod_idx
=
self
.
mainwin
.
findMod
(
type
(
self
))
newmod_idx
=
self
.
mainwin
.
findMod
(
new_type
)
if
curmod_idx
<
0
:
logging
.
error
(
'Unknown panel {}'
.
format
(
type
(
self
)))
elif
newmod_idx
<
0
:
...
...
@@ -28,26 +28,27 @@ class Module(QWidget):
# Unfocus the current module
if
QApplication
.
focusWidget
()
!=
None
:
QApplication
.
focusWidget
().
clearFocus
()
# Swap modules by unloading, changing the ui then loading
self
.
mainwin
.
modules
[
curmod_idx
].
unload
()
self
.
mainwin
.
ui
.
panels
.
setCurrentIndex
(
newmod_idx
)
self
.
mainwin
.
ui
.
panels
.
setFocusProxy
(
self
.
mainwin
.
modules
[
newmod_idx
])
self
.
mainwin
.
modules
[
newmod_idx
].
setFocus
()
# Select first element of the Module
self
.
mainwin
.
modules
[
newmod_idx
].
focusNextChild
()
self
.
mainwin
.
modules
[
newmod_idx
].
focusPreviousChild
()
self
.
mainwin
.
modules
[
newmod_idx
].
ui
.
retranslateUi
(
self
.
mainwin
)
self
.
mainwin
.
modules
[
newmod_idx
].
load
()
def
send
(
self
,
to
,
**
kwargs
):
mod_idx
=
self
.
mainwin
.
findMod
(
to
)
if
mod_idx
<
0
:
logging
.
error
(
'Unknown panel {}'
.
format
(
to
))
else
:
self
.
mainwin
.
modules
[
mod_idx
].
other
(
**
kwargs
)
def
load
(
self
):
logging
.
warning
(
'Unimplemented method "load" for {}'
.
format
(
self
.
__class__
))
...
...
translations/babyfut_fr.ts
View file @
4cfbe44c
...
...
@@ -245,6 +245,21 @@
<
source
>
Privacy
<
/source
>
<
translation
>
Vie
Privée
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../modules/authleague.py
"
line
=
"
51
"
/>
<
source
>
{}
Victories
<
/source
>
<
translation
>
{}
Victoires
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../modules/authleague.py
"
line
=
"
52
"
/>
<
source
>
{}
Games
Played
<
/source
>
<
translation
>
{}
Parties
Jouées
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../modules/authleague.py
"
line
=
"
53
"
/>
<
source
>
{}
Goals
Scored
<
/source
>
<
translation
>
{}
Buts
Marqués
<
/translation
>
<
/message
>
<
message
encoding
=
"
UTF-8
"
>
<
location
filename
=
"
../ui/options_ui.py
"
line
=
"
229
"
/>
<
source
>
Français
<
/source
>
...
...
@@ -285,7 +300,7 @@
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>&
lt
;
li
&
gt
;
Your
Picture
(
if
public
)
&
lt
;
/li>
;
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>&
lt
;
li
&
gt
;...
&
lt
;
/li>
;
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>&
lt
;
/ul>
;
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>&
lt
;
/p>
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>&
lt
;
/p>
;
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>&
lt
;
p
&
gt
;
<
byte
value
=
"
x9
"
/><
byte
value
=
"
x9
"
/>
That
way
players
can
keep
track
of
their
score
and
compare
it
with
others
.
...
...
ui/mainwin.py
View file @
4cfbe44c
...
...
@@ -5,20 +5,28 @@
"""
import
os
from
os.path
import
join
,
dirname
,
abspath
import
logging
OnRasp
=
os
.
uname
()[
1
]
==
'raspberrypi'
from
PyQt5
import
QtWidgets
from
PyQt5.QtWidgets
import
QGraphicsBlurEffect
,
QApplication
from
PyQt5.QtCore
import
Q
Time
,
Qt
from
PyQt5.QtCore
import
Q
t
,
QTime
,
QTranslator
from
Babyfut.ui.main_ui
import
Ui_MainWindow
from
Babyfut
import
modules
from
Babyfut.ui.main_ui
import
Ui_MainWindow
from
Babyfut.core.settings
import
Settings
class
MainWin
(
QtWidgets
.
QMainWindow
):
DEFAULT_LANG
=
'en'
TR_PATH
=
join
(
dirname
(
dirname
(
abspath
(
__file__
))),
'translations/'
)
def
__init__
(
self
,
parent
=
None
):
QtWidgets
.
QWidget
.
__init__
(
self
,
parent
)
self
.
ui
=
Ui_MainWindow
()
self
.
ui
.
setupUi
(
self
)
self
.
lang
=
MainWin
.
DEFAULT_LANG
self
.
_retranslateUI
()
#Background blur
bgBlur
=
QGraphicsBlurEffect
()
...
...
@@ -73,11 +81,34 @@ class MainWin(QtWidgets.QMainWindow):
self
.
modules
[
modIdx
].
other
(
**
msg
)
def
_loadSettings
(
self
):
from
Babyfut.core.settings
import
Settings
if
Settings
[
'ui.fullscreen'
]:
self
.
showFullScreen
()
QApplication
.
setOverrideCursor
(
Qt
.
BlankCursor
);
else
:
self
.
showNormal
()
QApplication
.
setOverrideCursor
(
Qt
.
ArrowCursor
);
self
.
_retranslateUI
()
def
_retranslateUI
(
self
):
app
=
QApplication
.
instance
()
oldlang
=
self
.
lang
newlang
=
Settings
[
'ui.language'
]
if
newlang
==
oldlang
:
pass
# Nothing to do
elif
newlang
!=
MainWin
.
DEFAULT_LANG
:
self
.
translator
=
QTranslator
()
if
self
.
translator
.
load
(
"babyfut_{}"
.
format
(
newlang
),
MainWin
.
TR_PATH
):
logging
.
info
(
'Installing
\'
{}
\'
'
.
format
(
newlang
))
app
.
installTranslator
(
self
.
translator
)
else
:
logging
.
warn
(
'Could not open translation file for
\'
{}
\'
in path "{}"'
.
format
(
newlang
,
MainWin
.
TR_PATH
))
elif
newlang
==
MainWin
.
DEFAULT_LANG
:
logging
.
info
(
'Installing language
\'
{}
\'
'
.
format
(
newlang
))
app
.
removeTranslator
(
self
.
translator
)
self
.
translator
=
None
self
.
lang
=
newlang
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment