Esempio n. 1
0
 def checkSettings(self):
     settings = QSettings('luigicruz', 'CyberRadio')
     if not settings.value('settings_set', type=bool):
         print("[GUI] Previous settings not found. Creating new ones.")
         settings.setValue('settings_set', True)
         settings.setValue('enable_cuda', not is_mac())
         settings.setValue('enable_numba', not is_mac())
         settings.setValue('enable_stereo', True)
         settings.setValue('last_frequency', 96.9e6)
         settings.setValue('demodulation_mode', 0)
         settings.setValue('tau', 75e-6)
         settings.setValue('favorites_list', defaultFavorites())
         settings.setValue('volume', 0)
         del settings
Esempio n. 2
0
 def app_icon(self):
     """
     The app icon. Not available on Mac because app icons are handled by the
     OS there.
     """
     if not is_mac():
         return QIcon(self.get_resource('Icon.ico'))
Esempio n. 3
0
def freeze(debug=False):
    """
    Compile your application to a standalone executable
    """
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X.
    app_name = SETTINGS['app_name']
    if is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
        executable = 'target/%s.app/Contents/MacOS/%s' % (app_name, app_name)
    else:
        executable = join('target', app_name, app_name)
        if is_windows():
            from fbs.freeze.windows import freeze_windows
            freeze_windows(debug=debug)
            executable += '.exe'
        elif is_linux():
            if is_ubuntu():
                from fbs.freeze.ubuntu import freeze_ubuntu
                freeze_ubuntu(debug=debug)
            elif is_arch_linux():
                from fbs.freeze.arch import freeze_arch
                freeze_arch(debug=debug)
            elif is_fedora():
                from fbs.freeze.fedora import freeze_fedora
                freeze_fedora(debug=debug)
            else:
                from fbs.freeze.linux import freeze_linux
                freeze_linux(debug=debug)
        else:
            raise RuntimeError('Unsupported OS')
    _LOG.info(
        "Done. You can now run `%s`. If that doesn't work, see "
        "https://build-system.fman.io/troubleshooting.", executable)
Esempio n. 4
0
def create_installer_mac():
    app_name = SETTINGS['app_name']
    dest = path('target/${installer}')
    dest_existed = exists(dest)
    if dest_existed:
        dest_bu = dest + '.bu'
        replace(dest, dest_bu)
    try:
        pdata = [
            join(dirname(__file__), 'create-dmg',
                 'create-dmg'), '--volname', app_name, '--app-drop-link',
            '170', '10', '--icon', app_name + '.app', '0', '10', dest,
            path('${freeze_dir}')
        ]

        if is_mac():
            major, minor = platform.mac_ver()[0].split('.')[:2]
            if (int(major) == 10 and int(minor) >= 15) or int(major) >= 11:
                pdata.insert(1, '--no-internet-enable')

        check_call(pdata, stdout=DEVNULL)
    except:
        if dest_existed:
            replace(dest_bu, dest)
        raise
    else:
        if dest_existed:
            remove(dest_bu)
Esempio n. 5
0
def run_pyinstaller(extra_args=None, debug=False):
    if extra_args is None:
        extra_args = []
    app_name = SETTINGS['app_name']
    # Would like log level WARN when not debugging. This works fine for
    # PyInstaller 3.3. However, for 3.4, it gives confusing warnings
    # "hidden import not found". So use ERROR instead.
    log_level = 'DEBUG' if debug else 'ERROR'
    args = [
        'pyinstaller', '--name', app_name, '--noupx', '--log-level', log_level,
        '--noconfirm'
    ]
    for hidden_import in SETTINGS['hidden_imports']:
        args.extend(['--hidden-import', hidden_import])
    args.extend(extra_args)
    args.extend([
        '--distpath',
        path('target'), '--specpath',
        path('target/PyInstaller'), '--workpath',
        path('target/PyInstaller'),
        path(SETTINGS['main_module'])
    ])
    if debug:
        args.append('--debug')
    run(args, check=True)
    output_dir = path('target/' + app_name + ('.app' if is_mac() else ''))
    freeze_dir = path('${freeze_dir}')
    # In most cases, rename(src, dst) silently "works" when src == dst. But on
    # some Windows drives, it raises a FileExistsError. So check src != dst:
    if PurePath(output_dir) != PurePath(freeze_dir):
        rename(output_dir, freeze_dir)
