Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packaging/requirements-flatpak.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
ruff
build
uv-build
installer
setuptools-scm
requests < 3.0
QtAwesome
legendary-gl @ git+https://github.com/RareDevs/legendary@9d32abcdd873b9193b403dc98f3f272cfcc8e897
legendary-gl @ git+https://github.com/RareDevs/legendary@828850273f47432c086d758cd3391047d6dd8ddf
orjson
vdf @ git+https://github.com/solsticegamestudios/vdf@f47c683c1330f0fcddec034fd49c26e41acd63f2
pypresence
2 changes: 1 addition & 1 deletion packaging/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setuptools-scm
requests < 3.0
PySide6-Essentials >= 6.8.1
QtAwesome
legendary-gl @ https://github.com/RareDevs/legendary/archive/9d32abcdd873b9193b403dc98f3f272cfcc8e897.zip
legendary-gl @ https://github.com/RareDevs/legendary/archive/828850273f47432c086d758cd3391047d6dd8ddf.zip
orjson
vdf @ https://github.com/solsticegamestudios/vdf/archive/f47c683c1330f0fcddec034fd49c26e41acd63f2.zip
pywin32 ; platform_system == "Windows"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"requests < 3.0",
"PySide6-Essentials >= 6.8.1",
"QtAwesome",
"legendary-gl @ git+https://github.com/RareDevs/legendary@9d32abcdd873b9193b403dc98f3f272cfcc8e897",
"legendary-gl @ git+https://github.com/RareDevs/legendary@828850273f47432c086d758cd3391047d6dd8ddf",
"orjson",
"vdf @ git+https://github.com/solsticegamestudios/vdf@f47c683c1330f0fcddec034fd49c26e41acd63f2",
"pywin32 ; platform_system == 'Windows'",
Expand Down
23 changes: 1 addition & 22 deletions rare/components/tabs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def __init__(self, settings: RareAppSettings, rcore: RareCore, parent):
self.args = rcore.args()

self.main_bar = MainTabBar(parent=self)
self.main_bar.installEventFilter(self)
self.setTabBar(self.main_bar)

# Generate Tabs
Expand Down Expand Up @@ -67,13 +66,8 @@ def __init__(self, settings: RareAppSettings, rcore: RareCore, parent):
# Account Tab
self.account_widget = AccountWidget(self.signals, self.core, self)
self.account_widget.exit_app.connect(self._on_exit_app)
account_action = QWidgetAction(self)
account_action.setDefaultWidget(self.account_widget)
self.account_menu = QMenu(self)
self.account_menu.addAction(account_action)
self.account_tab = QWidget(self)
self.account_index = self.addTab(
self.account_tab, qta_icon('mdi.account-circle', 'fa5s.user'), self.core.lgd.userdata.get('displayName')
self.account_widget, qta_icon('mdi.account-circle', 'fa5s.user'), self.core.lgd.userdata.get('displayName')
)

# Open game list on click on Games tab button
Expand All @@ -89,21 +83,6 @@ def __init__(self, settings: RareAppSettings, rcore: RareCore, parent):

self.setCurrentIndex(self.games_index)

def eventFilter(self, w: QObject, e: QEvent) -> bool:
if not isinstance(e, QEvent):
return True
if w is self.main_bar and e.type() == QEvent.Type.MouseButtonPress:
tab_idx = self.main_bar.tabAt(e.pos())
if tab_idx == self.account_index:
if e.button() == Qt.MouseButton.LeftButton:
origin = QPoint(
self.main_bar.tabRect(tab_idx).bottomRight().x() - self.account_menu.sizeHint().width(),
self.main_bar.tabRect(tab_idx).bottomRight().y(),
)
self.account_menu.exec(self.mapToGlobal(origin))
return True
return False

@Slot()
def _on_shortcut_activated_games(self):
self.setCurrentIndex(self.games_index)
Expand Down
22 changes: 13 additions & 9 deletions rare/components/tabs/account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import webbrowser

from PySide6.QtCore import Signal, Slot
from PySide6.QtWidgets import QLabel, QPushButton, QSizePolicy, QSpacerItem, QVBoxLayout, QWidget
from PySide6.QtCore import QEvent, QObject, Qt, Signal, Slot
from PySide6.QtWidgets import QLabel, QLayout, QPushButton, QSizePolicy, QSpacerItem, QVBoxLayout, QWidget

