Skip to content

Commit

Permalink
fixed crash on first monitor fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Jul 25, 2024
1 parent 78006be commit 821b7eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/BigPictureTV.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ def initialize_ui(self):

def generate_monitor_list(self):
output_file = os.path.join(os.environ['APPDATA'], "BigPictureTV", "monitors.txt")
subprocess.run([MULTIMONITORTOOL_PATH, "/stext", output_file], check=True)
os.makedirs(os.path.dirname(output_file), exist_ok=True)

try:
subprocess.run([MULTIMONITORTOOL_PATH, "/stext", output_file], check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while generating the monitor list: {e}")

def parse_monitors(self):
monitor_file = os.path.join(os.environ['APPDATA'], "BigPictureTV", "monitors.txt")
Expand Down Expand Up @@ -132,7 +137,8 @@ def create_default_settings(self):
"GAMEMODE_AUDIO": "TV",
"DESKTOP_AUDIO": "Headset",
"DisableAudioSwitch": False,
"CheckRate": 1000
"CheckRate": 1000,
"UseDisplaySwitch": True,
}
self.apply_settings()
self.save_settings()
Expand All @@ -157,7 +163,7 @@ def apply_settings(self):

gamemode_monitor = self.settings.get('GAMEMODE_MONITOR', '')
desktop_monitor = self.settings.get('DESKTOP_MONITOR', '')
self.use_displayswitch = self.settings.get('UseDisplaySwitch', False)
self.use_displayswitch = self.settings.get('UseDisplaySwitch', True)
self.ui.displayswitchBox.setChecked(self.use_displayswitch)
self.toggle_video_settings(not self.use_displayswitch)

Expand Down
3 changes: 2 additions & 1 deletion src/design.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Form implementation generated from reading ui file '.\src\ui\design.ui'
# Form implementation generated from reading ui file '.\ui\design.ui'
#
# Created by: PyQt6 UI code generator 6.7.0
#
Expand Down Expand Up @@ -116,6 +116,7 @@ def setupUi(self, MainWindow):
self.displayswitchBox.setMinimumSize(QtCore.QSize(0, 25))
self.displayswitchBox.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft)
self.displayswitchBox.setText("")
self.displayswitchBox.setChecked(True)
self.displayswitchBox.setObjectName("displayswitchBox")
self.gridLayout_5.addWidget(self.displayswitchBox, 2, 2, 1, 1)
self.displayswitchLabel = QtWidgets.QLabel(parent=self.settingsFrame)
Expand Down
3 changes: 3 additions & 0 deletions src/ui/design.ui
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
Expand Down

0 comments on commit 821b7eb

Please sign in to comment.