mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-22 02:52:23 +00:00
Display position when moving a monitor
This commit is contained in:
parent
a73ecbd037
commit
385541e6dd
14
main.py
14
main.py
@ -105,7 +105,7 @@ class Window(QObject):
|
|||||||
|
|
||||||
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(0, 0)
|
self.pos_label.move(5, 5)
|
||||||
|
|
||||||
def scale_mode_changed(self):
|
def scale_mode_changed(self):
|
||||||
mon = self.ui.screenCombo.currentText()
|
mon = self.ui.screenCombo.currentText()
|
||||||
@ -173,7 +173,7 @@ class Window(QObject):
|
|||||||
mon = self.ui.screenCombo.currentText()
|
mon = self.ui.screenCombo.currentText()
|
||||||
replicate = self.ui.replicaOf.currentText()
|
replicate = self.ui.replicaOf.currentText()
|
||||||
print(f"Making {mon} a replica of {replicate}")
|
print(f"Making {mon} a replica of {replicate}")
|
||||||
if replicate in ("None", '', None):
|
if replicate in ("None", "", None):
|
||||||
print("TODO: make things non-replicas")
|
print("TODO: make things non-replicas")
|
||||||
return
|
return
|
||||||
mon = self.xrandr_info[mon]
|
mon = self.xrandr_info[mon]
|
||||||
@ -190,7 +190,7 @@ class Window(QObject):
|
|||||||
else:
|
else:
|
||||||
# Keep the current mode, and change scaling so it
|
# Keep the current mode, and change scaling so it
|
||||||
# has the same effective size as the desired mode
|
# has the same effective size as the desired mode
|
||||||
mod_x, mod_y = [int(x) for x in mon["current_mode"].split('x')]
|
mod_x, mod_y = [int(x) for x in mon["current_mode"].split("x")]
|
||||||
target_x, target_y = [replicate[x] for x in ["res_x", "res_y"]]
|
target_x, target_y = [replicate[x] for x in ["res_x", "res_y"]]
|
||||||
scale_x = 1000 * target_x / mod_x
|
scale_x = 1000 * target_x / mod_x
|
||||||
scale_y = 1000 * target_y / mod_y
|
scale_y = 1000 * target_y / mod_y
|
||||||
@ -262,6 +262,10 @@ class Window(QObject):
|
|||||||
)
|
)
|
||||||
self.xrandr_info[mon]["item"].update_visuals(self.xrandr_info[mon])
|
self.xrandr_info[mon]["item"].update_visuals(self.xrandr_info[mon])
|
||||||
|
|
||||||
|
def show_pos(self, x, y):
|
||||||
|
self.pos_label.setText(f'{x},{y}')
|
||||||
|
self.pos_label.resize(self.pos_label.sizeHint())
|
||||||
|
|
||||||
def monitor_moved(self):
|
def monitor_moved(self):
|
||||||
"Update xrandr_info with new monitor positions"
|
"Update xrandr_info with new monitor positions"
|
||||||
for _, mon in self.xrandr_info.items():
|
for _, mon in self.xrandr_info.items():
|
||||||
@ -363,7 +367,9 @@ class Window(QObject):
|
|||||||
self.ui.modes.blockSignals(False)
|
self.ui.modes.blockSignals(False)
|
||||||
|
|
||||||
def scale_changed(self):
|
def scale_changed(self):
|
||||||
self.ui.horizontalScaleLabel.setText(f"{int(self.ui.horizontalScale.value()/10)}%")
|
self.ui.horizontalScaleLabel.setText(
|
||||||
|
f"{int(self.ui.horizontalScale.value()/10)}%"
|
||||||
|
)
|
||||||
self.ui.verticalScaleLabel.setText(f"{int(self.ui.verticalScale.value()/10)}%")
|
self.ui.verticalScaleLabel.setText(f"{int(self.ui.verticalScale.value()/10)}%")
|
||||||
self.mode_changed() # Not really, but it's the same thing
|
self.mode_changed() # Not really, but it's the same thing
|
||||||
|
|
||||||
|
@ -25,17 +25,13 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
|||||||
if data["orientation"] in (0, 2):
|
if data["orientation"] in (0, 2):
|
||||||
self.setRect(0, 0, data["res_x"], data["res_y"])
|
self.setRect(0, 0, data["res_x"], data["res_y"])
|
||||||
if data["orientation"] == 0:
|
if data["orientation"] == 0:
|
||||||
self.bottom_edge.setRect(
|
self.bottom_edge.setRect(0, data["res_y"] - 50, data["res_x"], 50)
|
||||||
0, data["res_y"] - 50, data["res_x"], 50
|
|
||||||
)
|
|
||||||
if data["orientation"] == 2:
|
if data["orientation"] == 2:
|
||||||
self.bottom_edge.setRect(0, 0, data["res_x"], 50)
|
self.bottom_edge.setRect(0, 0, data["res_x"], 50)
|
||||||
else:
|
else:
|
||||||
self.setRect(0, 0, data["res_y"], data["res_x"])
|
self.setRect(0, 0, data["res_y"], data["res_x"])
|
||||||
if data["orientation"] == 1:
|
if data["orientation"] == 1:
|
||||||
self.bottom_edge.setRect(
|
self.bottom_edge.setRect(data["res_y"] - 50, 0, 50, data["res_x"])
|
||||||
data["res_y"] - 50, 0, 50, data["res_x"]
|
|
||||||
)
|
|
||||||
if data["orientation"] == 3:
|
if data["orientation"] == 3:
|
||||||
self.bottom_edge.setRect(0, 0, 50, data["res_x"])
|
self.bottom_edge.setRect(0, 0, 50, data["res_x"])
|
||||||
self.setPos(data["pos_x"], data["pos_y"])
|
self.setPos(data["pos_x"], data["pos_y"])
|
||||||
@ -54,6 +50,7 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
|||||||
self.z -= 1
|
self.z -= 1
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
|
self.window.pos_label.show()
|
||||||
self.setCursor(Qt.ClosedHandCursor)
|
self.setCursor(Qt.ClosedHandCursor)
|
||||||
self.orig_pos = self.pos()
|
self.orig_pos = self.pos()
|
||||||
self.window.ui.screenCombo.setCurrentText(self.name)
|
self.window.ui.screenCombo.setCurrentText(self.name)
|
||||||
@ -61,6 +58,7 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
|||||||
def mouseReleaseEvent(self, event):
|
def mouseReleaseEvent(self, event):
|
||||||
self.setCursor(Qt.OpenHandCursor)
|
self.setCursor(Qt.OpenHandCursor)
|
||||||
self.window.monitor_moved()
|
self.window.monitor_moved()
|
||||||
|
self.window.pos_label.hide()
|
||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
view = event.widget().parent()
|
view = event.widget().parent()
|
||||||
@ -69,3 +67,4 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
|||||||
self.setPos(
|
self.setPos(
|
||||||
view.mapToScene(view.mapFromScene(self.orig_pos) + current_pos - click_pos)
|
view.mapToScene(view.mapFromScene(self.orig_pos) + current_pos - click_pos)
|
||||||
)
|
)
|
||||||
|
self.window.show_pos(int(self.pos().x()), int(self.pos().y()))
|
||||||
|
Loading…
Reference in New Issue
Block a user