Skip to content

Commit 330d917

Browse files
Merge pull request #38 from source-foundry/fix-screen-dimensions
Adjust app height for user display size
2 parents ef5bfda + 809ae24 commit 330d917

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

src/slice/__main__.py

+38-26
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class MainWindow(QMainWindow):
6666
def __init__(self, parent=None):
6767
super().__init__(parent)
6868

69+
# get the user screen dimensions for UI layout
70+
self.screen_dimensions = QDesktopWidget().screenGeometry(0)
71+
print(
72+
f"Screen dimensions: {self.screen_dimensions.height()}, {self.screen_dimensions.width()}"
73+
)
74+
6975
# default FontModel
7076
self.font_model = FontModel(None)
7177

@@ -232,31 +238,33 @@ def setUIMainLayout(self):
232238
#
233239

234240
def setUIAppIconTitle(self):
235-
recursive_id = QFontDatabase.addApplicationFont(":/font/RecursiveSans.ttf")
236-
font_family = QFontDatabase.applicationFontFamilies(recursive_id)[0]
237-
recursive = QFont(font_family)
238-
outerHBox = QHBoxLayout()
239-
titleLabel = QLabel("<h1>Slice</h1>")
240-
titleLabel.setStyleSheet("QLabel { font-size: 36px;}")
241-
titleLabel.setFont(recursive)
242-
titleLabel.setAlignment(Qt.AlignLeft | Qt.AlignBottom)
243-
iconLabel = QLabel()
244-
# note: commented block below shows how to use
245-
# svg embedded as a Python string literal
246-
# for QImage instantiation. The current
247-
# approach is better
248-
# svg_bytes = bytearray(svg_icon, encoding="utf-8")
249-
# qimage = QImage.fromData(svg_bytes)
250-
qimage = QImage(":/img/slice-icon.svg")
251-
pixmap = QPixmap.fromImage(qimage)
252-
iconLabel.setPixmap(pixmap)
253-
iconLabel.setFixedHeight(60)
254-
iconLabel.setFixedWidth(75)
255-
outerHBox.addWidget(iconLabel)
256-
outerHBox.addWidget(titleLabel)
257-
258-
# add widget to main layout
259-
self.main_layout.addLayout(outerHBox)
241+
# add the app logo and name view if screen dimensions permit it
242+
if self.screen_dimensions.height() >= 1000:
243+
recursive_id = QFontDatabase.addApplicationFont(":/font/RecursiveSans.ttf")
244+
font_family = QFontDatabase.applicationFontFamilies(recursive_id)[0]
245+
recursive = QFont(font_family)
246+
outerHBox = QHBoxLayout()
247+
titleLabel = QLabel("<h1>Slice</h1>")
248+
titleLabel.setStyleSheet("QLabel { font-size: 36px;}")
249+
titleLabel.setFont(recursive)
250+
titleLabel.setAlignment(Qt.AlignLeft | Qt.AlignBottom)
251+
iconLabel = QLabel()
252+
# note: commented block below shows how to use
253+
# svg embedded as a Python string literal
254+
# for QImage instantiation. The current
255+
# approach is better
256+
# svg_bytes = bytearray(svg_icon, encoding="utf-8")
257+
# qimage = QImage.fromData(svg_bytes)
258+
qimage = QImage(":/img/slice-icon.svg")
259+
pixmap = QPixmap.fromImage(qimage)
260+
iconLabel.setPixmap(pixmap)
261+
iconLabel.setFixedHeight(60)
262+
iconLabel.setFixedWidth(75)
263+
outerHBox.addWidget(iconLabel)
264+
outerHBox.addWidget(titleLabel)
265+
266+
# add widget to main layout
267+
self.main_layout.addLayout(outerHBox)
260268

261269
#
262270
# Font path free text entry field view (with DnD support)
@@ -443,7 +451,11 @@ def addStretch(self):
443451
self.main_layout.addStretch()
444452

445453
def setWindowCenterPosition(self):
446-
self.setGeometry(0, 0, 850, 900)
454+
# scale dimensions based upon available display size
455+
if self.screen_dimensions.height() >= 1000:
456+
self.setGeometry(0, 0, 850, 900)
457+
else:
458+
self.setGeometry(0, 0, 850, 750)
447459
rect = self.frameGeometry()
448460
centerCoord = QDesktopWidget().availableGeometry().center()
449461
rect.moveCenter(centerCoord)

0 commit comments

Comments
 (0)