14 from PyQt6.QtCore import QDir, pyqtSlot |
14 from PyQt6.QtCore import QDir, pyqtSlot |
15 from PyQt6.QtWidgets import QDialog |
15 from PyQt6.QtWidgets import QDialog |
16 |
16 |
17 from eric7.EricGui import EricPixmapCache |
17 from eric7.EricGui import EricPixmapCache |
18 from eric7.UI.NotificationWidget import NotificationTypes |
18 from eric7.UI.NotificationWidget import NotificationTypes |
|
19 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
19 |
20 |
20 from .Ui_GreaseMonkeyAddScriptDialog import Ui_GreaseMonkeyAddScriptDialog |
21 from .Ui_GreaseMonkeyAddScriptDialog import Ui_GreaseMonkeyAddScriptDialog |
21 |
22 |
22 |
23 |
23 class GreaseMonkeyAddScriptDialog(QDialog, Ui_GreaseMonkeyAddScriptDialog): |
24 class GreaseMonkeyAddScriptDialog(QDialog, Ui_GreaseMonkeyAddScriptDialog): |
68 @pyqtSlot() |
69 @pyqtSlot() |
69 def on_showScriptSourceButton_clicked(self): |
70 def on_showScriptSourceButton_clicked(self): |
70 """ |
71 """ |
71 Private slot to show an editor window with the source code. |
72 Private slot to show an editor window with the source code. |
72 """ |
73 """ |
|
74 from eric7.QScintilla.MiniEditor import MiniEditor |
73 from eric7.WebBrowser.Tools import WebBrowserTools |
75 from eric7.WebBrowser.Tools import WebBrowserTools |
74 |
76 |
75 tmpFileName = WebBrowserTools.ensureUniqueFilename( |
77 tmpFileName = WebBrowserTools.ensureUniqueFilename( |
76 os.path.join(QDir.tempPath(), "tmp-userscript.js") |
78 os.path.join(QDir.tempPath(), "tmp-userscript.js") |
77 ) |
79 ) |
78 if shutil.copy(self.__script.fileName(), tmpFileName): |
80 if shutil.copy(self.__script.fileName(), tmpFileName): |
79 from eric7.QScintilla.MiniEditor import MiniEditor |
|
80 |
|
81 editor = MiniEditor(tmpFileName, "JavaScript", self) |
81 editor = MiniEditor(tmpFileName, "JavaScript", self) |
82 editor.show() |
82 editor.show() |
83 |
83 |
84 def __accepted(self): |
84 def __accepted(self): |
85 """ |
85 """ |
92 success = True |
92 success = True |
93 else: |
93 else: |
94 msg = self.tr("<p>Cannot install script.</p>") |
94 msg = self.tr("<p>Cannot install script.</p>") |
95 success = False |
95 success = False |
96 |
96 |
97 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
98 |
|
99 if success: |
97 if success: |
100 WebBrowserWindow.showNotification( |
98 WebBrowserWindow.showNotification( |
101 EricPixmapCache.getPixmap("greaseMonkey48"), |
99 EricPixmapCache.getPixmap("greaseMonkey48"), |
102 self.tr("GreaseMonkey Script Installation"), |
100 self.tr("GreaseMonkey Script Installation"), |
103 msg, |
101 msg, |