2021-02-10 23:48:25 +13:00
|
|
|
import logging
|
|
|
|
import os
|
2021-03-17 22:12:11 +13:00
|
|
|
import sys
|
2021-02-10 23:48:25 +13:00
|
|
|
|
2021-03-17 22:12:11 +13:00
|
|
|
from Rare import __version__
|
2021-02-27 07:28:54 +13:00
|
|
|
from PyQt5.QtCore import QTranslator, QSettings
|
2021-03-09 02:38:58 +13:00
|
|
|
from PyQt5.QtGui import QIcon
|
2021-02-18 06:19:37 +13:00
|
|
|
from PyQt5.QtWidgets import QApplication
|
2021-03-18 01:47:58 +13:00
|
|
|
from custom_legendary.core import LegendaryCore
|
2021-02-10 23:48:25 +13:00
|
|
|
|
|
|
|
from Rare import style_path, lang_path
|
2021-02-18 06:19:37 +13:00
|
|
|
from Rare.Components.Launch.LaunchDialog import LaunchDialog
|
2021-02-10 23:48:25 +13:00
|
|
|
from Rare.Components.MainWindow import MainWindow
|
2021-02-18 06:19:37 +13:00
|
|
|
from Rare.utils.utils import get_lang
|
2021-02-10 23:48:25 +13:00
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
format='[%(name)s] %(levelname)s: %(message)s',
|
|
|
|
level=logging.INFO
|
|
|
|
)
|
|
|
|
logger = logging.getLogger("Rare")
|
|
|
|
core = LegendaryCore()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-03-17 22:12:11 +13:00
|
|
|
|
|
|
|
if "--version" in sys.argv:
|
|
|
|
print(__version__)
|
|
|
|
return
|
|
|
|
|
2021-03-09 02:38:58 +13:00
|
|
|
app = QApplication([])
|
2021-02-23 07:02:49 +13:00
|
|
|
app.setApplicationName("Rare")
|
|
|
|
app.setOrganizationName("Rare")
|
2021-03-10 04:52:51 +13:00
|
|
|
# app.setQuitOnLastWindowClosed(False)
|
|
|
|
|
2021-02-20 00:57:55 +13:00
|
|
|
settings = QSettings()
|
2021-02-18 01:58:29 +13:00
|
|
|
# Translator
|
2021-02-10 23:48:25 +13:00
|
|
|
translator = QTranslator()
|
2021-02-23 06:50:00 +13:00
|
|
|
lang = settings.value("language", get_lang(), type=str)
|
2021-02-20 00:57:55 +13:00
|
|
|
|
2021-02-10 23:48:25 +13:00
|
|
|
if os.path.exists(lang_path + lang + ".qm"):
|
|
|
|
translator.load(lang_path + lang + ".qm")
|
2021-02-18 01:58:29 +13:00
|
|
|
elif not lang == "en":
|
2021-02-10 23:48:25 +13:00
|
|
|
logger.info("Your language is not supported")
|
|
|
|
app.installTranslator(translator)
|
2021-02-18 01:58:29 +13:00
|
|
|
# Style
|
2021-02-10 23:48:25 +13:00
|
|
|
app.setStyleSheet(open(style_path + "RareStyle.qss").read())
|
2021-03-10 04:52:51 +13:00
|
|
|
app.setWindowIcon(QIcon(style_path + "Logo.png"))
|
2021-02-18 06:19:37 +13:00
|
|
|
launch_dialog = LaunchDialog(core)
|
|
|
|
launch_dialog.exec_()
|
2021-02-10 23:48:25 +13:00
|
|
|
mainwindow = MainWindow(core)
|
|
|
|
|
|
|
|
app.exec_()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
2021-03-10 04:52:51 +13:00
|
|
|
|
|
|
|
"""
|
|
|
|
tray = QSystemTrayIcon()
|
|
|
|
tray.setIcon(icon("fa.gamepad", color="white"))
|
|
|
|
tray.setVisible(True)
|
|
|
|
menu = QMenu()
|
|
|
|
option1 = QAction("Geeks for Geeks")
|
|
|
|
option1.triggered.connect(lambda: app.exec_())
|
|
|
|
option2 = QAction("GFG")
|
|
|
|
menu.addAction(option1)
|
|
|
|
menu.addAction(option2)
|
|
|
|
# To quit the app
|
|
|
|
quit = QAction("Quit")
|
|
|
|
quit.triggered.connect(app.quit)
|
|
|
|
menu.addAction(quit)
|
|
|
|
# Adding options to the System Tray
|
|
|
|
tray.setContextMenu(menu)"""
|