Esempio n. 6
0
def run_pyinstaller(extra_args=None, debug=False):
    if extra_args is None:
        extra_args = []
    app_name = SETTINGS['app_name']
    log_level = 'DEBUG' if debug else 'WARN'
    args = [
        'pyinstaller',
        '--name', app_name,
        '--noupx',
        '--log-level', log_level,
        '--noconfirm'
    ]
    for hidden_import in SETTINGS['hidden_imports']:
        args.extend(['--hidden-import', hidden_import])
    args.extend(extra_args)
    args.extend([
        '--distpath', path('target'),
        '--specpath', path('target/PyInstaller'),
        '--workpath', path('target/PyInstaller'),
        path(SETTINGS['main_module'])
    ])
    if debug:
        args.append('--debug')
    run(args, check=True)
    output_dir = path('target/' + app_name + ('.app' if is_mac() else ''))
    rename(output_dir, path('${freeze_dir}'))
Esempio n. 7
0
def freeze(debug=False):
    """
    Compile your application to a standalone executable
    """
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X:
    if is_windows():
        from fbs.freeze.windows import freeze_windows
        freeze_windows(debug=debug)
    elif is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
    elif is_linux():
        if is_ubuntu():
            from fbs.freeze.ubuntu import freeze_ubuntu
            freeze_ubuntu(debug=debug)
        elif is_arch_linux():
            from fbs.freeze.arch import freeze_arch
            freeze_arch(debug=debug)
        elif is_fedora():
            from fbs.freeze.fedora import freeze_fedora
            freeze_fedora(debug=debug)
        else:
            from fbs.freeze.linux import freeze_linux
            freeze_linux(debug=debug)
    else:
        raise RuntimeError('Unsupported OS')
Esempio n. 8
0
    def keyPressEvent(self, orig_event: QKeyEvent) -> None:
        """
        Re-definition of QWidget.keyPressEvent(). This function is called by Qt
        every time a key press is registered in the MainWindow / centralWidget.
        """
        # check if this key needs to be translated
        if orig_event.key() in self.keyTranslations:
            # get the translated event
            event = self.keyTranslations[orig_event.key()]
            translated = True

            # if the translation does not specify modifiers, keep the original modifiers
            if not event.modifiers() & Qt.AltModifier and not event.modifiers(
            ) & Qt.ControlModifier:
                event = QKeyEvent(QEvent.KeyPress, event.key(),
                                  orig_event.modifiers())
                translated = False
        else:
            # otherwise use the original event
            event = orig_event
            translated = False

        # if a valid key was pressed
        if event.key() in self.buttons:
            # get the Button corresponding to the key
            button = self.buttons[event.key()]

            # check for mac or windows to know to switch what funcitons Alt
            # and Ctrl correspond to
            if is_mac() or translated:
                # use modifiers() to determine which reference to animateClick on
                # and therefore which function to perform
                if event.modifiers(
                ) & Qt.AltModifier and button.ref_2 is not None:
                    # second function
                    button.ref_2.animateClick()
                elif event.modifiers(
                ) & Qt.ControlModifier and button.ref_3 is not None:
                    # third function
                    button.ref_3.animateClick()
                else:
                    # first / main funciton
                    button.ref_1.animateClick()
            else:
                # use modifiers() to determine which reference to animateClick on
                # and therefore which function to perform
                if event.modifiers(
                ) & Qt.ControlModifier and button.ref_2 is not None:
                    # second function
                    button.ref_2.animateClick()
                elif event.modifiers(
                ) & Qt.AltModifier and button.ref_3 is not None:
                    # third function
                    button.ref_3.animateClick()
                else:
                    # first / main funciton
                    button.ref_1.animateClick()

        return
Esempio n. 9
0
 def _create_resource_locator(self):
     if is_frozen():
         executable_dir = dirname(sys.executable)
         if is_mac():
             resources_dir = join(executable_dir, pardir, 'Resources')
         else:
             resources_dir = executable_dir
         return _ResourceLocator([resources_dir])
     else:
         return _DevelopmentResourceLocator(self.__class__)
