Skip to content

Commit

Permalink
(upd) in compliance with negar 1.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
javadr committed Dec 24, 2024
1 parent 6acf8d9 commit bb5284a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
6 changes: 5 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024-12-23 -- v0.9.4
-- Updated for compliance with python-negar 1.2.12
-- Fixed wheel event

2024-12-21 -- v0.9.2
-- Added comparative mode to illustrate how Negar processes its input.
-- Resolved issue with Ctrl+Alt+S following the upgrade to PyQt6.
Expand Down Expand Up @@ -30,7 +34,7 @@

2023-08-16 -- v0.8.1
-- Fixed issue with saving configurations in Windows

2023-08-16 -- v0.8
-- All configurations will be saved in a TOML file to be loaded in the next run.

Expand Down
2 changes: 1 addition & 1 deletion negar_gui/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import platform
from pathlib import Path

__version__ = "0.9.2"
__version__ = "0.9.4"

APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else "."
SETTING_FILE = Path.home() / f"{APPDATA}negar-gui/settings.toml"
Expand Down
28 changes: 14 additions & 14 deletions negar_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
sys.path.append(Path(__file__).parent.parent.as_posix())
from negar.constants import INFO # noqa: E402
from negar.constants import __version__ as negar__version # noqa: E402
from negar.virastar import PersianEditor, UnTouchable # noqa: E402
from negar.virastar import PersianEditor, ImmutableWords # noqa: E402

from negar_gui.constants import LOGO, __version__, SETTING_FILE # noqa: E402
from negar_gui.Ui_hwin import Ui_Dialog # noqa: E402
from negar_gui.Ui_mwin import Ui_MainWindow # noqa: E402
from negar_gui.Ui_uwin import Ui_uwWindow # noqa: E402
import negar_gui.resource_rc # Make sure this is imported
import negar_gui.resource_rc # noqa: F401 Make sure this is imported

_translate = QCoreApplication.translate
NEGARGUIPATH = Path(__file__).parent.as_posix()
Expand All @@ -71,7 +71,7 @@ def init_decorator(func):
def wrapper(*args, **kwargs):
func(*args, **kwargs)
self, parent = args[0], kwargs.pop("parent", None)
# Maximize Frame Size if either height or width exceeds real screen dimensionsq
# Maximize Frame Size if either height or width exceeds real screen dimensions
# screen = QApplication.desktop().screenGeometry()
screen = QApplication.primaryScreen().geometry()
h, w = screen.height(), screen.width()
Expand Down Expand Up @@ -186,7 +186,7 @@ def showEvent(self, event):
self.__load_settings()


class UntouchWindow(QMainWindow, Ui_uwWindow):
class ImmutableWordsWindow(QMainWindow, Ui_uwWindow):
@init_decorator
def __init__(self, parent=None):
self.parent = parent
Expand All @@ -197,7 +197,7 @@ def __init__(self, parent=None):

def setup_table(self, col=8):
self.untouch_table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
data = sorted(list(UnTouchable().get()), key=collator.sort_key)
data = sorted(list(ImmutableWords().get()), key=collator.sort_key)
data = [data[i * col : (i + 1) * col] for i in range(int(len(data) // col) + 1)]
model = TableModel(data)
self.untouch_table.setModel(model)
Expand All @@ -207,16 +207,16 @@ def connectSlots(self):
self.untouch_button.clicked.connect(self.untouch_add)

def untouch_add_enabler(self):
"""Enable `Add` button when a single word is entered in the untouchable text input."""
"""Enable `Add` button when a single word is entered in the immutable text input."""
word_list = self.untouch_word.text().split()
self.untouch_button.setEnabled(len(word_list) == 1)

def untouch_add(self):
"""Add a new word into untouchable words."""
"""Add a new word into immutable words."""
word = [self.untouch_word.text().strip()]
UnTouchable.add(word)
ImmutableWords.add(word)
self.untouch_word.clear()
self.setup_table() # updates untouchable list
self.setup_table() # updates immutable words list

def keyPressEvent(self, event):
if event.key() == Qt.Key.Key_Escape:
Expand Down Expand Up @@ -401,7 +401,7 @@ def connectSlots(self):
menu_item.triggered.connect(lambda: (self.option_control(), self.autoedit_handler()))

self.actionUntouchable_Words.triggered.connect(
lambda: (UntouchWindow(parent=self).show(), MAIN_WINDOW.hide())
lambda: (ImmutableWordsWindow(parent=self).show(), MAIN_WINDOW.hide())
)
self.actionCopy.triggered.connect(self.copy_slot)
self.copy_btn.clicked.connect(self.copy_slot)
Expand Down Expand Up @@ -768,10 +768,10 @@ def keyPressEvent(self, event):
super().keyPressEvent(event)

def wheelEvent(self, event):
modifiers = QApplication.keyboardModifiers()
# modifiers = event.modifiers()
# modifiers = QApplication.keyboardModifiers()
modifiers = event.modifiers()
# if modifiers == Qt.ControlModifier:
if modifiers & Qt.KeyboardModifier.ControlModifier:
if modifiers == Qt.KeyboardModifier.ControlModifier:
delta_notches = int(event.angleDelta().y() / 120)
self.font_slider.setValue(self.font_slider.value() + delta_notches)
self._set_font_size()
Expand Down Expand Up @@ -861,7 +861,7 @@ def edit_text(self, text=None):
)
try:
self.output_editor.append(colorized_text.output_markdown)
except:
except: # noqa: E722
pass
else:
self.output_editor.append(persian_editor.cleanup())
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
include_package_data=True,
packages=["negar_gui"],
install_requires=[
"python-negar>=1.2.9",
"python-negar>=1.2.12",
"PyQt6",
"pyperclip",
"pyuca",
Expand Down

0 comments on commit bb5284a

Please sign in to comment.