From 719e9a4ddf306b06bce7a5dcf0f3028731db0664 Mon Sep 17 00:00:00 2001 From: DH4 Date: Sun, 28 May 2017 15:05:08 -0500 Subject: [PATCH] Implemented change list order --- main.py | 31 +++++++++++++++++++++++++++++++ mainwindow.ui | 27 ++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index d165fc5..8a9ba8c 100644 --- a/main.py +++ b/main.py @@ -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')) @@ -292,6 +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.setCurrentIndex(index) self.selectedComponents[-1].update() def removeComponent(self): @@ -308,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', diff --git a/mainwindow.ui b/mainwindow.ui index ce8233e..b15cc8e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -129,6 +129,13 @@ + + + + Save As + + + @@ -142,7 +149,7 @@ 20 - 10 + 20 @@ -168,14 +175,28 @@ - Add Component + Add - Remove Component + Remove + + + + + + + Down + + + + + + + Up