Skip to content

Commit

Permalink
Added handling for light and dark themes set by system
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Baintner committed Jul 23, 2024
1 parent fef923c commit 0b93b02
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
10 changes: 9 additions & 1 deletion renderrob.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def __init__(self) -> None:
self.yellow_jobs = []
self.red_jobs = []

# TODO: Avoid global state with theme colors.
if self.app.styleHints().colorScheme().value == 1:
table_utils.COLORS = table_utils.COLORS_LIGHT
elif self.app.styleHints().colorScheme().value == 2:
table_utils.COLORS = table_utils.COLORS_DARK

def setup(self) -> None:
"""Provide main function."""
self.app.setStyle("Breeze")
Expand All @@ -58,6 +64,8 @@ def setup(self) -> None:
self.window.setWindowIcon(QIcon("icons/icon.ico"))
self.app.setWindowIcon(QIcon("icons/icon.ico"))
self.table = self.window.tableWidget
self.table.setStyleSheet(
"QTableWidget {background-color: " + str(table_utils.COLORS["grey_light"]) + "}")
self.refresh_recent_files_menu()
self.window.progressBar.setValue(0)
self.window.progressBar.setMinimum(0)
Expand Down Expand Up @@ -323,7 +331,7 @@ def _handle_output(self):
# Only scroll down if user is at bottom.
if self.window.textBrowser.verticalScrollBar().value() > (
self.window.textBrowser.verticalScrollBar().maximum()) - 1500:
self.window.textBrowser.moveCursor(QTextCursor.End)
self.window.textBrowser.moveCursor(QTextCursor.End + 1)
self.window.textBrowser.setCurrentCharFormat(color_format)
self.window.textBrowser.insertPlainText(line.replace(reset, "") + "\n")

Expand Down
23 changes: 21 additions & 2 deletions utils_rr/table_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
QTableWidgetItem, QWidget)
from utils_rr import ui_utils, path_utils

COLORS = {
COLORS_LIGHT = {
"red": 0x980030,
"yellow": 0xffd966,
"green": 0x9fd3b6,
Expand All @@ -15,13 +15,32 @@
"blue_grey": 0x4f7997,
"blue_grey_darker": 0x345064,
"grey_light": 0xebebeb,
"grey_inactive": 0xf8f8f8,
"grey_inactive": 0xfefefe,
"grey_neutral": 0x999999,
"black_light": 0x22282b,
"black_dark": 0x242a2d,
"white": 0xffffff,
}

COLORS_DARK = {
"red": 0x980030,
"yellow": 0xffd966,
"green": 0x9fd3b6,
"blue": 0x57a3b4,
"blue_grey_lighter": 0x6397bd,
"blue_grey": 0x4f7997,
"blue_grey_darker": 0x345064,
"grey_light": 0x323639,
"grey_inactive": 0x2d2d2d,
"grey_neutral": 0x222222,
"black_light": 0x22282b,
"black_dark": 0x242a2d,
"white": 0x232323,
}
# NOTE: This variable is being set from renderrob.py since we only know there if a dark or a
# light theme is requested.
COLORS = {}


def fix_active_row_path(item: QTableWidgetItem, blend_folder: str) -> None:
"""Fix the path of the currently selected row."""
Expand Down

0 comments on commit 0b93b02

Please sign in to comment.