MCPcopy Create free account
hub / github.com/PyQt5/PyQtClient / _resizeWidget

Method _resizeWidget

Widgets/FramelessWindow.py:148–209  ·  view source on GitHub ↗
(self, pos)

Source from the content-addressed store, hash-verified

146 super(FramelessWindow, self).move(pos)
147
148 def _resizeWidget(self, pos):
149 # 调整窗口大小
150 if self.Direction == None:
151 return
152 mpos = pos - self._pos
153 xPos, yPos = mpos.x(), mpos.y()
154 geometry = self.geometry()
155 x, y, w, h = geometry.x(), geometry.y(), geometry.width(
156 ), geometry.height()
157 if self.Direction == LeftTop: # 左上角
158 if w - xPos > self.minimumWidth():
159 x += xPos
160 w -= xPos
161 if h - yPos > self.minimumHeight():
162 y += yPos
163 h -= yPos
164 elif self.Direction == RightBottom: # 右下角
165 if w + xPos > self.minimumWidth():
166 w += xPos
167 self._pos = pos
168 if h + yPos > self.minimumHeight():
169 h += yPos
170 self._pos = pos
171 elif self.Direction == RightTop: # 右上角
172 if h - yPos > self.minimumHeight():
173 y += yPos
174 h -= yPos
175 if w + xPos > self.minimumWidth():
176 w += xPos
177 self._pos.setX(pos.x())
178 elif self.Direction == LeftBottom: # 左下角
179 if w - xPos > self.minimumWidth():
180 x += xPos
181 w -= xPos
182 if h + yPos > self.minimumHeight():
183 h += yPos
184 self._pos.setY(pos.y())
185 elif self.Direction == Left: # 左边
186 if w - xPos > self.minimumWidth():
187 x += xPos
188 w -= xPos
189 else:
190 return
191 elif self.Direction == Right: # 右边
192 if w + xPos > self.minimumWidth():
193 w += xPos
194 self._pos = pos
195 else:
196 return
197 elif self.Direction == Top: # 上面
198 if h - yPos > self.minimumHeight():
199 y += yPos
200 h -= yPos
201 else:
202 return
203 elif self.Direction == Bottom: # 下面
204 if h + yPos > self.minimumHeight():
205 h += yPos

Callers 1

mouseMoveEventMethod · 0.95

Calls 2

setGeometryMethod · 0.80
xMethod · 0.45

Tested by

no test coverage detected