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
56574fcd
Commit
56574fcd
authored
Jul 04, 2019
by
Samuel GAIST
Browse files
[widgets][assetwidget] Add currentAssetChanged signal
This signal will be emitted on change of the asset to edit.
parent
f8aa39c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
beat/editor/test/test_assetwidget.py
View file @
56574fcd
...
...
@@ -91,7 +91,9 @@ class TestAssetWidget:
(
asset_name
,
editor_type
),
)
in
asset_type_prefix_entry_map
.
items
():
asset
=
Asset
(
test_prefix
,
asset_type
,
asset_name
)
asset_widget
.
loadAsset
(
asset
)
with
qtbot
.
waitSignal
(
asset_widget
.
currentAssetChanged
):
asset_widget
.
loadAsset
(
asset
)
assert
isinstance
(
asset_widget
.
current_editor
,
editor_type
)
def
test_dirty
(
...
...
@@ -111,7 +113,8 @@ class TestAssetWidget:
(
asset_name
,
editor_type
),
)
in
asset_type_prefix_entry_map
.
items
():
asset
=
Asset
(
test_prefix
,
asset_type
,
asset_name
)
asset_widget
.
loadAsset
(
asset
)
with
qtbot
.
waitSignal
(
asset_widget
.
currentAssetChanged
):
asset_widget
.
loadAsset
(
asset
)
assert
not
asset_widget
.
current_editor
.
isDirty
()
with
qtbot
.
waitSignal
(
asset_widget
.
json_widget
.
textChanged
):
...
...
@@ -143,7 +146,8 @@ class TestAssetWidget:
(
asset_name
,
editor_type
),
)
in
asset_type_prefix_entry_map
.
items
():
asset
=
Asset
(
test_prefix
,
asset_type
,
asset_name
)
asset_widget
.
loadAsset
(
asset
)
with
qtbot
.
waitSignal
(
asset_widget
.
currentAssetChanged
):
asset_widget
.
loadAsset
(
asset
)
with
qtbot
.
waitSignal
(
asset_widget
.
json_widget
.
textChanged
):
asset_widget
.
current_editor
.
description_lineedit
.
selectAll
()
...
...
@@ -301,7 +305,8 @@ class TestAssetWidget:
monkeypatch
.
setattr
(
QMessageBox
,
"question"
,
lambda
*
args
:
QMessageBox
.
Yes
)
asset
=
Asset
(
test_prefix
,
asset_type
,
asset_name
)
asset_widget
.
loadAsset
(
asset
)
with
qtbot
.
waitSignal
(
asset_widget
.
currentAssetChanged
):
asset_widget
.
loadAsset
(
asset
)
assert
asset_widget
.
current_editor
.
asset_type
!=
AssetType
.
UNKNOWN
asset_widget
.
deleteAsset
(
asset
.
declaration_path
)
assert
asset_widget
.
current_editor
.
asset_type
==
AssetType
.
UNKNOWN
...
...
@@ -327,5 +332,5 @@ class TestAssetWidget:
with
open
(
asset
.
declaration_path
,
"wt"
)
as
declaration_file
:
declaration_file
.
write
(
""
)
asset
=
Asset
(
test_prefix
,
asset_type
,
asset_name
)
asset_widget
.
loadAsset
(
asset
)
with
qtbot
.
assertNotEmitted
(
asset_widget
.
currentAssetChanged
):
asset_widget
.
loadAsset
(
asset
)
beat/editor/widgets/assetwidget.py
View file @
56574fcd
...
...
@@ -27,6 +27,7 @@ import os
import
click
import
simplejson
as
json
from
PyQt5.QtCore
import
pyqtSignal
from
PyQt5.QtCore
import
pyqtSlot
from
PyQt5.QtCore
import
QFileSystemWatcher
from
PyQt5.QtCore
import
QTimer
...
...
@@ -124,6 +125,8 @@ class AssetWidget(QWidget):
accordingly.
"""
currentAssetChanged
=
pyqtSignal
([
Asset
])
def
__init__
(
self
,
parent
=
None
):
"""Constructor"""
...
...
@@ -369,6 +372,7 @@ class AssetWidget(QWidget):
self
.
watcher
.
addPath
(
asset
.
declaration_path
)
self
.
current_asset
=
asset
self
.
__update_content
()
self
.
currentAssetChanged
.
emit
(
asset
)
@
pyqtSlot
()
def
saveJson
(
self
):
...
...
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