Skip to content

Commit

Permalink
UI theme rework and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofpayne committed Nov 26, 2024
1 parent 85d6196 commit 24a452a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 40 deletions.
15 changes: 11 additions & 4 deletions laserstudio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import sys
import yaml
import os.path
from .utils.util import resource_path
import logging
import argparse
from .utils.util import resource_path
from .utils.colors import LedgerColors

if __name__ == "__main__":
app = QApplication(sys.argv)
Expand Down Expand Up @@ -42,12 +43,12 @@
palette = QPalette()
palette.setColor(QPalette.ColorRole.Window, QColor(25, 25, 25))
palette.setColor(QPalette.ColorRole.WindowText, QColor(240, 240, 240))
palette.setColor(QPalette.ColorRole.Base, QColor(40, 40, 40))
palette.setColor(QPalette.ColorRole.Base, QColor(50, 50, 50))
palette.setColor(QPalette.ColorRole.AlternateBase, Qt.GlobalColor.red)
palette.setColor(QPalette.ColorRole.ToolTipBase, QColor(25, 25, 25))
palette.setColor(QPalette.ColorRole.ToolTipText, Qt.GlobalColor.white)
palette.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.lightGray)
palette.setColor(QPalette.ColorRole.Button, QColor(40, 40, 40))
palette.setColor(QPalette.ColorRole.Button, QColor(45, 45, 45))
palette.setColor(
QPalette.ColorGroup.Disabled, QPalette.ColorRole.Button, QColor(30, 30, 30)
)
Expand All @@ -59,9 +60,15 @@
)
palette.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red)
palette.setColor(QPalette.ColorRole.Link, Qt.GlobalColor.red)
palette.setColor(QPalette.ColorRole.Highlight, QColor(40, 120, 233))
palette.setColor(QPalette.ColorRole.Highlight, LedgerColors.SafetyOrange.value)
palette.setColor(QPalette.ColorRole.HighlightedText, QColor(255, 255, 255))
app.setPalette(palette)
app.setStyleSheet("QToolBar { "
"border: 1px solid #252525;"
"border-radius: 4px;"
"margin: 3px;"
"padding: 6px;"
"background-color: #252525 }")

QLocale.setDefault(QLocale.c())

Expand Down
11 changes: 5 additions & 6 deletions laserstudio/widgets/keyboardbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def __init__(self, stage: StageInstrument, *__args):
self.displacement_xy = 100.0

vbox = QVBoxLayout()
vbox.setContentsMargins(0, 0, 0, 0)
self.setLayout(vbox)

grid = QGridLayout()
grid.setContentsMargins(0, 0, 0, 0)
if num_axis > 0:
w = QPushButton(Direction.left)
w.setFixedWidth(30)
Expand Down Expand Up @@ -75,16 +77,15 @@ def __init__(self, stage: StageInstrument, *__args):
w.setFixedWidth(30)
w.pressed.connect(lambda: self.move_stage(Direction.down))
grid.addWidget(w, 2, 2, alignment=Qt.AlignmentFlag.AlignCenter)
grid.setColumnStretch(2, 1)
if num_axis > 2:
w = QPushButton(Direction.zup)
w.setFixedWidth(30)
w.pressed.connect(lambda: self.move_stage(Direction.zup))
grid.addWidget(w, 1, 4)
grid.addWidget(w, 1, 4, alignment=Qt.AlignmentFlag.AlignCenter)
w = QPushButton(Direction.zdown)
w.setFixedWidth(30)
w.pressed.connect(lambda: self.move_stage(Direction.zdown))
grid.addWidget(w, 2, 4)
grid.addWidget(w, 2, 4, alignment=Qt.AlignmentFlag.AlignCenter)
grid.setColumnStretch(4, 1)

w = QDoubleSpinBox()
Expand All @@ -97,9 +98,7 @@ def __init__(self, stage: StageInstrument, *__args):
w.setSingleStep(10)
grid.addWidget(w, 3, 4)

w = QWidget()
w.setLayout(grid)
vbox.addWidget(w)
vbox.addLayout(grid)

self.setFocusPolicy(Qt.FocusPolicy.ClickFocus)

Expand Down
2 changes: 1 addition & 1 deletion laserstudio/widgets/return_line_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self):
self.returnPressed.connect(self.reset)

def highlight(self):
self.setStyleSheet("background: #344266;")
self.setStyleSheet("background: #b86a45;")

def reset(self):
self.setStyleSheet("")
Expand Down
1 change: 1 addition & 0 deletions laserstudio/widgets/toolbars/cameranittoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, laser_studio: "LaserStudio"):
hbox = QHBoxLayout()
vbox.addLayout(hbox)
hbox.addWidget(QLabel("Gain:"))
vbox.setContentsMargins(0, 0, 0, 0)
w = self.hist_low_input = ReturnSpinBox()
w.setMinimum(0)
w.setMaximum(0xFFFF)
Expand Down
34 changes: 15 additions & 19 deletions laserstudio/widgets/toolbars/cameratoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def __init__(self, laser_studio: "LaserStudio"):

w = QWidget()
self.addWidget(w)
hbox = QHBoxLayout()
w.setLayout(hbox)
grid = QGridLayout()
grid.setContentsMargins(0, 0, 0, 0)
w.setLayout(grid)

# Button to toggle off or on the camera image presentation in main viewer
w = QPushButton(self)
Expand All @@ -57,25 +58,23 @@ def __init__(self, laser_studio: "LaserStudio"):
QIcon.State.Off,
)
w.setIcon(icon)
w.setIconSize(QSize(24, 24))
w.setIconSize(QSize(16, 16))
w.toggled.connect(
lambda b: laser_studio.viewer.stage_sight.__setattr__("show_image", b)
)
hbox.addWidget(w)
grid.addWidget(w, 1, 1)

vbox2 = QVBoxLayout()
hbox.addLayout(vbox2)
w = QPushButton(self)
w.setText("Distortion Wizard")
# Distortion wizard button
w = QPushButton("Distortion Wizard")
self.camera_distortion_wizard = CameraDistortionWizard(laser_studio, self)
w.clicked.connect(lambda: self.camera_distortion_wizard.show())
vbox2.addWidget(w)
grid.addWidget(w, 2, 1)

# Probes wizard button
self.probes_distortion_wizard = ProbesPositionWizard(laser_studio, self)
w = QPushButton(self)
w.setText("Probes/Spots Position Wizard")
w = QPushButton("Probes/Spots Wizard")
w.clicked.connect(lambda: (self.probes_distortion_wizard.show()))
vbox2.addWidget(w)
grid.addWidget(w, 2, 2)
w.setHidden(
len(laser_studio.instruments.probes) + len(laser_studio.instruments.lasers)
== 0
Expand All @@ -85,14 +84,11 @@ def __init__(self, laser_studio: "LaserStudio"):
stage_sight = StageSight(None, self.camera)
w = StageSightViewer(stage_sight)
w.setHidden(True)
self.addWidget(w)
grid.addWidget(w, 3, 1, 1, 2)

# Refresh interval
w = QWidget()
self.addWidget(w)
hbox = QHBoxLayout()
w.setLayout(hbox)
hbox.addWidget(QLabel("Refresh interval:"))
grid.addWidget(QLabel("Refresh interval:"), 3, 1)
self.refresh_interval = w = ReturnSpinBox()
w.setSuffix("ms")
w.setMinimum(20)
Expand All @@ -106,7 +102,7 @@ def __init__(self, laser_studio: "LaserStudio"):
"refresh_interval", self.refresh_interval.value()
)
)
hbox.addWidget(w)
grid.addWidget(w, 3, 2)

self.image_dialog = QDialog()
self.image_dialog.setWindowTitle("Image Adjustment")
Expand All @@ -115,7 +111,7 @@ def __init__(self, laser_studio: "LaserStudio"):
w.setToolTip(self.image_dialog.windowTitle())
w.setIcon(QIcon(colored_image(":/icons/fontawesome-free/sliders-solid.svg")))
w.clicked.connect(lambda: self.image_dialog.exec())
self.addWidget(w)
grid.addWidget(w, 1, 2)

grid = QGridLayout()
# Image adjustment dialog (for USB camera)
Expand Down
2 changes: 1 addition & 1 deletion laserstudio/widgets/toolbars/maintoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, laser_studio: "LaserStudio"):
w = QLabel()
w.setPixmap(
QPixmap(resource_path(":/icons/logo.svg")).scaled(
64, 64, transformMode=Qt.TransformationMode.SmoothTransformation
32, 32, transformMode=Qt.TransformationMode.SmoothTransformation
)
)
w.setAlignment(Qt.AlignmentFlag.AlignCenter)
Expand Down
4 changes: 4 additions & 0 deletions laserstudio/widgets/toolbars/pdmtoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
QWidget,
QSpinBox,
QDoubleSpinBox,
QCheckBox,
)
from PyQt6.QtCore import Qt, QSize, QVariant
from PyQt6.QtGui import QIcon, QPixmap
Expand Down Expand Up @@ -34,6 +35,8 @@ def __init__(self, laser: PDMInstrument, laser_num: int):
self.setFloatable(True)

w = self.on_off_button = QPushButton(self)
if self.laser.label is not None:
w.setText(self.laser.label)
w.setToolTip("On/Off Laser")
w.setCheckable(True)
w.setChecked(False)
Expand All @@ -58,6 +61,7 @@ def __init__(self, laser: PDMInstrument, laser_num: int):
self.addWidget(w)

grid = QGridLayout()
grid.setContentsMargins(0, 4, 0, 0)
row = 0

# Laser pulsed power
Expand Down
15 changes: 6 additions & 9 deletions laserstudio/widgets/toolbars/stagetoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, laser_studio: "LaserStudio"):

w = QWidget()
vbox = QVBoxLayout()
vbox.setContentsMargins(0, 0, 0, 0)
w.setLayout(vbox)
self.addWidget(w)

Expand Down Expand Up @@ -87,16 +88,8 @@ def __init__(self, laser_studio: "LaserStudio"):
hbox.addWidget(w)
vbox.addLayout(hbox)

# Keyboard box
self.keyboardbox = w = KeyboardBox(self.stage)
self.addWidget(w)

w = QWidget()
vbox = QVBoxLayout()
w.setLayout(vbox)
self.addWidget(w)

hbox = QHBoxLayout()
hbox.setContentsMargins(0, 0, 0, 0)
vbox.addLayout(hbox)
# Move for
self.move_for_selector = box = QComboBox()
Expand All @@ -109,6 +102,10 @@ def __init__(self, laser_studio: "LaserStudio"):
hbox.addWidget(QLabel("Focus on:"))
hbox.addWidget(box)

# Keyboard box
self.keyboardbox = w = KeyboardBox(self.stage)
vbox.addWidget(w)

# Joysticks
self.joystick: Optional[Union[JoystickInstrument, JoystickHIDInstrument]] = None
input_dir = os.path.join(os.sep, "dev", "input")
Expand Down

0 comments on commit 24a452a

Please sign in to comment.