|
11 | 11 | import os
|
12 | 12 | import argparse
|
13 | 13 |
|
| 14 | +import urllib.request |
| 15 | +import webbrowser |
| 16 | + |
14 | 17 | import regutils as reg
|
15 | 18 |
|
16 | 19 | # import time
|
|
24 | 27 |
|
25 | 28 | import output
|
26 | 29 |
|
27 |
| - |
28 | 30 | import ctypes
|
29 |
| -myappid = 'VodBox.pyWinContext.1.0' # arbitrary string |
| 31 | + |
| 32 | +versionNums = [0, 1, 0] # major, minor, patch |
| 33 | +versionNumber = ".".join(str(x) for x in versionNums) |
| 34 | + |
| 35 | +myappid = 'VodBox.pyWinContext.' + versionNumber # arbitrary string |
30 | 36 | ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
31 | 37 |
|
32 | 38 | parser = argparse.ArgumentParser(
|
@@ -100,6 +106,21 @@ def initUI(self):
|
100 | 106 | self.actionSave.setShortcut(QtGui.QKeySequence("Ctrl+S"))
|
101 | 107 | self.actionImport.triggered.connect(self.action_import)
|
102 | 108 | self.actionExport.triggered.connect(self.action_export)
|
| 109 | + self.actionSource_Code.triggered.connect( |
| 110 | + lambda self: webbrowser.open( |
| 111 | + "https://github.com/VodBox/pyWinContext") |
| 112 | + ) |
| 113 | + self.actionAbout.triggered.connect( |
| 114 | + lambda: QMessageBox.about( |
| 115 | + self, "About pyWinContext", |
| 116 | + "pyWinContext v" + versionNumber + "\n" |
| 117 | + + "Written and Maintained by VodBox (Dillon Pentz)\n\n" |
| 118 | + + "Homepage: https://github.com/VodBox/pyWinContext\n" |
| 119 | + + "Source: https://github.com/VodBox/pyWinContext\n" |
| 120 | + + "Downloads: https://github.com/VodBox/pyWinContext/releases" |
| 121 | + ) |
| 122 | + ) |
| 123 | + self.actionCheck_For_Updates.triggered.connect(self.check_updates) |
103 | 124 | self.setWindowTitle('pyWinContext')
|
104 | 125 | fts = reg.get_file_types()
|
105 | 126 | types = {}
|
@@ -262,6 +283,58 @@ def action_import(self):
|
262 | 283 | def action_export(self):
|
263 | 284 | pass
|
264 | 285 |
|
| 286 | + def check_updates(self): |
| 287 | + release = self.find_later_release() |
| 288 | + if release is False: |
| 289 | + QMessageBox.information( |
| 290 | + self, "Check for Updates", |
| 291 | + "There are no new updates at this time." |
| 292 | + ) |
| 293 | + else: |
| 294 | + box = QMessageBox(self) |
| 295 | + box.setText( |
| 296 | + "An update is available! It is available at\n" |
| 297 | + + "https://github.com/VodBox/pyWinContext/releases/tag/" |
| 298 | + + release) |
| 299 | + box.setWindowTitle("Check for Updates") |
| 300 | + box.setIcon(QMessageBox.Information) |
| 301 | + download = box.addButton("Download", QMessageBox.AcceptRole) |
| 302 | + box.addButton("Okay", QMessageBox.AcceptRole) |
| 303 | + box.exec_() |
| 304 | + clicked = box.clickedButton() |
| 305 | + if clicked is download: |
| 306 | + webbrowser.open( |
| 307 | + "https://github.com/VodBox/pyWinContext/releases/tag/" |
| 308 | + + release) |
| 309 | + |
| 310 | + def find_later_release(self): |
| 311 | + resp = urllib.request.urlopen( |
| 312 | + "https://api.github.com/repos/VodBox/pyWinContext/releases/latest") |
| 313 | + verInfo = {} |
| 314 | + try: |
| 315 | + verInfo = json.loads(resp.read()) |
| 316 | + except json.JSONDecodeError: |
| 317 | + return False |
| 318 | + majorNum = int( |
| 319 | + re.search(r"v(\d+)\.(\d+)\.(\d+)", verInfo["tag_name"]).group(1) |
| 320 | + ) |
| 321 | + minorNum = int( |
| 322 | + re.search(r"v(\d+)\.(\d+)\.(\d+)", verInfo["tag_name"]).group(2) |
| 323 | + ) |
| 324 | + patchNum = int( |
| 325 | + re.search(r"v(\d+)\.(\d+)\.(\d+)", verInfo["tag_name"]).group(3) |
| 326 | + ) |
| 327 | + if ( |
| 328 | + majorNum < versionNums[0] |
| 329 | + or (majorNum == versionNums[0] and minorNum < versionNums[1]) |
| 330 | + or ( |
| 331 | + majorNum == versionNums[0] and minorNum == versionNums[1] |
| 332 | + and patchNum <= versionNums[2] |
| 333 | + ) |
| 334 | + ): |
| 335 | + return False |
| 336 | + return verInfo["tag_name"] |
| 337 | + |
265 | 338 | def search_change(self, text):
|
266 | 339 | for i in range(0, self.treeWidget_2.topLevelItemCount()):
|
267 | 340 | for x in range(0, self.treeWidget_2.topLevelItem(i).childCount()):
|
|
0 commit comments