app v1 fix
This commit is contained in:
126
core/app.py
126
core/app.py
@@ -178,16 +178,28 @@ class StickyNoteApp(AcrylicWindow):
|
||||
|
||||
self.configure_window()
|
||||
|
||||
self.build_tray()
|
||||
|
||||
self.restore_state()
|
||||
|
||||
self.apply_style()
|
||||
QTimer.singleShot(
|
||||
120,
|
||||
self.initialize_effects,
|
||||
)
|
||||
|
||||
QTimer.singleShot(
|
||||
self.profile["window"][
|
||||
"startup_stabilize_ms"
|
||||
],
|
||||
220,
|
||||
self.build_tray,
|
||||
)
|
||||
|
||||
QTimer.singleShot(
|
||||
80,
|
||||
self.restore_state,
|
||||
)
|
||||
|
||||
QTimer.singleShot(
|
||||
260,
|
||||
self.apply_style,
|
||||
)
|
||||
|
||||
QTimer.singleShot(
|
||||
320,
|
||||
self.finalize_startup,
|
||||
)
|
||||
|
||||
@@ -258,6 +270,7 @@ class StickyNoteApp(AcrylicWindow):
|
||||
QEasingCurve.Type.OutCubic
|
||||
)
|
||||
|
||||
# v1.0.1 configure_window.py
|
||||
def configure_window(self) -> None:
|
||||
window = self.profile["window"]
|
||||
|
||||
@@ -271,66 +284,33 @@ class StickyNoteApp(AcrylicWindow):
|
||||
window["min_height"],
|
||||
)
|
||||
|
||||
self.setWindowFlags(
|
||||
Qt.WindowType.Tool
|
||||
| Qt.WindowType.FramelessWindowHint
|
||||
| Qt.WindowType.WindowStaysOnTopHint
|
||||
| Qt.WindowType.CustomizeWindowHint
|
||||
self.setWindowFlag(
|
||||
Qt.WindowType.WindowStaysOnTopHint,
|
||||
True,
|
||||
)
|
||||
|
||||
self.setAttribute(
|
||||
Qt.WidgetAttribute.WA_TranslucentBackground,
|
||||
True,
|
||||
)
|
||||
|
||||
self.setAttribute(
|
||||
Qt.WidgetAttribute.WA_NoSystemBackground,
|
||||
True,
|
||||
)
|
||||
|
||||
self.setWindowFlag(
|
||||
Qt.WindowType.WindowMinMaxButtonsHint,
|
||||
False,
|
||||
)
|
||||
|
||||
self.setWindowFlag(
|
||||
Qt.WindowType.WindowCloseButtonHint,
|
||||
False,
|
||||
)
|
||||
|
||||
self.setWindowFlag(
|
||||
Qt.WindowType.CustomizeWindowHint,
|
||||
True,
|
||||
self.setAutoFillBackground(
|
||||
False
|
||||
)
|
||||
|
||||
self.setAutoFillBackground(False)
|
||||
|
||||
|
||||
appearance = (
|
||||
self.profile["appearance"]
|
||||
QTimer.singleShot(
|
||||
120,
|
||||
self.initialize_effects,
|
||||
)
|
||||
|
||||
try:
|
||||
if appearance[
|
||||
"enable_mica"
|
||||
]:
|
||||
self.windowEffect.setMicaEffect(
|
||||
self.winId(),
|
||||
True,
|
||||
)
|
||||
|
||||
elif appearance[
|
||||
"enable_acrylic"
|
||||
]:
|
||||
self.windowEffect.setAcrylicEffect(
|
||||
self.winId(),
|
||||
"00000001",
|
||||
)
|
||||
|
||||
except Exception:
|
||||
logging.exception(
|
||||
"window_effect_failure"
|
||||
)
|
||||
|
||||
def build_ui(self) -> None:
|
||||
self.root = QWidget(self)
|
||||
|
||||
@@ -465,7 +445,11 @@ class StickyNoteApp(AcrylicWindow):
|
||||
)
|
||||
|
||||
self.titleBar.hide()
|
||||
self.editor.setFocus()
|
||||
|
||||
def build_tray(self) -> None:
|
||||
if QSystemTrayIcon.isSystemTrayAvailable() is False:
|
||||
return
|
||||
if not self.profile[
|
||||
"behavior"
|
||||
]["enable_tray"]:
|
||||
@@ -619,7 +603,40 @@ class StickyNoteApp(AcrylicWindow):
|
||||
],
|
||||
)
|
||||
)
|
||||
def initialize_effects(self) -> None:
|
||||
appearance = (
|
||||
self.profile["appearance"]
|
||||
)
|
||||
|
||||
try:
|
||||
hwnd = int(self.winId())
|
||||
|
||||
if not hwnd:
|
||||
return
|
||||
|
||||
if appearance[
|
||||
"enable_mica"
|
||||
]:
|
||||
self.windowEffect.setMicaEffect(
|
||||
hwnd,
|
||||
True,
|
||||
)
|
||||
|
||||
elif appearance[
|
||||
"enable_acrylic"
|
||||
]:
|
||||
self.windowEffect.setAcrylicEffect(
|
||||
hwnd,
|
||||
"00000001",
|
||||
)
|
||||
|
||||
self.update()
|
||||
self.repaint()
|
||||
|
||||
except Exception:
|
||||
logging.exception(
|
||||
"window_effect_failure"
|
||||
)
|
||||
def start_drag(
|
||||
self,
|
||||
global_pos: QPoint,
|
||||
@@ -699,9 +716,14 @@ class StickyNoteApp(AcrylicWindow):
|
||||
)
|
||||
|
||||
def show_preview(self) -> None:
|
||||
if self.editor.hasFocus():
|
||||
if (
|
||||
self.editor.hasFocus()
|
||||
or not self.isActiveWindow()
|
||||
):
|
||||
return
|
||||
|
||||
self.preview.setFocusPolicy(
|
||||
Qt.FocusPolicy.NoFocus
|
||||
)
|
||||
markdown = (
|
||||
self.editor.toPlainText()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user