change Button layout, fix issue if no item selected and choose down button

This commit is contained in:
rimach 2012-03-08 23:14:59 +01:00
parent a2e40543ea
commit 499f51bd2b
2 changed files with 137 additions and 771 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver
from openlp.core.lib.ui import UiStrings
from openlp.core.lib.ui import UiStrings, create_up_down_push_button_set
class MediaTab(SettingsTab):
"""
@ -57,7 +57,7 @@ class MediaTab(SettingsTab):
self.leftLayout.addWidget(self.mediaPlayerGroupBox)
self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
self.playerOrderGroupBox.setObjectName(u'playerOrderGroupBox')
self.playerOrderLayout = QtGui.QVBoxLayout(self.playerOrderGroupBox)
self.playerOrderLayout = QtGui.QHBoxLayout(self.playerOrderGroupBox)
self.playerOrderLayout.setObjectName(u'playerOrderLayout')
self.playerOrderlistWidget = QtGui.QListWidget( \
self.playerOrderGroupBox)
@ -76,18 +76,15 @@ class MediaTab(SettingsTab):
QtGui.QAbstractItemView.NoEditTriggers)
self.playerOrderlistWidget.setObjectName(u'playerOrderlistWidget')
self.playerOrderLayout.addWidget(self.playerOrderlistWidget)
self.orderingButtonsWidget = QtGui.QWidget(self.playerOrderGroupBox)
self.orderingButtonsWidget.setObjectName(u'orderingButtonsWidget')
self.orderingButtonLayout = QtGui.QHBoxLayout( \
self.orderingButtonsWidget)
self.orderingButtonLayout = QtGui.QVBoxLayout()
self.orderingButtonLayout.setObjectName(u'orderingButtonLayout')
self.orderingDownButton = QtGui.QPushButton(self.orderingButtonsWidget)
self.orderingDownButton.setObjectName(u'orderingDownButton')
self.orderingButtonLayout.addWidget(self.orderingDownButton)
self.orderingUpButton = QtGui.QPushButton(self.playerOrderGroupBox)
self.orderingUpButton.setObjectName(u'orderingUpButton')
self.orderingButtonLayout.addStretch(1)
self.orderingUpButton, self.orderingDownButton = \
create_up_down_push_button_set(self)
self.orderingButtonLayout.addWidget(self.orderingUpButton)
self.playerOrderLayout.addWidget(self.orderingButtonsWidget)
self.orderingButtonLayout.addWidget(self.orderingDownButton)
self.orderingButtonLayout.addStretch(1)
self.playerOrderLayout.addLayout(self.orderingButtonLayout)
self.leftLayout.addWidget(self.playerOrderGroupBox)
self.advancedGroupBox = QtGui.QGroupBox(self.leftColumn)
self.advancedGroupBox.setObjectName(u'advancedGroupBox')
@ -105,10 +102,6 @@ class MediaTab(SettingsTab):
QtCore.QObject.connect(checkbox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onPlayerCheckBoxChanged)
QtCore.QObject.connect(self.orderingUpButton,
QtCore.SIGNAL(u'pressed()'), self.onOrderingUpButtonPressed)
QtCore.QObject.connect(self.orderingDownButton,
QtCore.SIGNAL(u'pressed()'), self.onOrderingDownButtonPressed)
def retranslateUi(self):
self.mediaPlayerGroupBox.setTitle(
@ -124,10 +117,6 @@ class MediaTab(SettingsTab):
'%s (unavailable)')) % player.name)
self.playerOrderGroupBox.setTitle(
translate('MediaPlugin.MediaTab', 'Player Order'))
self.orderingDownButton.setText(
translate('MediaPlugin.MediaTab', 'Down'))
self.orderingUpButton.setText(
translate('MediaPlugin.MediaTab', 'Up'))
self.advancedGroupBox.setTitle(UiStrings().Advanced)
self.overridePlayerCheckBox.setText(
translate('MediaPlugin.MediaTab',
@ -154,21 +143,23 @@ class MediaTab(SettingsTab):
self.playerCheckBoxes[u'%s' % player].setEnabled(True)
self.playerOrderlistWidget.addItem(player)
def onOrderingUpButtonPressed(self):
currentRow = self.playerOrderlistWidget.currentRow()
if currentRow > 0:
item = self.playerOrderlistWidget.takeItem(currentRow)
self.playerOrderlistWidget.insertItem(currentRow - 1, item)
self.playerOrderlistWidget.setCurrentRow(currentRow - 1)
self.usedPlayers.move(currentRow, currentRow - 1)
def onUpButtonClicked(self):
row = self.playerOrderlistWidget.currentRow()
if row <= 0:
return
item = self.playerOrderlistWidget.takeItem(row)
self.playerOrderlistWidget.insertItem(row - 1, item)
self.playerOrderlistWidget.setCurrentRow(row - 1)
self.usedPlayers.move(row, row - 1)
def onOrderingDownButtonPressed(self):
currentRow = self.playerOrderlistWidget.currentRow()
if currentRow < self.playerOrderlistWidget.count() - 1:
item = self.playerOrderlistWidget.takeItem(currentRow)
self.playerOrderlistWidget.insertItem(currentRow + 1, item)
self.playerOrderlistWidget.setCurrentRow(currentRow + 1)
self.usedPlayers.move(currentRow, currentRow + 1)
def onDownButtonClicked(self):
row = self.playerOrderlistWidget.currentRow()
if row == -1 or row > self.playerOrderlistWidget.count() - 1:
return
item = self.playerOrderlistWidget.takeItem(row)
self.playerOrderlistWidget.insertItem(row + 1, item)
self.playerOrderlistWidget.setCurrentRow(row + 1)
self.usedPlayers.move(row, row + 1)
def load(self):
if self.savedUsedPlayers: