Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

ConfigTool: General Widget update #610

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
84 changes: 43 additions & 41 deletions src/freeseer/frontend/configtool/AVWidget.py
Expand Up @@ -47,29 +47,29 @@ def __init__(self, parent=None):

config_icon = QtGui.QIcon.fromTheme("preferences-system")

self.fontSize = self.font().pixelSize()
self.fontUnit = "px"
if self.fontSize == -1: # Font is set as points, not pixels.
self.fontUnit = "pt"
self.fontSize = self.font().pointSize()
fontSize = self.font().pixelSize()
fontUnit = "px"
if fontSize == -1: # Font is set as points, not pixels.
fontUnit = "pt"
fontSize = self.font().pointSize()

self.boxStyle = "QGroupBox {{ font-weight: bold; font-size: {}{} }}".format(self.fontSize + 1, self.fontUnit)
self.BOX_WIDTH = 400
self.BOX_HEIGHT = 60
boxStyle = "QGroupBox {{ font-weight: bold; font-size: {}{} }}".format(fontSize + 1, fontUnit)
BOX_WIDTH = 400
BOX_HEIGHT = 60

#
# Audio Input
#

self.audioLayout = QtGui.QGridLayout()
audioLayout = QtGui.QGridLayout()
self.audioGroupBox = QtGui.QGroupBox("Audio Input")
self.audioGroupBox.setLayout(self.audioLayout)
self.audioGroupBox.setLayout(audioLayout)
self.mainLayout.insertWidget(0, self.audioGroupBox)

self.audioGroupBox.setCheckable(True)
self.audioGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.audioGroupBox.setFixedSize(self.BOX_WIDTH, self.BOX_HEIGHT)
self.audioGroupBox.setStyleSheet(self.boxStyle)
self.audioGroupBox.setFixedSize(BOX_WIDTH, BOX_HEIGHT)
self.audioGroupBox.setStyleSheet(boxStyle)

self.audioMixerLabel = QtGui.QLabel("Audio Mixer")
self.audioMixerLabel.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
Expand All @@ -80,23 +80,23 @@ def __init__(self, parent=None):
self.audioMixerSetupPushButton.setIcon(config_icon)
self.audioMixerSetupPushButton.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
self.audioMixerSetupPushButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.audioLayout.addWidget(self.audioMixerLabel, 0, 0)
self.audioLayout.addWidget(self.audioMixerComboBox, 0, 1)
self.audioLayout.addWidget(self.audioMixerSetupPushButton, 0, 2)
audioLayout.addWidget(self.audioMixerLabel, 0, 0)
audioLayout.addWidget(self.audioMixerComboBox, 0, 1)
audioLayout.addWidget(self.audioMixerSetupPushButton, 0, 2)

#
# Video Input
#

self.videoLayout = QtGui.QGridLayout()
videoLayout = QtGui.QGridLayout()
self.videoGroupBox = QtGui.QGroupBox("Video Input")
self.videoGroupBox.setLayout(self.videoLayout)
self.videoGroupBox.setLayout(videoLayout)
self.mainLayout.insertWidget(0, self.videoGroupBox)

self.videoGroupBox.setCheckable(True)
self.videoGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.videoGroupBox.setFixedSize(self.BOX_WIDTH, self.BOX_HEIGHT)
self.videoGroupBox.setStyleSheet(self.boxStyle)
self.videoGroupBox.setFixedSize(BOX_WIDTH, BOX_HEIGHT)
self.videoGroupBox.setStyleSheet(boxStyle)

self.videoMixerLabel = QtGui.QLabel("Video Mixer")
self.videoMixerLabel.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
Expand All @@ -107,23 +107,23 @@ def __init__(self, parent=None):
self.videoMixerSetupPushButton.setIcon(config_icon)
self.videoMixerSetupPushButton.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
self.videoMixerSetupPushButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.videoLayout.addWidget(self.videoMixerLabel, 0, 0)
self.videoLayout.addWidget(self.videoMixerComboBox, 0, 1)
self.videoLayout.addWidget(self.videoMixerSetupPushButton, 0, 2)
videoLayout.addWidget(self.videoMixerLabel, 0, 0)
videoLayout.addWidget(self.videoMixerComboBox, 0, 1)
videoLayout.addWidget(self.videoMixerSetupPushButton, 0, 2)

