|
@@ -15,21 +15,14 @@ class ToolBar(QtWidgets.QToolBar):
|
|
def addAction(self, action):
|
|
def addAction(self, action):
|
|
if isinstance(action, QtWidgets.QWidgetAction):
|
|
if isinstance(action, QtWidgets.QWidgetAction):
|
|
return super(ToolBar, self).addAction(action)
|
|
return super(ToolBar, self).addAction(action)
|
|
- btn = ToolButton()
|
|
|
|
|
|
+ btn = QtWidgets.QToolButton()
|
|
btn.setDefaultAction(action)
|
|
btn.setDefaultAction(action)
|
|
btn.setToolButtonStyle(self.toolButtonStyle())
|
|
btn.setToolButtonStyle(self.toolButtonStyle())
|
|
self.addWidget(btn)
|
|
self.addWidget(btn)
|
|
|
|
|
|
-
|
|
|
|
-class ToolButton(QtWidgets.QToolButton):
|
|
|
|
-
|
|
|
|
- """ToolBar companion class which ensures all buttons have the same size."""
|
|
|
|
-
|
|
|
|
- minSize = (60, 60)
|
|
|
|
-
|
|
|
|
- def minimumSizeHint(self):
|
|
|
|
- ms = super(ToolButton, self).minimumSizeHint()
|
|
|
|
- w1, h1 = ms.width(), ms.height()
|
|
|
|
- w2, h2 = self.minSize
|
|
|
|
- self.minSize = max(w1, w2), max(h1, h2)
|
|
|
|
- return QtCore.QSize(*self.minSize)
|
|
|
|
|
|
+ # center align
|
|
|
|
+ for i in range(self.layout().count()):
|
|
|
|
+ if isinstance(
|
|
|
|
+ self.layout().itemAt(i).widget(), QtWidgets.QToolButton
|
|
|
|
+ ):
|
|
|
|
+ self.layout().itemAt(i).setAlignment(QtCore.Qt.AlignCenter)
|