-
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #34 from Wolfmyths/future-update
V2.0 - Rewrite
- Loading branch information
Showing
28 changed files
with
2,145 additions
and
1,835 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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: Wolfmyths | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@echo on | ||
|
||
echo Setting Variables | ||
set disFolder="Genshin Stopwatch" | ||
set Txt="requirements.txt" | ||
set Spec="./src/python/main.spec" | ||
|
||
echo Installing Dependencies | ||
pip install -r %Txt% | ||
|
||
echo Running Pyinstaller | ||
pyinstaller --clean %Spec% --distpath ./%disFolder% | ||
|
||
echo Installation Finished! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 +1,5 @@ | ||
pyinstaller==5.13.0 | ||
PyQt5==5.15.9 | ||
PyQt5_sip==12.12.1 | ||
playsound==1.2.2 | ||
requests==2.31.0 | ||
PySide6==6.6.0 | ||
semantic-version==2.10.0 | ||
|
||
# External use | ||
pyinstaller==6.2.0 |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import json | ||
|
||
from PySide6.QtCore import QObject, QUrl, Signal | ||
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply | ||
|
||
from semantic_version import Version | ||
|
||
from constants import VERSION | ||
|
||
class checkUpdate(QObject): | ||
''' | ||
Instancing this object will run a series of | ||
functions to get the latest Myth Mod Manager version. | ||
`checkUpdate` will delete itself after it's finished. | ||
''' | ||
|
||
updateDetected = Signal(Version, str) | ||
upToDate = Signal() | ||
error = Signal() | ||
|
||
def __init__(self) -> None: | ||
super().__init__() | ||
|
||
link = 'https://api.github.com/repos/Wolfmyths/Genshin-Stopwatch/releases/latest' | ||
|
||
network = QNetworkAccessManager(self) | ||
request = QNetworkRequest(QUrl(link)) | ||
|
||
self.reply = network.get(request) | ||
self.reply.finished.connect(self.__reply_handler) | ||
|
||
def __reply_handler(self) -> None: | ||
reply: QNetworkReply = self.sender() | ||
|
||
if reply.error() == QNetworkReply.NetworkError.NoError: | ||
self.__checkVersion() | ||
else: | ||
self.error.emit() | ||
self.deleteLater() | ||
|
||
def __checkVersion(self) -> None: | ||
reply: QNetworkReply = self.sender() | ||
|
||
try: | ||
data: dict = json.loads(reply.readAll().data().decode()) | ||
except Exception as e: | ||
self.error.emit() | ||
return | ||
|
||
# Removing letters from version string | ||
version: str = data['tag_name'] | ||
|
||
for s in version: | ||
if not s.isdigit() and s != '.': | ||
version = version.replace(s, '') | ||
|
||
latestVersion = Version.coerce(version) | ||
|
||
if latestVersion > VERSION: | ||
self.updateDetected.emit(latestVersion, data['body']) | ||
else: | ||
self.upToDate.emit() | ||
|
||
self.deleteLater() |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import sys | ||
from datetime import timedelta | ||
from enum import StrEnum | ||
|
||
from semantic_version import Version | ||
|
||
class TimeFormats(StrEnum): | ||
Static_Timer = '%Y-%m-%d %I:%M:%S' | ||
Finished_Date = '%B %d @ %I:%M %p' | ||
Saved_Date = '%Y-%m-%d %H:%M:%S' | ||
|
||
|
||
# Used for debugging, flag to see if program is ran through the main.py script or an exe | ||
# This is used for when dealing with files that are packaged within the exe such as guide.html | ||
IS_SCRIPT: bool = not getattr(sys, 'frozen', False) | ||
|
||
# Loading paths, using `os.curdir` instead of `os.dirname(__file__)` because the file dir is in a temp dir | ||
ROOT = os.path.abspath(os.path.dirname(__file__)) if not IS_SCRIPT else os.path.join(os.path.abspath(os.getcwd()), 'src', 'python') | ||
CONFIG = os.path.abspath('config.ini') | ||
SAVEFILE = os.path.abspath('save.txt') | ||
ICON = os.path.join(ROOT, 'icon.ico') | ||
GUIDE = os.path.join(ROOT, 'guide.html') | ||
|
||
# Date Values | ||
ZERO = timedelta(days=0, hours=0, seconds=0) | ||
ONE = timedelta(seconds=1) | ||
|
||
# Program Info | ||
VERSION = Version(major=2, minor=0, patch=0) | ||
PROGRAM_NAME = 'Genshin Stopwatch' | ||
|
||
# Object Names | ||
MAIN_WINDOW = 'mw' | ||
SYS_TRAY = 'System Tray' | ||
TOOLBAR = 'tb' |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from configparser import ConfigParser | ||
from typing import Self | ||
from enum import StrEnum, auto | ||
import os | ||
|
||
from constants import SAVEFILE | ||
|
||
class StopwatchDataKeys(StrEnum): | ||
time_object = 'name' | ||
time_finished = 'time finished' | ||
time_original_duration = 'time original duration' | ||
border_color = 'border color' | ||
notes = auto() | ||
|
||
class dataParser(ConfigParser): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
# Create save file if it doesn't exist | ||
if not os.path.exists(SAVEFILE): | ||
with open(SAVEFILE, 'w+') as f: | ||
pass | ||
|
||
|
||
self.read(SAVEFILE) | ||
|
||
def __new__(cls) -> Self: | ||
|
||
if not hasattr(cls, 'instance'): | ||
|
||
cls.instance = super(dataParser, cls).__new__(cls) | ||
|
||
return cls.instance | ||
|
||
def save(self): | ||
with open(SAVEFILE, 'w') as f: | ||
self.write(f) |
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.