Detect default theme and use it

This commit is contained in:
leha-code 2022-03-20 14:03:17 -04:00
parent 687a91f587
commit 33aa358a28
No known key found for this signature in database
GPG Key ID: 15227A6455DDF7EE
4 changed files with 10 additions and 3 deletions

View File

@ -61,6 +61,7 @@ from PyQt5.QtWebKitWidgets import *
import qdarktheme # Dark style for PyQt5
import pypresence # Discord RPC
from PIL import Image
import darkdetect
# Load dark theme
dark_stylesheet = qdarktheme.load_stylesheet()
@ -80,6 +81,11 @@ if not os.path.exists(f"/home/{USER}/.minecraft-pi/overrides/images/mob/"):
# else:
# TODO: Add a tab with a button to import features from gMCPIL
if darkdetect.isDark():
theme = "dark"
else:
theme = "light"
class ConfigPluto(QDialog):
"""Startup configurator for Planet. Based on QDialog."""
@ -235,7 +241,7 @@ class Planet(QMainWindow):
"hidelauncher": True,
"profile": "Modded MCPE",
"render_distance": "Short",
"theme": "dark",
"theme": theme,
"discord_rpc": True,
}
@ -570,6 +576,8 @@ if __name__ == "__main__":
if os.path.exists(f"/home/{USER}/.planet-launcher/config.json"):
with open(f"/home/{USER}/.planet-launcher/config.json") as file:
app.setPalette(qdarktheme.load_palette(json.loads(file.read())["theme"]))
else:
app.setPalette(qdarktheme.load_palette(theme))
if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"):
pluto = ConfigPluto()

BIN
planet/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -4,7 +4,6 @@ Architecture: all
Maintainer: mcpiscript <mcpiscript@gmail.com>
Depends: python3-pyqt5, python3:any, python3-pyqt5.qtwebkit, python3-pyqt5.qtsvg, python3-pyqt5.qtwebkit, python3-pyqt5.qtmultimedia
Replaces: mcpil, mcpil-r
Provides: python3-pypresence
Recommends: minecraft-pi-reborn-client, minecraft-pi-reborn-server, python3-pyqtdarkmode, python3-mcpi, python3-minecraft-pi, python3-morpheus-mcpi
Section: games
Priority: optional

View File

@ -1,4 +1,4 @@
pip3 install pyqtdarktheme pypresence pillow
pip3 install pyqtdarktheme pypresence pillow darkdetect
link /usr/lib/planet-launcher/main.py /usr/bin/planet-launcher
chmod 755 /usr/lib/planet-launcher/main.py
link /usr/lib/planet-launcher/assets/planet-launcher.desktop /usr/share/applications/planet-launcher.desktop