Python PyQt5.QtCore.qVersion() Examples

The following are 9 code examples of PyQt5.QtCore.qVersion(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .
Example #1
Source File: qutescheme.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def qute_warning(url: QUrl) -> _HandlerRet:
    """Handler for qute://warning."""
    path = url.path()
    if path == '/old-qt':
        src = jinja.render('warning-old-qt.html',
                           title='Old Qt warning',
                           qt_version=qVersion())
    elif path == '/webkit':
        src = jinja.render('warning-webkit.html',
                           title='QtWebKit backend warning')
    elif path == '/sessions':
        src = jinja.render('warning-sessions.html',
                           title='Qt 5.15 sessions warning',
                           datadir=standarddir.data(),
                           sep=os.sep)
    else:
        raise NotFoundError("Invalid warning page {}".format(path))
    return 'text/html', src 
Example #2
Source File: earlyinit.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def check_qt_version():
    """Check if the Qt version is recent enough."""
    from PyQt5.QtCore import (qVersion, QT_VERSION, PYQT_VERSION,
                              PYQT_VERSION_STR)
    from pkg_resources import parse_version
    from qutebrowser.utils import log
    parsed_qversion = parse_version(qVersion())

    if (QT_VERSION < 0x050701 or PYQT_VERSION < 0x050700 or
            parsed_qversion < parse_version('5.7.1')):
        text = ("Fatal error: Qt >= 5.7.1 and PyQt >= 5.7 are required, "
                "but Qt {} / PyQt {} is installed.".format(qt_version(),
                                                           PYQT_VERSION_STR))
        _die(text)

    if qVersion().startswith('5.8.'):
        log.init.warning("Running qutebrowser with Qt 5.8 is untested and "
                         "unsupported!")

    if (parsed_qversion >= parse_version('5.12') and
            (PYQT_VERSION < 0x050c00 or QT_VERSION < 0x050c00)):
        log.init.warning("Combining PyQt {} with Qt {} is unsupported! Ensure "
                         "all versions are newer than 5.12 to avoid potential "
                         "issues.".format(PYQT_VERSION_STR, qt_version())) 
Example #3
Source File: utils.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def seccomp_args(qt_flag):
    """Get necessary flags to disable the seccomp BPF sandbox.

    This is needed for some QtWebEngine setups, with older Qt versions but
    newer kernels.

    Args:
        qt_flag: Add a '--qt-flag' argument.
    """
    affected_versions = set()
    for base, patch_range in [
            ## seccomp-bpf failure in syscall 0281
            ## https://github.com/qutebrowser/qutebrowser/issues/3163
            # 5.7.1
            ('5.7', [1]),

            ## seccomp-bpf failure in syscall 0281 (clock_nanosleep)
            ## https://bugreports.qt.io/browse/QTBUG-81313
            # 5.11.0 to 5.11.3 (inclusive)
            ('5.11', range(0, 4)),
            # 5.12.0 to 5.12.7 (inclusive)
            ('5.12', range(0, 8)),
            # 5.13.0 to 5.13.2 (inclusive)
            ('5.13', range(0, 3)),
            # 5.14.0
            ('5.14', [0]),
    ]:
        for patch in patch_range:
            affected_versions.add('{}.{}'.format(base, patch))

    version = (PYQT_WEBENGINE_VERSION_STR
               if PYQT_WEBENGINE_VERSION_STR is not None
               else qVersion())
    if version in affected_versions:
        disable_arg = 'disable-seccomp-filter-sandbox'
        return ['--qt-flag', disable_arg] if qt_flag else ['--' + disable_arg]

    return [] 
Example #4
Source File: earlyinit.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def qt_version(qversion=None, qt_version_str=None):
    """Get a Qt version string based on the runtime/compiled versions."""
    if qversion is None:
        from PyQt5.QtCore import qVersion
        qversion = qVersion()
    if qt_version_str is None:
        from PyQt5.QtCore import QT_VERSION_STR
        qt_version_str = QT_VERSION_STR

    if qversion != qt_version_str:
        return '{} (compiled {})'.format(qversion, qt_version_str)
    else:
        return qversion 
Example #5
Source File: configfiles.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self) -> None:
        super().__init__()
        self._filename = os.path.join(standarddir.data(), 'state')
        self.read(self._filename, encoding='utf-8')
        qt_version = qVersion()
        # We handle this here, so we can avoid setting qt_version_changed if
        # the config is brand new, but can still set it when qt_version wasn't
        # there before...
        if 'general' in self:
            old_qt_version = self['general'].get('qt_version', None)
            self.qt_version_changed = old_qt_version != qt_version
        else:
            self.qt_version_changed = False

        for sect in ['general', 'geometry', 'inspector']:
            try:
                self.add_section(sect)
            except configparser.DuplicateSectionError:
                pass

        deleted_keys = [
            ('general', 'fooled'),
            ('general', 'backend-warning-shown'),
            ('geometry', 'inspector'),
        ]
        for sect, key in deleted_keys:
            self[sect].pop(key, None)

        self['general']['qt_version'] = qt_version
        self['general']['version'] = qutebrowser.__version__ 