from rare.lgndr.core import LegendaryCore
from rare.models.signals import GlobalSignals
Expand All @@ -13,7 +13,7 @@ class AccountWidget(QWidget):
exit_app: Signal = Signal(int)
logout: Signal = Signal()

def __init__(self, signals: GlobalSignals, core: LegendaryCore, parent):
def __init__(self, signals: GlobalSignals, core: LegendaryCore, parent: QWidget | None = None):
super(AccountWidget, self).__init__(parent=parent)
self.signals = signals
self.core = core
Expand All @@ -33,13 +33,17 @@ def __init__(self, signals: GlobalSignals, core: LegendaryCore, parent):
self.quit_button = QPushButton(self.tr('Quit'), parent=self)
self.quit_button.clicked.connect(self._on_quit)

self.center_widget = QWidget(self)
center_widget = QVBoxLayout(self.center_widget)
center_widget.setSizeConstraint(QVBoxLayout.SizeConstraint.SetFixedSize)
center_widget.addWidget(QLabel(self.tr('Logged in as <b>{}</b>').format(username)))
center_widget.addSpacerItem(QSpacerItem(10, 10, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
center_widget.addWidget(self.open_browser)
center_widget.addWidget(self.logout_button)
center_widget.addWidget(self.quit_button)

layout = QVBoxLayout(self)
layout.addWidget(QLabel(self.tr('Logged in as <b>{}</b>').format(username)))
vspacer = QSpacerItem(10, 10, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
layout.addSpacerItem(vspacer)
layout.addWidget(self.open_browser)
layout.addWidget(self.logout_button)
layout.addWidget(self.quit_button)
layout.addWidget(self.center_widget, alignment=Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignTop)

@Slot()
def _on_browser_clicked(self):
Expand Down
8 changes: 8 additions & 0 deletions rare/components/tabs/downloads/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import platform
import queue
import signal
import time
from dataclasses import dataclass
from enum import IntEnum
Expand Down Expand Up @@ -74,6 +75,10 @@ def run(self):
result.app_title = self.rgame.app_title

start_t = time.time()
original_mask: set[int] | None = None
if platform.system() not in {'Windows'}:
# pylint: disable=E1101
original_mask = signal.pthread_sigmask(signal.SIG_BLOCK, {signal.SIGINT})
try:
self.item.download.dlm.logging_queue = cli.logging_queue
self.item.download.dlm.proc_debug = self.debug
Expand Down Expand Up @@ -156,6 +161,9 @@ def run(self):

return
finally:
if original_mask is not None:
# pylint: disable=E1101
signal.pthread_sigmask(signal.SIG_SETMASK, original_mask)
self._finish(result)

def _handle_postinstall(self, postinstall, igame):
Expand Down
2 changes: 1 addition & 1 deletion rare/components/tabs/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, settings: RareAppSettings, rcore: RareCore, parent=None):
library_page_right_layout.addWidget(self.head_bar)

self.details_page = GameDetailsTabs(settings, rcore, self)
self.details_page.back_clicked.connect(self._on_back_clicked)
self.details_page.backClicked.connect(self._on_back_clicked)
self.details_page.import_clicked.connect(self.import_clicked)
self.addWidget(self.details_page)

Expand Down
8 changes: 2 additions & 6 deletions rare/components/tabs/library/details/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import contextlib
import platform as pf

from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QKeyEvent, QShowEvent
from PySide6.QtCore import Signal
from PySide6.QtGui import QShowEvent
from PySide6.QtWidgets import QTreeView

from rare.models.game import RareGame
Expand Down Expand Up @@ -87,10 +87,6 @@ def update_game(self, rgame: RareGame):

self.setCurrentIndex(self.details_index)

def keyPressEvent(self, a0: QKeyEvent):
if a0.key() == Qt.Key.Key_Escape:
self.back_clicked.emit()


class GameMetadataView(QTreeView, SideTabContents):
def __init__(self, parent=None):
Expand Down
1 change: 1 addition & 0 deletions rare/components/tabs/library/details/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def __init__(self, rcore: RareCore, parent=None):
# lk: hide unfinished things
self.ui.description_field.setVisible(False)
self.ui.requirements_frame.setVisible(False)
self.ui.requirements_layout.setContentsMargins(0, 0, 0, 0)

@Slot()
def __on_install(self):
Expand Down
13 changes: 8 additions & 5 deletions rare/components/tabs/library/widgets/library_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
QPixmap,
QShowEvent,
)
from PySide6.QtWidgets import QLabel
from PySide6.QtWidgets import QLabel, QWidget

from rare.widgets.image_widget import ImageWidget


class ProgressLabel(QLabel):
def __init__(self, parent=None):
def __init__(self, parent: QWidget | None = None):
super(ProgressLabel, self).__init__(parent=parent)
if self.parent() is not None:
self.parent().installEventFilter(self)
self.setObjectName(type(self).__name__)
self.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter)
self.setFrameStyle(QLabel.Shape.StyledPanel)
if parent is not None:
parent.installEventFilter(self)

