Skip to content

Commit

Permalink
Improved startup time
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Nov 30, 2023
1 parent 370f024 commit 77bcfd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
15 changes: 7 additions & 8 deletions finalcif/gui/plaintextedit.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from contextlib import suppress
from enum import IntEnum
from functools import cache
from enum import IntEnum
from typing import TYPE_CHECKING

from PyQt5 import QtCore
from PyQt5.QtCore import pyqtSignal, Qt, QObject, QEvent, QSize
from PyQt5.QtGui import QTextOption, QFontMetrics, QContextMenuEvent, QFont, QColor
from PyQt5.QtWidgets import QPlainTextEdit, QFrame, QApplication, QAbstractScrollArea
from PyQt5.QtWidgets import QPlainTextEdit, QFrame, QAbstractScrollArea
from numpy import random

from finalcif.gui.edit_button import FloatingButtonWidget
Expand Down Expand Up @@ -55,7 +53,6 @@ def __str__(self):
return self.toPlainText()

@property
@cache
def fontmetric(self):
return QFontMetrics(self.document().defaultFont())

Expand Down Expand Up @@ -118,7 +115,9 @@ def setText(self, text: str, color: QColor = None, column: int = None):
"""
if color:
self.setBackground(color)
if self.cif_key in self.to_be_shortened and column == Column.CIF:
if not text:
return
if column == Column.CIF and self.cif_key in self.to_be_shortened:
self.setPlainText(f'{text[:300]} [...]')
else:
self.setPlainText(text)
Expand Down Expand Up @@ -146,7 +145,7 @@ def enterEvent(self, a0):
self.edit_button.update_position()
self.edit_button.show()

def leaveEvent(self, a0):
def leaveEvent(self, a0: QEvent) -> None:
super().leaveEvent(a0)
if self.edit_button and self.column == Column.EDIT:
self.edit_button.hide()
Expand Down Expand Up @@ -227,7 +226,7 @@ def sizeHint(self) -> QSize:

if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication, QTableWidget, QTableWidgetItem
from PyQt5.QtWidgets import QApplication, QTableWidget

app = QApplication(sys.argv)
window = QTableWidget()
Expand Down
1 change: 0 additions & 1 deletion tests/test_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def setUp(self) -> None:
# TODO: make tests where changes file is active:
(data / 'examples/1979688-finalcif_changes.cif').unlink(missing_ok=True)
self.myapp = AppWindow(file=self.testcif)
self.myapp.hide() # For full screen view
self.myapp.ui.LoopsPushButton.click()

def tearDown(self) -> None:
Expand Down

0 comments on commit 77bcfd8

Please sign in to comment.