#
# Record to Stream
#

self.streamLayout = QtGui.QGridLayout()
streamLayout = QtGui.QGridLayout()
self.streamGroupBox = QtGui.QGroupBox("Record to Stream")
self.streamGroupBox.setLayout(self.streamLayout)
self.streamGroupBox.setLayout(streamLayout)
self.mainLayout.insertWidget(0, self.streamGroupBox)

self.streamGroupBox.setCheckable(True)
self.streamGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.streamGroupBox.setFixedSize(self.BOX_WIDTH, self.BOX_HEIGHT)
self.streamGroupBox.setStyleSheet(self.boxStyle)
self.streamGroupBox.setFixedSize(BOX_WIDTH, BOX_HEIGHT)
self.streamGroupBox.setStyleSheet(boxStyle)

self.streamLabel = QtGui.QLabel("Stream Format")
self.streamLabel.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
Expand All @@ -134,31 +134,31 @@ def __init__(self, parent=None):
self.streamSetupPushButton.setIcon(config_icon)
self.streamSetupPushButton.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
self.streamSetupPushButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.streamLayout.addWidget(self.streamLabel, 0, 0)
self.streamLayout.addWidget(self.streamComboBox, 0, 1)
self.streamLayout.addWidget(self.streamSetupPushButton, 0, 2)
streamLayout.addWidget(self.streamLabel, 0, 0)
streamLayout.addWidget(self.streamComboBox, 0, 1)
streamLayout.addWidget(self.streamSetupPushButton, 0, 2)

#
# Record to File
#

self.fileLayout = QtGui.QGridLayout()
fileLayout = QtGui.QGridLayout()
self.fileGroupBox = QtGui.QGroupBox("Record to File")
self.fileGroupBox.setLayout(self.fileLayout)
self.fileGroupBox.setLayout(fileLayout)
self.mainLayout.insertWidget(0, self.fileGroupBox)

self.fileGroupBox.setCheckable(True)
self.fileGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.fileGroupBox.setFixedSize(self.BOX_WIDTH, self.BOX_HEIGHT + 40)
self.fileGroupBox.setStyleSheet(self.boxStyle)
self.fileGroupBox.setFixedSize(BOX_WIDTH, BOX_HEIGHT + 40)
self.fileGroupBox.setStyleSheet(boxStyle)

self.fileDirLabel = QtGui.QLabel("Record Directory")
self.fileDirLineEdit = QtGui.QLineEdit()
self.fileDirLabel.setBuddy(self.fileDirLineEdit)
self.fileDirPushButton = QtGui.QPushButton("Browse...")
self.fileLayout.addWidget(self.fileDirLabel, 0, 0)
self.fileLayout.addWidget(self.fileDirLineEdit, 0, 1)
self.fileLayout.addWidget(self.fileDirPushButton, 0, 2)
fileLayout.addWidget(self.fileDirLabel, 0, 0)
fileLayout.addWidget(self.fileDirLineEdit, 0, 1)
fileLayout.addWidget(self.fileDirPushButton, 0, 2)

self.fileLabel = QtGui.QLabel("File Format")
self.fileLabel.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
Expand All @@ -169,13 +169,15 @@ def __init__(self, parent=None):
self.fileSetupPushButton.setIcon(config_icon)
self.fileSetupPushButton.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
self.fileSetupPushButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.fileLayout.addWidget(self.fileLabel, 1, 0)
self.fileLayout.addWidget(self.fileComboBox, 1, 1)
self.fileLayout.addWidget(self.fileSetupPushButton, 1, 2)
fileLayout.addWidget(self.fileLabel, 1, 0)
fileLayout.addWidget(self.fileComboBox, 1, 1)
fileLayout.addWidget(self.fileSetupPushButton, 1, 2)

