14 from PyQt4.QtGui import QDialog |
14 from PyQt4.QtGui import QDialog |
15 |
15 |
16 from E5Gui import E5MessageBox |
16 from E5Gui import E5MessageBox |
17 |
17 |
18 from .Ui_GreaseMonkeyAddScriptDialog import Ui_GreaseMonkeyAddScriptDialog |
18 from .Ui_GreaseMonkeyAddScriptDialog import Ui_GreaseMonkeyAddScriptDialog |
19 |
|
20 from QScintilla.MiniEditor import MiniEditor |
|
21 |
|
22 from Helpviewer import HelpUtilities |
|
23 import Helpviewer.HelpWindow |
|
24 |
19 |
25 import UI.PixmapCache |
20 import UI.PixmapCache |
26 |
21 |
27 |
22 |
28 class GreaseMonkeyAddScriptDialog(QDialog, Ui_GreaseMonkeyAddScriptDialog): |
23 class GreaseMonkeyAddScriptDialog(QDialog, Ui_GreaseMonkeyAddScriptDialog): |
68 @pyqtSlot() |
63 @pyqtSlot() |
69 def on_showScriptSourceButton_clicked(self): |
64 def on_showScriptSourceButton_clicked(self): |
70 """ |
65 """ |
71 Private slot to show an editor window with the source code. |
66 Private slot to show an editor window with the source code. |
72 """ |
67 """ |
|
68 from Helpviewer import HelpUtilities |
|
69 |
73 tmpFileName = HelpUtilities.ensureUniqueFilename( |
70 tmpFileName = HelpUtilities.ensureUniqueFilename( |
74 os.path.join(QDir.tempPath(), "tmp-userscript.js")) |
71 os.path.join(QDir.tempPath(), "tmp-userscript.js")) |
75 if QFile.copy(self.__script.fileName(), tmpFileName): |
72 if QFile.copy(self.__script.fileName(), tmpFileName): |
|
73 from QScintilla.MiniEditor import MiniEditor |
76 editor = MiniEditor(tmpFileName, "JavaScript", self) |
74 editor = MiniEditor(tmpFileName, "JavaScript", self) |
77 editor.show() |
75 editor.show() |
78 |
76 |
79 def __accepted(self): |
77 def __accepted(self): |
80 """ |
78 """ |
86 success = True |
84 success = True |
87 else: |
85 else: |
88 msg = self.trUtf8("<p>Cannot install script.</p>") |
86 msg = self.trUtf8("<p>Cannot install script.</p>") |
89 success = False |
87 success = False |
90 |
88 |
|
89 import Helpviewer.HelpWindow |
91 if success and Helpviewer.HelpWindow.HelpWindow.notificationsEnabled(): |
90 if success and Helpviewer.HelpWindow.HelpWindow.notificationsEnabled(): |
92 Helpviewer.HelpWindow.HelpWindow.showNotification( |
91 Helpviewer.HelpWindow.HelpWindow.showNotification( |
93 UI.PixmapCache.getPixmap("greaseMonkey48.png"), |
92 UI.PixmapCache.getPixmap("greaseMonkey48.png"), |
94 self.trUtf8("GreaseMonkey Script Installation"), |
93 self.trUtf8("GreaseMonkey Script Installation"), |
95 msg) |
94 msg) |