r19537 by jghali - #4648: improve reactivity when changing opacity in "Extended Image Effects"
scribus-commit
scribus-commit at lists.scribus.net
Wed Sep 24 21:48:53 UTC 2014
Author: jghali
Date: Wed Sep 24 21:48:53 2014
New Revision: 19537
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19537
Log:
#4648: improve reactivity when changing opacity in "Extended Image Effects"
Modified:
trunk/Scribus/scribus/ui/extimageprops.cpp
trunk/Scribus/scribus/ui/extimageprops.h
Modified: trunk/Scribus/scribus/ui/extimageprops.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19537&path=/trunk/Scribus/scribus/ui/extimageprops.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/extimageprops.cpp (original)
+++ trunk/Scribus/scribus/ui/extimageprops.cpp Wed Sep 24 21:48:53 2014
@@ -20,6 +20,7 @@
#include <QHeaderView>
#include <QTableWidget>
#include <QTableWidgetItem>
+#include <QTimer>
#include "commonstrings.h"
#include "pageitem.h"
@@ -41,7 +42,14 @@
ExtImagePropsLayout = new QVBoxLayout( this );
ExtImagePropsLayout->setMargin(6);
ExtImagePropsLayout->setSpacing(6);
- m_view = view;
+ m_view = view;
+ m_timer = 0;
+ if (info->layerInfo.count() != 0)
+ {
+ m_timer = new QTimer(this);
+ m_timer->setSingleShot(true);
+ m_timer->setInterval(350);
+ }
currentItem = item;
currentLayer = 0;
originalInfo = *info;
@@ -308,8 +316,9 @@
layerTable->selectionModel()->clearSelection();
opacitySpinBox->setEnabled(false);
blendMode->setEnabled(false);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(changedLayer()));
connect(layerTable, SIGNAL(itemSelectionChanged()), this, SLOT(selLayer()));
- connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changedLayer()));
+ connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(delayedLayerChange()));
connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
}
}
@@ -392,17 +401,67 @@
void ExtImageProps::changedLayer()
{
+ updateLayerInfo();
+ if (doPreview)
+ {
+ m_view->Doc->loadPict(currentItem->Pfile, currentItem, true);
+ currentItem->update();
+ }
+}
+
+void ExtImageProps::delayedLayerChange()
+{
+ if (m_timer->isActive())
+ m_timer->stop();
+ updateLayerInfo();
+ m_timer->start();
+}
+
+void ExtImageProps::selLayer()
+{
+ QModelIndexList selectedRows = layerTable->selectionModel()->selectedRows();
+ if (selectedRows.count() <= 0)
+ {
+ currentLayer = -1;
+ opacitySpinBox->setEnabled(false);
+ blendMode->setEnabled(false);
+ return;
+ }
+
+ int selectedRow = selectedRows.at(0).row();
+ currentLayer = layerTable->rowCount() - selectedRow - 1;
+
+ disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(delayedLayerChange()));
+ disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
+ if ((currentItem->pixm.imgInfo.isRequest) && (currentItem->pixm.imgInfo.RequestProps.contains(currentLayer)))
+ {
+ opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.RequestProps[currentLayer].opacity / 255.0 * 100));
+ setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.RequestProps[currentLayer].blend]);
+ }
+ else
+ {
+ opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.layerInfo[currentLayer].opacity / 255.0 * 100));
+ setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.layerInfo[currentLayer].blend]);
+ }
+ opacitySpinBox->setEnabled(true);
+ blendMode->setEnabled(true);
+ connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(delayedLayerChange()));
+ connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
+}
+
+void ExtImageProps::updateLayerInfo()
+{
struct ImageLoadRequest loadingInfo;
- currentItem->pixm.imgInfo.isRequest = true;
+ bool isRequest = currentItem->pixm.imgInfo.isRequest;
for (int r = 0; r < layerTable->rowCount(); ++r)
{
int layerIndex = layerTable->rowCount() - r - 1;
if (currentLayer == layerIndex)
{
loadingInfo.blend = blendModesRev[blendMode->currentText()];
- loadingInfo.opacity = qRound(static_cast<int>(opacitySpinBox->value()) / 100.0 * 255);
- }
- else if (currentItem->pixm.imgInfo.RequestProps.contains(layerIndex))
+ loadingInfo.opacity = qRound(opacitySpinBox->value() / 100.0 * 255);
+ }
+ else if ((isRequest) && (currentItem->pixm.imgInfo.RequestProps.contains(layerIndex)))
{
loadingInfo.blend = currentItem->pixm.imgInfo.RequestProps[layerIndex].blend;
loadingInfo.opacity = currentItem->pixm.imgInfo.RequestProps[layerIndex].opacity;
@@ -419,43 +478,7 @@
loadingInfo.useMask = true;
currentItem->pixm.imgInfo.RequestProps.insert(layerIndex, loadingInfo);
}
- if (doPreview)
- {
- m_view->Doc->loadPict(currentItem->Pfile, currentItem, true);
- currentItem->update();
- }
-}
-
-void ExtImageProps::selLayer()
-{
- QModelIndexList selectedRows = layerTable->selectionModel()->selectedRows();
- if (selectedRows.count() <= 0)
- {
- currentLayer = -1;
- opacitySpinBox->setEnabled(false);
- blendMode->setEnabled(false);
- return;
- }
-
- int selectedRow = selectedRows.at(0).row();
- currentLayer = layerTable->rowCount() - selectedRow - 1;
-
- disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changedLayer()));
- disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
- if ((currentItem->pixm.imgInfo.isRequest) && (currentItem->pixm.imgInfo.RequestProps.contains(currentLayer)))
- {
- opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.RequestProps[currentLayer].opacity / 255.0 * 100));
- setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.RequestProps[currentLayer].blend]);
- }
- else
- {
- opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.layerInfo[currentLayer].opacity / 255.0 * 100));
- setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.layerInfo[currentLayer].blend]);
- }
- opacitySpinBox->setEnabled(true);
- blendMode->setEnabled(true);
- connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changedLayer()));
- connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
+ currentItem->pixm.imgInfo.isRequest = true;
}
void ExtImageProps::noPath()
Modified: trunk/Scribus/scribus/ui/extimageprops.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19537&path=/trunk/Scribus/scribus/ui/extimageprops.h
==============================================================================
--- trunk/Scribus/scribus/ui/extimageprops.h (original)
+++ trunk/Scribus/scribus/ui/extimageprops.h Wed Sep 24 21:48:53 2014
@@ -22,9 +22,11 @@
class QListWidgetItem;
class QPushButton;
class QTableWidget;
+class QTimer;
class ScribusView;
class PageItem;
+
#include "scribusapi.h"
#include "scimage.h"
@@ -65,6 +67,7 @@
void leaveCancel();
void changePreview();
void changedLayer();
+ void delayedLayerChange();
void selLayer();
void selPath(QListWidgetItem *c);
void noPath();
@@ -76,6 +79,9 @@
QHBoxLayout* layout1;
QHBoxLayout* layoutBottom;
+ QTimer* m_timer;
+
+ void updateLayerInfo();
};
#endif // EXTIMAGEPROPS_H
More information about the scribus-commit
mailing list