Skip to content

Commit

Permalink
slight fixes to component UIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tassaron committed May 28, 2017
2 parents fa89cd3 + 719e9a4 commit d9641d8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
32 changes: 31 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def __init__(self, window):
window.comboBox_resolution.setCurrentIndex(currentRes)
window.comboBox_resolution.currentIndexChanged.connect(self.updateResolution)

self.window.pushButton_listMoveUp.clicked.connect(self.moveComponentUp)
self.window.pushButton_listMoveDown.clicked.connect(self.moveComponentDown)

'''
window.lineEdit_visColor.setText('%s,%s,%s' % self.visColor)
window.pushButton_visColor.clicked.connect(lambda: self.pickColor('vis'))
Expand Down Expand Up @@ -292,7 +295,7 @@ def addComponent(self, moduleIndex):
self.pages.append(self.selectedComponents[-1].widget(self))
self.window.listWidget_componentList.setCurrentRow(index)
self.window.stackedWidget.addWidget(self.pages[-1])
self.window.stackedWidget.setCurrentWidget(self.pages[-1])
self.window.stackedWidget.setCurrentIndex(index)
self.selectedComponents[-1].update()

def removeComponent(self):
Expand All @@ -309,6 +312,33 @@ def changeComponentWidget(self):
index = self.window.listWidget_componentList.row(selected[0])
self.window.stackedWidget.setCurrentIndex(index)

def moveComponentUp(self):
row = self.window.listWidget_componentList.currentRow()
if row > 0:
item = self.window.listWidget_componentList.takeItem(row)
self.window.listWidget_componentList.insertItem(row - 1, item)
page = self.pages[row]
self.pages.pop(row)
self.pages.insert(row - 1, page)
widget = self.window.stackedWidget.removeWidget(page)
self.window.stackedWidget.insertWidget(row - 1, page)
self.window.listWidget_componentList.setCurrentRow(row - 1)
self.window.stackedWidget.setCurrentIndex(row -1)

def moveComponentDown(self):
row = self.window.listWidget_componentList.currentRow()
if row < len(self.pages):
item = self.window.listWidget_componentList.takeItem(row)
self.window.listWidget_componentList.insertItem(row + 1, item)
page = self.pages[row]
self.pages.pop(row)
self.pages.insert(row + 1, page)
widget = self.window.stackedWidget.removeWidget(page)
self.window.stackedWidget.insertWidget(row + 1, page)
self.window.listWidget_componentList.setCurrentRow(row + 1)
self.window.stackedWidget.setCurrentIndex(row + 1)


def LoadDefaultSettings(self):
self.resolutions = [
'1920x1080',
Expand Down
27 changes: 24 additions & 3 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_saveAs">
<property name="text">
<string>Save As</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand All @@ -142,7 +149,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
<height>20</height>
</size>
</property>
</spacer>
Expand All @@ -168,14 +175,28 @@
<item>
<widget class="QPushButton" name="pushButton_addComponent">
<property name="text">
<string>Add Component</string>
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_removeComponent">
<property name="text">
<string>Remove Component</string>
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_listMoveDown">
<property name="text">
<string>Down</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_listMoveUp">
<property name="text">
<string>Up</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit d9641d8

Please sign in to comment.