mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-21 18:42:22 +00:00
refactor
This commit is contained in:
parent
2f6b497087
commit
a1854f46ef
2
main.py
2
main.py
@ -68,7 +68,7 @@ class Window(QObject):
|
||||
|
||||
for name, monitor in self.xrandr_info.items():
|
||||
self.ui.screenCombo.addItem(name)
|
||||
mon_item = MonitorItem(0, 0, 0, 0, data=monitor, window=self, name=name,)
|
||||
mon_item = MonitorItem(data=monitor, window=self, name=name,)
|
||||
# mon_item.setPos(monitor["pos_x"], monitor["pos_y"])
|
||||
self.scene.addItem(mon_item)
|
||||
monitor["item"] = mon_item
|
||||
|
@ -10,25 +10,25 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
||||
data = kw.pop("data")
|
||||
self.name = kw.pop("name")
|
||||
self.window = kw.pop("window")
|
||||
super().__init__(*a, **kw)
|
||||
super().__init__(0, 0, 0, 0)
|
||||
self.setAcceptedMouseButtons(Qt.LeftButton)
|
||||
self.label = QGraphicsTextItem("", self)
|
||||
self.update_visuals(data)
|
||||
|
||||
def update_visuals(self, data):
|
||||
if data['replica_of']:
|
||||
if data["replica_of"]:
|
||||
label_text = f"{self.name} [{','.join(data['replica_of'])}]"
|
||||
else:
|
||||
label_text = self.name
|
||||
self.setRect(0, 0, data['res_x'], data['res_y'])
|
||||
self.setPos(data['pos_x'], data['pos_y'])
|
||||
self.setRect(0, 0, data["res_x"], data["res_y"])
|
||||
self.setPos(data["pos_x"], data["pos_y"])
|
||||
self.label.setPlainText(label_text)
|
||||
label_scale = min(
|
||||
self.rect().width() / self.label.boundingRect().width(),
|
||||
self.rect().height() / self.label.boundingRect().height(),
|
||||
)
|
||||
self.label.setScale(label_scale)
|
||||
if data['primary']:
|
||||
if data["primary"]:
|
||||
self.setBrush(QBrush("#eee8d5", Qt.SolidPattern))
|
||||
self.setZValue(1)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user