Example #1
0
    def get_childs(self, sender):
        """ Generate sub dirs relevant to main menu element """

        self.clear_child_table()
        self.current_parent = sender
        # Create Childs
        self.refresh_element = QToolButton()
        self.refresh_element.setObjectName('refresh')
        self.refresh_element.setIcon(QIcon(':/refresh'))
        self.refresh_element.setIconSize(QSize(22, 22))
        self.refresh_element.setCursor(Qt.PointingHandCursor)
        self.refresh_element.clicked.connect(lambda: self.get_keys(True, refresh=self.refresh_element.statusTip()))
        self.refresh_element.setEnabled(False)
        self.second_layout_keys_childs.addWidget(self.refresh_element)
        self.second_layout_keys_childs.addSpacing(5)
        sql = "SELECT DISTINCT child " \
              "FROM passwords " \
              "WHERE parent=? " \
              "ORDER BY child ASC"
        query = self.cursor.execute(sql, (sender,))
        for item in query.fetchall():
            child_element = QRadioButton()
            child_element.setObjectName("child-element")
            child_element.setText(item[0])
            child_element.setMinimumHeight(22)
            child_element.setCursor(Qt.PointingHandCursor)
            child_element.clicked.connect(self.get_keys)
            self.second_layout_keys_childs.addWidget(child_element)
            self.second_layout_keys_childs.addSpacing(5)
Example #2
0
 def generate_child_list(self):
     self.sender().blockSignals(True)
     for pos in reversed(range(self.cc.count())):
         curr_item = self.cc.takeAt(pos).widget()
         if curr_item is not None:
             curr_item.deleteLater()
     sql = "SELECT DISTINCT child " \
           "FROM passwords " \
           "WHERE parent=? " \
           "ORDER BY child ASC"
     query = self.cursor.execute(sql, (self.combo.currentText(), ))
     for item in query.fetchall():
         r_elem = QRadioButton()
         r_elem.setObjectName("child-element")
         r_elem.setText(item[0])
         r_elem.setFixedHeight(20)
         r_elem.setCursor(Qt.PointingHandCursor)
         r_elem.clicked.connect(self.child_text_replace)
         self.cc.addWidget(r_elem)
     self.sender().blockSignals(False)
Example #3
0
 def __init__(self, parent=None):
     super(ThemePage, self).__init__(parent)
     self.parent = parent
     self.setObjectName('settingsthemepage')
     mainLayout = QVBoxLayout()
     mainLayout.setSpacing(10)
     if sys.platform != 'darwin':
         self.lightRadio = QRadioButton(self)
         self.lightRadio.setIcon(QIcon(':/images/%s/theme-light.png' % self.parent.theme))
         self.lightRadio.setToolTip('<img src=":/images/theme-light-large.jpg" />')
         self.lightRadio.setIconSize(QSize(165, 121))
         self.lightRadio.setCursor(Qt.PointingHandCursor)
         self.lightRadio.clicked.connect(self.switchTheme)
         self.lightRadio.setChecked(self.parent.theme == 'light')
         self.darkRadio = QRadioButton(self)
         self.darkRadio.setIcon(QIcon(':/images/%s/theme-dark.png' % self.parent.theme))
         self.darkRadio.setToolTip('<img src=":/images/theme-dark-large.jpg" />')
         self.darkRadio.setIconSize(QSize(165, 121))
         self.darkRadio.setCursor(Qt.PointingHandCursor)
         self.darkRadio.clicked.connect(self.switchTheme)
         self.darkRadio.setChecked(self.parent.theme == 'dark')
         themeLayout = QGridLayout()
         themeLayout.setColumnStretch(0, 1)
         themeLayout.addWidget(self.lightRadio, 0, 1)
         themeLayout.addWidget(self.darkRadio, 0, 3)
         themeLayout.addWidget(QLabel('Light', self), 1, 1, Qt.AlignHCenter)
         themeLayout.setColumnStretch(2, 1)
         themeLayout.addWidget(QLabel('Dark', self), 1, 3, Qt.AlignHCenter)
         themeLayout.setColumnStretch(4, 1)
         themeGroup = QGroupBox('Theme')
         themeGroup.setLayout(themeLayout)
         mainLayout.addWidget(themeGroup)
     toolbar_labels = self.parent.settings.value('toolbarLabels', 'beside', type=str)
     toolbar_iconsRadio = QRadioButton('Icons only', self)
     toolbar_iconsRadio.setToolTip('Icons only')
     toolbar_iconsRadio.setCursor(Qt.PointingHandCursor)
     toolbar_iconsRadio.setChecked(toolbar_labels == 'none')
     toolbar_underRadio = QRadioButton('Text under icons', self)
     toolbar_underRadio.setToolTip('Text under icons')
     toolbar_underRadio.setCursor(Qt.PointingHandCursor)
     toolbar_underRadio.setChecked(toolbar_labels == 'under')
     toolbar_besideRadio = QRadioButton('Text beside icons', self)
     toolbar_besideRadio.setToolTip('Text beside icons')
     toolbar_besideRadio.setCursor(Qt.PointingHandCursor)
     toolbar_besideRadio.setChecked(toolbar_labels == 'beside')
     toolbar_buttonGroup = QButtonGroup(self)
     toolbar_buttonGroup.addButton(toolbar_iconsRadio, 1)
     toolbar_buttonGroup.addButton(toolbar_underRadio, 2)
     toolbar_buttonGroup.addButton(toolbar_besideRadio, 3)
     # noinspection PyUnresolvedReferences
     toolbar_buttonGroup.buttonClicked[int].connect(self.parent.parent.toolbar.setLabels)
     toolbarLayout = QGridLayout()
     toolbarLayout.addWidget(toolbar_besideRadio, 0, 0)
     toolbarLayout.addWidget(toolbar_underRadio, 0, 1)
     toolbarLayout.addWidget(toolbar_iconsRadio, 1, 0)
     toolbarGroup = QGroupBox('Toolbar')
     toolbarGroup.setLayout(toolbarLayout)
     mainLayout.addWidget(toolbarGroup)
     mainLayout.addStretch(1)
     self.setLayout(mainLayout)
