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