r20325 by craig - Barcode update from Terry, with timer for redrawing to smooth GUI operation/redraw
scribus-commit
scribus-commit at lists.scribus.net
Sat Aug 15 08:47:37 UTC 2015
Author: craig
Date: Sat Aug 15 08:47:37 2015
New Revision: 20325
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20325
Log:
Barcode update from Terry, with timer for redrawing to smooth GUI operation/redraw
Modified:
trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20325&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp Sat Aug 15 08:47:37 2015
@@ -20,6 +20,7 @@
#include <QTextStream>
#include <QStandardItemModel>
+#include <QTimer>
BarcodeType::BarcodeType(const QString &cmd, const QString &exa, const QString &exaop)
{
@@ -259,7 +260,6 @@
*
*/
-// useSamples = true;
guiColor = ui.codeEdit->palette().color(QPalette::Window);
ui.okButton->setText(CommonStrings::tr_OK);
@@ -293,13 +293,25 @@
tmpFile = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.png");
psFile = QDir::toNativeSeparators(ScPaths::getTempFileDir() + "bcode.ps");
+ paintBarcodeTimer=new QTimer(this);
+ paintBarcodeTimer->setSingleShot(true);
+ connect(paintBarcodeTimer, SIGNAL(timeout()), this, SLOT(paintBarcode()));
+
bcComboChanged();
+
}
BarcodeGenerator::~BarcodeGenerator()
{
QFile::remove(psFile);
QFile::remove(tmpFile);
+
+ if (paintBarcodeTimer)
+ {
+ delete paintBarcodeTimer;
+ paintBarcodeTimer=NULL;
+ }
+
}
void BarcodeGenerator::updateOptions()
@@ -385,15 +397,12 @@
ui.okButton->setEnabled(true);
QString s = ui.bcCombo->currentText();
-// if (useSamples)
-// {
- ui.codeEdit->blockSignals(true);
- ui.codeEdit->setText(map[s].exampleContents);
- ui.codeEdit->blockSignals(false);
- ui.optionsEdit->blockSignals(true);
- ui.optionsEdit->setText(map[s].exampleOptions);
- ui.optionsEdit->blockSignals(false);
-// }
+ ui.codeEdit->blockSignals(true);
+ ui.codeEdit->setText(map[s].exampleContents);
+ ui.codeEdit->blockSignals(false);
+ ui.optionsEdit->blockSignals(true);
+ ui.optionsEdit->setText(map[s].exampleOptions);
+ ui.optionsEdit->blockSignals(false);
QString enc=map[s].command;
ui.includetextCheck->setEnabled(resincludetextAvail[enc]);
@@ -405,7 +414,14 @@
updateUIFromOptionsText();
- paintBarcode();
+ enqueuePaintBarcode(0);
+}
+
+void BarcodeGenerator::enqueuePaintBarcode(int delay)
+{
+ ui.okButton->setEnabled(false);
+// paintBarcode();
+ paintBarcodeTimer->start(delay);
}
void BarcodeGenerator::updateOptionsTextFromUI() {
@@ -460,12 +476,12 @@
if (ui.formatCombo->currentIndex() != 0)
{
QString t=ui.formatCombo->currentText();
- if (!opts.contains(QRegExp("\\b"+vlbl+"=.*\\b")))
+ if (!opts.contains(QRegExp("\\b"+QRegExp::escape(vlbl)+"=.*\\b")))
opts.append(" "+vlbl+"="+t);
else
- opts.replace(QRegExp("\\b"+vlbl+"=\\S*\\b"),vlbl+"="+t);
+ opts.replace(QRegExp("\\b"+QRegExp::escape(vlbl)+"=\\S*\\b"),vlbl+"="+t);
} else {
- opts.replace(QRegExp("\\b"+vlbl+"=\\S*\\b")," ");
+ opts.replace(QRegExp("\\b"+QRegExp::escape(vlbl)+"=\\S*\\b")," ");
}
if (ui.eccCombo->currentIndex() != 0) {
@@ -538,49 +554,49 @@
void BarcodeGenerator::on_includetextCheck_stateChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_guardwhitespaceCheck_stateChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_includecheckCheck_stateChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_includecheckintextCheck_stateChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_parseCheck_stateChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_parsefncCheck_stateChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_formatCombo_currentIndexChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::on_eccCombo_currentIndexChanged(int)
{
updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::paintColorSample(QLabel *l, const ScColor & c)
@@ -599,8 +615,7 @@
bgColor = d.selectedColor();
ui.bgLabel->setToolTip(d.selectedColorName());
paintColorSample(ui.bgLabel, bgColor);
- updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::lnColorButton_pressed()
@@ -611,8 +626,7 @@
lnColor = d.selectedColor();
ui.linesLabel->setToolTip(d.selectedColorName());
paintColorSample(ui.linesLabel, lnColor);
- updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::txtColorButton_pressed()
@@ -623,8 +637,7 @@
txtColor = d.selectedColor();
ui.txtLabel->setToolTip(d.selectedColorName());
paintColorSample(ui.txtLabel, txtColor);
- updateOptionsTextFromUI();
- paintBarcode();
+ enqueuePaintBarcode(0);
}
void BarcodeGenerator::okButton_pressed()
@@ -661,20 +674,13 @@
void BarcodeGenerator::codeEdit_textChanged(const QString& s)
{
-// useSamples = false;
- paintBarcode();
-}
-
-void BarcodeGenerator::optionsEdit_textChanged(const QString& s)
-{
-
+ enqueuePaintBarcode(250);
}
void BarcodeGenerator::on_optionsEdit_textChanged(const QString &s )
{
-// useSamples = false;
updateUIFromOptionsText();
- paintBarcode();
+ enqueuePaintBarcode(250);
}
bool BarcodeGenerator::paintBarcode(const QString &fileName, int dpi)
@@ -742,13 +748,11 @@
{
// TODO capture gs output and display handled errors
ui.sampleLabel->setText("<qt>" + tr("Barcode incomplete") + "</qt>");
- ui.okButton->setEnabled(false);
}
return retval;
}
void BarcodeGenerator::resetButton_clicked()
{
-// useSamples = true;
bcComboChanged();
}
Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20325&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h (original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.h Sat Aug 15 08:47:37 2015
@@ -14,6 +14,7 @@
#include <QDialog>
#include <QLabel>
#include <QString>
+#include <QTimer>
#include "sccolor.h"
@@ -71,6 +72,8 @@
//! \brief BC/BC type mapping. QMap keys are used as BC names.
BarcodeMap map;
+ QTimer *paintBarcodeTimer;
+
//! \brief List of available barcode encoders.
QList<QString> encoderlist;
//! \brief Descriptions of each encoder.
@@ -115,9 +118,6 @@
QString tmpFile;
//! \brief A temporary PS file to store commants for Ghostscript.
QString psFile;
- /*! \brief Flag if user modified the codeEditor.
- To stop replacing his code with samples. */
- bool useSamples;
QColor guiColor;
/*! \brief Create bitmap for current BC.
@@ -128,7 +128,7 @@
\param dpi optional DPI value. Default is 72 for preview.
\retval bool true on success.
*/
- bool paintBarcode(const QString &fileName = QString(), int dpi = 72);
+// bool paintBarcode(const QString &fileName = QString(), int dpi = 72);
/*! \brief Create color preview.
Used for Color box feedback.
\param l A pointer to the sample QLabel
@@ -142,7 +142,11 @@
void updateOptionsTextFromUI();
void updateUIFromOptionsText();
+ private:
+ void enqueuePaintBarcode(int);
+
protected slots:
+ bool paintBarcode(const QString &fileName = QString(), int dpi = 72);
void bcComboChanged();
void bcComboChanged(int);
//void textCheck_changed();
More information about the scribus-commit
mailing list