Example #4
0
class ThemePage(QWidget):
    def __init__(self, parent=None):
        super(ThemePage, self).__init__(parent)
        self.parent = parent
        self.setObjectName('settingsthemepage')
        mainLayout = QVBoxLayout()
        mainLayout.setSpacing(10)
        if sys.platform != 'darwin':
            self.lightRadio = QRadioButton(self)
            self.lightRadio.setIcon(
                QIcon(':/images/%s/theme-light.png' % self.parent.theme))
            self.lightRadio.setToolTip(
                '<img src=":/images/theme-light-large.jpg" />')
            self.lightRadio.setIconSize(QSize(165, 121))
            self.lightRadio.setCursor(Qt.PointingHandCursor)
            self.lightRadio.clicked.connect(self.switchTheme)
            self.lightRadio.setChecked(self.parent.theme == 'light')
            self.darkRadio = QRadioButton(self)
            self.darkRadio.setIcon(
                QIcon(':/images/%s/theme-dark.png' % self.parent.theme))
            self.darkRadio.setToolTip(
                '<img src=":/images/theme-dark-large.jpg" />')
            self.darkRadio.setIconSize(QSize(165, 121))
            self.darkRadio.setCursor(Qt.PointingHandCursor)
            self.darkRadio.clicked.connect(self.switchTheme)
            self.darkRadio.setChecked(self.parent.theme == 'dark')
            themeLayout = QGridLayout()
            themeLayout.setColumnStretch(0, 1)
            themeLayout.addWidget(self.lightRadio, 0, 1)
            themeLayout.addWidget(self.darkRadio, 0, 3)
            themeLayout.addWidget(QLabel('Light', self), 1, 1, Qt.AlignHCenter)
            themeLayout.setColumnStretch(2, 1)
            themeLayout.addWidget(QLabel('Dark', self), 1, 3, Qt.AlignHCenter)
            themeLayout.setColumnStretch(4, 1)
            themeGroup = QGroupBox('Theme')
            themeGroup.setLayout(themeLayout)
            mainLayout.addWidget(themeGroup)
        toolbar_labels = self.parent.settings.value('toolbarLabels',
                                                    'beside',
                                                    type=str)
        toolbar_iconsRadio = QRadioButton('Icons only', self)
        toolbar_iconsRadio.setToolTip('Icons only')
        toolbar_iconsRadio.setCursor(Qt.PointingHandCursor)
        toolbar_iconsRadio.setChecked(toolbar_labels == 'none')
        toolbar_underRadio = QRadioButton('Text under icons', self)
        toolbar_underRadio.setToolTip('Text under icons')
        toolbar_underRadio.setCursor(Qt.PointingHandCursor)
        toolbar_underRadio.setChecked(toolbar_labels == 'under')
        toolbar_besideRadio = QRadioButton('Text beside icons', self)
        toolbar_besideRadio.setToolTip('Text beside icons')
        toolbar_besideRadio.setCursor(Qt.PointingHandCursor)
        toolbar_besideRadio.setChecked(toolbar_labels == 'beside')
        toolbar_buttonGroup = QButtonGroup(self)
        toolbar_buttonGroup.addButton(toolbar_iconsRadio, 1)
        toolbar_buttonGroup.addButton(toolbar_underRadio, 2)
        toolbar_buttonGroup.addButton(toolbar_besideRadio, 3)
        # noinspection PyUnresolvedReferences
        toolbar_buttonGroup.buttonClicked[int].connect(
            self.parent.parent.toolbar.setLabels)
        toolbarLayout = QGridLayout()
        toolbarLayout.addWidget(toolbar_besideRadio, 0, 0)
        toolbarLayout.addWidget(toolbar_underRadio, 0, 1)
        toolbarLayout.addWidget(toolbar_iconsRadio, 1, 0)
        toolbarGroup = QGroupBox('Toolbar')
        toolbarGroup.setLayout(toolbarLayout)
        mainLayout.addWidget(toolbarGroup)
        mainLayout.addStretch(1)
        self.setLayout(mainLayout)

    @pyqtSlot(bool)
    def switchTheme(self) -> None:
        if self.darkRadio.isChecked():
            newtheme = 'dark'
        else:
            newtheme = 'light'
        if newtheme != self.parent.theme:
            # noinspection PyArgumentList
            mbox = QMessageBox(icon=QMessageBox.NoIcon,
                               windowTitle='Restart required',
                               minimumWidth=500,
                               textFormat=Qt.RichText,
                               objectName='genericdialog')
            mbox.setWindowFlags(Qt.Dialog | Qt.WindowCloseButtonHint)
            mbox.setText(
                '''
                <style>
                    h1 {
                        color: %s;
                        font-family: "Futura-Light", sans-serif;
                        font-weight: 400;
                    }
                    p { font-size: 15px; }
                </style>
                <h1>Warning</h1>
                <p>The application needs to be restarted in order to switch themes. Ensure you have saved
                your project or finished any cut ror join tasks in progress.</p>
                <p>Would you like to restart and switch themes now?</p>''' %
                ('#C681D5' if self.parent.theme == 'dark' else '#642C68'))
            mbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            mbox.setDefaultButton(QMessageBox.Yes)
            response = mbox.exec_()
            if response == QMessageBox.Yes:
                self.parent.settings.setValue('theme', newtheme)
                self.parent.parent.theme = newtheme
                self.parent.parent.parent.reboot()
            else:
                self.darkRadio.setChecked(
                    True
                ) if newtheme == 'light' else self.lightRadio.setChecked(True)
