Skip to content

Commit

Permalink
Huge v6 Update! Refer to Releases for changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
theJayTea authored Dec 23, 2024
1 parent ea9eb6a commit 1af9eaf
Show file tree
Hide file tree
Showing 6 changed files with 933 additions and 252 deletions.
11 changes: 7 additions & 4 deletions Windows_and_Linux/ui/AboutWindow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import webbrowser

from PySide6 import QtCore, QtWidgets, QtGui
from PySide6.QtCore import Qt
from PySide6 import QtCore, QtGui, QtWidgets

from ui.UIUtils import UIUtils, colorMode

Expand All @@ -19,7 +18,7 @@ def init_ui(self):
Initialize the user interface for the about window.
"""
self.setWindowTitle(' ') # Hack to hide the title bar text. TODO: Find a better solution later.
self.setGeometry(300, 300, 500, 528) # Set the window size
self.setGeometry(300, 300, 650, 720) # Set the window size

# Center the window on the screen. I'm not aware of any methods in UIUtils to do this, so I'll be doing it manually.
screen = QtWidgets.QApplication.primaryScreen().geometry()
Expand Down Expand Up @@ -66,9 +65,13 @@ def init_ui(self):
Helped improve the reliability of text selection.</b><br>
<b>5. <a href="https://github.com/raghavdhingra24">raghavdhingra24</a>:</b><br>
Made the rounded corners anti-aliased & prettier.</b><br>
<b>6. <a href="https://github.com/ErrorCatDev">ErrorCatDev</a>:</b><br>
Significantly improved the About window, making it scrollable and cleaning things up. Also improved our .gitignore & requirements.txt.</b><br>
<b>7. <a href="https://github.com/Vadim-Karpenko">Vadim Karpenko</a>:</b><br>
Helped add the start-on-boot setting!</b><br>
</p>
<p style='text-align: center;'>
<b>Version:</b> 5.0 (Codename: Impressively Improved)
<b>Version:</b> 6.0 (Codename: Radically Refined)
</p>
<p />
"""
Expand Down
108 changes: 108 additions & 0 deletions Windows_and_Linux/ui/AutostartManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import logging
import sys
import winreg


class AutostartManager:
"""
Manages the autostart functionality for Writing Tools.
Handles setting/removing autostart registry entries on Windows.
"""

@staticmethod
def is_compiled():
"""
Check if we're running from a compiled exe or source.
"""
return hasattr(sys, 'frozen') and hasattr(sys, '_MEIPASS')

@staticmethod
def get_startup_path():
"""
Get the path that should be used for autostart.
Returns None if running from source or on non-Windows.
"""
if not sys.platform.startswith('win32'):
return None

if not AutostartManager.is_compiled():
return None

return sys.executable

@staticmethod
def set_autostart(enable: bool) -> bool:
"""
Enable or disable autostart for Writing Tools.
Args:
enable: True to enable autostart, False to disable
Returns:
bool: True if operation succeeded, False if failed or unsupported
"""
try:
startup_path = AutostartManager.get_startup_path()
if not startup_path:
return False

key_path = r"Software\Microsoft\Windows\CurrentVersion\Run"

try:
if enable:
# Open/create key and set value
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0,
winreg.KEY_WRITE)
winreg.SetValueEx(key, "WritingTools", 0, winreg.REG_SZ,
startup_path)
else:
# Open key and delete value if it exists
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0,
winreg.KEY_WRITE)
try:
winreg.DeleteValue(key, "WritingTools")
except WindowsError:
# Value doesn't exist, that's fine
pass

winreg.CloseKey(key)
return True

except WindowsError as e:
logging.error(f"Failed to modify autostart registry: {e}")
return False

except Exception as e:
logging.error(f"Error managing autostart: {e}")
return False

@staticmethod
def check_autostart() -> bool:
"""
Check if Writing Tools is set to start automatically.
Returns:
bool: True if autostart is enabled, False if disabled or unsupported
"""
try:
startup_path = AutostartManager.get_startup_path()
if not startup_path:
return False

try:
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Run",
0, winreg.KEY_READ)
value, _ = winreg.QueryValueEx(key, "WritingTools")
winreg.CloseKey(key)

# Check if the stored path matches our current exe
return value.lower() == startup_path.lower()

except WindowsError:
# Key or value doesn't exist
return False

except Exception as e:
logging.error(f"Error checking autostart status: {e}")
return False
10 changes: 9 additions & 1 deletion Windows_and_Linux/ui/CustomPopupWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def init_ui(self):
has_text = not not self.selected_text.strip()

self.custom_input = QtWidgets.QLineEdit()
self.custom_input.setPlaceholderText("Describe your change..." if has_text else "Please enter an instruction...")
self.custom_input.setPlaceholderText("Describe your change..." if has_text else "Ask your AI...")
self.custom_input.setStyleSheet(f"""
QLineEdit {{
padding: 8px;
Expand Down Expand Up @@ -145,6 +145,14 @@ def init_ui(self):
content_layout.addLayout(options_grid)
else:
self.custom_input.setMinimumWidth(300)

# Add update notice if available
if self.app.config.get("update_available", False):
update_label = QtWidgets.QLabel()
update_label.setOpenExternalLinks(True)
update_label.setText('<a href="https://github.com/theJayTea/WritingTools/releases" style="color:rgb(255, 0, 0); text-decoration: underline; font-weight: bold;">There\'s an update! :D Download now.</a>')
update_label.setStyleSheet("margin-top: 10px;")
content_layout.addWidget(update_label, alignment=QtCore.Qt.AlignmentFlag.AlignCenter)

logging.debug('CustomPopupWindow UI setup complete')

Expand Down
12 changes: 7 additions & 5 deletions Windows_and_Linux/ui/OnboardingWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from PySide6 import QtCore, QtWidgets
from PySide6.QtWidgets import QHBoxLayout, QRadioButton

from ui.SettingsWindow import SettingsWindow
from ui.UIUtils import UIUtils, colorMode


Expand Down Expand Up @@ -42,20 +41,23 @@ def show_welcome_screen(self):
self.content_layout.addWidget(title_label, alignment=QtCore.Qt.AlignmentFlag.AlignCenter)

features_text = """
Improves your writing with AI
Instantly optimize your writing with AI by selecting your text and invoking Writing Tools with "ctrl+space", anywhere.
• Works in any application in just a click
• Get a summary you can chat with of articles, YouTube videos, or documents by select all text with "ctrl+a"
(or select the YouTube transcript from its description), invoking Writing Tools, and choosing Summary.
• Chat with AI anytime by invoking Writing Tools without selecting any text.
• Supports an extensive range of AI models:
- Gemini 1.5 Flash
- Gemini 2.0
- ANY OpenAI Compatible API — including local LLMs!
"""
features_label = QtWidgets.QLabel(features_text)
features_label.setStyleSheet(f"font-size: 16px; color: {'#ffffff' if colorMode == 'dark' else '#333333'};")
features_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft)
self.content_layout.addWidget(features_label)

shortcut_label = QtWidgets.QLabel("Customize your shortcut key (default: ctrl+space):")
shortcut_label = QtWidgets.QLabel("Customize your shortcut key (default: \"ctrl+space\"):")
shortcut_label.setStyleSheet(f"font-size: 16px; color: {'#ffffff' if colorMode == 'dark' else '#333333'};")
self.content_layout.addWidget(shortcut_label)

Expand Down
Loading

0 comments on commit 1af9eaf

Please sign in to comment.