Skip to content
Snippets Groups Projects
Commit 3849bc08 authored by Thomas Holene Løkkeborg's avatar Thomas Holene Løkkeborg
Browse files

Merge branch 'autentiseringstavle-kode-font' into 'master'

#114 Autentiseringstavle-koder: monospaced font

See merge request !64
parents b134d684 2146818f
No related branches found
No related tags found
1 merge request!64#114 Autentiseringstavle-koder: monospaced font
Pipeline #81046 passed
......@@ -223,9 +223,10 @@ class MainWindow(QMainWindow):
self.tabs.setCurrentWidget(tab)
def open_soi_workspace_tab(self):
"""Open tab containing a SOIWorkspaceWidget."""
"""Open and select tab containing a SOIWorkspaceWidget."""
tab = SOIWorkspaceWidget()
self.tabs.addTab(tab, tab.soi.title)
self.tabs.setCurrentWidget(tab)
def close_tab(self, index):
"""Close tab at given index.
......
soitool/media/authenticationboardmodule.PNG

11.1 KiB | W: | H:

soitool/media/authenticationboardmodule.PNG

11.7 KiB | W: | H:

soitool/media/authenticationboardmodule.PNG
soitool/media/authenticationboardmodule.PNG
soitool/media/authenticationboardmodule.PNG
soitool/media/authenticationboardmodule.PNG
  • 2-up
  • Swipe
  • Onion skin
soitool/media/subtractorcodesmodule.PNG

3.19 KiB | W: | H:

soitool/media/subtractorcodesmodule.PNG

3.48 KiB | W: | H:

soitool/media/subtractorcodesmodule.PNG
soitool/media/subtractorcodesmodule.PNG
soitool/media/subtractorcodesmodule.PNG
soitool/media/subtractorcodesmodule.PNG
  • 2-up
  • Swipe
  • Onion skin
......@@ -114,8 +114,8 @@ class CodeTableBase(ModuleBase, QTableWidget, metaclass=Meta):
for i in range(self.start_no_of_codes):
# Insert non-editable code in third column
item_third = QTableWidgetItem(codes[i])
if self.type == SUBTRACTORCODES_MODULE:
item_third.setTextAlignment(Qt.AlignCenter)
item_third.setTextAlignment(Qt.AlignCenter)
item_third.setFont(self.code_font)
item_third.setFlags(item_third.flags() ^ Qt.ItemIsEditable)
self.setItem(i, 2, item_third)
......
......@@ -12,14 +12,17 @@ START_NO_OF_CODES = 10
CODE_LENGTH = 25
# Has to be 'ascii', 'digits' or 'combo'
# Codes will consist of A-Z if 'ascii', 0-9 if 'digits' and A-Z+0-9 if 'combo'.
# Codes will consist of A-Z if 'ascii', 0-9 if 'digits' and A-Z+0-9 if 'combo'
CODE_CHARACTER_TYPE = "ascii"
# Font for authentication codes, should be a monospaced font
CODE_FONT = QtGui.QFont("Consolas", 10, QtGui.QFont.SansSerif)
# Characters for first column,
# it's length determines maximum number of codes (rows).
ROW_IDENTIFIERS = string.ascii_uppercase
# Adds space between sets of characters, 0 => no spaces.
# Adds space between sets of characters, 0 => no spaces
# If code is 123456 and interval is 2, code will be 12 34 56
SPACE_INTERVAL = 5
SPACE_AMOUNT = 2
......@@ -38,6 +41,9 @@ class AuthenticationBoardModule(CodeTableBase):
CODE_LENGTH, spaced out for readability if SPACE_INTERVAL and SPACE_AMOUNT
is larger than 0.
The authentication codes have their own monospaced font for increased
readability, meaning each character has the same width.
If parameters are given, the widget initializes accordingly:
'size' is a dict: {"width": int, "height": int},
'data' is a dict with keys "cells", "code_length", "space_interval",
......@@ -47,9 +53,6 @@ class AuthenticationBoardModule(CodeTableBase):
The widget does not use more room than needed, and resizes dynamically.
It has shortcuts for adding and removing rows.
Codes are not horizontally centered for readability concerns because 'BGD'
is wider than 'III' (example) in certain fonts.
"""
def __init__(self, size=None, data=None):
......@@ -66,6 +69,8 @@ class AuthenticationBoardModule(CodeTableBase):
"Invalid value for CONSTANT 'CODE_CHARACTER_TYPE': "
"'{}'".format(CODE_CHARACTER_TYPE)
)
self.code_font = CODE_FONT
# Set default values for table to be generated
if size is None and data is None:
self.start_no_of_codes = START_NO_OF_CODES
......@@ -131,12 +136,10 @@ class AuthenticationBoardModule(CodeTableBase):
# Insert authentication-code in third column
item_third = QTableWidgetItem(code)
item_third.setFont(self.code_font)
item_third.setFlags(item_third.flags() ^ Qt.ItemIsEditable)
self.setItem(selected_row_index + 1, 2, item_third)
# Resize code-column in case it got wider
# Example: 'BGD' is wider than 'III' (depending on font)
self.resizeColumnToContents(2)
self.resizeRowToContents(selected_row_index + 1)
resize_table(self, columns=False, rows=False, has_headline=True)
......
......@@ -10,13 +10,16 @@ from soitool.modules.code_table_base import CodeTableBase
START_NO_OF_CODES = 7
CODE_LENGTH = 8
# Font for subtractorcodes
CODE_FONT = QtGui.QFont("Arial", 10, QtGui.QFont.SansSerif)
# Characters for first and second column
ROW_IDENTIFIERS = string.ascii_uppercase
# Adds space between sets of characters, 0 => no spaces.
# If code is 12345678 and interval is 2, code will be 1234 5678
SPACE_INTERVAL = 4
SPACE_AMOUNT = 5
SPACE_AMOUNT = 3
HEADLINE_TEXT = "Subtraktorkoder"
......@@ -56,6 +59,7 @@ class SubtractorcodesModule(CodeTableBase):
self.space_interval = SPACE_INTERVAL
self.space_amount = SPACE_AMOUNT
self.code_character_type = "digits"
self.code_font = CODE_FONT
CodeTableBase.__init__(self, size, data)
......@@ -114,6 +118,7 @@ class SubtractorcodesModule(CodeTableBase):
# Insert code
item_code = QTableWidgetItem(code)
item_code.setTextAlignment(Qt.AlignCenter)
item_code.setFont(self.code_font)
item_code.setFlags(item_code.flags() ^ Qt.ItemIsEditable)
self.setItem(selected_row_index + 1, 2, item_code)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment