Exemplo n.º 1
0
 def _uic(self):
     vbox = QVBoxLayout()  # main layout
     hbox = QHBoxLayout()  # top row layout
     self.refresh_button = QPushButton(
         _TR("button on Page table to update all folio values", "Refresh"))
     self.refresh_button.setToolTip(
         _TR("button on Page Table",
             "Update all folio values in the table to reflect any changes"))
     self.insert_button = QPushButton(
         _TR("button on Page table to insert text at page boundaries",
             "Insert"))
     self.insert_button.setToolTip(
         _TR("button on Page Table",
             "Insert the text at the start of every page"))
     self.insert_text = QLineEdit()
     self.insert_text.setFont(fonts.get_fixed())
     self.insert_text.setToolTip(
         _TR(
             "text field on Page Table",
             "Text to insert at the start of every page. %f becomes the folio, %i becomes the image filename."
         ))
     hbox.addWidget(self.refresh_button, 0)
     hbox.addWidget(self.insert_text, 1)  # text gets all available stretch
     hbox.addWidget(self.insert_button, 0)
     vbox.addLayout(hbox, 0)
     self.model = PageTableModel(self.pdata, self)
     self.view = PageTableView(self)
     self.view.setModel(self.model)
     vbox.addWidget(self.view, 1)
     self.setLayout(vbox)
Exemplo n.º 2
0
    def __init__(self, my_book):
        super().__init__(parent = my_book)
        # Initialize slot for cached copy of document text, see full_text()
        self._text = None
        self.contentsChanged.connect(self._text_modified)

        # TODO do I want to customize the layout?
        self.setDocumentLayout(QPlainTextDocumentLayout(self))
        # Set my default font to the current mono font.
        self.setDefaultFont( fonts.get_fixed(my_book.get_font_size()) )
Exemplo n.º 3
0
    def __init__(self, my_book):
        super().__init__(parent=my_book)
        # Initialize slot for cached copy of document text, see full_text()
        self._text = None
        self.contentsChanged.connect(self._text_modified)

        # TODO do I want to customize the layout?
        self.setDocumentLayout(QPlainTextDocumentLayout(self))
        # Set my default font to the current mono font.
        self.setDefaultFont(fonts.get_fixed(my_book.get_font_size()))
Exemplo n.º 4
0
 def __init__(self, my_book, parent=None):
     super().__init__(parent)
     self.book = my_book
     # Where we store the last-sought-for find string
     self.find_text = None
     # Register to read and write metadata
     my_book.get_meta_manager().register( C.MD_NO, self.read_meta, self.save_meta )
     # Set our only font (we don't care about the general font, only mono)
     # n.b. this gets the Book's default size as it hasn't loaded a document
     # yet.
     self.setFont(fonts.get_fixed(my_book.get_font_size()))
     # hook up to be notified of a change in font choice
     fonts.notify_me(self.font_change)
     # Set up our document not using the default one
     a_document = QTextDocument()
     a_document.setDocumentLayout(QPlainTextDocumentLayout(a_document))
     self.setDocument(a_document)
     # Turn off linewrap mode
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     # The following kludge allows us to get the correct highlight
     # color on focus-in. For unknown reasons Qt makes us use the
     # "Inactive" color group even after focus-in. See focusInEvent()
     # and focusOutEvent() below.
     self.palette_active = QPalette(self.palette())
     self.palette_inactive = QPalette(self.palette())
     b = self.palette().brush(QPalette.Active,QPalette.Highlight)
     self.palette_active.setBrush(QPalette.Inactive,QPalette.Highlight,b)
     # Set the cursor shape to IBeam -- no idea why this supposed default
     # inherited from QTextEdit, doesn't happen. But it doesn't.
     self.viewport().setCursor(Qt.IBeamCursor)
     # Hook up a slot to notice that the document has changed its
     # modification state.
     self.document().modificationChanged.connect(self.yikes)
     # Create our edit menu and stow it in the menu bar. Disable it.
     ed_menu = QMenu(C.ED_MENU_EDIT,self)
     ed_menu.addAction(C.ED_MENU_UNDO,self.undo,QKeySequence.Undo)
     ed_menu.addAction(C.ED_MENU_REDO,self.redo,QKeySequence.Redo)
     ed_menu.addSeparator()
     ed_menu.addAction(C.ED_MENU_CUT,self.cut,QKeySequence.Cut)
     ed_menu.addAction(C.ED_MENU_COPY,self.copy,QKeySequence.Copy)
     ed_menu.addAction(C.ED_MENU_PASTE,self.paste,QKeySequence.Paste)
     ed_menu.addSeparator()
     ed_menu.addAction(C.ED_MENU_FIND,self.find_action,QKeySequence.Find)
     ed_menu.addAction(C.ED_MENU_NEXT,self.find_next_action,QKeySequence.FindNext)
     self.edit_menu = mainwindow.get_menu_bar().addMenu(ed_menu)
     self.edit_menu.setVisible(False)
     # In order to get focus events, we need to set focus policy
     self.setFocusPolicy(Qt.StrongFocus)
