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
|
|
|
|
2022-02-26 06:43:27 +13:00
|
|
|
from rare.shared import ApiResultsSingleton
|
2021-09-27 03:43:56 +13:00
|
|
|
from rare.utils.extra_widgets import SelectViewWidget
|
2022-01-06 03:44:29 +13:00
|
|
|
from rare.utils.utils import icon
|
2021-09-27 03:43:56 +13:00
|
|
|
|
|
|
|
|
|
|
|
class GameListHeadBar(QWidget):
|
2021-10-12 10:19:32 +13:00
|
|
|
filterChanged = pyqtSignal(str)
|
2021-09-27 03:43:56 +13:00
|
|
|
|
2021-10-12 10:19:32 +13:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(GameListHeadBar, self).__init__(parent=parent)
|
2022-02-26 06:43:27 +13:00
|
|
|
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(
|
|
|
|
[
|
|
|
|
self.tr("All"),
|
|
|
|
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",
|
|
|
|
]
|
2022-02-26 06:43:27 +13:00
|
|
|
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")
|
|
|
|
|
2022-02-26 06:43:27 +13:00
|
|
|
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")
|
|
|
|
|
2022-02-26 06:43:27 +13:00
|
|
|
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)
|
2022-01-07 13:49:29 +13:00
|
|
|
self.filter.setCurrentIndex(0)
|
2021-09-27 03:43:56 +13:00
|
|
|
|
|
|
|
self.filter.currentIndexChanged.connect(self.filter_changed)
|
|
|
|
self.layout().addStretch(1)
|
|
|
|
|
2022-01-06 03:44:29 +13:00
|
|
|
self.import_game = QPushButton(icon("mdi.import", "fa.arrow-down"), self.tr("Import Game"))
|
2021-10-12 10:19:32 +13:00
|
|
|
self.import_clicked = self.import_game.clicked
|
2021-09-27 03:43:56 +13:00
|
|
|
self.layout().addWidget(self.import_game)
|
|
|
|
|
2022-01-06 03:44:29 +13:00
|
|
|
self.egl_sync = QPushButton(icon("mdi.sync", "fa.refresh"), self.tr("Sync with EGL"))
|
2021-10-12 10:19:32 +13:00
|
|
|
self.egl_sync_clicked = self.egl_sync.clicked
|
|
|
|
self.layout().addWidget(self.egl_sync)
|
|
|
|
# FIXME: Until it is ready
|
2021-10-13 08:11:52 +13:00
|
|
|
# self.egl_sync.setEnabled(False)
|
2021-10-12 10:19:32 +13:00
|
|
|
|
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)
|
2021-10-13 08:11:52 +13:00
|
|
|
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-10-12 10:19:32 +13:00
|
|
|
|
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):
|
2021-10-12 10:19:32 +13:00
|
|
|
self.filterChanged.emit(self.available_filters[i])
|
2021-09-27 03:43:56 +13:00
|
|
|
self.settings.setValue("filter", i)
|