Esempio n. 10
0
def installer():
    """
    Create an installer for your app
    """
    require_existing_project()
    if not exists(path('${freeze_dir}')):
        raise FbsError(
            'It seems your app has not yet been frozen. Please run:\n'
            '    fbs freeze')
    linux_distribution_not_supported_msg = \
        "Your Linux distribution is not supported, sorry. " \
        "You can run `fbs buildvm` followed by `fbs runvm` to start a Docker " \
        "VM of a supported distribution."
    try:
        installer_fname = SETTINGS['installer']
    except KeyError:
        if is_linux():
            raise FbsError(linux_distribution_not_supported_msg)
        raise
    out_file = join('target', installer_fname)
    msg_parts = ['Created %s.' % out_file]
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    elif is_linux():
        app_name = SETTINGS['app_name']
        if is_ubuntu():
            from fbs.installer.ubuntu import create_installer_ubuntu
            create_installer_ubuntu()
            install_cmd = 'sudo dpkg -i ' + out_file
            remove_cmd = 'sudo dpkg --purge ' + app_name
        elif is_arch_linux():
            from fbs.installer.arch import create_installer_arch
            create_installer_arch()
            install_cmd = 'sudo pacman -U ' + out_file
            remove_cmd = 'sudo pacman -R ' + app_name
        elif is_fedora():
            from fbs.installer.fedora import create_installer_fedora
            create_installer_fedora()
            install_cmd = 'sudo dnf install ' + out_file
            remove_cmd = 'sudo dnf remove ' + app_name
        else:
            raise FbsError(linux_distribution_not_supported_msg)
        msg_parts.append(
            'You can for instance install it via the following command:\n'
            '    %s\n'
            'This places it in /opt/%s. To uninstall it again, you can use:\n'
            '    %s' % (install_cmd, app_name, remove_cmd))
    else:
        raise FbsError('Unsupported OS')
    _LOG.info(' '.join(msg_parts))
Esempio n. 11
0
 def test_freeze_installer(self):
     freeze()
     if is_mac():
         executable = path('${freeze_dir}/Contents/MacOS/${app_name}')
     elif is_windows():
         executable = path('${freeze_dir}/${app_name}.exe')
     else:
         executable = path('${freeze_dir}/${app_name}')
     self.assertTrue(exists(executable), executable + ' does not exist')
     installer()
     self.assertTrue(exists(path('target/${installer}')))
Esempio n. 12
0
def installer():
    """
    Create an installer for your app
    """
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    else:
        raise RuntimeError('Unsupported OS')
Esempio n. 13
0
def run_pyinstaller(extra_args=None, debug=False):
    if extra_args is None:
        extra_args = []
    app_name = SETTINGS['app_name']
    # Would like log level WARN when not debugging. This works fine for
    # PyInstaller 3.3. However, for 3.4, it gives confusing warnings
    # "hidden import not found". So use ERROR instead.
    log_level = 'DEBUG' if debug else 'ERROR'
    args = [
        'pyinstaller',
        '--name', app_name,
        '--noupx',
        '--log-level', log_level,
        '--noconfirm'
    ]
    for hidden_import in SETTINGS['hidden_imports']:
        args.extend(['--hidden-import', hidden_import])
    args.extend(extra_args)
    args.extend([
        '--distpath', path('target'),
        '--specpath', path('target/PyInstaller'),
        '--workpath', path('target/PyInstaller')
    ])
    args.extend(['--additional-hooks-dir', join(dirname(__file__), 'hooks')])
    if debug:
        args.extend(['--debug', 'all'])
        if is_mac():
            # Force generation of an .app bundle. Otherwise, PyInstaller skips
            # it when --debug is given.
            args.append('-w')
    hook_path = _generate_runtime_hook()
    args.extend(['--runtime-hook', hook_path])
    args.append(path(SETTINGS['main_module']))
    run(args, check=True)
    output_dir = path('target/' + app_name + ('.app' if is_mac() else ''))
    freeze_dir = path('${freeze_dir}')
    # In most cases, rename(src, dst) silently "works" when src == dst. But on
    # some Windows drives, it raises a FileExistsError. So check src != dst:
    if PurePath(output_dir) != PurePath(freeze_dir):
        rename(output_dir, freeze_dir)
Esempio n. 14
0
def sign():
    """
    Sign your app, so the user's OS trusts it
    """
    require_frozen_app()
    if is_windows():
        from fbs.sign.windows import sign_windows
        sign_windows()
        _LOG.info('Signed all binary files in %s and its subdirectories.',
                  relpath(path('${freeze_dir}'), path('.')))
    elif is_mac():
        _LOG.info('fbs does not yet implement `sign` on macOS.')
    else:
        _LOG.info('This platform does not support signing frozen apps.')
