Merge branch 'feat/preview' into 'main'

feat: Added resizing option to preview window to reduce lag.

See merge request CodeByMrFinchum/OptimaLab35!41
This commit is contained in:
Mr Finchum 2025-02-12 14:44:15 +00:00
commit b548def5fe
4 changed files with 120 additions and 41 deletions

View file

@ -1,17 +1,23 @@
# Changelog
### 0.14.x
#### 0.14.1: Patch changelog
## 0.15.0: Preview Image Resizing Update
- Added the ability to change the preview image size dynamically.
- Previously, the image was processed and displayed at its original size, causing lag or unresponsiveness when adjusting the slider.
- Reducing the processed image size should help improve performance.
- Default preview image size is now **25%**, but users can adjust it between **10% and 100%**.
## 0.14.x
### 0.14.1: Patch changelog
- Updated the changelog to include missing entries.
#### 0.14.0: Code refactor (by Mr. Finch)
### 0.14.0: Code refactor (by Mr. Finch)
- Introduced constants and optimized the code.
### 0.13.x
#### 0.13.1: Fixed image processing
## 0.13.x
### 0.13.1: Fixed image processing
- Fixed a bug that made it impossible to process images.
#### 0.13.0: Requirements file (by Mr. Finch)
### 0.13.0: Requirements file (by Mr. Finch)
- Added a requirements file.
## 0.12.x

View file

@ -863,6 +863,7 @@ class PreviewWindow(QMainWindow, Ui_Preview_Window):
brightness = int(self.ui.brightness_spinBox.text()),
contrast = int(self.ui.contrast_spinBox.text()),
grayscale = self.ui.grayscale_checkBox.isChecked(),
resize = self.ui.scale_Slider.value(),
callback = self.display_image # Callback to update UI
)
self.threadpool.start(worker) # Run worker in a thread
@ -943,13 +944,14 @@ class ImageProcessorRunnable(QRunnable):
class ImageProcessorWorker(QRunnable):
"""Worker class to load and process the image in a separate thread."""
# ChatGPT
def __init__(self, path, optima_manager, brightness, contrast, grayscale, callback):
def __init__(self, path, optima_manager, brightness, contrast, grayscale, resize, callback):
super().__init__()
self.path = path
self.optima_manager = optima_manager
self.brightness = brightness
self.contrast = contrast
self.grayscale = grayscale
self.resize = resize
self.callback = callback # Function to call when processing is done
@Slot()
@ -963,7 +965,7 @@ class ImageProcessorWorker(QRunnable):
img = self.optima_manager.process_image_object(
image_input_file = self.path,
watermark = "PREVIEW",
resize=100,
resize = self.resize,
grayscale = self.grayscale,
brightness = self.brightness,
contrast = self.contrast

View file

@ -43,8 +43,8 @@ class Ui_Preview_Window(object):
self.widget.setObjectName(u"widget")
self.widget.setMinimumSize(QSize(160, 628))
self.widget.setMaximumSize(QSize(150, 16777215))
self.verticalLayout_5 = QVBoxLayout(self.widget)
self.verticalLayout_5.setObjectName(u"verticalLayout_5")
self.verticalLayout_4 = QVBoxLayout(self.widget)
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
self.groupBox_3 = QGroupBox(self.widget)
self.groupBox_3.setObjectName(u"groupBox_3")
self.verticalLayout_3 = QVBoxLayout(self.groupBox_3)
@ -60,7 +60,7 @@ class Ui_Preview_Window(object):
self.verticalLayout_3.addWidget(self.load_Button)
self.verticalLayout_5.addWidget(self.groupBox_3)
self.verticalLayout_4.addWidget(self.groupBox_3)
self.groupBox_2 = QGroupBox(self.widget)
self.groupBox_2.setObjectName(u"groupBox_2")
@ -87,7 +87,7 @@ class Ui_Preview_Window(object):
self.verticalLayout.addWidget(self.reset_brightness_Button)
self.verticalLayout_5.addWidget(self.groupBox_2)
self.verticalLayout_4.addWidget(self.groupBox_2)
self.groupBox = QGroupBox(self.widget)
self.groupBox.setObjectName(u"groupBox")
@ -114,7 +114,7 @@ class Ui_Preview_Window(object):
self.verticalLayout_2.addWidget(self.reset_contrast_Button)
self.verticalLayout_5.addWidget(self.groupBox)
self.verticalLayout_4.addWidget(self.groupBox)
self.groupBox_5 = QGroupBox(self.widget)
self.groupBox_5.setObjectName(u"groupBox_5")
@ -126,43 +126,58 @@ class Ui_Preview_Window(object):
self.gridLayout.addWidget(self.grayscale_checkBox, 0, 0, 1, 1)
self.verticalLayout_5.addWidget(self.groupBox_5)
self.verticalLayout_4.addWidget(self.groupBox_5)
self.verticalSpacer = QSpacerItem(20, 219, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
self.verticalLayout_5.addItem(self.verticalSpacer)
self.verticalLayout_4.addItem(self.verticalSpacer)
self.groupBox_4 = QGroupBox(self.widget)
self.groupBox_4.setObjectName(u"groupBox_4")
self.verticalLayout_4 = QVBoxLayout(self.groupBox_4)
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
self.gridLayout_2 = QGridLayout(self.groupBox_4)
self.gridLayout_2.setObjectName(u"gridLayout_2")
self.live_update = QCheckBox(self.groupBox_4)
self.live_update.setObjectName(u"live_update")
self.live_update.setChecked(True)
self.verticalLayout_4.addWidget(self.live_update)
self.gridLayout_2.addWidget(self.live_update, 0, 0, 1, 1)
self.scale_label = QLabel(self.groupBox_4)
self.scale_label.setObjectName(u"scale_label")
self.gridLayout_2.addWidget(self.scale_label, 0, 1, 1, 1)
self.scale_Slider = QSlider(self.groupBox_4)
self.scale_Slider.setObjectName(u"scale_Slider")
self.scale_Slider.setMinimum(10)
self.scale_Slider.setMaximum(100)
self.scale_Slider.setPageStep(10)
self.scale_Slider.setValue(25)
self.scale_Slider.setOrientation(Qt.Horizontal)
self.gridLayout_2.addWidget(self.scale_Slider, 1, 0, 1, 2)
self.update_Button = QPushButton(self.groupBox_4)
self.update_Button.setObjectName(u"update_Button")
self.update_Button.setEnabled(False)
self.update_Button.setAutoFillBackground(False)
self.verticalLayout_4.addWidget(self.update_Button)
self.gridLayout_2.addWidget(self.update_Button, 2, 0, 1, 2)
self.checkBox = QCheckBox(self.groupBox_4)
self.checkBox.setObjectName(u"checkBox")
self.checkBox.setLayoutDirection(Qt.LeftToRight)
self.checkBox.setChecked(True)
self.verticalLayout_4.addWidget(self.checkBox)
self.gridLayout_2.addWidget(self.checkBox, 3, 0, 1, 2)
self.close_Button = QPushButton(self.groupBox_4)
self.close_Button.setObjectName(u"close_Button")
self.verticalLayout_4.addWidget(self.close_Button)
self.gridLayout_2.addWidget(self.close_Button, 4, 0, 1, 2)
self.verticalLayout_5.addWidget(self.groupBox_4)
self.verticalLayout_4.addWidget(self.groupBox_4)
self.horizontalLayout.addWidget(self.widget)
@ -170,7 +185,7 @@ class Ui_Preview_Window(object):
Preview_Window.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(Preview_Window)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 875, 27))
self.menubar.setGeometry(QRect(0, 0, 875, 22))
Preview_Window.setMenuBar(self.menubar)
self.retranslateUi(Preview_Window)
@ -179,6 +194,7 @@ class Ui_Preview_Window(object):
self.contrast_Slider.valueChanged.connect(self.contrast_spinBox.setValue)
self.contrast_spinBox.valueChanged.connect(self.contrast_Slider.setValue)
self.live_update.toggled.connect(self.update_Button.setDisabled)
self.scale_Slider.valueChanged.connect(self.scale_label.setNum)
QMetaObject.connectSlotsByName(Preview_Window)
# setupUi
@ -212,6 +228,13 @@ class Ui_Preview_Window(object):
self.live_update.setToolTip(QCoreApplication.translate("Preview_Window", u"Live update applies changes instantly. If the app becomes unresponsive or lags, disable this option.", None))
#endif // QT_CONFIG(tooltip)
self.live_update.setText(QCoreApplication.translate("Preview_Window", u"Live refresh", None))
#if QT_CONFIG(tooltip)
self.scale_label.setToolTip(QCoreApplication.translate("Preview_Window", u"Sets the resize value for the preview image. A high value may cause the application to freeze.", None))
#endif // QT_CONFIG(tooltip)
self.scale_label.setText(QCoreApplication.translate("Preview_Window", u"25", None))
#if QT_CONFIG(tooltip)
self.scale_Slider.setToolTip(QCoreApplication.translate("Preview_Window", u"Sets the resize value for the preview image. A high value may cause the application to freeze.", None))
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(tooltip)
self.update_Button.setToolTip(QCoreApplication.translate("Preview_Window", u"Apply Changes to Preview", None))
#endif // QT_CONFIG(tooltip)

