Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 08-12-2025, 04:36 PM   #586
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,695
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by BeckyEbook View Post
But now it is defined, plus it is the same color as Base.
Are you sure? It was my understanding that AlternateBase (in plugin_utils.py) is being assigned the same color as the Window role from Sigil.

https://github.com/Sigil-Ebook/Sigil...unner.cpp#L244

https://github.com/dougmassay/sigil-..._utils.py#L264

https://github.com/dougmassay/sigil-..._utils.py#L272

Unless Base and Window are the same color.

I'm not opposed to your suggestion, but I would ultimately like the actual system alternateBase color to be used. With a hard-coded color in plugin_utils.py being embedded in tons of Qt plugins, that might not be a realistic hope.

I'd rather we didn't have to do this (match_dark_palette) on Windows at all, but...
DiapDealer is online now   Reply With Quote
Old 08-12-2025, 05:33 PM   #587
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 874
Karma: 3501146
Join Date: Jan 2017
Location: Poland
Device: Various
Of course – not Base, but Window.
BeckyEbook is offline   Reply With Quote
Old 08-13-2025, 03:27 PM   #588
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,695
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I went ahead and updated plugin_utils.py (and the light version) with your suggested color. Thanks!
DiapDealer is online now   Reply With Quote
Old 08-14-2025, 11:27 AM   #589
wrCisco
Connoisseur
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 50
Karma: 605108
Join Date: Apr 2016
Device: none
Ok, I updated my copy of plugin_utils too.

One question for DiapDealer: the readme of the sigil-plugin-utils repository indicates the GPL v3 license but the notice at the top of each file shows the 2-clause BSD license. Is the latter the valid one or do you have another preference?
wrCisco is offline   Reply With Quote
Old 08-14-2025, 11:59 AM   #590
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,695
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I prefer the 2-clause BSD (more permissive than GPLv3). I think GitHub might have just defaulted to GPLv3 when I quickly created the repo. I'll try to make them match. Thanks.

EDIT: I think I got everything updated to match on GitHub. Thanks again.

Last edited by DiapDealer; 08-14-2025 at 12:10 PM.
DiapDealer is online now   Reply With Quote
Old Yesterday, 05:34 PM   #591
wrCisco
Connoisseur
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 50
Karma: 605108
Join Date: Apr 2016
Device: none
I wanted to improve and generalize the first-words-then-everywhere wrapping of text for the plain text of QLabels, so I'm partially rewriting the code of my WrappingCheckBox widget to use QTextBoundaryFinder to split words and graphemes in a text, and I stumbled upon a small incompatibility between pyqt5 and pyside6: while in pyside6 you can iterate over qt enums, in pyqt5 you can't. Do you know if there is a more clever way to do what I'm doing with 'boundary_reasons' in the following function (an optional parameter which, if None, is assigned all the enumeration's values combined)?

Code:
from functools import reduce
from plugin_utils import QtCore

def tokenize_text(
            text: str,
            boundary_type: QtCore.QTextBoundaryFinder.BoundaryType,
            boundary_reasons: QtCore.QTextBoundaryFinder.BoundaryReason | None = None) -> list[str]:
        """
        Divide text in a list of tokens based on boundary_type.
        boundary types: Grapheme, Word, Line, Sentence
        """
        if boundary_reasons is None:
            try:
                # BreakOpportunity doesn't come up while iterating over BoundaryReason flags
                # (PySide 6.9), so I use it as the initializer of the reduce function
                boundary_reasons = reduce(
                    lambda x, y: x | y,
                    QtCore.QTextBoundaryFinder.BoundaryReason,
                    QtCore.QTextBoundaryFinder.BoundaryReason.BreakOpportunity
                )
            except TypeError:
                # PyQt5 doesn't allow iterations over Qt enums
                boundary_reasons = (
                    QtCore.QTextBoundaryFinder.BoundaryReason.StartOfItem
                    | QtCore.QTextBoundaryFinder.BoundaryReason.EndOfItem
                    | QtCore.QTextBoundaryFinder.BoundaryReason.MandatoryBreak
                    | QtCore.QTextBoundaryFinder.BoundaryReason.SoftHyphen
                    | QtCore.QTextBoundaryFinder.BoundaryReason.BreakOpportunity
                )
        tbf = QtCore.QTextBoundaryFinder(boundary_type, text)
        tokens = []
        pos = prev = tbf.position()
        while True:
            pos = tbf.toNextBoundary()
            if pos == -1:
                break
            if pos != prev and boundary_reasons & tbf.boundaryReasons():
                token = text[prev:pos]
                tokens.append(text[prev:pos])
                prev = pos
        return tokens
I found a couple of Stack Overflow answers that address the issue, but the solution proposed seems way too complex for my limited use case (https://stackoverflow.com/questions/...representation, https://stackoverflow.com/questions/...-typedef-for-q).
wrCisco is offline   Reply With Quote
Old Yesterday, 07:23 PM   #592
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,887
Karma: 6120478
Join Date: Nov 2009
Device: many
Given it is only one enum and given PyQt5/Qt5 has no further development and therefore the enum will never be changed, your approach seems like the simplest and best.

That said, PyQt5 had a long life. Are there any earlier versions of this enum in Qt5 that changed? Maybe eyeball the history of the Qt source file that defines the Qt5 enum on github to see if it ever changed over its life. If not, you should be golden.

Update: It did change very early in Qt 5.0 from the final Qt 4.x series as per:
https://github.com/qt/qtbase/commit/...41ecc95fa976e9

But since that change happened to make Qt 5.0.0 you should be quite safe.

Here is the enum as stated in Qt 5.15.x. You should be good to go.

Code:
   enum BoundaryReason {
        NotAtBoundary = 0,
        BreakOpportunity = 0x1f,
        StartOfItem = 0x20,
        EndOfItem = 0x40,
        MandatoryBreak = 0x80,
        SoftHyphen = 0x100
    };

Last edited by KevinH; Yesterday at 07:45 PM.
KevinH is offline   Reply With Quote
Old Yesterday, 07:46 PM   #593
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,695
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I knowingly punted on trying to attain enum compatibility between PyQt5 and PySide6 with plugin_utils.

I agree with Kevin here. No need to get overly clever/complex for one enum. You could check to see if PySide6 is already in sys.modules rather than try/except, but there's no real advantage either approach would have over the other in my opinion.
DiapDealer is online now   Reply With Quote
Old Today, 04:41 AM   #594
wrCisco
Connoisseur
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 50
Karma: 605108
Join Date: Apr 2016
Device: none
Ok, thank you both!
wrCisco is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 06:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-04-2012 11:33 PM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 09:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 12:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 12:44 PM


All times are GMT -4. The time now is 07:59 PM.


MobileRead.com is a privately owned, operated and funded community.