# Blank line
self.mainLayout.insertSpacerItem(0, QtGui.QSpacerItem(0, self.fontSize * 2))
#
# Heading
#

self.mainLayout.insertSpacerItem(0, QtGui.QSpacerItem(0, fontSize * 2))
self.title = QtGui.QLabel(u"{0} Recording {1}".format(u'<h1>', u'</h1>'))
self.mainLayout.insertWidget(0, self.title)

Expand Down
83 changes: 63 additions & 20 deletions src/freeseer/frontend/configtool/GeneralWidget.py
Expand Up @@ -44,34 +44,77 @@ def __init__(self, parent=None):
self.mainLayout.addStretch(0)
self.setLayout(self.mainLayout)

self.fontSize = self.font().pixelSize()
self.fontUnit = "px"
if self.fontSize == -1: # Font is set as points, not pixels.
self.fontUnit = "pt"
self.fontSize = self.font().pointSize()
fontSize = self.font().pixelSize()
fontUnit = "px"
if fontSize == -1: # Font is set as points, not pixels.
fontUnit = "pt"
fontSize = self.font().pointSize()

boxStyle = "QGroupBox {{ font-weight: bold; font-size: {}{} }}".format(fontSize + 1, fontUnit)
BOX_WIDTH = 400
BOX_HEIGHT = 60

#
# General
# Heading
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't like the existing style for "section headers", but since they're there this one should be consistent with them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtomwing do you mean you don't like the styling that #574 introduced? If so, what about it specifically?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dideler I think he meant the

Section header

where my code was

Heading

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. The style code was right above the commented line, so that confused me.

#

self.boxStyle = "QGroupBox {{ font-weight: bold; font-size: {}{} }}".format(self.fontSize + 1, self.fontUnit)
self.miscLayout = QtGui.QVBoxLayout()
self.miscGroupBox = QtGui.QGroupBox("General")
self.miscGroupBox.setLayout(self.miscLayout)
self.miscGroupBox.setStyleSheet(self.boxStyle)
self.mainLayout.insertWidget(0, self.miscGroupBox)
self.title = QtGui.QLabel(u"{0} General {1}".format(u'<h1>', u'</h1>'))
self.mainLayout.insertWidget(0, self.title)
self.mainLayout.insertSpacerItem(1, QtGui.QSpacerItem(0, fontSize * 2))

#
# Language
#

self.languageLayout = QtGui.QHBoxLayout()
self.miscLayout.addLayout(self.languageLayout)
self.languageLabel = QtGui.QLabel("Default Language")
languageBoxLayout = QtGui.QVBoxLayout()
self.languageGroupBox = QtGui.QGroupBox("Language")
self.languageGroupBox.setLayout(languageBoxLayout)
self.languageGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.languageGroupBox.setFixedSize(BOX_WIDTH, BOX_HEIGHT)
self.languageGroupBox.setStyleSheet(boxStyle)
self.mainLayout.insertWidget(2, self.languageGroupBox)

languageLayout = QtGui.QHBoxLayout()
languageBoxLayout.addLayout(languageLayout)
self.translateButton = QtGui.QPushButton("Help us translate")
self.languageComboBox = QtGui.QComboBox()
self.languageComboBox.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.languageLabel.setBuddy(self.languageComboBox)
self.languageLayout.addWidget(self.languageLabel)
self.languageLayout.addWidget(self.languageComboBox)
languageLayout.addWidget(self.languageComboBox, 2)
languageLayout.addSpacerItem(QtGui.QSpacerItem(40, 0))
languageLayout.addWidget(self.translateButton, 1)

#
# Appearance
#

