self._controlLayout.addWidget(self._message, 1000)
self._controlLayout.addWidget(self._closeLabel, 1, QtCore.Qt.AlignCenter)
- self._topLevelLayout = QtGui.QHBoxLayout()
- self._topLevelLayout.addLayout(self._controlLayout)
self._widget = QtGui.QWidget()
- self._widget.setLayout(self._topLevelLayout)
+ self._widget.setLayout(self._controlLayout)
self._widget.hide()
@property
class QHtmlDelegate(QtGui.QStyledItemDelegate):
- # @bug Not showing all of a message
+ UNDEFINED_SIZE = -1
+
+ def __init__(self, *args, **kwd):
+ QtGui.QStyledItemDelegate.__init__(*((self, ) + args), **kwd)
+ self._width = self.UNDEFINED_SIZE
def paint(self, painter, option, index):
newOption = QtGui.QStyleOptionViewItemV4(option)
doc.documentLayout().draw(painter, ctx)
painter.restore()
+ def setWidth(self, width, model):
+ if self._width == width:
+ return
+ self._width = width
+ for c in xrange(model.rowCount()):
+ cItem = model.item(c, 0)
+ for r in xrange(model.rowCount()):
+ rItem = cItem.child(r, 0)
+ rIndex = model.indexFromItem(rItem)
+ self.sizeHintChanged.emit(rIndex)
+ return
+
def sizeHint(self, option, index):
newOption = QtGui.QStyleOptionViewItemV4(option)
self.initStyleOption(newOption, index)
doc = QtGui.QTextDocument()
doc.setHtml(newOption.text)
- doc.setTextWidth(newOption.rect.width())
+ if self._width != self.UNDEFINED_SIZE:
+ width = self._width
+ else:
+ width = newOption.rect.width()
+ doc.setTextWidth(width)
size = QtCore.QSize(doc.idealWidth(), doc.size().height())
return size
+class QSignalingMainWindow(QtGui.QMainWindow):
+
+ closed = QtCore.pyqtSignal()
+ hidden = QtCore.pyqtSignal()
+ shown = QtCore.pyqtSignal()
+
+ def __init__(self, *args, **kwd):
+ QtGui.QMainWindow.__init__(*((self, )+args), **kwd)
+
+ def closeEvent(self, event):
+ QtGui.QMainWindow.closeEvent(self, event)
+ self.closed.emit()
+
+ def hideEvent(self, event):
+ QtGui.QMainWindow.hideEvent(self, event)
+ self.hidden.emit()
+
+ def showEvent(self, event):
+ QtGui.QMainWindow.showEvent(self, event)
+ self.shown.emit()
+
+
def _null_set_stackable(window, isStackable):
pass
def _maemo_set_autorient(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
+ window.setAttribute(QtCore.Qt.WA_Maemo5AutoOrientation, isStackable)
try:
set_autorient = _null_set_autorient
-def _null_set_landscape(window, isStackable):
- pass
-
-
-def _maemo_set_landscape(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
-
-
-try:
- QtCore.Qt.WA_Maemo5LandscapeOrientation
- set_landscape = _maemo_set_landscape
-except AttributeError:
- set_landscape = _null_set_landscape
+def screen_orientation():
+ geom = QtGui.QApplication.desktop().screenGeometry()
+ if geom.width() <= geom.height():
+ return QtCore.Qt.Vertical
+ else:
+ return QtCore.Qt.Horizontal
-def _null_set_portrait(window, isStackable):
+def _null_set_window_orientation(window, orientation):
pass
-def _maemo_set_portrait(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
+def _maemo_set_window_orientation(window, orientation):
+ if orientation == QtCore.Qt.Vertical:
+ oldHint = QtCore.Qt.WA_Maemo5LandscapeOrientation
+ newHint = QtCore.Qt.WA_Maemo5PortraitOrientation
+ elif orientation == QtCore.Qt.Horizontal:
+ oldHint = QtCore.Qt.WA_Maemo5PortraitOrientation
+ newHint = QtCore.Qt.WA_Maemo5LandscapeOrientation
+ window.setAttribute(oldHint, False)
+ window.setAttribute(newHint, True)
try:
+ QtCore.Qt.WA_Maemo5LandscapeOrientation
QtCore.Qt.WA_Maemo5PortraitOrientation
- set_portrait = _maemo_set_portrait
+ set_window_orientation = _maemo_set_window_orientation
except AttributeError:
- set_portrait = _null_set_portrait
+ set_window_orientation = _null_set_window_orientation
def _null_show_progress_indicator(window, isStackable):
def _maemo_show_progress_indicator(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
+ window.setAttribute(QtCore.Qt.WA_Maemo5ShowProgressIndicator, isStackable)
try:
mark_numbers_preferred = _null_mark_numbers_preferred
-def screen_orientation():
- geom = QtGui.QApplication.desktop().screenGeometry()
- if geom.width() <= geom.height():
- return QtCore.Qt.Vertical
- else:
- return QtCore.Qt.Horizontal
-
-
def _null_get_theme_icon(iconNames, fallback = None):
icon = fallback if fallback is not None else QtGui.QIcon()
return icon