forked from openlp/openlp
Fix tabbed source select gui size
This commit is contained in:
parent
4b64e24e36
commit
c42af376cc
@ -897,10 +897,12 @@ class PJLink1(QTcpSocket):
|
||||
|
||||
:param src: Video source to select in projector
|
||||
"""
|
||||
log.debug('(%s) set_input_source(src=%s)' % (self.ip, src))
|
||||
if self.source_available is None:
|
||||
return
|
||||
elif src not in self.source_available:
|
||||
return
|
||||
log.debug('(%s) Setting input source to %s' % (self.ip, src))
|
||||
self.send_command(cmd='INPT', opts=src)
|
||||
self.poll_loop()
|
||||
|
||||
|
@ -250,12 +250,14 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm):
|
||||
self.editProjector.emit(self.projector)
|
||||
self.close()
|
||||
|
||||
@pyqtSlot()
|
||||
def help_me(self):
|
||||
"""
|
||||
Show a help message about the input fields.
|
||||
"""
|
||||
log.debug('help_me() signal received')
|
||||
|
||||
@pyqtSlot()
|
||||
def cancel_me(self):
|
||||
"""
|
||||
Cancel button clicked - just close.
|
||||
|
@ -353,14 +353,16 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
||||
"""
|
||||
list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow())
|
||||
projector = list_item.data(QtCore.Qt.UserRole)
|
||||
|
||||
# Testing tabwidget for source select
|
||||
# QTabwidget for source select
|
||||
source_select_form = SourceSelectDialog(parent=self,
|
||||
projectordb=self.projectordb)
|
||||
|
||||
source = source_select_form.exec_(projector.link)
|
||||
log.debug('(%s) source_select_form() returned %s' % (projector.link.ip, source))
|
||||
if source is not None and source > 0:
|
||||
projector.link.set_input_source(str(source))
|
||||
return
|
||||
|
||||
# QDialog for source select - Delete when QTabWidget finished
|
||||
layout = QtGui.QVBoxLayout()
|
||||
box = QtGui.QDialog(parent=self)
|
||||
box.setModal(True)
|
||||
|
@ -40,7 +40,7 @@ from PyQt4.QtCore import pyqtSlot, pyqtSignal
|
||||
from PyQt4.QtGui import QDialog, QButtonGroup, QDialogButtonBox, QGroupBox, QRadioButton, \
|
||||
QTabBar, QTabWidget, QVBoxLayout, QWidget
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.core.common import translate, is_macosx
|
||||
from openlp.core.lib import build_icon
|
||||
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_SOURCES
|
||||
|
||||
@ -50,11 +50,14 @@ def source_group(inputs, source_text):
|
||||
Return a dictionary where key is source[0] and values are inputs
|
||||
grouped by source[0].
|
||||
ex:
|
||||
dict{"1": "11 12 13 14 15",
|
||||
"2": "21 22 23 24 25",
|
||||
dict{ "key": { "key1": source_text[key1],
|
||||
"key2": source_text[key2],
|
||||
"key3": source_text[key3],
|
||||
... }
|
||||
"key": ... }
|
||||
|
||||
:param inputs: List of inputs
|
||||
:param source_text: Dictionary of {code: text} values to display
|
||||
:returns: dict
|
||||
"""
|
||||
groupdict = {}
|
||||
@ -78,10 +81,15 @@ def Build_Tab(group, source_key, default):
|
||||
Create the radio button page for a tab.
|
||||
Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
|
||||
|
||||
source_key: { group: { code: string,
|
||||
code: string,
|
||||
source_key: {"groupkey1": {"key1": string,
|
||||
"key2": string,
|
||||
...
|
||||
},
|
||||
"groupkey2": {"key1": string,
|
||||
"key2": string
|
||||
....
|
||||
},
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
:param group: Button group widget to add buttons to
|
||||
@ -95,6 +103,7 @@ def Build_Tab(group, source_key, default):
|
||||
tempkey = list(source_key.keys())[0] # Should only be 1 key
|
||||
sourcelist = list(source_key[tempkey])
|
||||
sourcelist.sort()
|
||||
button_count = len(sourcelist)
|
||||
for key in sourcelist:
|
||||
itemwidget = QRadioButton(source_key[tempkey][key])
|
||||
itemwidget.setAutoExclusive(True)
|
||||
@ -103,7 +112,7 @@ def Build_Tab(group, source_key, default):
|
||||
group.addButton(itemwidget, int(key))
|
||||
layout.addWidget(itemwidget)
|
||||
layout.addStretch()
|
||||
return widget
|
||||
return (widget, button_count)
|
||||
|
||||
|
||||
class SourceSelectDialog(QDialog):
|
||||
@ -122,14 +131,16 @@ class SourceSelectDialog(QDialog):
|
||||
self.setWindowTitle(translate('OpenLP.SourceSelectDialog', 'Select Projector Source'))
|
||||
self.setObjectName('source_select_dialog')
|
||||
self.setWindowIcon(build_icon(':/icon/openlp-log-32x32.png'))
|
||||
self.setMinimumWidth(300)
|
||||
self.setMinimumHeight(400)
|
||||
self.setModal(True)
|
||||
|
||||
self.button_count = 0 # Maximum number of buttons in a single page
|
||||
self.layout = QVBoxLayout()
|
||||
self.layout.setObjectName('source_select_dialog_layout')
|
||||
self.tabwidget = QTabWidget(self)
|
||||
self.tabwidget.setObjectName('source_select_dialog_tabwidget')
|
||||
self.tabwidget.setUsesScrollButtons(False)
|
||||
if is_macosx():
|
||||
self.tabwidget.setTabPosition(QTabWidget.North)
|
||||
else:
|
||||
self.tabwidget.setTabPosition(QTabWidget.West)
|
||||
self.layout.addWidget(self.tabwidget)
|
||||
self.setLayout(self.layout)
|
||||
@ -145,24 +156,31 @@ class SourceSelectDialog(QDialog):
|
||||
projector.model,
|
||||
projector.source_available)
|
||||
self.source_group = source_group(projector.source_available, self.source_text)
|
||||
# self.source_group = {'4': {'41': 'Storage 1'}, '5': {"51": 'Network 1'}}
|
||||
self.button_group = QButtonGroup()
|
||||
keys = list(self.source_group.keys())
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
self.tabwidget.addTab(Build_Tab(group=self.button_group,
|
||||
(tab, button_count) = Build_Tab(group=self.button_group,
|
||||
source_key={key: self.source_group[key]},
|
||||
default=self.projector.source), PJLINK_DEFAULT_SOURCES[key])
|
||||
button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
|
||||
default=self.projector.source)
|
||||
self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
|
||||
self.button_count = self.button_count if self.button_count > button_count else button_count
|
||||
self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
|
||||
QtGui.QDialogButtonBox.Cancel)
|
||||
button_box.accepted.connect(self.accepted)
|
||||
button_box.rejected.connect(self.rejected)
|
||||
self.layout.addWidget(button_box)
|
||||
self.button_box.accepted.connect(self.accept_me)
|
||||
self.button_box.rejected.connect(self.reject_me)
|
||||
self.layout.addWidget(self.button_box)
|
||||
selected = super(SourceSelectDialog, self).exec_()
|
||||
return selected
|
||||
|
||||
def accepted(self):
|
||||
self.accept()
|
||||
return projector.set_input_source(self.button_group.checkedId())
|
||||
@pyqtSlot()
|
||||
def accept_me(self):
|
||||
selected = self.button_group.checkedId()
|
||||
log.debug('SourceSelectDialog().accepted() Setting source to %s' % selected)
|
||||
self.done(selected)
|
||||
|
||||
def rejected(self):
|
||||
self.reject()
|
||||
return 0
|
||||
@pyqtSlot()
|
||||
def reject_me(self):
|
||||
log.debug('SourceSelectDialog() - Rejected')
|
||||
self.done(0)
|
||||
|
Loading…
Reference in New Issue
Block a user