Skip to content

Commit

Permalink
Add icons for text margins
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Nov 13, 2024
1 parent 57641ec commit a96ccf8
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 22 deletions.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_dark/icons.conf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ font = nw_font.svg
forward = typ_chevron-right.svg
import = mixed_import.svg
list = typ_th-list.svg
margin_bottom = mixed_margin-bottom.svg
margin_left = mixed_margin-left.svg
margin_right = mixed_margin-right.svg
margin_top = mixed_margin-top.svg
maximise = typ_arrow-maximise.svg
menu = typ_th-dot-menu.svg
minimise = typ_arrow-minimise.svg
Expand Down Expand Up @@ -94,6 +98,8 @@ search_regex = nw_search-regex.svg
search_replace = mixed_search-replace.svg
search_word = nw_search-word.svg
settings = typ_cog.svg
size_height = mixed_size-height.svg
size_width = mixed_size-width.svg
star = typ_star.svg
status_idle = typ_media-pause-grey.svg
status_lang = typ_globe-grey.svg
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_dark/mixed_size-height.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_dark/mixed_size-width.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_light/icons.conf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ font = nw_font.svg
forward = typ_chevron-right.svg
import = mixed_import.svg
list = typ_th-list.svg
margin_bottom = mixed_margin-bottom.svg
margin_left = mixed_margin-left.svg
margin_right = mixed_margin-right.svg
margin_top = mixed_margin-top.svg
maximise = typ_arrow-maximise.svg
menu = typ_th-dot-menu.svg
minimise = typ_arrow-minimise.svg
Expand Down Expand Up @@ -94,6 +98,8 @@ search_regex = nw_search-regex.svg
search_replace = mixed_search-replace.svg
search_word = nw_search-word.svg
settings = typ_cog.svg
size_height = mixed_size-height.svg
size_width = mixed_size-width.svg
star = typ_star.svg
status_idle = typ_media-pause-grey.svg
status_lang = typ_globe-grey.svg
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_light/mixed_margin-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_light/mixed_margin-top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_light/mixed_size-height.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions novelwriter/assets/icons/typicons_light/mixed_size-width.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions novelwriter/extensions/configlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""
from __future__ import annotations

from PyQt5.QtGui import QColor, QFont, QPalette
from PyQt5.QtGui import QColor, QFont, QPalette, QPixmap
from PyQt5.QtWidgets import (
QAbstractButton, QFrame, QHBoxLayout, QLabel, QLayout, QScrollArea,
QVBoxLayout, QWidget
Expand Down Expand Up @@ -183,7 +183,7 @@ def addGroupLabel(self, label: str, identifier: int | None = None) -> None:
def addRow(
self,
label: str | None,
widget: QWidget | list[QWidget | str | int],
widget: QWidget | list[QWidget | QPixmap | str | int],
helpText: str = "",
unit: str | None = None,
button: QWidget | None = None,
Expand All @@ -200,6 +200,10 @@ def addRow(
for item in widget:
if isinstance(item, QWidget):
wBox.addWidget(item)
elif isinstance(item, QPixmap):
icon = QLabel(self)
icon.setPixmap(item)
wBox.addWidget(icon)
elif isinstance(item, str):
wBox.addWidget(QLabel(item, self))
elif isinstance(item, int):
Expand Down
3 changes: 2 additions & 1 deletion novelwriter/gui/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ class GuiIcons:

# Format Icons
"fmt_bold", "fmt_bold-md", "fmt_italic", "fmt_italic-md", "fmt_mark", "fmt_strike",
"fmt_strike-md", "fmt_subscript", "fmt_superscript", "fmt_underline",
"fmt_strike-md", "fmt_subscript", "fmt_superscript", "fmt_underline", "margin_bottom",
"margin_left", "margin_right", "margin_top", "size_height", "size_width",

# General Button Icons
"add", "add_document", "backward", "bookmark", "browse", "checked", "close", "copy",
Expand Down
43 changes: 24 additions & 19 deletions novelwriter/tools/manussettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,15 +964,6 @@ def buildForm(self) -> None:
spW = 6*SHARED.theme.textNWidth
dbW = 8*SHARED.theme.textNWidth

# Common Translations

trW = self.tr("W:") # Width
trH = self.tr("H:") # Height
trT = self.tr("T:") # Top
trB = self.tr("B:") # Bottom
trL = self.tr("L:") # Left
trR = self.tr("R:") # Right

# Text Content
# ============

Expand Down Expand Up @@ -1084,6 +1075,13 @@ def buildForm(self) -> None:
self._sidebar.addButton(title, section)
self.addGroupLabel(title, section)

pixT = SHARED.theme.getPixmap("margin_top", (iPx, iPx))
pixB = SHARED.theme.getPixmap("margin_bottom", (iPx, iPx))
pixL = SHARED.theme.getPixmap("margin_left", (iPx, iPx))
pixR = SHARED.theme.getPixmap("margin_right", (iPx, iPx))
pixH = SHARED.theme.getPixmap("size_height", (iPx, iPx))
pixW = SHARED.theme.getPixmap("size_width", (iPx, iPx))

# Title
self.titleMarginT = NDoubleSpinBox(self)
self.titleMarginT.setFixedWidth(dbW)
Expand All @@ -1093,7 +1091,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["H0"]),
[trT, self.titleMarginT, 6, trB, self.titleMarginB],
[pixT, self.titleMarginT, 6, pixB, self.titleMarginB],
unit="em",
)

# Heading 1
Expand All @@ -1105,7 +1104,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["H1"]),
[trT, self.h1MarginT, 6, trB, self.h1MarginB],
[pixT, self.h1MarginT, 6, pixB, self.h1MarginB],
unit="em",
)

