Пример #1
0
import sys

from PySide6.QtWidgets import QApplication, QMessageBox, QSystemTrayIcon

from window import Window
from libmanager import APP_NAME

if __name__ == "__main__":
    app = QApplication()

    if not QSystemTrayIcon.isSystemTrayAvailable():
        QMessageBox.critical(None, APP_NAME, "Cannot detect any system tray on system")
        sys.exit(1)

    QApplication.setQuitOnLastWindowClosed(False)

    window = Window()
    window.show()
    sys.exit(app.exec_())
Пример #2
0
    def __init__(self) -> None:
        super().__init__()

        # self.load_ui()  # Broken
        # Use pyside-uic form.ui > gui.py to generate the UI instead
        self.setupUi(self)

        # Hide ASAP to avoid window flash
        self.about_widget.setHidden(True)
        self.plugins_widget.setHidden(True)
        self.config_widget.setHidden(True)
        self.log_widget.setHidden(True)

        h = LogHandler(self.append_log)
        fs = '%(levelname)-8s %(message)s'
        formatter = logging.Formatter(fs)
        h.setFormatter(formatter)
        logging.getLogger().addHandler(h)

        self.ICON = QIcon('images/icon.png')

        self.WHEEL_MAP = {
            -7: self.wheel_neg7,
            -6: self.wheel_neg6,
            -5: self.wheel_neg5,
            -4: self.wheel_neg4,
            -3: self.wheel_neg3,
            -2: self.wheel_neg2,
            -1: self.wheel_neg1,
            0: self.wheel_cent0,
            1: self.wheel_pos1,
            2: self.wheel_pos2,
            3: self.wheel_pos3,
            4: self.wheel_pos4,
            5: self.wheel_pos5,
            6: self.wheel_pos6,
            7: self.wheel_pos7,
        }
        self.BUTTON_MAP = [None, self.button_1, self.button_2, self.button_3, self.button_4, self.button_5]

        self.setWindowIcon(self.ICON)
        self.setWindowTitle(self.TITLE)
        #self.set_ms_windows_icon()
        extra = {
            # Button colors
            'danger': '#dc3545',
            'warning': '#ffc107',
            'success': '#17a2b8',

            # Font
            'font_family': 'Roboto',
        }
        self.apply_stylesheet(self, theme='dark_red.xml', extra=extra)

        # self.setWindowFlags(self.windowFlags() | Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)
        # self.statusbar.setSizeGripEnabled(False)

        self.update_status_bar("Connecting...")

        self.show()

        if QSystemTrayIcon.isSystemTrayAvailable():
            self.systray = QSystemTrayIcon()
            self.systray.setIcon(self.ICON)
            systray_menu = QMenu(title=self.TITLE, parent=self)
            quit_action = QAction("&Quit", self)
            systray_menu.addAction(quit_action)
            quit_action.triggered.connect(self.close)
            self.systray.setContextMenu(systray_menu)
            self.systray.setVisible(True)
            self.systray.activated.connect(self.handle_systray_activation)

        shuttle_signals.data.connect(self.handle_events)
        self.shuttle_worker = ShuttleWorker()
        self.shuttle_worker.start()
        self.shuttle_worker.finished.connect(self.shuttle_worker.quit)

        self.about_text.setMarkdown(f"""
Contour ShuttleXpress
=====================

A multiplatform userland driver, configuration editor, event manager & generator for Contour ShuttleXpress.

Version: `{__version__}`

Source: `{__repo__}`

Running on Python v{python_version()}

Legal notice
------------

### License

Copyright 2021-2022 Raphaël Doursenaud

This software is released under the terms of the GNU General Public License, version 3.0 or later (GPL-3.0-or-later).

### Dependencies & License Acknowledgment

**Python**

Used under the terms of the PSF License Agreement.

**libusb hidapi**

Copyright Alan Ott, Signal 11 Software.  
Used under the terms of the GNU General Public License, version 3.0 (GPL-3.0).

**Trezor cython-hidapi**  

Copyright Pavol Rusnak, SatoshiLabs.  
Used under the terms of the GNU General Public License, version 3.0 (GPL-3.0).

**Qt PySide6**

Used under the terms of the GNU Lesser General Public License v3.0 (LGPL-3.0).

**UN-GCPDS Qt-Material**

Used under the BSD-2-Clause License.

**Material Design Icons**

Used under the Pictogrammers Free License.

### Trademarks

Contour, ShuttleXpress and ShuttlePro are trademarks of Contour Innovations LLC in the United States of America.

These are not registered or active trademarks in the European Union and France where I reside.
""")
        self.about_button.clicked.connect(self.toggle_about_vis)
        self.plug_button.clicked.connect(self.toggle_plugins_vis)
        self.conf_button.clicked.connect(self.toggle_config_vis)
        self.log_button.clicked.connect(self.toggle_log_vis)
        self.log_clear_button.clicked.connect(self.clear_log)