appearanceBoxLayout = QtGui.QVBoxLayout()
self.appearanceGroupBox = QtGui.QGroupBox("Appearance")
self.appearanceGroupBox.setLayout(appearanceBoxLayout)
self.appearanceGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.appearanceGroupBox.setFixedSize(BOX_WIDTH, BOX_HEIGHT)
self.appearanceGroupBox.setStyleSheet(boxStyle)
self.mainLayout.insertWidget(3, self.appearanceGroupBox)

self.autoHideCheckBox = QtGui.QCheckBox("Enable Auto-Hide")
self.miscLayout.addWidget(self.autoHideCheckBox)
self.autoHideCheckBox = QtGui.QCheckBox("Auto-Hide to system tray on record")
appearanceBoxLayout.addWidget(self.autoHideCheckBox)

#
# Reset
#

resetBoxLayout = QtGui.QVBoxLayout()
self.resetGroupBox = QtGui.QGroupBox("Reset")
self.resetGroupBox.setLayout(resetBoxLayout)
self.resetGroupBox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.resetGroupBox.setFixedSize(BOX_WIDTH / 2, BOX_HEIGHT)
self.resetGroupBox.setStyleSheet(boxStyle)
self.mainLayout.addWidget(self.resetGroupBox)
self.mainLayout.addSpacerItem(QtGui.QSpacerItem(0, 20))

resetLayout = QtGui.QHBoxLayout()
resetBoxLayout.addLayout(resetLayout)
self.resetButton = QtGui.QPushButton("Reset settings to defaults")
resetLayout.addWidget(self.resetButton)

if __name__ == "__main__":
import sys
Expand Down
70 changes: 51 additions & 19 deletions src/freeseer/frontend/configtool/configtool.py
Expand Up @@ -120,10 +120,9 @@ def __init__(self, profile, config):
# general tab connections
#
self.connect(self.generalWidget.languageComboBox, QtCore.SIGNAL('currentIndexChanged(int)'), self.set_default_language)
self.connect(self.avWidget.fileDirPushButton, QtCore.SIGNAL('clicked()'), self.browse_video_directory)
self.connect(self.avWidget.fileDirLineEdit, QtCore.SIGNAL('editingFinished()'), self.update_record_directory)
self.connect(self.generalWidget.autoHideCheckBox, QtCore.SIGNAL('toggled(bool)'), self.toggle_autohide)

self.connect(self.generalWidget.translateButton, QtCore.SIGNAL('clicked()'), self.open_translate_url)
self.connect(self.generalWidget.resetButton, QtCore.SIGNAL('clicked()'), self.confirm_reset)
#
# AV tab connections
#
Expand All @@ -134,6 +133,8 @@ def __init__(self, profile, config):
self.connect(self.avWidget.videoMixerComboBox, QtCore.SIGNAL('activated(const QString&)'), self.change_videomixer)
self.connect(self.avWidget.videoMixerSetupPushButton, QtCore.SIGNAL('clicked()'), self.setup_video_mixer)
self.connect(self.avWidget.fileGroupBox, QtCore.SIGNAL('toggled(bool)'), self.toggle_record_to_file)
self.connect(self.avWidget.fileDirPushButton, QtCore.SIGNAL('clicked()'), self.browse_video_directory)
self.connect(self.avWidget.fileDirLineEdit, QtCore.SIGNAL('editingFinished()'), self.update_record_directory)
self.connect(self.avWidget.fileComboBox, QtCore.SIGNAL('activated(const QString&)'), self.change_file_format)
self.connect(self.avWidget.fileSetupPushButton, QtCore.SIGNAL('clicked()'), self.setup_file_format)
self.connect(self.avWidget.streamGroupBox, QtCore.SIGNAL('toggled(bool)'), self.toggle_record_to_stream)
Expand Down Expand Up @@ -168,6 +169,15 @@ def __init__(self, profile, config):
def retranslate(self):
self.setWindowTitle(self.app.translate("ConfigToolApp", "Freeseer ConfigTool"))

