Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 50f09c4

Browse files
authored
Merge pull request #39 from MemerGamer/app-fixes
App fixes
2 parents bfc349c + b6285bb commit 50f09c4

File tree

9 files changed

+306
-268
lines changed

9 files changed

+306
-268
lines changed

src/core/main.py

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import sys
32
import json
43
from pathlib import Path
@@ -7,9 +6,12 @@
76
QWidget,
87
QDialog,
98
)
10-
from PySide6.QtCore import QFile, Signal
11-
from PySide6.QtUiTools import QUiLoader
9+
from PySide6.QtCore import Signal
1210
from PySide6.QtGui import QPixmap
11+
from PySide6.QtCore import Qt
12+
from PySide6.QtGui import QPixmap
13+
from PySide6.QtWidgets import QSizePolicy
14+
1315

1416
# Add the parent directory of 'src' to sys.path
1517
current_dir = Path(__file__).resolve().parent
@@ -27,6 +29,7 @@
2729
# UI imports
2830
from src.ui.settings_ui import Ui_Form
2931
from src.ui.videoeditor_ui import Ui_Form as Ui_VideoEditor
32+
from src.ui.form_ui import Ui_Main
3033

3134
# Core imports
3235
from src.core.project_creation_dialog import ProjectCreationDialog
@@ -54,14 +57,15 @@ def __init__(self, parent=None):
5457
self.load_ui()
5558

5659
@logger.catch
57-
def apply_stylesheet(self):
58-
"""Apply the stylesheet to the main window and update the image based on the theme"""
60+
def resizeEvent(self, event):
61+
"""Resize event for the main window"""
62+
super().resizeEvent(event)
63+
self.update_image()
5964

60-
# Set the custom stylesheet based on the current theme
61-
self.customStyleSheet = f"background-color: {self.current_theme['background']}; color: {self.current_theme['font']}; border-color: {self.current_theme['primary']}; font-size: {self.settings['fontSize']}px; font-family: {self.settings['fontFamily']}; "
62-
self.setStyleSheet(self.customStyleSheet)
65+
@logger.catch
66+
def update_image(self):
67+
"""Update the image based on the theme and resize event."""
6368

