Skip to content

Commit

Permalink
add publish report viewer to admin actions
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Dec 10, 2024
1 parent a8441e3 commit 14d4c75
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 29 deletions.
68 changes: 39 additions & 29 deletions client/ayon_core/tools/publisher/publish_report_viewer/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,31 +484,16 @@ def __init__(self, *args, **kwargs):
self._time_delegate = time_delegate
self._remove_btn = remove_btn

def _update_remove_btn(self):
viewport = self.viewport()
height = viewport.height() + self.header().height()
pos_x = viewport.width() - self._remove_btn.width() - 5
pos_y = height - self._remove_btn.height() - 5
self._remove_btn.move(max(0, pos_x), max(0, pos_y))

def _on_rows_inserted(self):
header = self.header()
header.resizeSections(QtWidgets.QHeaderView.ResizeToContents)
self._update_remove_btn()

def resizeEvent(self, event):
super().resizeEvent(event)
self._update_remove_btn()

def showEvent(self, event):
super().showEvent(event)
self._model.refresh()
header = self.header()
header.resizeSections(QtWidgets.QHeaderView.ResizeToContents)
self._update_remove_btn()

def _on_selection_change(self):
self.selection_changed.emit()
def resizeEvent(self, event):
super().resizeEvent(event)
self._update_remove_btn()

def add_filepaths(self, filepaths):
self._model.add_filepaths(filepaths)
Expand All @@ -518,6 +503,30 @@ def remove_item_by_id(self, item_id):
self._model.remove_item_by_id(item_id)
self._fill_selection()

def get_current_report(self):
index = self.currentIndex()
item_id = index.data(ITEM_ID_ROLE)
return self._model.get_report_by_id(item_id)

def refresh(self):
self._model.refresh()
self._fill_selection()

def _update_remove_btn(self):
viewport = self.viewport()
height = viewport.height() + self.header().height()
pos_x = viewport.width() - self._remove_btn.width() - 5
pos_y = height - self._remove_btn.height() - 5
self._remove_btn.move(max(0, pos_x), max(0, pos_y))

def _on_rows_inserted(self):
header = self.header()
header.resizeSections(QtWidgets.QHeaderView.ResizeToContents)
self._update_remove_btn()

def _on_selection_change(self):
self.selection_changed.emit()

def _on_remove_clicked(self):
index = self.currentIndex()
item_id = index.data(ITEM_ID_ROLE)
Expand All @@ -533,11 +542,6 @@ def _fill_selection(self):
if index.isValid():
self.setCurrentIndex(index)

def get_current_report(self):
index = self.currentIndex()
item_id = index.data(ITEM_ID_ROLE)
return self._model.get_report_by_id(item_id)


class LoadedFilesWidget(QtWidgets.QWidget):
report_changed = QtCore.Signal()
Expand Down Expand Up @@ -577,15 +581,18 @@ def dropEvent(self, event):
self._add_filepaths(filepaths)
event.accept()

def refresh(self):
self._view.refresh()

def get_current_report(self):
return self._view.get_current_report()

def _on_report_change(self):
self.report_changed.emit()

def _add_filepaths(self, filepaths):
self._view.add_filepaths(filepaths)

def get_current_report(self):
return self._view.get_current_report()


class PublishReportViewerWindow(QtWidgets.QWidget):
default_width = 1200
Expand Down Expand Up @@ -624,9 +631,12 @@ def __init__(self, parent=None):
self.resize(self.default_width, self.default_height)
self.setStyleSheet(style.load_stylesheet())

def _on_report_change(self):
report = self._loaded_files_widget.get_current_report()
self.set_report(report)
def refresh(self):
self._loaded_files_widget.refresh()

def set_report(self, report_data):
self._main_widget.set_report(report_data)

def _on_report_change(self):
report = self._loaded_files_widget.get_current_report()
self.set_report(report)
17 changes: 17 additions & 0 deletions client/ayon_core/tools/tray/ui/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
from ayon_core.tools.launcher.ui import LauncherWindow
from ayon_core.tools.loader.ui import LoaderWindow
from ayon_core.tools.console_interpreter.ui import ConsoleInterpreterWindow
from ayon_core.tools.publisher.publish_report_viewer import (
PublishReportViewerWindow,
)

from .addons_manager import TrayAddonsManager
from .host_console_listener import HostListener
Expand Down Expand Up @@ -89,6 +92,7 @@ def __init__(self, tray_widget, main_window):
self._launcher_window = None
self._browser_window = None
self._console_window = ConsoleInterpreterWindow()
self._publish_report_viewer_window = PublishReportViewerWindow()

self._update_check_timer = update_check_timer
self._update_check_interval = update_check_interval
Expand Down Expand Up @@ -161,6 +165,13 @@ def initialize_addons(self):
)
console_action.triggered.connect(self._show_console_window)

publish_report_viewer_action = ITrayAddon.add_action_to_admin_submenu(
"Publish report viewer", tray_menu
)
publish_report_viewer_action.triggered.connect(
self._show_publish_report_viewer
)

self._addons_manager.initialize(tray_menu)

# Add default actions under addon actions
Expand Down Expand Up @@ -575,6 +586,12 @@ def _show_console_window(self):
self._console_window.raise_()
self._console_window.activateWindow()

def _show_publish_report_viewer(self):
self._publish_report_viewer_window.refresh()
self._publish_report_viewer_window.show()
self._publish_report_viewer_window.raise_()
self._publish_report_viewer_window.activateWindow()


class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
"""Tray widget.
Expand Down

0 comments on commit 14d4c75

Please sign in to comment.