Commit 56574fcd authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[widgets][assetwidget] Add currentAssetChanged signal

This signal will be emitted on change of the asset
to edit.
parent f8aa39c9
......@@ -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)
......@@ -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):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment