Skip to content

Commit

Permalink
Refactor main menu (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo authored Oct 29, 2024
2 parents e424fcf + 4eace70 commit 8725eda
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 131 deletions.
12 changes: 12 additions & 0 deletions novelwriter/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import uuid
import xml.etree.ElementTree as ET

from collections.abc import Callable
from configparser import ConfigParser
from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -414,6 +415,10 @@ def numberToRoman(value: int, toLower: bool = False) -> str:
return roman.lower() if toLower else roman


##
# Qt Helpers
##

def cssCol(col: QColor, alpha: int | None = None) -> str:
"""Convert a QColor object to an rgba entry to use in CSS."""
return f"rgba({col.red()}, {col.green()}, {col.blue()}, {alpha or col.alpha()})"
Expand All @@ -429,6 +434,13 @@ def describeFont(font: QFont) -> str:
return "Error"


def qtLambda(func: Callable, *args: Any, **kwargs: Any) -> Callable:
"""A replacement for Python lambdas that works for Qt slots."""
def wrapper(*args_: Any, **kwargs_: Any) -> None:
func(*args, **kwargs)
return wrapper


##
# Encoder Functions
##
Expand Down
Loading

0 comments on commit 8725eda

Please sign in to comment.