diff --git a/main.py b/main.py index 3b1a305..abc2c2b 100644 --- a/main.py +++ b/main.py @@ -68,15 +68,7 @@ class Window(QObject): for name, monitor in self.xrandr_info.items(): self.ui.screenCombo.addItem(name) - mon_item = MonitorItem( - 0, - 0, - monitor["res_x"], - monitor["res_y"], - data=monitor, - window=self, - name=name, - ) + mon_item = MonitorItem(0, 0, 0, 0, data=monitor, window=self, name=name,) mon_item.setPos(monitor["pos_x"], monitor["pos_y"]) self.scene.addItem(mon_item) monitor["item"] = mon_item @@ -86,18 +78,18 @@ class Window(QObject): def monitor_moved(self): "Update xrandr_info with new monitor positions" for _, mon in self.xrandr_info.items(): - item = mon['item'] - mon['pos_x'] = item.x() - mon['pos_y'] = item.y() + item = mon["item"] + mon["pos_x"] = item.x() + mon["pos_y"] = item.y() self.update_replica_of_data() for _, mon in self.xrandr_info.items(): - mon['item'].update_visuals(mon) + mon["item"].update_visuals(mon) self.adjust_view() def adjust_view(self): self.ui.sceneView.resetTransform() self.ui.sceneView.ensureVisible(self.scene.sceneRect(), 100, 100) - scale_factor = .8 * min( + scale_factor = 0.8 * min( self.ui.sceneView.width() / self.scene.sceneRect().width(), self.ui.sceneView.height() / self.scene.sceneRect().height(), ) @@ -142,10 +134,10 @@ class Window(QObject): def update_replica_of_data(self): for a in self.xrandr_info: - self.xrandr_info[a]['replica_of'] = [] + self.xrandr_info[a]["replica_of"] = [] for b in self.xrandr_info: 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): # Show modes @@ -168,7 +160,7 @@ class Window(QObject): for mon in self.xrandr_info: if mon != name: self.ui.replicaOf.addItem(mon) - if mon in self.xrandr_info[name]['replica_of']: + if mon in self.xrandr_info[name]["replica_of"]: self.ui.replicaOf.setCurrentText(mon) def updateScaleLabels(self): diff --git a/main.ui b/main.ui index 85a7b9b..4ee81b5 100644 --- a/main.ui +++ b/main.ui @@ -18,222 +18,152 @@ - - - 1 - - - - Global Settings - - - - QFormLayout::FieldsStayAtSizeHint + + + + + Settings for - - Qt::AlignHCenter|Qt::AlignTop + + + + + + QComboBox::AdjustToContents - - 6 + + + + + + Enabled - - - - Use physical model + + + + + + Primary + + + + + + + Resolution + + + + + + + QComboBox::AdjustToContents + + + + + + + Orientation + + + + + + + QComboBox::AdjustToContents + + + + + + + Replica of: + + + + + + + QComboBox::AdjustToContents + + + + + + + Horizontal Scale: + + + + + + + + + 400 - - - - - - Global scale: + + 5 + + + 25 - - - - Qt::Horizontal + + QSlider::TicksBelow + - - - - Qt::Vertical + + + + TextLabel - - - 20 - 40 - - - + - - - - Qt::LeftToRight - - - Screen Settings - - - - Qt::AlignHCenter|Qt::AlignTop + + + + + Vertical Scale: - - + + + + + + + + 400 + + + 5 + + + 25 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + + + - Settings for + TextLabel - - - - QComboBox::AdjustToContents - - - - - - - Enabled - - - - - - - Primary - - - - - - - Resolution - - - - - - - QComboBox::AdjustToContents - - - - - - - Orientation - - - - - - - QComboBox::AdjustToContents - - - - - - - Replica of: - - - - - - - QComboBox::AdjustToContents - - - - - - - Horizontal Scale: - - - - - - - Vertical Scale: - - - - - - - - - - 400 - - - 5 - - - 25 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - - - - - - - - - - - - - - - - - - 400 - - - 5 - - - 25 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - - - - - - - - - - - - - + + diff --git a/monitor_item.py b/monitor_item.py index 45dfad1..38cb50a 100644 --- a/monitor_item.py +++ b/monitor_item.py @@ -20,6 +20,8 @@ class MonitorItem(QGraphicsRectItem, QObject): 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.label.setPlainText(label_text) label_scale = min( self.rect().width() / self.label.boundingRect().width(),