def destroyMessageOverlay(self): if self.messageDialog != None: #Plasma::locationToInverseDirection(q->location()) self.messageDialog.animatedHide(Plasma.Direction(0)) self.messageDialog.deleteLater() self.messageDialog.hide() self.messageDialog = None self.showPopup(0) if self.messageOverlay == None: return self.messageOverlay.hide() self.messageOverlay = None
def showModalWidget(self, mainWidget): #mainWidget.widgetClose.connect(self.destroyMessageOverlay) if self.messageOverlay: return if self.messageDialog: return corona = self.scene() mainWidget.adjustSize() hint = mainWidget.preferredSize() if (hint.height() > self.widget.size().height()) or ( hint.width() > self.widget.size().width()): ## either a collapsed popup in h/v form factor or just too small, ## so show it in a dialog associated with ourselves #pass if (corona): corona.addOffscreenWidget(mainWidget) if (self.messageDialog): pass else: self.messageDialog = Plasma.Dialog() self.messageDialog.setGraphicsWidget(mainWidget) mainWidget.setParentItem(self.messageDialog.graphicsWidget()) else: self.messageOverlay = self.createMessageOverlay() self.formatOverlay() self.messageOverlay.opacity = 0.8 mainWidget.setParentItem(self.messageOverlay) l = QGraphicsLinearLayout(self.messageOverlay) l.addItem(mainWidget) if self.messageDialog: pos = self.geometry().topLeft().toPoint() if (corona): pos = corona.popupPosition(self.applet, self.messageDialog.size()) self.messageDialog.move(pos) #self.locationToDirection(self.location()) self.messageDialog.animatedShow(Plasma.Direction(0)) self.hidePopup() else: self.messageOverlay.show()