def __center_on_parent(self):
fm = QFontMetrics(self.font())
Expand All @@ -29,6 +29,9 @@ def __center_on_parent(self):
self.setGeometry(rect)

def event(self, e: QEvent) -> bool:
# FIXME: investigate why this happens
if not isinstance(e, QEvent):
return True
if e.type() == QEvent.Type.ParentAboutToChange:
if self.parent() is not None:
self.parent().removeEventFilter(self)
Expand All @@ -41,7 +44,7 @@ def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
self.__center_on_parent()
super().showEvent(a0)
return super().showEvent(a0)

def eventFilter(self, a0: QObject, a1: QEvent) -> bool:
if a0 is self.parent() and a1.type() == QEvent.Type.Resize:
Expand Down
7 changes: 5 additions & 2 deletions rare/components/tabs/store/widgets/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from rare.utils.misc import qta_icon
from rare.widgets.elide_label import ElideLabel
from rare.widgets.image_widget import LoadingSpinnerImageWidget
from rare.widgets.side_tab import SideTabContents, SideTabWidget
from rare.widgets.side_tab import SideTabBar, SideTabContents, SideTabWidget

logger = getLogger('StoreDetails')

Expand Down Expand Up @@ -54,8 +54,11 @@ def __init__(self, installed: list, store_api: StoreAPI, parent=None):
self.in_wishlist = False
self.wishlist = []

self.requirements_tabs = SideTabWidget(parent=self.ui.requirements_frame)
self.requirements_tabs = SideTabWidget(
tab_orientation=SideTabBar.TabOrientation.Vertical, parent=self.ui.requirements_frame
)
self.requirements_tabs.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.ui.requirements_layout.setContentsMargins(0, 0, 0, 0)
self.ui.requirements_layout.addWidget(self.requirements_tabs)
self.ui.requirements_layout.setAlignment(Qt.AlignmentFlag.AlignBottom)

Expand Down
9 changes: 6 additions & 3 deletions rare/resources/static_css/stylesheet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

import qstylizer.style
from PySide6.QtCore import QObject
Expand All @@ -13,6 +14,8 @@
compressAlgo = 'zlib'
compressThreshold = 0

workdir = Path(__file__).parent


def css_name(widget: wrappertype | QObject | type, subwidget: str = ''):
return f'#{widget_object_name(widget, "")}{subwidget}'
Expand Down Expand Up @@ -239,7 +242,7 @@ def css_name(widget: wrappertype | QObject | type, subwidget: str = ''):


if __name__ == '__main__':
with open(os.path.join(os.path.dirname(__file__), 'stylesheet.qss'), 'w', encoding='utf-8') as stylesheet:
with workdir.joinpath('stylesheet.qss').open('w', encoding='utf-8') as stylesheet:
stylesheet.write(f'/* This file is auto-generated from "{os.path.basename(__file__)}". DO NOT EDIT!!! */\n\n')
stylesheet.write(style.toString(recursive=True))

Expand All @@ -255,9 +258,9 @@ def css_name(widget: wrappertype | QObject | type, subwidget: str = ''):
'--threshold',
str(compressThreshold),
'--verbose' if verbose else '',
os.path.join(os.path.dirname(__file__), 'stylesheet.qrc'),
workdir.joinpath('stylesheet.qrc').as_posix(),
'-o',
os.path.join(os.path.dirname(__file__), '__init__.py'),
workdir.joinpath('__init__.py').as_posix(),
],
True,
)
Loading
Loading