From 5f85fde10feea0d69593542c7716d0a757544020 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Fri, 31 Jan 2020 17:51:40 -0300 Subject: [PATCH] Support scale changes per monitor --- main.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 494f5ce..ff5f0c8 100644 --- a/main.py +++ b/main.py @@ -53,14 +53,13 @@ class Window(QObject): self.ui = ui ui.show() self.ui.screenCombo.currentTextChanged.connect(self.monitor_selected) - self.ui.horizontalScale.valueChanged.connect(self.updateScaleLabels) - self.ui.verticalScale.valueChanged.connect(self.updateScaleLabels) self.xrandr_info = {} self.get_xrandr_info() self.orig_xrandr_info = deepcopy(self.xrandr_info) self.fill_ui() - - self.ui.modes.currentTextChanged.connect(self.change_mode) + self.ui.horizontalScale.valueChanged.connect(self.scale_changed) + self.ui.verticalScale.valueChanged.connect(self.scale_changed) + self.ui.modes.currentTextChanged.connect(self.mode_changed) def fill_ui(self): """Load data from xrandr and setup the whole thing.""" @@ -76,9 +75,11 @@ class Window(QObject): monitor["item"] = mon_item self.adjust_view() - def change_mode(self): + def mode_changed(self): mon = self.ui.screenCombo.currentText() mode = self.ui.modes.currentText() + if not mode: + return print(f'Changing {mon} to {mode}') self.xrandr_info[mon]['current_mode'] = mode mode_x, mode_y = mode.split('x') @@ -152,6 +153,8 @@ class Window(QObject): self.xrandr_info[a]["replica_of"].append(b) def monitor_selected(self, name): + # needed so we don't flip through all modes as they are added + self.ui.modes.blockSignals(True) # Show modes self.ui.modes.clear() for mode in self.xrandr_info[name]["modes"]: @@ -174,10 +177,13 @@ class Window(QObject): self.ui.replicaOf.addItem(mon) if mon in self.xrandr_info[name]["replica_of"]: self.ui.replicaOf.setCurrentText(mon) + self.ui.modes.blockSignals(False) - def updateScaleLabels(self): + def scale_changed(self): self.ui.horizontalScaleLabel.setText(f"{self.ui.horizontalScale.value()}%") self.ui.verticalScaleLabel.setText(f"{self.ui.verticalScale.value()}%") + self.mode_changed() # Not really, but it's the same thing + if __name__ == "__main__":