Example #6
Source File: raster_vision.py    From raster-vision-qgis with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, iface):
        """Constructor.

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """

        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'RasterVisionPlugin_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        # Create the dialog (after translation) and keep reference
        self.experiment_controller = ExperimentDialogController(self.iface)
        self.predict_controller = PredictDialogController(self.iface)
        self.profiles_controller = ProfilesDialogController()
        self.config_controller = ConfigDialogController()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Raster Vision')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'RasterVisionPlugin')
        self.toolbar.setObjectName(u'RasterVisionPlugin')

    # noinspection PyMethodMayBeStatic 
Example #7
Source File: hqgis.py    From Hqgis with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, iface):
        self.provider = HqgisProvider()
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'Hqgis_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        # Create the dialog (after translation) and keep reference
        self.dlg = HqgisDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Hqgis')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'Hqgis')
        self.toolbar.setObjectName(u'Hqgis')
        self.getMapCoordinates = GetMapCoordinates(self.iface)
        self.getMapCoordTool = None

    # noinspection PyMethodMayBeStatic 
Example #8
Source File: dzetsaka.py    From dzetsaka with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, iface):
        """Constructor.

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """
        # Save reference to the QGIS interface
        self.iface = iface

        # add Processing loadAlgorithms

        # init dialog and dzetsaka dock
        QDialog.__init__(self)
        #sender = self.sender()
        self.settings = QSettings()
        self.loadConfig()

        self.provider = dzetsakaProvider(self.providerType)
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)

        if self.firstInstallation is True:
            self.showWelcomeWidget()

        # initialize locale
        """
        locale = self.settings.value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'dzetsaka_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
        """
        
        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&dzetsaka')
#        # TODO: We are going to let the user set this up in a future iteration
#        self.toolbar = self.iface.addToolBar(u'dzetsaka')
#        self.toolbar.setObjectName(u'dzetsaka')
        self.pluginIsActive = False
        self.dockwidget = None
#        



        # param
        self.lastSaveDir = ''

        # run dock
        # self.run() 
Example #9
Source File: offline_map_matching.py    From Offline-MapMatching with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, iface):
        '''Constructor.

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        '''
        
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'OfflineMapMatching_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        # Create the dialog (after translation) and keep reference
        self.dlg = OfflineMapMatchingDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Offline-MapMatching')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'OfflineMapMatching')
        self.toolbar.setObjectName(u'OfflineMapMatching')
        
        #add help-document to the GUI
        dir = os.path.dirname(__file__)
        file = os.path.abspath(os.path.join(dir, 'help_docs', 'help.html'))
        if os.path.exists(file):
            with open(file) as helpf:
                help = helpf.read()
                self.dlg.textBrowser_help.insertHtml(help)
                self.dlg.textBrowser_help.moveCursor(QTextCursor.Start)
        
        #declare additional instance vars
        self.map_matcher = MapMatcher()
        self.provider = OfflineMapMatchingProvider()
        
        #connect slots and signals
        self.dlg.comboBox_trajectory.currentIndexChanged.connect(self.startPopulateFieldsComboBox)
        self.dlg.pushButton_start.clicked.connect(self.startMapMatching)
        
        #set a default crs to avoid problems in QGIS 3.4
        self.dlg.mQgsProjectionSelectionWidget.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))

    # noinspection PyMethodMayBeStatic