[go: nahoru, domu]

Skip to content

Commit

Permalink
Add stretch before project is opened
Browse files Browse the repository at this point in the history
The stretch shall increase the plugin's size to its maximum, so that it does not expand when a project is opened. That way it retains the same size before and after the project is opened
  • Loading branch information
podestplatz committed Aug 9, 2019
1 parent b0bb316 commit bc4062c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bcfplugin/gui/plugin_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def mouseEntered(self, index):
itemRect = self.rectForIndex(index)
x = itemRect.width() - deleteButton.geometry().width()
vOffset = self.verticalOffset() # scroll offset
y = itemRect.y() - vOffset + (itemRect.height() -
deleteButton.geometry().height()) / 2
y = itemRect.y() - vOffset + deleteButton.geometry().height()
deleteButton.move(x, y)

deleteButton.show()
Expand Down Expand Up @@ -308,6 +307,7 @@ def __init__(self):

self.projectGroup = self.createProjectGroup()
self.mainLayout.addWidget(self.projectGroup)
self.mainLayout.addStretch()

self.topicGroup = self.createTopicGroup()
self.topicGroup.hide()
Expand All @@ -326,7 +326,9 @@ def __init__(self):
self.notificationLabel = createNotificationLabel()
self.mainLayout.addWidget(self.notificationLabel)

# handlers for an opened project
""" handlers for an opened project """
# remove stretch added at the beginning
self.projectOpened.connect(self.deleteStretch)
self.projectOpened.connect(self.topicCbModel.projectOpened)
self.projectOpened.connect(self.openedProjectUiHandler)
# reset models for every opened project
Expand Down Expand Up @@ -601,6 +603,17 @@ def showExitSaveDialog(self):
dialog.exec()


def deleteStretch(self):

""" Delete the first QSpacerItem found in mainLayout """

for idx in range(0, self.mainLayout.count()):
child = self.mainLayout.itemAt(idx)
if issubclass(type(child), QSpacerItem):
self.mainLayout.takeAt(idx)
break


if __name__ == "__main__":
app = QApplication(sys.argv)

Expand Down

0 comments on commit bc4062c

Please sign in to comment.