Skip to content

Commit

Permalink
added results filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiaskummer@googlemail.com authored and tobiaskummer@googlemail.com committed Mar 2, 2016
1 parent 1082e18 commit 4a25c26
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 20 deletions.
116 changes: 96 additions & 20 deletions BlenderUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(self, parent=None):
dir_ = self.line_path.text()
self.btn_cancel.hide()
self.frm_progress.hide()
self.btngrp_filter.hide()
self.btn_Check.setFocus() # set focus to Check Now button
self.lbl_available.hide() # hide the message at the top
self.progressBar.setValue(0) # reset progress bar
Expand All @@ -110,7 +111,9 @@ def about(self):
<a href="https://builder.blender.org/download/"><span style=" text-decoration: underline; color:#2980b9;">\
https://builder.blender.org/download/</span></a></p><p><br/>Developed by Tobias Kummer for Overmind Studios</p><p>\
Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0"><span style=" text-decoration:\
underline; color:#2980b9;">Apache 2.0 license</span></a></p></body></html>'
underline; color:#2980b9;">Apache 2.0 license</span></a></p><p>Project home: \
<a href="https://github.com/tobkum/BlenderUpdater"><span style=" text-decoration:\
underline; color:#2980b9;">https://github.com/tobkum/BlenderUpdater</a></p></body></html>'
QtGui.QMessageBox.about(self, 'About', aboutText)

def check_dir(self):
Expand Down Expand Up @@ -163,33 +166,105 @@ def check(self):
del finallist[0] # remove first entry which is the header of the table

"""generate buttons"""
i = 0
for index, text in enumerate(finallist):
btn[index] = QtGui.QPushButton(self)
if "OSX" in text[1]: # set icon according to OS
btn[index].setIcon(appleicon)
elif "linux" in text[1]:
btn[index].setIcon(linuxicon)
elif "win" in text[1]:
btn[index].setIcon(windowsicon)

version = str(text[1])
buttontext = str(text[0]) + " | " + str(text[1]) + " | " + str(text[3])
btn[index].setIconSize(QtCore.QSize(24, 24))
btn[index].setText(buttontext)
btn[index].setFixedWidth(686)
btn[index].move(6, 45 + i)
i += 30
btn[index].clicked.connect(lambda throwaway=0, version=version: self.download(version))
btn[index].show()
def filterall():
global btn
for i in btn:
btn[i].hide()
i = 0
btn = {}
for index, text in enumerate(finallist):
btn[index] = QtGui.QPushButton(self)
if "OSX" in text[1]: # set icon according to OS
btn[index].setIcon(appleicon)
elif "linux" in text[1]:
btn[index].setIcon(linuxicon)
elif "win" in text[1]:
btn[index].setIcon(windowsicon)

version = str(text[1])
buttontext = str(text[0]) + " | " + str(text[1]) + " | " + str(text[3])
btn[index].setIconSize(QtCore.QSize(24, 24))
btn[index].setText(buttontext)
btn[index].setFixedWidth(686)
btn[index].move(6, 45 + i)
i += 30
btn[index].clicked.connect(lambda throwaway=0, version=version: self.download(version))
btn[index].show()

def filterosx():
global btn
for i in btn:
btn[i].hide()
btn = {}
i = 0
for index, text in enumerate(finallist):
btn[index] = QtGui.QPushButton(self)
if "OSX" in text[1]:
btn[index].setIcon(appleicon)
version = str(text[1])
buttontext = str(text[0]) + " | " + str(text[1]) + " | " + str(text[3])
btn[index].setIconSize(QtCore.QSize(24, 24))
btn[index].setText(buttontext)
btn[index].setFixedWidth(686)
btn[index].move(6, 45 + i)
i += 30
btn[index].clicked.connect(lambda throwaway=0, version=version: self.download(version))
btn[index].show()

def filterlinux():
global btn
for i in btn:
btn[i].hide()
btn = {}
i = 0
for index, text in enumerate(finallist):
btn[index] = QtGui.QPushButton(self)
if "linux" in text[1]:
btn[index].setIcon(linuxicon)
version = str(text[1])
buttontext = str(text[0]) + " | " + str(text[1]) + " | " + str(text[3])
btn[index].setIconSize(QtCore.QSize(24, 24))
btn[index].setText(buttontext)
btn[index].setFixedWidth(686)
btn[index].move(6, 45 + i)
i += 30
btn[index].clicked.connect(lambda throwaway=0, version=version: self.download(version))
btn[index].show()

def filterwindows():
global btn
for i in btn:
btn[i].hide()
btn = {}
i = 0
for index, text in enumerate(finallist):
btn[index] = QtGui.QPushButton(self)
if "win" in text[1]:
btn[index].setIcon(windowsicon)
version = str(text[1])
buttontext = str(text[0]) + " | " + str(text[1]) + " | " + str(text[3])
btn[index].setIconSize(QtCore.QSize(24, 24))
btn[index].setText(buttontext)
btn[index].setFixedWidth(686)
btn[index].move(6, 45 + i)
i += 30
btn[index].clicked.connect(lambda throwaway=0, version=version: self.download(version))
btn[index].show()