Esempio n. 15
0
 def test_freeze_installer(self):
     freeze()
     if is_mac():
         executable = path('${freeze_dir}/Contents/MacOS/${app_name}')
     elif is_windows():
         executable = path('${freeze_dir}/${app_name}.exe')
     else:
         executable = path('${freeze_dir}/${app_name}')
     self.assertTrue(exists(executable), executable + ' does not exist')
     installer()
     self.assertTrue(exists(path('target/${installer}')))
     if is_linux():
         applications_dir = path('target/installer/usr/share/applications')
         self.assertEqual(['MyApp.desktop'], listdir(applications_dir))
         with open(join(applications_dir, 'MyApp.desktop')) as f:
             self.assertIn('MyApp', f.read())
Esempio n. 16
0
def _generate_resources():
    """
    Copy the data files from src/main/resources to ${freeze_dir}.
    Automatically filters files mentioned in the setting resources_to_filter:
    Placeholders such as ${app_name} are automatically replaced by the
    corresponding setting in files on that list.
    """
    freeze_dir = path('${freeze_dir}')
    if is_mac():
        resources_dest_dir = join(freeze_dir, 'Contents', 'Resources')
    else:
        resources_dest_dir = freeze_dir
    for path_fn in _defaults.path, path:
        for profile in LOADED_PROFILES:
            _copy(path_fn, 'src/main/resources/' + profile, resources_dest_dir)
            _copy(path_fn, 'src/freeze/' + profile, freeze_dir)
Esempio n. 17
0
def freeze(debug=False):
    """
    Compile your code to a standalone executable
    """
    require_existing_project()
    if not _has_module('PyInstaller'):
        raise FbsError("Could not find PyInstaller. Maybe you need to:\n"
                       "    pip install PyInstaller==3.4")
    version = SETTINGS['version']
    if not is_valid_version(version):
        raise FbsError(
            'Invalid version detected in settings. It should be three\n'
            'numbers separated by dots, such as "1.2.3". You have:\n\t"%s".\n'
            'Usually, this can be fixed in src/build/settings/base.json.' %
            version)
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X.
    app_name = SETTINGS['app_name']
    if is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
        executable = 'target/%s.app/Contents/MacOS/%s' % (app_name, app_name)
    else:
        executable = join('target', app_name, app_name)
        if is_windows():
            from fbs.freeze.windows import freeze_windows
            freeze_windows(debug=debug)
            executable += '.exe'
        elif is_linux():
            if is_ubuntu():
                from fbs.freeze.ubuntu import freeze_ubuntu
                freeze_ubuntu(debug=debug)
            elif is_arch_linux():
                from fbs.freeze.arch import freeze_arch
                freeze_arch(debug=debug)
            elif is_fedora():
                from fbs.freeze.fedora import freeze_fedora
                freeze_fedora(debug=debug)
            else:
                from fbs.freeze.linux import freeze_linux
                freeze_linux(debug=debug)
        else:
            raise FbsError('Unsupported OS')
    _LOG.info(
        "Done. You can now run `%s`. If that doesn't work, see "
        "https://build-system.fman.io/troubleshooting.", executable)
Esempio n. 18
0
def run_pyinstaller(extra_args=None, debug=False):
    if extra_args is None:
        extra_args = []
    app_name = SETTINGS['app_name']
    log_level = 'DEBUG' if debug else 'WARN'
    cmdline = [
        'pyinstaller', '--name', app_name, '--noupx', '--log-level', log_level
    ] + extra_args + [
        '--distpath',
        path('target'), '--specpath',
        path('target/PyInstaller'), '--workpath',
        path('target/PyInstaller'), SETTINGS['main_module']
    ]
    if debug:
        cmdline.append('--debug')
    run(cmdline, check=True)
    output_dir = path('target/' + app_name + ('.app' if is_mac() else ''))
    rename(output_dir, path('${freeze_dir}'))
Esempio n. 19
0
def freeze(debug=False):
    """
    Compile your code to a standalone executable
    """
    require_existing_project()
    if not _has_module('PyInstaller'):
        raise FbsError(
            "Could not find PyInstaller. Maybe you need to:\n"
            "    pip install PyInstaller==3.4"
        )
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X.
    app_name = SETTINGS['app_name']
    if is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
        executable = 'target/%s.app/Contents/MacOS/%s' % (app_name, app_name)
    else:
        executable = join('target', app_name, app_name)
        if is_windows():
            from fbs.freeze.windows import freeze_windows
            freeze_windows(debug=debug)
            executable += '.exe'
        elif is_linux():
            if is_ubuntu():
                from fbs.freeze.ubuntu import freeze_ubuntu
                freeze_ubuntu(debug=debug)
            elif is_arch_linux():
                from fbs.freeze.arch import freeze_arch
                freeze_arch(debug=debug)
            elif is_fedora():
                from fbs.freeze.fedora import freeze_fedora
                freeze_fedora(debug=debug)
            else:
                from fbs.freeze.linux import freeze_linux
                freeze_linux(debug=debug)
        else:
            raise FbsError('Unsupported OS')
    _LOG.info(
        "Done. You can now run `%s`. If that doesn't work, see "
        "https://build-system.fman.io/troubleshooting.", executable
    )
