Skip to content

Commit

Permalink
Add autostart toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko committed Sep 15, 2024
1 parent 3d4cb75 commit e671a56
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
*#

/test.py
/lib
/venv
/.venv
/build
/builddir
/dist
Expand Down
4 changes: 3 additions & 1 deletion openfreebuds_qt/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from openfreebuds_qt.app.module import OfbQtAboutModule, OfbQtSoundQualityModule, OfbQtLinuxExtrasModule, \
OfbQtHotkeysModule, OfbQtGesturesModule, OfbQtDualConnectModule, OfbQtDeviceOtherSettingsModule, \
OfbQtDeviceInfoModule, OfbQtCommonModule, OfbQtChooseDeviceModule, OfbQtUiSettingsModule
from openfreebuds_qt.config import ConfigLock
from openfreebuds_qt.constants import ASSETS_PATH
from openfreebuds_qt.designer.main_window import Ui_OfbMainWindowDesign
from openfreebuds_qt.generic import IOfbQtApplication, IOfbMainWindow
Expand Down Expand Up @@ -66,7 +67,8 @@ def __init__(self, ctx: IOfbQtApplication):

# App-related modules
self.tabs.add_section(self.tr("Application"))
self._attach_module(self.tr("User interface"), OfbQtUiSettingsModule(self.tabs.root, self.ctx))
if ConfigLock.owned:
self._attach_module(self.tr("User interface"), OfbQtUiSettingsModule(self.tabs.root, self.ctx))
if OfbQtHotkeysModule.available():
self._attach_module(self.tr("Keyboard shortcuts"), OfbQtHotkeysModule(self.tabs.root, self.ctx))
if sys.platform == "linux":
Expand Down
7 changes: 7 additions & 0 deletions openfreebuds_qt/app/module/ui_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from openfreebuds import OfbEventKind
from openfreebuds.shortcuts import OfbShortcuts
from openfreebuds.utils.logger import create_logger
from openfreebuds_backend import is_run_at_boot, set_run_at_boot
from openfreebuds_qt.app.module import OfbQtCommonWithShortcutsModule
from openfreebuds_qt.config import OfbQtConfigParser
from openfreebuds_qt.designer.ui_settings import Ui_OfbQtUiSettingsModule
Expand Down Expand Up @@ -50,6 +51,12 @@ def __init__(self, *args, **kwargs):
self.tray_eq_toggle.setChecked(self.config.get("ui", "tray_show_equalizer", False))
with blocked_signals(self.tray_dc_toggle):
self.tray_dc_toggle.setChecked(self.config.get("ui", "tray_show_dual_connect", False))
with blocked_signals(self.autostart_toggle):
self.autostart_toggle.setChecked(is_run_at_boot())

@asyncSlot(bool)
async def on_autostart_toggle(self, value: bool):
set_run_at_boot(value)

@asyncSlot(bool)
async def on_tray_eq_toggle(self, value: bool):
Expand Down
48 changes: 36 additions & 12 deletions openfreebuds_qt/designer/ui_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
<string>Main</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Restart OpenFeebuds to apply changes</string>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="language_picker">
<item>
<property name="text">
<string>System</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
Expand All @@ -41,13 +43,18 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="language_picker">
<item>
<property name="text">
<string>System</string>
</property>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Restart OpenFeebuds to apply changes</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="autostart_toggle">
<property name="text">
<string>Launch at system startup</string>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -209,12 +216,29 @@
</hint>
</hints>
</connection>
<connection>
<sender>autostart_toggle</sender>
<signal>toggled(bool)</signal>
<receiver>OfbQtUiSettingsModule</receiver>
<slot>on_autostart_toggle(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>247</x>
<y>129</y>
</hint>
<hint type="destinationlabel">
<x>247</x>
<y>261</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>on_tray_eq_toggle(bool)</slot>
<slot>on_tray_dc_toggle(bool)</slot>
<slot>on_language_choose(int)</slot>
<slot>on_tray_color_choose(int)</slot>
<slot>on_tray_shortcut_choose(int)</slot>
<slot>on_autostart_toggle(bool)</slot>
</slots>
</ui>

0 comments on commit e671a56

Please sign in to comment.