Example #5
0
 def __init__(self, parent=None):
     super(VideoPage, self).__init__(parent)
     self.parent = parent
     self.setObjectName('settingsvideopage')
     decodingCheckbox = QCheckBox('Hardware decoding', self)
     decodingCheckbox.setToolTip('Enable hardware based video decoding')
     decodingCheckbox.setCursor(Qt.PointingHandCursor)
     decodingCheckbox.setChecked(self.parent.parent.hardwareDecoding)
     decodingCheckbox.stateChanged.connect(self.switchDecoding)
     decodingLabel = QLabel(
         '''
         <b>ON:</b> attempt to use best hardware decoder, fall back to software decoding on error
         <br/>
         <b>OFF:</b> always use software decoding
     ''', self)
     decodingLabel.setObjectName('decodinglabel')
     decodingLabel.setTextFormat(Qt.RichText)
     decodingLabel.setWordWrap(True)
     ratioCheckbox = QCheckBox('Keep aspect ratio', self)
     ratioCheckbox.setToolTip('Keep source video aspect ratio')
     ratioCheckbox.setCursor(Qt.PointingHandCursor)
     ratioCheckbox.setChecked(self.parent.parent.keepRatio)
     ratioCheckbox.stateChanged.connect(self.keepAspectRatio)
     ratioLabel = QLabel(
         '''
         <b>OFF:</b> stretch video to application window size, ignored in fullscreen
         <br/>
         <b>ON:</b> lock video to its set video aspect, black bars added to compensate
     ''', self)
     ratioLabel.setObjectName('ratiolabel')
     ratioLabel.setTextFormat(Qt.RichText)
     ratioLabel.setWordWrap(True)
     videoLayout = QVBoxLayout()
     videoLayout.addWidget(decodingCheckbox)
     videoLayout.addWidget(decodingLabel)
     videoLayout.addWidget(SettingsDialog.lineSeparator())
     videoLayout.addWidget(ratioCheckbox)
     videoLayout.addWidget(ratioLabel)
     videoGroup = QGroupBox('Playback')
     videoGroup.setLayout(videoLayout)
     zoomLevel = self.parent.settings.value('videoZoom', 0, type=int)
     zoom_qtrRadio = QRadioButton('Quarter [1:4]', self)
     zoom_qtrRadio.setToolTip('1/4 Zoom')
     zoom_qtrRadio.setCursor(Qt.PointingHandCursor)
     zoom_qtrRadio.setChecked(zoomLevel == -2)
     zoom_halfRadio = QRadioButton('Half [1:2]', self)
     zoom_halfRadio.setToolTip('1/2 Half')
     zoom_halfRadio.setCursor(Qt.PointingHandCursor)
     zoom_halfRadio.setChecked(zoomLevel == -1)
     zoom_originalRadio = QRadioButton('No zoom [1:1]', self)
     zoom_originalRadio.setToolTip('1/1 No zoom')
     zoom_originalRadio.setCursor(Qt.PointingHandCursor)
     zoom_originalRadio.setChecked(zoomLevel == 0)
     zoom_doubleRadio = QRadioButton('Double [2:1]', self)
     zoom_doubleRadio.setToolTip('2/1 Double')
     zoom_doubleRadio.setCursor(Qt.PointingHandCursor)
     zoom_doubleRadio.setChecked(zoomLevel == 1)
     zoom_buttonGroup = QButtonGroup(self)
     zoom_buttonGroup.addButton(zoom_qtrRadio, 1)
     zoom_buttonGroup.addButton(zoom_halfRadio, 2)
     zoom_buttonGroup.addButton(zoom_originalRadio, 3)
     zoom_buttonGroup.addButton(zoom_doubleRadio, 4)
     # noinspection PyUnresolvedReferences
     zoom_buttonGroup.buttonClicked[int].connect(self.setZoom)
     zoomLabel = QLabel(
         '<b>NOTE:</b> video zoom settings only affect the video playback and '
         + 'will not apply zoom effects to the media you produce', self)
     zoomLabel.setObjectName('zoomlabel')
     zoomLabel.setTextFormat(Qt.RichText)
     zoomLabel.setWordWrap(True)
     zoomLayout = QGridLayout()
     zoomLayout.addWidget(zoom_qtrRadio, 0, 0)
     zoomLayout.addWidget(zoom_halfRadio, 0, 1)
     zoomLayout.addWidget(zoom_originalRadio, 1, 0)
     zoomLayout.addWidget(zoom_doubleRadio, 1, 1)
     zoomLayout.addWidget(zoomLabel, 2, 0, 1, 2)
     zoomGroup = QGroupBox('Zoom')
     zoomGroup.setLayout(zoomLayout)
     mainLayout = QVBoxLayout()
     mainLayout.setSpacing(10)
     mainLayout.addWidget(videoGroup)
     mainLayout.addWidget(zoomGroup)
     mainLayout.addStretch(1)
     self.setLayout(mainLayout)