Esempio n. 20
0
def open_playlist(path_to_playlist):
    logger.info('open_playlist...')

    try:
        set_default_arrangements(path_to_playlist)
    except Exception as e:
        logger.error("open_playlist - Cannot set default arrangements: %s" %
                     str(e))

    try:
        if is_windows():
            path_to_propresenter = "C:\\Program Files (x86)\\Renewed Vision\\ProPresenter 6\\ProPresenter.exe"
            subprocess.Popen([path_to_propresenter, path_to_playlist],
                             creationflags=DETACHED_PROCESS)
        elif is_mac():
            path_to_propresenter = '/Applications/ProPresenter 6.app'
            subprocess.Popen(
                ['open', '-a', path_to_propresenter, path_to_playlist])
    except Exception as e:
        logger.error('open_playlist - Cannot open playlist: %s' % str(e))
Esempio n. 21
0
    def populateSettings(self):
        self.numbaCbx.setChecked(self.parent.enableNumba)

        self.cudaCbx.setChecked(self.parent.enableCuda)
        self.cudaCbx.setEnabled(False)

        self.stereoCbx.setChecked(self.parent.enableStereo)
        self.stereoCbx.setEnabled(False)

        if self.parent.tau == 75e-6:
            self.deemp75Rdio.setChecked(True)
        else:
            self.deemp50Rdio.setChecked(True)

        # Apply System Specific Settings
        if isCudaCapable():
            self.cudaCbx.setEnabled(True)

        if is_mac():
            self.cudaCbx.setEnabled(False)  # macOS doesn't support CUDA ­Ъци
Esempio n. 22
0
def sign_installer():
    """
    Sign installer, so the user's OS trusts it
    """
    if is_mac():
        _LOG.info('fbs does not yet implement `sign_installer` on macOS.')
        return
    if is_ubuntu():
        _LOG.info('Ubuntu does not support signing installers.')
        return
    require_installer()
    if is_windows():
        from fbs.sign_installer.windows import sign_installer_windows
        sign_installer_windows()
    elif is_arch_linux():
        from fbs.sign_installer.arch import sign_installer_arch
        sign_installer_arch()
    elif is_fedora():
        from fbs.sign_installer.fedora import sign_installer_fedora
        sign_installer_fedora()
    _LOG.info('Signed %s.', join('target', SETTINGS['installer']))
Esempio n. 23
0
def installer():
    """
    Create an installer for your app
    """
    require_existing_project()
    out_file = join('target', SETTINGS['installer'])
    msg_parts = ['Created %s.' % out_file]
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    elif is_linux():
        app_name = SETTINGS['app_name']
        if is_ubuntu():
            from fbs.installer.ubuntu import create_installer_ubuntu
            create_installer_ubuntu()
            install_cmd = 'sudo dpkg -i ' + out_file
            remove_cmd = 'sudo dpkg --purge ' + app_name
        elif is_arch_linux():
            from fbs.installer.arch import create_installer_arch
            create_installer_arch()
            install_cmd = 'sudo pacman -U ' + out_file
            remove_cmd = 'sudo pacman -R ' + app_name
        elif is_fedora():
            from fbs.installer.fedora import create_installer_fedora
            create_installer_fedora()
            install_cmd = 'sudo dnf install ' + out_file
            remove_cmd = 'sudo dnf remove ' + app_name
        else:
            raise FbsError('Unsupported Linux distribution')
        msg_parts.append(
            'You can for instance install it via the following command:\n'
            '    %s\n'
            'This places it in /opt/%s. To uninstall it again, you can use:\n'
            '    %s' % (install_cmd, app_name, remove_cmd))
    else:
        raise FbsError('Unsupported OS')
    _LOG.info(' '.join(msg_parts))
