-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from UdK-VPT/clickable_progress_steps
Clickable progress steps
- Loading branch information
Showing
17 changed files
with
2,849 additions
and
3,261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,64 @@ | ||
from PyQt4 import QtCore, QtGui | ||
from PyQt4.QtCore import SIGNAL | ||
from ui_main_process_dock import Ui_MainProcess_dock, _fromUtf8 | ||
from ui_process_button import QProcessButton | ||
from collections import OrderedDict | ||
|
||
class MainProcess_dock(QtGui.QDockWidget, Ui_MainProcess_dock): | ||
|
||
def __init__(self): | ||
QtGui.QDockWidget.__init__(self) | ||
|
||
self.setupUi(self) | ||
self.selection_to_page = {} | ||
self.check_mark = QtGui.QPixmap(_fromUtf8(":/Icons/Icons/checkmark.png")) | ||
self.open_mark = QtGui.QPixmap(_fromUtf8(":/Icons/Icons/openmark.png")) | ||
self.selection_to_page = OrderedDict([]) | ||
self._check_mark = QtGui.QPixmap(_fromUtf8(":/Icons/Icons/checkmark.png")) | ||
self._open_mark = QtGui.QPixmap(_fromUtf8(":/Icons/Icons/openmark.png")) | ||
|
||
page_triples = [] | ||
|
||
page_list = [] | ||
# put each page-widget in a list of triples, as they are not sorted properly | ||
for page in self.process_page.children(): | ||
if type(page) is QtGui.QWidget: | ||
self.selection_to_page[page.accessibleName()] = page | ||
page_list.append(page.accessibleName()) | ||
if isinstance(page, QtGui.QWidget): | ||
index = self.process_page.indexOf(page) | ||
page_triples.append((index, page.accessibleName(), page)) | ||
|
||
page_list.reverse() | ||
page_triples_sorted = sorted(page_triples, key=lambda tup: tup[0]) | ||
self.selection_to_page = OrderedDict(map(lambda trip: trip[1:], page_triples_sorted)) | ||
|
||
for i in range(0, len(page_list)): | ||
self.active_page_dropdown.addItem(page_list[i]) | ||
self.active_page_dropdown.setItemData(i, self.open_mark, QtCore.Qt.DecorationRole) | ||
|
||
self.active_page_dropdown.currentIndexChanged.connect(lambda: self.go_to_page(self.active_page_dropdown.currentText())) | ||
|
||
def set_checkbox_on_page(self, checkbox_name, page_name, check_yes_no): | ||
# add page-names to according position in dropdown-menu, so the user can navigate through the process | ||
for page_number, page in enumerate(self.selection_to_page.keys()): | ||
self.active_page_dropdown.addItem(page) | ||
self.active_page_dropdown.setItemData(page_number, self._open_mark, QtCore.Qt.DecorationRole) | ||
|
||
if not checkbox_name or checkbox_name.isspace(): | ||
print "A checkbox with the given name " + checkbox_name + " was not found." | ||
self.active_page_dropdown.currentIndexChanged.connect(lambda: self.go_to_page(self.active_page_dropdown.currentText())) | ||
|
||
elif not page_name or page_name.isspace(): | ||
print "A page with the given name " + page_name + " was not found." | ||
# set the currently displayed widget to the first process-page, otherwise the correct display is not guaranteed | ||
self.process_page.setCurrentWidget(self.selection_to_page.values()[0]) | ||
|
||
elif type(check_yes_no) is not bool: | ||
print "A boolean check_yes_no has to be passed as a third parameter." | ||
def go_to_page(self, selection_name): | ||
[self.process_page.setCurrentWidget(page) | ||
for page in self.selection_to_page.values() if selection_name == page.accessibleName()] | ||
|
||
else: | ||
def set_checkbox_on_page(self, checkbox_name, page_name, check_yes_no): | ||
if isinstance(check_yes_no, bool): | ||
page = self.findChild(QtGui.QWidget, page_name) | ||
checkbox = page.findChild(QtGui.QPushButton, checkbox_name) | ||
|
||
if checkbox: | ||
checkbox.setChecked(check_yes_no) | ||
|
||
def is_checkbox_on_page_checked(self, checkbox_name, page_name): | ||
page = self.process_page.findChild(QtGui.QWidget, page_name) | ||
return page.findChild(QtGui.QPushButton, checkbox_name).isChecked() | ||
|
||
if not checkbox_name or checkbox_name.isspace(): | ||
print "A checkbox with the given name " + checkbox_name + " was not found." | ||
|
||
elif not page_name or page_name.isspace(): | ||
print "A page with the given name " + page_name + " was not found." | ||
|
||
else: | ||
page = self.process_page.findChild(QtGui.QWidget, page_name) | ||
return page.findChild(QtGui.QPushButton, checkbox_name).isChecked() | ||
|
||
def set_page_done(self, value): | ||
|
||
if type(value) is not bool: | ||
print "A boolean value has to be passed as a third parameter." | ||
|
||
else: | ||
def set_current_page_done(self, value): | ||
if isinstance(value, bool): | ||
page_name = self.active_page_dropdown.currentText() | ||
page = self.selection_to_page[page_name] | ||
|
||
if (page_name) == page.accessibleName(): | ||
index = self.active_page_dropdown.currentIndex() | ||
self.active_page_dropdown.setItemData(index, self.check_mark, QtCore.Qt.DecorationRole) | ||
self.active_page_dropdown.setItemData(index, self._check_mark, QtCore.Qt.DecorationRole) | ||
self.active_page_dropdown.setCurrentIndex((index+1) % len(self.selection_to_page)) | ||
|
||
def go_to_page(self, selection_name): | ||
|
||
if selection_name is not None and not selection_name.isspace(): | ||
|
||
for selection in self.selection_to_page: | ||
page = self.selection_to_page[selection] | ||
|
||
if (selection_name) == page.accessibleName(): | ||
self.process_page.setCurrentWidget(page) | ||
break | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.