Skip to content

Commit

Permalink
Add a button to detach the player from the window
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Jan 31, 2019
1 parent 14cb561 commit 322a67c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyforms_gui/appmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def __init__(self, ClassObject):
if not widget._show: dock.hide()

if conf.PYFORMS_STYLESHEET:

stylesheet_files = [conf.PYFORMS_STYLESHEET]

p = platform.system()
Expand Down
20 changes: 20 additions & 0 deletions pyforms_gui/controls/control_player/control_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from AnyQt import QtCore
from AnyQt.QtWidgets import QFrame
from AnyQt.QtWidgets import QApplication
from AnyQt.QtWidgets import QMainWindow

from pyforms_gui.controls.control_base import ControlBase

if _api.USED_API == _api.QT_API_PYQT5:
Expand Down Expand Up @@ -71,6 +73,9 @@ def init_form(self):
# Define the icon for the Play button

self.videoPlay.setIcon(conf.PYFORMS_ICON_VIDEOPLAYER_PAUSE_PLAY)
self.detach_btn.setIcon(conf.PYFORMS_ICON_VIDEOPLAYER_DETACH)

self.detach_btn.clicked.connect(self.__detach_player_evt)

self._video_widget = VideoGLWidget()
self._video_widget._control = self
Expand Down Expand Up @@ -329,6 +334,21 @@ def call_next_frame(self, update_slider=True, update_number=True, increment_fram
self.form.setUpdatesEnabled(True)


def __detach_player_evt(self):
self._old_layout = self.parentWidget().layout()
self._old_layout_index = self._old_layout.indexOf(self)
self._detach_win = QMainWindow(parent=self.parent)
self._detach_win.setWindowTitle('Player')
self._detach_win.setCentralWidget(self)
self.detach_btn.hide()
self._detach_win.closeEvent = self.__detach_win_closed_evt
self._detach_win.show()

def __detach_win_closed_evt(self, event):
self._old_layout.insertWidget(self._old_layout_index, self)
self.detach_btn.show()
self._detach_win.close()
del self._detach_win

def videoPlay_clicked(self):
"""Slot for Play/Pause functionality."""
Expand Down
49 changes: 45 additions & 4 deletions pyforms_gui/controls/control_player/video.ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: #666;
color: #FFF;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand All @@ -35,7 +42,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -76,7 +92,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
<height>24</height>
</size>
</property>
<property name="maximumSize">
Expand All @@ -95,15 +111,24 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="videoPlay">
<property name="minimumSize">
<size>
<width>0</width>
<height>31</height>
<height>21</height>
</size>
</property>
<property name="focusPolicy">
Expand Down Expand Up @@ -176,6 +201,9 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="pageStep">
<number>0</number>
</property>
Expand Down Expand Up @@ -215,6 +243,19 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="detach_btn">
<property name="toolTip">
<string extracomment="Detach the player">Detach the player</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
3 changes: 3 additions & 0 deletions pyforms_gui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def path(filename):
PYFORMS_ICON_VIDEOPLAYER_PAUSE_PLAY.addPixmap(qApp.style().standardPixmap(QStyle.SP_MediaPause), mode=QIcon.Normal,
state=QIcon.On)

PYFORMS_ICON_VIDEOPLAYER_DETACH = QIcon()
PYFORMS_ICON_VIDEOPLAYER_DETACH.addPixmap(qApp.style().standardPixmap(QStyle.SP_TitleBarMaxButton), mode=QIcon.Normal )

PYFORMS_ICON_CODEEDITOR_SAVE = QIcon(qApp.style().standardPixmap(QStyle.SP_DialogSaveButton))
PYFORMS_ICON_CODEEDITOR_DISCART = QIcon(qApp.style().standardPixmap(QStyle.SP_DialogDiscardButton))

Expand Down

0 comments on commit 322a67c

Please sign in to comment.