@@ -66,6 +66,12 @@ class MainWindow(QMainWindow):
66
66
def __init__ (self , parent = None ):
67
67
super ().__init__ (parent )
68
68
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
+
69
75
# default FontModel
70
76
self .font_model = FontModel (None )
71
77
@@ -232,31 +238,33 @@ def setUIMainLayout(self):
232
238
#
233
239
234
240
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 )
260
268
261
269
#
262
270
# Font path free text entry field view (with DnD support)
@@ -443,7 +451,11 @@ def addStretch(self):
443
451
self .main_layout .addStretch ()
444
452
445
453
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 )
447
459
rect = self .frameGeometry ()
448
460
centerCoord = QDesktopWidget ().availableGeometry ().center ()
449
461
rect .moveCenter (centerCoord )
0 commit comments