def doLayout(self, rect, testOnly=False): """ """ x = rect.x() y = rect.y() lineHeight = 0 for item in self.itemList: wid = item.widget() spaceX = self.spacing() + wid.style().layoutSpacing( QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Horizontal) spaceY = self.spacing() + wid.style().layoutSpacing( QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Vertical) nextX = x + item.sizeHint().width() + spaceX if nextX - spaceX > rect.right() and lineHeight > 0: x = rect.x() y = y + lineHeight + spaceY nextX = x + item.sizeHint().width() + spaceX lineHeight = 0 if not testOnly: item.setGeometry( QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint())) x = nextX lineHeight = max(lineHeight, item.sizeHint().height()) return y + lineHeight - rect.y()
def sobj_tab_middle_mouse_event(self, event): if event.button() == QtCore.Qt.MouseButton.MiddleButton: pos = event.pos() # This is because hamburger button tab_pos = self.sObjTabWidget.tabBar().tabAt( QtCore.QPoint(pos.x() - 26, pos.y())) if tab_pos != -1: widget = self.sObjTabWidget.widget(tab_pos) tab = self.get_stype_tab_by_widget(widget) self.toggle_stype_tab(tab=tab, hide=True) tree_item = self.get_tree_item_by_code(tab.get_tab_code()) if tree_item: tree_item.setCheckState(0, QtCore.Qt.Unchecked) event.accept()
def readSettings(self): """ Reading Settings """ self.settings.beginGroup('ui_maya_dock') self.docked = bool(int(self.settings.value('docked', 1))) self.dock_pos = self.settings.value('dock_pos', QtCore.QPoint(200, 200)) if self.docked: self.move(self.dock_pos) self.dock_is_floating = bool( int(self.settings.value('dock_isFloating', 0))) self.dock_size = self.settings.value('dock_size', QtCore.QSize(427, 690)) if int(self.settings.value('dock_tabArea', 1)) == 2: self.dock_area = 'right' else: self.dock_area = 'left' self.settings.endGroup()
def create_scene(self): self.scene.clear() # self.scene.setBackgroundBrush(QtCore.Qt.black) self.pm1 = Pixmap() self.pm2 = Pixmap() self.pm3 = Pixmap() self.scene.addItem(self.pm1.pixmap_item) self.scene.addItem(self.pm2.pixmap_item) self.scene.addItem(self.pm3.pixmap_item) # animation self.machine = QtCore.QStateMachine() self.state1 = QtCore.QState(self.machine) self.state2 = QtCore.QState(self.machine) self.state3 = QtCore.QState(self.machine) self.state1.assignProperty(self.pm1, 'pos', QtCore.QPoint(0, 0)) self.state1.assignProperty(self.pm1, 'opacity', 1) self.state2.assignProperty(self.pm1, 'pos', QtCore.QPoint(-255, 0)) self.state2.assignProperty(self.pm1, 'opacity', 0) self.state3.assignProperty(self.pm1, 'pos', QtCore.QPoint(255, 0)) self.state3.assignProperty(self.pm1, 'opacity', 0) self.state1.assignProperty(self.pm2, 'pos', QtCore.QPoint(255, 0)) self.state1.assignProperty(self.pm2, 'opacity', 0) self.state2.assignProperty(self.pm2, 'pos', QtCore.QPoint(0, 0)) self.state2.assignProperty(self.pm2, 'opacity', 1) self.state3.assignProperty(self.pm2, 'pos', QtCore.QPoint(-255, 0)) self.state3.assignProperty(self.pm2, 'opacity', 0) self.state1.assignProperty(self.pm3, 'pos', QtCore.QPoint(-255, 0)) self.state1.assignProperty(self.pm3, 'opacity', 0) self.state2.assignProperty(self.pm3, 'pos', QtCore.QPoint(255, 0)) self.state2.assignProperty(self.pm3, 'opacity', 0) self.state3.assignProperty(self.pm3, 'pos', QtCore.QPoint(0, 0)) self.state3.assignProperty(self.pm3, 'opacity', 1) self.machine.setInitialState(self.state1) self.pm1_anm = QtCore.QPropertyAnimation(self.pm1, 'pos', self) self.pm1_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.pm1_anm.setDuration(300) self.pm1_anm_o = QtCore.QPropertyAnimation(self.pm1, 'opacity', self) self.pm1_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.pm1_anm_o.setDuration(200) self.pm2_anm = QtCore.QPropertyAnimation(self.pm2, 'pos', self) self.pm2_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.pm2_anm.setDuration(300) self.pm2_anm_o = QtCore.QPropertyAnimation(self.pm2, 'opacity', self) self.pm2_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.pm2_anm_o.setDuration(200) self.pm3_anm = QtCore.QPropertyAnimation(self.pm3, 'pos', self) self.pm3_anm.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.pm3_anm.setDuration(300) self.pm3_anm_o = QtCore.QPropertyAnimation(self.pm3, 'opacity', self) self.pm3_anm_o.setEasingCurve(QtCore.QEasingCurve.OutExpo) self.pm3_anm_o.setDuration(200) self.t4 = self.state1.addTransition(self.value_decreased, self.state3) self.t4.addAnimation(self.pm1_anm) self.t4.addAnimation(self.pm1_anm_o) self.t4.addAnimation(self.pm2_anm) self.t4.addAnimation(self.pm2_anm_o) self.t4.addAnimation(self.pm3_anm) self.t4.addAnimation(self.pm3_anm_o) self.t5 = self.state2.addTransition(self.value_decreased, self.state1) self.t5.addAnimation(self.pm1_anm) self.t5.addAnimation(self.pm1_anm_o) self.t5.addAnimation(self.pm2_anm) self.t5.addAnimation(self.pm2_anm_o) self.t5.addAnimation(self.pm3_anm) self.t5.addAnimation(self.pm3_anm_o) self.t6 = self.state3.addTransition(self.value_decreased, self.state2) self.t6.addAnimation(self.pm1_anm) self.t6.addAnimation(self.pm1_anm_o) self.t6.addAnimation(self.pm2_anm) self.t6.addAnimation(self.pm2_anm_o) self.t6.addAnimation(self.pm3_anm) self.t6.addAnimation(self.pm3_anm_o) self.t1 = self.state1.addTransition(self.value_increased, self.state2) self.t1.addAnimation(self.pm1_anm) self.t1.addAnimation(self.pm1_anm_o) self.t1.addAnimation(self.pm2_anm) self.t1.addAnimation(self.pm2_anm_o) self.t1.addAnimation(self.pm3_anm) self.t1.addAnimation(self.pm3_anm_o) self.t2 = self.state2.addTransition(self.value_increased, self.state3) self.t2.addAnimation(self.pm1_anm) self.t2.addAnimation(self.pm1_anm_o) self.t2.addAnimation(self.pm2_anm) self.t2.addAnimation(self.pm2_anm_o) self.t2.addAnimation(self.pm3_anm) self.t2.addAnimation(self.pm3_anm_o) self.t3 = self.state3.addTransition(self.value_increased, self.state1) self.t3.addAnimation(self.pm1_anm) self.t3.addAnimation(self.pm1_anm_o) self.t3.addAnimation(self.pm2_anm) self.t3.addAnimation(self.pm2_anm_o) self.t3.addAnimation(self.pm3_anm) self.t3.addAnimation(self.pm3_anm_o) # initial fill if self.pix_list: self.pm_list = [self.pm1, self.pm2, self.pm3] for i, pm in enumerate(self.pm_list): pm.add_pixmap(self.pix_list[i % len(self.pix_list)]) self.previewGraphicsView.setSceneRect(self.pm1.pixmap_item.boundingRect()) self.previewGraphicsView.fitInView(self.pm1.pixmap_item.boundingRect(), QtCore.Qt.KeepAspectRatio) self.imagesSlider.setValue(0)