Files
IfcOpenShell/src/ifcviewer-full/components/Style.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

498 lines
17 KiB
C++
Raw Normal View History

2026-05-06 10:47:03 +10:00
// This file was generated with the assistance of an AI coding tool.
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#include "Style.h"
2026-05-11 09:17:45 +10:00
#include "../InterfaceSettings.h"
2026-05-06 10:47:03 +10:00
namespace ifcinterface::components::style {
QString buildAppStyleSheet() {
2026-05-11 09:17:45 +10:00
const auto& theme = ifcinterface::InterfaceSettings::instance();
2026-05-06 21:35:12 +10:00
QString stylesheet = QStringLiteral(R"(
2026-05-06 13:13:37 +10:00
QMainWindow#appWindow {
2026-05-06 21:35:12 +10:00
background: ${app_background};
color: ${primary_text};
selection-background-color: ${selection_background};
selection-color: ${selection_text};
}
QDialog#appDialog {
background: ${app_background};
color: ${primary_text};
2026-05-06 10:47:03 +10:00
}
2026-05-07 14:12:27 +10:00
QMessageBox,
QMessageBox QWidget,
QMessageBox QLabel {
background: ${app_background};
color: ${primary_text};
}
2026-05-07 12:21:55 +10:00
QFileDialog,
QFileDialog QWidget,
QFileDialog QStackedWidget,
QFileDialog QSplitter {
background: ${app_background};
color: ${primary_text};
}
QTabBar#appTabBar {
2026-05-11 09:17:45 +10:00
background: ${tab_bar_background};
2026-05-07 12:21:55 +10:00
}
QTabBar#appTabBar::tab {
2026-05-11 09:17:45 +10:00
background: ${tab_background};
2026-05-06 21:35:12 +10:00
color: ${secondary_text};
2026-05-06 10:47:03 +10:00
padding: 8px 14px;
margin-right: 2px;
border-bottom: 2px solid transparent;
}
2026-05-07 12:21:55 +10:00
QTabBar#appTabBar::tab:selected {
2026-05-06 21:35:12 +10:00
color: ${primary_text};
border-bottom: 2px solid ${selection_background};
2026-05-06 10:47:03 +10:00
}
2026-05-07 12:21:55 +10:00
QTabBar#appTabBar::tab:hover {
2026-05-11 09:17:45 +10:00
color: ${hover_text};
2026-05-06 10:47:03 +10:00
}
QFrame#ribbonBand {
2026-05-11 09:17:45 +10:00
background: ${ribbon_background};
2026-05-06 21:35:12 +10:00
border-top: 1px solid ${border};
}
2026-05-07 12:21:55 +10:00
QTabWidget#appTabWidget::pane {
2026-05-06 21:35:12 +10:00
border: none;
background: transparent;
2026-05-06 10:47:03 +10:00
}
QFrame#ribbonPage {
background: transparent;
}
QFrame#ribbonGroup {
background: transparent;
2026-05-06 21:35:12 +10:00
border-right: 1px solid ${border};
2026-05-06 10:47:03 +10:00
}
2026-05-07 12:21:55 +10:00
QFrame#ribbonGroup[separator="false"] {
border-right: none;
}
2026-05-06 10:47:03 +10:00
QLabel#ribbonGroupLabel {
2026-05-10 22:04:03 +10:00
font-size: ${font_small}px;
2026-05-06 10:47:03 +10:00
font-weight: 600;
}
QToolButton#ribbonButton {
background: transparent;
border: none;
padding: 6px 4px 4px 4px;
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 10:47:03 +10:00
}
QToolButton#ribbonButton:hover {
2026-05-06 21:35:12 +10:00
background: ${ribbon_button_hover};
2026-05-06 10:47:03 +10:00
}
QToolButton#ribbonButton:pressed {
2026-05-06 21:35:12 +10:00
background: ${ribbon_button_pressed};
2026-05-06 10:47:03 +10:00
}
QFrame#viewportShell {
2026-05-06 21:35:12 +10:00
background: ${viewport_shell_background};
border-top: none;
2026-05-06 10:47:03 +10:00
}
QFrame#viewportFrame {
2026-05-06 21:35:12 +10:00
border: 1px solid ${border};
2026-05-06 10:47:03 +10:00
}
QDockWidget {
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 10:47:03 +10:00
}
2026-05-06 13:13:37 +10:00
QLabel {
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 13:13:37 +10:00
background: transparent;
}
QAbstractItemView,
QTreeWidget,
QListWidget,
QTableWidget,
QLineEdit,
2026-05-07 12:21:55 +10:00
QComboBox,
2026-05-06 21:35:12 +10:00
QSpinBox,
QDoubleSpinBox,
QCheckBox,
2026-05-09 22:00:19 +10:00
QRadioButton,
2026-05-06 21:35:12 +10:00
QPushButton,
2026-05-06 13:13:37 +10:00
QToolButton {
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 13:13:37 +10:00
}
QLabel[textRole="secondary"] {
2026-05-06 21:35:12 +10:00
color: ${secondary_text};
2026-05-06 13:13:37 +10:00
}
QLabel[textRole="disabled"] {
2026-05-06 21:35:12 +10:00
color: ${disabled_text};
2026-05-06 13:13:37 +10:00
}
QLabel[textRole="warning"] {
2026-05-06 21:35:12 +10:00
color: ${warning_text};
2026-05-06 13:13:37 +10:00
}
QLabel#panelTitleText {
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-10 22:04:03 +10:00
font-size: ${font_small}px;
font-weight: 600;
2026-05-06 10:47:03 +10:00
}
2026-05-06 13:13:37 +10:00
QToolButton#panelTitleButton {
2026-05-06 10:47:03 +10:00
border: none;
background: transparent;
}
2026-05-06 13:13:37 +10:00
QToolButton#panelTitleButton:hover {
2026-05-11 09:17:45 +10:00
color: ${hover_text};
background: ${ribbon_button_hover};
2026-05-06 10:47:03 +10:00
}
QFrame#panel {
2026-05-06 21:35:12 +10:00
background: ${panel_background};
border: 1px solid ${border};
border-radius: ${panel_radius}px;
2026-05-06 10:47:03 +10:00
}
QTreeWidget, QListWidget, QTableWidget, QAbstractScrollArea {
2026-05-06 21:35:12 +10:00
background: ${panel_background};
2026-05-06 10:47:03 +10:00
border: none;
outline: none;
2026-05-06 21:35:12 +10:00
gridline-color: ${border};
2026-05-06 10:47:03 +10:00
}
2026-05-10 22:04:03 +10:00
QTableWidget#modelCoordinatesTable {
font-size: ${font_small}px;
}
QTableWidget#modelCoordinatesTable QHeaderView::section {
font-size: ${font_small}px;
}
2026-05-06 10:47:03 +10:00
QTreeWidget::viewport, QListWidget::viewport, QTableWidget::viewport {
2026-05-06 21:35:12 +10:00
background: ${panel_background};
2026-05-06 10:47:03 +10:00
}
QHeaderView::section {
2026-05-06 21:35:12 +10:00
background: ${control_background};
color: ${primary_text};
2026-05-06 10:47:03 +10:00
border: none;
2026-05-06 21:35:12 +10:00
border-bottom: 1px solid ${border};
2026-05-06 10:47:03 +10:00
padding: 7px 8px;
font-weight: 600;
}
QTableCornerButton::section {
2026-05-06 21:35:12 +10:00
background: ${control_background};
2026-05-06 10:47:03 +10:00
border: none;
}
QScrollArea {
2026-05-06 21:35:12 +10:00
background: ${panel_background};
2026-05-06 10:47:03 +10:00
border: none;
}
QScrollArea > QWidget > QWidget {
2026-05-06 21:35:12 +10:00
background: ${panel_background};
2026-05-06 10:47:03 +10:00
}
QLineEdit {
2026-05-06 21:35:12 +10:00
background: ${control_background};
border: 1px solid ${border};
border-radius: ${panel_radius}px;
padding: ${padding}px ${padding}px;
color: ${primary_text};
2026-05-06 10:47:03 +10:00
}
QLineEdit:focus {
2026-05-06 21:35:12 +10:00
border: 1px solid ${control_border_focus};
}
2026-05-07 12:21:55 +10:00
QComboBox {
background: ${control_background};
border: 1px solid ${border};
border-radius: ${panel_radius}px;
2026-05-09 22:00:19 +10:00
padding: ${padding}px 24px ${padding}px ${padding}px;
2026-05-07 12:21:55 +10:00
}
QComboBox:focus {
border: 1px solid ${control_border_focus};
}
2026-05-09 22:00:19 +10:00
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 18px;
border: none;
background: transparent;
}
QComboBox::down-arrow {
width: 0px;
height: 0px;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 6px solid ${secondary_text};
margin-right: 4px;
}
2026-05-07 12:21:55 +10:00
QComboBox QAbstractItemView {
background: ${panel_background};
border: 1px solid ${border};
selection-background-color: ${selection_background};
selection-color: ${selection_text};
}
2026-05-06 21:35:12 +10:00
QSpinBox, QDoubleSpinBox {
background: ${control_background};
border: 1px solid ${border};
border-radius: ${panel_radius}px;
2026-05-09 22:00:19 +10:00
padding: ${padding}px 24px ${padding}px ${padding}px;
2026-05-06 21:35:12 +10:00
}
QSpinBox:focus, QDoubleSpinBox:focus {
border: 1px solid ${control_border_focus};
}
2026-05-09 22:00:19 +10:00
QSpinBox::up-button, QDoubleSpinBox::up-button,
QSpinBox::down-button, QDoubleSpinBox::down-button {
subcontrol-origin: padding;
width: 18px;
border: none;
background: transparent;
}
QSpinBox::up-button, QDoubleSpinBox::up-button {
subcontrol-position: top right;
}
QSpinBox::down-button, QDoubleSpinBox::down-button {
subcontrol-position: bottom right;
}
QSpinBox::up-arrow, QDoubleSpinBox::up-arrow {
width: 0px;
height: 0px;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 5px solid ${secondary_text};
}
QSpinBox::down-arrow, QDoubleSpinBox::down-arrow {
width: 0px;
height: 0px;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 5px solid ${secondary_text};
}
2026-05-06 21:35:12 +10:00
QCheckBox {
background: transparent;
spacing: 8px;
}
QCheckBox::indicator {
width: 16px;
height: 16px;
border: 1px solid ${border};
border-radius: ${panel_radius}px;
background: ${control_background};
}
QCheckBox::indicator:hover {
background: ${ribbon_button_hover};
2026-05-06 10:47:03 +10:00
}
2026-05-06 21:35:12 +10:00
QCheckBox::indicator:checked {
border: 1px solid ${selection_background};
background: ${selection_background};
}
2026-05-09 22:00:19 +10:00
QRadioButton {
background: transparent;
color: ${primary_text};
spacing: 8px;
padding: 2px 0;
}
QRadioButton::indicator {
width: 16px;
height: 16px;
border: 1px solid ${border};
border-radius: 8px;
background: ${control_background};
}
QRadioButton::indicator:hover {
background: ${ribbon_button_hover};
}
QRadioButton::indicator:checked {
border: 1px solid ${selection_background};
background: ${selection_background};
}
QRadioButton::indicator:unchecked {
background: ${control_background};
}
2026-05-06 21:35:12 +10:00
QPushButton {
background: ${control_background};
border: 1px solid ${border};
border-radius: ${panel_radius}px;
padding: ${padding}px ${padding}px;
}
QPushButton:hover {
background: ${ribbon_button_hover};
}
QPushButton:pressed {
background: ${ribbon_button_pressed};
}
2026-05-07 17:10:04 +10:00
QMenu {
background: ${panel_background};
color: ${primary_text};
border: 1px solid ${border};
padding: 4px;
}
QMenu::item {
background: transparent;
color: ${primary_text};
padding: 6px 24px 6px 10px;
border-radius: ${panel_radius}px;
}
QMenu::item:selected {
background: ${selection_background};
color: ${selection_text};
}
QMenu::item:disabled {
color: ${disabled_text};
}
QMenu::separator {
height: 1px;
background: ${border};
margin: 4px 8px;
}
QMenu::icon {
padding-left: 2px;
}
2026-05-06 21:35:12 +10:00
QFrame#entityClassBox,
QGroupBox#propertySetBox {
background: ${box_background};
border: 1px solid ${border};
border-radius: ${panel_radius}px;
2026-05-06 10:47:03 +10:00
}
QLabel#entityClassLabel {
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 10:47:03 +10:00
font-weight: 700;
background: transparent;
}
2026-05-06 12:36:28 +10:00
QWidget#keyValueTable {
2026-05-06 10:47:03 +10:00
background: transparent;
}
QTreeView::item, QListView::item, QTableView::item {
padding: 4px;
}
QScrollBar:vertical {
background: transparent;
width: 10px;
margin: 2px 2px 2px 0;
}
QScrollBar:horizontal {
background: transparent;
height: 10px;
margin: 0 2px 2px 2px;
}
QScrollBar::handle:vertical, QScrollBar::handle:horizontal {
2026-05-06 21:35:12 +10:00
background: ${scroll_handle};
border-radius: ${panel_radius}px;
2026-05-06 10:47:03 +10:00
min-height: 24px;
min-width: 24px;
}
QScrollBar::handle:vertical:hover, QScrollBar::handle:horizontal:hover {
2026-05-06 21:35:12 +10:00
background: ${scroll_handle_hover};
2026-05-06 10:47:03 +10:00
}
QScrollBar::add-line, QScrollBar::sub-line,
QScrollBar::add-page, QScrollBar::sub-page {
background: transparent;
border: none;
}
QStatusBar {
2026-05-06 21:35:12 +10:00
background: ${status_background};
2026-05-06 10:47:03 +10:00
}
QStatusBar QLabel {
2026-05-06 21:35:12 +10:00
color: ${secondary_text};
2026-05-06 10:47:03 +10:00
background: transparent;
border: none;
padding: 2px 8px;
}
QGroupBox {
background: transparent;
2026-05-06 21:35:12 +10:00
border: 1px solid ${border};
border-radius: ${panel_radius}px;
2026-05-06 10:47:03 +10:00
margin-top: 10px;
padding-top: 10px;
}
2026-05-06 21:35:12 +10:00
QGroupBox#propertySetBox::title {
2026-05-06 10:47:03 +10:00
subcontrol-origin: margin;
2026-05-06 21:35:12 +10:00
left: ${padding}px;
2026-05-06 10:47:03 +10:00
padding: 0 4px;
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 10:47:03 +10:00
}
2026-05-06 21:35:12 +10:00
QGroupBox#propertySetBox > QWidget {
background: ${box_background};
2026-05-06 10:47:03 +10:00
}
QWidget#panelSection {
background: transparent;
}
QWidget#panelSectionFilterWrapper {
background: transparent;
}
2026-05-06 13:13:37 +10:00
QLabel#keyValueTrailingIconLabel {
2026-05-06 10:47:03 +10:00
background: transparent;
}
2026-05-06 12:36:28 +10:00
QWidget#panelScrollBody {
2026-05-06 21:35:12 +10:00
background: ${panel_background};
2026-05-06 10:47:03 +10:00
}
QFrame#panelSectionHeader {
2026-05-06 21:35:12 +10:00
background: ${section_header_background};
2026-05-06 10:47:03 +10:00
}
QToolButton#panelSectionHeaderButton {
background: transparent;
border: none;
2026-05-06 21:35:12 +10:00
color: ${primary_text};
2026-05-06 10:47:03 +10:00
font-weight: 700;
text-align: left;
2026-05-06 21:35:12 +10:00
padding: ${section_header_padding}px;
2026-05-06 10:47:03 +10:00
margin: 0;
}
QToolButton#panelSectionHeaderButton:hover {
2026-05-11 09:17:45 +10:00
color: ${hover_text};
2026-05-06 10:47:03 +10:00
}
QToolButton#panelSectionHeaderButton::menu-indicator {
image: none;
width: 0;
}
QToolButton#panelSectionFilterToggle {
background: transparent;
border: none;
2026-05-06 21:35:12 +10:00
padding: ${section_header_padding}px;
2026-05-06 10:47:03 +10:00
}
QToolButton#panelSectionFilterToggle:hover {
2026-05-11 09:17:45 +10:00
background: ${ribbon_button_hover};
2026-05-06 10:47:03 +10:00
}
QWidget#panelSectionBody {
background: transparent;
}
2026-05-06 12:36:28 +10:00
QLabel#keyValueValueLabel {
2026-05-11 09:17:45 +10:00
color: ${primary_text};
2026-05-06 10:47:03 +10:00
background: transparent;
}
2026-05-06 21:35:12 +10:00
)");
stylesheet.replace("${panel_radius}", QString::number(metrics::panel_radius));
stylesheet.replace("${padding}", QString::number(metrics::padding));
stylesheet.replace("${section_header_padding}", QString::number(metrics::section_header_padding));
2026-05-10 22:04:03 +10:00
stylesheet.replace("${font_small}", QString::number(typography::small));
2026-05-06 21:35:12 +10:00
2026-05-11 09:17:45 +10:00
stylesheet.replace("${app_background}", theme.color("app_background"));
stylesheet.replace("${border}", theme.color("border"));
stylesheet.replace("${selection_background}", theme.color("selection_background"));
stylesheet.replace("${selection_text}", theme.color("selection_text"));
stylesheet.replace("${tab_bar_background}", theme.color("tab_bar_background"));
stylesheet.replace("${tab_background}", theme.color("tab_background"));
stylesheet.replace("${hover_text}", theme.color("hover_text"));
stylesheet.replace("${ribbon_background}", theme.color("ribbon_background"));
stylesheet.replace("${ribbon_button_hover}", theme.color("ribbon_button_hover"));
stylesheet.replace("${ribbon_button_pressed}", theme.color("ribbon_button_pressed"));
stylesheet.replace("${viewport_shell_background}", theme.color("viewport_shell_background"));
stylesheet.replace("${viewport_background}", theme.color("viewport_background"));
stylesheet.replace("${panel_background}", theme.color("panel_background"));
stylesheet.replace("${control_background}", theme.color("control_background"));
stylesheet.replace("${control_border_focus}", theme.color("control_border_focus"));
stylesheet.replace("${box_background}", theme.color("box_background"));
stylesheet.replace("${scroll_handle}", theme.color("scroll_handle"));
stylesheet.replace("${scroll_handle_hover}", theme.color("scroll_handle_hover"));
stylesheet.replace("${status_background}", theme.color("status_background"));
stylesheet.replace("${section_header_background}", theme.color("section_header_background"));
2026-05-06 21:35:12 +10:00
2026-05-11 09:17:45 +10:00
stylesheet.replace("${primary_text}", theme.color("primary_text"));
stylesheet.replace("${secondary_text}", theme.color("secondary_text"));
stylesheet.replace("${disabled_text}", theme.color("disabled_text"));
stylesheet.replace("${warning_text}", theme.color("warning_text"));
2026-05-06 21:35:12 +10:00
return stylesheet;
2026-05-06 10:47:03 +10:00
}
} // namespace ifcinterface::components::style