Skip to content

Commit

Permalink
#48 Added "Additional Preferences" for even more control
Browse files Browse the repository at this point in the history
  • Loading branch information
rohankishore authored Nov 25, 2023
1 parent f36dccc commit 4b05214
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 26 deletions.
2 changes: 1 addition & 1 deletion auratext/Core/MenuConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def read_only():
# language_menu.addMenu(z_menu)

prefernces_menu.addMenu(language_menu)
# prefernces_menu.addAction("Autocomplete Dictionary", )
prefernces_menu.addAction("Additional Preferences", self.additional_prefs)
menubar.addMenu(prefernces_menu)

help_menu = QMenu("&?", self)
Expand Down
88 changes: 88 additions & 0 deletions auratext/Core/additional_prefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import json
import os
import sys

from PyQt6.QtWidgets import (
QLabel,
QCheckBox,
QPushButton,
QVBoxLayout,
QDialog,
QWidget,
QMessageBox,
QComboBox,
QApplication,
)

local_app_data = os.path.join(os.getenv("LocalAppData"), "AuraText")


class SettingsWindow(QDialog):
def __init__(self):
super().__init__()

with open(f"{local_app_data}/data/config.json", "r") as json_file:
self._config = json.load(json_file)

self.splash_status = self._config['splash']

self._config = {
"splash": "",
}

self.init_ui()

def init_ui(self):
layout = QVBoxLayout()
layout.addStretch()
layout.addSpacing(100)

self.splash_checkbox = QCheckBox("Show Adaptive Splash Screens")
self.splash_checkbox.setChecked(True) if self.splash_status == "True" else self.splash_checkbox.setChecked(
False)

layout.addWidget(self.splash_checkbox)

# Save Button
save_button = QPushButton("Apply")
save_button.setStyleSheet(
"QPushButton {"
" border-radius: 10px;"
" padding: 5px;"
"background-color: #121212;"
"color: white;"
"}"
)
save_button.clicked.connect(self.save_settings)
layout.addWidget(save_button)

self.setLayout(layout)
self.setWindowTitle("Settings Window")

def save_settings(self):
if self.splash_checkbox.isChecked():
self.splash_status = "True"
else:
self.splash_status = "False"

# Update the splash status in the existing configuration
self._config["splash"] = self.splash_status

# Save the updated configuration back to the JSON file
with open(f"{local_app_data}/data/config.json", "w") as json_file:
json.dump(self._config, json_file, indent=4)

print(self.splash_status)

# self._themes["editor_theme"] = self.editor_theme_input.isChecked()
# self._themes["margin_theme"] = self.margin_theme_input.isChecked()
# self._themes["lines_theme"] = self.lines_theme_input.isChecked()
# self._themes["lines_fg"] = self.lines_fg_input.isChecked()
# self._themes["font"] = self.font_theme_combobox.currentText()
# self._themes["theme_type"] = self.theme_combobox.currentText()

QMessageBox.information(
self,
"Settings Applied!",
"The chosen settings have been applied.",
)
73 changes: 48 additions & 25 deletions auratext/Core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import git
import pyjokes
import qdarktheme
from PyQt6.QtCore import Qt, QSize, pyqtSignal
from PyQt6.QtGui import QColor, QFont, QActionGroup, QFileSystemModel, QPixmap, QIcon, QFontMetrics
from PyQt6.QtCore import Qt, QSize
from PyQt6.QtGui import QColor, QFont, QActionGroup, QFileSystemModel, QPixmap, QIcon
from PyQt6.QtWidgets import (
QMainWindow,
QInputDialog,
Expand All @@ -25,13 +25,12 @@
QPushButton,
QWidget,
QVBoxLayout,
QDialog,
QStatusBar,
QLabel
QStatusBar
)

from . import Lexers
from . import MenuConfig
from . import additional_prefs
from . import Modules as ModuleFile
from . import PluginDownload
from . import WelcomeScreen
Expand Down Expand Up @@ -63,8 +62,14 @@ def __init__(self):
self.local_app_data = local_app_data
# self._terminal_history = ""

