src/eric7/WebBrowser/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationScriptInfoDialog.py

Tue, 18 Oct 2022 16:06:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 18 Oct 2022 16:06:21 +0200
branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
permissions
-rw-r--r--

Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.

# -*- coding: utf-8 -*-

# Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to show GreaseMonkey script information.
"""

from PyQt6.QtCore import pyqtSlot
from PyQt6.QtWidgets import QDialog

from .Ui_GreaseMonkeyConfigurationScriptInfoDialog import (
    Ui_GreaseMonkeyConfigurationScriptInfoDialog,
)

from ..GreaseMonkeyScript import GreaseMonkeyScript

from eric7.EricGui import EricPixmapCache


class GreaseMonkeyConfigurationScriptInfoDialog(
    QDialog, Ui_GreaseMonkeyConfigurationScriptInfoDialog
):
    """
    Class implementing a dialog to show GreaseMonkey script information.
    """

    def __init__(self, script, parent=None):
        """
        Constructor

        @param script reference to the script (GreaseMonkeyScript)
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)

        self.iconLabel.setPixmap(EricPixmapCache.getPixmap("greaseMonkey48"))

        self.__scriptFileName = script.fileName()

        self.setWindowTitle(self.tr("Script Details of {0}").format(script.name()))

        self.nameLabel.setText(script.fullName())
        self.versionLabel.setText(script.version())
        self.urlLabel.setText(script.downloadUrl().toString())
        if script.startAt() == GreaseMonkeyScript.DocumentStart:
            self.startAtLabel.setText("document-start")
        else:
            self.startAtLabel.setText("document-end")
        self.descriptionBrowser.setHtml(script.description())
        self.runsAtBrowser.setHtml("<br/>".join(script.include()))
        self.doesNotRunAtBrowser.setHtml("<br/>".join(script.exclude()))

    @pyqtSlot()
    def on_showScriptSourceButton_clicked(self):
        """
        Private slot to show an editor window with the script source code.
        """
        from eric7.QScintilla.MiniEditor import MiniEditor

        editor = MiniEditor(self.__scriptFileName, "JavaScript", self)
        editor.show()

eric ide

mercurial