mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-22 02:52:23 +00:00
cleanups
This commit is contained in:
parent
55d8522c4b
commit
ed55a157fe
12
main.py
12
main.py
@ -2,7 +2,7 @@ from copy import deepcopy
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide2.QtCore import QFile, QObject, Slot, SIGNAL
|
from PySide2.QtCore import QFile, QObject, Slot
|
||||||
from PySide2.QtUiTools import QUiLoader
|
from PySide2.QtUiTools import QUiLoader
|
||||||
from PySide2.QtWidgets import QApplication, QGraphicsScene
|
from PySide2.QtWidgets import QApplication, QGraphicsScene
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ def parse_monitor(line):
|
|||||||
|
|
||||||
def is_replica_of(a, b):
|
def is_replica_of(a, b):
|
||||||
"""Return True if monitor a is a replica of b.
|
"""Return True if monitor a is a replica of b.
|
||||||
|
|
||||||
Replica means same resolution and position.
|
Replica means same resolution and position.
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
@ -89,7 +89,7 @@ class Window(QObject):
|
|||||||
item = mon['item']
|
item = mon['item']
|
||||||
mon['pos_x'] = item.x()
|
mon['pos_x'] = item.x()
|
||||||
mon['pos_y'] = item.y()
|
mon['pos_y'] = item.y()
|
||||||
self.set_replica_of()
|
self.update_replica_of_data()
|
||||||
for _, mon in self.xrandr_info.items():
|
for _, mon in self.xrandr_info.items():
|
||||||
mon['item'].update_visuals(mon)
|
mon['item'].update_visuals(mon)
|
||||||
|
|
||||||
@ -136,13 +136,13 @@ class Window(QObject):
|
|||||||
if "*" in line:
|
if "*" in line:
|
||||||
print(f"Current mode for {name}: {mode_name}")
|
print(f"Current mode for {name}: {mode_name}")
|
||||||
self.xrandr_info[name]["current_mode"] = mode_name
|
self.xrandr_info[name]["current_mode"] = mode_name
|
||||||
self.set_replica_of()
|
self.update_replica_of_data()
|
||||||
|
|
||||||
def set_replica_of(self):
|
def update_replica_of_data(self):
|
||||||
for a in self.xrandr_info:
|
for a in self.xrandr_info:
|
||||||
self.xrandr_info[a]['replica_of'] = []
|
self.xrandr_info[a]['replica_of'] = []
|
||||||
for b in self.xrandr_info:
|
for b in self.xrandr_info:
|
||||||
if a !=b and is_replica_of(self.xrandr_info[a], self.xrandr_info[b]):
|
if a != b and is_replica_of(self.xrandr_info[a], self.xrandr_info[b]):
|
||||||
self.xrandr_info[a]['replica_of'].append(b)
|
self.xrandr_info[a]['replica_of'].append(b)
|
||||||
|
|
||||||
def monitor_selected(self, name):
|
def monitor_selected(self, name):
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
from PySide2.QtCore import Qt, Signal, QObject
|
from PySide2.QtCore import Qt, QObject
|
||||||
from PySide2.QtWidgets import QGraphicsRectItem, QGraphicsTextItem
|
from PySide2.QtWidgets import QGraphicsRectItem, QGraphicsTextItem
|
||||||
from PySide2.QtGui import QBrush, QPen
|
from PySide2.QtGui import QBrush
|
||||||
|
|
||||||
|
|
||||||
class MonitorItem(QGraphicsRectItem, QObject):
|
class MonitorItem(QGraphicsRectItem, QObject):
|
||||||
z = 0
|
z = 0
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, *a, **kw):
|
def __init__(self, *a, **kw):
|
||||||
data = kw.pop("data")
|
data = kw.pop("data")
|
||||||
self.name = kw.pop("name")
|
self.name = kw.pop("name")
|
||||||
|
Loading…
Reference in New Issue
Block a user