with open(f"{local_app_data}/data/theme.json", "r") as json_file:
self._themes = json.load(json_file)
# COMMENTED OUT CODE FOR FRAMELESS WINDOW. IN DEVELOPMENT
#self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
#self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)

with open(f"{local_app_data}/data/theme.json", "r") as themes_file:
self._themes = json.load(themes_file)
with open(f"{local_app_data}/data/config.json", "r") as config_file:
self._config = json.load(config_file)
qdarktheme.setup_theme(
self._themes["theme_type"], custom_colors={"primary": self._themes["theme"]}
)
Expand All @@ -73,24 +78,30 @@ def __init__(self):
self._terminal_history = thfile.readlines()
# self._terminal_history.split('\n')

# Splash Screen
splash_pix = ""
current_time = datetime.datetime.now().time()
sunrise_time = current_time.replace(hour=6, minute=0, second=0, microsecond=0)
sunset_time = current_time.replace(hour=18, minute=0, second=0, microsecond=0)

# Check which time interval the current time falls into
if sunrise_time <= current_time < sunrise_time.replace(hour=12):
splash_pix = QPixmap(f"{local_app_data}/icons/splash_morning.png")
elif sunrise_time.replace(hour=12) <= current_time < sunset_time:
splash_pix = QPixmap(f"{local_app_data}/icons/splash_afternoon.png")
def splashScreen():
# Splash Screen
splash_pix = ""
current_time = datetime.datetime.now().time()
sunrise_time = current_time.replace(hour=6, minute=0, second=0, microsecond=0)
sunset_time = current_time.replace(hour=18, minute=0, second=0, microsecond=0)

# Check which time interval the current time falls into
if sunrise_time <= current_time < sunrise_time.replace(hour=12):
splash_pix = QPixmap(f"{local_app_data}/icons/splash_morning.png")
elif sunrise_time.replace(hour=12) <= current_time < sunset_time:
splash_pix = QPixmap(f"{local_app_data}/icons/splash_afternoon.png")
else:
splash_pix = QPixmap(f"{local_app_data}/icons/splash_night.png")

splash = QSplashScreen(splash_pix)
splash.show()
time.sleep(1)
splash.hide()

if self._config["splash"] == "True":
splashScreen()
else:
splash_pix = QPixmap(f"{local_app_data}/icons/splash_night.png")

splash = QSplashScreen(splash_pix)
splash.show()
time.sleep(1)
splash.hide()
pass

self.tab_widget = TabWidget()
self.current_editor = ""
Expand Down Expand Up @@ -193,6 +204,14 @@ def __init__(self):
self.load_plugins()
self.showMaximized()

#def mousePressEvent(self, event):
# self.dragPos = event.globalPosition().toPoint()

#def mouseMoveEvent(self, event):
#self.move(self.pos() + event.globalPosition().toPoint() - self.dragPos)
#self.dragPos = event.globalPosition().toPoint()
#event.accept()

def create_editor(self):
self.text_editor = CodeEditor(self)
return self.text_editor
Expand Down Expand Up @@ -246,7 +265,7 @@ def treeview_project(self, path):
tree_view.setColumnHidden(1, True) # File type column
tree_view.setColumnHidden(2, True) # Size column
tree_view.setColumnHidden(3, True) # Date modified column

tree_view.doubleClicked.connect(self.open_file)

def expandSidebar__Explorer(self):
Expand Down Expand Up @@ -657,6 +676,10 @@ def open_project_as_treeview(self):
project_path = dialog.selectedFiles()[0]
self.treeview_project(project_path)

def additional_prefs(self):
settings = additional_prefs.SettingsWindow()
settings.exec()

def new_document(self, checked=False, title="Scratch 1"):
self.current_editor = self.create_editor()

Expand Down

0 comments on commit 4b05214

Please sign in to comment.