View Single Post
Old 07-21-2016, 06:41 PM   #12
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Follow-up

I thought I'd give some feedback on this. Although I can see that the update works fine on the 'Magnify fonts' demo, I can't get it to work as-is on my own CSS tweaker Editor plugin. I *can* get it to work with a small kludge so I'm not too worried but I wondered if you may be able to shed some light - no rush if you're busy.

Background: I'll try to avoid too much detail...
My Editor plugin calls one huge QDialog (which I've been using in a User Interface plugin for years). It tweaks a single CSS file using loads of GUI widgets. Tweaks are done via cssutils on a parsed sheet. It has its own simple preview QWebView pane for instant feedback of changes to text appearance, so every single CSS change needs to be immediately written to disk (using container.open method ATMO). My original hope was to be able to get rid of my QWebView and use the Editor's Preview. ATMO I think that may be a bit ambitious.

Whichever style rule I'm currently tweaking has a temporary highlight applied ('background-color:aqua') so it's easy to see which text is affected in the HTML preview. The very last tweak before saving the QDialog is always the same, i.e. to make sure any remaining highlights are removed. This happens in the QDialog self.accept() method immediately before QDialog.accept(self).

Now to the crux of the problem:
Running from source, including the new self.boss.gui.preview.start_refresh_timer() addition. No matter whether I make 1 or 101 CSS tweaks the result is always the same, namely, after hitting the Tool dialog's Save button, Preview/LiveCSS show all changes except that last remove-the-highlights change. The file on disk is correct and Show Diffs shows that the highlights are indeed gone but Preview/LiveCSS don't think so.

If I force the highlights to be removed before pressing the Save button, the problem goes away. I could easily add an extra button to the QDialog to do this, but 4-years of previously *not doing it* means I'm going to forget to press it.

My current kludge is to add the red bit to the Editor plugin Tool code which also seems to fix it:
Code:
dlg = CSSTweakerDlg(...)
if dlg.exec_():
    try:
        self.boss.close_editor(cssname)
    except:
        pass
    self.boss.edit_file(cssname)
    ... etc ...
Do you think this may just be a timing problem, i.e. the file isn't being saved to disk quite fast enough for Preview/LiveCSS to see it? Or something else ...
jackie_w is offline   Reply With Quote