Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
Kajongg
Commits
ef0fbff5
Commit
ef0fbff5
authored
Apr 07, 2021
by
Wolfgang Rohdewald
Browse files
kdestub: new class Action
parent
4a028bee
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/kdestub.py
View file @
ef0fbff5
...
...
@@ -330,15 +330,13 @@ class KStandardAction:
mainWindow
=
Internal
.
mainWindow
separator
=
QAction
(
Internal
.
mainWindow
)
separator
.
setSeparator
(
True
)
mainWindow
.
actionStatusBar
=
mainWindow
.
kajonggAction
(
'options_show_statusbar'
,
None
)
mainWindow
.
actionStatusBar
=
Action
(
mainWindow
,
'options_show_statusbar'
,
None
)
mainWindow
.
actionStatusBar
.
setCheckable
(
True
)
mainWindow
.
actionStatusBar
.
setEnabled
(
True
)
mainWindow
.
actionStatusBar
.
toggled
.
connect
(
mainWindow
.
toggleStatusBar
)
mainWindow
.
actionStatusBar
.
setText
(
i18nc
(
'@action:inmenu'
,
"Show St&atusbar"
))
mainWindow
.
actionToolBar
=
mainWindow
.
kajonggAction
(
'options_show_toolbar'
,
None
)
mainWindow
.
actionToolBar
=
Action
(
mainWindow
,
'options_show_toolbar'
,
None
)
mainWindow
.
actionToolBar
.
setCheckable
(
True
)
mainWindow
.
actionToolBar
.
setEnabled
(
True
)
mainWindow
.
actionToolBar
.
toggled
.
connect
(
mainWindow
.
toggleToolBar
)
...
...
@@ -456,12 +454,12 @@ class KXmlGuiWindow(CaptionMixin, QMainWindow):
self
.
menus
[
menu
]
=
(
mainMenu
,
menuItems
)
self
.
menuBar
().
addMenu
(
mainMenu
)
self
.
setCaption
(
''
)
self
.
actionHelp
=
self
.
kajongg
Action
(
"help"
,
"help-contents"
,
Help
.
start
)
self
.
actionHelp
=
Action
(
self
,
"help"
,
"help-contents"
,
Help
.
start
)
self
.
actionHelp
.
setText
(
i18nc
(
'@action:inmenu'
,
'&Help'
))
self
.
actionLanguage
=
self
.
kajongg
Action
(
self
.
actionLanguage
=
Action
(
self
,
"language"
,
"preferences-desktop-locale"
,
self
.
selectLanguage
)
self
.
actionLanguage
.
setText
(
i18n
(
'Switch Application Language'
))
self
.
actionAboutKajongg
=
self
.
kajongg
Action
(
self
.
actionAboutKajongg
=
Action
(
self
,
'aboutkajongg'
,
'kajongg'
,
self
.
aboutKajongg
)
self
.
actionAboutKajongg
.
setText
(
i18nc
(
'@action:inmenu'
,
'About &Kajongg'
))
...
...
@@ -515,10 +513,6 @@ class KXmlGuiWindow(CaptionMixin, QMainWindow):
"""stub"""
return
self
.
_toolBar
def
kajonggAction
(
self
,
name
,
icon
,
slot
=
None
,
shortcut
=
None
,
actionData
=
None
):
"""this is defined in MainWindow(KXmlGuiWindow)"""
@
staticmethod
def
selectLanguage
():
"""show an about dialog"""
...
...
@@ -647,6 +641,23 @@ def KIcon(name=None): # pylint: disable=invalid-name
return
QIcon
.
fromTheme
(
name
)
class
Action
(
QAction
):
def
__init__
(
self
,
parent
,
name
,
icon
,
slot
=
None
,
shortcut
=
None
,
actionData
=
None
):
super
().
__init__
(
parent
)
if
icon
:
self
.
setIcon
(
KIcon
(
icon
))
if
slot
:
self
.
triggered
.
connect
(
slot
)
if
parent
:
parent
.
actionCollection
().
addAction
(
name
,
self
)
if
shortcut
:
self
.
setShortcut
(
Qt
.
CTRL
+
shortcut
)
self
.
setShortcutContext
(
Qt
.
ApplicationShortcut
)
if
actionData
is
not
None
:
self
.
setData
(
actionData
)
class
KConfigSkeletonItem
:
"""one preferences setting used by KOnfigSkeleton"""
...
...
src/mainwindow.py
View file @
ef0fbff5
...
...
@@ -71,7 +71,7 @@ except ImportError as importError:
try
:
from
mi18n
import
i18n
,
i18nc
from
kde
import
KIcon
,
KXmlGuiWindow
,
KStandardAction
from
kde
import
KXmlGuiWindow
,
KStandardAction
from
board
import
FittingView
from
playerlist
import
PlayerList
...
...
@@ -87,6 +87,7 @@ try:
from
configdialog
import
ConfigDialog
from
statesaver
import
StateSaver
from
util
import
checkMemory
from
kdestub
import
Action
except
ImportError
as
importError
:
NOTFOUND
.
append
(
'Kajongg is not correctly installed: modules: %s'
%
...
...
@@ -220,25 +221,9 @@ class MainWindow(KXmlGuiWindow):
self
.
centralView
.
resizeEvent
(
True
)
KXmlGuiWindow
.
showEvent
(
self
,
event
)
def
kajonggAction
(
self
,
name
,
icon
,
slot
=
None
,
shortcut
=
None
,
actionData
=
None
):
"""simplify defining actions"""
res
=
QAction
(
self
)
if
icon
:
res
.
setIcon
(
KIcon
(
icon
))
if
slot
:
res
.
triggered
.
connect
(
slot
)
self
.
actionCollection
().
addAction
(
name
,
res
)
if
shortcut
:
res
.
setShortcut
(
Qt
.
CTRL
+
shortcut
)
res
.
setShortcutContext
(
Qt
.
ApplicationShortcut
)
if
actionData
is
not
None
:
res
.
setData
(
actionData
)
return
res
def
_kajonggToggleAction
(
self
,
name
,
icon
,
shortcut
=
None
,
actionData
=
None
):
"""a checkable action"""
res
=
self
.
kajongg
Action
(
res
=
Action
(
self
,
name
,
icon
,
shortcut
=
shortcut
,
...
...
@@ -268,37 +253,44 @@ class MainWindow(KXmlGuiWindow):
self
.
background
=
None
# just for pylint
self
.
windTileset
=
Tileset
(
Internal
.
Preferences
.
windTilesetName
)
self
.
adjustMainView
()
self
.
actionScoreGame
=
self
.
kajonggAction
(
self
.
actionScoreGame
=
Action
(
self
,
"scoreGame"
,
"draw-freehand"
,
self
.
scoringScene
,
Qt
.
Key_C
)
self
.
actionPlayGame
=
self
.
kajonggAction
(
self
.
actionPlayGame
=
Action
(
self
,
"play"
,
"arrow-right"
,
self
.
playGame
,
Qt
.
Key_N
)
self
.
actionAbortGame
=
self
.
kajonggAction
(
self
.
actionAbortGame
=
Action
(
self
,
"abort"
,
"dialog-close"
,
self
.
abortAction
,
Qt
.
Key_W
)
self
.
actionAbortGame
.
setEnabled
(
False
)
self
.
actionQuit
=
self
.
kajonggAction
(
self
.
actionQuit
=
Action
(
self
,
"quit"
,
"application-exit"
,
self
.
close
,
Qt
.
Key_Q
)
self
.
actionPlayers
=
self
.
kajonggAction
(
self
.
actionPlayers
=
Action
(
self
,
"players"
,
"im-user"
,
self
.
slotPlayers
)
self
.
actionRulesets
=
self
.
kajonggAction
(
self
.
actionRulesets
=
Action
(
self
,
"rulesets"
,
"games-kajongg-law"
,
self
.
slotRulesets
)
self
.
actionChat
=
self
.
_kajonggToggleAction
(
"chat"
,
"call-start"
,
shortcut
=
Qt
.
Key_H
,
actionData
=
ChatWindow
)
self
.
actionChat
.
setEnabled
(
False
)
self
.
actionAngle
=
self
.
kajonggAction
(
self
.
actionAngle
=
Action
(
self
,
"angle"
,
"object-rotate-left"
,
self
.
changeAngle
,
...
...
@@ -315,7 +307,8 @@ class MainWindow(KXmlGuiWindow):
self
.
actionFullscreen
=
self
.
_kajonggToggleAction
(
"fullscreen"
,
"view-fullscreen"
,
shortcut
=
Qt
.
Key_F
+
Qt
.
ShiftModifier
)
self
.
actionFullscreen
.
toggled
.
connect
(
self
.
fullScreen
)
self
.
actionAutoPlay
=
self
.
kajonggAction
(
self
.
actionAutoPlay
=
Action
(
self
,
"demoMode"
,
"arrow-right-double"
,
None
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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