self.lbl_available.show()
self.btngrp_filter.show()
self.btn_osx.clicked.connect(filterosx)
self.btn_linux.clicked.connect(filterlinux)
self.btn_windows.clicked.connect(filterwindows)
self.btn_allos.clicked.connect(filterall)
lastcheck = datetime.now().strftime('%a %b %d %H:%M:%S %Y')
self.statusbar.showMessage ("Ready - Last check: " + str(lastcheck))
config.read('config.ini')
config.set('main', 'lastcheck', str(lastcheck))
with open('config.ini', 'w') as f:
config.write(f)
f.close()
filterall()

def download(self, version):
global dir_
Expand All @@ -214,6 +289,7 @@ def download(self, version):
btn[i].hide()
self.lbl_available.hide()
self.progressBar.show()
self.btngrp_filter.hide()
self.lbl_task.setText('Downloading')
self.lbl_task.show()
self.frm_progress.show()
Expand Down
41 changes: 41 additions & 0 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,42 @@ def setupUi(self, MainWindow):
self.lbl_cleanup = QtGui.QLabel(self.frm_progress)
self.lbl_cleanup.setGeometry(QtCore.QRect(70, 140, 81, 24))
self.lbl_cleanup.setObjectName(_fromUtf8("lbl_cleanup"))
self.btngrp_filter = QtGui.QGroupBox(self.centralwidget)
self.btngrp_filter.setGeometry(QtCore.QRect(200, 340, 307, 61))
self.btngrp_filter.setObjectName(_fromUtf8("btngrp_filter"))
self.btn_osx = QtGui.QPushButton(self.btngrp_filter)
self.btn_osx.setGeometry(QtCore.QRect(227, 30, 75, 23))
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/Apple-icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btn_osx.setIcon(icon6)
self.btn_osx.setCheckable(True)
self.btn_osx.setAutoExclusive(True)
self.btn_osx.setObjectName(_fromUtf8("btn_osx"))
self.btn_windows = QtGui.QPushButton(self.btngrp_filter)
self.btn_windows.setGeometry(QtCore.QRect(79, 30, 75, 23))
self.btn_windows.setAutoFillBackground(False)
icon7 = QtGui.QIcon()
icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/Windows-icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btn_windows.setIcon(icon7)
self.btn_windows.setCheckable(True)
self.btn_windows.setAutoExclusive(True)
self.btn_windows.setFlat(False)
self.btn_windows.setObjectName(_fromUtf8("btn_windows"))
self.btn_allos = QtGui.QPushButton(self.btngrp_filter)
self.btn_allos.setGeometry(QtCore.QRect(5, 30, 75, 23))
self.btn_allos.setCheckable(True)
self.btn_allos.setChecked(True)
self.btn_allos.setAutoExclusive(True)
self.btn_allos.setObjectName(_fromUtf8("btn_allos"))
self.btn_linux = QtGui.QPushButton(self.btngrp_filter)
self.btn_linux.setGeometry(QtCore.QRect(153, 30, 75, 23))
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/Linux-icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btn_linux.setIcon(icon8)
self.btn_linux.setCheckable(True)
self.btn_linux.setAutoExclusive(True)
self.btn_linux.setObjectName(_fromUtf8("btn_linux"))
self.btngrp_filter.raise_()
self.frm_start.raise_()
self.btn_Quit.raise_()
self.btn_Check.raise_()
Expand Down Expand Up @@ -173,5 +209,10 @@ def retranslateUi(self, MainWindow):
self.lbl_extraction.setText(_translate("MainWindow", "Extraction", None))
self.lbl_copying.setText(_translate("MainWindow", "Copying files", None))
self.lbl_cleanup.setText(_translate("MainWindow", "Cleaning up", None))
self.btngrp_filter.setTitle(_translate("MainWindow", "Filter results", None))
self.btn_osx.setText(_translate("MainWindow", "OSX", None))
self.btn_windows.setText(_translate("MainWindow", "Windows", None))
self.btn_allos.setText(_translate("MainWindow", "all OS", None))
self.btn_linux.setText(_translate("MainWindow", "Linux", None))

import res_rc
111 changes: 111 additions & 0 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,117 @@
</property>
</widget>
</widget>
<widget class="QGroupBox" name="btngrp_filter">
<property name="geometry">
<rect>
<x>200</x>
<y>340</y>
<width>307</width>
<height>61</height>
</rect>
</property>
<property name="title">
<string>Filter results</string>
</property>
<widget class="QPushButton" name="btn_osx">
<property name="geometry">
<rect>
<x>227</x>
<y>30</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>OSX</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/newPrefix/images/Apple-icon.png</normaloff>:/newPrefix/images/Apple-icon.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="btn_windows">
<property name="geometry">
<rect>
<x>79</x>
<y>30</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Windows</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/newPrefix/images/Windows-icon.png</normaloff>:/newPrefix/images/Windows-icon.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="btn_allos">
<property name="geometry">
<rect>
<x>5</x>
<y>30</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>all OS</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="btn_linux">
<property name="geometry">
<rect>
<x>153</x>
<y>30</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Linux</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/newPrefix/images/Linux-icon.png</normaloff>:/newPrefix/images/Linux-icon.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</widget>
<zorder>btngrp_filter</zorder>
<zorder>frm_start</zorder>
<zorder>btn_Quit</zorder>
<zorder>btn_Check</zorder>
Expand Down

0 comments on commit 4a25c26

Please sign in to comment.