View file

@ -54,7 +54,7 @@
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
@ -202,8 +202,8 @@
<property name="title">
<string>Behavior</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="live_update">
<property name="toolTip">
<string>Live update applies changes instantly. If the app becomes unresponsive or lags, disable this option.</string>
@ -216,7 +216,39 @@
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QLabel" name="scale_label">
<property name="toolTip">
<string>Sets the resize value for the preview image. A high value may cause the application to freeze.</string>
</property>
<property name="text">
<string>25</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QSlider" name="scale_Slider">
<property name="toolTip">
<string>Sets the resize value for the preview image. A high value may cause the application to freeze.</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>10</number>
</property>
<property name="value">
<number>25</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="update_Button">
<property name="enabled">
<bool>false</bool>
@ -232,7 +264,7 @@
</property>
</widget>
</item>
<item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="toolTip">
<string>Enable to copy adjustments to the main window upon closing</string>
@ -248,7 +280,7 @@
</property>
</widget>
</item>
<item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="close_Button">
<property name="toolTip">
<string/>
@ -272,7 +304,7 @@
<x>0</x>
<y>0</y>
<width>875</width>
<height>27</height>
<height>22</height>
</rect>
</property>
</widget>
@ -359,5 +391,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>scale_Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>scale_label</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>783</x>
<y>644</y>
</hint>
<hint type="destinationlabel">
<x>831</x>
<y>619</y>
</hint>
</hints>
</connection>
</connections>
</ui>