Skip to content

Commit

Permalink
major improvements to UI and add pypresence back
Browse files Browse the repository at this point in the history
  • Loading branch information
NevermindNilas committed Jun 20, 2024
1 parent 1b911f2 commit 1b28f24
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 19 deletions.
48 changes: 46 additions & 2 deletions gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import os
import sys
import time
import random

from pypresence import Presence
from pypresence.exceptions import DiscordNotFound

from PyQt6.QtWidgets import (
QApplication,
Expand Down Expand Up @@ -40,15 +45,15 @@
)
logger = logging.getLogger(__name__)

TITLE = "The Anime Scripter - 1.8.6 (Alpha)"
TITLE = "The Anime Scripter - 1.8.7 (Alpha)"
W, H = 1280, 720
REPOSITORY = "https://github.com/NevermindNilas/TheAnimeScripter"

if getattr(sys, "frozen", False):
mainPath = os.path.dirname(sys.executable)
else:
mainPath = os.path.dirname(os.path.abspath(__file__))


class VideoProcessingApp(QMainWindow):
def __init__(self):
super().__init__()
Expand All @@ -58,6 +63,7 @@ def __init__(self):

GlobalBlur(self.winId(), Acrylic=True)

self.pyPresence()
self.setStyleSheet(Style())
self.centralWidget = QWidget()
self.stackedWidget = QStackedWidget()
Expand All @@ -71,6 +77,44 @@ def __init__(self):
loadSettings(self, self.settingsFile)
fadeIn(self, self.centralWidget, 500)


def pyPresence(self):
presetTitles = [
"Enhancing my videos",
"True 4K Enjoyer",
"Editing with Style",
"Crafting Cinematic Masterpieces",
"Bringing Pixels to Life",
"Cutting and Splicing Magic",
"From Raw to Refined",
"Harnessing the Power of AI",
"Journey Through Editing",
"Creating the Perfect Video",
"Transforming Media",
"Mastering the Art of Video",
"From Pixels to Perfection",
]
chosenTitle = random.choice(presetTitles)

# Get version from TITLE:
version = TITLE.split(" - ")[1].split(" (")[0]
try:
clientID = "1213461768785891388"
RPC = Presence(clientID)
RPC.connect()
RPC.update(
state=chosenTitle,
details=f"Version: {version}",
large_image="icon",
large_text="The Anime Scripter",
start=int(time.time()),
buttons=[{"label": "View on GitHub", "url": REPOSITORY}]
)
except ConnectionRefusedError:
print("Could not connect to Discord. Is Discord running?")
except DiscordNotFound:
print("Discord is not installed or not running.")

def createLayouts(self):
self.layout = QVBoxLayout()
self.centralWidget.setLayout(self.layout)
Expand Down
2 changes: 1 addition & 1 deletion requirements-linux.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--extra-index-url https://download.pytorch.org/whl/cu121
#pypresence
pypresence
pyqt6
opencv-python
timm
Expand Down
2 changes: 1 addition & 1 deletion requirements-windows.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--extra-index-url https://download.pytorch.org/whl/cu121
#pypresence
pypresence
pyqt6
opencv-python
timm
Expand Down
40 changes: 25 additions & 15 deletions src/uiLogic.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import subprocess
import os
import json
import threading
import logging
import time

from PyQt6.QtWidgets import QCheckBox, QGraphicsOpacityEffect
from PyQt6.QtCore import QPropertyAnimation, QEasingCurve
Expand All @@ -15,14 +13,14 @@ def Style() -> str:
"""
return """
* {
font-family: Tahoma;
font-size: 12px;
font-family: Segoe UI;
font-size: 14px;
color: #FFFFFF;
}
QMainWindow {
background-color: rgba(0, 0, 0, 0);
border-radius: 10px;
border-radius: 5px;
}
QWidget {
Expand All @@ -32,9 +30,8 @@ def Style() -> str:
QPushButton {
background-color: rgba(60, 60, 60, 0.5);
color: #FFFFFF;
border: none;
border-radius: 5px;
padding: 5px 10px;
min-height: 25px;
}
QPushButton:hover {
Expand All @@ -44,14 +41,29 @@ def Style() -> str:
QLineEdit {
background-color: rgba(60, 60, 60, 0.5);
color: #FFFFFF;
border: none;
border-radius: 5px;
padding: 5px;
min-height: 25px;
}
QComboBox {
min-width: 100px;
background-color: rgba(60, 60, 60, 0.5);
color: #FFFFFF;
border-radius: 5px;
min-height: 25px;
}
QComboBox QAbstractItemView {
border: 2px solid darkgray; /* Border for the dropdown list */
selection-background-color: #606060; /* Background color of hovered item */
color: #FFFFFF; /* Text color of items */
background-color: rgba(60, 60, 60, 0.8); /* Background of the dropdown */
border-radius: 5px; /* Rounded corners for the dropdown list */
}
QCheckBox {
color: #FFFFFF;
padding: 5px;
}
QTextEdit {
Expand All @@ -65,16 +77,14 @@ def Style() -> str:
QGroupBox {
border: 1px solid #4A4A4A;
border-radius: 5px;
margin-top: 1ex;
margin-top: 2ex;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top center;
padding: -7px 5px 0 5px;
}
"""

def runCommand(self, mainPath, settingsFile) -> None:
Expand Down Expand Up @@ -120,13 +130,13 @@ def runCommand(self, mainPath, settingsFile) -> None:
command = " ".join(command)
print(command)
def runCommandInTerminal(command):
os.system(f'start cmd /c "{command} & exit"')
os.system(f'start cmd /c {command}')

threading.Thread(target=runCommandInTerminal, args=(command,), daemon=True).start()


except Exception as e:
self.outputWindow.append(f"An error occurred while running the command, {e}")
print(f"An error occurred while running the command, {e}")
logging.error(f"An error occurred while running, {e}")


Expand Down

0 comments on commit 1b28f24

Please sign in to comment.