Example #6
0
 def __init__(self, parent=None):
     super(ThemePage, self).__init__(parent)
     self.parent = parent
     self.setObjectName('settingsthemepage')
     mainLayout = QVBoxLayout()
     mainLayout.setSpacing(10)
     pen = QPen(
         QColor('#4D5355' if self.parent.theme == 'dark' else '#B9B9B9'))
     pen.setWidth(2)
     theme_light = QPixmap(':/images/theme-light.png', 'PNG')
     painter = QPainter(theme_light)
     painter.setPen(pen)
     painter.setBrush(Qt.NoBrush)
     painter.drawRect(0, 0, theme_light.width(), theme_light.height())
     theme_dark = QPixmap(':/images/theme-dark.png', 'PNG')
     painter = QPainter(theme_dark)
     painter.setPen(pen)
     painter.setBrush(Qt.NoBrush)
     painter.drawRect(0, 0, theme_dark.width(), theme_dark.height())
     self.lightRadio = QRadioButton(self)
     self.lightRadio.setIcon(QIcon(theme_light))
     self.lightRadio.setIconSize(QSize(165, 121))
     self.lightRadio.setCursor(Qt.PointingHandCursor)
     self.lightRadio.clicked.connect(self.switchTheme)
     self.lightRadio.setChecked(self.parent.theme == 'light')
     self.darkRadio = QRadioButton(self)
     self.darkRadio.setIcon(QIcon(theme_dark))
     self.darkRadio.setIconSize(QSize(165, 121))
     self.darkRadio.setCursor(Qt.PointingHandCursor)
     self.darkRadio.clicked.connect(self.switchTheme)
     self.darkRadio.setChecked(self.parent.theme == 'dark')
     themeLayout = QGridLayout()
     themeLayout.setColumnStretch(0, 1)
     themeLayout.addWidget(self.lightRadio, 0, 1)
     themeLayout.addWidget(self.darkRadio, 0, 3)
     themeLayout.addWidget(QLabel('Light', self), 1, 1, Qt.AlignHCenter)
     themeLayout.setColumnStretch(2, 1)
     themeLayout.addWidget(QLabel('Dark', self), 1, 3, Qt.AlignHCenter)
     themeLayout.setColumnStretch(4, 1)
     themeGroup = QGroupBox('Theme')
     themeGroup.setLayout(themeLayout)
     mainLayout.addWidget(themeGroup)
     index_leftRadio = QRadioButton('Clips on left')
     index_leftRadio.setToolTip('Display Clip Index on the left hand side')
     index_leftRadio.setCursor(Qt.PointingHandCursor)
     index_leftRadio.setChecked(self.parent.parent.indexLayout == 'left')
     index_rightRadio = QRadioButton('Clips on right')
     index_rightRadio.setToolTip(
         'Display Clip Index on the right hand side')
     index_rightRadio.setCursor(Qt.PointingHandCursor)
     index_rightRadio.setChecked(self.parent.parent.indexLayout == 'right')
     index_buttonGroup = QButtonGroup(self)
     index_buttonGroup.addButton(index_leftRadio, 1)
     index_buttonGroup.addButton(index_rightRadio, 2)
     # noinspection PyUnresolvedReferences
     index_buttonGroup.buttonClicked[int].connect(
         self.parent.parent.setClipIndexLayout)
     indexLayout = QHBoxLayout()
     indexLayout.addWidget(index_leftRadio)
     indexLayout.addWidget(index_rightRadio)
     layoutGroup = QGroupBox('Layout')
     layoutGroup.setLayout(indexLayout)
     mainLayout.addWidget(layoutGroup)
     toolbar_labels = self.parent.settings.value('toolbarLabels',
                                                 'beside',
                                                 type=str)
     toolbar_notextRadio = QRadioButton('No text (buttons only)', self)
     toolbar_notextRadio.setToolTip('No text (buttons only)')
     toolbar_notextRadio.setCursor(Qt.PointingHandCursor)
     toolbar_notextRadio.setChecked(toolbar_labels == 'none')
     toolbar_underRadio = QRadioButton('Text under buttons', self)
     toolbar_underRadio.setToolTip('Text under buttons')
     toolbar_underRadio.setCursor(Qt.PointingHandCursor)
     toolbar_underRadio.setChecked(toolbar_labels == 'under')
     toolbar_besideRadio = QRadioButton('Text beside buttons', self)
     toolbar_besideRadio.setToolTip('Text beside buttons')
     toolbar_besideRadio.setCursor(Qt.PointingHandCursor)
     toolbar_besideRadio.setChecked(toolbar_labels == 'beside')
     toolbar_buttonGroup = QButtonGroup(self)
     toolbar_buttonGroup.addButton(toolbar_besideRadio, 1)
     toolbar_buttonGroup.addButton(toolbar_underRadio, 2)
     toolbar_buttonGroup.addButton(toolbar_notextRadio, 3)
     # noinspection PyUnresolvedReferences
     toolbar_buttonGroup.buttonClicked[int].connect(self.setLabelStyle)
     toolbarLayout = QGridLayout()
     toolbarLayout.addWidget(toolbar_besideRadio, 0, 0)
     toolbarLayout.addWidget(toolbar_underRadio, 0, 1)
     toolbarLayout.addWidget(toolbar_notextRadio, 1, 0)
     toolbarGroup = QGroupBox('Toolbar')
     toolbarGroup.setLayout(toolbarLayout)
     mainLayout.addWidget(toolbarGroup)
     nativeDialogsCheckbox = QCheckBox('Use native dialogs', self)
     nativeDialogsCheckbox.setToolTip('Use native file dialogs')
     nativeDialogsCheckbox.setCursor(Qt.PointingHandCursor)
     nativeDialogsCheckbox.setChecked(self.parent.parent.nativeDialogs)
     nativeDialogsCheckbox.stateChanged.connect(self.setNativeDialogs)
     nativeDialogsLabel = QLabel(
         '''
         <b>ON:</b> use native dialog widgets as provided by your operating system
         <br/>
         <b>OFF:</b> use a generic file open & save dialog widget provided by the Qt toolkit
         <br/><br/>
         <b>NOTE:</b> native dialogs should always be used if working
     ''', self)
     nativeDialogsLabel.setObjectName('nativedialogslabel')
     nativeDialogsLabel.setTextFormat(Qt.RichText)
     nativeDialogsLabel.setWordWrap(True)
     advancedLayout = QVBoxLayout()
     advancedLayout.addWidget(nativeDialogsCheckbox)
     advancedLayout.addWidget(nativeDialogsLabel)
     advancedGroup = QGroupBox('Advanced')
     advancedGroup.setLayout(advancedLayout)
     mainLayout.addWidget(advancedGroup)
     mainLayout.addStretch(1)
     self.setLayout(mainLayout)
