Skip to content

Commit

Permalink
修复拖动窗口到不同显示器后 UI 不符合预期的问题 (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Dec 10, 2024
1 parent f8a5860 commit d4e257a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import asyncio
from aiohttp.client_exceptions import ClientConnectorError
from qasync import asyncClose, asyncSlot
from PyQt5.QtCore import Qt, pyqtSignal, QSize
from PyQt5.QtCore import Qt, pyqtSignal, QSize, QEvent
from PyQt5.QtGui import QIcon, QImage
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon

Expand Down Expand Up @@ -101,6 +101,8 @@ def __init__(self):
self.lastTipsTime = time.time()
self.lastTipsType = None

self.isDragging = False

self.__initInterface()
self.__initNavigation()
self.__initListener()
Expand Down Expand Up @@ -1037,3 +1039,10 @@ def exceptHook(self, ty, value, tb):
def __onCurrentStackedChanged(self, index):
widget: SmoothScrollArea = self.stackedWidget.view.currentWidget()
widget.delegate.vScrollBar.resetValue(0)

def eventFilter(self, obj, e: QEvent):
# Fix #553
if e.type() == QEvent.Type.MouseButtonRelease:
self.adjustSize()

return super().eventFilter(obj, e)
11 changes: 9 additions & 2 deletions app/view/opgg_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from qasync import asyncSlot, asyncClose
from PyQt5.QtGui import QColor, QPainter, QIcon, QShowEvent
from PyQt5.QtCore import Qt, pyqtSignal, QSize, QRect
from PyQt5.QtCore import Qt, pyqtSignal, QSize, QRect, QEvent
from PyQt5.QtWidgets import (QHBoxLayout, QStackedWidget, QWidget, QLabel,
QFrame, QVBoxLayout, QSpacerItem, QSizePolicy,
QApplication)
Expand Down Expand Up @@ -499,7 +499,7 @@ def showEvent(self, a0: QShowEvent) -> None:
dpi = self.devicePixelRatioF()
x = pos.right()
y = pos.center().y() - size.height() * dpi / 2
rect = QRect( int(x / dpi), int(y / dpi), size.width(), size.height())
rect = QRect(int(x / dpi), int(y / dpi), size.width(), size.height())

# 如果超出右边界,则直接 return 了
screenWidth = win32api.GetSystemMetrics(0)
Expand All @@ -522,6 +522,13 @@ def setHomeInterfaceEnabled(self, enabeld):
interface = self.homeInterface if enabeld else self.tierInterface
self.stackedWidget.setCurrentWidget(interface)

def eventFilter(self, obj, e: QEvent):
# Fix #553
if e.type() == QEvent.Type.MouseButtonRelease:
self.adjustSize()

return super().eventFilter(obj, e)


class WaitingInterface(QFrame):
def __init__(self, parent: QWidget = None):
Expand Down

0 comments on commit d4e257a

Please sign in to comment.