Refactor color code usage

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2023-08-18 18:02:16 +08:00
parent f456f1303e
commit cb7734c8df
5 changed files with 39 additions and 27 deletions
+5
View File
@@ -37,3 +37,8 @@ PROXY_SERVER_BYPASS = (
'172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;'
'172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*'
)
class Color:
LIGHT_RED_ = '#FF7276'
LIGHT_BLUE = '#43ACED'
+4 -4
View File
@@ -1,4 +1,4 @@
from Furious.Utility.Constants import APPLICATION_NAME, GOLDEN_RATIO
from Furious.Utility.Constants import APPLICATION_NAME, GOLDEN_RATIO, Color
from Furious.Utility.Utility import (
bootstrapIcon,
StateContext,
@@ -31,7 +31,7 @@ class ConnectingProgressBar(Translatable, SupportConnectedCallback, QWidget):
# Create a progress bar widget
self.progressBar = QProgressBar(self)
self.progressBar.setRange(0, 100)
self.progressBar.setStyleSheet(self.getStyleSheet('#43ACED'))
self.progressBar.setStyleSheet(self.getStyleSheet(Color.LIGHT_BLUE))
# create a timer to update the progress bar
self.timer = QtCore.QTimer(self)
@@ -64,11 +64,11 @@ class ConnectingProgressBar(Translatable, SupportConnectedCallback, QWidget):
def connectedCallback(self):
self.setWindowIcon(bootstrapIcon('rocket-takeoff-connected-dark.svg'))
self.progressBar.setStyleSheet(self.getStyleSheet('#F4364C'))
self.progressBar.setStyleSheet(self.getStyleSheet(Color.LIGHT_RED_))
def disconnectedCallback(self):
self.setWindowIcon(bootstrapIcon('rocket-takeoff-window.svg'))
self.progressBar.setStyleSheet(self.getStyleSheet('#43ACED'))
self.progressBar.setStyleSheet(self.getStyleSheet(Color.LIGHT_BLUE))
def retranslate(self):
with StateContext(self):
+4 -3
View File
@@ -24,6 +24,7 @@ from Furious.Utility.Constants import (
APPLICATION_REPO_NAME,
PLATFORM,
GOLDEN_RATIO,
Color,
)
from Furious.Utility.Utility import (
Base64Encoder,
@@ -1088,7 +1089,7 @@ class NormalServerWidget(Translatable, SupportConnectedCallback, TableWidget):
self.setVerticalHeader(NormalServerVerticalHeader(self))
# Selection
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
self.setSelectionBehavior(QTableWidget.SelectionBehavior.SelectRows)
self.setSelectionMode(QTableWidget.SelectionMode.ExtendedSelection)
@@ -1591,12 +1592,12 @@ class NormalServerWidget(Translatable, SupportConnectedCallback, TableWidget):
super().keyPressEvent(event)
def connectedCallback(self):
self.setSelectionColor('#F4364C')
self.setSelectionColor(Color.LIGHT_RED_)
# Reactivate with possible color
self.activateItemByIndex(self.activatedItemIndex)
def disconnectedCallback(self):
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
# Reactivate with possible color
self.activateItemByIndex(self.activatedItemIndex)
+10 -4
View File
@@ -25,7 +25,13 @@ from Furious.Widget.EditConfiguration import (
QuestionDeleteBox,
)
from Furious.Widget.AssetViewer import AssetViewerWidget
from Furious.Utility.Constants import APP, APPLICATION_NAME, GOLDEN_RATIO, DATA_DIR
from Furious.Utility.Constants import (
APP,
APPLICATION_NAME,
GOLDEN_RATIO,
DATA_DIR,
Color,
)
from Furious.Utility.Utility import (
RoutesStorage,
StateContext,
@@ -784,7 +790,7 @@ class EditRoutingTableWidget(Translatable, SupportConnectedCallback, TableWidget
self.setVerticalHeader(EditRoutingTableVerticalHeader(self))
# Selection
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
self.setSelectionBehavior(QTableWidget.SelectionBehavior.SelectRows)
self.setSelectionMode(QTableWidget.SelectionMode.ExtendedSelection)
@@ -927,12 +933,12 @@ class EditRoutingTableWidget(Translatable, SupportConnectedCallback, TableWidget
self.setItem(row, column, item)
def connectedCallback(self):
self.setSelectionColor('#F4364C')
self.setSelectionColor(Color.LIGHT_RED_)
# Reactivate with possible color
self.activateItemByIndex(routingToIndex(), activate=True)
def disconnectedCallback(self):
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
# Reactivate with possible color
self.activateItemByIndex(routingToIndex(), activate=True)
+16 -16
View File
@@ -1,5 +1,5 @@
from Furious.Gui.Action import Action, Seperator
from Furious.Utility.Constants import APP
from Furious.Utility.Constants import APP, Color
from Furious.Utility.Utility import (
StateContext,
SupportConnectedCallback,
@@ -36,17 +36,17 @@ class HeaderView(SupportConnectedCallback, QHeaderView):
self.setSectionsClickable(True)
self.setStyleSheet(
f'QHeaderView::section:hover {{ background-color: #43ACED; }}'
f'QHeaderView::section:hover {{ background-color: {Color.LIGHT_BLUE}; }}'
)
def connectedCallback(self):
self.setStyleSheet(
f'QHeaderView::section:hover {{ background-color: #F4364C; }}'
f'QHeaderView::section:hover {{ background-color: {Color.LIGHT_RED_}; }}'
)
def disconnectedCallback(self):
self.setStyleSheet(
f'QHeaderView::section:hover {{ background-color: #43ACED; }}'
f'QHeaderView::section:hover {{ background-color: {Color.LIGHT_BLUE}; }}'
)
@@ -54,7 +54,7 @@ class ListWidget(SupportConnectedCallback, QListWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
def setSelectionColor(self, color):
self.setStyleSheet(
@@ -72,10 +72,10 @@ class ListWidget(SupportConnectedCallback, QListWidget):
return sorted(list(set(index.row() for index in self.selectedIndexes())))
def connectedCallback(self):
self.setSelectionColor('#F4364C')
self.setSelectionColor(Color.LIGHT_RED_)
def disconnectedCallback(self):
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
class MainWindow(Translatable, SupportConnectedCallback, NeedSyncSettings, QMainWindow):
@@ -118,7 +118,7 @@ class Menu(Translatable, SupportConnectedCallback, QMenu):
self.addAction(action)
self.setStyleSheet(self.getStyleSheet('#43ACED'))
self.setStyleSheet(self.getStyleSheet(Color.LIGHT_BLUE))
@staticmethod
def getStyleSheet(color):
@@ -133,10 +133,10 @@ class Menu(Translatable, SupportConnectedCallback, QMenu):
)
def connectedCallback(self):
self.setStyleSheet(self.getStyleSheet('#F4364C'))
self.setStyleSheet(self.getStyleSheet(Color.LIGHT_RED_))
def disconnectedCallback(self):
self.setStyleSheet(self.getStyleSheet('#43ACED'))
self.setStyleSheet(self.getStyleSheet(Color.LIGHT_BLUE))
def retranslate(self):
with StateContext(self):
@@ -147,7 +147,7 @@ class MenuBar(SupportConnectedCallback, QMenuBar):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
def setSelectionColor(self, color):
self.setStyleSheet(
@@ -161,10 +161,10 @@ class MenuBar(SupportConnectedCallback, QMenuBar):
)
def connectedCallback(self):
self.setSelectionColor('#F4364C')
self.setSelectionColor(Color.LIGHT_RED_)
def disconnectedCallback(self):
self.setSelectionColor('#43ACED')
self.setSelectionColor(Color.LIGHT_BLUE)
class MessageBox(Translatable, SupportConnectedCallback, QMessageBox):
@@ -263,12 +263,12 @@ class TableWidget(QTableWidget):
if APP().tray is None:
# Initializing
item.setForeground(QColor('#43ACED'))
item.setForeground(QColor(Color.LIGHT_BLUE))
else:
if APP().tray.ConnectAction.isConnected():
item.setForeground(QColor('#F4364C'))
item.setForeground(QColor(Color.LIGHT_RED_))
else:
item.setForeground(QColor('#43ACED'))
item.setForeground(QColor(Color.LIGHT_BLUE))
else:
for column in range(self.columnCount()):
item = self.item(int(index), column)