clickable label to the right place

This commit is contained in:
Matheus Cirillo
2024-04-26 20:17:54 -03:00
parent 18dcedd6a0
commit bcf4453c8d
2 changed files with 17 additions and 21 deletions

View File

@@ -46,7 +46,6 @@ from src.core.ts_core import (TagStudioCore, TAG_COLORS, DATE_FIELDS, TEXT_FIELD
from src.core.utils.web import strip_web_protocol
from src.qt.flowlayout import FlowLayout, FlowWidget
from src.qt.main_window import Ui_MainWindow
from src.qt.utils.clickableLabels import FileOpenerLabel
import src.qt.resources_rc
# SIGQUIT is not defined on Windows
@@ -1970,6 +1969,23 @@ class AddFieldModal(QWidget):
self.root_layout.addStretch(1)
self.root_layout.addWidget(self.button_container)
class FileOpenerLabel(QLabel):
def __init__(self, text, parent=None):
super().__init__(text, parent)
def setFilePath(self, filepath):
self.filepath = filepath
def mousePressEvent(self, event):
super().mousePressEvent(event)
#open file
if hasattr(self, 'filepath'):
if os.path.exists(self.filepath):
os.startfile(self.filepath)
logging.info(f'Opening file: {self.filepath}')
else:
logging.error(f'File not found: {self.filepath}')
class PreviewPanel(QWidget):
"""The Preview Panel Widget."""
tags_updated = Signal()

View File

@@ -1,20 +0,0 @@
import os
import logging
from PySide6.QtWidgets import QLabel
class FileOpenerLabel(QLabel):
def __init__(self, text, parent=None):
super().__init__(text, parent)
def setFilePath(self, filepath):
self.filepath = filepath
def mousePressEvent(self, event):
super().mousePressEvent(event)
#open file
if hasattr(self, 'filepath'):
if os.path.exists(self.filepath):
os.startfile(self.filepath)
logging.info(f'Opening file: {self.filepath}')
else:
logging.error(f'File not found: {self.filepath}')