1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00

Add selectable colors schemes and style sheets

This commit is contained in:
Stelios Tsampas 2021-05-18 01:56:01 +03:00
parent 10cd3d5227
commit f34e1ce61f
10 changed files with 484 additions and 129 deletions

View file

@ -14,7 +14,7 @@ from rare import lang_path, style_path
from rare.components.dialogs.launch_dialog import LaunchDialog
from rare.components.main_window import MainWindow
from rare.components.tray_icon import TrayIcon
from rare.utils.utils import get_lang
from rare.utils.utils import get_lang, load_color_scheme
start_time = time.strftime('%y-%m-%d--%H:%M') # year-month-day-hour-minute
file_name = os.path.expanduser(f"~/.cache/rare/logs/Rare_{start_time}.log")
@ -68,8 +68,13 @@ class App(QApplication):
# Style
self.setStyle(QStyleFactory.create("Fusion"))
self.setStyleSheet(open(style_path + "RareStyle.qss").read())
self.setWindowIcon(QIcon(style_path + "Logo.png"))
if (color := settings.value("color_scheme", None)) is not None:
custom_palette = load_color_scheme(os.path.join(style_path, "colors", color + ".scheme"))
if custom_palette is not None:
self.setPalette(custom_palette)
if (style := settings.value("style_sheet", None)) is not None:
self.setStyleSheet(open(os.path.join(style_path, "qss", style + ".qss")).read())
self.setWindowIcon(QIcon(os.path.join(style_path + "Logo.png")))
# launch app
self.launch_dialog = LaunchDialog(self.core, args.offline)

View file

