app v1 fix
This commit is contained in:
128
core/app.py
128
core/app.py
@@ -178,16 +178,28 @@ class StickyNoteApp(AcrylicWindow):
|
|||||||
|
|
||||||
self.configure_window()
|
self.configure_window()
|
||||||
|
|
||||||
self.build_tray()
|
QTimer.singleShot(
|
||||||
|
120,
|
||||||
self.restore_state()
|
self.initialize_effects,
|
||||||
|
)
|
||||||
self.apply_style()
|
|
||||||
|
|
||||||
QTimer.singleShot(
|
QTimer.singleShot(
|
||||||
self.profile["window"][
|
220,
|
||||||
"startup_stabilize_ms"
|
self.build_tray,
|
||||||
],
|
)
|
||||||
|
|
||||||
|
QTimer.singleShot(
|
||||||
|
80,
|
||||||
|
self.restore_state,
|
||||||
|
)
|
||||||
|
|
||||||
|
QTimer.singleShot(
|
||||||
|
260,
|
||||||
|
self.apply_style,
|
||||||
|
)
|
||||||
|
|
||||||
|
QTimer.singleShot(
|
||||||
|
320,
|
||||||
self.finalize_startup,
|
self.finalize_startup,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -258,6 +270,7 @@ class StickyNoteApp(AcrylicWindow):
|
|||||||
QEasingCurve.Type.OutCubic
|
QEasingCurve.Type.OutCubic
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# v1.0.1 configure_window.py
|
||||||
def configure_window(self) -> None:
|
def configure_window(self) -> None:
|
||||||
window = self.profile["window"]
|
window = self.profile["window"]
|
||||||
|
|
||||||
@@ -271,66 +284,33 @@ class StickyNoteApp(AcrylicWindow):
|
|||||||
window["min_height"],
|
window["min_height"],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setWindowFlags(
|
self.setWindowFlag(
|
||||||
Qt.WindowType.Tool
|
Qt.WindowType.WindowStaysOnTopHint,
|
||||||
| Qt.WindowType.FramelessWindowHint
|
True,
|
||||||
| Qt.WindowType.WindowStaysOnTopHint
|
|
||||||
| Qt.WindowType.CustomizeWindowHint
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setAttribute(
|
self.setAttribute(
|
||||||
Qt.WidgetAttribute.WA_TranslucentBackground,
|
Qt.WidgetAttribute.WA_TranslucentBackground,
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setAttribute(
|
self.setAttribute(
|
||||||
Qt.WidgetAttribute.WA_NoSystemBackground,
|
Qt.WidgetAttribute.WA_NoSystemBackground,
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setWindowFlag(
|
|
||||||
Qt.WindowType.WindowMinMaxButtonsHint,
|
|
||||||
False,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.setWindowFlag(
|
self.setWindowFlag(
|
||||||
Qt.WindowType.WindowCloseButtonHint,
|
Qt.WindowType.WindowCloseButtonHint,
|
||||||
False,
|
False,
|
||||||
)
|
)
|
||||||
|
self.setAutoFillBackground(
|
||||||
self.setWindowFlag(
|
False
|
||||||
Qt.WindowType.CustomizeWindowHint,
|
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setAutoFillBackground(False)
|
QTimer.singleShot(
|
||||||
|
120,
|
||||||
|
self.initialize_effects,
|
||||||
appearance = (
|
|
||||||
self.profile["appearance"]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
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:
|
def build_ui(self) -> None:
|
||||||
self.root = QWidget(self)
|
self.root = QWidget(self)
|
||||||
|
|
||||||
@@ -341,7 +321,7 @@ class StickyNoteApp(AcrylicWindow):
|
|||||||
self.layout = QVBoxLayout(
|
self.layout = QVBoxLayout(
|
||||||
self.root
|
self.root
|
||||||
)
|
)
|
||||||
|
|
||||||
window = self.profile["window"]
|
window = self.profile["window"]
|
||||||
|
|
||||||
margin = window[
|
margin = window[
|
||||||
@@ -465,7 +445,11 @@ class StickyNoteApp(AcrylicWindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.titleBar.hide()
|
self.titleBar.hide()
|
||||||
|
self.editor.setFocus()
|
||||||
|
|
||||||
def build_tray(self) -> None:
|
def build_tray(self) -> None:
|
||||||
|
if QSystemTrayIcon.isSystemTrayAvailable() is False:
|
||||||
|
return
|
||||||
if not self.profile[
|
if not self.profile[
|
||||||
"behavior"
|
"behavior"
|
||||||
]["enable_tray"]:
|
]["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(
|
def start_drag(
|
||||||
self,
|
self,
|
||||||
global_pos: QPoint,
|
global_pos: QPoint,
|
||||||
@@ -699,9 +716,14 @@ class StickyNoteApp(AcrylicWindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def show_preview(self) -> None:
|
def show_preview(self) -> None:
|
||||||
if self.editor.hasFocus():
|
if (
|
||||||
|
self.editor.hasFocus()
|
||||||
|
or not self.isActiveWindow()
|
||||||
|
):
|
||||||
return
|
return
|
||||||
|
self.preview.setFocusPolicy(
|
||||||
|
Qt.FocusPolicy.NoFocus
|
||||||
|
)
|
||||||
markdown = (
|
markdown = (
|
||||||
self.editor.toPlainText()
|
self.editor.toPlainText()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user