FIXED: unexpected window movement during mode change
This commit is contained in:
+20
-9
@@ -15,11 +15,13 @@ import clipboard
|
|||||||
from table import Table
|
from table import Table
|
||||||
import engine
|
import engine
|
||||||
|
|
||||||
|
|
||||||
class Mode:
|
class Mode:
|
||||||
CURRENT_ZONE = 'Damage: Current zone'
|
CURRENT_ZONE = 'Damage: Current zone'
|
||||||
OVERALL = 'Damage: Overall'
|
OVERALL = 'Damage: Overall'
|
||||||
LAST_FIGHT = 'Damage: Last fight'
|
LAST_FIGHT = 'Damage: Last fight'
|
||||||
|
|
||||||
|
|
||||||
class BottomButtons(QWidget):
|
class BottomButtons(QWidget):
|
||||||
def __init__(self, table, mode):
|
def __init__(self, table, mode):
|
||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
@@ -61,19 +63,28 @@ class BottomButtons(QWidget):
|
|||||||
|
|
||||||
reset[self.mode()]()
|
reset[self.mode()]()
|
||||||
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
class ModeWidget(QComboBox):
|
||||||
|
def __init__(self):
|
||||||
|
QComboBox.__init__(self)
|
||||||
|
|
||||||
|
self.addItem(Mode.CURRENT_ZONE)
|
||||||
|
self.addItem(Mode.OVERALL)
|
||||||
|
self.addItem(Mode.LAST_FIGHT)
|
||||||
|
|
||||||
|
|
||||||
class MainWidget(QWidget):
|
class MainWidget(QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
|
|
||||||
self.mouse_pos = None
|
self.mouse_pos = None
|
||||||
self.mode = QComboBox()
|
self.mode = ModeWidget()
|
||||||
self.mode.minimumContentsLength()
|
|
||||||
self.table = Table()
|
self.table = Table()
|
||||||
self.bottom_buttons = BottomButtons(self.table, lambda : self.mode.currentText())
|
self.bottom_buttons = BottomButtons(
|
||||||
|
self.table, lambda: self.mode.currentText())
|
||||||
|
|
||||||
self.layout = QVBoxLayout()
|
self.layout = QVBoxLayout()
|
||||||
self.layout.addWidget(self.mode)
|
self.layout.addWidget(self.mode)
|
||||||
@@ -81,10 +92,6 @@ class MainWidget(QWidget):
|
|||||||
self.layout.addWidget(self.bottom_buttons)
|
self.layout.addWidget(self.bottom_buttons)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
self.mode.addItem(Mode.CURRENT_ZONE)
|
|
||||||
self.mode.addItem(Mode.OVERALL)
|
|
||||||
self.mode.addItem(Mode.LAST_FIGHT)
|
|
||||||
|
|
||||||
self.table.fill(self.session())
|
self.table.fill(self.session())
|
||||||
|
|
||||||
timer = QTimer(self)
|
timer = QTimer(self)
|
||||||
@@ -95,6 +102,11 @@ class MainWidget(QWidget):
|
|||||||
self.mouse_pos = event.pos()
|
self.mouse_pos = event.pos()
|
||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
|
if self.mode.geometry().contains(event.pos()):
|
||||||
|
return
|
||||||
|
if not self.mouse_pos:
|
||||||
|
return
|
||||||
|
|
||||||
if event.buttons() & Qt.LeftButton:
|
if event.buttons() & Qt.LeftButton:
|
||||||
diff = event.pos() - self.mouse_pos
|
diff = event.pos() - self.mouse_pos
|
||||||
newpos = self.pos() + diff
|
newpos = self.pos() + diff
|
||||||
@@ -109,4 +121,3 @@ class MainWidget(QWidget):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return sessions[self.mode.currentText()]()
|
return sessions[self.mode.currentText()]()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user