mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-22 02:52:23 +00:00
Support enabling / disabling monitors from the UI
This commit is contained in:
parent
4373045db9
commit
b3c03fe723
@ -16,6 +16,9 @@ def gen_xrandr_from_data(data):
|
|||||||
cli = ["xrandr"]
|
cli = ["xrandr"]
|
||||||
for name, mon in data.items():
|
for name, mon in data.items():
|
||||||
cli.append(f"--output {name}")
|
cli.append(f"--output {name}")
|
||||||
|
if not mon["enabled"]:
|
||||||
|
cli.append("--off")
|
||||||
|
else:
|
||||||
cli.append(f'--pos {int(mon["pos_x"])}x{int(mon["pos_y"])}')
|
cli.append(f'--pos {int(mon["pos_x"])}x{int(mon["pos_y"])}')
|
||||||
cli.append(f'--mode {mon["current_mode"]}')
|
cli.append(f'--mode {mon["current_mode"]}')
|
||||||
mod_x, mod_y = [int(n) for n in mon["current_mode"].split("x")]
|
mod_x, mod_y = [int(n) for n in mon["current_mode"].split("x")]
|
||||||
@ -27,8 +30,6 @@ def gen_xrandr_from_data(data):
|
|||||||
)
|
)
|
||||||
if mon["primary"]:
|
if mon["primary"]:
|
||||||
cli.append("--primary")
|
cli.append("--primary")
|
||||||
if not mon["enabled"]:
|
|
||||||
cli.append("--off")
|
|
||||||
|
|
||||||
return " ".join(cli)
|
return " ".join(cli)
|
||||||
|
|
||||||
@ -104,11 +105,20 @@ class Window(QObject):
|
|||||||
self.ui.cancelButton.clicked.connect(self.ui.reject)
|
self.ui.cancelButton.clicked.connect(self.ui.reject)
|
||||||
self.ui.scaleModeCombo.currentTextChanged.connect(self.scale_mode_changed)
|
self.ui.scaleModeCombo.currentTextChanged.connect(self.scale_mode_changed)
|
||||||
self.ui.primary.stateChanged.connect(self.primary_changed)
|
self.ui.primary.stateChanged.connect(self.primary_changed)
|
||||||
|
self.ui.enabled.stateChanged.connect(self.enabled_changed)
|
||||||
|
|
||||||
self.pos_label = QLabel(self.ui.sceneView)
|
self.pos_label = QLabel(self.ui.sceneView)
|
||||||
self.pos_label.setText("FOOOOO")
|
self.pos_label.setText("FOOOOO")
|
||||||
self.pos_label.move(5, 5)
|
self.pos_label.move(5, 5)
|
||||||
|
|
||||||
|
def enabled_changed(self):
|
||||||
|
mon = self.ui.screenCombo.currentText()
|
||||||
|
enabled = self.ui.enabled.isChecked()
|
||||||
|
print(f'Setting {mon} enabled status to {enabled}')
|
||||||
|
monitor = self.xrandr_info[mon]
|
||||||
|
monitor['enabled'] = enabled
|
||||||
|
monitor["item"].update_visuals(monitor)
|
||||||
|
|
||||||
def primary_changed(self):
|
def primary_changed(self):
|
||||||
mon = self.ui.screenCombo.currentText()
|
mon = self.ui.screenCombo.currentText()
|
||||||
primary = self.ui.primary.isChecked()
|
primary = self.ui.primary.isChecked()
|
||||||
|
@ -41,6 +41,7 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
|||||||
self.rect().height() / self.label.boundingRect().height(),
|
self.rect().height() / self.label.boundingRect().height(),
|
||||||
)
|
)
|
||||||
self.label.setScale(label_scale)
|
self.label.setScale(label_scale)
|
||||||
|
if data["enabled"]:
|
||||||
if data["primary"]:
|
if data["primary"]:
|
||||||
self.setBrush(QBrush("#eee8d5", Qt.SolidPattern))
|
self.setBrush(QBrush("#eee8d5", Qt.SolidPattern))
|
||||||
self.setZValue(1)
|
self.setZValue(1)
|
||||||
@ -48,6 +49,8 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
|||||||
self.setBrush(QBrush("white", Qt.SolidPattern))
|
self.setBrush(QBrush("white", Qt.SolidPattern))
|
||||||
self.setZValue(self.z)
|
self.setZValue(self.z)
|
||||||
self.z -= 1
|
self.z -= 1
|
||||||
|
else:
|
||||||
|
self.setBrush(QBrush("#010101", Qt.FDiagPattern))
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
self.window.pos_label.show()
|
self.window.pos_label.show()
|
||||||
|
Loading…
Reference in New Issue
Block a user