6 """ |
6 """ |
7 Module implementing a window for showing the QtHelp index. |
7 Module implementing a window for showing the QtHelp index. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QEvent |
10 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QEvent |
|
11 from PyQt6.QtGui import QGuiApplication, QClipboard |
11 from PyQt6.QtHelp import QHelpLink |
12 from PyQt6.QtHelp import QHelpLink |
12 from PyQt6.QtWidgets import ( |
13 from PyQt6.QtWidgets import ( |
13 QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QMenu, QDialog, |
14 QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QMenu, QDialog, |
14 QApplication |
15 QApplication |
15 ) |
16 ) |
239 else: |
240 else: |
240 newTab = menu.addAction(self.tr("Open Link in New Tab")) |
241 newTab = menu.addAction(self.tr("Open Link in New Tab")) |
241 newBackgroundTab = menu.addAction( |
242 newBackgroundTab = menu.addAction( |
242 self.tr("Open Link in Background Tab")) |
243 self.tr("Open Link in Background Tab")) |
243 newWindow = menu.addAction(self.tr("Open Link in New Window")) |
244 newWindow = menu.addAction(self.tr("Open Link in New Window")) |
244 # TODO: add link to copy the URL |
245 menu.addSeparator() |
|
246 copyLink = menu.addAction(self.tr("Copy URL to Clipboard")) |
245 menu.move(self.__index.mapToGlobal(pos)) |
247 menu.move(self.__index.mapToGlobal(pos)) |
246 |
248 |
247 act = menu.exec() |
249 act = menu.exec() |
248 model = self.__index.model() |
250 model = self.__index.model() |
249 if model is not None: |
251 if model is not None: |
261 self.newTab.emit(link) |
263 self.newTab.emit(link) |
262 elif act == newBackgroundTab: |
264 elif act == newBackgroundTab: |
263 self.newBackgroundTab.emit(link) |
265 self.newBackgroundTab.emit(link) |
264 elif not self.__internal and act == newWindow: |
266 elif not self.__internal and act == newWindow: |
265 self.newWindow.emit(link) |
267 self.newWindow.emit(link) |
|
268 elif act == copyLink: |
|
269 # copy the URL to both clipboard areas |
|
270 QGuiApplication.clipboard().setText( |
|
271 link.toString(), QClipboard.Mode.Clipboard) |
|
272 QGuiApplication.clipboard().setText( |
|
273 link.toString(), QClipboard.Mode.Selection) |