video_window.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # -*- coding: utf-8 -*-
  2. from PyQt6.QtCore import *
  3. from PyQt6.QtWidgets import *
  4. from PyQt6.QtGui import *
  5. from qfluentwidgets import *
  6. from demeter.core import *
  7. from .video_scene import VideoScene
  8. from .video_footage import VideoFootage
  9. from .video_combine import VideoCombine
  10. class Widget(QFrame):
  11. def __init__(self, text: str, parent=None):
  12. super().__init__(parent=parent)
  13. self.label = SubtitleLabel(text, self)
  14. self.hBoxLayout = QHBoxLayout(self)
  15. setFont(self.label, 24)
  16. self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
  17. self.hBoxLayout.addWidget(self.label, 1, Qt.AlignmentFlag.AlignCenter)
  18. self.setObjectName(text.replace(' ', '-'))
  19. class VideoWindow(MSFluentWindow):
  20. def __init__(self, id, parent):
  21. super().__init__()
  22. self.info = Demeter.service('common').one('video', id=id)
  23. self.id = id
  24. self.parent = parent
  25. self.initWindow()
  26. # create sub interface
  27. self.videoFootage = VideoFootage(self)
  28. self.videoScene = VideoScene(self)
  29. self.videoCombine = VideoCombine(self)
  30. self.libraryInterface = Widget('library Interface', self)
  31. self.initNavigation()
  32. def initNavigation(self):
  33. self.addSubInterface(self.videoScene, FluentIcon.APPLICATION, '场景')
  34. self.addSubInterface(self.videoFootage, FluentIcon.VIDEO, '镜头')
  35. self.addSubInterface(self.videoCombine, FluentIcon.ALBUM, '合成')
  36. self.addSubInterface(self.libraryInterface, FluentIcon.BOOK_SHELF, '库', FluentIcon.LIBRARY_FILL, NavigationItemPosition.BOTTOM)
  37. # 添加自定义导航组件
  38. self.navigationInterface.addItem(
  39. routeKey='Help',
  40. icon=FluentIcon.HELP,
  41. text='帮助',
  42. onClick=self.showMessageBox,
  43. selectable=False,
  44. position=NavigationItemPosition.BOTTOM,
  45. )
  46. self.navigationInterface.setCurrentItem(self.videoScene.objectName())
  47. self.stackedWidget.currentChanged.connect(self.initData)
  48. def initData(self):
  49. widget = self.stackedWidget.currentWidget()
  50. if (widget):
  51. widget.initData()
  52. def initWindow(self):
  53. Demeter.model('video_scene').init(self.id)
  54. self.setWindowIcon(QIcon(Demeter.path + 'gui/resource/images/logo.png'))
  55. self.setWindowTitle('灵镜影片:' + self.info['name'])
  56. desktop = QApplication.screens()[0].size()
  57. w, h = desktop.width(), desktop.height()
  58. #self.resize(w-636, h-194)
  59. self.resize(w, h)
  60. #self.showFullScreen()
  61. self.setMinimumWidth(760)
  62. self.move(w//2 - self.width()//2, h//2 - self.height()//2)
  63. def showMessageBox(self):
  64. w = MessageBox(
  65. '支持作者🥰',
  66. '个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀',
  67. self
  68. )
  69. w.yesButton.setText('来啦老弟')
  70. w.cancelButton.setText('下次一定')
  71. if w.exec():
  72. QDesktopServices.openUrl(QUrl("https://qfluentwidgets.com/zh/price/"))