コード例 #1
0
    def _call_cb(self, callback, found, text, flags, caller):
        """Call the given callback if it's non-None.

        Delays the call via a QTimer so the website is re-rendered in between.

        Args:
            callback: What to call
            found: If the text was found
            text: The text searched for
            flags: The flags searched with
            caller: Name of the caller.
        """
        found_text = 'found' if found else "didn't find"
        # Removing FindWrapsAroundDocument to get the same logging as with
        # QtWebEngine
        debug_flags = debug.qflags_key(
            QWebPage, flags & ~QWebPage.FindWrapsAroundDocument,
            klass=QWebPage.FindFlag)
        if debug_flags != '0x0000':
            flag_text = 'with flags {}'.format(debug_flags)
        else:
            flag_text = ''
        log.webview.debug(' '.join([caller, found_text, text, flag_text])
                          .strip())
        if callback is not None:
            QTimer.singleShot(0, functools.partial(callback, found))

        self.finished.emit(found)
コード例 #2
0
 def _on_fullscreen_requested(self, on):
     if not config.val.content.windowed_fullscreen:
         if on:
             self.state_before_fullscreen = self.windowState()
             self.setWindowState(Qt.WindowFullScreen
                                 | self.state_before_fullscreen)
         elif self.isFullScreen():
             self.setWindowState(self.state_before_fullscreen)
     log.misc.debug('on: {}, state before fullscreen: {}'.format(
         on, debug.qflags_key(Qt, self.state_before_fullscreen)))
コード例 #3
0
 def test_int_noklass(self):
     """Test passing an int without explicit klass given."""
     with pytest.raises(TypeError):
         debug.qflags_key(Qt, 42)
コード例 #4
0
 def test_add_base(self):
     """Test with add_base=True."""
     flags = debug.qflags_key(Qt, Qt.AlignTop, add_base=True)
     assert flags == 'Qt.AlignTop'
コード例 #5
0
 def test_qflags_key(self, base, value, klass, expected):
     flags = debug.qflags_key(base, value, klass=klass)
     assert flags == expected