Skip to content

Commit

Permalink
[Feature] Add first-launch dialog, inor UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko committed Sep 24, 2024
1 parent 90265fa commit 4386713
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 17 deletions.
46 changes: 46 additions & 0 deletions openfreebuds_qt/app/dialog/first_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import sys
import webbrowser

from PyQt6.QtCore import pyqtSlot
from PyQt6.QtWidgets import QDialog
from qasync import asyncSlot

import openfreebuds_backend
from openfreebuds_qt.config import OfbQtConfigParser
from openfreebuds_qt.constants import LINK_WEBSITE_HELP
from openfreebuds_qt.designer.first_run_dialog import Ui_OfbQtFirstRunDialog
from openfreebuds_qt.utils import get_img_colored, qt_error_handler


class OfbQtFirstRunDialog(Ui_OfbQtFirstRunDialog, QDialog):
def __init__(self, ctx):
super().__init__(ctx.main_window)

self.ctx = ctx
self.config = OfbQtConfigParser.get_instance()

self.setupUi(self)

self.autostart_checkbox.setEnabled(not self.config.is_containerized_app)
self.linux_notice.setVisible(sys.platform == 'linux')

preview_fn = "ofb_linux_preview" if sys.platform == 'linux' else "ofb_win32_preview"
preview_image = get_img_colored(preview_fn,
color=self.palette().text().color().getRgb(),
base_dir="image")
self.preview_root.setPixmap(preview_image)

@asyncSlot()
async def on_confirm(self):
async with qt_error_handler("OfbQtFirstRunDialog_Confirm", self.ctx):
self.hide()

if self.autostart_checkbox.isChecked():
openfreebuds_backend.set_run_at_boot(True)

self.config.set("ui", "first_run_finished", True)
self.config.save()

@pyqtSlot()
def on_faq_click(self):
webbrowser.open(LINK_WEBSITE_HELP)
4 changes: 2 additions & 2 deletions openfreebuds_qt/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from openfreebuds_qt.constants import ASSETS_PATH, LINK_RPC_HELP, LINK_WEBSITE_HELP
from openfreebuds_qt.designer.main_window import Ui_OfbMainWindowDesign
from openfreebuds_qt.generic import IOfbQtApplication, IOfbMainWindow
from openfreebuds_qt.utils import qt_error_handler, OfbCoreEvent, OfbQtReportTool, get_qt_icon_colored
from openfreebuds_qt.utils import qt_error_handler, OfbCoreEvent, OfbQtReportTool, get_img_colored

log = create_logger("OfbQtMainWindow")

Expand All @@ -45,7 +45,7 @@ def __init__(self, ctx: IOfbQtApplication):

# Extras button
self.extra_options_button.setIcon(
get_qt_icon_colored("settings", self.palette().text().color().getRgb())
QIcon(get_img_colored("settings", self.palette().text().color().getRgb()))
)

self.extra_menu = QMenu()
Expand Down
6 changes: 2 additions & 4 deletions openfreebuds_qt/app/module/sound_quality.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import json

from PIL import Image, ImageQt
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QSlider, QMenu, QInputDialog, QMessageBox, QFileDialog
Expand All @@ -10,10 +9,9 @@
from openfreebuds.exceptions import OfbTooManyItemsError
from openfreebuds.utils.logger import create_logger
from openfreebuds_qt.app.module.common import OfbQtCommonModule
from openfreebuds_qt.constants import ASSETS_PATH
from openfreebuds_qt.designer.sound_quality import Ui_OfbQtSoundQualityModule
from openfreebuds_qt.qt_i18n import get_eq_preset_names
from openfreebuds_qt.utils import get_qt_icon_colored
from openfreebuds_qt.utils import get_img_colored
from openfreebuds_qt.utils.async_dialog import run_dialog_async
from openfreebuds_qt.utils.core_event import OfbCoreEvent
from openfreebuds_qt.utils.qt_utils import fill_combo_box, blocked_signals, qt_error_handler
Expand Down Expand Up @@ -42,7 +40,7 @@ def __init__(self, *args, **kwargs):
self.setupUi(self)

self.undo_btn.setIcon(
get_qt_icon_colored("undo", self.palette().text().color().getRgb())
QIcon(get_img_colored("undo", self.palette().text().color().getRgb()))
)

self.custom_menu = QMenu()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion openfreebuds_qt/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_tray_icon_theme(self):
return "dark" if not backend_theme else "light"

# Auto-detect using qt
return self.qt_is_dark_theme
return "dark" if not self.qt_is_dark_theme else "light"

@cached_property
def is_containerized_app(self):
Expand Down
278 changes: 278 additions & 0 deletions openfreebuds_qt/designer/first_run_dialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OfbQtFirstRunDialog</class>
<widget class="QWidget" name="OfbQtFirstRunDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>570</width>
<height>320</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string>Welcome</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget_4" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="preview_root">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Image</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>This application allows you to manage your HUAWEI Bluetooth earphones. To access them, look for headphones icon in system tray panel, near other icons.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Left-click on this icon will cycle through noise cancellation modes (can be configured), right-click will provide access to full battery status and main options. Settings window provides access to all features.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="linux_notice">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>If you're running under GNOME shell and can't find tray icon, please, check FAQ.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="autostart_checkbox">
<property name="text">
<string>Launch OpenFreebuds at system boot</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>You could change this options anytime later in settings.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="faq_btn">
<property name="text">
<string>FAQ</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="confirm_btn">
<property name="text">
<string>Get started</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>faq_btn</sender>
<signal>clicked()</signal>
<receiver>OfbQtFirstRunDialog</receiver>
<slot>on_faq_click()</slot>
<hints>
<hint type="sourcelabel">
<x>436</x>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>285</x>
<y>160</y>
</hint>
</hints>
</connection>
<connection>
<sender>confirm_btn</sender>
<signal>clicked()</signal>
<receiver>OfbQtFirstRunDialog</receiver>
<slot>on_confirm()</slot>
<hints>
<hint type="sourcelabel">
<x>522</x>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>285</x>
<y>160</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>on_faq_click()</slot>
<slot>on_confirm()</slot>
</slots>
</ui>
Loading

0 comments on commit 4386713

Please sign in to comment.