Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
8878ac44
Commit
8878ac44
authored
May 09, 2019
by
Samuel GAIST
Browse files
[widgets][dialog] Refactor dialog to implement support for context
parent
a3362947
Changes
2
Hide whitespace changes
Inline
Side-by-side
beat/editor/test/test_dialogs.py
View file @
8878ac44
...
...
@@ -46,8 +46,8 @@ def creation_type(request):
class
TestAssetCreationDialog
:
"""Test that the asset creation dialog works as expected"""
def
test_widget_visibility
(
self
,
qtbot
,
test_prefix
,
asset_type
):
dialog
=
AssetCreationDialog
(
test_prefix
,
asset_type
)
def
test_widget_visibility
(
self
,
qtbot
,
beat_context
,
asset_type
):
dialog
=
AssetCreationDialog
(
beat_context
,
asset_type
)
dialog
.
show
()
qtbot
.
addWidget
(
dialog
)
...
...
@@ -55,8 +55,8 @@ class TestAssetCreationDialog:
assert
dialog
.
new_version_radio_button
.
isVisible
()
==
asset_type
.
can_create
()
assert
dialog
.
fork_radio_button
.
isVisible
()
==
asset_type
.
can_fork
()
def
test_input_disabling
(
self
,
qtbot
,
test_prefix
):
dialog
=
AssetCreationDialog
(
test_prefix
,
AssetType
.
DATAFORMAT
)
def
test_input_disabling
(
self
,
qtbot
,
beat_context
):
dialog
=
AssetCreationDialog
(
beat_context
,
AssetType
.
DATAFORMAT
)
dialog
.
show
()
qtbot
.
addWidget
(
dialog
)
...
...
@@ -79,8 +79,8 @@ class TestAssetCreationDialog:
assert
dialog
.
fork_combobox
.
isEnabled
()
assert
dialog
.
creationType
()
==
AssetCreationDialog
.
FORK
def
test_create_new
(
self
,
qtbot
,
test_prefix
):
dialog
=
AssetCreationDialog
(
test_prefix
,
AssetType
.
DATAFORMAT
)
def
test_create_new
(
self
,
qtbot
,
beat_context
):
dialog
=
AssetCreationDialog
(
beat_context
,
AssetType
.
DATAFORMAT
)
qtbot
.
addWidget
(
dialog
)
asset_name
=
"test_asset"
...
...
@@ -96,8 +96,8 @@ class TestAssetCreationDialog:
assert
dialog
.
creationType
()
==
AssetCreationDialog
.
NEW
assert
dialog
.
assetInfo
()
==
asset_name
def
test_create_new_version
(
self
,
qtbot
,
test_prefix
):
dialog
=
AssetCreationDialog
(
test_prefix
,
AssetType
.
DATAFORMAT
)
def
test_create_new_version
(
self
,
qtbot
,
beat_context
):
dialog
=
AssetCreationDialog
(
beat_context
,
AssetType
.
DATAFORMAT
)
qtbot
.
addWidget
(
dialog
)
with
qtbot
.
waitCallback
()
as
cb
:
...
...
@@ -110,8 +110,8 @@ class TestAssetCreationDialog:
assert
dialog
.
creationType
()
==
AssetCreationDialog
.
NEW_VERSION
assert
dialog
.
assetInfo
()
==
dialog
.
new_version_combobox
.
currentText
()
def
test_create_fork
(
self
,
qtbot
,
test_prefix
):
dialog
=
AssetCreationDialog
(
test_prefix
,
AssetType
.
DATAFORMAT
)
def
test_create_fork
(
self
,
qtbot
,
beat_context
):
dialog
=
AssetCreationDialog
(
beat_context
,
AssetType
.
DATAFORMAT
)
qtbot
.
addWidget
(
dialog
)
asset_name
=
"test_asset"
...
...
beat/editor/widgets/dialogs.py
View file @
8878ac44
...
...
@@ -31,8 +31,6 @@ from PyQt5.QtWidgets import QLineEdit
from
PyQt5.QtWidgets
import
QRadioButton
from
PyQt5.QtWidgets
import
QVBoxLayout
from
beat.cmdline.config
import
Configuration
from
..backend.assetmodel
import
AssetType
from
..backend.assetmodel
import
AssetModel
...
...
@@ -47,10 +45,12 @@ class CreationType:
class
AssetCreationDialog
(
QDialog
,
CreationType
):
def
__init__
(
self
,
prefix_path
,
asset_type
,
parent
=
None
):
def
__init__
(
self
,
context
,
asset_type
,
parent
=
None
):
super
(
AssetCreationDialog
,
self
).
__init__
(
parent
)
config
=
Configuration
({})
config
=
context
.
meta
[
"config"
]
user
=
config
.
user
prefix_path
=
config
.
path
asset_model
=
AssetModel
()
asset_model
.
asset_type
=
asset_type
...
...
@@ -65,7 +65,7 @@ class AssetCreationDialog(QDialog, CreationType):
asset
for
asset
in
self
.
fork_asset_list
if
asset
not
in
basetypes
]
self
.
new_version_asset_list
=
[
asset
for
asset
in
self
.
fork_asset_list
if
config
.
user
in
asset
asset
for
asset
in
self
.
fork_asset_list
if
user
in
asset
]
# New asset
...
...
@@ -170,8 +170,8 @@ class AssetCreationDialog(QDialog, CreationType):
return
self
.
FORK
@
staticmethod
def
getAssetInfo
(
parent
,
prefix_path
,
asset_type
):
dialog
=
AssetCreationDialog
(
prefix_path
,
asset_type
,
parent
)
def
getAssetInfo
(
parent
,
context
,
asset_type
):
dialog
=
AssetCreationDialog
(
context
,
asset_type
,
parent
)
result
=
dialog
.
exec_
()
if
result
==
QDialog
.
Accepted
:
...
...
Write
Preview
Supports
Markdown
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