mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-24 20:12:21 +00:00
Support enabling / disabling monitors from the UI
This commit is contained in:
parent
4373045db9
commit
b3c03fe723
@ -16,19 +16,20 @@ def gen_xrandr_from_data(data):
|
||||
cli = ["xrandr"]
|
||||
for name, mon in data.items():
|
||||
cli.append(f"--output {name}")
|
||||
cli.append(f'--pos {int(mon["pos_x"])}x{int(mon["pos_y"])}')
|
||||
cli.append(f'--mode {mon["current_mode"]}')
|
||||
mod_x, mod_y = [int(n) for n in mon["current_mode"].split("x")]
|
||||
if mon["orientation"] in (1, 3):
|
||||
mod_x, mod_y = mod_y, mod_x
|
||||
cli.append(f'--scale {mon["res_x"]/mod_x}x{mon["res_y"]/mod_y}')
|
||||
cli.append(
|
||||
f"--rotate {['normal', 'left', 'inverted', 'right'][mon['orientation']]}"
|
||||
)
|
||||
if mon["primary"]:
|
||||
cli.append("--primary")
|
||||
if not mon["enabled"]:
|
||||
cli.append("--off")
|
||||
else:
|
||||
cli.append(f'--pos {int(mon["pos_x"])}x{int(mon["pos_y"])}')
|
||||
cli.append(f'--mode {mon["current_mode"]}')
|
||||
mod_x, mod_y = [int(n) for n in mon["current_mode"].split("x")]
|
||||
if mon["orientation"] in (1, 3):
|
||||
mod_x, mod_y = mod_y, mod_x
|
||||
cli.append(f'--scale {mon["res_x"]/mod_x}x{mon["res_y"]/mod_y}')
|
||||
cli.append(
|
||||
f"--rotate {['normal', 'left', 'inverted', 'right'][mon['orientation']]}"
|
||||
)
|
||||
if mon["primary"]:
|
||||
cli.append("--primary")
|
||||
|
||||
return " ".join(cli)
|
||||
|
||||
@ -104,11 +105,20 @@ class Window(QObject):
|
||||
self.ui.cancelButton.clicked.connect(self.ui.reject)
|
||||
self.ui.scaleModeCombo.currentTextChanged.connect(self.scale_mode_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.setText("FOOOOO")
|
||||
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):
|
||||
mon = self.ui.screenCombo.currentText()
|
||||
primary = self.ui.primary.isChecked()
|
||||
|
@ -41,13 +41,16 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
||||
self.rect().height() / self.label.boundingRect().height(),
|
||||
)
|
||||
self.label.setScale(label_scale)
|
||||
if data["primary"]:
|
||||
self.setBrush(QBrush("#eee8d5", Qt.SolidPattern))
|
||||
self.setZValue(1)
|
||||
if data["enabled"]:
|
||||
if data["primary"]:
|
||||
self.setBrush(QBrush("#eee8d5", Qt.SolidPattern))
|
||||
self.setZValue(1)
|
||||
else:
|
||||
self.setBrush(QBrush("white", Qt.SolidPattern))
|
||||
self.setZValue(self.z)
|
||||
self.z -= 1
|
||||
else:
|
||||
self.setBrush(QBrush("white", Qt.SolidPattern))
|
||||
self.setZValue(self.z)
|
||||
self.z -= 1
|
||||
self.setBrush(QBrush("#010101", Qt.FDiagPattern))
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
self.window.pos_label.show()
|
||||
|
Loading…
Reference in New Issue
Block a user