3 Commits

7 changed files with 133 additions and 40 deletions

View File

@@ -130,8 +130,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.ui.menuHelp.setWindowFlags(self.ui.menuHelp.windowFlags() | Qt.FramelessWindowHint)
self.ui.menuHelp.setWindowFlags(self.ui.menuHelp.windowFlags() | Qt.NoDropShadowWindowHint)
self.ui.menuHelp.setAttribute(Qt.WA_TranslucentBackground)
# Load the custom information icon.
icon = QIcon(os.path.join(os.path.dirname(__file__), "resources", "information.svg"))
# Save some light/dark theme values for later, including the appropriately colored info icon.
if is_dark_theme():
bg_color = "#2b2b2b"
icon = QIcon(os.path.join(os.path.dirname(__file__), "resources", "information_white.svg"))
else:
bg_color = "#e3e3e3"
icon = QIcon(os.path.join(os.path.dirname(__file__), "resources", "information_black.svg"))
self.ui.actionAbout.setIcon(icon)
self.ui.actionAbout_Qt.setIcon(icon)
# Title tree loading code. Now powered by Models:tm:
@@ -155,10 +160,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.trees[tree].collapsed.connect(lambda: self.resize_tree(self.ui.platform_tabs.currentIndex()))
# This stylesheet patch allows me to add the correct padding above the scrollbar so that it doesn't overlap
# the QTreeView's header.
if is_dark_theme():
bg_color = "#2b2b2b"
else:
bg_color = "#e3e3e3"
self.trees[tree].setStyleSheet(self.trees[tree].styleSheet() + f"""
QTreeView QScrollBar::sub-line:vertical {{
border: 0;
@@ -655,10 +656,18 @@ if __name__ == "__main__":
# Load Fusion because that's objectively the best base theme, and then load the fancy stylesheet on top to make
# NUSGet look nice and pretty.
app.setStyle("fusion")
if is_dark_theme():
stylesheet = open(os.path.join(os.path.dirname(__file__), "resources", "style_dark.qss")).read()
else:
stylesheet = open(os.path.join(os.path.dirname(__file__), "resources", "style_light.qss")).read()
theme_sheet = "style_dark.qss"
try:
# Check for an environment variable overriding the theme. This is mostly for theme testing but would also allow
# you to force a theme.
if os.environ["THEME"].lower() == "light":
theme_sheet = "style_light.qss"
except KeyError:
if is_dark_theme():
theme_sheet = "style_dark.qss"
else:
theme_sheet = "style_light.qss"
stylesheet = open(os.path.join(os.path.dirname(__file__), "resources", theme_sheet)).read()
image_path_prefix = pathlib.Path(os.path.join(os.path.dirname(__file__), "resources")).resolve().as_posix()
stylesheet = stylesheet.replace("{IMAGE_PREFIX}", image_path_prefix)
app.setStyleSheet(stylesheet)

View File

@@ -54,6 +54,7 @@ def connect_label_to_checkbox(label, checkbox):
checkbox.toggle()
label.mousePressEvent = toggle_checkbox
def connect_is_enabled_to_checkbox(items, chkbox):
for item in items:
if chkbox.isChecked():
@@ -61,6 +62,7 @@ def connect_is_enabled_to_checkbox(items, chkbox):
else:
item.setEnabled(False)
def check_nusget_updates(app, current_version: str, progress_callback=None) -> str | None:
# Simple function to make a request to the GitHub API and then check if the latest available version is newer.
gh_api_request = requests.get(url="https://api.github.com/repos/NinjaCheetah/NUSGet/releases/latest", stream=True)
@@ -80,6 +82,7 @@ def check_nusget_updates(app, current_version: str, progress_callback=None) -> s
progress_callback.emit(app.translate("MainWindow", "\n\nYou're running the latest release of NUSGet."))
return None
def get_config_file() -> pathlib.Path:
config_dir = pathlib.Path(os.path.join(
os.environ.get('APPDATA') or
@@ -90,11 +93,13 @@ def get_config_file() -> pathlib.Path:
config_dir.mkdir(exist_ok=True)
return config_dir.joinpath("config.json")
def save_config(config_data: dict) -> None:
config_file = get_config_file()
print(f"writing data: {config_data}")
open(config_file, "w").write(json.dumps(config_data))
def update_setting(config_data: dict, setting: str, value: any) -> None:
config_data[setting] = value
save_config(config_data)

View File

@@ -17,28 +17,6 @@ class AboutNUSGet(QDialog):
self.setFixedWidth(450)
self.setFixedHeight(500)
# Set background color to match main app
self.setStyleSheet("""
QLabel[class="title"] {
font-size: 20px;
font-weight: bold;
}
QLabel[class="version"] {
font-size: 13px;
color: #aaaaaa;
}
QLabel[class="copyright"] {
font-size: 12px;
color: #888888;
}
QLabel[class="header"] {
font-size: 14px;
font-weight: bold;
border-bottom: 1px solid #444444;
padding-bottom: 4px;
margin-top: 8px;
}""")
# Create main layout
self.layout = QVBoxLayout()
self.layout.setSpacing(4)

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32"
height="32"
viewBox="0 0 32 32"
version="1.1"
id="svg1"
inkscape:version="1.4.1 (93de688d07, 2025-03-30)"
sodipodi:docname="information_black.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#999999"
borderopacity="1"
inkscape:showpageshadow="2"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="px"
inkscape:zoom="25.125"
inkscape:cx="16.139303"
inkscape:cy="16.835821"
inkscape:window-width="1920"
inkscape:window-height="1012"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="path1"
style="fill:#000000;stroke:#000000;stroke-width:1.306;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
d="M 16 1.6523438 A 14.346852 14.346854 0 0 0 1.6523438 16 A 14.346852 14.346854 0 0 0 16 30.347656 A 14.346852 14.346854 0 0 0 30.347656 16 A 14.346852 14.346854 0 0 0 16 1.6523438 z M 15.992188 4.7265625 C 16.642424 4.7265625 17.197259 4.94079 17.65625 5.3710938 C 18.124803 5.8013975 18.359375 6.3235594 18.359375 6.9355469 C 18.359375 7.5475344 18.124803 8.0677432 17.65625 8.4980469 C 17.197259 8.9283506 16.642424 9.1445312 15.992188 9.1445312 C 15.341951 9.1445312 14.787116 8.9283506 14.328125 8.4980469 C 13.869134 8.0677432 13.640625 7.5475344 13.640625 6.9355469 C 13.640625 6.3235594 13.869134 5.8013975 14.328125 5.3710938 C 14.787116 4.94079 15.341951 4.7265625 15.992188 4.7265625 z M 13.841797 11.238281 L 18.144531 11.238281 L 18.144531 27.273438 L 13.841797 27.273438 L 13.841797 11.238281 z " />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -10,6 +10,33 @@ QMainWindow QLabel {
color: #ffffff;
}
QDialog QLabel {
color: #ffffff;
}
QDialog QLabel[class="title"] {
font-size: 20px;
font-weight: bold;
}
QDialog QLabel[class="version"] {
font-size: 13px;
color: #aaaaaa;
}
QDialog QLabel[class="copyright"] {
font-size: 12px;
color: #888888;
}
QDialog QLabel[class="header"] {
font-size: 14px;
font-weight: bold;
border-bottom: 1px solid #444444;
padding-bottom: 4px;
margin-top: 8px;
}
QMenuBar {
background-color: #2b2b2b;
}

View File

@@ -10,18 +10,46 @@ QMainWindow QLabel {
color: #000000;
}
QDialog QLabel {
color: #000000;
}
QDialog QLabel[class="title"] {
font-size: 20px;
font-weight: bold;
}
QDialog QLabel[class="version"] {
font-size: 13px;
color: #777777;
}
QDialog QLabel[class="copyright"] {
font-size: 12px;
color: #444444;
}
QDialog QLabel[class="header"] {
font-size: 14px;
font-weight: bold;
border-bottom: 1px solid #111111;
padding-bottom: 4px;
margin-top: 8px;
}
QMenuBar {
background-color: #ffffff;
background-color: #e3e3e3;
color: #000000;
}
QMenuBar::item:selected {
background-color: rgba(60, 60, 60, 1);
color: white;
background-color: rgb(195, 195, 195);
color: #000000;
}
QMenuBar::item:pressed {
background-color: #1a73e8;
color: #000000;
color: #ffffff;
}
QMenu {
@@ -42,7 +70,7 @@ QMenu::item {
QMenu::item:selected {
background-color: #1a73e8;
color: #000000;
color: #ffffff;
}
QMenu::icon {
@@ -107,7 +135,7 @@ QLineEdit:focus {
QLineEdit:disabled {
background-color: rgba(182, 182, 182, 0.5);
border: 1px solid rgba(100, 100, 100, 0.3);
color: rgba(255, 255, 255, 0.3);
color: rgba(143, 143, 143, 0.3);
}
QTabWidget::pane {
@@ -223,7 +251,7 @@ QPushButton:pressed {
QPushButton:disabled {
background-color: rgba(182, 182, 182, 0.5);
border: 1px solid rgba(100, 100, 100, 0.3);
color: rgba(255, 255, 255, 0.3);
color: rgba(143, 143, 143, 0.3);
}
QComboBox {
@@ -373,7 +401,7 @@ WrapCheckboxWidget:disabled {
}
WrapCheckboxWidget QLabel:disabled {
color: #919191;
color: rgba(143, 143, 143, 0.3);
}
WrapCheckboxWidget QCheckBox::indicator {