Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// Maybe consider PyLint once all Flake8 linting is fixed
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.mypyEnabled": false,
// Flake8 is already a pycodestyle wrapper
"python.linting.pycodestyleEnabled": false,
"python.linting.pylintArgs": [
Expand All @@ -44,9 +44,6 @@
"python.linting.flake8Args": [
"--max-line-length=120"
],
"python.linting.mypyArgs": [
"--max-line-length=120"
],
"python.formatting.autopep8Args": [
"--max-line-length=120"
],
Expand Down
28 changes: 14 additions & 14 deletions res/update_checker.ui
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
<widget class="QLabel" name="labelUpdateStatus">
<property name="geometry">
<rect>
<x>17</x>
<x>20</x>
<y>10</y>
<width>281</width>
<width>218</width>
<height>16</height>
</rect>
</property>
Expand All @@ -58,13 +58,13 @@
</sizepolicy>
</property>
<property name="text">
<string/>
<string>There is an update available for AutoSplit.</string>
</property>
</widget>
<widget class="QLabel" name="labelCurrentVersion">
<property name="geometry">
<rect>
<x>17</x>
<x>20</x>
<y>30</y>
<width>91</width>
<height>16</height>
Expand All @@ -77,7 +77,7 @@
<widget class="QLabel" name="labelLatestVersion">
<property name="geometry">
<rect>
<x>17</x>
<x>20</x>
<y>50</y>
<width>81</width>
<height>16</height>
Expand All @@ -90,14 +90,14 @@
<widget class="QLabel" name="labelGoToDownload">
<property name="geometry">
<rect>
<x>17</x>
<y>76</y>
<width>241</width>
<x>20</x>
<y>80</y>
<width>119</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string/>
<string>Open download page?</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonLeft">
Expand All @@ -113,7 +113,7 @@
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
<string>Open</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonRight">
Expand All @@ -126,7 +126,7 @@
</rect>
</property>
<property name="text">
<string/>
<string>Later</string>
</property>
</widget>
<widget class="QLabel" name="labelCurrentVersionNumber">
Expand Down Expand Up @@ -158,9 +158,9 @@
<widget class="QCheckBox" name="checkBoxDoNotAskMeAgain">
<property name="geometry">
<rect>
<x>17</x>
<y>100</y>
<width>141</width>
<x>20</x>
<y>102</y>
<width>131</width>
<height>20</height>
</rect>
</property>
Expand Down
2 changes: 1 addition & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ packaging
pyautogui
PySide6
flake8
mypy
requests
types-requests
#
# Comment this out if you don't want to build AutoSplit.exe:
PyInstaller
Expand Down
25 changes: 11 additions & 14 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import signal
import time

from menu_bar import about, VERSION, viewHelp, checkForUpdates
from menu_bar import about, VERSION, viewHelp, checkForUpdates, open_update_checker
from settings_file import auto_split_directory
from split_parser import BELOW_FLAG, DUMMY_FLAG, PAUSE_FLAG
import capture_windows
Expand All @@ -39,7 +39,8 @@

class AutoSplit(QtWidgets.QMainWindow, design.Ui_MainWindow):
from hotkeys import send_command
from settings_file import saveSettings, saveSettingsAs, loadSettings, haveSettingsChanged, getSaveSettingsValues
from settings_file import saveSettings, saveSettingsAs, loadSettings, haveSettingsChanged, getSaveSettingsValues, \
load_check_for_updates_on_open, set_check_for_updates_on_open
from screen_region import selectRegion, selectWindow, alignRegion, validateBeforeComparison
from hotkeys import afterSettingHotkey, beforeSettingHotkey, setSplitHotkey, setResetHotkey, setSkipSplitHotkey, \
setUndoSplitHotkey, setPauseHotkey
Expand All @@ -55,17 +56,15 @@ class AutoSplit(QtWidgets.QMainWindow, design.Ui_MainWindow):
undoSplitSignal = QtCore.pyqtSignal()
pauseSignal = QtCore.pyqtSignal()
afterSettingHotkeySignal = QtCore.pyqtSignal()
updateCheckerWidgetSignal = QtCore.pyqtSignal(str, bool)
# Use this signal when trying to show an error from outside the main thread
showErrorSignal = QtCore.pyqtSignal(FunctionType)

def __init__(self, parent=None):
super(AutoSplit, self).__init__(parent)
self.setupUi(self)

#These are only global settings values. They are not *pkl settings values.
self.getGlobalSettingsValues()
check_for_updates_on_open = self.setting_check_for_updates_on_open.value('check_for_updates_on_open', True, type=bool)
self.actionCheck_for_Updates_on_Open.setChecked(check_for_updates_on_open)
self.load_check_for_updates_on_open()

# Parse command line args
self.is_auto_controlled = ('--auto-controlled' in sys.argv)
Expand Down Expand Up @@ -161,6 +160,9 @@ def run(self):
self.alignregionButton.clicked.connect(self.alignRegion)
self.selectwindowButton.clicked.connect(self.selectWindow)
self.startImageReloadButton.clicked.connect(lambda: self.loadStartImage(True, True))
self.actionCheck_for_Updates_on_Open.changed.connect(lambda: self.set_check_for_updates_on_open(
self.actionCheck_for_Updates_on_Open.isChecked())
)

# update x, y, width, and height when changing the value of these spinbox's are changed
self.xSpinBox.valueChanged.connect(self.updateX)
Expand All @@ -172,6 +174,8 @@ def run(self):
self.updateCurrentSplitImage.connect(self.updateSplitImageGUI)
self.afterSettingHotkeySignal.connect(self.afterSettingHotkey)
self.startAutoSplitterSignal.connect(self.autoSplitter)
self.updateCheckerWidgetSignal.connect(lambda latest_version, check_on_open:
open_update_checker(self, latest_version, check_on_open))
self.resetSignal.connect(self.reset)
self.skipSplitSignal.connect(self.skipSplit)
self.undoSplitSignal.connect(self.undoSplit)
Expand Down Expand Up @@ -224,9 +228,6 @@ def run(self):

# FUNCTIONS

def getGlobalSettingsValues(self):
self.setting_check_for_updates_on_open = QtCore.QSettings('AutoSplit', 'Check For Updates On Open')

# TODO add checkbox for going back to image 1 when resetting.
def browse(self):
# User selects the file with the split images in it.
Expand Down Expand Up @@ -1153,10 +1154,6 @@ def updateSplitImage(self, custom_image_file: str = '', from_start_image: bool =

# exit safely when closing the window
def closeEvent(self, event: QtGui.QCloseEvent = None):
#save global setting values here
self.setting_check_for_updates_on_open.setValue('check_for_updates_on_open',
self.actionCheck_for_Updates_on_Open.isChecked())

def exit():
if event is not None:
event.accept()
Expand Down Expand Up @@ -1207,7 +1204,7 @@ def main():
main_window.show()
# Needs to be after main_window.show() to be shown over
if main_window.actionCheck_for_Updates_on_Open.isChecked():
checkForUpdates(main_window, check_for_updates_on_open=True)
checkForUpdates(main_window, check_on_open=True)

# Kickoff the event loop every so often so we can handle KeyboardInterrupt (^C)
timer = QtCore.QTimer()
Expand Down
87 changes: 51 additions & 36 deletions src/menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
from AutoSplit import AutoSplit

import os
from PyQt6 import QtWidgets

import requests
from packaging import version
import update_checker
from PyQt6 import QtWidgets
from PyQt6.QtCore import QThread
from requests.exceptions import RequestException
from simplejson.errors import JSONDecodeError
import requests

import about
import design
import error_messages
import settings_file
import resources_rc # noqa: F401
from about import Ui_aboutAutoSplitWidget
import update_checker

# AutoSplit Version number
VERSION = "1.6.1"


# About Window
class AboutWidget(QtWidgets.QWidget, Ui_aboutAutoSplitWidget):
class __AboutWidget(QtWidgets.QWidget, about.Ui_aboutAutoSplitWidget):
def __init__(self):
super().__init__()
self.setupUi(self)
Expand All @@ -27,56 +33,65 @@ def __init__(self):
self.versionLabel.setText(f"Version: {VERSION}")
self.show()

class UpdateCheckerWidget(QtWidgets.QWidget, update_checker.Ui_UpdateChecker):
def __init__(self, latest_version: str, autosplit: AutoSplit, check_for_updates_on_open: bool = False):

def about(self: AutoSplit):
self.AboutWidget = __AboutWidget()


class __UpdateCheckerWidget(QtWidgets.QWidget, update_checker.Ui_UpdateChecker):
def __init__(self, latest_version: str, design_window: design.Ui_MainWindow, check_on_open: bool = False):
super().__init__()
self.setupUi(self)
self.labelCurrentVersionNumber.setText(VERSION)
self.labelLatestVersionNumber.setText(latest_version)
self.pushButtonLeft.clicked.connect(self.openUpdate)
self.pushButtonRight.clicked.connect(self.closeWindow)
self.autosplit = autosplit
self.checkBoxDoNotAskMeAgain.stateChanged.connect(self.doNotAskMeAgainStateChanged)
self.design_window = design_window
if version.parse(latest_version) > version.parse(VERSION):
self.labelUpdateStatus.setText("There is an update available for AutoSplit.")
self.labelGoToDownload.setText("Open download page?")
self.pushButtonLeft.setVisible(True)
self.pushButtonLeft.setText("Open")
self.pushButtonRight.setText("Later")
if not check_for_updates_on_open:
self.checkBoxDoNotAskMeAgain.setVisible(False)
self.checkBoxDoNotAskMeAgain.setVisible(check_on_open)
self.show()
elif not check_for_updates_on_open:
elif not check_on_open:
self.labelUpdateStatus.setText("You are on the latest AutoSplit version.")
self.labelGoToDownload.setVisible(False)
self.pushButtonLeft.setVisible(False)
self.pushButtonRight.setText("OK")
self.checkBoxDoNotAskMeAgain.setVisible(False)
self.show()

def openUpdate(self):
if self.checkBoxDoNotAskMeAgain.isChecked():
self.autosplit.actionCheck_for_Updates_on_Open.setChecked(False)
os.system("start \"\" https://github.com/Toufool/Auto-Split/releases/latest")
self.close()

def closeWindow(self):
if self.checkBoxDoNotAskMeAgain.isChecked():
self.autosplit.actionCheck_for_Updates_on_Open.setChecked(False)
self.close()
def doNotAskMeAgainStateChanged(self):
settings_file.set_check_for_updates_on_open(
self.design_window,
self.checkBoxDoNotAskMeAgain.isChecked())


def open_update_checker(autosplit: AutoSplit, latest_version: str, check_on_open: bool):
autosplit.UpdateCheckerWidget = __UpdateCheckerWidget(latest_version, autosplit, check_on_open)


def viewHelp():
os.system("start \"\" https://github.com/Toufool/Auto-Split#tutorial")


def about(self: AutoSplit):
self.AboutWidget = AboutWidget()

def checkForUpdates(autosplit: AutoSplit, check_for_updates_on_open: bool = False):
try:
response = requests.get("https://api.github.com/repos/Toufool/Auto-Split/releases/latest")
latest_version = response.json()["name"].split("v")[1]
autosplit.UpdateCheckerWidget = UpdateCheckerWidget(latest_version, autosplit, check_for_updates_on_open)
except:
if not check_for_updates_on_open:
error_messages.checkForUpdatesError()
else:
pass
class __CheckForUpdatesThread(QThread):
def __init__(self, autosplit: AutoSplit, check_on_open: bool):
super().__init__()
self.autosplit = autosplit
self.check_on_open = check_on_open

def run(self):
try:
response = requests.get("https://api.github.com/repos/Toufool/Auto-Split/releases/latest")
latest_version = response.json()["name"].split("v")[1]
self.autosplit.updateCheckerWidgetSignal.emit(latest_version, self.check_on_open)
except (RequestException, KeyError, JSONDecodeError):
if not self.check_on_open:
self.autosplit.showErrorSignal(error_messages.checkForUpdatesError)


def checkForUpdates(autosplit: AutoSplit, check_on_open: bool = False):
autosplit.CheckForUpdatesThread = __CheckForUpdatesThread(autosplit, check_on_open)
autosplit.CheckForUpdatesThread.start()
4 changes: 2 additions & 2 deletions src/resources_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2297,9 +2297,9 @@
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00D\x00\x00\x00\x00\x00\x01\x00\x00\x0a\x91\
\x00\x00\x01}N\xa9\xa5H\
\x00\x00\x01}cp\x8e\xee\
\x00\x00\x00\x18\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01}N\xa9\xa5\x04\
\x00\x00\x01}cp\x8eO\
"

