Add macOS about menu and test plugin support(early state).
This commit is contained in:
1 parent
77c4be7dcf
commit
deb06f0190
10 files changed
+85
-9
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
from manager.plugin import Plugin, PluginManager
|
||||||
|
import core_lib as core
|
||||||
|
|
||||||
|
__all__ = ["Plugin", "PluginManager", "core"]
|
||||||
@@ -16,3 +16,5 @@ This launcher should adhere to the following rules:
|
|||||||
5: Freedom like a bird (This project uses the MIT license)
|
5: Freedom like a bird (This project uses the MIT license)
|
||||||
"""
|
"""
|
||||||
__website__ = "https://repo.weispace.net/wei/Launcher"
|
__website__ = "https://repo.weispace.net/wei/Launcher"
|
||||||
|
|
||||||
|
from TapLauncher import Plugin, PluginManager, core
|
||||||
@@ -94,11 +94,13 @@ class Launcher(QApplication, LauncherObject):
|
|||||||
move_window_to_center(self.main_window)
|
move_window_to_center(self.main_window)
|
||||||
|
|
||||||
# Set icon
|
# Set icon
|
||||||
if self.icon_path.exists() and platform.system().lower() != "darwin":
|
icon_existing = self.icon_path.exists()
|
||||||
|
if icon_existing and platform.system().lower() != "darwin":
|
||||||
self.setWindowIcon(QIcon(self.icon_path.as_posix()))
|
self.setWindowIcon(QIcon(self.icon_path.as_posix()))
|
||||||
else:
|
elif not icon_existing:
|
||||||
self.logger.error("No icon found.")
|
self.logger.error("No icon found.")
|
||||||
|
|
||||||
|
|
||||||
def exec(self):
|
def exec(self):
|
||||||
# init managers
|
# init managers
|
||||||
self.profile_manager.profile_load.emit()
|
self.profile_manager.profile_load.emit()
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
# nuitka-project: --macos-app-icon={MAIN_DIRECTORY}/resources/icons/apple-app-icon-default.png
|
# nuitka-project: --macos-app-icon={MAIN_DIRECTORY}/resources/icons/apple-app-icon-default.png
|
||||||
# nuitka-project: --macos-app-name="TapLauncher"
|
# nuitka-project: --macos-app-name="TapLauncher"
|
||||||
# nuitka-project: --macos-signed-app-name="net.wei.taplauncher"
|
# nuitka-project: --macos-signed-app-name="net.wei.taplauncher"
|
||||||
# nuitka-project:--output-filename="TapLauncher"
|
# nuitka-project: --output-filename="TapLauncher"
|
||||||
|
# nuitka-project: --output-folder-name=TapLauncher.app
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
class Plugin:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class PluginManager:
|
||||||
|
pass
|
||||||
@@ -10,7 +10,6 @@ from core_lib.game.version_info import LATEST_VERSION_ALIASES
|
|||||||
from manager.profile import ProfileSummary, LaunchProfile, ProfileManager
|
from manager.profile import ProfileSummary, LaunchProfile, ProfileManager
|
||||||
from manager.widgets import AskForRequest, WidgetManager
|
from manager.widgets import AskForRequest, WidgetManager
|
||||||
from pages.process_log import ProcessLogWindow
|
from pages.process_log import ProcessLogWindow
|
||||||
from core_lib.qt.item_button import ItemButton
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileButton(QFrame):
|
class ProfileButton(QFrame):
|
||||||
@@ -87,7 +86,7 @@ class ProfileButton(QFrame):
|
|||||||
self.clicked.emit()
|
self.clicked.emit()
|
||||||
super().mousePressEvent(event)
|
super().mousePressEvent(event)
|
||||||
|
|
||||||
class ProfileListItem(ItemButton):
|
class ProfileListItem(QPushButton):
|
||||||
selected = Signal(object)
|
selected = Signal(object)
|
||||||
|
|
||||||
def __init__(self, profile: ProfileSummary, parent: QWidget | None = None) -> None:
|
def __init__(self, profile: ProfileSummary, parent: QWidget | None = None) -> None:
|
||||||
|
|||||||
@@ -12,10 +12,9 @@ from PySide6.QtWidgets import (
|
|||||||
from manager.profile import ProfileDetail, ProfileManager, ProfileSummary, UpdateProfileRequest
|
from manager.profile import ProfileDetail, ProfileManager, ProfileSummary, UpdateProfileRequest
|
||||||
from manager.game import AvailableVersion
|
from manager.game import AvailableVersion
|
||||||
from pages.add_modded_version import AddModdedVersionDialog
|
from pages.add_modded_version import AddModdedVersionDialog
|
||||||
from core_lib.qt.item_button import ItemButton
|
|
||||||
|
|
||||||
|
|
||||||
class ManageProfileItem(ItemButton):
|
class ManageProfileItem(QPushButton):
|
||||||
selected = Signal(object)
|
selected = Signal(object)
|
||||||
|
|
||||||
def __init__(self, app, profile: ProfileSummary,
|
def __init__(self, app, profile: ProfileSummary,
|
||||||
@@ -26,6 +25,8 @@ class ManageProfileItem(ItemButton):
|
|||||||
self.app = app
|
self.app = app
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
self.setObjectName("manageProfileItem")
|
self.setObjectName("manageProfileItem")
|
||||||
|
# Custom row backgrounds cover the full widget, including native macOS margins.
|
||||||
|
self.setAttribute(Qt.WidgetAttribute.WA_LayoutUsesWidgetRect)
|
||||||
self.setCheckable(True)
|
self.setCheckable(True)
|
||||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
self.setMinimumHeight(64)
|
self.setMinimumHeight(64)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from TapLauncher import Plugin
|
||||||
|
|
||||||
|
class ExperimentalFarm(Plugin):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def entry(context: dict) -> None:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
group = "net.wei"
|
||||||
|
id = "experimentalfarm"
|
||||||
|
name = "Experimental Farm"
|
||||||
|
version = ">=1"
|
||||||
|
entrypoint = "__init__.py:entry"
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from html import escape
|
||||||
|
import sys
|
||||||
|
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
from PySide6.QtCore import QSize
|
from PySide6.QtCore import QSize
|
||||||
from PySide6.QtGui import QIcon, Qt, QPixmap
|
from PySide6.QtGui import QIcon, Qt, QPixmap, QAction
|
||||||
from PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget, QToolButton, \
|
from PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget, QToolButton, \
|
||||||
QStackedWidget
|
QStackedWidget
|
||||||
from PySide6.QtCore import Slot
|
from PySide6.QtCore import Slot
|
||||||
@@ -11,7 +13,7 @@ from PySide6.QtWidgets import QMessageBox, QFileDialog
|
|||||||
from core_lib.qt import messagebox
|
from core_lib.qt import messagebox
|
||||||
from core_lib.qt.progress_dialog import ProgressDialog
|
from core_lib.qt.progress_dialog import ProgressDialog
|
||||||
from core_lib.qt.messagebox import ask_yes_no_with_plain_text
|
from core_lib.qt.messagebox import ask_yes_no_with_plain_text
|
||||||
from constant import MAIN_REPO_URL
|
from constant import MAIN_REPO_URL, LAUNCHER_VERSION, LAUNCHER_NAME, LAUNCHER_DESCRIPTION
|
||||||
from manager.widgets import AskForRequest, SelectPathRequest
|
from manager.widgets import AskForRequest, SelectPathRequest
|
||||||
from pages.account import AccountPage
|
from pages.account import AccountPage
|
||||||
from pages.create_profile import CreateProfilePage
|
from pages.create_profile import CreateProfilePage
|
||||||
@@ -476,3 +478,49 @@ class LauncherMainWindow(QMainWindow):
|
|||||||
widget_signal.ask_for_path.connect(
|
widget_signal.ask_for_path.connect(
|
||||||
self.ask_for_path
|
self.ask_for_path
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.add_mac_os_about_menu()
|
||||||
|
|
||||||
|
def add_mac_os_about_menu(self) -> None:
|
||||||
|
if sys.platform != "darwin" or hasattr(self, "_mac_os_about_dialog"):
|
||||||
|
return
|
||||||
|
|
||||||
|
tr = self.app.tr_text
|
||||||
|
title = f"{tr('About')} {LAUNCHER_NAME}"
|
||||||
|
version = escape(tr("Version: {version}", version=LAUNCHER_VERSION))
|
||||||
|
description = escape(LAUNCHER_DESCRIPTION.strip()).replace("\n", "<br>")
|
||||||
|
|
||||||
|
dialog = QMessageBox(self)
|
||||||
|
dialog.setWindowTitle(title)
|
||||||
|
dialog.setTextFormat(Qt.TextFormat.RichText)
|
||||||
|
|
||||||
|
dialog.setText(
|
||||||
|
f"<b>{escape(LAUNCHER_NAME)}</b><br>{version}<br><br>"
|
||||||
|
f'{description}<br><br><a href="{escape(MAIN_REPO_URL)}">'
|
||||||
|
f"{escape(tr('Main repo'))}</a>"
|
||||||
|
)
|
||||||
|
dialog.setStandardButtons(QMessageBox.StandardButton.Ok)
|
||||||
|
dialog.setWindowModality(Qt.WindowModality.NonModal)
|
||||||
|
|
||||||
|
# Add app icon to dialog
|
||||||
|
icon_path = self.app.icon_dir / "apple-app-icon-default.png"
|
||||||
|
if not icon_path.is_file():
|
||||||
|
icon_path = self.app.icon_path
|
||||||
|
icon = QIcon(str(icon_path))
|
||||||
|
if not icon.isNull():
|
||||||
|
dialog.setWindowIcon(icon)
|
||||||
|
dialog.setIconPixmap(icon.pixmap(QSize(128, 128)))
|
||||||
|
self._mac_os_about_dialog = dialog
|
||||||
|
|
||||||
|
def show_about() -> None:
|
||||||
|
dialog.show()
|
||||||
|
dialog.raise_()
|
||||||
|
dialog.activateWindow()
|
||||||
|
|
||||||
|
menu_bar = self.menuBar()
|
||||||
|
menu_bar.setNativeMenuBar(True)
|
||||||
|
help_menu = menu_bar.addMenu(tr("About"))
|
||||||
|
about_action = QAction(title, self)
|
||||||
|
about_action.setMenuRole(QAction.MenuRole.AboutRole)
|
||||||
|
about_action.triggered.connect(show_about)
|
||||||
|
help_menu.addAction(about_action)
|
||||||
Reference in new issue
Block a user