Beispiel #1
0
    def about(self):
        """Called by the about action.
        """

        from PySide2 import __version__ as pyside2_version

        QMessageBox.about(
            self, "About IDF+", """<b>IDF+</b> v{0}
                <p>This is an enhanced editor for EnergyPlus simulation input files.
                For more information please see
                <a href="https://github.com/mattdoiron/idfplus/">
                https://github.com/mattdoiron/idfplus/
                </a></p>
                <p>Copyright &copy; 2014-2017 Matt Doiron ([email protected]).
                All rights reserved.</p>
                <p>IDF+ is free software: you can redistribute it and/or modify
                it under the terms of the GNU General Public License as published by
                the Free Software Foundation, either version 3 of the License, or
                (at your option) any later version.</p>
                <p>IDF+ is distributed in the hope that it will be useful,
                but WITHOUT ANY WARRANTY; without even the implied warranty of
                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
                GNU General Public License at <a href="http://www.gnu.org/licenses/">
                http://www.gnu.org/licenses/</a> for more details.</p>
                <p>Built with: Python {1}, Qt {2} and PySide {3} on {4}</p>""".
            format(__version__, platform.python_version(), qVersion(),
                   pyside2_version, platform.system()))
    def paintEvent(self, event):
        rect = QRect(10, 20, 80, 60)

        path = QPainterPath()
        path.moveTo(20, 80)
        path.lineTo(20, 30)
        path.cubicTo(80, 0, 50, 50, 80, 80)

        startAngle = 30 * 16
        arcLength = 120 * 16

        painter = QPainter(self)
        painter.setPen(self.pen)
        painter.setBrush(self.brush)
        if self.antialiased:
            painter.setRenderHint(QPainter.Antialiasing)

        for x in range(0, self.width(), 100):
            for y in range(0, self.height(), 100):
                painter.save()
                painter.translate(x, y)
                if self.transformed:
                    painter.translate(50, 50)
                    painter.rotate(60.0)
                    painter.scale(0.6, 0.9)
                    painter.translate(-50, -50)

                if self.shape == RenderArea.Line:
                    painter.drawLine(rect.bottomLeft(), rect.topRight())
                elif self.shape == RenderArea.Points:
                    painter.drawPoints(RenderArea.points)
                elif self.shape == RenderArea.Polyline:
                    painter.drawPolyline(RenderArea.points)
                elif self.shape == RenderArea.Polygon:
                    painter.drawPolygon(RenderArea.points)
                elif self.shape == RenderArea.Rect:
                    painter.drawRect(rect)
                elif self.shape == RenderArea.RoundedRect:
                    painter.drawRoundedRect(rect, 25, 25, Qt.RelativeSize)
                elif self.shape == RenderArea.Ellipse:
                    painter.drawEllipse(rect)
                elif self.shape == RenderArea.Arc:
                    painter.drawArc(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Chord:
                    painter.drawChord(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Pie:
                    painter.drawPie(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Path:
                    painter.drawPath(path)
                elif self.shape == RenderArea.Text:
                    painter.drawText(rect, Qt.AlignCenter,
                                     "PySide 2\nQt %s" % qVersion())
                elif self.shape == RenderArea.Pixmap:
                    painter.drawPixmap(10, 10, self.pixmap)

                painter.restore()

        painter.setPen(self.palette().dark().color())
        painter.setBrush(Qt.NoBrush)
        painter.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1))
Beispiel #3
0
    def paintEvent(self, event):
        rect = QRect(10, 20, 80, 60)

        path = QPainterPath()
        path.moveTo(20, 80)
        path.lineTo(20, 30)
        path.cubicTo(80, 0, 50, 50, 80, 80)

        startAngle = 30 * 16
        arcLength = 120 * 16

        painter = QPainter(self)
        painter.setPen(self.pen)
        painter.setBrush(self.brush)
        if self.antialiased:
            painter.setRenderHint(QPainter.Antialiasing)

        for x in range(0, self.width(), 100):
            for y in range(0, self.height(), 100):
                painter.save()
                painter.translate(x, y)
                if self.transformed:
                    painter.translate(50, 50)
                    painter.rotate(60.0)
                    painter.scale(0.6, 0.9)
                    painter.translate(-50, -50)

                if self.shape == RenderArea.Line:
                    painter.drawLine(rect.bottomLeft(), rect.topRight())
                elif self.shape == RenderArea.Points:
                    painter.drawPoints(RenderArea.points)
                elif self.shape == RenderArea.Polyline:
                    painter.drawPolyline(RenderArea.points)
                elif self.shape == RenderArea.Polygon:
                    painter.drawPolygon(RenderArea.points)
                elif self.shape == RenderArea.Rect:
                    painter.drawRect(rect)
                elif self.shape == RenderArea.RoundedRect:
                    painter.drawRoundedRect(rect, 25, 25, Qt.RelativeSize)
                elif self.shape == RenderArea.Ellipse:
                    painter.drawEllipse(rect)
                elif self.shape == RenderArea.Arc:
                    painter.drawArc(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Chord:
                    painter.drawChord(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Pie:
                    painter.drawPie(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Path:
                    painter.drawPath(path)
                elif self.shape == RenderArea.Text:
                    painter.drawText(rect, Qt.AlignCenter,
                                     "PySide 2\nQt %s" % qVersion())
                elif self.shape == RenderArea.Pixmap:
                    painter.drawPixmap(10, 10, self.pixmap)

                painter.restore()

        painter.setPen(self.palette().dark().color())
        painter.setBrush(Qt.NoBrush)
        painter.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1))
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_AboutWidget()
        self.ui.setupUi(self)

        self.ui.version.setText(app.__version__)
        self.ui.qtVersion.setText(qVersion())

        self.ui.builtWithQtBtn.clicked.connect(qApp.aboutQt)
def launch_qt_gui(bk, prefs):
    supports_theming = (bk.launcher_version() >= 20200117)
    if not ismacos:
        setup_highdpi(bk._w.highdpi)
    setup_ui_font(bk._w.uifont)
    if not ismacos and not iswindows:
        # Qt 5.10.1 on Linux resets the global font on first event loop tick.
        # So workaround it by setting the font once again in a timer.
        QTimer.singleShot(0, lambda: setup_ui_font(bk._w.uifont))

    app = QApplication(sys.argv)
    icon = os.path.join(bk._w.plugin_dir, bk._w.plugin_name, 'plugin.svg')
    app.setWindowIcon(QIcon(icon))

    if tuple_version(qVersion()) >= (5, 10, 0):
        app.setAttribute(Qt.AA_DisableWindowContextHelpButton)

    # Make plugin match Sigil's light/dark theme
    if supports_theming:
        if bk.colorMode() == "dark":
            app.setStyle(QStyleFactory.create("Fusion"))
            app.setPalette(dark_palette(bk.color))

    print('Application dir: {}'.format(QCoreApplication.applicationDirPath()))
    # Install qtbase translator for standard dialogs and such.
    # Use the Sigil language setting unless manually overridden.
    qt_translator = QTranslator()
    if prefs['language_override'] is not None:
        print('Plugin preferences language override in effect')
        qmf = 'qtbase_{}'.format(prefs['language_override'])
    else:
        qmf = 'qtbase_{}'.format(bk.sigil_ui_lang)
    # Get bundled or external translations directory
    qt_trans_dir = getQtTranslationsPath(bk._w.appdir)
    print('Qt translation dir: {}'.format(qt_trans_dir))
    print('Looking for {} in {}'.format(qmf, qt_trans_dir))
    qt_translator.load(qmf, qt_trans_dir)
    print('Translator succesfully installed: {}'.format(
        app.installTranslator(qt_translator)))

    ex = App(bk, prefs)
    ex.show()
    app.exec_()
    return _DETAILS
Beispiel #6
0
from PySide2 import __version__
from PySide2.QtCore import qVersion
from shiboken2 import __version__ as _shiboken_ver

# application settings
BETA = True
VERSION = "0.1.55"
APP_NAME_SHORT = 'VocabMate'
APP_NAME_VERBOSE = 'Vocabulary Mate'
_stdout_handler = logging.StreamHandler(sys.stdout)
if os.environ.get('DEBUG'):
    _file_handler = logging.FileHandler(filename='logging.log')
    LOGGING_HANDLERS = [_file_handler, _stdout_handler]
else:
    LOGGING_HANDLERS = [
        _stdout_handler,
    ]
# Qt versions
PYSIDE_VERSION = __version__
QT_VERSION = qVersion()
SHIBOKEN_VERSION = _shiboken_ver
# project repository
PROJECT_URL = "https://github.com/upday7/VocabMate"
PROJECT_ISSUE_URL = PROJECT_URL + "/issues"

# variables
CACHE_DIR = Path(tempfile.gettempdir(), '_vocab_tmp')
SESSION_CACHE_DIR = Path(tempfile.gettempdir(), '_vocab_tmp', 'secret')
TEST_CACHE_DIR = Path(tempfile.gettempdir(), '_vocab_tmp', 'secret')
def launch_gui(bk, prefs):
    if not ismacos:
        try:
            setup_highdpi(bk._w.highdpi)
        except Exception:
            pass
    try:
        setup_ui_font(bk._w.uifont)
    except Exception:
        pass
    if not ismacos and not iswindows:
        # Qt 5.10.1 on Linux resets the global font on first event loop tick.
        # So workaround it by setting the font once again in a timer.
        try:
            QTimer.singleShot(0, lambda: setup_ui_font(bk._w.uifont))
        except Exception:
            pass
    app = QApplication([])
    icon = os.path.join(bk._w.plugin_dir, bk._w.plugin_name, 'plugin.svg')
    app.setWindowIcon(QIcon(icon))

    if tuple_version(qVersion()) >= (5, 10, 0):
        app.setAttribute(Qt.AA_DisableWindowContextHelpButton)

    # Make plugin match Sigil's light/dark theme
    dark_palette(bk, app)

    print('Application dir: {}'.format(QCoreApplication.applicationDirPath()))
    # Install qtbase translator for standard dialogs and such.
    # Use the Sigil language setting unless manually overridden.
    qt_translator = QTranslator()
    misc_prefs = prefs['miscellaneous_settings']
    if misc_prefs['language_override'] is not None:
        print('Plugin preferences language override in effect')
        qmf = 'qtbase_{}'.format(misc_prefs['language_override'])
    else:
        qmf = 'qtbase_{}'.format(bk.sigil_ui_lang)
    # Get bundled or external translations directory
    qt_trans_dir = getQtTranslationsPath(bk._w.appdir)
    print('Qt translation dir: {}'.format(qt_trans_dir))
    print('Looking for {} in {}'.format(qmf, qt_trans_dir))
    qt_translator.load(qmf, qt_trans_dir)
    print('Qt Base Translator succesfully installed: {}'.format(
        app.installTranslator(qt_translator)))

    # Install translator for the tagmechanic plugin dialog.
    # Use the Sigil language setting unless manually overridden.
    plugin_translator = QTranslator()
    if misc_prefs['language_override'] is not None:
        print('Plugin preferences language override in effect')
        qmf = '{}_{}'.format(bk._w.plugin_name.lower(),
                             misc_prefs['language_override'])
    else:
        qmf = '{}_{}'.format(bk._w.plugin_name.lower(), bk.sigil_ui_lang)
    print('Looking for {} in {}'.format(
        qmf, os.path.join(bk._w.plugin_dir, bk._w.plugin_name,
                          'translations')))
    plugin_translator.load(
        qmf, os.path.join(bk._w.plugin_dir, bk._w.plugin_name, 'translations'))
    print('Plugin Translator succesfully installed: {}'.format(
        app.installTranslator(plugin_translator)))

    win = guiMain(bk, prefs)
    app.exec_()
    return win.getAbort()
Beispiel #8
0
def help_url(page):
    """Build a Qt help URL from the page name"""
    major_version = qVersion().split('.')[0]
    return "https://doc.qt.io/qt-{}/{}.html".format(major_version, page)
Beispiel #9
0
    def __init__(self):
        super(WidgetGallery, self).__init__()

        self._progress_bar = self.create_progress_bar()

        self._style_combobox = QComboBox()
        init_widget(self._style_combobox, "styleComboBox")
        self._style_combobox.addItems(style_names())

        style_label = QLabel("Style:")
        init_widget(style_label, "style_label")
        style_label.setBuddy(self._style_combobox)

        help_label = QLabel("Press F1 over a widget to see Documentation")
        init_widget(help_label, "help_label")

        disable_widgets_checkbox = QCheckBox("Disable widgets")
        init_widget(disable_widgets_checkbox, "disable_widgets_checkbox")

        buttons_groupbox = self.create_buttons_groupbox()
        itemview_tabwidget = self.create_itemview_tabwidget()
        simple_input_widgets_groupbox = self.create_simple_inputwidgets_groupbox(
        )
        text_toolbox = self.create_text_toolbox()

        self._style_combobox.textActivated.connect(self.change_style)
        disable_widgets_checkbox.toggled.connect(buttons_groupbox.setDisabled)
        disable_widgets_checkbox.toggled.connect(text_toolbox.setDisabled)
        disable_widgets_checkbox.toggled.connect(
            itemview_tabwidget.setDisabled)
        disable_widgets_checkbox.toggled.connect(
            simple_input_widgets_groupbox.setDisabled)

        help_shortcut = QShortcut(self)
        help_shortcut.setKey(QKeySequence.HelpContents)
        help_shortcut.activated.connect(self.help_on_current_widget)

        top_layout = QHBoxLayout()
        top_layout.addWidget(style_label)
        top_layout.addWidget(self._style_combobox)
        top_layout.addStretch(1)
        top_layout.addWidget(help_label)
        top_layout.addStretch(1)
        top_layout.addWidget(disable_widgets_checkbox)

        dialog_buttonbox = QDialogButtonBox(QDialogButtonBox.Help
                                            | QDialogButtonBox.Close)
        init_widget(dialog_buttonbox, "dialogButtonBox")
        dialog_buttonbox.helpRequested.connect(launch_module_help)
        dialog_buttonbox.rejected.connect(self.reject)

        main_layout = QGridLayout(self)
        main_layout.addLayout(top_layout, 0, 0, 1, 2)
        main_layout.addWidget(buttons_groupbox, 1, 0)
        main_layout.addWidget(simple_input_widgets_groupbox, 1, 1)
        main_layout.addWidget(itemview_tabwidget, 2, 0)
        main_layout.addWidget(text_toolbox, 2, 1)
        main_layout.addWidget(self._progress_bar, 3, 0, 1, 2)
        main_layout.addWidget(dialog_buttonbox, 4, 0, 1, 2)

        self.setWindowTitle("Widget Gallery Qt {}".format(qVersion()))