def qInitResources():
Expand Down
26 changes: 25 additions & 1 deletion src/settings_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from AutoSplit import AutoSplit

from win32 import win32gui
from PyQt6 import QtWidgets
from PyQt6 import QtCore, QtWidgets
import os
import sys
import keyboard
import pickle

from hotkeys import _hotkey_action
import design
import error_messages

# Get the directory of either AutoSplit.exe or AutoSplit.py
Expand Down Expand Up @@ -304,3 +305,26 @@ def loadSettings(self: AutoSplit, load_settings_on_open: bool = False, load_sett
self.last_successfully_loaded_settings_file_path = self.load_settings_file_path
self.checkLiveImage()
self.loadStartImage()


def load_check_for_updates_on_open(designWindow: design.Ui_MainWindow):
"""
Retrieve the 'Check For Updates On Open' QSettings and set the checkbox state
These are only global settings values. They are not *pkl settings values.
"""

value = QtCore \
.QSettings('AutoSplit', 'Check For Updates On Open') \
.value('check_for_updates_on_open', True, type=bool)
designWindow.actionCheck_for_Updates_on_Open.setChecked(value)


def set_check_for_updates_on_open(designWindow: design.Ui_MainWindow, value: bool):
"""
Sets the 'Check For Updates On Open' QSettings value and the checkbox state
"""

designWindow.actionCheck_for_Updates_on_Open.setChecked(value)
QtCore \
.QSettings('AutoSplit', 'Check For Updates On Open') \
.setValue('check_for_updates_on_open', value)
Loading