Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Add window icon. #74

Merged
merged 4 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ nexus.egg-info/
**/__pycache__/
src/nexus/ui/*.py
src/nexus/translations/
/resources_rc.py
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ repos:
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
exclude: '^.+\.desktop$'
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-symlinks
Expand Down Expand Up @@ -46,7 +47,7 @@ repos:
- --statistics
- --max-line-length=120
- --per-file-ignores=src/nexus/Freqlog/backends/__init__.py:F401
- --exclude=venv,src/nexus/ui
- --exclude=venv,src/nexus/ui,resources_rc.py
additional_dependencies: [flake8]
- id: pytest
name: pytest
Expand Down
9 changes: 9 additions & 0 deletions com.charachorder.nexus.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Comment=CharaChorder's all-in-one desktop app, supporting Linux, Windows, and macOS.
Exec=nexus
Icon=ui/images/icon.ico
Name=nexus
StartupNotify=true
StartupWMClass=nexus
Terminal=false
Type=Application
6 changes: 5 additions & 1 deletion dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def run_command(command: str):
for f in glob.glob('ui/*.ui'):
run_command(f"{venv_path}pyside6-uic {f} -o src/nexus/ui/{Path(f).stem}.py")

# Generate resources
print("Generating resources...")
run_command(f"{venv_path}pyside6-rcc ui/resources.qrc -o resources_rc.py")

# Generate translations
print("Generating TS templates...")
run_command(f"{venv_path}pyside6-lupdate " +
Expand All @@ -73,7 +77,7 @@ def run_command(command: str):

if not (args.no_build or args.ui_only):
# Pyinstaller command
build_cmd = "pyinstaller --onefile --name nexus src/nexus/__main__.py"
build_cmd = "pyinstaller --onefile --name nexus src/nexus/__main__.py --icon ui/images/icon.ico"
if os_name == "notwin": # Add hidden imports for Linux
build_cmd += " --hidden-import pynput.keyboard._xorg --hidden-import pynput.mouse._xorg"

Expand Down
15 changes: 11 additions & 4 deletions src/nexus/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
QDialog, QFileDialog, QDialogButtonBox, QVBoxLayout, QLabel, QMenu, QSystemTrayIcon
from PySide6.QtGui import QIcon, QAction

from nexus import __id__, __version__
from nexus.Freqlog import Freqlog
from nexus.ui.BanlistDialog import Ui_BanlistDialog
from nexus.ui.BanwordDialog import Ui_BanwordDialog
from nexus.ui.MainWindow import Ui_MainWindow

from nexus.style import Stylesheet, Colors

from nexus.Freqlog.Definitions import CaseSensitivity, WordMetadataAttr, WordMetadataAttrLabel, WordMetadata, Defaults

if os.name == 'nt': # Needed for taskbar icon on Windows
import ctypes

ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(f"{__id__}.{__version__}")


class MainWindow(QMainWindow, Ui_MainWindow):
"""Set up the main window. Required because Qt is a PITA."""
Expand Down Expand Up @@ -85,10 +89,10 @@ def __init__(self, args: argparse.Namespace):
self.tr = self.translator.translate

# System tray
self.tray_icon = QIcon(os.path.join(script_parent_path, 'assets', 'images', 'icon.ico'))
self.nexus_icon = QIcon(":images/icon.ico")
self.tray = QSystemTrayIcon()
self.tray.activated.connect(self.show_hide)
self.tray.setIcon(self.tray_icon)
self.tray.setIcon(self.nexus_icon)
self.tray.setVisible(True)

# System tray menu
Expand All @@ -101,6 +105,9 @@ def __init__(self, args: argparse.Namespace):
self.tray_menu.addAction(self.quit_tray_menu_action)
self.tray.setContextMenu(self.tray_menu)

# Set window icon - required for Wayland
self.app.setDesktopFileName(f"{__id__}")

# Components
self.start_stop_button: QPushButton = self.window.startStopButton
self.chentry_table: QTableWidget = self.window.chentryTable
Expand Down
3 changes: 2 additions & 1 deletion src/nexus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""All-in-one cross-platform CharaChorder desktop app."""

__author__ = "CharaChorder"
__version__ = "0.3.0"
__id__ = "com.charachorder.nexus"
__version__ = "0.4.0"
Loading