-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit abc95a3
Showing
57 changed files
with
36,980 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Byte-compiled / optimized / DLL files | ||
*/__pycache__ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# vscode | ||
.vscode/ | ||
.VSCodeCounter | ||
|
||
# scshub | ||
*.log | ||
tools/config.json | ||
tools/converter_pix.exe | ||
tools/scs_extractor.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SOURCES += SCSHub/view/interface/main_window.py \ | ||
SCSHub/view/interface/home_interface.py \ | ||
SCSHub/view/interface/pix_interface.py \ | ||
SCSHub/view/interface/scs_interface.py \ | ||
SCSHub/view/interface/setting_interface.py \ | ||
SCSHub/view/ui/pix_ui.py \ | ||
SCSHub/view/ui/scs_ui.py \ | ||
|
||
TRANSLATIONS += SCSHub/resource/locale/scshub.ts \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import sys | ||
from PyQt5.QtCore import Qt, QTranslator | ||
from PyQt5.QtWidgets import QApplication | ||
|
||
from qfluentwidgets import FluentTranslator | ||
|
||
from scshub.common.config import cfg | ||
from scshub.view.main_window import MainWindow | ||
|
||
# enable dpi scale | ||
if cfg.get(cfg.dpiScale) == "Auto": | ||
QApplication.setHighDpiScaleFactorRoundingPolicy( | ||
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) | ||
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) | ||
else: | ||
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0" | ||
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale)) | ||
|
||
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) | ||
|
||
# create application | ||
app = QApplication(sys.argv) | ||
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings) | ||
|
||
# internationalization | ||
locale = cfg.get(cfg.language).value | ||
translator = FluentTranslator(locale) | ||
scsHubTranslator = QTranslator() | ||
scsHubTranslator.load(locale, "SCSHub", ".", ":/SCSHub/locale") | ||
|
||
app.installTranslator(translator) | ||
app.installTranslator(scsHubTranslator) | ||
|
||
# create main window | ||
w = MainWindow() | ||
w.show() | ||
|
||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
from PyQt5.QtCore import Qt, QUrl | ||
from PyQt5.QtGui import QDesktopServices | ||
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget, QHBoxLayout | ||
|
||
from qfluentwidgets import (IconWidget, TextWrap, SingleDirectionScrollArea, FlowLayout, CardWidget, | ||
ElevatedCardWidget , FluentIcon) | ||
|
||
from .tool import StyleSheet, signalBus | ||
|
||
|
||
class LinkCard(ElevatedCardWidget): | ||
|
||
def __init__(self, icon, title, content, url, parent=None): | ||
super().__init__(parent=parent) | ||
self.url = QUrl(url) | ||
self.setFixedSize(198, 220) | ||
self.iconWidget = IconWidget(icon, self) | ||
self.titleLabel = QLabel(title, self) | ||
self.contentLabel = QLabel(TextWrap.wrap(content, 20, False)[0], self) | ||
self.urlWidget = IconWidget(FluentIcon.LINK, self) | ||
|
||
self.__initWidget() | ||
|
||
def __initWidget(self): | ||
self.setCursor(Qt.PointingHandCursor) | ||
|
||
self.iconWidget.setFixedSize(54, 54) | ||
self.urlWidget.setFixedSize(16, 16) | ||
|
||
self.vBoxLayout = QVBoxLayout(self) | ||
self.vBoxLayout.setSpacing(0) | ||
self.vBoxLayout.setContentsMargins(24, 24, 24, 24) | ||
self.vBoxLayout.addWidget(self.iconWidget) | ||
self.vBoxLayout.addSpacing(16) | ||
self.vBoxLayout.addWidget(self.titleLabel) | ||
self.vBoxLayout.addSpacing(8) | ||
self.vBoxLayout.addWidget(self.contentLabel) | ||
self.vBoxLayout.setAlignment(Qt.AlignLeft | Qt.AlignTop) | ||
self.urlWidget.move(170, 192) | ||
|
||
self.titleLabel.setObjectName('titleLabel') | ||
self.contentLabel.setObjectName('contentLabel') | ||
|
||
def mouseReleaseEvent(self, e): | ||
super().mouseReleaseEvent(e) | ||
QDesktopServices.openUrl(self.url) | ||
|
||
class LinkCardView(SingleDirectionScrollArea): | ||
|
||
def __init__(self, parent=None): | ||
super().__init__(parent, Qt.Horizontal) | ||
self.view = QWidget(self) | ||
self.hBoxLayout = QHBoxLayout(self.view) | ||
|
||
self.hBoxLayout.setContentsMargins(30, 10, 30, 10) | ||
self.hBoxLayout.setSpacing(16) | ||
self.hBoxLayout.setAlignment(Qt.AlignLeft) | ||
|
||
self.setWidget(self.view) | ||
self.setWidgetResizable(True) | ||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) | ||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) | ||
|
||
self.view.setObjectName('view') | ||
StyleSheet.LINK_CARD.apply(self) | ||
|
||
def addCard(self, icon, title, content, url): | ||
""" add link card """ | ||
card = LinkCard(icon, title, content, url, self.view) | ||
self.hBoxLayout.addWidget(card, 0, Qt.AlignLeft) | ||
|
||
|
||
class InterfaceCard(CardWidget): | ||
|
||
def __init__(self, icon, title, content, routeKey, parent=None): | ||
super().__init__(parent=parent) | ||
self.routekey = routeKey | ||
|
||
self.setCursor(Qt.PointingHandCursor) | ||
|
||
self.iconWidget = IconWidget(icon, self) | ||
self.titleLabel = QLabel(title, self) | ||
self.contentLabel = QLabel(TextWrap.wrap(content, 45, False)[0], self) | ||
|
||
self.hBoxLayout = QHBoxLayout(self) | ||
self.vBoxLayout = QVBoxLayout() | ||
|
||
self.setFixedSize(360, 90) | ||
self.iconWidget.setFixedSize(48, 48) | ||
|
||
self.hBoxLayout.setSpacing(28) | ||
self.hBoxLayout.setContentsMargins(20, 0, 0, 0) | ||
self.vBoxLayout.setSpacing(2) | ||
self.vBoxLayout.setContentsMargins(0, 0, 0, 0) | ||
self.vBoxLayout.setAlignment(Qt.AlignVCenter) | ||
|
||
self.hBoxLayout.setAlignment(Qt.AlignVCenter) | ||
self.hBoxLayout.addWidget(self.iconWidget) | ||
self.hBoxLayout.addLayout(self.vBoxLayout) | ||
self.vBoxLayout.addStretch(1) | ||
self.vBoxLayout.addWidget(self.titleLabel) | ||
self.vBoxLayout.addWidget(self.contentLabel) | ||
self.vBoxLayout.addStretch(1) | ||
|
||
self.titleLabel.setObjectName('titleLabel') | ||
self.contentLabel.setObjectName('contentLabel') | ||
|
||
def mouseReleaseEvent(self, e): | ||
super().mouseReleaseEvent(e) | ||
signalBus.switchToInterface.emit(self.routekey) | ||
|
||
class InterfaceCardView(QWidget): | ||
|
||
def __init__(self, title: str, parent=None): | ||
super().__init__(parent=parent) | ||
self.titleLabel = QLabel(title, self) | ||
self.vBoxLayout = QVBoxLayout(self) | ||
self.flowLayout = FlowLayout() | ||
|
||
self.vBoxLayout.setContentsMargins(30, 5, 30, 5) | ||
self.vBoxLayout.setSpacing(10) | ||
self.flowLayout.setContentsMargins(0, 0, 0, 0) | ||
self.flowLayout.setHorizontalSpacing(12) | ||
self.flowLayout.setVerticalSpacing(12) | ||
|
||
self.vBoxLayout.addWidget(self.titleLabel) | ||
self.vBoxLayout.addLayout(self.flowLayout, 1) | ||
|
||
self.titleLabel.setObjectName('viewTitleLabel') | ||
StyleSheet.SAMPLE_CARD.apply(self) | ||
|
||
def addSampleCard(self, icon, title, content, routeKey): | ||
""" add sample card """ | ||
card = InterfaceCard(icon, title, content, routeKey, self) | ||
self.flowLayout.addWidget(card) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import sys, os | ||
from enum import Enum | ||
|
||
from PyQt5.QtCore import QLocale | ||
|
||
from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator, | ||
OptionsValidator, Theme, ConfigSerializer) | ||
|
||
from .tool import TOOLS_PATH | ||
|
||
|
||
class Language(Enum): | ||
""" Language enumeration """ | ||
|
||
ENGLISH = QLocale(QLocale.English) | ||
AUTO = QLocale() | ||
|
||
|
||
class LanguageSerializer(ConfigSerializer): | ||
""" Language serializer """ | ||
|
||
def serialize(self, language): | ||
return language.value.name() if language != Language.AUTO else "Auto" | ||
|
||
def deserialize(self, value: str): | ||
return Language(QLocale(value)) if value != "Auto" else Language.AUTO | ||
|
||
|
||
def isWin11(): | ||
return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000 | ||
|
||
|
||
class Config(QConfig): | ||
""" Config of application """ | ||
|
||
# main window | ||
micaEnabled = ConfigItem("MainWindow", "MicaEnabled", isWin11(), BoolValidator()) | ||
dpiScale = OptionsConfigItem( | ||
"MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True) | ||
language = OptionsConfigItem( | ||
"MainWindow", "Language", Language.ENGLISH, OptionsValidator(Language), LanguageSerializer(), restart=True) | ||
|
||
|
||
cfg = Config() | ||
cfg.themeMode.value = Theme.AUTO | ||
qconfig.load(os.path.join(TOOLS_PATH, "config.json"), cfg) |
Oops, something went wrong.