Tue, 16 Nov 2021 18:00:40 +0100
Some fine tuning of the icon bar 'More' button behavior.
eric7/EricWidgets/EricIconBar.py | file | annotate | diff | comparison | revisions |
--- a/eric7/EricWidgets/EricIconBar.py Mon Nov 15 19:59:30 2021 +0100 +++ b/eric7/EricWidgets/EricIconBar.py Tue Nov 16 18:00:40 2021 +0100 @@ -124,8 +124,7 @@ self.setColor(self.__color) - self.__createMoreLabel() - self.__layout.insertWidget(0, self.__moreLabel) + self.__createAndAddMoreLabel() self.__adjustIconLabels() @@ -140,7 +139,7 @@ self.setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) # remove the 'More' icon - itm = self.__layout.takeAt(self.__layout.count() - 2) + itm = self.__layout.takeAt(self.__layout.count() - 1) itm.widget().deleteLater() del itm @@ -155,8 +154,7 @@ self.__orientation = orientation - self.__createMoreLabel() - self.__layout.insertWidget(self.__layout.count() - 1, self.__moreLabel) + self.__createAndAddMoreLabel() self.__adjustIconLabels() @@ -178,7 +176,7 @@ @type str """ # remove the 'More' icon - itm = self.__layout.takeAt(self.__layout.count() - 2) + itm = self.__layout.takeAt(self.__layout.count() - 1) itm.widget().deleteLater() del itm @@ -210,8 +208,7 @@ widget.setPixmap( icon.pixmap(self.__barSize, self.__barSize)) - self.__createMoreLabel() - self.__layout.insertWidget(self.__layout.count() - 1, self.__moreLabel) + self.__createAndAddMoreLabel() self.__adjustIconLabels() @@ -276,7 +273,7 @@ return iconLabel - def __createMoreLabel(self): + def __createAndAddMoreLabel(self): """ Private method to create the label to be shown for too many icons. """ @@ -299,6 +296,8 @@ ) ) + self.__layout.addWidget(self.__moreLabel) + self.__moreLabel.clicked.connect(self.__moreLabelClicked) def addIcon(self, icon, label=""): @@ -470,7 +469,7 @@ EricIconBar.MenuStyleSheetTemplate.format( baseColor.name(), highlightColor.name())) - for index in range(self.__layout.count() - 2): + for index in range(self.count()): iconLabel = self.__layout.itemAt(index) if iconLabel: widget = iconLabel.widget() @@ -506,10 +505,7 @@ self.height() ) - 2 * self.__borderSize - iconsSize = ( - self.count() * self.__barSize + - (self.count() - 1) * self.__layout.spacing() - ) + iconsSize = self.count() * self.__barSize if size < iconsSize: self.__moreLabel.show() @@ -519,12 +515,12 @@ if iconLabel: if size < iconsSize: iconLabel.widget().hide() - iconsSize -= self.__barSize - self.__layout.spacing() + iconsSize -= self.__barSize else: iconLabel.widget().show() else: self.__moreLabel.hide() - for index in range(self.__layout.count() - 2): + for index in range(self.count()): iconLabel = self.__layout.itemAt(index) if iconLabel: iconLabel.widget().show()