r19536 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:28 UTC 2014
Author: jghali
Date: Wed Sep 24 21:48:28 2014
New Revision: 19536
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19536
Log:
#4648: improve reactivity when changing opacity in "Extended Image Effects"
Modified:
branches/Version14x/Scribus/scribus/extimageprops.cpp
branches/Version14x/Scribus/scribus/extimageprops.h
Modified: branches/Version14x/Scribus/scribus/extimageprops.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19536&path=/branches/Version14x/Scribus/scribus/extimageprops.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/extimageprops.cpp (original)
+++ branches/Version14x/Scribus/scribus/extimageprops.cpp Wed Sep 24 21:48:28 2014
@@ -21,6 +21,7 @@
#include <QHeaderView>
#include <QTableWidget>
#include <QTableWidgetItem>
+#include <QTimer>
#include "commonstrings.h"
#include "pageitem.h"
@@ -42,6 +43,13 @@
ExtImagePropsLayout->setMargin(6);
ExtImagePropsLayout->setSpacing(6);
viewWidget = 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;
@@ -121,6 +129,7 @@
textLabel2->setText( tr( "Opacity:" ) );
layout1->addWidget( textLabel2 );
opacitySpinBox = new QSpinBox( tab );
+ opacitySpinBox->setKeyboardTracking(false);
opacitySpinBox->setMinimum(0);
opacitySpinBox->setMaximum(100);
opacitySpinBox->setSingleStep(10);
@@ -298,8 +307,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(int)), this, SLOT(changedLayer()));
+ connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(delayedLayerChange()));
connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
}
}
@@ -380,8 +390,59 @@
void ExtImageProps::changedLayer()
{
+ updateLayerInfo();
+ if (doPreview)
+ {
+ viewWidget->Doc->LoadPict(currentItem->Pfile, currentItem->ItemNr, 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(int)), 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(int)), 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;
@@ -390,7 +451,7 @@
loadingInfo.blend = blendModesRev[blendMode->currentText()];
loadingInfo.opacity = qRound(opacitySpinBox->value() / 100.0 * 255);
}
- else if (currentItem->pixm.imgInfo.RequestProps.contains(layerIndex))
+ 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;
@@ -407,43 +468,7 @@
loadingInfo.useMask = true;
currentItem->pixm.imgInfo.RequestProps.insert(layerIndex, loadingInfo);
}
- if (doPreview)
- {
- viewWidget->Doc->LoadPict(currentItem->Pfile, currentItem->ItemNr, 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(int)), 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(int)), this, SLOT(changedLayer()));
- connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
+ currentItem->pixm.imgInfo.isRequest = true;
}
void ExtImageProps::noPath()
Modified: branches/Version14x/Scribus/scribus/extimageprops.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19536&path=/branches/Version14x/Scribus/scribus/extimageprops.h
==============================================================================
--- branches/Version14x/Scribus/scribus/extimageprops.h (original)
+++ branches/Version14x/Scribus/scribus/extimageprops.h Wed Sep 24 21:48:28 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