64-
# Check the theme name and update the image
6569
if (
6670
"latte" in self.current_theme["name"].lower()
6771
or "light" in self.current_theme["name"].lower()
@@ -70,22 +74,37 @@ def apply_stylesheet(self):
7074
else:
7175
image_path = "docs/_static/ManimStudioLogoDark.png"
7276

73-
self.ui.label.setPixmap(QPixmap(image_path))
77+
pixmap = QPixmap(image_path)
78+
if not pixmap.isNull():
79+
scaledPixmap = pixmap.scaled(
80+
self.ui.label.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation
81+
)
82+
self.ui.label.setPixmap(scaledPixmap)
83+
84+
self.ui.label.setAlignment(Qt.AlignCenter)
85+
86+
@logger.catch
87+
def apply_stylesheet(self):
88+
"""Apply the stylesheet to the main window and update the image based on the theme"""
89+
90+
# Set the custom stylesheet based on the current theme
91+
self.customStyleSheet = f"background-color: {self.current_theme['background']}; color: {self.current_theme['font']}; border-color: {self.current_theme['primary']}; font-size: {self.settings['fontSize']}px; font-family: {self.settings['fontFamily']}; "
92+
self.setStyleSheet(self.customStyleSheet)
93+
94+
# Update the image
95+
self.update_image()
7496

7597
self.styleSheetUpdated.emit(self.customStyleSheet)
7698
logger.info("Stylesheet applied")
7799

78100
@logger.catch
79101
def load_ui(self):
80102
"""Load the UI from the .ui file"""
81-
loader = QUiLoader()
82103

83-
path = Path(__file__).resolve().parent.parent / "ui" / "form.ui"
84-
ui_file = QFile(path)
85-
ui_file.open(QFile.ReadOnly)
86-
self.ui = loader.load(ui_file, self)
87-
ui_file.close()
104+
self.ui = Ui_Main()
105+
self.ui.setupUi(self)
88106

107+
self.ui.label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
89108
# Apply the theme
90109
self.apply_stylesheet()
91110

src/ui/form.ui

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,38 @@
99
<rect>
1010
<x>0</x>
1111
<y>0</y>
12-
<width>420</width>
13-
<height>240</height>
12+
<width>626</width>
13+
<height>328</height>
1414
</rect>
1515
</property>
1616
<property name="sizePolicy">
17-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
17+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
1818
<horstretch>0</horstretch>
1919
<verstretch>0</verstretch>
2020
</sizepolicy>
2121
</property>
2222
<property name="minimumSize">
2323
<size>
24-
<width>420</width>
25-
<height>240</height>
24+
<width>0</width>
25+
<height>0</height>
2626
</size>
2727
</property>
2828
<property name="maximumSize">
2929
<size>
30-
<width>420</width>
31-
<height>240</height>
30+
<width>16777215</width>
31+
<height>16777215</height>
3232
</size>
3333
</property>
3434
<property name="sizeIncrement">
3535
<size>
36-
<width>1</width>
37-
<height>1</height>
36+
<width>0</width>
37+
<height>0</height>
3838
</size>
3939
</property>
4040
<property name="baseSize">
4141
<size>
42-
<width>1</width>
43-
<height>1</height>
42+
<width>0</width>
43+
<height>0</height>
4444
</size>
4545
</property>
4646
<property name="palette">
@@ -494,24 +494,30 @@
494494
</property>
495495
<layout class="QVBoxLayout" name="verticalLayout">
496496
<item>
497-
<layout class="QGridLayout" name="gridLayout">
497+
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0" columnstretch="0,0,0,0,0" rowminimumheight="0,0,0,0,0,0" columnminimumwidth="0,0,0,0,0">
498498
<item row="0" column="1">
499499
<widget class="QLabel" name="label">
500500
<property name="enabled">
501501
<bool>true</bool>
502502
</property>
503503
<property name="sizePolicy">
504-
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
504+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
505505
<horstretch>0</horstretch>
506506
<verstretch>0</verstretch>
507507
</sizepolicy>
508508
</property>
509-
<property name="maximumSize">
509+
<property name="minimumSize">
510510
<size>
511511
<width>100</width>
512512
<height>100</height>
513513
</size>
514514
</property>
515+
<property name="maximumSize">
516+
<size>
517+
<width>16777215</width>
518+
<height>16777215</height>
519+
</size>
520+
</property>
515521
<property name="sizeIncrement">
516522
<size>
517523
<width>0</width>
@@ -536,7 +542,7 @@
536542
<pixmap>docs/_static/ManimStudioLogoDark.png</pixmap>
537543
</property>
538544
<property name="scaledContents">
539-
<bool>true</bool>
545+
<bool>false</bool>
540546
</property>
541547
<property name="alignment">
542548
<set>Qt::AlignCenter</set>
@@ -569,7 +575,7 @@
569575
<item row="5" column="1" colspan="4">
570576
<widget class="QPushButton" name="settingsBtn">
571577
<property name="sizePolicy">
572-
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
578+
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
573579
<horstretch>0</horstretch>
574580
<verstretch>0</verstretch>
575581
</sizepolicy>
@@ -581,6 +587,18 @@
581587
</item>
582588
<item row="0" column="2" rowspan="2" colspan="3">
583589
<widget class="QTextEdit" name="textEdit">
590+
<property name="sizePolicy">
591+
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
592+
<horstretch>0</horstretch>
593+
<verstretch>0</verstretch>
594+
</sizepolicy>
595+
</property>
596+
<property name="minimumSize">
597+
<size>
598+
<width>500</width>
599+
<height>200</height>
600+
</size>
601+
</property>
584602
<property name="readOnly">
585603
<bool>true</bool>
586604
</property>

src/ui/form_ui.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ def setupUi(self, Main):
2323
if not Main.objectName():
2424
Main.setObjectName(u"Main")
2525
Main.setWindowModality(Qt.WindowModal)
26-
Main.resize(420, 240)
27-
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
26+
Main.resize(626, 328)
27+
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
2828
sizePolicy.setHorizontalStretch(0)
2929
sizePolicy.setVerticalStretch(0)
3030
sizePolicy.setHeightForWidth(Main.sizePolicy().hasHeightForWidth())
3131
Main.setSizePolicy(sizePolicy)
32-
Main.setMinimumSize(QSize(420, 240))
33-
Main.setMaximumSize(QSize(420, 240))
34-
Main.setSizeIncrement(QSize(1, 1))
35-
Main.setBaseSize(QSize(1, 1))
32+
Main.setMinimumSize(QSize(0, 0))
33+
Main.setMaximumSize(QSize(16777215, 16777215))
34+
Main.setSizeIncrement(QSize(0, 0))
35+
Main.setBaseSize(QSize(0, 0))
3636
palette = QPalette()
3737
brush = QBrush(QColor(0, 0, 0, 255))
3838
brush.setStyle(Qt.SolidPattern)
@@ -127,19 +127,17 @@ def setupUi(self, Main):
127127
self.label = QLabel(Main)
128128
self.label.setObjectName(u"label")
129129
self.label.setEnabled(True)
130-
sizePolicy1 = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
131-
sizePolicy1.setHorizontalStretch(0)
132-
sizePolicy1.setVerticalStretch(0)
133-
sizePolicy1.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
134-
self.label.setSizePolicy(sizePolicy1)
135-
self.label.setMaximumSize(QSize(100, 100))
130+
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
131+
self.label.setSizePolicy(sizePolicy)
132+
self.label.setMinimumSize(QSize(100, 100))
133+
self.label.setMaximumSize(QSize(16777215, 16777215))
136134
self.label.setSizeIncrement(QSize(0, 0))
137135
self.label.setBaseSize(QSize(50, 50))
138136
font = QFont()
139137
font.setPointSize(1)
140138
self.label.setFont(font)
141139
self.label.setPixmap(QPixmap(u"docs/_static/ManimStudioLogoDark.png"))
142-
self.label.setScaledContents(True)
140+
self.label.setScaledContents(False)
143141
self.label.setAlignment(Qt.AlignCenter)
144142
self.label.setWordWrap(False)
145143
self.label.setMargin(0)
@@ -159,16 +157,22 @@ def setupUi(self, Main):
159157

160158
self.settingsBtn = QPushButton(Main)
161159
self.settingsBtn.setObjectName(u"settingsBtn")
162-
sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
163-
sizePolicy2.setHorizontalStretch(0)
164-
sizePolicy2.setVerticalStretch(0)
165-
sizePolicy2.setHeightForWidth(self.settingsBtn.sizePolicy().hasHeightForWidth())
166-
self.settingsBtn.setSizePolicy(sizePolicy2)
160+
sizePolicy1 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
161+
sizePolicy1.setHorizontalStretch(0)
162+
sizePolicy1.setVerticalStretch(0)
163+
sizePolicy1.setHeightForWidth(self.settingsBtn.sizePolicy().hasHeightForWidth())
164+
self.settingsBtn.setSizePolicy(sizePolicy1)
167165

168166
self.gridLayout.addWidget(self.settingsBtn, 5, 1, 1, 4)
169167

170168
self.textEdit = QTextEdit(Main)
171169
self.textEdit.setObjectName(u"textEdit")
170+
sizePolicy2 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
171+
sizePolicy2.setHorizontalStretch(0)
172+
sizePolicy2.setVerticalStretch(0)
173+
sizePolicy2.setHeightForWidth(self.textEdit.sizePolicy().hasHeightForWidth())
174+
self.textEdit.setSizePolicy(sizePolicy2)
175+
self.textEdit.setMinimumSize(QSize(500, 200))
172176
self.textEdit.setReadOnly(True)
173177

174178
self.gridLayout.addWidget(self.textEdit, 0, 2, 2, 3)

src/ui/project_creation_dialog.ui

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,39 @@
1313
<property name="windowTitle">
1414
<string>Form</string>
1515
</property>
16-
<widget class="QWidget" name="gridLayoutWidget">
17-
<property name="geometry">
18-
<rect>
19-
<x>9</x>
20-
<y>9</y>
21-
<width>731</width>
22-
<height>211</height>
23-
</rect>
24-
</property>
25-
<layout class="QGridLayout" name="gridLayout">
26-
<item row="0" column="1">
27-
<widget class="QLineEdit" name="projectNameLineEdit"/>
28-
</item>
29-
<item row="0" column="0">
30-
<widget class="QLabel" name="projectNameLabel">
31-
<property name="text">
32-
<string>Project name:</string>
33-
</property>
34-
</widget>
35-
</item>
36-
<item row="1" column="0">
37-
<widget class="QLabel" name="folderSelectLabel">
38-
<property name="text">
39-
<string>Select folder:</string>
40-
</property>
41-
</widget>
42-
</item>
43-
<item row="1" column="1">
44-
<widget class="QComboBox" name="folderSelectComboBox"/>
45-
</item>
46-
<item row="2" column="0" colspan="2">
47-
<widget class="QPushButton" name="createProjectPushButton">
48-
<property name="text">
49-
<string>Create Project</string>
50-
</property>
51-
</widget>
52-
</item>
53-
</layout>
54-
</widget>
16+
<layout class="QGridLayout" name="gridLayout_2">
17+
<item row="0" column="0">
18+
<layout class="QGridLayout" name="gridLayout">
19+
<item row="0" column="1">
20+
<widget class="QLineEdit" name="projectNameLineEdit"/>
21+
</item>
22+
<item row="0" column="0">
23+
<widget class="QLabel" name="projectNameLabel">
24+
<property name="text">
25+
<string>Project name:</string>
26+
</property>
27+
</widget>
28+
</item>
29+
<item row="1" column="0">
30+
<widget class="QLabel" name="folderSelectLabel">
31+
<property name="text">
32+
<string>Select folder:</string>
33+
</property>
34+
</widget>
35+
</item>
36+
<item row="1" column="1">
37+
<widget class="QComboBox" name="folderSelectComboBox"/>
38+
</item>
39+
<item row="2" column="0" colspan="2">
40+
<widget class="QPushButton" name="createProjectPushButton">
41+
<property name="text">
42+
<string>Create Project</string>
43+
</property>
44+
</widget>
45+
</item>
46+
</layout>
47+
</item>
48+
</layout>
5549
</widget>
5650
<resources/>
5751
<connections/>

0 commit comments

Comments
 (0)