Made URl clickable in TagImportDialog

Made the predicted url in TagImportDialog clickable and open the url in a browser with QDesktopServices.
Also fixed the source url in window.py to use QDesktopServices
dev
Peery 3 years ago
parent aed0def559
commit af671102d5

@ -1,6 +1,6 @@
from PyQt5 import QtWidgets
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QStandardItemModel, QStandardItem, QDesktopServices
from PyQt5.QtCore import Qt, QUrl
from ArtNet.gui.dialogs.tag_import_dialog.tag_import_dialog import Ui_Dialog
@ -14,6 +14,7 @@ class TagImportDialog(QtWidgets.QDialog):
self.ui.setupUi(self)
self.ui.import_all_button.clicked.connect(self.on_import_all_clicked)
self.ui.remove_all_button.clicked.connect(self.on_remove_all_clicked)
self.ui.used_link_label.linkActivated.connect(self.on_used_link_activated)
self.to_import = []
self.not_import = []
@ -61,7 +62,8 @@ class TagImportDialog(QtWidgets.QDialog):
:param link:
:return:
"""
self.ui.used_link_label.setText(link)
hyperlink = "<a href=\"{0}\">{1}</a>".format(link, link)
self.ui.used_link_label.setText(hyperlink)
def set_ignore_tag_list(self, tags: list):
"""
@ -116,6 +118,10 @@ class TagImportDialog(QtWidgets.QDialog):
self.set_import_tag_list(self.to_import)
self.set_ignore_tag_list(self.not_import)
def on_used_link_activated(self, link):
print("Predicted link activated:", link)
QDesktopServices.openUrl(QUrl(link))
def exec_(self) -> int:
if super(TagImportDialog, self).exec_() == QtWidgets.QDialog.Rejected:
return None

@ -2,7 +2,7 @@ import validators, os
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, QSize, QUrl
from PyQt5.QtGui import QPixmap, QResizeEvent, QKeyEvent, QStandardItemModel, QStandardItem, QMovie
from PyQt5.QtGui import QPixmap, QResizeEvent, QKeyEvent, QStandardItemModel, QStandardItem, QMovie, QDesktopServices
from PyQt5 import QtMultimedia
from PyQt5.QtMultimediaWidgets import QVideoWidget
@ -72,6 +72,7 @@ class Window(QtWidgets.QMainWindow):
self.ui.prev_unknown_image_button.clicked.connect(self.on_prev_unknown_image_clicked)
self.ui.next_unknown_image_button.clicked.connect(self.on_next_unknown_image_clicked)
self.ui.delete_button.clicked.connect(self.on_delete_image_clicked)
self.ui.link_label.linkActivated.connect(self.on_link_label_activated)
self.ui.presence_docker_button.clicked.connect(self.toggle_presence_docker)
@ -746,7 +747,7 @@ class Window(QtWidgets.QMainWindow):
self.set_tag_list(self.curr_tags)
return
self.__main.import_tags(self.curr_art_id, result)
self.__main.import_tags(result)
self.set_tag_list(self.curr_tags)
def on_next_clicked(self):
@ -1041,3 +1042,7 @@ class Window(QtWidgets.QMainWindow):
return
self.__main.refresh_shown_image()
def on_link_label_activated(self, link: str):
print("Source link activated!", link)
QDesktopServices.openUrl(QUrl(link))
Loading…
Cancel
Save