1
0
Fork 0
mirror of synced 2024-06-26 18:20:50 +12:00
Rare/rare/components/tabs/games/head_bar.py

102 lines
3.5 KiB
Python
Raw Normal View History

2021-09-27 03:43:56 +13:00
from PyQt5.QtCore import QSize, QSettings, pyqtSignal
2021-12-24 22:09:50 +13:00
from PyQt5.QtWidgets import (
QLineEdit,
QLabel,
QPushButton,
QWidget,
QHBoxLayout,
QComboBox,
)
2021-09-27 03:43:56 +13:00
from rare.shared import ApiResultsSingleton
2021-09-27 03:43:56 +13:00
from rare.utils.extra_widgets import SelectViewWidget
from rare.utils.utils import icon
2021-09-27 03:43:56 +13:00
class GameListHeadBar(QWidget):
filterChanged = pyqtSignal(str)
2021-09-27 03:43:56 +13:00
def __init__(self, parent=None):
super(GameListHeadBar, self).__init__(parent=parent)
self.api_results = ApiResultsSingleton()
2021-09-27 03:43:56 +13:00
self.setLayout(QHBoxLayout())
# self.installed_only = QCheckBox(self.tr("Installed only"))
self.settings = QSettings()
# self.installed_only.setChecked(self.settings.value("installed_only", False, bool))
# self.layout.addWidget(self.installed_only)
self.filter = QComboBox()
2021-12-24 22:09:50 +13:00
self.filter.addItems(
[
2022-03-16 09:25:54 +13:00
self.tr("All games"),
2021-12-24 22:09:50 +13:00
self.tr("Installed only"),
self.tr("Offline Games"),
2021-12-20 09:32:18 +13:00
])
self.layout().addWidget(self.filter)
2021-12-24 22:09:50 +13:00
self.available_filters = [
"all",
"installed",
"offline",
]
if self.api_results.bit32_games:
2021-12-31 13:03:59 +13:00
self.filter.addItem(self.tr("32 Bit Games"))
self.available_filters.append("32bit")
if self.api_results.mac_games:
2021-12-31 13:03:59 +13:00
self.filter.addItem(self.tr("Mac games"))
self.available_filters.append("mac")
if self.api_results.no_asset_games:
2021-12-31 13:03:59 +13:00
self.filter.addItem(self.tr("Exclude Origin"))
self.available_filters.append("installable")
2021-12-20 09:32:18 +13:00
self.filter.addItem(self.tr("Include Unreal Engine"))
self.available_filters.append("include_ue")
2021-09-30 10:22:47 +13:00
2021-09-27 03:43:56 +13:00
try:
self.filter.setCurrentIndex(self.settings.value("filter", 0, int))
except TypeError:
self.settings.setValue("filter", 0)
self.filter.setCurrentIndex(0)
2021-09-27 03:43:56 +13:00
self.filter.currentIndexChanged.connect(self.filter_changed)
self.layout().addStretch(1)
self.import_game = QPushButton(icon("mdi.import", "fa.arrow-down"), self.tr("Import Game"))
self.import_clicked = self.import_game.clicked
2021-09-27 03:43:56 +13:00
self.layout().addWidget(self.import_game)
self.egl_sync = QPushButton(icon("mdi.sync", "fa.refresh"), self.tr("Sync with EGL"))
self.egl_sync_clicked = self.egl_sync.clicked
self.layout().addWidget(self.egl_sync)
# FIXME: Until it is ready
# self.egl_sync.setEnabled(False)
2021-09-27 03:43:56 +13:00
self.layout().addStretch(1)
icon_label = QLabel()
icon_label.setPixmap(icon("fa.search").pixmap(QSize(20, 20)))
self.layout().addWidget(icon_label)
self.search_bar = QLineEdit()
self.search_bar.setObjectName("search_bar")
self.search_bar.setFrame(False)
2021-09-27 03:43:56 +13:00
self.search_bar.setMinimumWidth(200)
self.search_bar.setPlaceholderText(self.tr("Search Game"))
self.layout().addWidget(self.search_bar)
self.layout().addStretch(2)
checked = QSettings().value("icon_view", True, bool)
self.view = SelectViewWidget(checked)
self.layout().addWidget(self.view)
self.layout().addStretch(1)
2021-09-27 03:43:56 +13:00
self.refresh_list = QPushButton()
self.refresh_list.setIcon(icon("fa.refresh")) # Reload icon
self.layout().addWidget(self.refresh_list)
def filter_changed(self, i):
self.filterChanged.emit(self.available_filters[i])
2021-09-27 03:43:56 +13:00
self.settings.setValue("filter", i)