Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1032 from ess-dmsc/ECDC-3503-Fix-for-MacOS-dark-m…
Browse files Browse the repository at this point in the history
…ode-breaks-presentation-in-Linux

 ECDC-3503-Fix-for-MacOS-dark-mode-breaks-presentation-in-Linux
  • Loading branch information
ggoneiESS authored Jul 3, 2023
2 parents 6d17ca4 + ae878a6 commit 7808e7c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
5 changes: 4 additions & 1 deletion nexus-constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def closeEvent(self, event: QCloseEvent) -> None:
if "help" in parser.parse_args():
exit(0)
logging.basicConfig(level=logging.INFO)
QApplication.setStyle("Fusion")
if sys.platform == "darwin":
QApplication.setStyle(
"Fusion"
) # this helps macOS but causes Linux GUI to be unusable
QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
surfaceFormat = QSurfaceFormat()
surfaceFormat.setSwapInterval(1)
Expand Down
2 changes: 1 addition & 1 deletion nexus_constructor/instrument_view/line_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, vertex_data: QtCore.QByteArray, parent=None):
self.position_attribute.setCount(2)
self.addAttribute(self.position_attribute)

if platform == "darwin":
if platform == "darwin": # this may no longer be needed
normal = QVector3D.normal(QVector3D(0, 0, 0), QVector3D(0, 0, 0))
normal_buffer_values = []
# Need to have a normal for each vector
Expand Down
10 changes: 8 additions & 2 deletions nexus_constructor/ui_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Optional
from sys import platform

import numpy as np
from PySide6.QtCore import Qt
Expand Down Expand Up @@ -61,7 +62,10 @@ def validate_combobox_edit(
:param tooltip_on_reject: Tooltip to display combobox edit is invalid.
:return: None.
"""
colour = "#333333" if is_valid else "#f6989d"
colour = "#FFFFFF" if is_valid else "#f6989d"
if platform == "darwin" and colour == "#FFFFFF":
colour = "#333333"

combobox_edit.setStyleSheet(f"QComboBox {{ background-color: {colour} }}")
if "Suggestion" in tooltip_on_reject and callable(suggestion_callable):
tooltip_on_reject += suggestion_callable()
Expand All @@ -86,7 +90,9 @@ def validate_line_edit(
:param tooltip_on_reject: Tooltip to display if line edit is invalid.
:return: None.
"""
colour = "#333333" if is_valid else "#f6989d"
colour = "#FFFFFF" if is_valid else "#f6989d"
if platform == "darwin" and colour == "#FFFFFF":
colour = "#333333"
line_edit.setStyleSheet(f"QLineEdit {{ background-color: {colour} }}")
if "Suggestion" in tooltip_on_reject and callable(suggestion_callable):
tooltip_on_reject += suggestion_callable()
Expand Down
2 changes: 1 addition & 1 deletion nx-class-documentation/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h1>User Manual and Reference Documentation<a class="headerlink" href="#user-man
</div>
<hr class="docutils" />
<p class="rubric">Publishing Information</p>
<p>This manual built Jun 13, 2023.</p>
<p>This manual built Jul 03, 2023.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>This document is available in these formats online:</p>
Expand Down
2 changes: 1 addition & 1 deletion nx-class-documentation/html/searchindex.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def test_GIVEN_invalid_WHEN_validating_line_edit_THEN_line_edit_turns_red():
def test_GIVEN_valid_WHEN_validating_line_edit_THEN_line_edit_turns_white():
line_edit = DummyLineEdit()
validate_line_edit(line_edit, True)
assert "background-color: #333333" in line_edit.stylesheet
assert (
"background-color: "
+ ("#333333" if os.uname().sysname == "Darwin" else "#FFFFFF")
in line_edit.stylesheet
)


def test_GIVEN_valid_WHEN_validating_line_edit_with_tooltip_THEN_line_edit_tooltip_is_changed():
Expand Down
2 changes: 1 addition & 1 deletion ui_tests/ui_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RUNNING_ON_WINDOWS = sys.platform.startswith("win")

RED_BACKGROUND = "{ background-color: #f6989d }"
WHITE_BACKGROUND = "{ background-color: #333333 }" # no longer white
WHITE_BACKGROUND = "{ background-color: " + ("#333333" if sys.platform == "darwin" else "#FFFFFF") + " }"
LINE_EDIT = "QLineEdit "
SPIN_BOX = "QSpinBox "
RED_LINE_EDIT_STYLE_SHEET = LINE_EDIT + RED_BACKGROUND
Expand Down

0 comments on commit 7808e7c

Please sign in to comment.