|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to show GreaseMonkey script information. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtWidgets import QDialog |
|
12 |
|
13 from .Ui_GreaseMonkeyConfigurationScriptInfoDialog import ( |
|
14 Ui_GreaseMonkeyConfigurationScriptInfoDialog |
|
15 ) |
|
16 |
|
17 from ..GreaseMonkeyScript import GreaseMonkeyScript |
|
18 |
|
19 import UI.PixmapCache |
|
20 |
|
21 |
|
22 class GreaseMonkeyConfigurationScriptInfoDialog( |
|
23 QDialog, Ui_GreaseMonkeyConfigurationScriptInfoDialog): |
|
24 """ |
|
25 Class implementing a dialog to show GreaseMonkey script information. |
|
26 """ |
|
27 def __init__(self, script, parent=None): |
|
28 """ |
|
29 Constructor |
|
30 |
|
31 @param script reference to the script (GreaseMonkeyScript) |
|
32 @param parent reference to the parent widget (QWidget) |
|
33 """ |
|
34 super().__init__(parent) |
|
35 self.setupUi(self) |
|
36 |
|
37 self.iconLabel.setPixmap( |
|
38 UI.PixmapCache.getPixmap("greaseMonkey48")) |
|
39 |
|
40 self.__scriptFileName = script.fileName() |
|
41 |
|
42 self.setWindowTitle( |
|
43 self.tr("Script Details of {0}").format(script.name())) |
|
44 |
|
45 self.nameLabel.setText(script.fullName()) |
|
46 self.versionLabel.setText(script.version()) |
|
47 self.urlLabel.setText(script.downloadUrl().toString()) |
|
48 if script.startAt() == GreaseMonkeyScript.DocumentStart: |
|
49 self.startAtLabel.setText("document-start") |
|
50 else: |
|
51 self.startAtLabel.setText("document-end") |
|
52 self.descriptionBrowser.setHtml(script.description()) |
|
53 self.runsAtBrowser.setHtml("<br/>".join(script.include())) |
|
54 self.doesNotRunAtBrowser.setHtml("<br/>".join(script.exclude())) |
|
55 |
|
56 @pyqtSlot() |
|
57 def on_showScriptSourceButton_clicked(self): |
|
58 """ |
|
59 Private slot to show an editor window with the script source code. |
|
60 """ |
|
61 from QScintilla.MiniEditor import MiniEditor |
|
62 editor = MiniEditor(self.__scriptFileName, "JavaScript", self) |
|
63 editor.show() |