Exemplo n.º 5
0
 def __init__(self, my_book, parent=None):
     super().__init__(parent)
     self.book = my_book
     # Where we store the last-sought-for find string
     self.find_text = None
     # Register to read and write metadata
     my_book.get_meta_manager().register(C.MD_NO, self._read_meta,
                                         self._save_meta)
     # Set our only font (we don't care about the general font, only mono)
     # n.b. this gets the Book's default size as it hasn't loaded a document
     # yet.
     self.setFont(fonts.get_fixed(my_book.get_font_size()))
     # hook up to be notified of a change in font choice
     fonts.notify_me(self.font_change)
     # Set up our document not using the default one
     a_document = QTextDocument()
     a_document.setDocumentLayout(QPlainTextDocumentLayout(a_document))
     self.setDocument(a_document)
     # Turn off linewrap mode
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     # The following kludge allows us to get the correct highlight
     # color on focus-in. For unknown reasons Qt makes us use the
     # "Inactive" color group even after focus-in. See focusInEvent()
     # and focusOutEvent() below.
     self.palette_active = QPalette(self.palette())
     self.palette_inactive = QPalette(self.palette())
     b = self.palette().brush(QPalette.Active, QPalette.Highlight)
     self.palette_active.setBrush(QPalette.Inactive, QPalette.Highlight, b)
     # Set the cursor shape to IBeam -- no idea why this supposed default
     # inherited from QTextEdit, doesn't happen. But it doesn't.
     self.viewport().setCursor(Qt.IBeamCursor)
     # Hook up a slot to notice that the document has changed its
     # modification state.
     self.document().modificationChanged.connect(self.yikes)
     # Create the list of actions for our edit menu and save it
     # for use on focus-in.
     self.ed_action_list = [
         (C.ED_MENU_UNDO, self.undo, QKeySequence.Undo),
         (C.ED_MENU_REDO, self.redo, QKeySequence.Redo), (None, None, None),
         (C.ED_MENU_CUT, self.cut, QKeySequence.Cut),
         (C.ED_MENU_COPY, self.copy, QKeySequence.Copy),
         (C.ED_MENU_PASTE, self.paste, QKeySequence.Paste),
         (None, None, None),
         (C.ED_MENU_FIND, self.find_action, QKeySequence.Find),
         (C.ED_MENU_NEXT, self.find_next_action, QKeySequence.FindNext)
     ]
     self.setFocusPolicy(Qt.StrongFocus)
Exemplo n.º 6
0
 def font_change(self, is_mono):
     if not is_mono:
         self.setFont(fonts.get_general())
     self.Editor.setFont(fonts.get_fixed(self.my_book.get_font_size()))
     self.one_line_height = self.Editor.fontMetrics().lineSpacing()
Exemplo n.º 7
0
 def font_change(self,is_mono):
     if is_mono :
         self.setFont(fonts.get_fixed(self.book.get_font_size()))
Exemplo n.º 8
0
 def reset(self) :
     self.choice = fonts.get_fixed().family()
     self.fcb.setCurrentText( self.choice )
Exemplo n.º 9
0
 def font_change(self,is_mono):
     if not is_mono :
         self.setFont(fonts.get_general())
     self.Editor.setFont(fonts.get_fixed(self.my_book.get_font_size()))
     self.one_line_height = self.Editor.fontMetrics().lineSpacing()
Exemplo n.º 10
0
settings = QSettings()
import constants as C
import fonts
from PyQt5.QtGui import (QFont, QFontInfo, QFontDatabase)

# check initialize
# check defaults on empty settings
def same_font(qf1, qf2):
    return qf1.family() == qf2.family() and qf1.pointSize() == qf2.pointSize()

settings.clear()
myfdb = QFontDatabase()
genqf = myfdb.systemFont(QFontDatabase.GeneralFont)
fonts.initialize(settings)
assert same_font(genqf,fonts.get_general())
monqf = fonts.get_fixed()
dbg = monqf.family()
assert monqf.family() == 'Liberation Mono'
assert monqf.pointSize() == C.DEFAULT_FONT_SIZE
SIGBOOL = None
def slot(boola):
    global SIGBOOL
    SIGBOOL = boola
fonts.notify_me(slot)
fonts.set_general(genqf) # should be no signal
assert SIGBOOL is None
palqf = myfdb.font('Palatino','Normal',18)
fonts.set_general(palqf) # should cause signal(false)
assert SIGBOOL == False # altho None is never true, it isn't False
couqf = myfdb.font('Courier','Normal',17)
fonts.set_fixed(couqf) # should cause signal(true)
Exemplo n.º 11
0
import fonts
from PyQt5.QtGui import (QFont, QFontInfo, QFontDatabase)


# check initialize
# check defaults on empty settings
def same_font(qf1, qf2):
    return qf1.family() == qf2.family() and qf1.pointSize() == qf2.pointSize()


T.settings.clear()
myfdb = QFontDatabase()
genqf = myfdb.systemFont(QFontDatabase.GeneralFont)
fonts.initialize(T.settings)
assert same_font(genqf, fonts.get_general())
monqf = fonts.get_fixed()
dbg = monqf.family()
assert monqf.family() == 'Liberation Mono'
assert monqf.pointSize() == C.DEFAULT_FONT_SIZE
SIGBOOL = None


def slot(boola):
    global SIGBOOL
    SIGBOOL = boola


fonts.notify_me(slot)
fonts.set_general(genqf)  # should be no signal
assert SIGBOOL is None
palqf = myfdb.font('Palatino', 'Normal', 18)
Exemplo n.º 12
0
 def font_change(self, boolean):
     if boolean:  # mono font change
         self.insert_text.setFont(fonts.get_fixed())
Exemplo n.º 13
0
 def font_change(self, is_mono):
     if is_mono:
         self.setFont(fonts.get_fixed(self.book.get_font_size()))