#
# Reusable Strings
#
self.confirmResetDefaultsTitleString = self.app.translate("ConfigToolApp", "Freeseer")
self.confirmResetDefaultsQuestionString = self.app.translate(
"ConfigToolApp",
"Your Freeseer settings will be restored to their original defaults.")
# --- End Reusable Strings

#
# Menu
#
Expand Down Expand Up @@ -196,9 +206,12 @@ def retranslate(self):
#
# GeneralWidget
#
self.generalWidget.miscGroupBox.setTitle(self.app.translate("ConfigToolApp", "Miscellaneous"))
self.generalWidget.languageLabel.setText(self.app.translate("ConfigToolApp", "Default Language"))
self.generalWidget.autoHideCheckBox.setText(self.app.translate("ConfigToolApp", "Enable Auto-Hide"))
self.generalWidget.languageGroupBox.setTitle(self.app.translate("ConfigToolApp", "Language"))
self.generalWidget.translateButton.setText(self.app.translate("ConfigToolApp", "Help us translate"))
self.generalWidget.appearanceGroupBox.setTitle(self.app.translate("ConfigToolApp", "Appearance"))
self.generalWidget.autoHideCheckBox.setText(self.app.translate("ConfigToolApp", "Auto-Hide to system tray on record"))
self.generalWidget.resetGroupBox.setTitle(self.app.translate("ConfigToolApp", "Reset"))
self.generalWidget.resetButton.setText(self.app.translate("ConfigToolApp", "Reset settings to defaults"))
# --- End GeneralWidget

#
Expand Down Expand Up @@ -289,20 +302,24 @@ def set_default_language(self, language):
self.config.default_language = language_file
self.config.save()

def browse_video_directory(self):
directory = self.avWidget.fileDirLineEdit.text()
def open_translate_url(self):
url = QtCore.QUrl("http://freeseer.readthedocs.org/en/latest/contribute/translation.html")
QtGui.QDesktopServices.openUrl(url)

newDir = QtGui.QFileDialog.getExistingDirectory(self, "Select Video Directory", directory)
if newDir == "":
newDir = directory

videodir = os.path.abspath(str(newDir))
self.avWidget.fileDirLineEdit.setText(videodir)
self.avWidget.fileDirLineEdit.emit(QtCore.SIGNAL("editingFinished()"))

def update_record_directory(self):
self.config.videodir = str(self.avWidget.fileDirLineEdit.text())
self.config.save()
def confirm_reset(self):
"""Presents a confirmation dialog to ask the user if they are sure they wish to reset all settings.
If confirmed, reset the settings in this profile to default
"""
confirm = QMessageBox.question(self,
self.confirmResetDefaultsTitleString,
self.confirmResetDefaultsQuestionString,
QMessageBox.Ok | QMessageBox.Cancel,
QMessageBox.Cancel)

if confirm == QMessageBox.Ok:
self.config.set_defaults()
self.config.save()
self.load_general_widget()

def toggle_autohide(self, state):
self.config.auto_hide = state
Expand Down Expand Up @@ -431,6 +448,21 @@ def toggle_record_to_file(self, state):
self.config.record_to_file = state
self.config.save()

def browse_video_directory(self):
directory = self.avWidget.fileDirLineEdit.text()

new_dir = QtGui.QFileDialog.getExistingDirectory(self, "Select Video Directory", directory)
if not new_dir:
new_dir = directory

videodir = os.path.abspath(str(new_dir))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtomwing should this videodir variable be renamed to video_dir? The reason I'm unsure is that it sort of mirrors the videodir variable in the config profile class referenced below with "self.config.videodir".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

videodir seems fine.

self.avWidget.fileDirLineEdit.setText(videodir)
self.avWidget.fileDirLineEdit.emit(QtCore.SIGNAL("editingFinished()"))

def update_record_directory(self):
self.config.videodir = str(self.avWidget.fileDirLineEdit.text())
self.config.save()

def change_file_format(self, format):
self.config.record_to_file_plugin = format
self.config.save()
Expand Down