Example #7
0
class ThemePage(QWidget):
    def __init__(self, parent=None):
        super(ThemePage, self).__init__(parent)
        self.parent = parent
        self.setObjectName('settingsthemepage')
        mainLayout = QVBoxLayout()
        mainLayout.setSpacing(10)
        pen = QPen(
            QColor('#4D5355' if self.parent.theme == 'dark' else '#B9B9B9'))
        pen.setWidth(2)
        theme_light = QPixmap(':/images/theme-light.png', 'PNG')
        painter = QPainter(theme_light)
        painter.setPen(pen)
        painter.setBrush(Qt.NoBrush)
        painter.drawRect(0, 0, theme_light.width(), theme_light.height())
        theme_dark = QPixmap(':/images/theme-dark.png', 'PNG')
        painter = QPainter(theme_dark)
        painter.setPen(pen)
        painter.setBrush(Qt.NoBrush)
        painter.drawRect(0, 0, theme_dark.width(), theme_dark.height())
        self.lightRadio = QRadioButton(self)
        self.lightRadio.setIcon(QIcon(theme_light))
        self.lightRadio.setIconSize(QSize(165, 121))
        self.lightRadio.setCursor(Qt.PointingHandCursor)
        self.lightRadio.clicked.connect(self.switchTheme)
        self.lightRadio.setChecked(self.parent.theme == 'light')
        self.darkRadio = QRadioButton(self)
        self.darkRadio.setIcon(QIcon(theme_dark))
        self.darkRadio.setIconSize(QSize(165, 121))
        self.darkRadio.setCursor(Qt.PointingHandCursor)
        self.darkRadio.clicked.connect(self.switchTheme)
        self.darkRadio.setChecked(self.parent.theme == 'dark')
        themeLayout = QGridLayout()
        themeLayout.setColumnStretch(0, 1)
        themeLayout.addWidget(self.lightRadio, 0, 1)
        themeLayout.addWidget(self.darkRadio, 0, 3)
        themeLayout.addWidget(QLabel('Light', self), 1, 1, Qt.AlignHCenter)
        themeLayout.setColumnStretch(2, 1)
        themeLayout.addWidget(QLabel('Dark', self), 1, 3, Qt.AlignHCenter)
        themeLayout.setColumnStretch(4, 1)
        themeGroup = QGroupBox('Theme')
        themeGroup.setLayout(themeLayout)
        mainLayout.addWidget(themeGroup)
        index_leftRadio = QRadioButton('Clips on left')
        index_leftRadio.setToolTip('Display Clip Index on the left hand side')
        index_leftRadio.setCursor(Qt.PointingHandCursor)
        index_leftRadio.setChecked(self.parent.parent.indexLayout == 'left')
        index_rightRadio = QRadioButton('Clips on right')
        index_rightRadio.setToolTip(
            'Display Clip Index on the right hand side')
        index_rightRadio.setCursor(Qt.PointingHandCursor)
        index_rightRadio.setChecked(self.parent.parent.indexLayout == 'right')
        index_buttonGroup = QButtonGroup(self)
        index_buttonGroup.addButton(index_leftRadio, 1)
        index_buttonGroup.addButton(index_rightRadio, 2)
        # noinspection PyUnresolvedReferences
        index_buttonGroup.buttonClicked[int].connect(
            self.parent.parent.setClipIndexLayout)
        indexLayout = QHBoxLayout()
        indexLayout.addWidget(index_leftRadio)
        indexLayout.addWidget(index_rightRadio)
        layoutGroup = QGroupBox('Layout')
        layoutGroup.setLayout(indexLayout)
        mainLayout.addWidget(layoutGroup)
        toolbar_labels = self.parent.settings.value('toolbarLabels',
                                                    'beside',
                                                    type=str)
        toolbar_notextRadio = QRadioButton('No text (buttons only)', self)
        toolbar_notextRadio.setToolTip('No text (buttons only)')
        toolbar_notextRadio.setCursor(Qt.PointingHandCursor)
        toolbar_notextRadio.setChecked(toolbar_labels == 'none')
        toolbar_underRadio = QRadioButton('Text under buttons', self)
        toolbar_underRadio.setToolTip('Text under buttons')
        toolbar_underRadio.setCursor(Qt.PointingHandCursor)
        toolbar_underRadio.setChecked(toolbar_labels == 'under')
        toolbar_besideRadio = QRadioButton('Text beside buttons', self)
        toolbar_besideRadio.setToolTip('Text beside buttons')
        toolbar_besideRadio.setCursor(Qt.PointingHandCursor)
        toolbar_besideRadio.setChecked(toolbar_labels == 'beside')
        toolbar_buttonGroup = QButtonGroup(self)
        toolbar_buttonGroup.addButton(toolbar_besideRadio, 1)
        toolbar_buttonGroup.addButton(toolbar_underRadio, 2)
        toolbar_buttonGroup.addButton(toolbar_notextRadio, 3)
        # noinspection PyUnresolvedReferences
        toolbar_buttonGroup.buttonClicked[int].connect(self.setLabelStyle)
        toolbarLayout = QGridLayout()
        toolbarLayout.addWidget(toolbar_besideRadio, 0, 0)
        toolbarLayout.addWidget(toolbar_underRadio, 0, 1)
        toolbarLayout.addWidget(toolbar_notextRadio, 1, 0)
        toolbarGroup = QGroupBox('Toolbar')
        toolbarGroup.setLayout(toolbarLayout)
        mainLayout.addWidget(toolbarGroup)
        nativeDialogsCheckbox = QCheckBox('Use native dialogs', self)
        nativeDialogsCheckbox.setToolTip('Use native file dialogs')
        nativeDialogsCheckbox.setCursor(Qt.PointingHandCursor)
        nativeDialogsCheckbox.setChecked(self.parent.parent.nativeDialogs)
        nativeDialogsCheckbox.stateChanged.connect(self.setNativeDialogs)
        nativeDialogsLabel = QLabel(
            '''
            <b>ON:</b> use native dialog widgets as provided by your operating system
            <br/>
            <b>OFF:</b> use a generic file open & save dialog widget provided by the Qt toolkit
            <br/><br/>
            <b>NOTE:</b> native dialogs should always be used if working
        ''', self)
        nativeDialogsLabel.setObjectName('nativedialogslabel')
        nativeDialogsLabel.setTextFormat(Qt.RichText)
        nativeDialogsLabel.setWordWrap(True)
        advancedLayout = QVBoxLayout()
        advancedLayout.addWidget(nativeDialogsCheckbox)
        advancedLayout.addWidget(nativeDialogsLabel)
        advancedGroup = QGroupBox('Advanced')
        advancedGroup.setLayout(advancedLayout)
        mainLayout.addWidget(advancedGroup)
        mainLayout.addStretch(1)
        self.setLayout(mainLayout)

    @pyqtSlot(int)
    def setLabelStyle(self, button_id: int) -> None:
        if button_id == 2:
            style = 'under'
        elif button_id == 3:
            style = 'none'
        else:
            style = 'beside'
        self.parent.settings.setValue('toolbarLabels', style)
        self.parent.parent.setToolBarStyle(style)

    @pyqtSlot(int)
    def setNativeDialogs(self, state: int) -> None:
        self.parent.parent.saveSetting('nativeDialogs', state == Qt.Checked)
        self.parent.parent.nativeDialogs = (state == Qt.Checked)

    @pyqtSlot(bool)
    def switchTheme(self) -> None:
        if self.darkRadio.isChecked():
            newtheme = 'dark'
        else:
            newtheme = 'light'
        if newtheme != self.parent.theme:
            # noinspection PyArgumentList
            mbox = QMessageBox(icon=QMessageBox.NoIcon,
                               windowTitle='Restart required',
                               minimumWidth=500,
                               textFormat=Qt.RichText,
                               objectName='genericdialog')
            mbox.setWindowFlags(Qt.Dialog | Qt.WindowCloseButtonHint)
            mbox.setText(
                '''
                <style>
                    h1 {
                        color: %s;
                        font-family: "Futura-Light", sans-serif;
                        font-weight: 400;
                    }
                </style>
                <h1>Warning</h1>
                <p>The application needs to be restarted in order to switch themes. Attempts will be made to reopen
                media files and add back all clip times from your clip index.</p>
                <p>Would you like to restart and switch themes now?</p>''' %
                ('#C681D5' if self.parent.theme == 'dark' else '#642C68'))
            mbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            mbox.setDefaultButton(QMessageBox.Yes)
            response = mbox.exec_()
            if response == QMessageBox.Yes:
                self.parent.settings.setValue('theme', newtheme)
                self.parent.parent.theme = newtheme
                self.parent.parent.parent.reboot()
            else:
                self.darkRadio.setChecked(
                    True
                ) if newtheme == 'light' else self.lightRadio.setChecked(True)