@ -10,7 +10,7 @@ from PyQt5.QtWidgets import QFileDialog, QWidget
from rare.components.tabs.settings.rpc_settings import RPCSettings
from rare.ui.components.tabs.settings.rare import Ui_RareSettings
from rare.utils.extra_widgets import PathEdit
from rare.utils.utils import get_lang, get_possible_langs
from rare.utils.utils import get_lang, get_possible_langs, get_color_schemes, get_style_sheets
logger = getLogger("RareSettings")
@ -43,20 +43,41 @@ class RareSettings(QWidget, Ui_RareSettings):
# Select Image directory
self.img_dir = PathEdit(self.img_dir_path, file_type=QFileDialog.DirectoryOnly, save_func=self.save_path)
self.layout_img_dir.addWidget(self.img_dir)
self.img_dir_layout.addWidget(self.img_dir)
# Select lang
self.select_lang.addItems([i[1] for i in languages])
self.lang_select.addItems([i[1] for i in languages])
if language in get_possible_langs():
index = [lang[0] for lang in languages].index(language)
self.select_lang.setCurrentIndex(index)
self.lang_select.setCurrentIndex(index)
else:
self.select_lang.setCurrentIndex(0)
self.info_lang.setVisible(False)
self.select_lang.currentIndexChanged.connect(self.update_lang)
self.lang_select.setCurrentIndex(0)
self.lang_select.currentIndexChanged.connect(self.update_lang)
colors = get_color_schemes()
self.color_select.addItems(colors)
if (color := self.settings.value("color_scheme")) in colors:
self.color_select.setCurrentIndex(self.color_select.findText(color))
self.color_select.setDisabled(False)
self.style_select.setDisabled(True)
else:
self.color_select.setCurrentIndex(0)
self.color_select.currentIndexChanged.connect(self.on_color_select_changed)
styles = get_style_sheets()
self.style_select.addItems(styles)
if (style := self.settings.value("style_sheet")) in styles:
self.style_select.setCurrentIndex(self.style_select.findText(style))
self.style_select.setDisabled(False)
self.color_select.setDisabled(True)
else:
self.style_select.setCurrentIndex(0)
self.style_select.currentIndexChanged.connect(self.on_style_select_changed)
self.interface_info.setVisible(False)
self.rpc = RPCSettings()
self.layout_rpc.addWidget(self.rpc)
self.rpc_layout.addWidget(self.rpc)
self.init_checkboxes(self.checkboxes)
self.sys_tray.stateChanged.connect(
@ -83,6 +104,26 @@ class RareSettings(QWidget, Ui_RareSettings):
self.log_dir_clean_button.setVisible(False)
self.log_dir_size_label.setVisible(False)
def on_color_select_changed(self, color):
if color:
self.style_select.setCurrentIndex(0)
self.style_select.setDisabled(True)
self.settings.setValue("color_scheme", self.color_select.currentText())
else:
self.settings.remove("color_scheme")
self.style_select.setDisabled(False)
self.interface_info.setVisible(True)
def on_style_select_changed(self, style):
if style:
self.color_select.setCurrentIndex(0)
self.color_select.setDisabled(True)
self.settings.setValue("style_sheet", self.style_select.currentText())
else:
self.settings.remove("style_sheet")
self.color_select.setDisabled(False)
self.interface_info.setVisible(True)
def open_dir(self):
if os.name == "nt":
os.startfile(self.logdir)
@ -99,7 +140,7 @@ class RareSettings(QWidget, Ui_RareSettings):
def update_lang(self, i: int):
self.settings.setValue("language", languages[i][0])
self.info_lang.setVisible(True)
self.interface_info.setVisible(True)
def update_path(self):
old_path = self.img_dir_path

View file

@ -0,0 +1,61 @@
[ColorScheme]
Active\AlternateBase=#2f2f2f
Active\Base=#333333
Active\BrightText=#ffffff
Active\Button=#525252
Active\ButtonText=#dddddd
Active\Dark=#333333
Active\Highlight=#f0544c
Active\HighlightedText=#ffffff
Active\Light=#555555
Active\Link=#fc6f5d
Active\LinkVisited=#853931
Active\Mid=#a0a0a4
Active\Midlight=#e9e7e3
Active\PlaceholderText=#eeeeee
Active\Shadow=#343434
Active\Text=#eeeeee
Active\ToolTipBase=#444444
Active\ToolTipText=#eeeeee
Active\Window=#444444
Active\WindowText=#dddddd
Disabled\AlternateBase=#2f2f2f
Disabled\Base=#333333
Disabled\BrightText=#ffffff
Disabled\Button=#525252
Disabled\ButtonText=#808080
Disabled\Dark=#333333
Disabled\Highlight=#f0544c
Disabled\HighlightedText=#808080
Disabled\Light=#555555
Disabled\Link=#fc6f5d
Disabled\LinkVisited=#853931
Disabled\Mid=#a0a0a4
Disabled\Midlight=#e9e7e3
Disabled\PlaceholderText=#eeeeee
Disabled\Shadow=#343434
Disabled\Text=#808080
Disabled\ToolTipBase=#444444
Disabled\ToolTipText=#eeeeee
Disabled\Window=#444444
Disabled\WindowText=#808080
Inactive\AlternateBase=#2f2f2f
Inactive\Base=#333333
Inactive\BrightText=#ffffff
Inactive\Button=#525252
Inactive\ButtonText=#dddddd
Inactive\Dark=#333333
Inactive\Highlight=#f0544c
Inactive\HighlightedText=#ffffff
Inactive\Light=#555555
Inactive\Link=#fc6f5d
Inactive\LinkVisited=#853931
Inactive\Mid=#a0a0a4
Inactive\Midlight=#e9e7e3
Inactive\PlaceholderText=#eeeeee
Inactive\Shadow=#343434
Inactive\Text=#eeeeee
Inactive\ToolTipBase=#444444
Inactive\ToolTipText=#eeeeee
Inactive\Window=#444444
Inactive\WindowText=#dddddd

View file

@ -0,0 +1,61 @@
[ColorScheme]
Active\AlternateBase=#f7f7f7
Active\Base=#333344
Active\BrightText=#ffffff
Active\Button=#3c3f41
Active\ButtonText=#eeeeee
Active\Dark=#9f0910
Active\Highlight=#2f4f4f
Active\HighlightedText=#eeeeee
Active\Light=#ffffff
Active\Link=#0000ff
Active\LinkVisited=#ff00ff
Active\Mid=#b80e35
Active\Midlight=#ca0651
Active\PlaceholderText=#eeeeee
Active\Shadow=#767676
Active\Text=#eeeeee
Active\ToolTipBase=#ffffdc
Active\ToolTipText=#eeeeee
Active\Window=#202225
Active\WindowText=#eeeeee
Disabled\AlternateBase=#f7f7f7
Disabled\Base=#333344
Disabled\BrightText=#ffffff
Disabled\Button=#3c3f41
Disabled\ButtonText=#808080
Disabled\Dark=#9f0910
Disabled\Highlight=#2f4f4f
Disabled\HighlightedText=#808080
Disabled\Light=#ffffff
Disabled\Link=#0000ff
Disabled\LinkVisited=#ff00ff
Disabled\Mid=#b80e35
Disabled\Midlight=#ca0651
Disabled\PlaceholderText=#eeeeee
Disabled\Shadow=#767676
Disabled\Text=#808080
Disabled\ToolTipBase=#ffffdc
Disabled\ToolTipText=#eeeeee
Disabled\Window=#202225
Disabled\WindowText=#808080
Inactive\AlternateBase=#f7f7f7
Inactive\Base=#333344
Inactive\BrightText=#ffffff
Inactive\Button=#3c3f41
Inactive\ButtonText=#eeeeee
Inactive\Dark=#9f0910
Inactive\Highlight=#2f4f4f
Inactive\HighlightedText=#eeeeee
Inactive\Light=#ffffff
Inactive\Link=#0000ff
Inactive\LinkVisited=#ff00ff
Inactive\Mid=#b80e35
Inactive\Midlight=#ca0651
Inactive\PlaceholderText=#eeeeee
Inactive\Shadow=#767676
Inactive\Text=#eeeeee
Inactive\ToolTipBase=#ffffdc
Inactive\ToolTipText=#eeeeee
Inactive\Window=#202225
Inactive\WindowText=#eeeeee

View file

@ -0,0 +1,61 @@
[ColorScheme]
Active\AlternateBase=#eff3f7
Active\Base=#eff3f7
Active\BrightText=#ffffff
Active\Button=#eff3f7
Active\ButtonText=#000000
Active\Dark=#c7cbce
Active\Highlight=#4965ae
Active\HighlightedText=#ffffff
Active\Light=#ffffff
Active\Link=#0000ff
Active\LinkVisited=#ff00ff
Active\Mid=#a0a0a4
Active\Midlight=#e9e7e3
Active\PlaceholderText=#000000
Active\Shadow=#b8bbbe
Active\Text=#000000
Active\ToolTipBase=#ffffdc
Active\ToolTipText=#000000
Active\Window=#eff3f7
Active\WindowText=#000000
Disabled\AlternateBase=#eff3f7
Disabled\Base=#eff3f7
Disabled\BrightText=#ffffff
Disabled\Button=#eff3f7
Disabled\ButtonText=#808080
Disabled\Dark=#c7cbce
Disabled\Highlight=#4965ae
Disabled\HighlightedText=#808080
Disabled\Light=#ffffff
Disabled\Link=#0000ff
Disabled\LinkVisited=#ff00ff
Disabled\Mid=#a0a0a4
Disabled\Midlight=#e9e7e3
Disabled\PlaceholderText=#000000
Disabled\Shadow=#b8bbbe
Disabled\Text=#808080
Disabled\ToolTipBase=#ffffdc
Disabled\ToolTipText=#000000
Disabled\Window=#eff3f7
Disabled\WindowText=#808080
Inactive\AlternateBase=#eff3f7
Inactive\Base=#eff3f7
Inactive\BrightText=#ffffff
Inactive\Button=#eff3f7
Inactive\ButtonText=#000000
Inactive\Dark=#c7cbce
Inactive\Highlight=#4965ae
Inactive\HighlightedText=#ffffff
Inactive\Light=#ffffff
Inactive\Link=#0000ff
Inactive\LinkVisited=#ff00ff
Inactive\Mid=#a0a0a4
Inactive\Midlight=#e9e7e3
Inactive\PlaceholderText=#000000
Inactive\Shadow=#b8bbbe
Inactive\Text=#000000
Inactive\ToolTipBase=#ffffdc
Inactive\ToolTipText=#000000
Inactive\Window=#eff3f7
Inactive\WindowText=#000000

View file

@ -14,63 +14,78 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_RareSettings(object):
def setupUi(self, RareSettings):
RareSettings.setObjectName("RareSettings")
self.layout_rare = QtWidgets.QGridLayout(RareSettings)
self.layout_rare.setObjectName("layout_rare")
self.gb_img_dir = QtWidgets.QGroupBox(RareSettings)
self.gb_img_dir.setObjectName("gb_img_dir")
self.layout_img_dir = QtWidgets.QVBoxLayout(self.gb_img_dir)
self.layout_img_dir.setObjectName("layout_img_dir")
self.layout_rare.addWidget(self.gb_img_dir, 0, 0, 1, 1)
self.gb_lang = QtWidgets.QGroupBox(RareSettings)
self.rare_layout = QtWidgets.QGridLayout(RareSettings)
self.rare_layout.setObjectName("rare_layout")
self.rpc_layout = QtWidgets.QVBoxLayout()
self.rpc_layout.setObjectName("rpc_layout")
self.rare_layout.addLayout(self.rpc_layout, 1, 2, 1, 1)
self.img_dir_group = QtWidgets.QGroupBox(RareSettings)
self.img_dir_group.setObjectName("img_dir_group")
self.img_dir_layout = QtWidgets.QVBoxLayout(self.img_dir_group)
self.img_dir_layout.setObjectName("img_dir_layout")
self.rare_layout.addWidget(self.img_dir_group, 0, 0, 1, 2, QtCore.Qt.AlignTop)
self.interface_group = QtWidgets.QGroupBox(RareSettings)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.gb_lang.sizePolicy().hasHeightForWidth())
self.gb_lang.setSizePolicy(sizePolicy)
self.gb_lang.setObjectName("gb_lang")
self.layout_lang = QtWidgets.QVBoxLayout(self.gb_lang)
self.layout_lang.setObjectName("layout_lang")
self.select_lang = QtWidgets.QComboBox(self.gb_lang)
self.select_lang.setObjectName("select_lang")
self.layout_lang.addWidget(self.select_lang, 0, QtCore.Qt.AlignTop)
self.info_lang = QtWidgets.QLabel(self.gb_lang)
sizePolicy.setHeightForWidth(self.interface_group.sizePolicy().hasHeightForWidth())
self.interface_group.setSizePolicy(sizePolicy)
self.interface_group.setObjectName("interface_group")
self.interface_layout = QtWidgets.QGridLayout(self.interface_group)
self.interface_layout.setObjectName("interface_layout")
self.lang_label = QtWidgets.QLabel(self.interface_group)
self.lang_label.setObjectName("lang_label")
self.interface_layout.addWidget(self.lang_label, 0, 1, 1, 1, QtCore.Qt.AlignRight)
self.style_label = QtWidgets.QLabel(self.interface_group)
self.style_label.setObjectName("style_label")
self.interface_layout.addWidget(self.style_label, 2, 1, 1, 1, QtCore.Qt.AlignRight)
self.color_label = QtWidgets.QLabel(self.interface_group)
self.color_label.setObjectName("color_label")
self.interface_layout.addWidget(self.color_label, 1, 1, 1, 1, QtCore.Qt.AlignRight)
self.lang_select = QtWidgets.QComboBox(self.interface_group)
self.lang_select.setObjectName("lang_select")
self.interface_layout.addWidget(self.lang_select, 0, 2, 1, 1)
self.interface_info = QtWidgets.QLabel(self.interface_group)
font = QtGui.QFont()
font.setItalic(True)
self.info_lang.setFont(font)
self.info_lang.setWordWrap(True)
self.info_lang.setObjectName("info_lang")
self.layout_lang.addWidget(self.info_lang, 0, QtCore.Qt.AlignTop)
self.layout_rare.addWidget(self.gb_lang, 0, 1, 1, 1)
self.gb_settings = QtWidgets.QGroupBox(RareSettings)
self.gb_settings.setObjectName("gb_settings")
self.gridLayout = QtWidgets.QGridLayout(self.gb_settings)
self.gridLayout.setObjectName("gridLayout")
self.auto_update = QtWidgets.QCheckBox(self.gb_settings)
self.auto_update.setObjectName("auto_update")
self.gridLayout.addWidget(self.auto_update, 1, 0, 1, 1)
self.confirm_start = QtWidgets.QCheckBox(self.gb_settings)
self.confirm_start.setObjectName("confirm_start")
self.gridLayout.addWidget(self.confirm_start, 2, 0, 1, 1)
self.sys_tray = QtWidgets.QCheckBox(self.gb_settings)
self.sys_tray.setObjectName("sys_tray")
self.gridLayout.addWidget(self.sys_tray, 0, 0, 1, 1)
self.notification = QtWidgets.QCheckBox(self.gb_settings)
self.notification.setObjectName("notification")
self.gridLayout.addWidget(self.notification, 0, 1, 1, 1)
self.auto_sync_cloud = QtWidgets.QCheckBox(self.gb_settings)
self.interface_info.setFont(font)
self.interface_info.setWordWrap(True)
self.interface_info.setObjectName("interface_info")
self.interface_layout.addWidget(self.interface_info, 3, 0, 1, 4)
self.style_select = QtWidgets.QComboBox(self.interface_group)
self.style_select.setObjectName("style_select")
self.style_select.addItem("")
self.interface_layout.addWidget(self.style_select, 2, 2, 1, 1)
self.color_select = QtWidgets.QComboBox(self.interface_group)
self.color_select.setObjectName("color_select")
self.color_select.addItem("")
self.interface_layout.addWidget(self.color_select, 1, 2, 1, 1)
self.rare_layout.addWidget(self.interface_group, 1, 0, 1, 1, QtCore.Qt.AlignTop)
self.settings_group = QtWidgets.QGroupBox(RareSettings)
self.settings_group.setObjectName("settings_group")
self.behaviour_layout = QtWidgets.QGridLayout(self.settings_group)
self.behaviour_layout.setObjectName("behaviour_layout")
self.auto_sync_cloud = QtWidgets.QCheckBox(self.settings_group)
self.auto_sync_cloud.setObjectName("auto_sync_cloud")
self.gridLayout.addWidget(self.auto_sync_cloud, 3, 0, 1, 1)
self.save_size = QtWidgets.QCheckBox(self.gb_settings)
self.behaviour_layout.addWidget(self.auto_sync_cloud, 3, 0, 1, 1)
self.auto_update = QtWidgets.QCheckBox(self.settings_group)
self.auto_update.setObjectName("auto_update")
self.behaviour_layout.addWidget(self.auto_update, 1, 0, 1, 1)
self.confirm_start = QtWidgets.QCheckBox(self.settings_group)
self.confirm_start.setObjectName("confirm_start")
self.behaviour_layout.addWidget(self.confirm_start, 2, 0, 1, 1)
self.sys_tray = QtWidgets.QCheckBox(self.settings_group)
self.sys_tray.setObjectName("sys_tray")
self.behaviour_layout.addWidget(self.sys_tray, 0, 0, 1, 1)
spacerItem = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.behaviour_layout.addItem(spacerItem, 0, 2, 4, 1)
self.notification = QtWidgets.QCheckBox(self.settings_group)
self.notification.setObjectName("notification")
self.behaviour_layout.addWidget(self.notification, 0, 1, 1, 1)
self.save_size = QtWidgets.QCheckBox(self.settings_group)
self.save_size.setObjectName("save_size")
self.gridLayout.addWidget(self.save_size, 1, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(0, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 0, 2, 4, 1)
self.layout_rare.addWidget(self.gb_settings, 1, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.layout_rare.addItem(spacerItem1, 3, 0, 1, 2)
self.layout_rpc = QtWidgets.QVBoxLayout()
self.layout_rpc.setObjectName("layout_rpc")
self.layout_rare.addLayout(self.layout_rpc, 1, 1, 1, 1)
self.behaviour_layout.addWidget(self.save_size, 1, 1, 1, 1)
self.rare_layout.addWidget(self.settings_group, 1, 1, 1, 1, QtCore.Qt.AlignTop)
self.log_dir_group = QtWidgets.QGroupBox(RareSettings)
self.log_dir_group.setObjectName("log_dir_group")
self.log_dir_layout = QtWidgets.QVBoxLayout(self.log_dir_group)
@ -86,7 +101,9 @@ class Ui_RareSettings(object):
self.log_dir_size_label.setWordWrap(True)
self.log_dir_size_label.setObjectName("log_dir_size_label")
self.log_dir_layout.addWidget(self.log_dir_size_label)
self.layout_rare.addWidget(self.log_dir_group, 2, 1, 1, 1)
self.rare_layout.addWidget(self.log_dir_group, 0, 2, 1, 1, QtCore.Qt.AlignTop)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.rare_layout.addItem(spacerItem1, 2, 1, 1, 1)
self.retranslateUi(RareSettings)
QtCore.QMetaObject.connectSlotsByName(RareSettings)
@ -94,15 +111,20 @@ class Ui_RareSettings(object):
def retranslateUi(self, RareSettings):
_translate = QtCore.QCoreApplication.translate
RareSettings.setWindowTitle(_translate("RareSettings", "RareSettings"))
self.gb_img_dir.setTitle(_translate("RareSettings", "Image Cache Directory"))
self.gb_lang.setTitle(_translate("RareSettings", "Language"))
self.info_lang.setText(_translate("RareSettings", "Restart Rare to apply the new settings."))
self.gb_settings.setTitle(_translate("RareSettings", "Behaviour"))
self.img_dir_group.setTitle(_translate("RareSettings", "Image Cache Directory"))
self.interface_group.setTitle(_translate("RareSettings", "Interface"))
self.lang_label.setText(_translate("RareSettings", "Language"))
self.style_label.setText(_translate("RareSettings", "Style Sheet"))
self.color_label.setText(_translate("RareSettings", "Color Scheme"))
self.interface_info.setText(_translate("RareSettings", "Restart Rare to apply."))
self.style_select.setItemText(0, _translate("RareSettings", "None"))
self.color_select.setItemText(0, _translate("RareSettings", "None"))
self.settings_group.setTitle(_translate("RareSettings", "Behaviour"))
self.auto_sync_cloud.setText(_translate("RareSettings", "Automatically sync with cloud"))
self.auto_update.setText(_translate("RareSettings", "Update games on application startup"))
self.confirm_start.setText(_translate("RareSettings", "Confirm game launch"))
self.sys_tray.setText(_translate("RareSettings", "Exit to System tray"))
self.notification.setText(_translate("RareSettings", "Show notification on download completion"))
self.auto_sync_cloud.setText(_translate("RareSettings", "Automatically sync with cloud"))
self.save_size.setText(_translate("RareSettings", "Restore window size on application startup"))
self.log_dir_group.setTitle(_translate("RareSettings", "Logs"))
self.log_dir_open_button.setText(_translate("RareSettings", "Open Log directory"))

View file

@ -5,17 +5,20 @@
<property name="windowTitle">
<string>RareSettings</string>
</property>
<layout class="QGridLayout" name="layout_rare">
<item row="0" column="0">
<widget class="QGroupBox" name="gb_img_dir">
<layout class="QGridLayout" name="rare_layout">
<item row="1" column="2">
<layout class="QVBoxLayout" name="rpc_layout"/>
</item>
<item row="0" column="0" colspan="2" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="img_dir_group">
<property name="title">
<string>Image Cache Directory</string>
</property>
<layout class="QVBoxLayout" name="layout_img_dir"/>
<layout class="QVBoxLayout" name="img_dir_layout"/>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="gb_lang">
<item row="1" column="0" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="interface_group">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -23,36 +26,82 @@
</sizepolicy>
</property>
<property name="title">
<string>Language</string>
<string>Interface</string>
</property>
<layout class="QVBoxLayout" name="layout_lang">
<item alignment="Qt::AlignTop">
<widget class="QComboBox" name="select_lang"/>
<layout class="QGridLayout" name="interface_layout">
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="lang_label">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QLabel" name="info_lang">
<item row="2" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="style_label">
<property name="text">
<string>Style Sheet</string>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="color_label">
<property name="text">
<string>Color Scheme</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="lang_select"/>
</item>
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="interface_info">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Restart Rare to apply the new settings.</string>
<string>Restart Rare to apply.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="style_select">
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="color_select">
<item>
<property name="text">
<string>None</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="gb_settings">
<item row="1" column="1" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="settings_group">
<property name="title">
<string>Behaviour</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="behaviour_layout">
<item row="3" column="0">
<widget class="QCheckBox" name="auto_sync_cloud">
<property name="text">
<string>Automatically sync with cloud</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="auto_update">
<property name="text">
@ -74,6 +123,19 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="4">
<spacer name="settings_hspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="notification">
<property name="text">
@ -81,13 +143,6 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="auto_sync_cloud">
<property name="text">
<string>Automatically sync with cloud</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="save_size">
<property name="text">
@ -95,39 +150,10 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="4">
<spacer name="settings_hspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="rare_vspacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="layout_rpc"/>
</item>
<item row="2" column="1">
<item row="0" column="2" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="log_dir_group">
<property name="title">
<string>Logs</string>
@ -160,6 +186,19 @@
</layout>
</widget>
</item>
<item row="2" column="1">
<spacer name="rare_vspacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>

View file

@ -2,14 +2,6 @@
<ui version="4.0">
<class>RPCSettings</class>
<widget class="QGroupBox" name="RPCSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>178</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle">
<string>Discord RPC</string>
</property>

View file

@ -7,6 +7,8 @@ from logging import getLogger
import requests
from PIL import Image, UnidentifiedImageError
from PyQt5.QtCore import pyqtSignal, QLocale, QSettings
from PyQt5.QtGui import QPalette, QColor
from rare import style_path
# Windows
if os.name == "nt":
@ -122,6 +124,77 @@ def get_lang():
return QLocale.system().name().split("_")[0]
color_role_map = {
0: "WindowText",
1: "Button",
2: "Light",
3: "Midlight",
4: "Dark",
5: "Mid",
6: "Text",
7: "BrightText",
8: "ButtonText",
9: "Base",
10: "Window",
11: "Shadow",
12: "Highlight",
13: "HighlightedText",
14: "Link",
15: "LinkVisited",
16: "AlternateBase",
# 17: "NoRole",
18: "ToolTipBase",
19: "ToolTipText",
20: "PlaceholderText",
# 21: "NColorRoles",
}
color_group_map = {
0: "Active",
1: "Disabled",
2: "Inactive",
}
def load_color_scheme(path: str):
custom_palette = QPalette()
settings = QSettings(path, QSettings.IniFormat)
try:
settings.beginGroup("ColorScheme")
for g in color_group_map:
settings.beginGroup(color_group_map[g])
group = QPalette.ColorGroup(g)
for r in color_role_map:
role = QPalette.ColorRole(r)
custom_palette.setColor(group, role, QColor(settings.value(color_role_map[r])))
settings.endGroup()
settings.endGroup()
text_color = custom_palette.text().color()
text_color.setAlpha(128)
custom_palette.setColor(custom_palette.Active, custom_palette.PlaceholderText, text_color)
custom_palette.setColor(custom_palette.Inactive, custom_palette.PlaceholderText, text_color)
custom_palette.setColor(custom_palette.Disabled, custom_palette.PlaceholderText, text_color)
except:
custom_palette = None
return custom_palette
def get_color_schemes():
colors = []
for file in os.listdir(os.path.join(style_path, "colors")):
if file.endswith(".scheme") and os.path.isfile(os.path.join(style_path, "colors", file)):
colors.append(file.replace(".scheme", ""))
return colors
def get_style_sheets():
styles = []
for file in os.listdir(os.path.join(style_path, "qss")):
if file.endswith(".qss") and os.path.isfile(os.path.join(style_path, "qss", file)):
styles.append(file.replace(".qss", ""))
return styles
def get_possible_langs():
langs = ["en"]
for i in os.listdir(lang_path):