# Heading 2
Expand All @@ -1117,7 +1117,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["H2"]),
[trT, self.h2MarginT, 6, trB, self.h2MarginB],
[pixT, self.h2MarginT, 6, pixB, self.h2MarginB],
unit="em",
)

# Heading 3
Expand All @@ -1129,7 +1130,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["H3"]),
[trT, self.h3MarginT, 6, trB, self.h3MarginB],
[pixT, self.h3MarginT, 6, pixB, self.h3MarginB],
unit="em",
)

# Heading 4
Expand All @@ -1141,7 +1143,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["H4"]),
[trT, self.h4MarginT, 6, trB, self.h4MarginB],
[pixT, self.h4MarginT, 6, pixB, self.h4MarginB],
unit="em",
)

# Text
Expand All @@ -1153,7 +1156,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["TT"]),
[trT, self.textMarginT, 6, trB, self.textMarginB],
[pixT, self.textMarginT, 6, pixB, self.textMarginB],
unit="em",
)

# Separator
Expand All @@ -1165,7 +1169,8 @@ def buildForm(self) -> None:

self.addRow(
trConst(nwStyles.T_LABEL["SP"]),
[trT, self.sepMarginT, 6, trB, self.sepMarginB],
[pixT, self.sepMarginT, 6, pixB, self.sepMarginB],
unit="em",
)

# Page Layout
Expand Down Expand Up @@ -1198,7 +1203,7 @@ def buildForm(self) -> None:

self.addRow(
self._build.getLabel("format.pageSize"),
[self.pageSize, 6, trW, self.pageWidth, 6, trH, self.pageHeight],
[self.pageSize, 6, pixW, self.pageWidth, 6, pixH, self.pageHeight],
)

# Page Margins
Expand All @@ -1216,11 +1221,11 @@ def buildForm(self) -> None:

self.addRow(
self._build.getLabel("format.pageMargins"),
[trT, self.topMargin, 6, trB, self.bottomMargin],
[pixT, self.topMargin, 6, pixB, self.bottomMargin],
)
self.addRow(
"",
[trL, self.leftMargin, 6, trR, self.rightMargin],
[pixL, self.leftMargin, 6, pixR, self.rightMargin],
)

# Open Document
Expand Down

0 comments on commit a96ccf8

Please sign in to comment.