Esempio n. 24
0
def generate_resources():
    """
    Copy the data files from src/main/resources to the target/ directory.
    Automatically filters files mentioned in the setting resources_to_filter:
    Placeholders such as ${app_name} are automatically replaced by the
    corresponding setting in files on that list.
    """
    freeze_dir = path('${freeze_dir}')
    if is_mac():
        resources_dest_dir = join(freeze_dir, 'Contents', 'Resources')
    else:
        resources_dest_dir = freeze_dir
    kwargs = {'files_to_filter': SETTINGS['resources_to_filter']}
    resource_dirs = [
        path('src/main/resources/' + profile) for profile in LOADED_PROFILES
    ]
    for dir_ in resource_dirs:
        if exists(dir_):
            copy_with_filtering(dir_, resources_dest_dir, **kwargs)
        frozen_resources_dir = dir_ + '-frozen'
        if exists(frozen_resources_dir):
            copy_with_filtering(frozen_resources_dir, freeze_dir, **kwargs)
Esempio n. 25
0
def installer():
    """
    Create an installer for your app
    """
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    elif is_linux():
        if is_ubuntu():
            from fbs.installer.ubuntu import create_installer_ubuntu
            create_installer_ubuntu()
        elif is_arch_linux():
            from fbs.installer.arch import create_installer_arch
            create_installer_arch()
        elif is_fedora():
            from fbs.installer.fedora import create_installer_fedora
            create_installer_fedora()
        else:
            raise RuntimeError('Unsupported Linux distribution')
    else:
        raise RuntimeError('Unsupported OS')
Esempio n. 26
0
    def populateSettings(self):
        self.cudaCbx.setChecked(self.parent.enableCuda)
        self.cudaCbx.setEnabled(False)

        self.stereoCbx.setChecked(self.parent.enableStereo)
        self.stereoCbx.setEnabled(False)

        self.bufferMult.setValue(self.parent.buffer_mult)

        if self.parent.tau == 75e-6:
            self.deemp75Rdio.setChecked(True)
        else:
            self.deemp50Rdio.setChecked(True)

        # Apply System Specific Settings
        if isCudaCapable():
            self.cudaCbx.setEnabled(True)
        else:
            print(
                "[SETTINGS] Can't find CUPY nor CUSIGNAL. Disabling CUDA support."
            )

        if is_mac():
            self.cudaCbx.setEnabled(False)  # macOS doesn't support CUDA ­Ъци
Esempio n. 27
0
def build():
    fbs.builtin_commands.freeze()
    if platform.is_mac():
        # Not tested on macOS Catalina, might not work
        fix_dark_mode()
Esempio n. 28
0
class MacApp(QApplication):
    def event(self, e: QEvent) -> bool:
        logger.info('event - Event of type %s detected.' % e.type())
        if e.type() == QEvent.FileOpen:
            file = e.file()
            logger.info('event - file path is %s' % file)
            if str(file).endswith('.pro6plx'):
                quickstart(file)
        return QApplication.event(appctxt.app, e)


if __name__ == '__main__':
    logger.info('open-pro6plx started.')

    if is_mac():
        logger.info('Using MacApplicationContext')
        appctxt = MacApplicationContext()
    else:
        logger.info('Using ApplicationContext')
        appctxt = ApplicationContext()

    window = MainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(window)
    enable_file_drag(ui.lineEdit)
    window.show()

    if is_windows():
        quickstart()
Esempio n. 29
0
def get_resource_dirs():
    app_dir = dirname(sys.executable)
    return [join(app_dir, pardir, 'Resources') if is_mac() else app_dir]
Esempio n. 30
0
    def drag_enter_event(event: QDragEnterEvent) -> None:
        data = event.mimeData()
        url = data.urls()[0]
        if url and url.isLocalFile() and url.fileName().endswith('.pdf'):
            event.acceptProposedAction()

    def drop_event(event: QDropEvent) -> None:
        data = event.mimeData()
        url = data.urls()[0]
        if url and url.isLocalFile() and url.fileName().endswith('.pdf'):
            line_edit.setText(url.toLocalFile())

    line_edit.dragEnterEvent = drag_enter_event
    line_edit.dropEvent = drop_event


if __name__ == '__main__':
    path_to_pdf = sys.argv[1] if len(sys.argv) > 1 else None
    poppler_path = '/usr/local/bin' if is_mac() else None

    appctxt = ApplicationContext()
    MainWindow = MainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    enable_file_drag(ui.lineEdit)
    if path_to_pdf and os.path.exists(path_to_pdf):
        MainWindow.set_path_to_pdf(path_to_pdf)
    MainWindow.show()
    sys.exit(appctxt.app.exec_())