Add customize qss support for theme.
Fix an issue that causes all feature flags will not be added to the launch command regardless of it is enabled. Add some default themes.
This commit is contained in:
1 parent
1754b01230
commit
b7af7e3469
53 files changed
+1319
-130
No files matched your search
@@ -10,6 +10,7 @@ from core_lib.game.version_info import LATEST_VERSION_ALIASES
|
||||
from manager.profile import ProfileSummary, LaunchProfile, ProfileManager
|
||||
from manager.widgets import AskForRequest, WidgetManager
|
||||
from pages.process_log import ProcessLogWindow
|
||||
from core_lib.qt.item_button import ItemButton
|
||||
|
||||
|
||||
class ProfileButton(QFrame):
|
||||
@@ -46,7 +47,6 @@ class ProfileButton(QFrame):
|
||||
self.version_label.setObjectName("profileVersion")
|
||||
self.arrow_label = QLabel("▾")
|
||||
self.arrow_label.setObjectName("profileArrow")
|
||||
self.arrow_label.setStyleSheet("border-style:solid; background-color: transparent; ")
|
||||
self.arrow_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.arrow_label.setFixedWidth(24)
|
||||
|
||||
@@ -87,7 +87,7 @@ class ProfileButton(QFrame):
|
||||
self.clicked.emit()
|
||||
super().mousePressEvent(event)
|
||||
|
||||
class ProfileListItem(QPushButton):
|
||||
class ProfileListItem(ItemButton):
|
||||
selected = Signal(object)
|
||||
|
||||
def __init__(self, profile: ProfileSummary, parent: QWidget | None = None) -> None:
|
||||
@@ -209,7 +209,7 @@ class LaunchProfilePage(QWidget):
|
||||
|
||||
# Widgets
|
||||
self.status_label = QLabel(self.app.tr_text("Select a profile to launch"))
|
||||
self.status_label.setStyleSheet("font-size: 12px; font-weight: 600;")
|
||||
self.status_label.setObjectName("launchStatus")
|
||||
self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
# Profile button (just like the official launcher look like)
|
||||
|
||||
@@ -12,9 +12,10 @@ from PySide6.QtWidgets import (
|
||||
from manager.profile import ProfileDetail, ProfileManager, ProfileSummary, UpdateProfileRequest
|
||||
from manager.game import AvailableVersion
|
||||
from pages.add_modded_version import AddModdedVersionDialog
|
||||
from core_lib.qt.item_button import ItemButton
|
||||
|
||||
|
||||
class ManageProfileItem(QPushButton):
|
||||
class ManageProfileItem(ItemButton):
|
||||
selected = Signal(object)
|
||||
|
||||
def __init__(self, app, profile: ProfileSummary,
|
||||
|
||||
+2
-69
@@ -3,6 +3,7 @@ import threading
|
||||
from collections import deque
|
||||
from collections.abc import Callable
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from PySide6.QtGui import QCloseEvent
|
||||
@@ -79,75 +80,7 @@ class ProcessLogWindow(QMainWindow):
|
||||
layout.addWidget(self.log_output)
|
||||
self.setCentralWidget(container)
|
||||
|
||||
self.setStyleSheet(
|
||||
"""
|
||||
QMainWindow {
|
||||
spacing: 0;
|
||||
}
|
||||
|
||||
QPlainTextEdit {
|
||||
background-color: #0f0f10;
|
||||
color: "#e5e5e5";
|
||||
font-family: Consolas;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
QScrollBar:vertical {
|
||||
background-color: #0f0f10;
|
||||
width: 5px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical {
|
||||
background-color: #3a3a3a;
|
||||
min-height: 24px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical:hover {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:vertical,
|
||||
QScrollBar::sub-line:vertical {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
QScrollBar::add-page:vertical,
|
||||
QScrollBar::sub-page:vertical {
|
||||
background: none;
|
||||
}
|
||||
|
||||
|
||||
/* Horizontal scrollbar */
|
||||
|
||||
QScrollBar:horizontal {
|
||||
background-color: #0f0f10;
|
||||
height: 5px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
QScrollBar::handle:horizontal {
|
||||
background-color: #3a3a3a;
|
||||
min-width: 24px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:horizontal:hover {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:horizontal,
|
||||
QScrollBar::sub-line:horizontal {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
QScrollBar::add-page:horizontal,
|
||||
QScrollBar::sub-page:horizontal {
|
||||
background: none;
|
||||
}
|
||||
"""
|
||||
)
|
||||
self.app.apply_qss(Path("process_log.qss"), self.setStyleSheet)
|
||||
|
||||
self._signals.output.connect(self._append_output)
|
||||
self._signals.finished.connect(self._process_finished)
|
||||
|
||||
+8
-1
@@ -16,6 +16,7 @@ from PySide6.QtWidgets import (
|
||||
)
|
||||
|
||||
from constant import LAUNCHER_DESCRIPTION, LAUNCHER_NAME, LAUNCHER_VERSION
|
||||
from core_lib.qt import messagebox
|
||||
from manager.settings_models import AccountSettings, AppearanceSettings, GeneralSettings
|
||||
|
||||
LANGUAGE_LABELS = {
|
||||
@@ -403,6 +404,7 @@ class SettingsPage(QWidget):
|
||||
self.client_id_edit.selectAll()
|
||||
return False
|
||||
|
||||
old_theme = self.settings.get("appearance", AppearanceSettings).theme
|
||||
data = {
|
||||
"general": {"language": self.language_combo.currentData()},
|
||||
"appearance": {"theme": self.theme_combo.currentData()},
|
||||
@@ -410,7 +412,7 @@ class SettingsPage(QWidget):
|
||||
"credentials_save_method": selected_credentials_method,
|
||||
"token_refresh_interval":
|
||||
current_token_refresh_interval
|
||||
},
|
||||
}
|
||||
}
|
||||
try:
|
||||
self.settings.validate(data)
|
||||
@@ -456,6 +458,11 @@ class SettingsPage(QWidget):
|
||||
QMessageBox.critical(self, self.app.tr_text("Settings error"), str(error))
|
||||
return False
|
||||
|
||||
if old_theme !=self.settings.get("appearance", AppearanceSettings).theme:
|
||||
messagebox.info(None, "Launcher",
|
||||
self.app.tr_text("To make all page apply new theme."
|
||||
" Is recommend to restart the launcher after change it."))
|
||||
|
||||
self._settings_dirty = False
|
||||
selected_language = data["general"]["language"]
|
||||
self.app.apply_language(selected_language)
|
||||
|
||||
+8
-9
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import threading
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
@@ -10,6 +9,7 @@ from PySide6.QtCore import Qt, QObject, Signal, Slot
|
||||
from PySide6.QtWidgets import QPushButton, QVBoxLayout, QPlainTextEdit, \
|
||||
QHBoxLayout, QComboBox, QWidget
|
||||
|
||||
from constant import CLIENT_ID
|
||||
from core_lib.common.common import FileObject, download_multiple_files
|
||||
from core_lib.common.exception import VersionNotSelectedException, UnsupportedPlatformException, \
|
||||
NativeResolveException, DownloadException, DependencyException, AssetManifestFetchException, \
|
||||
@@ -106,12 +106,7 @@ class TestPage(QWidget):
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
self.setStyleSheet(
|
||||
textwrap.dedent("""
|
||||
QPushButton#ActionButton {
|
||||
padding: 6px 12px;
|
||||
}
|
||||
"""))
|
||||
self.app.apply_qss(Path("test.qss"), self.setStyleSheet)
|
||||
|
||||
self.signals = self.PageSignals(self)
|
||||
|
||||
@@ -663,11 +658,13 @@ class TestPage(QWidget):
|
||||
game_args, jvm_args = find_game_and_jvm_args(target_args)
|
||||
parsed_jvm_args = parse_and_generate_arguments(
|
||||
jvm_args,
|
||||
arg_maps
|
||||
arg_maps,
|
||||
strict_placeholders=False,
|
||||
)
|
||||
parsed_game_args = parse_and_generate_arguments(
|
||||
game_args,
|
||||
arg_maps
|
||||
arg_maps,
|
||||
strict_placeholders=False,
|
||||
)
|
||||
self.widget_mgr.download_signal.log.emit(f"Parsed jvm arguments: \n{parsed_jvm_args}\n{" ".join(parsed_jvm_args)}")
|
||||
self.widget_mgr.download_signal.log.emit(f"Parsed game arguments: \n{parsed_game_args}\n{" ".join(parsed_game_args)}")
|
||||
@@ -772,6 +769,7 @@ class TestPage(QWidget):
|
||||
classpath=classpath,
|
||||
classpath_separator=";",
|
||||
library_directory=libraries_dir.as_posix(),
|
||||
clientid=CLIENT_ID,
|
||||
)
|
||||
|
||||
target_args = arguments if arguments else old_args
|
||||
@@ -818,6 +816,7 @@ class TestPage(QWidget):
|
||||
main_class=main_class,
|
||||
java_path=java_path,
|
||||
full_args=target_args,
|
||||
strict_placeholders=False,
|
||||
)
|
||||
|
||||
self.widget_mgr.download_signal.log.emit(f"Launch command: {cmd}")
|
||||
|
||||
Reference in new issue
Block a user