Example #8
0
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.datetime = QDateTime.currentDateTime()
        self.stats_url = ""  #grafana web url

        # connect to sql
        self.conn = psycopg2.connect("host= dbname= user= password="******"SELECT * from benji ORDER BY in_ts DESC LIMIT 1"
        self.cur.execute(sql)
        latest_row = self.cur.fetchone()
        if latest_row[3] == None:
            self.status = 'IN'
            self.confirm_msg = "Latest Status: {}, {}".format(
                self.status, datetime.strftime(latest_row[2],
                                               "%Y-%m-%d-%H:%M"))
        else:
            self.status = 'OUT'
            self.confirm_msg = "Latest Status: {}, {}".format(
                self.status, datetime.strftime(latest_row[3],
                                               "%Y-%m-%d-%H:%M"))

        # get images
        self.img_path = '/img/'
        self.sleep_img = QPixmap(self.img_path + 'sleep.png')
        self.sleepy_img = QPixmap(self.img_path + 'sleepy.png')
        self.awake_img = QPixmap(self.img_path + 'awake.png')
        self.in_img = QPixmap(self.img_path + 'in.png')
        self.out_img = QPixmap(self.img_path + 'out.png')
        self.in_grey_img = QPixmap(self.img_path + 'in_grey.png')
        self.out_grey_img = QPixmap(self.img_path + 'out_grey.png')
        self.time_img = QPixmap(self.img_path + 'time_img.png')
        self.msg_img = QPixmap(self.img_path + 'msg_img.png')
        self.stats_img = QPixmap(self.img_path + 'stats_img.png')

        self.initUI()

    def initUI(self):
        grid = QGridLayout()
        self.setLayout(grid)

        # title_img QLabel
        self.title_img = QLabel()
        self.title_img.setStyleSheet(self.hover_css())
        self.title_img.setAlignment(Qt.AlignCenter)
        grid.addWidget(self.title_img, 0, 0, 1, 3)

        # ts QDateTimeEdit
        time_label = QLabel()
        time_label.setPixmap(self.time_img)
        grid.addWidget(time_label, 1, 0)

        # now_btn QRadioButton
        self.now_btn = QRadioButton('Now')
        self.now_btn.setChecked(True)
        self.now_btn.setCursor(QCursor(Qt.PointingHandCursor))
        grid.addWidget(self.now_btn, 1, 1, 1, 1)

        # manual_btn QRadioButton
        self.manual_btn = QRadioButton('Manually')
        self.manual_btn.setCursor(QCursor(Qt.PointingHandCursor))
        grid.addWidget(self.manual_btn, 1, 2, 1, 1)

        # ts QDateTimeEdit
        self.ts = QDateTimeEdit(self)
        self.ts.setDateTime(self.datetime)
        self.ts.setDateTimeRange(QDateTime(1900, 1, 1, 00, 00, 00),
                                 QDateTime(2100, 1, 1, 00, 00, 00))
        self.ts.setDisplayFormat('yyyy.MM.dd hh:mm')
        grid.addWidget(self.ts, 2, 2, 1, 1)

        # msg label
        msg_label = QLabel()
        msg_label.setPixmap(self.msg_img)
        grid.addWidget(msg_label, 3, 0)

        # msg QTextEdit
        self.msg = QTextEdit()
        self.msg.setStyleSheet(
            "background-color: white; border-radius: 10px; border: 3px solid white;"
        )
        self.msg.installEventFilter(self)
        grid.addWidget(self.msg, 4, 0, 1, 3)

        # in_btn, out_btn Qlabel
        self.in_btn = QLabel()
        self.in_btn.setAlignment(Qt.AlignCenter)
        self.in_btn.setCursor(QCursor(Qt.PointingHandCursor))

        self.out_btn = QLabel()
        self.out_btn.setAlignment(Qt.AlignCenter)
        self.out_btn.setCursor(QCursor(Qt.PointingHandCursor))

        grid.addWidget(self.in_btn, 5, 1)
        grid.addWidget(self.out_btn, 5, 2)

        # stats_btn QLabel
        stats_btn = QLabel()
        stats_btn.setPixmap(self.stats_img)
        stats_btn.setAlignment(Qt.AlignLeft)
        stats_btn.setCursor(QCursor(Qt.PointingHandCursor))
        grid.addWidget(stats_btn, 5, 0)

        # confirm text QLabel
        self.confirmlabel = QLabel(self.confirm_msg, self)
        grid.addWidget(self.confirmlabel, 6, 0, 1, 3)

        # conditional images
        if self.status == 'IN':
            self.in_btn.setPixmap(self.in_grey_img)
            self.out_btn.setPixmap(self.out_img)
            self.title_img.setPixmap(self.awake_img)
        else:
            self.in_btn.setPixmap(self.in_img)
            self.out_btn.setPixmap(self.out_grey_img)
            self.title_img.setPixmap(self.sleep_img)

        ### EVENT ###
        clickable(self.in_btn).connect(self.inCheck)
        clickable(self.out_btn).connect(self.outCheck)
        clickable(stats_btn).connect(self.openWeb)

        self.setWindowTitle('BENJI')
        self.setStyleSheet("background-color: rgb(220,208,255);")
        self.setGeometry(300, 300, 300, 200)
        self.show()

    def eventFilter(self, obj, event):
        if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Return:
            if self.status == 'OUT':
                self.inCheck()
            else:
                self.outCheck()
        return super().eventFilter(obj, event)

    def hover_css(self):
        hover_css_text = "".join([
            "QLabel{min-height:100px;}", "QLabel:hover{image:url(",
            self.img_path, "sleepy.png);}"
        ])
        return hover_css_text

    def inCheck(self):
        self.status = 'IN'
        self.datetime = QDateTime.currentDateTime()
        self.save()

        self.title_img.setPixmap(self.awake_img)
        self.in_btn.setPixmap(self.in_grey_img)
        self.out_btn.setPixmap(self.out_img)

    def outCheck(self):
        self.status = 'OUT'
        self.datetime = QDateTime.currentDateTime()
        self.save()

        self.title_img.setPixmap(self.sleep_img)
        self.out_btn.setPixmap(self.out_grey_img)
        self.in_btn.setPixmap(self.in_img)

    def openWeb(self):
        webbrowser.open(self.stats_url)
Example #9
0
 def __init__(self, parent=None):
     super(VideoPage, self).__init__(parent)
     self.parent = parent
     self.setObjectName('settingsvideopage')
     decodingCheckbox = QCheckBox('Hardware decoding', self)
     decodingCheckbox.setToolTip('Enable hardware based video decoding')
     decodingCheckbox.setCursor(Qt.PointingHandCursor)
     decodingCheckbox.setChecked(self.parent.parent.hardwareDecoding)
     decodingCheckbox.stateChanged.connect(self.switchDecoding)
     decodingLabel = QLabel(
         '''
         <b>ON:</b> saves laptop power + prevents video tearing; falls back to software decoding if your hardware is
         not supported
         <br/>
         <b>OFF:</b> always use software based decoding''', self)
     decodingLabel.setObjectName('decodinglabel')
     decodingLabel.setTextFormat(Qt.RichText)
     decodingLabel.setWordWrap(True)
     pboCheckbox = QCheckBox('Enable use of PBOs', self)
     pboCheckbox.setToolTip('Enable the use of Pixel Buffer Objects (PBOs)')
     pboCheckbox.setCursor(Qt.PointingHandCursor)
     pboCheckbox.setChecked(self.parent.parent.enablePBO)
     pboCheckbox.stateChanged.connect(self.togglePBO)
     pboCheckboxLabel = QLabel(' (recommended for 4K videos)')
     pboCheckboxLabel.setObjectName('checkboxsubtext')
     pboLabel = QLabel(
         '''
         <b>ON:</b> usually improves performance with 4K videos but results in slower performance + latency with
         standard media due to higher memory use
         <br/>
         <b>OFF</b>: this should be your default choice for most media files
     ''', self)
     pboLabel.setObjectName('pbolabel')
     pboLabel.setTextFormat(Qt.RichText)
     pboLabel.setWordWrap(True)
     ratioCheckbox = QCheckBox('Keep aspect ratio', self)
     ratioCheckbox.setToolTip('Keep source video aspect ratio')
     ratioCheckbox.setCursor(Qt.PointingHandCursor)
     ratioCheckbox.setChecked(self.parent.parent.keepRatio)
     ratioCheckbox.stateChanged.connect(self.keepAspectRatio)
     ratioLabel = QLabel(
         '''
         <b>OFF:</b> stretch video to application window size, ignored in fullscreen
         <br/>
         <b>ON:</b> lock video to its set video aspect, black bars added to compensate
     ''', self)
     ratioLabel.setObjectName('ratiolabel')
     ratioLabel.setTextFormat(Qt.RichText)
     ratioLabel.setWordWrap(True)
     videoLayout = QVBoxLayout()
     videoLayout.addWidget(decodingCheckbox)
     videoLayout.addWidget(decodingLabel)
     videoLayout.addLayout(SettingsDialog.lineSeparator())
     pboCheckboxLayout = QHBoxLayout()
     pboCheckboxLayout.setContentsMargins(0, 0, 0, 0)
     pboCheckboxLayout.addWidget(pboCheckbox)
     pboCheckboxLayout.addWidget(pboCheckboxLabel)
     pboCheckboxLayout.addStretch(1)
     videoLayout.addLayout(pboCheckboxLayout)
     videoLayout.addWidget(pboLabel)
     videoLayout.addLayout(SettingsDialog.lineSeparator())
     videoLayout.addWidget(ratioCheckbox)
     videoLayout.addWidget(ratioLabel)
     videoGroup = QGroupBox('Playback')
     videoGroup.setLayout(videoLayout)
     zoomLevel = self.parent.settings.value('videoZoom', 0, type=int)
     zoom_originalRadio = QRadioButton('No zoom [1:1]', self)
     zoom_originalRadio.setToolTip('1/1 No zoom')
     zoom_originalRadio.setCursor(Qt.PointingHandCursor)
     zoom_originalRadio.setChecked(zoomLevel == 0)
     zoom_qtrRadio = QRadioButton('Quarter [1:4]', self)
     zoom_qtrRadio.setToolTip('1/4 Zoom')
     zoom_qtrRadio.setCursor(Qt.PointingHandCursor)
     zoom_qtrRadio.setChecked(zoomLevel == -2)
     zoom_halfRadio = QRadioButton('Half [1:2]', self)
     zoom_halfRadio.setToolTip('1/2 Half')
     zoom_halfRadio.setCursor(Qt.PointingHandCursor)
     zoom_halfRadio.setChecked(zoomLevel == -1)
     zoom_doubleRadio = QRadioButton('Double [2:1]', self)
     zoom_doubleRadio.setToolTip('2/1 Double')
     zoom_doubleRadio.setCursor(Qt.PointingHandCursor)
     zoom_doubleRadio.setChecked(zoomLevel == 1)
     zoom_buttonGroup = QButtonGroup(self)
     zoom_buttonGroup.addButton(zoom_originalRadio, 3)
     zoom_buttonGroup.addButton(zoom_qtrRadio, 1)
     zoom_buttonGroup.addButton(zoom_halfRadio, 2)
     zoom_buttonGroup.addButton(zoom_doubleRadio, 4)
     # noinspection PyUnresolvedReferences
     zoom_buttonGroup.buttonClicked[int].connect(self.setZoom)
     zoomLayout = QGridLayout()
     zoomLayout.addWidget(zoom_originalRadio, 0, 0)
     zoomLayout.addWidget(zoom_qtrRadio, 0, 1)
     zoomLayout.addWidget(zoom_halfRadio, 1, 0)
     zoomLayout.addWidget(zoom_doubleRadio, 1, 1)
     zoomGroup = QGroupBox('Zoom')
     zoomGroup.setLayout(zoomLayout)
     noteLabel = QLabel(
         '<b>NOTE:</b> video settings apply only to video playback and have no affect on the media '
         'files you produce', self)
     noteLabel.setObjectName('zoomlabel')
     noteLabel.setTextFormat(Qt.RichText)
     noteLabel.setWordWrap(True)
     mainLayout = QVBoxLayout()
     mainLayout.setSpacing(15)
     mainLayout.addWidget(videoGroup)
     mainLayout.addWidget(zoomGroup)
     mainLayout.addWidget(noteLabel)
     mainLayout.addStretch(1)
     self.setLayout(mainLayout)