Skip to content

Commit 12e7097

Browse files
committed
enh: make buttons larger in filter view
1 parent a119072 commit 12e7097

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

dcoraid/gui/dbview/filter_base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def __init__(self, *args, **kwargs):
5555
QtCore.Qt.DropAction.IgnoreAction) # no drop by default
5656
self.tableWidget.horizontalHeader().setSectionResizeMode(
5757
0, QtWidgets.QHeaderView.ResizeMode.Stretch)
58+
self.tableWidget.horizontalHeader().setSectionResizeMode(
59+
1, QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
60+
5861

5962
def get_entry_actions(self, row, entry):
6063
"""This is defined in the subclasses (Circle, Collection, etc)"""
@@ -98,8 +101,10 @@ def set_entry(self, row, entry):
98101
# tool buttons (2nd column)
99102
widact = QtWidgets.QWidget(self)
100103
horz_layout = QtWidgets.QHBoxLayout(widact)
101-
horz_layout.setContentsMargins(2, 0, 2, 0)
104+
horz_layout.setContentsMargins(0, 0, 5, 0)
105+
horz_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
102106

107+
col_width = 0
103108
for action in self.get_entry_actions(row, entry):
104109
if action["name"] in self.active_actions:
105110
tbact = QtWidgets.QToolButton(widact)
@@ -108,8 +113,13 @@ def set_entry(self, row, entry):
108113
tbact.setToolTip(action["tooltip"])
109114
tbact.clicked.connect(action["function"])
110115
horz_layout.addWidget(tbact)
111-
horz_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
116+
row_height = tbact.geometry().height()
117+
col_width += row_height
118+
tbact.setFixedWidth(row_height)
119+
120+
self.tableWidget.setColumnWidth(1, col_width)
112121
self.tableWidget.setCellWidget(row, 1, widact)
122+
113123
return widact
114124

115125
def set_entry_label(self, row, entry):

dcoraid/gui/dbview/filter_base.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
</property>
3232
<item>
3333
<layout class="QHBoxLayout" name="horizontalLayout_8" stretch="0,0,99,1,0">
34+
<property name="rightMargin">
35+
<number>0</number>
36+
</property>
3437
<item>
3538
<widget class="QLabel" name="label">
3639
<property name="text">

0 commit comments

Comments
 (0)