mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 16:44:16 +02:00
[wgem] runtime dir | improving installation options dialog design
This commit is contained in:
@@ -7,6 +7,7 @@ from PyQt5.QtWidgets import QRadioButton, QGroupBox, QCheckBox, QComboBox, QGrid
|
||||
|
||||
from bauh.api.abstract.view import SingleSelectComponent, InputOption, MultipleSelectComponent, SelectViewType, \
|
||||
TextInputComponent, FormComponent
|
||||
from bauh.view.qt import css
|
||||
from bauh.view.util import resource
|
||||
|
||||
|
||||
@@ -160,12 +161,18 @@ class MultipleSelectQt(QGroupBox):
|
||||
|
||||
def __init__(self, model: MultipleSelectComponent, callback):
|
||||
super(MultipleSelectQt, self).__init__(model.label if model.label else None)
|
||||
self.setStyleSheet("QGroupBox { font-weight: bold }")
|
||||
self.setStyleSheet(css.GROUP_BOX)
|
||||
self.model = model
|
||||
self._layout = QGridLayout()
|
||||
self.setLayout(self._layout)
|
||||
|
||||
line, col = 0, 0
|
||||
if model.label:
|
||||
line = 1
|
||||
self.layout().addWidget(QLabel(), 0, 1)
|
||||
else:
|
||||
line = 0
|
||||
|
||||
col = 0
|
||||
|
||||
pixmap_help = QPixmap()
|
||||
|
||||
@@ -200,6 +207,9 @@ class MultipleSelectQt(QGroupBox):
|
||||
else:
|
||||
col += 1
|
||||
|
||||
if model.label:
|
||||
self.layout().addWidget(QLabel(), line + 1, 1)
|
||||
|
||||
|
||||
class InputFilter(QLineEdit):
|
||||
|
||||
@@ -248,22 +258,26 @@ class IconButton(QWidget):
|
||||
class FormQt(QGroupBox):
|
||||
|
||||
def __init__(self, model: FormComponent):
|
||||
super(FormQt, self).__init__()
|
||||
super(FormQt, self).__init__(model.label if model.label else '')
|
||||
self.model = model
|
||||
self.setLayout(QFormLayout())
|
||||
self.setStyleSheet('QLabel { font-weight: bold; }')
|
||||
self.setStyleSheet(css.GROUP_BOX)
|
||||
|
||||
self.layout().addRow(QLabel(), QLabel())
|
||||
|
||||
for c in model.components:
|
||||
if isinstance(c, TextInputComponent):
|
||||
label, field = self._new_text_input(c)
|
||||
self.layout().addRow(label, field)
|
||||
elif isinstance(c, SingleSelectComponent):
|
||||
label = QLabel(c.label.capitalize() + ':' if c.label else '')
|
||||
label = QLabel(c.label.capitalize() if c.label else '')
|
||||
field = ComboBoxQt(c)
|
||||
self.layout().addRow(label, field)
|
||||
else:
|
||||
raise Exception('Unsupported component type {}'.format(c.__class__.__name__))
|
||||
|
||||
self.layout().addRow(QLabel(), QLabel())
|
||||
|
||||
def _new_text_input(self, c: TextInputComponent) -> Tuple[QLabel, QLineEdit]:
|
||||
line_edit = QLineEdit()
|
||||
|
||||
@@ -284,7 +298,7 @@ class FormQt(QGroupBox):
|
||||
c.value = text
|
||||
|
||||
line_edit.textChanged.connect(update_model)
|
||||
return QLabel(c.label.capitalize() + ':' if c.label else ''), line_edit
|
||||
return QLabel(c.label.capitalize() if c.label else ''), line_edit
|
||||
|
||||
|
||||
def new_single_select(model: SingleSelectComponent):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import List
|
||||
|
||||
from PyQt5.QtCore import QSize, Qt
|
||||
from PyQt5.QtWidgets import QMessageBox, QVBoxLayout, QLabel, QWidget, QScrollArea, QFrame
|
||||
from PyQt5.QtWidgets import QMessageBox, QVBoxLayout, QLabel, QWidget, QScrollArea, QFrame, QSizePolicy
|
||||
|
||||
from bauh.api.abstract.view import ViewComponent, SingleSelectComponent, MultipleSelectComponent, TextInputComponent, \
|
||||
FormComponent
|
||||
@@ -63,10 +63,10 @@ class ConfirmationDialog(QMessageBox):
|
||||
|
||||
scroll.setFixedHeight(height)
|
||||
|
||||
self.layout().addWidget(scroll, 1, 1)
|
||||
self.layout().addWidget(scroll, 1 if body else 0, 1)
|
||||
|
||||
if not body and width > 0:
|
||||
self.layout().addWidget(QLabel(' ' * int(width / 2)), 0, 1)
|
||||
self.layout().addWidget(QLabel(' ' * int(width / 2)), 1, 1)
|
||||
|
||||
self.exec_()
|
||||
|
||||
|
||||
@@ -2,3 +2,18 @@
|
||||
OK_BUTTON = """QPushButton { background: green; color: white; font-weight: bold}
|
||||
QPushButton:disabled { background-color: gray; }
|
||||
"""
|
||||
|
||||
GROUP_BOX = """
|
||||
QGroupBox {
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
border: 1px solid silver;
|
||||
border-radius: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
QGroupBox::title {
|
||||
subcontrol-origin: margin;
|
||||
left: 7px;
|
||||
padding: 0px 5px 0px 5px;
|
||||
}
|
||||
"""
|
||||
Reference in New Issue
Block a user