Rare Settings
This commit is contained in:
parent
9b465861c1
commit
2e67eea56a
|
@ -23,7 +23,7 @@ class InstallDialog(QDialog):
|
|||
|
||||
self.layout.addLayout(self.form)
|
||||
|
||||
self.ok_btn = QPushButton("Get Download infos")
|
||||
self.ok_btn = QPushButton("Next")
|
||||
self.ok_btn.clicked.connect(self.ok)
|
||||
self.cancel = QPushButton("Cancel")
|
||||
self.cancel.clicked.connect(lambda: self.close())
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import os
|
||||
from getpass import getuser
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLabel, QButtonGroup, QRadioButton
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
|
||||
|
@ -12,4 +15,58 @@ class ImportWidget(QWidget):
|
|||
self.core = core
|
||||
|
||||
self.back = QPushButton("Back")
|
||||
self.layout.addWidget(self.back)
|
||||
self.layout.addWidget(self.back)
|
||||
self.title = QLabel("<h3>Import existing Login session</h3>")
|
||||
self.title.setWordWrap(True)
|
||||
self.layout.addWidget(self.title)
|
||||
appdata_paths = self.get_appdata_paths()
|
||||
|
||||
if len(appdata_paths) == 0:
|
||||
self.infoText = QLabel("Found Installations here. \n<b>Note:</b> You will get logged out there")
|
||||
self.infoText.setWordWrap(True)
|
||||
self.layout.addWidget(self.infoText)
|
||||
|
||||
else:
|
||||
self.btn_group = QButtonGroup()
|
||||
for i,p in enumerate(appdata_paths):
|
||||
radio_button = QRadioButton(p)
|
||||
if i == 0:
|
||||
radio_button.setChecked(True)
|
||||
self.btn_group.addButton(radio_button)
|
||||
self.layout.addWidget(radio_button)
|
||||
|
||||
self.appdata_path_text = QLabel(self.tr("Appdata path: ") + str(self.core.egl.appdata_path))
|
||||
self.appdata_path_text.setWordWrap(True)
|
||||
self.login_text = QLabel("")
|
||||
# self.layout.addWidget(self.btn_group)
|
||||
self.layout.addWidget(self.login_text)
|
||||
self.layout.addStretch(1)
|
||||
self.import_btn = QPushButton("Import")
|
||||
self.layout.addWidget(self.import_btn)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def get_appdata_paths(self) -> list:
|
||||
if self.core.egl.appdata_path:
|
||||
return [self.core.egl.appdata_path]
|
||||
|
||||
else: # Linux
|
||||
wine_paths = []
|
||||
possible_wine_paths = [os.path.expanduser('~/Games/epic-games-store/'),
|
||||
os.path.expanduser('~/.wine/')]
|
||||
if os.environ.get("WINEPREFIX"):
|
||||
possible_wine_paths.append(os.environ.get("WINEPREFIX"))
|
||||
|
||||
for i in possible_wine_paths:
|
||||
if os.path.exists(i):
|
||||
if os.path.exists(os.path.join(i, "drive_c/users", getuser(),
|
||||
'Local Settings/Application Data/EpicGamesLauncher',
|
||||
'Saved/Config/Windows')):
|
||||
wine_paths.append(i)
|
||||
|
||||
if len(wine_paths) > 0:
|
||||
appdata_dirs = [
|
||||
os.path.join(i, "drive_c/users", getuser(), 'Local Settings/Application Data/EpicGamesLauncher',
|
||||
'Saved/Config/Windows') for i in wine_paths]
|
||||
return appdata_dirs
|
||||
return []
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QStackedLayout, QWidget, QPushButton
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare.Components.Dialogs.Login import BrowserLogin
|
||||
from Rare.Components.Dialogs.Login import ImportWidget
|
||||
|
||||
|
||||
# Login Opportunities: Browser, Import
|
||||
from Rare.Components.Dialogs.Login.BrowserLogin import BrowserLogin
|
||||
from Rare.Components.Dialogs.Login.ImportWidget import ImportWidget
|
||||
|
||||
|
||||
class LoginDialog(QDialog):
|
||||
|
@ -16,7 +15,6 @@ class LoginDialog(QDialog):
|
|||
|
||||
self.core = core
|
||||
self.setWindowTitle("Rare - Login")
|
||||
self.setGeometry(0, 0, 400, 600)
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
|
@ -53,6 +51,7 @@ class LoginDialog(QDialog):
|
|||
self.layout.addWidget(self.browser_widget)
|
||||
|
||||
self.import_widget = ImportWidget(self.core)
|
||||
self.import_widget.back.clicked.connect(lambda: self.layout.setCurrentIndex(0))
|
||||
self.layout.addWidget(self.import_widget)
|
||||
|
||||
self.layout.addWidget(LoginSuccessfulWidget())
|
||||
|
|
|
@ -4,7 +4,7 @@ from PyQt5.QtCore import QThread, pyqtSignal
|
|||
from PyQt5.QtWidgets import QDialog, QLabel, QProgressBar, QVBoxLayout
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare.Components.Dialogs.Login import LoginDialog
|
||||
from Rare.Components.Dialogs.Login.LoginDialog import LoginDialog
|
||||
from Rare.utils.utils import download_images
|
||||
logger = getLogger("Login")
|
||||
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QTabWidget, QTabBar, QWidget, QToolButton, QWidgetAction, QMenu
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare import style_path
|
||||
from Rare.Components.Tabs.Account.AccountWidget import MiniWidget
|
||||
from Rare.Components.Tabs.Downloads.DownloadTab import DownloadTab
|
||||
from Rare.Components.Tabs.Games.GamesTab import Games
|
||||
from Rare.Components.Tabs.Settings.SettingsTab import SettingsTab
|
||||
|
||||
|
||||
class TabWidget(QTabWidget):
|
||||
def __init__(self, core):
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(TabWidget, self).__init__()
|
||||
self.setTabBar(TabBar(2))
|
||||
|
||||
self.settings = SettingsTab(core)
|
||||
self.game_list = Games(core)
|
||||
self.addTab(self.game_list, self.tr("Games"))
|
||||
self.downloadTab = DownloadTab(core)
|
||||
|
@ -26,8 +28,9 @@ class TabWidget(QTabWidget):
|
|||
self.addTab(self.account, "")
|
||||
self.setTabEnabled(3, False)
|
||||
# self.settings = SettingsTab(core)
|
||||
self.settings = QWidget()
|
||||
self.addTab(self.settings, QIcon(style_path + "/Icons/settings.png"), "")
|
||||
|
||||
self.addTab(self.settings, QIcon(style_path + "/Icons/settings.png"), None)
|
||||
|
||||
self.tabBar().setTabButton(3, self.tabBar().RightSide, TabButtonWidget(core))
|
||||
|
||||
def resizeEvent(self, event):
|
||||
|
@ -39,6 +42,7 @@ class TabBar(QTabBar):
|
|||
def __init__(self, expanded):
|
||||
super(TabBar, self).__init__()
|
||||
self._expanded = expanded
|
||||
self.setObjectName("main_tab_bar")
|
||||
|
||||
def tabSizeHint(self, index):
|
||||
size = super(TabBar, self).tabSizeHint(index)
|
||||
|
@ -55,6 +59,7 @@ class TabButtonWidget(QToolButton):
|
|||
super(TabButtonWidget, self).__init__()
|
||||
self.setText("Icon")
|
||||
self.setPopupMode(QToolButton.InstantPopup)
|
||||
|
||||
self.setIcon(QIcon(style_path + "/Icons/account.png"))
|
||||
self.setToolTip("Account")
|
||||
self.setMenu(QMenu())
|
||||
|
|
|
@ -11,7 +11,7 @@ class MiniWidget(QWidget):
|
|||
self.layout = QVBoxLayout()
|
||||
self.core = core
|
||||
self.layout.addWidget(QLabel("Account"))
|
||||
self.layout.addWidget(QLabel("Logged in as "+ self.core.lgd.userdata["display_name"]))
|
||||
self.layout.addWidget(QLabel("Logged in as " + self.core.lgd.userdata.get("display_name")))
|
||||
|
||||
self.open_browser = QPushButton("Account settings")
|
||||
self.open_browser.clicked.connect(self.open_account)
|
||||
|
@ -30,8 +30,6 @@ class MiniWidget(QWidget):
|
|||
if reply == QMessageBox.Yes:
|
||||
self.core.lgd.invalidate_userdata()
|
||||
QCoreApplication.exit(0)
|
||||
# self.core.lgd.invalidate_userdata()
|
||||
# exit()
|
||||
|
||||
def open_account(self):
|
||||
webbrowser.open("https://www.epicgames.com/account/personal?productName=epicgames")
|
||||
webbrowser.open("https://www.epicgames.com/account/personal?productName=epicgames")
|
||||
|
|
|
@ -3,6 +3,8 @@ import subprocess
|
|||
import time
|
||||
from logging import getLogger
|
||||
|
||||
from legendary.models.game import Game
|
||||
from notifypy import Notify
|
||||
from PyQt5.QtCore import QThread, pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar
|
||||
from legendary.core import LegendaryCore
|
||||
|
@ -80,6 +82,7 @@ class DownloadTab(QWidget):
|
|||
super(DownloadTab, self).__init__()
|
||||
self.core = core
|
||||
self.layout = QVBoxLayout()
|
||||
self.active_game: Game = None
|
||||
|
||||
self.installing_game = QLabel("Installing Game: None")
|
||||
self.dl_speed = QLabel("Download speed: 0MB/s")
|
||||
|
@ -134,7 +137,7 @@ class DownloadTab(QWidget):
|
|||
logger.error('Installation cannot proceed, exiting.')
|
||||
QMessageBox.warning(self, "Installation failed", "Installation failed. See logs for more information")
|
||||
return
|
||||
|
||||
self.active_game = game
|
||||
self.thread = DownloadThread(dlm, self.core, igame)
|
||||
self.thread.status.connect(self.status)
|
||||
self.thread.start()
|
||||
|
@ -143,7 +146,11 @@ class DownloadTab(QWidget):
|
|||
if text == "dl_finished":
|
||||
pass
|
||||
elif text == "finish":
|
||||
QMessageBox.information(self, "Info", "Download finished")
|
||||
notification = Notify()
|
||||
notification.title = "Installation finished"
|
||||
notification.message = f"Download of game {self.active_game.app_title}"
|
||||
notification.send()
|
||||
#QMessageBox.information(self, "Info", "Download finished")
|
||||
self.finished.emit()
|
||||
self.installing_game.setText("Installing Game: No running download")
|
||||
elif text == "error":
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import QEvent, pyqtSignal
|
||||
from PyQt5.QtCore import QEvent, pyqtSignal, QSettings
|
||||
from PyQt5.QtGui import QPixmap, QIcon
|
||||
from PyQt5.QtWidgets import *
|
||||
from legendary.core import LegendaryCore
|
||||
|
@ -10,7 +10,6 @@ from legendary.models.game import InstalledGame
|
|||
from Rare import style_path
|
||||
from Rare.utils import LegendaryApi
|
||||
from Rare.utils.QtExtensions import ClickableLabel
|
||||
from Rare.utils.RareConfig import IMAGE_DIR
|
||||
|
||||
logger = getLogger("GameWidgetInstalled")
|
||||
|
||||
|
@ -25,17 +24,20 @@ class GameWidgetInstalled(QWidget):
|
|||
self.core = core
|
||||
self.game = game
|
||||
self.running = False
|
||||
settings = QSettings()
|
||||
|
||||
self.IMAGE_DIR = settings.value("img_dir", os.path.expanduser("~/.cache/rare"))
|
||||
|
||||
self.update_available = self.core.get_asset(self.game.app_name, True).build_version != game.version
|
||||
if self.update_available:
|
||||
logger.info("Update available for game: " + self.game.app_name)
|
||||
|
||||
if os.path.exists(f"{IMAGE_DIR}/{game.app_name}/FinalArt.png"):
|
||||
pixmap = QPixmap(f"{IMAGE_DIR}/{game.app_name}/FinalArt.png")
|
||||
elif os.path.exists(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png"):
|
||||
pixmap = QPixmap(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png")
|
||||
elif os.path.exists(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png"):
|
||||
pixmap = QPixmap(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png")
|
||||
if os.path.exists(f"{self.IMAGE_DIR}/{game.app_name}/FinalArt.png"):
|
||||
pixmap = QPixmap(f"{self.IMAGE_DIR}/{game.app_name}/FinalArt.png")
|
||||
elif os.path.exists(f"{self.IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png"):
|
||||
pixmap = QPixmap(f"{self.IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png")
|
||||
elif os.path.exists(f"{self.IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png"):
|
||||
pixmap = QPixmap(f"{self.IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png")
|
||||
else:
|
||||
logger.warning(f"No Image found: {self.game.title}")
|
||||
pixmap = None
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtCore import pyqtSignal, QSettings
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
|
||||
from legendary.core import LegendaryCore
|
||||
|
@ -9,7 +9,6 @@ from legendary.models.game import Game
|
|||
|
||||
from Rare.Components.Dialogs.InstallDialog import InstallDialog
|
||||
from Rare.utils.QtExtensions import ClickableLabel
|
||||
from Rare.utils.RareConfig import IMAGE_DIR
|
||||
from Rare.utils.utils import download_image
|
||||
|
||||
logger = getLogger("Uninstalled")
|
||||
|
@ -24,6 +23,7 @@ class GameWidgetUninstalled(QWidget):
|
|||
self.core = core
|
||||
self.game = game
|
||||
|
||||
IMAGE_DIR = QSettings().value("img_dir", type=str)
|
||||
if os.path.exists(f"{IMAGE_DIR}/{game.app_name}/UninstalledArt.png"):
|
||||
pixmap = QPixmap(f"{IMAGE_DIR}/{game.app_name}/UninstalledArt.png")
|
||||
else:
|
||||
|
|
12
Rare/Components/Tabs/Settings/About.py
Normal file
12
Rare/Components/Tabs/Settings/About.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QFormLayout, QLabel
|
||||
|
||||
|
||||
class About(QWidget):
|
||||
def __init__(self):
|
||||
super(About, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
self.title = QLabel("<h2>About</h2>")
|
||||
self.layout.addWidget(self.title)
|
||||
|
||||
self.setLayout(self.layout)
|
12
Rare/Components/Tabs/Settings/Legendary.py
Normal file
12
Rare/Components/Tabs/Settings/Legendary.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QFormLayout, QLabel
|
||||
|
||||
|
||||
class LegendarySettings(QWidget):
|
||||
def __init__(self):
|
||||
super(LegendarySettings, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
self.title = QLabel("<h2>Legendary settings</h2>")
|
||||
self.layout.addWidget(self.title)
|
||||
|
||||
self.setLayout(self.layout)
|
12
Rare/Components/Tabs/Settings/Linux.py
Normal file
12
Rare/Components/Tabs/Settings/Linux.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
|
||||
|
||||
|
||||
class LinuxSettings(QWidget):
|
||||
def __init__(self):
|
||||
super(LinuxSettings, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
self.title = QLabel("<h2>Linux settings (Wine, dxvk)</h2>")
|
||||
self.layout.addWidget(self.title)
|
||||
|
||||
self.setLayout(self.layout)
|
95
Rare/Components/Tabs/Settings/Rare.py
Normal file
95
Rare/Components/Tabs/Settings/Rare.py
Normal file
|
@ -0,0 +1,95 @@
|
|||
import os
|
||||
import shutil
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import QSettings, QTranslator
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QFileDialog, QComboBox, QApplication, QPushButton
|
||||
|
||||
from Rare.utils.QtExtensions import PathEdit
|
||||
from Rare.utils.utils import get_lang, get_possible_langs
|
||||
|
||||
logger = getLogger("RareSettings")
|
||||
class RareSettings(QWidget):
|
||||
def __init__(self):
|
||||
super(RareSettings, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
self.title = QLabel("<h2>Rare settings</h2>")
|
||||
self.layout.addWidget(self.title)
|
||||
settings = QSettings()
|
||||
img_dir = settings.value("img_dir", type=str)
|
||||
language = settings.value("language", type=str)
|
||||
# default settings
|
||||
if not img_dir:
|
||||
settings.setValue("img_dir", os.path.expanduser("~/.cache/rare/"))
|
||||
if not language:
|
||||
settings.setValue("language", get_lang())
|
||||
del settings
|
||||
# select Image dir
|
||||
self.select_path = PathEdit(img_dir, type_of_file=QFileDialog.DirectoryOnly)
|
||||
self.select_path.text_edit.textChanged.connect(lambda t: self.save_path_button.setDisabled(False))
|
||||
self.save_path_button = QPushButton("Save")
|
||||
self.save_path_button.clicked.connect(self.save_path)
|
||||
self.img_dir = SettingsWidget("Image Directory", self.select_path, self.save_path_button)
|
||||
self.layout.addWidget(self.img_dir)
|
||||
|
||||
# Select lang
|
||||
self.select_lang = QComboBox()
|
||||
languages = ["English", "Deutsch"]
|
||||
self.select_lang.addItems(languages)
|
||||
if language in get_possible_langs():
|
||||
if language == "de":
|
||||
self.select_lang.setCurrentIndex(1)
|
||||
elif language == "en":
|
||||
self.select_lang.setCurrentIndex(0)
|
||||
else:
|
||||
self.select_lang.setCurrentIndex(0)
|
||||
self.lang_widget = SettingsWidget("Language", self.select_lang)
|
||||
self.select_lang.currentIndexChanged.connect(self.update_lang)
|
||||
self.layout.addWidget(self.lang_widget)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def save_path(self):
|
||||
self.save_path_button.setDisabled(True)
|
||||
self.update_path()
|
||||
|
||||
def update_lang(self, i: int):
|
||||
settings = QSettings()
|
||||
if i == 0:
|
||||
settings.setValue("language", "en")
|
||||
elif i == 1:
|
||||
settings.setValue("language", "de")
|
||||
del settings
|
||||
self.lang_widget.info_text.setText("Restart Application to activate changes")
|
||||
|
||||
def update_path(self):
|
||||
settings = QSettings()
|
||||
old_path = settings.value("img_dir", type=str)
|
||||
new_path = self.select_path.text()
|
||||
settings.setValue("img_dir", new_path)
|
||||
print(old_path, new_path)
|
||||
del settings
|
||||
if old_path != new_path:
|
||||
if os.path.exists(new_path):
|
||||
os.makedirs(new_path)
|
||||
logger.info("Move Images")
|
||||
shutil.move(old_path, new_path)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class SettingsWidget(QWidget):
|
||||
def __init__(self, text: str, widget: QWidget, accept_button: QPushButton=None):
|
||||
super(SettingsWidget, self).__init__()
|
||||
self.setObjectName("settings_widget")
|
||||
self.layout = QVBoxLayout()
|
||||
self.info_text = QLabel("")
|
||||
self.layout.addWidget(QLabel(text))
|
||||
self.layout.addWidget(widget)
|
||||
if accept_button:
|
||||
self.layout.addWidget(accept_button)
|
||||
self.layout.addWidget(self.info_text)
|
||||
self.setLayout(self.layout)
|
56
Rare/Components/Tabs/Settings/SettingsTab.py
Normal file
56
Rare/Components/Tabs/Settings/SettingsTab.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
import os
|
||||
|
||||
from PyQt5.QtCore import QRect, QPoint, QSize
|
||||
from PyQt5.QtWidgets import QWidget, QTabWidget, QStylePainter, QStyleOptionTab, QTabBar, QStyle, QLabel
|
||||
|
||||
from Rare.Components.Tabs.Settings.About import About
|
||||
from Rare.Components.Tabs.Settings.Legendary import LegendarySettings
|
||||
from Rare.Components.Tabs.Settings.Linux import LinuxSettings
|
||||
from Rare.Components.Tabs.Settings.Rare import RareSettings
|
||||
|
||||
|
||||
class SettingsTab(QTabWidget):
|
||||
def __init__(self, core):
|
||||
super(SettingsTab, self).__init__()
|
||||
self.core = core
|
||||
self.setTabBar(TabBar())
|
||||
self.setTabPosition(QTabWidget.West)
|
||||
self.addTab(RareSettings(), "Rare")
|
||||
self.addTab(LegendarySettings(), "Legendary")
|
||||
if os.name != "nt":
|
||||
self.addTab(LinuxSettings(), "Linux")
|
||||
self.addTab(About(), "About")
|
||||
|
||||
|
||||
|
||||
class TabBar(QTabBar):
|
||||
def __init__(self):
|
||||
super(TabBar, self).__init__()
|
||||
self.setObjectName("settings_bar")
|
||||
|
||||
|
||||
def tabSizeHint(self, index):
|
||||
# width = QTabBar.tabSizeHint(self, index).width()
|
||||
return QSize(200, 30)
|
||||
|
||||
def paintEvent(self, event):
|
||||
painter = QStylePainter(self)
|
||||
opt = QStyleOptionTab()
|
||||
|
||||
for i in range(self.count()):
|
||||
self.initStyleOption(opt, i)
|
||||
painter.drawControl(QStyle.CE_TabBarTabShape, opt)
|
||||
painter.save()
|
||||
|
||||
s = opt.rect.size()
|
||||
s.transpose()
|
||||
r = QRect(QPoint(), s)
|
||||
r.moveCenter(opt.rect.center())
|
||||
opt.rect = r
|
||||
|
||||
c = self.tabRect(i).center()
|
||||
painter.translate(c)
|
||||
painter.rotate(90)
|
||||
painter.translate(-c)
|
||||
painter.drawControl(QStyle.CE_TabBarTabLabel, opt);
|
||||
painter.restore()
|
0
Rare/Components/Tabs/Settings/__init__.py
Normal file
0
Rare/Components/Tabs/Settings/__init__.py
Normal file
10
Rare/Main.py
10
Rare/Main.py
|
@ -2,16 +2,14 @@ import logging
|
|||
import os
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import QTranslator
|
||||
from PyQt5.QtCore import QTranslator, QSettings
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare import style_path, lang_path
|
||||
from Rare.Components.Launch.LaunchDialog import LaunchDialog
|
||||
from Rare.Components.MainWindow import MainWindow
|
||||
# from Rare.Start.Launch import LaunchDialog
|
||||
# from Rare.Start.Login import LoginWindow
|
||||
# from Rare.utils.RareUtils import get_lang
|
||||
from Rare.utils.utils import get_lang
|
||||
|
||||
logging.basicConfig(
|
||||
|
@ -24,9 +22,11 @@ core = LegendaryCore()
|
|||
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
settings = QSettings()
|
||||
# Translator
|
||||
translator = QTranslator()
|
||||
lang = get_lang()
|
||||
lang = settings.value("language",get_lang() , type=str)
|
||||
|
||||
if os.path.exists(lang_path + lang + ".qm"):
|
||||
translator.load(lang_path + lang + ".qm")
|
||||
elif not lang == "en":
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 103 KiB |
|
@ -2,14 +2,16 @@ QWidget {
|
|||
background-color: #202225;
|
||||
color: white;
|
||||
}
|
||||
QLabel{
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
QTabBar::tab {
|
||||
|
||||
QTabBar::tab#main_tab_bar{
|
||||
border: none;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
QTabBar::tab:hover {
|
||||
QTabBar::tab:hover#main_tab_bar{
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
|
@ -61,4 +63,18 @@ QCheckBox::indicator:checked {
|
|||
}
|
||||
QPushButton:hover#installed_menu_button{
|
||||
background-color: green;
|
||||
}
|
||||
}
|
||||
|
||||
QTabBar::tab#settings_bar{
|
||||
|
||||
border-radius: 0;
|
||||
|
||||
}
|
||||
|
||||
QTabBar::tab:hover#settings_bar {
|
||||
border-left: 2px solid white;
|
||||
}
|
||||
|
||||
QTabBar::tab::selected#settings_bar {
|
||||
background-color: darkslategrey;
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
import configparser
|
||||
import os
|
||||
from logging import getLogger
|
||||
|
||||
config_path = os.path.join(os.path.expanduser("~"), ".config/Rare/")
|
||||
rare_config = configparser.ConfigParser()
|
||||
|
||||
logger = getLogger("Config")
|
||||
rare_config.read(config_path + "config.ini")
|
||||
|
||||
if not os.path.exists(config_path):
|
||||
os.makedirs(config_path)
|
||||
rare_config["Rare"] = {
|
||||
"IMAGE_DIR": os.path.expanduser(f"~/.cache/images"),
|
||||
"theme": "default"
|
||||
}
|
||||
rare_config.write(open(config_path + "config.ini", "w"))
|
||||
elif not rare_config.sections():
|
||||
rare_config["Rare"] = {
|
||||
"IMAGE_DIR": os.path.expanduser("~/.cache/images"),
|
||||
"theme": "default"
|
||||
}
|
||||
rare_config.write(open(config_path + "config.ini", "w"))
|
||||
|
||||
|
||||
def get_config() -> {}:
|
||||
return rare_config.__dict__["_sections"]
|
||||
|
||||
|
||||
def set_config(new_config: {}):
|
||||
rare_config.__dict__["_sections"] = new_config
|
||||
rare_config.write(open(config_path + "config.ini", "w"))
|
||||
|
||||
|
||||
IMAGE_DIR = rare_config["Rare"]["IMAGE_DIR"]
|
||||
THEME = rare_config["Rare"]["theme"]
|
|
@ -5,13 +5,15 @@ from logging import getLogger
|
|||
|
||||
import requests
|
||||
from PIL import Image
|
||||
from PyQt5.QtCore import pyqtSignal, QLocale
|
||||
from PyQt5.QtCore import pyqtSignal, QLocale, QSettings
|
||||
from legendary.core import LegendaryCore
|
||||
|
||||
from Rare import lang_path
|
||||
from Rare.utils import legendaryConfig
|
||||
from Rare.utils.RareConfig import IMAGE_DIR
|
||||
|
||||
logger = getLogger("Utils")
|
||||
s = QSettings()
|
||||
IMAGE_DIR = s.value("language", os.path.expanduser("~/.cache/rare"), type=str)
|
||||
|
||||
|
||||
def download_images(signal: pyqtSignal, core: LegendaryCore):
|
||||
|
@ -21,7 +23,12 @@ def download_images(signal: pyqtSignal, core: LegendaryCore):
|
|||
|
||||
# Download Images
|
||||
for i, game in enumerate(sorted(core.get_game_list(), key=lambda x: x.app_title)):
|
||||
download_image(game)
|
||||
|
||||
try:
|
||||
download_image(game)
|
||||
except json.decoder.JSONDecodeError:
|
||||
shutil.rmtree(f"{IMAGE_DIR}/{game.app_name}")
|
||||
download_image(game)
|
||||
signal.emit(i)
|
||||
|
||||
|
||||
|
@ -94,3 +101,11 @@ def get_lang():
|
|||
else:
|
||||
logger.info("Found locale in system config: " + QLocale.system().name().split("_")[0])
|
||||
return QLocale.system().name().split("_")[0]
|
||||
|
||||
|
||||
def get_possible_langs():
|
||||
langs = ["en"]
|
||||
for i in os.listdir(lang_path):
|
||||
if i.endswith(".qm"):
|
||||
langs.append(i.split(".")[0])
|
||||
return langs
|
||||
|
|
Loading…
Reference in a new issue