gui: tweak layout
This commit is contained in:
@@ -188,36 +188,27 @@ class KeyBindingDialog(QtWidgets.QDialog):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.result = {}
|
self.result = {}
|
||||||
self.layout = QtWidgets.QVBoxLayout()
|
self.layout = QtWidgets.QFormLayout()
|
||||||
|
self.layout.setFieldGrowthPolicy(
|
||||||
|
QtWidgets.QFormLayout.AllNonFixedFieldsGrow
|
||||||
|
)
|
||||||
|
|
||||||
sub_layout = QtWidgets.QHBoxLayout()
|
|
||||||
sub_layout.addWidget(QtWidgets.QLabel('Key'))
|
|
||||||
self.key = QtWidgets.QLineEdit()
|
self.key = QtWidgets.QLineEdit()
|
||||||
sub_layout.addWidget(self.key)
|
self.layout.addRow(QtWidgets.QLabel('Key'), self.key)
|
||||||
self.layout.addLayout(sub_layout)
|
|
||||||
|
|
||||||
sub_layout = QtWidgets.QHBoxLayout()
|
|
||||||
sub_layout.addWidget(QtWidgets.QLabel('Mods'))
|
|
||||||
self.mods = QtWidgets.QListWidget()
|
self.mods = QtWidgets.QListWidget()
|
||||||
for option in self.modifier_options:
|
for option in self.modifier_options:
|
||||||
self.mods.addItem(option)
|
self.mods.addItem(option)
|
||||||
self.mods.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
self.mods.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||||
sub_layout.addWidget(self.mods)
|
self.layout.addRow(QtWidgets.QLabel('Mods'), self.mods)
|
||||||
self.layout.addLayout(sub_layout)
|
|
||||||
|
|
||||||
sub_layout = QtWidgets.QHBoxLayout()
|
|
||||||
sub_layout.addWidget(QtWidgets.QLabel('Action'))
|
|
||||||
self.action = QtWidgets.QComboBox()
|
self.action = QtWidgets.QComboBox()
|
||||||
for option in self.action_options:
|
for option in self.action_options:
|
||||||
self.action.addItem(option)
|
self.action.addItem(option)
|
||||||
sub_layout.addWidget(self.action)
|
self.layout.addRow(QtWidgets.QLabel('Action'), self.action)
|
||||||
self.layout.addLayout(sub_layout)
|
|
||||||
|
|
||||||
sub_layout = QtWidgets.QHBoxLayout()
|
|
||||||
sub_layout.addWidget(QtWidgets.QLabel('Chars'))
|
|
||||||
self.chars = QtWidgets.QLineEdit()
|
self.chars = QtWidgets.QLineEdit()
|
||||||
sub_layout.addWidget(self.chars)
|
self.layout.addRow(QtWidgets.QLabel('Chars'), self.chars)
|
||||||
self.layout.addLayout(sub_layout)
|
|
||||||
|
|
||||||
buttons = QtWidgets.QDialogButtonBox()
|
buttons = QtWidgets.QDialogButtonBox()
|
||||||
buttons.addButton(buttons.Ok)
|
buttons.addButton(buttons.Ok)
|
||||||
@@ -258,6 +249,7 @@ class KeyBindingsWidget(QtWidgets.QWidget):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.layout = QtWidgets.QVBoxLayout()
|
self.layout = QtWidgets.QVBoxLayout()
|
||||||
|
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||||
self.update()
|
self.update()
|
||||||
btn_group = QtWidgets.QHBoxLayout()
|
btn_group = QtWidgets.QHBoxLayout()
|
||||||
btn_group.setAlignment(QtCore.Qt.AlignLeft)
|
btn_group.setAlignment(QtCore.Qt.AlignLeft)
|
||||||
@@ -338,19 +330,15 @@ class ConfigWidget(QtWidgets.QWidget):
|
|||||||
def prettify(self, s):
|
def prettify(self, s):
|
||||||
return ' '.join(x.capitalize() for x in s.split('_'))
|
return ' '.join(x.capitalize() for x in s.split('_'))
|
||||||
|
|
||||||
def render_item(self, layout, name, widget):
|
|
||||||
sub_layout = QtWidgets.QHBoxLayout()
|
|
||||||
sub_layout.addWidget(QtWidgets.QLabel(self.prettify(name)))
|
|
||||||
sub_layout.addWidget(widget)
|
|
||||||
layout.addLayout(sub_layout)
|
|
||||||
|
|
||||||
def render_section(self, widgets, sup=None, name=None):
|
def render_section(self, widgets, sup=None, name=None):
|
||||||
layout = QtWidgets.QVBoxLayout()
|
layout = QtWidgets.QFormLayout()
|
||||||
|
layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
|
||||||
for wname, widget in widgets.items():
|
for wname, widget in widgets.items():
|
||||||
if type(widget) is dict:
|
if type(widget) is dict:
|
||||||
self.render_section(widget, layout, wname)
|
self.render_section(widget, layout, wname)
|
||||||
else:
|
else:
|
||||||
self.render_item(layout, wname, widget)
|
layout.addRow(QtWidgets.QLabel(self.prettify(wname)), widget)
|
||||||
|
|
||||||
if name and sup is not None:
|
if name and sup is not None:
|
||||||
layout.setContentsMargins(10, 0, 0, 0)
|
layout.setContentsMargins(10, 0, 0, 0)
|
||||||
@@ -706,7 +694,6 @@ class Config(QtWidgets.QWidget):
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.add_tabs()
|
self.add_tabs()
|
||||||
self.add_buttons()
|
self.add_buttons()
|
||||||
self.setWindowTitle(NAME)
|
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
def add_tabs(self):
|
def add_tabs(self):
|
||||||
@@ -751,11 +738,27 @@ class Config(QtWidgets.QWidget):
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
app = QtWidgets.QApplication([NAME])
|
app = QtWidgets.QApplication([NAME])
|
||||||
app.setApplicationName(NAME)
|
app.setApplicationName(NAME)
|
||||||
with open(ALACRITTY_CONFIG) as f:
|
with open(ALACRITTY_CONFIG) as f:
|
||||||
config = yaml.safe_load(f.read())
|
config = yaml.safe_load(f.read())
|
||||||
conf = Config(config)
|
window = QtWidgets.QMainWindow()
|
||||||
conf.show()
|
window.setCentralWidget(Config(config))
|
||||||
|
window.setGeometry(
|
||||||
|
QtWidgets.QStyle.alignedRect(
|
||||||
|
QtCore.Qt.LeftToRight,
|
||||||
|
QtCore.Qt.AlignCenter,
|
||||||
|
QtCore.QSize(300, 400),
|
||||||
|
app.desktop().availableGeometry()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
window.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
||||||
|
window.setWindowTitle(NAME)
|
||||||
|
window.setUnifiedTitleAndToolBarOnMac(True)
|
||||||
|
window.show()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Reference in New Issue
Block a user