Yes. I've used a fairly similar structure for all the Editor plugins I've done. Summarised below.
Once ResultsDlg (and optional Show Diffs dialog) are closed:
- With red bit - all tweaks show in Preview/LiveCSS, no highlight, all OK.
- Without red bit - all tweaks show in Preview/LiveCSS, but highlight also still visible in both, but not in Show Diffs.
Double-clicking CSS file (as long as it wasn't already open) makes highlight disappear.
Spoiler:
Code:
class CSSTweakerTool(Tool):
name = 'CSSTweaker'
...
def create_action(self, for_toolbar=True):
...
ac.triggered.connect(self.do_the_action)
return ac
def do_the_action(self):
self.boss.commit_all_editors_to_container()
try:
show_changes, dirty = self.css_tweaker()
except Exception:
import traceback
msg = 'Failed to Tweak CSS file'
error_dialog(self.gui, _(msg), ...)
self.boss.revert_requested(self.boss.global_undo.previous_container)
else:
if show_changes:
self.boss.show_current_diff()
if dirty:
self.boss.apply_container_update_to_gui()
else:
self.boss.rewind_savepoint()
def css_tweaker(self):
log = []
self.boss.add_savepoint('Before: CSS Tweaker')
container = self.current_container
... find container cssname ...
... some container checking ...
if not OK to proceed:
return False, False
dlg = CSSTweakerDlg(...)
if dlg.exec_():
try:
self.boss.close_editor(cssname)
except:
pass
self.boss.edit_file(cssname)
log.extend(dlg.csslog)
resdlg = ResultsDlg(self.name, log, show_changes_button=True, parent=self.gui)
return resdlg.exec_(), True
else:
return False, False
ETA: Extra info. I should have tried this sooner - without the
red bit I can also "fix" things by right-clicking Preview and selecting 'Refresh Preview"
ETA2: Replacing the
red bit with the single command you spoke of above,
self.boss.gui.preview.start_refresh_timer() also fixes things. This is neater.
In the production version of 2.62 adding that command twice, fixes things:
1st - where the red bit is
2nd - immediately following the self.boss.apply_container_update_to_gui()