You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.8 KiB
Python
133 lines
4.8 KiB
Python
import logging
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
from ArtNet.gui.windows.browser.picture_browser import Ui_MainWindow
|
|
from ArtNet.gui.windows.artnet_mainwindow import ArtnetMainWindow
|
|
|
|
from ArtNet.gui.dialogs.image_info_dialog.image_dialog import ArtInfoDialog
|
|
|
|
|
|
class BrowseWindow(ArtnetMainWindow):
|
|
|
|
UNKNOWN_TITLE = "-Title Unknown-"
|
|
UNKNOWN_PRESENCE = "(Not in Database)"
|
|
|
|
def __init__(self, main):
|
|
super().__init__(main)
|
|
|
|
self.ui = Ui_MainWindow()
|
|
self.ui.setupUi(self)
|
|
|
|
self.__showing_search_param_frame: bool = True
|
|
self.__showing_detail_frame: bool = True
|
|
|
|
self.curr_art_id: int = None
|
|
self.curr_image_title: str = None
|
|
self.curr_link: str = None
|
|
self.curr_art_path: str = None
|
|
self.curr_file_name: str = None
|
|
self.curr_presences: list = list()
|
|
self.curr_tags: list = list()
|
|
self.curr_imply_tags: list = list()
|
|
self.curr_tag_aliases: list = list()
|
|
|
|
# callbacks
|
|
# action
|
|
self.ui.actionArtNet_Importer.triggered.connect(self.on_importer_clicked)
|
|
# buttons
|
|
self.ui.toggle_search_frame_button.clicked.connect(self.on_toggle_search_frame_clicked)
|
|
self.ui.toggle_detail_frame_button.clicked.connect(self.on_toggle_detail_frame_clicked)
|
|
self.ui.image_info_button.clicked.connect(self.on_image_info_clicked)
|
|
|
|
def display_image(self, image_title: str, image_authors: list, full_path: str, relative_path: str, art_ID: int,
|
|
link: str, file_name: str, description: str):
|
|
"""
|
|
Display the described image in the GraphicsView
|
|
"""
|
|
logging.debug(f"Asked browser to display image ID:\"{art_ID}\", title:\"{image_title}\", path:\"{full_path}\"")
|
|
self.set_presences(image_authors)
|
|
|
|
def set_tag_list(self, tags: list, set_checked: bool = True, no_implication: bool = False):
|
|
pass # TODO to implement
|
|
|
|
def set_presences(self, presences: list):
|
|
"""
|
|
Set the presences for this window
|
|
"""
|
|
if len(presences) > 1:
|
|
for name, domain in presences:
|
|
if domain == BrowseWindow.UNKNOWN_PRESENCE:
|
|
presences.remove((name, domain))
|
|
elif len(presences) == 0:
|
|
presences = [(self.curr_art_path.split("/")[0], BrowseWindow.UNKNOWN_PRESENCE)]
|
|
self.curr_presences = presences
|
|
|
|
self.data_changed = True
|
|
|
|
def convert_presences_to_text(self, presences: list) -> str:
|
|
"""
|
|
Prepares the presence variable to be printed as a label.
|
|
"""
|
|
s = ""
|
|
for name, domain in presences:
|
|
full_data = self.get_presence(name, domain)
|
|
if full_data is None:
|
|
link = ""
|
|
else:
|
|
name, domain, _, link = full_data[0]
|
|
text = name + ":" + domain
|
|
if link is None or len(link) == 0: # no link, then just do plain text
|
|
hyperlink = text
|
|
else:
|
|
hyperlink = "<a href=\"{0}\">{1}</a>".format(link, text)
|
|
|
|
s += hyperlink
|
|
s += "|"
|
|
|
|
s = s[:-1]
|
|
return s
|
|
|
|
# callback methods
|
|
|
|
def on_importer_clicked(self):
|
|
logging.debug("Clicked on open ArtNet importer!")
|
|
self.main.switch_to_importer()
|
|
|
|
def on_toggle_search_frame_clicked(self):
|
|
logging.debug("Clicked on button to toggle the search frame!")
|
|
|
|
if self.__showing_search_param_frame:
|
|
logging.debug("Hiding search param frame")
|
|
self.ui.search_param_frame.hide()
|
|
self.__showing_search_param_frame = False
|
|
self.ui.toggle_search_frame_button.setArrowType(Qt.RightArrow)
|
|
else:
|
|
logging.debug("Showing search param frame")
|
|
self.ui.search_param_frame.show()
|
|
self.__showing_search_param_frame = True
|
|
self.ui.toggle_search_frame_button.setArrowType(Qt.LeftArrow)
|
|
|
|
def on_toggle_detail_frame_clicked(self):
|
|
logging.debug("Clicked on button to toggle the detail frame!")
|
|
|
|
if self.__showing_detail_frame:
|
|
logging.debug("Hiding detail frame")
|
|
self.ui.bottom_frame.hide()
|
|
self.__showing_detail_frame = False
|
|
self.ui.toggle_detail_frame_button.setArrowType(Qt.DownArrow)
|
|
else:
|
|
logging.debug("Showing detail frame")
|
|
self.ui.bottom_frame.show()
|
|
self.__showing_detail_frame = True
|
|
self.ui.toggle_detail_frame_button.setArrowType(Qt.UpArrow)
|
|
|
|
def on_image_info_clicked(self):
|
|
logging.debug("Clicked on button to show image info!")
|
|
if self.main.curr_image_index is not None:
|
|
dialog = ArtInfoDialog(self)
|
|
#dialog.set_image_info() # TODO see image_info_dialog/
|
|
dialog.exec_()
|
|
else:
|
|
pass
|