Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 24745 → Rev 24746

/trunk/Scribus/scribus/qtiocompressor.cpp
1,195 → 1,195
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
 
#include "qtiocompressor.h"
#include <zlib.h>
#include <QtCore/QDebug>
 
typedef Bytef ZlibByte;
typedef uInt ZlibSize;
 
class QtIOCompressorPrivate {
QtIOCompressor *q_ptr;
Q_DECLARE_PUBLIC(QtIOCompressor)
public:
enum State {
// Read state
NotReadFirstByte,
InStream,
EndOfStream,
// Write state
NoBytesWritten,
BytesWritten,
// Common
Closed,
Error
};
 
QtIOCompressorPrivate(QtIOCompressor *q_ptr, QIODevice *device, int compressionLevel, int bufferSize);
~QtIOCompressorPrivate();
void flushZlib(int flushMode);
bool writeBytes(ZlibByte *buffer, ZlibSize outputSize);
void setZlibError(const QString &erroMessage, int zlibErrorCode);
 
QIODevice *device;
bool manageDevice;
z_stream zlibStream;
const int compressionLevel;
const ZlibSize bufferSize;
ZlibByte *buffer;
State state;
QtIOCompressor::StreamFormat streamFormat;
};
 
/*!
\internal
*/
QtIOCompressorPrivate::QtIOCompressorPrivate(QtIOCompressor *q_ptr, QIODevice *device, int compressionLevel, int bufferSize)
:q_ptr(q_ptr)
,device(device)
,compressionLevel(compressionLevel)
,bufferSize(bufferSize)
,buffer(new ZlibByte[bufferSize])
,state(Closed)
,streamFormat(QtIOCompressor::ZlibFormat)
{
// Use default zlib memory management.
zlibStream.zalloc = Z_NULL;
zlibStream.zfree = Z_NULL;
zlibStream.opaque = Z_NULL;
}
 
/*!
\internal
*/
QtIOCompressorPrivate::~QtIOCompressorPrivate()
{
delete[] buffer;
}
 
/*!
\internal
Flushes the zlib stream.
*/
void QtIOCompressorPrivate::flushZlib(int flushMode)
{
// No input.
zlibStream.next_in = 0;
zlibStream.avail_in = 0;
int status;
do {
zlibStream.next_out = buffer;
zlibStream.avail_out = bufferSize;
status = deflate(&zlibStream, flushMode);
if (status != Z_OK && status != Z_STREAM_END) {
state = QtIOCompressorPrivate::Error;
setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor", "Internal zlib error when compressing: "), status);
return;
}
 
ZlibSize outputSize = bufferSize - zlibStream.avail_out;
 
// Try to write data from the buffer to to the underlying device, return on failure.
if (!writeBytes(buffer, outputSize))
return;
 
// If the mode is Z_FNISH we must loop until we get Z_STREAM_END,
// else we loop as long as zlib is able to fill the output buffer.
} while ((flushMode == Z_FINISH && status != Z_STREAM_END) || (flushMode != Z_FINISH && zlibStream.avail_out == 0));
 
if (flushMode == Z_FINISH)
Q_ASSERT(status == Z_STREAM_END);
else
Q_ASSERT(status == Z_OK);
}
 
/*!
\internal
Writes outputSize bytes from buffer to the inderlying device.
*/
bool QtIOCompressorPrivate::writeBytes(ZlibByte *buffer, ZlibSize outputSize)
{
Q_Q(QtIOCompressor);
ZlibSize totalBytesWritten = 0;
// Loop until all bytes are written to the underlying device.
do {
const qint64 bytesWritten = device->write(reinterpret_cast<char *>(buffer), outputSize);
if (bytesWritten == -1) {
q->setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor", "Error writing to underlying device: ") + device->errorString());
return false;
}
totalBytesWritten += bytesWritten;
} while (totalBytesWritten != outputSize);
 
// put up a flag so that the device will be flushed on close.
state = BytesWritten;
return true;
}
 
/*!
\internal
Sets the error string to errorMessage + zlib error string for zlibErrorCode
*/
void QtIOCompressorPrivate::setZlibError(const QString &errorMessage, int zlibErrorCode)
{
Q_Q(QtIOCompressor);
// Watch out, zlibErrorString may be null.
const char * const zlibErrorString = zError(zlibErrorCode);
QString errorString;
if (zlibErrorString)
errorString = errorMessage + zlibErrorString;
else
errorString = errorMessage + " Unknown error, code " + QString::number(zlibErrorCode);
 
q->setErrorString(errorString);
}
 
/*! \class QtIOCompressor
\brief The QtIOCompressor class is a QIODevice that compresses data streams.
 
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
 
#include "qtiocompressor.h"
#include <zlib.h>
#include <QtCore/QDebug>
 
typedef Bytef ZlibByte;
typedef uInt ZlibSize;
 
class QtIOCompressorPrivate {
QtIOCompressor *q_ptr;
Q_DECLARE_PUBLIC(QtIOCompressor)
public:
enum State {
// Read state
NotReadFirstByte,
InStream,
EndOfStream,
// Write state
NoBytesWritten,
BytesWritten,
// Common
Closed,
Error
};
 
QtIOCompressorPrivate(QtIOCompressor *q_ptr, QIODevice *device, int compressionLevel, int bufferSize);
~QtIOCompressorPrivate();
void flushZlib(int flushMode);
bool writeBytes(ZlibByte *buffer, ZlibSize outputSize);
void setZlibError(const QString &erroMessage, int zlibErrorCode);
 
QIODevice *device;
bool manageDevice;
z_stream zlibStream;
const int compressionLevel;
const ZlibSize bufferSize;
ZlibByte *buffer;
State state;
QtIOCompressor::StreamFormat streamFormat;
};
 
/*!
\internal
*/
QtIOCompressorPrivate::QtIOCompressorPrivate(QtIOCompressor *q_ptr, QIODevice *device, int compressionLevel, int bufferSize)
:q_ptr(q_ptr)
,device(device)
,compressionLevel(compressionLevel)
,bufferSize(bufferSize)
,buffer(new ZlibByte[bufferSize])
,state(Closed)
,streamFormat(QtIOCompressor::ZlibFormat)
{
// Use default zlib memory management.
zlibStream.zalloc = Z_NULL;
zlibStream.zfree = Z_NULL;
zlibStream.opaque = Z_NULL;
}
 
/*!
\internal
*/
QtIOCompressorPrivate::~QtIOCompressorPrivate()
{
delete[] buffer;
}
 
/*!
\internal
Flushes the zlib stream.
*/
void QtIOCompressorPrivate::flushZlib(int flushMode)
{
// No input.
zlibStream.next_in = 0;
zlibStream.avail_in = 0;
int status;
do {
zlibStream.next_out = buffer;
zlibStream.avail_out = bufferSize;
status = deflate(&zlibStream, flushMode);
if (status != Z_OK && status != Z_STREAM_END) {
state = QtIOCompressorPrivate::Error;
setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor", "Internal zlib error when compressing: "), status);
return;
}
 
ZlibSize outputSize = bufferSize - zlibStream.avail_out;
 
// Try to write data from the buffer to to the underlying device, return on failure.
if (!writeBytes(buffer, outputSize))
return;
 
// If the mode is Z_FNISH we must loop until we get Z_STREAM_END,
// else we loop as long as zlib is able to fill the output buffer.
} while ((flushMode == Z_FINISH && status != Z_STREAM_END) || (flushMode != Z_FINISH && zlibStream.avail_out == 0));
 
if (flushMode == Z_FINISH)
Q_ASSERT(status == Z_STREAM_END);
else
Q_ASSERT(status == Z_OK);
}
 
/*!
\internal
Writes outputSize bytes from buffer to the inderlying device.
*/
bool QtIOCompressorPrivate::writeBytes(ZlibByte *buffer, ZlibSize outputSize)
{
Q_Q(QtIOCompressor);
ZlibSize totalBytesWritten = 0;
// Loop until all bytes are written to the underlying device.
do {
const qint64 bytesWritten = device->write(reinterpret_cast<char *>(buffer), outputSize);
if (bytesWritten == -1) {
q->setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor", "Error writing to underlying device: ") + device->errorString());
return false;
}
totalBytesWritten += bytesWritten;
} while (totalBytesWritten != outputSize);
 
// put up a flag so that the device will be flushed on close.
state = BytesWritten;
return true;
}
 
/*!
\internal
Sets the error string to errorMessage + zlib error string for zlibErrorCode
*/
void QtIOCompressorPrivate::setZlibError(const QString &errorMessage, int zlibErrorCode)
{
Q_Q(QtIOCompressor);
// Watch out, zlibErrorString may be null.
const char * const zlibErrorString = zError(zlibErrorCode);
QString errorString;
if (zlibErrorString)
errorString = errorMessage + zlibErrorString;
else
errorString = errorMessage + " Unknown error, code " + QString::number(zlibErrorCode);
 
q->setErrorString(errorString);
}
 
/*! \class QtIOCompressor
\brief The QtIOCompressor class is a QIODevice that compresses data streams.
 
A QtIOCompressor object is constructed with a pointer to an
underlying QIODevice. Data written to the QtIOCompressor object
will be compressed before it is written to the underlying
197,59 → 197,59
the data will be read from the underlying device and then
decompressed.
 
QtIOCompressor is a sequential device, which means that it does
not support seeks or random access. Internally, QtIOCompressor
uses the zlib library to compress and uncompress data.
 
Usage examples:
Writing compressed data to a file:
\code
QFile file("foo");
QtIOCompressor compressor(&file);
compressor.open(QIODevice::WriteOnly);
compressor.write(QByteArray() << "The quick brown fox");
compressor.close();
\endcode
 
Reading compressed data from a file:
\code
QFile file("foo");
QtIOCompressor compressor(&file);
compressor.open(QIODevice::ReadOnly);
const QByteArray text = compressor.readAll();
compressor.close();
\endcode
 
QtIOCompressor can also read and write compressed data in
different compressed formats, ref. StreamFormat. Use
setStreamFormat() before open() to select format.
*/
 
/*!
\enum QtIOCompressor::StreamFormat
This enum specifies which stream format to use.
 
\value ZlibFormat: This is the default and has the smallest overhead.
 
\value GzipFormat: This format is compatible with the gzip file
format, but has more overhead than ZlibFormat. Note: requires zlib
version 1.2.x or higher at runtime.
 
\value RawZipFormat: This is compatible with the most common
compression method of the data blocks contained in ZIP
archives. Note: ZIP file headers are not read or generated, so
setting this format, by itself, does not let QtIOCompressor read
or write ZIP files. Ref. the ziplist example program.
 
\sa setStreamFormat()
*/
 
/*!
Constructs a QtIOCompressor using the given \a device as the underlying device.
 
The allowed value range for \a compressionLevel is 0 to 9, where 0 means no compression
and 9 means maximum compression. The default value is 6.
QtIOCompressor is a sequential device, which means that it does
not support seeks or random access. Internally, QtIOCompressor
uses the zlib library to compress and uncompress data.
 
Usage examples:
Writing compressed data to a file:
\code
QFile file("foo");
QtIOCompressor compressor(&file);
compressor.open(QIODevice::WriteOnly);
compressor.write(QByteArray() << "The quick brown fox");
compressor.close();
\endcode
 
Reading compressed data from a file:
\code
QFile file("foo");
QtIOCompressor compressor(&file);
compressor.open(QIODevice::ReadOnly);
const QByteArray text = compressor.readAll();
compressor.close();
\endcode
 
QtIOCompressor can also read and write compressed data in
different compressed formats, ref. StreamFormat. Use
setStreamFormat() before open() to select format.
*/
 
/*!
\enum QtIOCompressor::StreamFormat
This enum specifies which stream format to use.
 
\value ZlibFormat: This is the default and has the smallest overhead.
 
\value GzipFormat: This format is compatible with the gzip file
format, but has more overhead than ZlibFormat. Note: requires zlib
version 1.2.x or higher at runtime.
 
\value RawZipFormat: This is compatible with the most common
compression method of the data blocks contained in ZIP
archives. Note: ZIP file headers are not read or generated, so
setting this format, by itself, does not let QtIOCompressor read
or write ZIP files. Ref. the ziplist example program.
 
\sa setStreamFormat()
*/
 
/*!
Constructs a QtIOCompressor using the given \a device as the underlying device.
 
The allowed value range for \a compressionLevel is 0 to 9, where 0 means no compression
and 9 means maximum compression. The default value is 6.
 
\a bufferSize specifies the size of the internal buffer used when reading from and writing to the
underlying device. The default value is 65KB. Using a larger value allows for faster compression and
decompression at the expense of memory usage.
256,299 → 256,299
*/
QtIOCompressor::QtIOCompressor(QIODevice *device, int compressionLevel, int bufferSize)
:d_ptr(new QtIOCompressorPrivate(this, device, compressionLevel, bufferSize))
{}
 
/*!
Destroys the QtIOCompressor, closing it if necessary.
*/
QtIOCompressor::~QtIOCompressor()
{
Q_D(QtIOCompressor);
close();
delete d;
}
 
/*!
Sets the format on the compressed stream to \a format.
 
\sa QtIOCompressor::StreamFormat
*/
void QtIOCompressor::setStreamFormat(StreamFormat format)
{
Q_D(QtIOCompressor);
 
// Print a waning if the compile-time version of zlib does not support gzip.
if (format == GzipFormat && checkGzipSupport(ZLIB_VERSION) == false)
qWarning("QtIOCompressor::setStreamFormat: zlib 1.2.x or higher is "
"required to use the gzip format. Current version is: %s",
ZLIB_VERSION);
 
d->streamFormat = format;
}
 
/*!
Returns the format set on the compressed stream.
\sa QtIOCompressor::StreamFormat
*/
QtIOCompressor::StreamFormat QtIOCompressor::streamFormat() const
{
Q_D(const QtIOCompressor);
return d->streamFormat;
}
 
/*!
Returns true if the zlib library in use supports the gzip format, false otherwise.
*/
bool QtIOCompressor::isGzipSupported()
{
return checkGzipSupport(zlibVersion());
}
 
/*!
\reimp
*/
bool QtIOCompressor::isSequential() const
{
return true;
}
{}
 
/*!
Destroys the QtIOCompressor, closing it if necessary.
*/
QtIOCompressor::~QtIOCompressor()
{
Q_D(QtIOCompressor);
close();
delete d;
}
 
/*!
Sets the format on the compressed stream to \a format.
 
\sa QtIOCompressor::StreamFormat
*/
void QtIOCompressor::setStreamFormat(StreamFormat format)
{
Q_D(QtIOCompressor);
 
// Print a waning if the compile-time version of zlib does not support gzip.
if (format == GzipFormat && checkGzipSupport(ZLIB_VERSION) == false)
qWarning("QtIOCompressor::setStreamFormat: zlib 1.2.x or higher is "
"required to use the gzip format. Current version is: %s",
ZLIB_VERSION);
 
d->streamFormat = format;
}
 
/*!
Returns the format set on the compressed stream.
\sa QtIOCompressor::StreamFormat
*/
QtIOCompressor::StreamFormat QtIOCompressor::streamFormat() const
{
Q_D(const QtIOCompressor);
return d->streamFormat;
}
 
/*!
Returns true if the zlib library in use supports the gzip format, false otherwise.
*/
bool QtIOCompressor::isGzipSupported()
{
return checkGzipSupport(zlibVersion());
}
 
/*!
\reimp
*/
bool QtIOCompressor::isSequential() const
{
return true;
}
 
/*!
Opens the QtIOCompressor in \a mode. Only ReadOnly and WriteOnly is supported.
This function will return false if you try to open in other modes.
 
If the underlying device is not opened, this function will open it in a suitable mode. If this happens
the device will also be closed when close() is called.
 
If the underlying device is already opened, its openmode must be compatible with \a mode.
 
Returns true on success, false on error.
 
\sa close()
*/
bool QtIOCompressor::open(OpenMode mode)
{
Q_D(QtIOCompressor);
if (isOpen()) {
qWarning("QtIOCompressor::open: device already open");
return false;
}
 
// Check for correct mode: ReadOnly xor WriteOnly
const bool read = (bool)(mode & ReadOnly);
const bool write = (bool)(mode & WriteOnly);
const bool both = (read && write);
const bool neither = !(read || write);
if (both || neither) {
qWarning("QtIOCompressor::open: QtIOCompressor can only be opened in the ReadOnly or WriteOnly modes");
return false;
}
 
// If the underlying device is open, check that is it opened in a compatible mode.
if (d->device->isOpen()) {
d->manageDevice = false;
const OpenMode deviceMode = d->device->openMode();
if (read && !(deviceMode & ReadOnly)) {
qWarning("QtIOCompressor::open: underlying device must be open in one of the ReadOnly or WriteOnly modes");
return false;
} else if (write && !(deviceMode & WriteOnly)) {
qWarning("QtIOCompressor::open: underlying device must be open in one of the ReadOnly or WriteOnly modes");
return false;
}
 
// If the underlying device is closed, open it.
} else {
d->manageDevice = true;
if (d->device->open(mode) == false) {
setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor", "Error opening underlying device: ") + d->device->errorString());
return false;
}
}
 
// Initialize zlib for deflating or inflating.
 
// The second argument to inflate/deflateInit2 is the windowBits parameter,
// which also controls what kind of compression stream headers to use.
// The default value for this is 15. Passing a value greater than 15
// enables gzip headers and then subtracts 16 form the windowBits value.
// (So passing 31 gives gzip headers and 15 windowBits). Passing a negative
// value selects no headers hand then negates the windowBits argument.
int windowBits;
switch (d->streamFormat) {
case QtIOCompressor::GzipFormat:
windowBits = 31;
break;
case QtIOCompressor::RawZipFormat:
windowBits = -15;
break;
default:
windowBits = 15;
}
 
int status;
if (read) {
d->state = QtIOCompressorPrivate::NotReadFirstByte;
d->zlibStream.avail_in = 0;
d->zlibStream.next_in = 0;
if (d->streamFormat == QtIOCompressor::ZlibFormat) {
status = inflateInit(&d->zlibStream);
} else {
if (checkGzipSupport(zlibVersion()) == false) {
setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor::open", "The gzip format not supported in this version of zlib."));
return false;
}
 
status = inflateInit2(&d->zlibStream, windowBits);
}
} else {
d->state = QtIOCompressorPrivate::NoBytesWritten;
if (d->streamFormat == QtIOCompressor::ZlibFormat)
status = deflateInit(&d->zlibStream, d->compressionLevel);
else
status = deflateInit2(&d->zlibStream, d->compressionLevel, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY);
}
 
// Handle error.
if (status != Z_OK) {
d->setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor::open", "Internal zlib error: "), status);
return false;
}
return QIODevice::open(mode);
}
 
/*!
Closes the QtIOCompressor, and also the underlying device if it was opened by QtIOCompressor.
\sa open()
*/
void QtIOCompressor::close()
{
Q_D(QtIOCompressor);
if (isOpen() == false)
return;
 
// Flush and close the zlib stream.
if (openMode() & ReadOnly) {
d->state = QtIOCompressorPrivate::NotReadFirstByte;
inflateEnd(&d->zlibStream);
} else {
if (d->state == QtIOCompressorPrivate::BytesWritten) { // Only flush if we have written anything.
d->state = QtIOCompressorPrivate::NoBytesWritten;
d->flushZlib(Z_FINISH);
}
deflateEnd(&d->zlibStream);
}
 
// Close the underlying device if we are managing it.
if (d->manageDevice)
d->device->close();
 
QIODevice::close();
}
 
/*!
Flushes the internal buffer.
 
Each time you call flush, all data written to the QtIOCompressor is compressed and written to the
underlying device. Calling this function can reduce the compression ratio. The underlying device
is not flushed.
 
Calling this function when QtIOCompressor is in ReadOnly mode has no effect.
*/
void QtIOCompressor::flush()
{
Q_D(QtIOCompressor);
if (isOpen() == false || openMode() & ReadOnly)
return;
 
d->flushZlib(Z_SYNC_FLUSH);
}
 
/*!
Returns 1 if there might be data available for reading, or 0 if there is no data available.
 
There is unfortunately no way of knowing how much data there is available when dealing with compressed streams.
 
Also, since the remaining compressed data might be a part of the meta-data that ends the compressed stream (and
therefore will yield no uncompressed data), you cannot assume that a read after getting a 1 from this function will return data.
*/
qint64 QtIOCompressor::bytesAvailable() const
{
Q_D(const QtIOCompressor);
if ((openMode() & ReadOnly) == false)
return 0;
 
int numBytes = 0;
 
switch (d->state) {
case QtIOCompressorPrivate::NotReadFirstByte:
numBytes = d->device->bytesAvailable();
break;
case QtIOCompressorPrivate::InStream:
numBytes = 1;
break;
case QtIOCompressorPrivate::EndOfStream:
case QtIOCompressorPrivate::Error:
default:
numBytes = 0;
break;
};
 
numBytes += QIODevice::bytesAvailable();
 
if (numBytes > 0)
return 1;
else
return 0;
}
 
/*!
\internal
Reads and decompresses data from the underlying device.
*/
qint64 QtIOCompressor::readData(char *data, qint64 maxSize)
{
Q_D(QtIOCompressor);
 
if (d->state == QtIOCompressorPrivate::EndOfStream)
return 0;
 
if (d->state == QtIOCompressorPrivate::Error)
return -1;
 
// We are ging to try to fill the data buffer
d->zlibStream.next_out = reinterpret_cast<ZlibByte *>(data);
d->zlibStream.avail_out = maxSize;
 
int status;
do {
// Read data if if the input buffer is empty. There could be data in the buffer
// from a previous readData call.
if (d->zlibStream.avail_in == 0) {
qint64 bytesAvalible = d->device->read(reinterpret_cast<char *>(d->buffer), d->bufferSize);
d->zlibStream.next_in = d->buffer;
d->zlibStream.avail_in = bytesAvalible;
 
if (bytesAvalible == -1) {
d->state = QtIOCompressorPrivate::Error;
setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor", "Error reading data from underlying device: ") + d->device->errorString());
return -1;
}
 
if (d->state != QtIOCompressorPrivate::InStream) {
// If we are not in a stream and get 0 bytes, we are probably trying to read from an empty device.
if(bytesAvalible == 0)
return 0;
else if (bytesAvalible > 0)
d->state = QtIOCompressorPrivate::InStream;
}
}
 
// Decompress.
status = inflate(&d->zlibStream, Z_SYNC_FLUSH);
switch (status) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR:
 
If the underlying device is already opened, its openmode must be compatible with \a mode.
 
Returns true on success, false on error.
 
\sa close()
*/
bool QtIOCompressor::open(OpenMode mode)
{
Q_D(QtIOCompressor);
if (isOpen()) {
qWarning("QtIOCompressor::open: device already open");
return false;
}
 
// Check for correct mode: ReadOnly xor WriteOnly
const bool read = (bool)(mode & ReadOnly);
const bool write = (bool)(mode & WriteOnly);
const bool both = (read && write);
const bool neither = !(read || write);
if (both || neither) {
qWarning("QtIOCompressor::open: QtIOCompressor can only be opened in the ReadOnly or WriteOnly modes");
return false;
}
 
// If the underlying device is open, check that is it opened in a compatible mode.
if (d->device->isOpen()) {
d->manageDevice = false;
const OpenMode deviceMode = d->device->openMode();
if (read && !(deviceMode & ReadOnly)) {
qWarning("QtIOCompressor::open: underlying device must be open in one of the ReadOnly or WriteOnly modes");
return false;
} else if (write && !(deviceMode & WriteOnly)) {
qWarning("QtIOCompressor::open: underlying device must be open in one of the ReadOnly or WriteOnly modes");
return false;
}
 
// If the underlying device is closed, open it.
} else {
d->manageDevice = true;
if (d->device->open(mode) == false) {
setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor", "Error opening underlying device: ") + d->device->errorString());
return false;
}
}
 
// Initialize zlib for deflating or inflating.
 
// The second argument to inflate/deflateInit2 is the windowBits parameter,
// which also controls what kind of compression stream headers to use.
// The default value for this is 15. Passing a value greater than 15
// enables gzip headers and then subtracts 16 form the windowBits value.
// (So passing 31 gives gzip headers and 15 windowBits). Passing a negative
// value selects no headers hand then negates the windowBits argument.
int windowBits;
switch (d->streamFormat) {
case QtIOCompressor::GzipFormat:
windowBits = 31;
break;
case QtIOCompressor::RawZipFormat:
windowBits = -15;
break;
default:
windowBits = 15;
}
 
int status;
if (read) {
d->state = QtIOCompressorPrivate::NotReadFirstByte;
d->zlibStream.avail_in = 0;
d->zlibStream.next_in = 0;
if (d->streamFormat == QtIOCompressor::ZlibFormat) {
status = inflateInit(&d->zlibStream);
} else {
if (checkGzipSupport(zlibVersion()) == false) {
setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor::open", "The gzip format not supported in this version of zlib."));
return false;
}
 
status = inflateInit2(&d->zlibStream, windowBits);
}
} else {
d->state = QtIOCompressorPrivate::NoBytesWritten;
if (d->streamFormat == QtIOCompressor::ZlibFormat)
status = deflateInit(&d->zlibStream, d->compressionLevel);
else
status = deflateInit2(&d->zlibStream, d->compressionLevel, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY);
}
 
// Handle error.
if (status != Z_OK) {
d->setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor::open", "Internal zlib error: "), status);
return false;
}
return QIODevice::open(mode);
}
 
/*!
Closes the QtIOCompressor, and also the underlying device if it was opened by QtIOCompressor.
\sa open()
*/
void QtIOCompressor::close()
{
Q_D(QtIOCompressor);
if (isOpen() == false)
return;
 
// Flush and close the zlib stream.
if (openMode() & ReadOnly) {
d->state = QtIOCompressorPrivate::NotReadFirstByte;
inflateEnd(&d->zlibStream);
} else {
if (d->state == QtIOCompressorPrivate::BytesWritten) { // Only flush if we have written anything.
d->state = QtIOCompressorPrivate::NoBytesWritten;
d->flushZlib(Z_FINISH);
}
deflateEnd(&d->zlibStream);
}
 
// Close the underlying device if we are managing it.
if (d->manageDevice)
d->device->close();
 
QIODevice::close();
}
 
/*!
Flushes the internal buffer.
 
Each time you call flush, all data written to the QtIOCompressor is compressed and written to the
underlying device. Calling this function can reduce the compression ratio. The underlying device
is not flushed.
 
Calling this function when QtIOCompressor is in ReadOnly mode has no effect.
*/
void QtIOCompressor::flush()
{
Q_D(QtIOCompressor);
if (isOpen() == false || openMode() & ReadOnly)
return;
 
d->flushZlib(Z_SYNC_FLUSH);
}
 
/*!
Returns 1 if there might be data available for reading, or 0 if there is no data available.
 
There is unfortunately no way of knowing how much data there is available when dealing with compressed streams.
 
Also, since the remaining compressed data might be a part of the meta-data that ends the compressed stream (and
therefore will yield no uncompressed data), you cannot assume that a read after getting a 1 from this function will return data.
*/
qint64 QtIOCompressor::bytesAvailable() const
{
Q_D(const QtIOCompressor);
if ((openMode() & ReadOnly) == false)
return 0;
 
int numBytes = 0;
 
switch (d->state) {
case QtIOCompressorPrivate::NotReadFirstByte:
numBytes = d->device->bytesAvailable();
break;
case QtIOCompressorPrivate::InStream:
numBytes = 1;
break;
case QtIOCompressorPrivate::EndOfStream:
case QtIOCompressorPrivate::Error:
default:
numBytes = 0;
break;
};
 
numBytes += QIODevice::bytesAvailable();
 
if (numBytes > 0)
return 1;
else
return 0;
}
 
/*!
\internal
Reads and decompresses data from the underlying device.
*/
qint64 QtIOCompressor::readData(char *data, qint64 maxSize)
{
Q_D(QtIOCompressor);
 
if (d->state == QtIOCompressorPrivate::EndOfStream)
return 0;
 
if (d->state == QtIOCompressorPrivate::Error)
return -1;
 
// We are ging to try to fill the data buffer
d->zlibStream.next_out = reinterpret_cast<ZlibByte *>(data);
d->zlibStream.avail_out = maxSize;
 
int status;
do {
// Read data if if the input buffer is empty. There could be data in the buffer
// from a previous readData call.
if (d->zlibStream.avail_in == 0) {
qint64 bytesAvalible = d->device->read(reinterpret_cast<char *>(d->buffer), d->bufferSize);
d->zlibStream.next_in = d->buffer;
d->zlibStream.avail_in = bytesAvalible;
 
if (bytesAvalible == -1) {
d->state = QtIOCompressorPrivate::Error;
setErrorString(QT_TRANSLATE_NOOP("QtIOCompressor", "Error reading data from underlying device: ") + d->device->errorString());
return -1;
}
 
if (d->state != QtIOCompressorPrivate::InStream) {
// If we are not in a stream and get 0 bytes, we are probably trying to read from an empty device.
if(bytesAvalible == 0)
return 0;
else if (bytesAvalible > 0)
d->state = QtIOCompressorPrivate::InStream;
}
}
 
// Decompress.
status = inflate(&d->zlibStream, Z_SYNC_FLUSH);
switch (status) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR:
d->state = QtIOCompressorPrivate::Error;
d->setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor", "Internal zlib error when decompressing: "), status);
return -1;
case Z_BUF_ERROR: // No more input and zlib can not provide more output - Not an error, we can try to read again when we have more input.
555,70 → 555,70
return 0;
break;
}
// Loop util data buffer is full or we reach the end of the input stream.
} while (d->zlibStream.avail_out != 0 && status != Z_STREAM_END);
 
if (status == Z_STREAM_END) {
d->state = QtIOCompressorPrivate::EndOfStream;
 
// Unget any data left in the read buffer.
for (int i = d->zlibStream.avail_in; i >= 0; --i)
d->device->ungetChar(*reinterpret_cast<char *>(d->zlibStream.next_in + i));
}
 
const ZlibSize outputSize = maxSize - d->zlibStream.avail_out;
return outputSize;
}
 
 
/*!
\internal
Compresses and writes data to the underlying device.
*/
qint64 QtIOCompressor::writeData(const char *data, qint64 maxSize)
{
if (maxSize < 1)
return 0;
Q_D(QtIOCompressor);
d->zlibStream.next_in = reinterpret_cast<ZlibByte *>(const_cast<char *>(data));
d->zlibStream.avail_in = maxSize;
 
if (d->state == QtIOCompressorPrivate::Error)
return -1;
 
do {
d->zlibStream.next_out = d->buffer;
d->zlibStream.avail_out = d->bufferSize;
const int status = deflate(&d->zlibStream, Z_NO_FLUSH);
if (status != Z_OK) {
d->state = QtIOCompressorPrivate::Error;
d->setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor", "Internal zlib error when compressing: "), status);
return -1;
}
 
ZlibSize outputSize = d->bufferSize - d->zlibStream.avail_out;
 
// Try to write data from the buffer to to the underlying device, return -1 on failure.
if (d->writeBytes(d->buffer, outputSize) == false)
return -1;
 
} while (d->zlibStream.avail_out == 0); // run until output is not full.
Q_ASSERT(d->zlibStream.avail_in == 0);
 
return maxSize;
}
 
/*
\internal
Checks if the run-time zlib version is 1.2.x or higher.
*/
bool QtIOCompressor::checkGzipSupport(const char * const versionString)
{
if (strlen(versionString) < 3)
return false;
 
if (versionString[0] == '0' || (versionString[0] == '1' && (versionString[2] == '0' || versionString[2] == '1' )))
return false;
 
return true;
}
// Loop util data buffer is full or we reach the end of the input stream.
} while (d->zlibStream.avail_out != 0 && status != Z_STREAM_END);
 
if (status == Z_STREAM_END) {
d->state = QtIOCompressorPrivate::EndOfStream;
 
// Unget any data left in the read buffer.
for (int i = d->zlibStream.avail_in; i >= 0; --i)
d->device->ungetChar(*reinterpret_cast<char *>(d->zlibStream.next_in + i));
}
 
const ZlibSize outputSize = maxSize - d->zlibStream.avail_out;
return outputSize;
}
 
 
/*!
\internal
Compresses and writes data to the underlying device.
*/
qint64 QtIOCompressor::writeData(const char *data, qint64 maxSize)
{
if (maxSize < 1)
return 0;
Q_D(QtIOCompressor);
d->zlibStream.next_in = reinterpret_cast<ZlibByte *>(const_cast<char *>(data));
d->zlibStream.avail_in = maxSize;
 
if (d->state == QtIOCompressorPrivate::Error)
return -1;
 
do {
d->zlibStream.next_out = d->buffer;
d->zlibStream.avail_out = d->bufferSize;
const int status = deflate(&d->zlibStream, Z_NO_FLUSH);
if (status != Z_OK) {
d->state = QtIOCompressorPrivate::Error;
d->setZlibError(QT_TRANSLATE_NOOP("QtIOCompressor", "Internal zlib error when compressing: "), status);
return -1;
}
 
ZlibSize outputSize = d->bufferSize - d->zlibStream.avail_out;
 
// Try to write data from the buffer to to the underlying device, return -1 on failure.
if (d->writeBytes(d->buffer, outputSize) == false)
return -1;
 
} while (d->zlibStream.avail_out == 0); // run until output is not full.
Q_ASSERT(d->zlibStream.avail_in == 0);
 
return maxSize;
}
 
/*
\internal
Checks if the run-time zlib version is 1.2.x or higher.
*/
bool QtIOCompressor::checkGzipSupport(const char * const versionString)
{
if (strlen(versionString) < 3)
return false;
 
if (versionString[0] == '0' || (versionString[0] == '1' && (versionString[2] == '0' || versionString[2] == '1' )))
return false;
 
return true;
}
/trunk/Scribus/scribus/sccolorengine.cpp
753,7 → 753,7
rgb.r = qRound(color.m_values[0] * 255.0);
rgb.g = qRound(color.m_values[1] * 255.0);
rgb.b = qRound(color.m_values[2] * 255.0);
tmp = getColorProof(rgb, doc, spot, gamutCheck & gamutChkEnabled);
tmp = getColorProof(rgb, doc, spot, gamutCheck && gamutChkEnabled);
}
else
{
762,7 → 762,7
cmyk.m = qRound(color.m_values[1] * 255.0);
cmyk.y = qRound(color.m_values[2] * 255.0);
cmyk.k = qRound(color.m_values[3] * 255.0);
tmp = getColorProof(cmyk, doc, spot, gamutCheck & gamutChkEnabled);
tmp = getColorProof(cmyk, doc, spot, gamutCheck && gamutChkEnabled);
}
return tmp;
}
1106,7 → 1106,7
xformProof = doc->stdProofGC;
if ((color.m_values[0] == 0) && (color.m_values[1] == 0) && (color.m_values[2] == 1.0))
alert = false;
if ((color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2]))
if ((color.m_values[0] == color.m_values[1]) && (color.m_values[1] == color.m_values[2]))
alert = false;
}
else if (color.getColorModel() == colorModelCMYK)
/trunk/Scribus/scribus/ui/propertiespalette_image.cpp
549,7 → 549,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
//CB Don't pass in the scale to the offset change as its taken from the new scale
m_doc->itemSelection_SetImageScaleAndOffset(imageXScaleSpinBox->value() / 100.0 / m_item->pixm.imgInfo.xres * 72.0, imageYScaleSpinBox->value() / 100.0 / m_item->pixm.imgInfo.yres * 72.0, imageXOffsetSpinBox->value() / m_unitRatio, imageYOffsetSpinBox->value() / m_unitRatio);
562,7 → 562,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
//CB Don't pass in the scale to the offset change as its taken from the new scale
m_doc->itemSelection_SetImageScaleAndOffset(72.0 / imgDpiX->value(), 72.0 / imgDpiY->value(), imageXOffsetSpinBox->value() / m_unitRatio, imageYOffsetSpinBox->value() / m_unitRatio);
576,7 → 576,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
m_doc->itemSelection_SetImageRotation(360 - imageRotation->value());
if (frameScale->isChecked())
623,7 → 623,7
keepImageDPIRatioButton->setEnabled(false);
}
 
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
m_item->setImageScalingMode(freeScale->isChecked(), cbProportional->isChecked());
m_doc->changed();
/trunk/Scribus/scribus/ui/propertiespalette_line.cpp
461,7 → 461,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
double oldL = m_item->lineWidth();
m_doc->itemSelection_SetLineWidth(lineWidth->value() / m_unitRatio);
492,7 → 492,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
if (lineType->currentIndex() == 37)
{
529,7 → 529,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
Qt::PenJoinStyle c = Qt::MiterJoin;
switch (lineJoinStyle->currentIndex())
552,7 → 552,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
Qt::PenCapStyle c = Qt::FlatCap;
switch (lineEndStyle->currentIndex())
611,7 → 611,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
if (m_item->lineWidth() != 0.0)
{
/trunk/Scribus/scribus/ui/propertiespalette_shadow.cpp
247,7 → 247,7
 
void PropertiesPalette_Shadow::handleNewValues()
{
if (!m_haveItem)
if (!m_haveItem || !m_haveDoc)
return;
double x = softShadowXOffset->valueAsDouble() / m_unitRatio;
double y = softShadowYOffset->valueAsDouble() / m_unitRatio;
258,10 → 258,8
int b = softShadowBlendMode->valueAsInt();
double o = (100 - softShadowOpacity->valueAsDouble()) / 100.0;
int s = softShadowShade->valueAsInt();
if (m_haveDoc)
{
m_doc->itemSelection_SetSoftShadow(hasSoftShadow->valueAsBool(), color, x, y, r, s, o, b, softShadowErase->valueAsBool(), softShadowObjTrans->valueAsBool());
}
 
m_doc->itemSelection_SetSoftShadow(hasSoftShadow->valueAsBool(), color, x, y, r, s, o, b, softShadowErase->valueAsBool(), softShadowObjTrans->valueAsBool());
}
 
void PropertiesPalette_Shadow::changeEvent(QEvent *e)
/trunk/Scribus/scribus/ui/propertiespalette_shape.cpp
134,7 → 134,7
{
PageItem *currentItem = nullptr;
 
if (m_doc && m_doc->m_Selection->count()>0)
if (m_doc && m_doc->m_Selection->count() > 0)
currentItem = m_doc->m_Selection->itemAt(0);
 
return currentItem;
147,10 → 147,10
 
void PropertiesPalette_Shape::setLocked(bool isLocked)
{
QPalette pal(qApp->palette());
QPalette pal(QApplication::palette());
if (isLocked)
pal.setCurrentColorGroup(QPalette::Disabled);
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
enableCustomShape();
enableEditShape();
298,7 → 298,6
}
setCurrentItem(currItem);
updateGeometry();
//repaint();
}
 
void PropertiesPalette_Shape::handleUpdateRequest(int updateFlags)
392,7 → 391,7
PageItem::TextFlowMode mode = PageItem::TextFlowDisabled;
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
if (textFlowDisabled->isChecked())
mode = PageItem::TextFlowDisabled;
415,7 → 414,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
m_tmpSelection->clear();
if (m_item->asRegularPolygon())
446,7 → 445,7
void PropertiesPalette_Shape::handleShapeEditEnded()
{
disconnect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
if (m_tmpSelection->count() > 0)
{
481,7 → 480,7
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText))
return;
/trunk/Scribus/scribus/ui/propertiespalette_utils.cpp
38,9 → 38,6
 
//using namespace std;
 
 
LineStyleValue::LineStyleValue() : m_doc(nullptr), m_name() {};
 
LineStyleValue::LineStyleValue(const multiLine& line, ScribusDoc* doc, const QString& name) :
m_Line(line),
m_doc(doc),
/trunk/Scribus/scribus/ui/propertiespalette_utils.h
48,7 → 48,7
ScGuardedPtr<ScribusDoc> m_doc;
QString m_name;
LineStyleValue();
LineStyleValue() = default;
LineStyleValue(const multiLine& line, ScribusDoc* doc, const QString& name);
LineStyleValue(const LineStyleValue& other);
LineStyleValue& operator= (const LineStyleValue& other);
/trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
50,7 → 50,6
setupUi(this);
setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
 
_userActionOn = false;
userActionSniffer = new UserActionSniffer(this);
connect(userActionSniffer, SIGNAL(actionStart()), this, SLOT(spinboxStartUserAction()));
connect(userActionSniffer, SIGNAL(actionEnd()), this, SLOT(spinboxFinishUserAction()));
107,7 → 106,6
connect(doGroup , SIGNAL(clicked()), this, SLOT(handleGrouping()) );
connect(doUnGroup, SIGNAL(clicked()), this, SLOT(handleUngrouping()) );
 
m_haveItem = false;
xposSpin->showValue(0);
yposSpin->showValue(0);
widthSpin->showValue(0);
617,7 → 615,7
return;
bool sigBlocked1 = widthSpin->blockSignals(true);
bool sigBlocked2 = heightSpin->blockSignals(true);
if ((m_lineMode) && (m_item->asLine()))
if (m_lineMode && m_item->isLine())
{
QTransform ma;
ma.translate(m_item->xPos(), m_item->yPos());
677,10 → 675,10
base = gx + gw / 2.0;
else if ((bp == 1) || (bp == 4))
base = gx + gw;
if (!_userActionOn)
if (!m_userActionOn)
m_ScMW->view->startGroupTransaction();
m_doc->moveGroup(x - base, 0);
if (!_userActionOn)
if (!m_userActionOn)
{
m_ScMW->view->endGroupTransaction();
}
747,10 → 745,10
base = gy + gh / 2.0;
else if ((bp == 3) || (bp == 4))
base = gy + gh;
if (!_userActionOn)
if (!m_userActionOn)
m_ScMW->view->startGroupTransaction();
m_doc->moveGroup(0, y - base);
if (!_userActionOn)
if (!m_userActionOn)
{
m_ScMW->view->endGroupTransaction();
}
804,7 → 802,7
double oldH = (m_item->height() != 0.0) ? m_item->height() : 1.0;
if (m_doc->m_Selection->isMultipleSelection())
{
if (!_userActionOn)
if (!m_userActionOn)
m_ScMW->view->startGroupTransaction();
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
if (keepFrameWHRatioButton->isChecked())
818,7 → 816,7
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
showWH(gw, gh);
}
if (!_userActionOn)
if (!m_userActionOn)
{
m_ScMW->view->endGroupTransaction();
}
886,7 → 884,7
double oldH = (m_item->height() != 0.0) ? m_item->height() : 1.0;
if (m_doc->m_Selection->isMultipleSelection())
{
if (!_userActionOn)
if (!m_userActionOn)
m_ScMW->view->startGroupTransaction();
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
if (keepFrameWHRatioButton->isChecked())
900,7 → 898,7
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
showWH(gw, gh);
}
if (!_userActionOn)
if (!m_userActionOn)
{
m_ScMW->view->endGroupTransaction();
}
959,9 → 957,9
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
double gx, gy, gh, gw;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
if (!_userActionOn)
if (!m_userActionOn)
m_ScMW->view->startGroupTransaction(Um::Rotate, "", Um::IRotate);
if (m_doc->m_Selection->isMultipleSelection())
{
971,7 → 969,7
}
else
m_doc->rotateItem(rotationSpin->value()*(-1), m_item);
if (!_userActionOn)
if (!m_userActionOn)
{
for (int i = 0; i < m_doc->m_Selection->count(); ++i)
m_doc->m_Selection->itemAt(i)->checkChanges(true);
1022,7 → 1020,7
double inX, inY, gx, gy, gh, gw;
inX = 0;
inY = 0;
if ((m_haveDoc) && (m_haveItem))
if (m_haveDoc && m_haveItem)
{
m_haveItem = false;
m_doc->setRotationMode(m);
1213,17 → 1211,17
 
bool PropertiesPalette_XYZ::userActionOn()
{
return _userActionOn;
return m_userActionOn;
}
 
void PropertiesPalette_XYZ::spinboxStartUserAction()
{
_userActionOn = true;
m_userActionOn = true;
}
 
void PropertiesPalette_XYZ::spinboxFinishUserAction()
{
_userActionOn = false;
m_userActionOn = false;
 
for (int i = 0; i < m_doc->m_Selection->count(); ++i)
m_doc->m_Selection->itemAt(i)->checkChanges(true);
1258,17 → 1256,17
flipH->setIcon(im.loadIcon("16/flip-object-horizontal.png"));
flipV->setIcon(im.loadIcon("16/flip-object-vertical.png"));
QIcon a = QIcon();
QIcon a;
a.addPixmap(im.loadPixmap("16/lock.png"), QIcon::Normal, QIcon::On);
a.addPixmap(im.loadPixmap("16/lock-unlocked.png"), QIcon::Normal, QIcon::Off);
doLock->setIcon(a);
 
QIcon a2 = QIcon();
QIcon a2;
a2.addPixmap(im.loadPixmap("NoPrint.png"), QIcon::Normal, QIcon::On);
a2.addPixmap(im.loadPixmap("16/document-print.png"), QIcon::Normal, QIcon::Off);
noPrint->setIcon(a2);
 
QIcon a3 = QIcon();
QIcon a3;
a3.addPixmap(im.loadPixmap("framenoresize.png"), QIcon::Normal, QIcon::On);
a3.addPixmap(im.loadPixmap("frameresize.png"), QIcon::Normal, QIcon::Off);
noResize->setIcon(a3);
1309,7 → 1307,7
widthSpin->setReadOnly(isLocked);
heightSpin->setReadOnly(isLocked);
rotationSpin->setReadOnly(isLocked);
QPalette pal(qApp->palette());
QPalette pal(QApplication::palette());
if (isLocked)
pal.setCurrentColorGroup(QPalette::Disabled);
 
1329,7 → 1327,7
b=true;
widthSpin->setReadOnly(b);
heightSpin->setReadOnly(b);
QPalette pal(qApp->palette());
QPalette pal(QApplication::palette());
if (b)
pal.setCurrentColorGroup(QPalette::Disabled);
/trunk/Scribus/scribus/ui/propertiespalette_xyz.h
106,7 → 106,7
double m_oldRotation {0.0};
 
bool _userActionOn;
bool m_userActionOn { false };
UserActionSniffer *userActionSniffer;
void installSniffer(ScrSpinBox *spinBox);
 
/trunk/Scribus/scribus/ui/propertywidget_distance.cpp
286,17 → 286,6
{
textItem->setColumns(static_cast<int>(columns->value()));
showColumns(textItem->m_columns, textItem->m_columnGap);
//this is already done in showColumns()
/*if (static_cast<int>(columns->value()) == 1)
{
columnGap->setEnabled(false);
columnGapLabel->setEnabled(false);
}
else
{
columnGap->setEnabled(true);
columnGapLabel->setEnabled(true);
}*/
textItem->update();
if (m_doc->appMode == modeEditTable)
m_item->asTable()->update();
/trunk/Scribus/scribus/ui/propertywidget_fontfeatures.cpp
1,725 → 1,723
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include "propertywidget_fontfeatures.h"
#include "appmodes.h"
#include "pageitem_table.h"
#include "iconmanager.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "selection.h"
 
#include "fonts/fontfeatures.h"
 
PropertyWidget_FontFeatures::PropertyWidget_FontFeatures(QWidget* parent) : QFrame(parent)
{
m_item = nullptr;
m_ScMW = nullptr;
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include "propertywidget_fontfeatures.h"
#include "appmodes.h"
#include "pageitem_table.h"
#include "iconmanager.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "selection.h"
 
#include "fonts/fontfeatures.h"
 
PropertyWidget_FontFeatures::PropertyWidget_FontFeatures(QWidget* parent) : QFrame(parent)
{
setupUi(this);
 
layout()->setAlignment(Qt::AlignTop);
 
initWidgets();
languageChange();
}
 
void PropertyWidget_FontFeatures::setMainWindow(ScribusMainWindow *mw)
{
m_ScMW = mw;
}
 
void PropertyWidget_FontFeatures::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
{
languageChange();
return;
}
QWidget::changeEvent(e);
}
 
void PropertyWidget_FontFeatures::languageChange()
{
retranslateUi(this);
}
 
void PropertyWidget_FontFeatures::showFontFeatures(const QString& s, const QStringList& availableFeatures)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
 
enableFeatures(availableFeatures);
 
QStringList fontFeatures = s.split(',');
ContextualCheck->setChecked(true);
CommonCheck->setChecked(true);
SlashedZeroCheck->setEnabled(true);
for (int i = 0; i < fontFeatures.count(); i++)
{
if (fontFeatures[i] == "-clig")
ContextualCheck->setChecked(false);
else if (fontFeatures[i] == "-liga")
CommonCheck->setChecked(false);
else if (fontFeatures[i] == "+dlig")
DiscretionaryCheck->setChecked(true);
else if (fontFeatures[i] == "+hlig")
HistoricalCheck->setChecked(true);
else if (fontFeatures[i] == "+subs")
SubscriptRadio->setChecked(true);
else if (fontFeatures[i] == "+sups")
SuperscriptRadio->setChecked(true);
else if (fontFeatures[i] == "+smcp")
SmallRadio->setChecked(true);
else if (fontFeatures[i] == "+c2sc")
SmallFromCRadio->setChecked(true);
else if (fontFeatures[i] == "+pcap")
PetiteRadio->setChecked(true);
else if (fontFeatures[i] == "+c2pc")
PetiteCapRadio->setChecked(true);
else if (fontFeatures[i] == "+unic")
UnicaseRadio->setChecked(true);
else if (fontFeatures[i] == "+titl")
TiltingRadio->setChecked(true);
else if (fontFeatures[i] == "+lnum")
LiningRadio->setChecked(true);
else if (fontFeatures[i] == "+onum")
OldStyleRadio->setChecked(true);
else if (fontFeatures[i] == "+pnum")
ProportionalRadio->setChecked(true);
else if (fontFeatures[i] == "+tnum")
TabularRadio->setChecked(true);
else if (fontFeatures[i] == "+frac")
DiagonalRadio->setChecked(true);
else if (fontFeatures[i] == "+afrc")
StackedRadio->setChecked(true);
else if (fontFeatures[i] == "+ordn")
OrdinalCheck->setChecked(true);
else if (fontFeatures[i] == "+zero")
SlashedZeroCheck->setChecked(true);
else if (fontFeatures[i] == "+ss01")
StyleSet01->setChecked(true);
else if (fontFeatures[i] == "+ss02")
StyleSet02->setChecked(true);
else if (fontFeatures[i] == "+ss03")
StyleSet03->setChecked(true);
else if (fontFeatures[i] == "+ss04")
StyleSet04->setChecked(true);
else if (fontFeatures[i] == "+ss05")
StyleSet05->setChecked(true);
else if (fontFeatures[i] == "+ss06")
StyleSet06->setChecked(true);
else if (fontFeatures[i] == "+ss07")
StyleSet07->setChecked(true);
else if (fontFeatures[i] == "+ss08")
StyleSet08->setChecked(true);
else if (fontFeatures[i] == "+ss09")
StyleSet09->setChecked(true);
else if (fontFeatures[i] == "+ss10")
StyleSet10->setChecked(true);
else if (fontFeatures[i] == "+ss11")
StyleSet11->setChecked(true);
else if (fontFeatures[i] == "+ss12")
StyleSet12->setChecked(true);
else if (fontFeatures[i] == "+ss13")
StyleSet13->setChecked(true);
else if (fontFeatures[i] == "+ss14")
StyleSet14->setChecked(true);
else if (fontFeatures[i] == "+ss15")
StyleSet15->setChecked(true);
else if (fontFeatures[i] == "+ss16")
StyleSet16->setChecked(true);
else if (fontFeatures[i] == "+ss17")
StyleSet17->setChecked(true);
else if (fontFeatures[i] == "+ss18")
StyleSet18->setChecked(true);
else if (fontFeatures[i] == "+ss19")
StyleSet19->setChecked(true);
else if (fontFeatures[i] == "+ss20")
StyleSet20->setChecked(true);
}
if (OldStyleRadio->isChecked())
{
SlashedZeroCheck->setChecked(false);
SlashedZeroCheck->setEnabled(false);
}
}
 
void PropertyWidget_FontFeatures::handleFontFeatures()
{
if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
return;
 
// Ligatures
QStringList font_feature ;
if (!CommonCheck->isChecked())
font_feature << "-liga";
if (!ContextualCheck->isChecked())
font_feature << "-clig";
if (DiscretionaryCheck->isChecked())
font_feature << "+dlig";
if (HistoricalCheck->isChecked())
font_feature << "+hlig";
 
//Capitals
if (SmallRadio->isChecked())
font_feature << "+smcp";
if (SmallFromCRadio->isChecked())
font_feature << "+c2sc";
if (PetiteRadio->isChecked())
font_feature << "+pcap";
if (PetiteCapRadio->isChecked())
font_feature << "+c2pc";
if (UnicaseRadio->isChecked())
font_feature << "+unic";
if (TiltingRadio->isChecked())
font_feature << "+titl";
 
//Numeric
if (LiningRadio->isChecked())
font_feature << "+lnum";
if (OldStyleRadio->isChecked())
font_feature << "+onum";
if (ProportionalRadio->isChecked())
font_feature << "+pnum";
if (TabularRadio->isChecked())
font_feature << "+tnum";
if (DiagonalRadio->isChecked())
font_feature << "+frac";
if (StackedRadio->isChecked())
font_feature <<"+afrc";
 
//Position
if (SubscriptRadio->isChecked())
font_feature << "+subs";
if (SuperscriptRadio->isChecked())
font_feature << "+sups";
if (OrdinalCheck->isChecked())
font_feature << "+ordn";
 
if (SlashedZeroCheck->isChecked())
font_feature << "+zero";
 
// Stylistic sets
if (StyleSet01->isChecked())
font_feature << "+ss01";
if (StyleSet02->isChecked())
font_feature << "+ss02";
if (StyleSet03->isChecked())
font_feature << "+ss03";
if (StyleSet04->isChecked())
font_feature << "+ss04";
if (StyleSet05->isChecked())
font_feature << "+ss05";
if (StyleSet06->isChecked())
font_feature << "+ss06";
if (StyleSet07->isChecked())
font_feature << "+ss07";
if (StyleSet08->isChecked())
font_feature << "+ss08";
if (StyleSet09->isChecked())
font_feature << "+ss09";
if (StyleSet10->isChecked())
font_feature << "+ss10";
if (StyleSet11->isChecked())
font_feature << "+ss11";
if (StyleSet12->isChecked())
font_feature << "+ss12";
if (StyleSet13->isChecked())
font_feature << "+ss13";
if (StyleSet14->isChecked())
font_feature << "+ss14";
if (StyleSet15->isChecked())
font_feature << "+ss15";
if (StyleSet16->isChecked())
font_feature << "+ss16";
if (StyleSet17->isChecked())
font_feature << "+ss17";
if (StyleSet18->isChecked())
font_feature << "+ss18";
if (StyleSet19->isChecked())
font_feature << "+ss19";
if (StyleSet20->isChecked())
font_feature << "+ss20";
 
Selection tempSelection(this, false);
tempSelection.addItem(m_item, true);
m_doc->itemSelection_SetFontFeatures(font_feature.join(","), &tempSelection);
}
 
void PropertyWidget_FontFeatures::setDoc(ScribusDoc *d)
{
if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
return;
 
if (m_doc)
{
disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
}
 
m_doc = d;
m_item = nullptr;
 
if (m_doc.isNull())
{
disconnectSignals();
return;
}
 
connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
}
 
void PropertyWidget_FontFeatures::handleSelectionChanged()
{
if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning())
return;
 
PageItem* currItem = currentItemFromSelection();
setCurrentItem(currItem);
updateGeometry();
repaint();
}
 
void PropertyWidget_FontFeatures::updateCharStyle(const CharStyle& charStyle)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
showFontFeatures(charStyle.fontFeatures(), charStyle.font().fontFeatures());
}
 
void PropertyWidget_FontFeatures::updateStyle(const ParagraphStyle& newCurrent)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
 
const CharStyle& charStyle = newCurrent.charStyle();
showFontFeatures(charStyle.fontFeatures(), charStyle.font().fontFeatures());
}
 
void PropertyWidget_FontFeatures::connectSignals()
{
connect(CommonCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(ContextualCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(DiscretionaryCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(HistoricalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(NormalCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SmallRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SmallFromCRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(PetiteRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(PetiteCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(UnicaseRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(TiltingRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(LiningRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(OldStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultWidthRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(ProportionalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(TabularRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultFractionsRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(DiagonalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StackedRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultPosRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SubscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SuperscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(OrdinalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(SlashedZeroCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(StyleSet01, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet02, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet03, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet04, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet05, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet06, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet07, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet08, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet09, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet10, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet11, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet12, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet13, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet14, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet15, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet16, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet17, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet18, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet19, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet20, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
}
 
void PropertyWidget_FontFeatures::disconnectSignals()
{
disconnect(CommonCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(ContextualCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(DiscretionaryCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(HistoricalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(NormalCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SmallRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SmallFromCRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(PetiteRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(PetiteCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(UnicaseRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(TiltingRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(LiningRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(OldStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultWidthRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(ProportionalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(TabularRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultFractionsRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(DiagonalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StackedRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultPosRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SubscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SuperscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(OrdinalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(SlashedZeroCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(StyleSet01, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet02, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet03, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet04, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet05, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet06, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet07, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet08, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet09, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet10, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet11, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet12, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet13, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet14, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet15, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet16, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet17, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet18, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet19, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet20, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
}
 
void PropertyWidget_FontFeatures::disableAllFeatures()
{
CommonCheck->setChecked(true);
ContextualCheck->setChecked(true);
DiscretionaryCheck->setChecked(false);
HistoricalCheck->setChecked(false);
NormalCapRadio->setChecked(true);
DefaultStyleRadio->setChecked(true);
DefaultWidthRadio->setChecked(true);
DefaultFractionsRadio->setChecked(true);
DefaultPosRadio->setChecked(true);
SlashedZeroCheck->setChecked(false);
 
StyleSet01->setChecked(false);
StyleSet02->setChecked(false);
StyleSet03->setChecked(false);
StyleSet04->setChecked(false);
StyleSet05->setChecked(false);
StyleSet06->setChecked(false);
StyleSet07->setChecked(false);
StyleSet08->setChecked(false);
StyleSet09->setChecked(false);
StyleSet10->setChecked(false);
StyleSet11->setChecked(false);
StyleSet12->setChecked(false);
StyleSet13->setChecked(false);
StyleSet14->setChecked(false);
StyleSet15->setChecked(false);
StyleSet16->setChecked(false);
StyleSet17->setChecked(false);
StyleSet18->setChecked(false);
StyleSet19->setChecked(false);
StyleSet20->setChecked(false);
}
 
void PropertyWidget_FontFeatures::enableFeatures(const QStringList& fontFeatures)
{
quint64 oldFlags = featureFlags();
quint64 newFlags = FontFeatures::fontFlagsFromList(fontFeatures);
 
disableAllFeatures();
 
CommonCheck->setVisible(newFlags & FontFeatures::CommonLigatures);
ContextualCheck->setVisible(newFlags & FontFeatures::ContextualLigatures);
DiscretionaryCheck->setVisible(newFlags & FontFeatures::DiscretionaryLigatures);
HistoricalCheck->setVisible(newFlags & FontFeatures::HistoricalLigatures);
 
SmallRadio->setVisible(newFlags & FontFeatures::SmallCaps);
SmallFromCRadio->setVisible(newFlags & FontFeatures::SmallCapsFromCaps);
PetiteRadio->setVisible(newFlags & FontFeatures::PetiteCaps);
PetiteCapRadio->setVisible(newFlags & FontFeatures::PetiteCapsFromCaps);
UnicaseRadio->setVisible(newFlags & FontFeatures::UnicaseCaps);
TiltingRadio->setVisible(newFlags & FontFeatures::TiltingCaps);
 
LiningRadio->setVisible(newFlags & FontFeatures::LiningNumerals);
OldStyleRadio->setVisible(newFlags & FontFeatures::OldStyleNumerals);
 
ProportionalRadio->setVisible(newFlags & FontFeatures::ProportionalNumeralWidth);
TabularRadio->setVisible(newFlags & FontFeatures::TabularNumeralWidth);
 
DiagonalRadio->setVisible(newFlags & FontFeatures::DiagonalFractions);
StackedRadio->setVisible(newFlags & FontFeatures::StackedFractions);
 
SubscriptRadio->setVisible(newFlags & FontFeatures::Subscript);
SuperscriptRadio->setVisible(newFlags & FontFeatures::Superscript);
OrdinalCheck->setVisible(newFlags & FontFeatures::Ordinals);
 
SlashedZeroCheck->setVisible(newFlags & FontFeatures::SlashedZero);
 
StyleSet01->setVisible(newFlags & FontFeatures::StyleSet01);
StyleSet02->setVisible(newFlags & FontFeatures::StyleSet02);
StyleSet03->setVisible(newFlags & FontFeatures::StyleSet03);
StyleSet04->setVisible(newFlags & FontFeatures::StyleSet04);
StyleSet05->setVisible(newFlags & FontFeatures::StyleSet05);
StyleSet06->setVisible(newFlags & FontFeatures::StyleSet06);
StyleSet07->setVisible(newFlags & FontFeatures::StyleSet07);
StyleSet08->setVisible(newFlags & FontFeatures::StyleSet08);
StyleSet09->setVisible(newFlags & FontFeatures::StyleSet09);
StyleSet10->setVisible(newFlags & FontFeatures::StyleSet10);
StyleSet11->setVisible(newFlags & FontFeatures::StyleSet11);
StyleSet12->setVisible(newFlags & FontFeatures::StyleSet12);
StyleSet13->setVisible(newFlags & FontFeatures::StyleSet13);
StyleSet14->setVisible(newFlags & FontFeatures::StyleSet14);
StyleSet15->setVisible(newFlags & FontFeatures::StyleSet15);
StyleSet16->setVisible(newFlags & FontFeatures::StyleSet16);
StyleSet17->setVisible(newFlags & FontFeatures::StyleSet17);
StyleSet18->setVisible(newFlags & FontFeatures::StyleSet18);
StyleSet19->setVisible(newFlags & FontFeatures::StyleSet19);
StyleSet20->setVisible(newFlags & FontFeatures::StyleSet20);
 
groupBox_7->setVisible(newFlags & FontFeatures::StyleSetsMask);
 
// Hide Default features when their relative ones aren't found in the font.
NormalCapRadio->setVisible(newFlags & FontFeatures::CapsMask);
DefaultStyleRadio->setVisible(newFlags & FontFeatures::NumeralStyleMask);
DefaultWidthRadio->setVisible(newFlags & FontFeatures::NumeralWidthMask);
DefaultFractionsRadio->setVisible(newFlags & FontFeatures::NumeralFractionsMask);
DefaultPosRadio->setVisible(newFlags & FontFeatures::GlyphPositionMask);
 
// Hide Lines
line->setVisible(newFlags & FontFeatures::LigaturesMask);
 
line_2->setVisible(newFlags & FontFeatures::CapsMask);
line_3->setVisible(newFlags & FontFeatures::NumeralStyleMask);
line_4->setVisible(newFlags & FontFeatures::NumeralWidthMask);
line_5->setVisible(newFlags & FontFeatures::NumeralFractionsMask);
line_6->setVisible(newFlags & FontFeatures::GlyphPositionMask);
line_7->setVisible(SlashedZeroCheck->isVisible());
 
// Do not trigger item relayout unnecessarily,
// that can hurt text typing speed
if (oldFlags != featureFlags())
emit needsRelayout();
}
 
quint64 PropertyWidget_FontFeatures::featureFlags()
{
quint64 flags = 0;
 
if (CommonCheck->isVisible())
flags |= FontFeatures::CommonLigatures;
if (ContextualCheck->isVisible())
flags |= FontFeatures::ContextualLigatures;
if (DiscretionaryCheck->isVisible())
flags |= FontFeatures::DiscretionaryLigatures;
if (HistoricalCheck->isVisible())
flags |= FontFeatures::HistoricalLigatures;
 
if (SmallRadio->isVisible())
flags |= FontFeatures::SmallCaps;
if (SmallFromCRadio->isVisible())
flags |= FontFeatures::SmallCapsFromCaps;
if (PetiteRadio->isVisible())
flags |= FontFeatures::PetiteCaps;
if (PetiteCapRadio->isVisible())
flags |= FontFeatures::PetiteCapsFromCaps;
if (UnicaseRadio->isVisible())
flags |= FontFeatures::UnicaseCaps;
if (TiltingRadio->isVisible())
flags |= FontFeatures::TiltingCaps;
 
if (LiningRadio->isVisible())
flags |= FontFeatures::LiningNumerals;
if (OldStyleRadio->isVisible())
flags |= FontFeatures::OldStyleNumerals;
 
if (ProportionalRadio->isVisible())
flags |= FontFeatures::ProportionalNumeralWidth;
if (TabularRadio->isVisible())
flags |= FontFeatures::TabularNumeralWidth;
 
if (DiagonalRadio->isVisible())
flags |= FontFeatures::DiagonalFractions;
if (StackedRadio->isVisible())
flags |= FontFeatures::StackedFractions;
 
if (SubscriptRadio->isVisible())
flags |= FontFeatures::Subscript;
if (SuperscriptRadio->isVisible())
flags |= FontFeatures::Superscript;
if (OrdinalCheck->isVisible())
flags |= FontFeatures::Ordinals;
 
if (SlashedZeroCheck->isVisible())
flags |= FontFeatures::SlashedZero;
 
if (StyleSet01->isVisible())
flags |= FontFeatures::StyleSet01;
if (StyleSet02->isVisible())
flags |= FontFeatures::StyleSet02;
if (StyleSet03->isVisible())
flags |= FontFeatures::StyleSet03;
if (StyleSet04->isVisible())
flags |= FontFeatures::StyleSet04;
if (StyleSet05->isVisible())
flags |= FontFeatures::StyleSet05;
if (StyleSet06->isVisible())
flags |= FontFeatures::StyleSet06;
if (StyleSet07->isVisible())
flags |= FontFeatures::StyleSet07;
if (StyleSet08->isVisible())
flags |= FontFeatures::StyleSet08;
if (StyleSet09->isVisible())
flags |= FontFeatures::StyleSet09;
if (StyleSet10->isVisible())
flags |= FontFeatures::StyleSet10;
if (StyleSet11->isVisible())
flags |= FontFeatures::StyleSet11;
if (StyleSet12->isVisible())
flags |= FontFeatures::StyleSet12;
if (StyleSet13->isVisible())
flags |= FontFeatures::StyleSet13;
if (StyleSet14->isVisible())
flags |= FontFeatures::StyleSet14;
if (StyleSet15->isVisible())
flags |= FontFeatures::StyleSet15;
if (StyleSet16->isVisible())
flags |= FontFeatures::StyleSet16;
if (StyleSet17->isVisible())
flags |= FontFeatures::StyleSet17;
if (StyleSet18->isVisible())
flags |= FontFeatures::StyleSet18;
if (StyleSet19->isVisible())
flags |= FontFeatures::StyleSet19;
if (StyleSet20->isVisible())
flags |= FontFeatures::StyleSet20;
 
return flags;
}
 
void PropertyWidget_FontFeatures::configureWidgets()
{
bool enabled = false;
if (m_item && m_doc)
{
if (m_item->isPathText() || m_item->isTextFrame() || m_item->isTable())
enabled = true;
if ((m_item->isGroup()) && (!m_item->isSingleSel))
enabled = false;
if (m_item->isOSGFrame() || m_item->isSymbol())
enabled = false;
if (m_doc->m_Selection->count() > 1)
enabled = false;
}
setEnabled(enabled);
}
 
void PropertyWidget_FontFeatures::initWidgets()
{
CommonCheck->setChecked(true);
ContextualCheck->setChecked(true);
DiscretionaryCheck->setChecked(false);
HistoricalCheck->setChecked(false);
NormalCapRadio->setChecked(true);
SmallRadio->setChecked(false);
SmallFromCRadio->setChecked(false);
PetiteRadio->setChecked(false);
PetiteCapRadio->setChecked(false);
UnicaseRadio->setChecked(false);
TiltingRadio->setChecked(false);
 
DefaultStyleRadio->setChecked(true);
LiningRadio->setChecked(false);
OldStyleRadio->setChecked(false);
 
DefaultWidthRadio->setChecked(true);
ProportionalRadio->setChecked(false);
TabularRadio->setChecked(false);
DefaultFractionsRadio->setChecked(true);
DiagonalRadio->setChecked(false);
StackedRadio->setChecked(false);
 
DefaultPosRadio->setChecked(true);
SubscriptRadio->setChecked(false);
SuperscriptRadio->setChecked(false);
OrdinalCheck->setChecked(false);
 
SlashedZeroCheck->setChecked(false);
 
StyleSet01->setChecked(false);
StyleSet02->setChecked(false);
StyleSet03->setChecked(false);
StyleSet04->setChecked(false);
StyleSet05->setChecked(false);
StyleSet06->setChecked(false);
StyleSet07->setChecked(false);
StyleSet08->setChecked(false);
StyleSet09->setChecked(false);
StyleSet10->setChecked(false);
StyleSet11->setChecked(false);
StyleSet12->setChecked(false);
StyleSet13->setChecked(false);
StyleSet14->setChecked(false);
StyleSet15->setChecked(false);
StyleSet16->setChecked(false);
StyleSet17->setChecked(false);
StyleSet18->setChecked(false);
StyleSet19->setChecked(false);
StyleSet20->setChecked(false);
}
 
void PropertyWidget_FontFeatures::setCurrentItem(PageItem *item)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
 
if (item && m_doc.isNull())
setDoc(item->doc());
 
m_item = item;
 
disconnectSignals();
configureWidgets();
 
if (m_item)
{
if (m_item->isTextFrame() || m_item->isPathText() || m_item->isTable())
{
ParagraphStyle parStyle = m_item->itemText.defaultStyle();
if (m_doc->appMode == modeEdit)
m_item->currentTextProps(parStyle);
else if (m_doc->appMode == modeEditTable)
m_item->asTable()->activeCell().textFrame()->currentTextProps(parStyle);
updateStyle(parStyle);
}
connectSignals();
}
}
languageChange();
}
 
void PropertyWidget_FontFeatures::setMainWindow(ScribusMainWindow *mw)
{
m_ScMW = mw;
}
 
void PropertyWidget_FontFeatures::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
{
languageChange();
return;
}
QWidget::changeEvent(e);
}
 
void PropertyWidget_FontFeatures::languageChange()
{
retranslateUi(this);
}
 
void PropertyWidget_FontFeatures::showFontFeatures(const QString& s, const QStringList& availableFeatures)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
 
enableFeatures(availableFeatures);
 
QStringList fontFeatures = s.split(',');
ContextualCheck->setChecked(true);
CommonCheck->setChecked(true);
SlashedZeroCheck->setEnabled(true);
for (int i = 0; i < fontFeatures.count(); i++)
{
if (fontFeatures[i] == "-clig")
ContextualCheck->setChecked(false);
else if (fontFeatures[i] == "-liga")
CommonCheck->setChecked(false);
else if (fontFeatures[i] == "+dlig")
DiscretionaryCheck->setChecked(true);
else if (fontFeatures[i] == "+hlig")
HistoricalCheck->setChecked(true);
else if (fontFeatures[i] == "+subs")
SubscriptRadio->setChecked(true);
else if (fontFeatures[i] == "+sups")
SuperscriptRadio->setChecked(true);
else if (fontFeatures[i] == "+smcp")
SmallRadio->setChecked(true);
else if (fontFeatures[i] == "+c2sc")
SmallFromCRadio->setChecked(true);
else if (fontFeatures[i] == "+pcap")
PetiteRadio->setChecked(true);
else if (fontFeatures[i] == "+c2pc")
PetiteCapRadio->setChecked(true);
else if (fontFeatures[i] == "+unic")
UnicaseRadio->setChecked(true);
else if (fontFeatures[i] == "+titl")
TiltingRadio->setChecked(true);
else if (fontFeatures[i] == "+lnum")
LiningRadio->setChecked(true);
else if (fontFeatures[i] == "+onum")
OldStyleRadio->setChecked(true);
else if (fontFeatures[i] == "+pnum")
ProportionalRadio->setChecked(true);
else if (fontFeatures[i] == "+tnum")
TabularRadio->setChecked(true);
else if (fontFeatures[i] == "+frac")
DiagonalRadio->setChecked(true);
else if (fontFeatures[i] == "+afrc")
StackedRadio->setChecked(true);
else if (fontFeatures[i] == "+ordn")
OrdinalCheck->setChecked(true);
else if (fontFeatures[i] == "+zero")
SlashedZeroCheck->setChecked(true);
else if (fontFeatures[i] == "+ss01")
StyleSet01->setChecked(true);
else if (fontFeatures[i] == "+ss02")
StyleSet02->setChecked(true);
else if (fontFeatures[i] == "+ss03")
StyleSet03->setChecked(true);
else if (fontFeatures[i] == "+ss04")
StyleSet04->setChecked(true);
else if (fontFeatures[i] == "+ss05")
StyleSet05->setChecked(true);
else if (fontFeatures[i] == "+ss06")
StyleSet06->setChecked(true);
else if (fontFeatures[i] == "+ss07")
StyleSet07->setChecked(true);
else if (fontFeatures[i] == "+ss08")
StyleSet08->setChecked(true);
else if (fontFeatures[i] == "+ss09")
StyleSet09->setChecked(true);
else if (fontFeatures[i] == "+ss10")
StyleSet10->setChecked(true);
else if (fontFeatures[i] == "+ss11")
StyleSet11->setChecked(true);
else if (fontFeatures[i] == "+ss12")
StyleSet12->setChecked(true);
else if (fontFeatures[i] == "+ss13")
StyleSet13->setChecked(true);
else if (fontFeatures[i] == "+ss14")
StyleSet14->setChecked(true);
else if (fontFeatures[i] == "+ss15")
StyleSet15->setChecked(true);
else if (fontFeatures[i] == "+ss16")
StyleSet16->setChecked(true);
else if (fontFeatures[i] == "+ss17")
StyleSet17->setChecked(true);
else if (fontFeatures[i] == "+ss18")
StyleSet18->setChecked(true);
else if (fontFeatures[i] == "+ss19")
StyleSet19->setChecked(true);
else if (fontFeatures[i] == "+ss20")
StyleSet20->setChecked(true);
}
if (OldStyleRadio->isChecked())
{
SlashedZeroCheck->setChecked(false);
SlashedZeroCheck->setEnabled(false);
}
}
 
void PropertyWidget_FontFeatures::handleFontFeatures()
{
if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
return;
 
// Ligatures
QStringList font_feature ;
if (!CommonCheck->isChecked())
font_feature << "-liga";
if (!ContextualCheck->isChecked())
font_feature << "-clig";
if (DiscretionaryCheck->isChecked())
font_feature << "+dlig";
if (HistoricalCheck->isChecked())
font_feature << "+hlig";
 
//Capitals
if (SmallRadio->isChecked())
font_feature << "+smcp";
if (SmallFromCRadio->isChecked())
font_feature << "+c2sc";
if (PetiteRadio->isChecked())
font_feature << "+pcap";
if (PetiteCapRadio->isChecked())
font_feature << "+c2pc";
if (UnicaseRadio->isChecked())
font_feature << "+unic";
if (TiltingRadio->isChecked())
font_feature << "+titl";
 
//Numeric
if (LiningRadio->isChecked())
font_feature << "+lnum";
if (OldStyleRadio->isChecked())
font_feature << "+onum";
if (ProportionalRadio->isChecked())
font_feature << "+pnum";
if (TabularRadio->isChecked())
font_feature << "+tnum";
if (DiagonalRadio->isChecked())
font_feature << "+frac";
if (StackedRadio->isChecked())
font_feature <<"+afrc";
 
//Position
if (SubscriptRadio->isChecked())
font_feature << "+subs";
if (SuperscriptRadio->isChecked())
font_feature << "+sups";
if (OrdinalCheck->isChecked())
font_feature << "+ordn";
 
if (SlashedZeroCheck->isChecked())
font_feature << "+zero";
 
// Stylistic sets
if (StyleSet01->isChecked())
font_feature << "+ss01";
if (StyleSet02->isChecked())
font_feature << "+ss02";
if (StyleSet03->isChecked())
font_feature << "+ss03";
if (StyleSet04->isChecked())
font_feature << "+ss04";
if (StyleSet05->isChecked())
font_feature << "+ss05";
if (StyleSet06->isChecked())
font_feature << "+ss06";
if (StyleSet07->isChecked())
font_feature << "+ss07";
if (StyleSet08->isChecked())
font_feature << "+ss08";
if (StyleSet09->isChecked())
font_feature << "+ss09";
if (StyleSet10->isChecked())
font_feature << "+ss10";
if (StyleSet11->isChecked())
font_feature << "+ss11";
if (StyleSet12->isChecked())
font_feature << "+ss12";
if (StyleSet13->isChecked())
font_feature << "+ss13";
if (StyleSet14->isChecked())
font_feature << "+ss14";
if (StyleSet15->isChecked())
font_feature << "+ss15";
if (StyleSet16->isChecked())
font_feature << "+ss16";
if (StyleSet17->isChecked())
font_feature << "+ss17";
if (StyleSet18->isChecked())
font_feature << "+ss18";
if (StyleSet19->isChecked())
font_feature << "+ss19";
if (StyleSet20->isChecked())
font_feature << "+ss20";
 
Selection tempSelection(this, false);
tempSelection.addItem(m_item, true);
m_doc->itemSelection_SetFontFeatures(font_feature.join(","), &tempSelection);
}
 
void PropertyWidget_FontFeatures::setDoc(ScribusDoc *d)
{
if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
return;
 
if (m_doc)
{
disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
}
 
m_doc = d;
m_item = nullptr;
 
if (m_doc.isNull())
{
disconnectSignals();
return;
}
 
connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
}
 
void PropertyWidget_FontFeatures::handleSelectionChanged()
{
if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning())
return;
 
PageItem* currItem = currentItemFromSelection();
setCurrentItem(currItem);
updateGeometry();
repaint();
}
 
void PropertyWidget_FontFeatures::updateCharStyle(const CharStyle& charStyle)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
showFontFeatures(charStyle.fontFeatures(), charStyle.font().fontFeatures());
}
 
void PropertyWidget_FontFeatures::updateStyle(const ParagraphStyle& newCurrent)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
 
const CharStyle& charStyle = newCurrent.charStyle();
showFontFeatures(charStyle.fontFeatures(), charStyle.font().fontFeatures());
}
 
void PropertyWidget_FontFeatures::connectSignals()
{
connect(CommonCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(ContextualCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(DiscretionaryCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(HistoricalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(NormalCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SmallRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SmallFromCRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(PetiteRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(PetiteCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(UnicaseRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(TiltingRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(LiningRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(OldStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultWidthRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(ProportionalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(TabularRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultFractionsRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(DiagonalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StackedRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(DefaultPosRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SubscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(SuperscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(OrdinalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(SlashedZeroCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
 
connect(StyleSet01, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet02, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet03, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet04, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet05, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet06, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet07, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet08, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet09, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet10, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet11, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet12, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet13, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet14, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet15, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet16, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet17, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet18, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet19, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
connect(StyleSet20, SIGNAL(clicked()), this, SLOT(handleFontFeatures()), Qt::UniqueConnection);
}
 
void PropertyWidget_FontFeatures::disconnectSignals()
{
disconnect(CommonCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(ContextualCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(DiscretionaryCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(HistoricalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(NormalCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SmallRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SmallFromCRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(PetiteRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(PetiteCapRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(UnicaseRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(TiltingRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(LiningRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(OldStyleRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultWidthRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(ProportionalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(TabularRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultFractionsRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(DiagonalRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StackedRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(DefaultPosRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SubscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(SuperscriptRadio, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(OrdinalCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(SlashedZeroCheck, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
 
disconnect(StyleSet01, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet02, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet03, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet04, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet05, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet06, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet07, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet08, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet09, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet10, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet11, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet12, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet13, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet14, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet15, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet16, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet17, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet18, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet19, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
disconnect(StyleSet20, SIGNAL(clicked()), this, SLOT(handleFontFeatures()));
}
 
void PropertyWidget_FontFeatures::disableAllFeatures()
{
CommonCheck->setChecked(true);
ContextualCheck->setChecked(true);
DiscretionaryCheck->setChecked(false);
HistoricalCheck->setChecked(false);
NormalCapRadio->setChecked(true);
DefaultStyleRadio->setChecked(true);
DefaultWidthRadio->setChecked(true);
DefaultFractionsRadio->setChecked(true);
DefaultPosRadio->setChecked(true);
SlashedZeroCheck->setChecked(false);
 
StyleSet01->setChecked(false);
StyleSet02->setChecked(false);
StyleSet03->setChecked(false);
StyleSet04->setChecked(false);
StyleSet05->setChecked(false);
StyleSet06->setChecked(false);
StyleSet07->setChecked(false);
StyleSet08->setChecked(false);
StyleSet09->setChecked(false);
StyleSet10->setChecked(false);
StyleSet11->setChecked(false);
StyleSet12->setChecked(false);
StyleSet13->setChecked(false);
StyleSet14->setChecked(false);
StyleSet15->setChecked(false);
StyleSet16->setChecked(false);
StyleSet17->setChecked(false);
StyleSet18->setChecked(false);
StyleSet19->setChecked(false);
StyleSet20->setChecked(false);
}
 
void PropertyWidget_FontFeatures::enableFeatures(const QStringList& fontFeatures)
{
quint64 oldFlags = featureFlags();
quint64 newFlags = FontFeatures::fontFlagsFromList(fontFeatures);
 
disableAllFeatures();
 
CommonCheck->setVisible(newFlags & FontFeatures::CommonLigatures);
ContextualCheck->setVisible(newFlags & FontFeatures::ContextualLigatures);
DiscretionaryCheck->setVisible(newFlags & FontFeatures::DiscretionaryLigatures);
HistoricalCheck->setVisible(newFlags & FontFeatures::HistoricalLigatures);
 
SmallRadio->setVisible(newFlags & FontFeatures::SmallCaps);
SmallFromCRadio->setVisible(newFlags & FontFeatures::SmallCapsFromCaps);
PetiteRadio->setVisible(newFlags & FontFeatures::PetiteCaps);
PetiteCapRadio->setVisible(newFlags & FontFeatures::PetiteCapsFromCaps);
UnicaseRadio->setVisible(newFlags & FontFeatures::UnicaseCaps);
TiltingRadio->setVisible(newFlags & FontFeatures::TiltingCaps);
 
LiningRadio->setVisible(newFlags & FontFeatures::LiningNumerals);
OldStyleRadio->setVisible(newFlags & FontFeatures::OldStyleNumerals);
 
ProportionalRadio->setVisible(newFlags & FontFeatures::ProportionalNumeralWidth);
TabularRadio->setVisible(newFlags & FontFeatures::TabularNumeralWidth);
 
DiagonalRadio->setVisible(newFlags & FontFeatures::DiagonalFractions);
StackedRadio->setVisible(newFlags & FontFeatures::StackedFractions);
 
SubscriptRadio->setVisible(newFlags & FontFeatures::Subscript);
SuperscriptRadio->setVisible(newFlags & FontFeatures::Superscript);
OrdinalCheck->setVisible(newFlags & FontFeatures::Ordinals);
 
SlashedZeroCheck->setVisible(newFlags & FontFeatures::SlashedZero);
 
StyleSet01->setVisible(newFlags & FontFeatures::StyleSet01);
StyleSet02->setVisible(newFlags & FontFeatures::StyleSet02);
StyleSet03->setVisible(newFlags & FontFeatures::StyleSet03);
StyleSet04->setVisible(newFlags & FontFeatures::StyleSet04);
StyleSet05->setVisible(newFlags & FontFeatures::StyleSet05);
StyleSet06->setVisible(newFlags & FontFeatures::StyleSet06);
StyleSet07->setVisible(newFlags & FontFeatures::StyleSet07);
StyleSet08->setVisible(newFlags & FontFeatures::StyleSet08);
StyleSet09->setVisible(newFlags & FontFeatures::StyleSet09);
StyleSet10->setVisible(newFlags & FontFeatures::StyleSet10);
StyleSet11->setVisible(newFlags & FontFeatures::StyleSet11);
StyleSet12->setVisible(newFlags & FontFeatures::StyleSet12);
StyleSet13->setVisible(newFlags & FontFeatures::StyleSet13);
StyleSet14->setVisible(newFlags & FontFeatures::StyleSet14);
StyleSet15->setVisible(newFlags & FontFeatures::StyleSet15);
StyleSet16->setVisible(newFlags & FontFeatures::StyleSet16);
StyleSet17->setVisible(newFlags & FontFeatures::StyleSet17);
StyleSet18->setVisible(newFlags & FontFeatures::StyleSet18);
StyleSet19->setVisible(newFlags & FontFeatures::StyleSet19);
StyleSet20->setVisible(newFlags & FontFeatures::StyleSet20);
 
groupBox_7->setVisible(newFlags & FontFeatures::StyleSetsMask);
 
// Hide Default features when their relative ones aren't found in the font.
NormalCapRadio->setVisible(newFlags & FontFeatures::CapsMask);
DefaultStyleRadio->setVisible(newFlags & FontFeatures::NumeralStyleMask);
DefaultWidthRadio->setVisible(newFlags & FontFeatures::NumeralWidthMask);
DefaultFractionsRadio->setVisible(newFlags & FontFeatures::NumeralFractionsMask);
DefaultPosRadio->setVisible(newFlags & FontFeatures::GlyphPositionMask);
 
// Hide Lines
line->setVisible(newFlags & FontFeatures::LigaturesMask);
 
line_2->setVisible(newFlags & FontFeatures::CapsMask);
line_3->setVisible(newFlags & FontFeatures::NumeralStyleMask);
line_4->setVisible(newFlags & FontFeatures::NumeralWidthMask);
line_5->setVisible(newFlags & FontFeatures::NumeralFractionsMask);
line_6->setVisible(newFlags & FontFeatures::GlyphPositionMask);
line_7->setVisible(SlashedZeroCheck->isVisible());
 
// Do not trigger item relayout unnecessarily,
// that can hurt text typing speed
if (oldFlags != featureFlags())
emit needsRelayout();
}
 
quint64 PropertyWidget_FontFeatures::featureFlags()
{
quint64 flags = 0;
 
if (CommonCheck->isVisible())
flags |= FontFeatures::CommonLigatures;
if (ContextualCheck->isVisible())
flags |= FontFeatures::ContextualLigatures;
if (DiscretionaryCheck->isVisible())
flags |= FontFeatures::DiscretionaryLigatures;
if (HistoricalCheck->isVisible())
flags |= FontFeatures::HistoricalLigatures;
 
if (SmallRadio->isVisible())
flags |= FontFeatures::SmallCaps;
if (SmallFromCRadio->isVisible())
flags |= FontFeatures::SmallCapsFromCaps;
if (PetiteRadio->isVisible())
flags |= FontFeatures::PetiteCaps;
if (PetiteCapRadio->isVisible())
flags |= FontFeatures::PetiteCapsFromCaps;
if (UnicaseRadio->isVisible())
flags |= FontFeatures::UnicaseCaps;
if (TiltingRadio->isVisible())
flags |= FontFeatures::TiltingCaps;
 
if (LiningRadio->isVisible())
flags |= FontFeatures::LiningNumerals;
if (OldStyleRadio->isVisible())
flags |= FontFeatures::OldStyleNumerals;
 
if (ProportionalRadio->isVisible())
flags |= FontFeatures::ProportionalNumeralWidth;
if (TabularRadio->isVisible())
flags |= FontFeatures::TabularNumeralWidth;
 
if (DiagonalRadio->isVisible())
flags |= FontFeatures::DiagonalFractions;
if (StackedRadio->isVisible())
flags |= FontFeatures::StackedFractions;
 
if (SubscriptRadio->isVisible())
flags |= FontFeatures::Subscript;
if (SuperscriptRadio->isVisible())
flags |= FontFeatures::Superscript;
if (OrdinalCheck->isVisible())
flags |= FontFeatures::Ordinals;
 
if (SlashedZeroCheck->isVisible())
flags |= FontFeatures::SlashedZero;
 
if (StyleSet01->isVisible())
flags |= FontFeatures::StyleSet01;
if (StyleSet02->isVisible())
flags |= FontFeatures::StyleSet02;
if (StyleSet03->isVisible())
flags |= FontFeatures::StyleSet03;
if (StyleSet04->isVisible())
flags |= FontFeatures::StyleSet04;
if (StyleSet05->isVisible())
flags |= FontFeatures::StyleSet05;
if (StyleSet06->isVisible())
flags |= FontFeatures::StyleSet06;
if (StyleSet07->isVisible())
flags |= FontFeatures::StyleSet07;
if (StyleSet08->isVisible())
flags |= FontFeatures::StyleSet08;
if (StyleSet09->isVisible())
flags |= FontFeatures::StyleSet09;
if (StyleSet10->isVisible())
flags |= FontFeatures::StyleSet10;
if (StyleSet11->isVisible())
flags |= FontFeatures::StyleSet11;
if (StyleSet12->isVisible())
flags |= FontFeatures::StyleSet12;
if (StyleSet13->isVisible())
flags |= FontFeatures::StyleSet13;
if (StyleSet14->isVisible())
flags |= FontFeatures::StyleSet14;
if (StyleSet15->isVisible())
flags |= FontFeatures::StyleSet15;
if (StyleSet16->isVisible())
flags |= FontFeatures::StyleSet16;
if (StyleSet17->isVisible())
flags |= FontFeatures::StyleSet17;
if (StyleSet18->isVisible())
flags |= FontFeatures::StyleSet18;
if (StyleSet19->isVisible())
flags |= FontFeatures::StyleSet19;
if (StyleSet20->isVisible())
flags |= FontFeatures::StyleSet20;
 
return flags;
}
 
void PropertyWidget_FontFeatures::configureWidgets()
{
bool enabled = false;
if (m_item && m_doc)
{
if (m_item->isPathText() || m_item->isTextFrame() || m_item->isTable())
enabled = true;
if ((m_item->isGroup()) && (!m_item->isSingleSel))
enabled = false;
if (m_item->isOSGFrame() || m_item->isSymbol())
enabled = false;
if (m_doc->m_Selection->count() > 1)
enabled = false;
}
setEnabled(enabled);
}
 
void PropertyWidget_FontFeatures::initWidgets()
{
CommonCheck->setChecked(true);
ContextualCheck->setChecked(true);
DiscretionaryCheck->setChecked(false);
HistoricalCheck->setChecked(false);
NormalCapRadio->setChecked(true);
SmallRadio->setChecked(false);
SmallFromCRadio->setChecked(false);
PetiteRadio->setChecked(false);
PetiteCapRadio->setChecked(false);
UnicaseRadio->setChecked(false);
TiltingRadio->setChecked(false);
 
DefaultStyleRadio->setChecked(true);
LiningRadio->setChecked(false);
OldStyleRadio->setChecked(false);
 
DefaultWidthRadio->setChecked(true);
ProportionalRadio->setChecked(false);
TabularRadio->setChecked(false);
DefaultFractionsRadio->setChecked(true);
DiagonalRadio->setChecked(false);
StackedRadio->setChecked(false);
 
DefaultPosRadio->setChecked(true);
SubscriptRadio->setChecked(false);
SuperscriptRadio->setChecked(false);
OrdinalCheck->setChecked(false);
 
SlashedZeroCheck->setChecked(false);
 
StyleSet01->setChecked(false);
StyleSet02->setChecked(false);
StyleSet03->setChecked(false);
StyleSet04->setChecked(false);
StyleSet05->setChecked(false);
StyleSet06->setChecked(false);
StyleSet07->setChecked(false);
StyleSet08->setChecked(false);
StyleSet09->setChecked(false);
StyleSet10->setChecked(false);
StyleSet11->setChecked(false);
StyleSet12->setChecked(false);
StyleSet13->setChecked(false);
StyleSet14->setChecked(false);
StyleSet15->setChecked(false);
StyleSet16->setChecked(false);
StyleSet17->setChecked(false);
StyleSet18->setChecked(false);
StyleSet19->setChecked(false);
StyleSet20->setChecked(false);
}
 
void PropertyWidget_FontFeatures::setCurrentItem(PageItem *item)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;
 
if (item && m_doc.isNull())
setDoc(item->doc());
 
m_item = item;
 
disconnectSignals();
configureWidgets();
 
if (m_item)
{
if (m_item->isTextFrame() || m_item->isPathText() || m_item->isTable())
{
ParagraphStyle parStyle = m_item->itemText.defaultStyle();
if (m_doc->appMode == modeEdit)
m_item->currentTextProps(parStyle);
else if (m_doc->appMode == modeEditTable)
m_item->asTable()->activeCell().textFrame()->currentTextProps(parStyle);
updateStyle(parStyle);
}
connectSignals();
}
}
/trunk/Scribus/scribus/ui/propertywidget_fontfeatures.h
29,8 → 29,6
void connectSignals();
void disconnectSignals();
void disableAllFeatures();
PageItem* m_item;
ScribusMainWindow* m_ScMW;
 
void configureWidgets();
void initWidgets();
39,6 → 37,9
 
quint64 featureFlags();
 
PageItem* m_item { nullptr };
ScribusMainWindow* m_ScMW { nullptr };
 
public slots:
void setMainWindow(ScribusMainWindow *mw);
void setDoc(ScribusDoc *d);
/trunk/Scribus/scribus/ui/propertywidget_hyphenation.cpp
19,9 → 19,6
PropertyWidget_Hyphenation::PropertyWidget_Hyphenation(QWidget* parent)
: QFrame(parent)
{
m_item = nullptr;
m_ScMW = nullptr;
 
setupUi(this);
 
hyphenCharLineEdit->setMaxLength(1);
/trunk/Scribus/scribus/ui/propertywidget_hyphenation.h
27,13 → 27,14
protected:
void connectSignals();
void disconnectSignals();
PageItem* m_item;
ScribusMainWindow* m_ScMW;
 
void configureWidgets();
void setCurrentItem(PageItem *item);
void changeEvent(QEvent *e) override;
 
PageItem* m_item { nullptr };
ScribusMainWindow* m_ScMW { nullptr };
 
public slots:
void setMainWindow(ScribusMainWindow *mw);
void setDoc(ScribusDoc *d);
/trunk/Scribus/scribus/ui/propertywidget_optmargins.cpp
17,9 → 17,6
 
PropertyWidget_OptMargins::PropertyWidget_OptMargins(QWidget* parent) : QFrame(parent)
{
m_item = nullptr;
m_ScMW = nullptr;
 
setupUi(this);
 
layout()->setAlignment(Qt::AlignTop);
/trunk/Scribus/scribus/ui/propertywidget_optmargins.h
27,8 → 27,8
void updateStyle(const ParagraphStyle& newCurrent);
 
protected:
PageItem * m_item;
ScribusMainWindow* m_ScMW;
PageItem * m_item { nullptr };
ScribusMainWindow* m_ScMW { nullptr };
 
void connectSignals();
void disconnectSignals();
/trunk/Scribus/scribus/ui/propertywidget_pareffect.cpp
630,7 → 630,7
connect(m_enhanced, SIGNAL(paletteShown(bool)), bulletCharTableButton, SLOT(setChecked(bool)));
m_enhanced->setDoc(m_doc);
m_enhanced->setEnabled(true);
// QString styleName = peCharStyleCombo->currentText();
 
setCurrentComboItem(m_enhanced->fontSelector, m_item->currentStyle().charStyle().font().scName());
m_enhanced->newFont(m_enhanced->fontSelector->currentIndex());
m_enhanced->show();
/trunk/Scribus/scribus/ui/propertywidgetbase.cpp
21,20 → 21,7
return nullptr;
 
PageItem *currentItem = nullptr;
 
if (m_doc->m_Selection->count() > 1)
{
/*uint lowestItem = 999999;
for (int a=0; a<m_doc->m_Selection->count(); ++a)
{
currentItem = m_doc->m_Selection->itemAt(a);
lowestItem = qMin(lowestItem, currentItem->ItemNr);
}
currentItem = m_doc->Items->at(lowestItem);*/
if (m_doc->m_Selection->count() > 0)
currentItem = m_doc->m_Selection->itemAt(0);
}
else if (m_doc->m_Selection->count() == 1)
currentItem = m_doc->m_Selection->itemAt(0);
 
return currentItem;
}
/trunk/Scribus/scribus/ui/smcellstylewidget.cpp
13,6 → 13,7
#include "smcellstylewidget.h"
 
SMCellStyleWidget::SMCellStyleWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
 
24,10 → 25,6
connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
}
 
SMCellStyleWidget::~SMCellStyleWidget()
{
}
 
void SMCellStyleWidget::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
/trunk/Scribus/scribus/ui/smcellstylewidget.h
28,7 → 28,7
/// Constructor.
SMCellStyleWidget(QWidget* parent = nullptr);
/// Destructor.
~SMCellStyleWidget();
~SMCellStyleWidget() = default;
 
void setDoc(ScribusDoc* doc);
 
/trunk/Scribus/scribus/ui/smcstylewidget.cpp
18,6 → 18,7
 
 
SMCStyleWidget::SMCStyleWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
 
203,7 → 204,7
connect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
}
 
void SMCStyleWidget::show(CharStyle *cstyle, QList<CharStyle> &cstyles, const QString &defLang, int unitIndex)
void SMCStyleWidget::show(const CharStyle *cstyle, const QList<CharStyle> &cstyles, const QString &defLang, int /*unitIndex*/)
{
disconnect(effects_, SIGNAL(State(int)), this, SLOT(slotColorChange()));
parentCombo->setEnabled(!cstyle->isDefaultStyle());
375,11 → 376,8
connect(effects_, SIGNAL(State(int)), this, SLOT(slotColorChange()));
}
 
void SMCStyleWidget::show(QList<CharStyle*> &cstyles, QList<CharStyle> &cstylesAll, const QString &defLang, int unitIndex)
void SMCStyleWidget::show(const QList<CharStyle*> &cstyles, const QList<CharStyle> &cstylesAll, const QString &defLang, int unitIndex)
{
// int decimals = unitGetDecimalsFromIndex(unitIndex);
// QString suffix = unitGetSuffixFromIndex(unitIndex);
 
if (cstyles.count() == 1)
show(cstyles[0], cstylesAll, defLang, unitIndex);
else if (cstyles.count() > 1)
629,7 → 627,7
backColor_->setCurrentText(s);
}
 
void SMCStyleWidget::showLanguage(const QList<CharStyle*> &cstyles, const QString &defLang)
void SMCStyleWidget::showLanguage(const QList<CharStyle*> &cstyles, const QString& /*defLang*/)
{
QString s(cstyles[0]->language());
for (int i = 0; i < cstyles.count(); ++i)
687,7 → 685,7
hyphenCharLineEdit->setValue(hyphenText);
}
 
void SMCStyleWidget::showParent(const QList<CharStyle*> &cstyles)
void SMCStyleWidget::showParent(const QList<CharStyle*>& /*cstyles*/)
{
parentCombo->setEnabled(false);
}
725,9 → 723,3
strokeShade_->setEnabled(enabled);
strokeColor_->setEnabled(enabled);
}
 
 
SMCStyleWidget::~SMCStyleWidget()
{
}
/trunk/Scribus/scribus/ui/smcstylewidget.h
20,11 → 20,11
Q_OBJECT
public:
SMCStyleWidget(QWidget* parent = nullptr);
~SMCStyleWidget();
~SMCStyleWidget() = default;
 
void setDoc(ScribusDoc* doc);
void show(CharStyle *cstyle, QList<CharStyle> &cstyles, const QString &defLang, int unitIndex);
void show(QList<CharStyle*> &cstyles, QList<CharStyle> &cstylesAll, const QString &defLang, int unitIndex);
void show(const CharStyle *cstyle, const QList<CharStyle> &cstyles, const QString &defLang, int unitIndex);
void show(const QList<CharStyle*> &cstyles, const QList<CharStyle> &cstylesAll, const QString &defLang, int unitIndex);
//void fillLangCombo(QMap<QString,QString> langMap);
void fillLangComboFromList(const QStringList& langList);
void fillColorCombo(ColorList &colors);
/trunk/Scribus/scribus/ui/smfontfeatures.cpp
91,7 → 91,7
fractionComboBox->setCurrentIndex(oldFractionIndex);
}
 
QStringList SMFontFeatures::comboboxFeatures(QComboBox* combo)
QStringList SMFontFeatures::comboboxFeatures(QComboBox* combo) const
{
QStringList features;
for (int i = 0; i < combo->count(); ++i)
/trunk/Scribus/scribus/ui/smfontfeatures.h
64,7 → 64,7
void setupNumeralWidthCombo(quint64 featureFlags);
void setupNumeralFractionCombo(quint64 featureFlags);
 
QStringList comboboxFeatures(QComboBox* combo);
QStringList comboboxFeatures(QComboBox* combo) const;
 
bool m_hasParent = false;
bool m_useParentValue = false;
/trunk/Scribus/scribus/ui/smlinestyle.cpp
35,7 → 35,6
m_widget = new SMLineStyleWidget();
m_twidget->addTab(m_widget, tr("Properties"));
unitChange();
// connect(m_widget->lineStyles, SIGNAL(highlighted(int)), this, SLOT(slotCurrentLineChanged(int)));
connect(m_widget->lineStyles, SIGNAL(currentRowChanged(int)), this, SLOT(slotCurrentLineChanged(int)));
}
return m_twidget;
569,8 → 568,7
{
double unitRatio = m_widget->lineWidth->unitRatio();
 
QHash<QString, multiLine*>::iterator it;
for (it = m_selection.begin(); it != m_selection.end(); ++it)
for (auto it = m_selection.begin(); it != m_selection.end(); ++it)
{
multiLine *tmp = it.value();
(*tmp)[m_currentLine].Width = m_widget->lineWidth->value() / unitRatio;
636,8 → 634,8
 
m_widget->lineStyles->clear();
 
multiLine *tmpLine = m_selection.begin().value();
for (multiLine::iterator it = tmpLine->begin(); it != tmpLine->end(); ++it)
const multiLine *tmpLine = m_selection.begin().value();
for (auto it = tmpLine->begin(); it != tmpLine->end(); ++it)
{
pm2 = getWidePixmap(calcFarbe(it->Color, it->Shade));
tmp2 = " "+ tmp.setNum(it->Width * unitRatio, 'f', decimals) + unitSuffix + " ";
720,7 → 718,7
if (m_selection.count() < 1)
return;
QPixmap pm = QPixmap(200, 37);
QPixmap pm(200, 37);
pm.fill(Qt::white);
QPainter p;
p.begin(&pm);
/trunk/Scribus/scribus/ui/smlinestylewidget.cpp
209,8 → 209,3
QColor tmpf = ScColorEngine::getDisplayColor(color, m_colors.document(), shade);
return tmpf;
}
 
SMLineStyleWidget::~SMLineStyleWidget()
{
}
/trunk/Scribus/scribus/ui/smlinestylewidget.h
24,7 → 24,7
 
public:
SMLineStyleWidget();
~SMLineStyleWidget();
~SMLineStyleWidget() = default;
void showStyle(const multiLine &lineStyle, ColorList &colorList, int subLine = 0);
void unitChange(int unitIndex);
/trunk/Scribus/scribus/ui/smpstylewidget.cpp
574,7 → 574,7
backColor_->setCurrentText(s);
}
 
void SMPStyleWidget::showLineSpacing(QList<ParagraphStyle*> &pstyles)
void SMPStyleWidget::showLineSpacing(const QList<ParagraphStyle*> &pstyles)
{
lineSpacingMode->clear();
lineSpacingMode->addItem( tr("Fixed Linespacing"));
618,7 → 618,7
lineSpacing->setValue(tmpLS);
}
 
void SMPStyleWidget::showSpaceAB(QList<ParagraphStyle*> &pstyles, int unitIndex)
void SMPStyleWidget::showSpaceAB(const QList<ParagraphStyle*> &pstyles, int unitIndex)
{
// double unitRatio = unitGetRatioFromIndex(unitIndex);
double tmpA = -1.2;
653,7 → 653,7
spaceBelow->setValue(tmpA);
}
 
void SMPStyleWidget::showDropCap(QList<ParagraphStyle*> &pstyles, QList<CharStyle> &cstyles, int unitIndex)
void SMPStyleWidget::showDropCap(const QList<ParagraphStyle*> &pstyles, const QList<CharStyle> &cstyles, int unitIndex)
{
disconnectPESignals();
bool dc = pstyles[0]->hasDropCap();
687,7 → 687,7
connectPESignals();
}
 
void SMPStyleWidget::showBullet(QList<ParagraphStyle *> &pstyles, QList<CharStyle> &cstyles, int unitIndex)
void SMPStyleWidget::showBullet(const QList<ParagraphStyle *> &pstyles, const QList<CharStyle> &cstyles, int unitIndex)
{
// double unitRatio = unitGetRatioFromIndex(unitIndex);
 
719,7 → 719,7
bulletCharTableButton->setEnabled(true);
}
 
void SMPStyleWidget::showNumeration(QList<ParagraphStyle *> &pstyles, QList<CharStyle> &cstyles, int unitIndex)
void SMPStyleWidget::showNumeration(const QList<ParagraphStyle *> &pstyles, const QList<CharStyle> &cstyles, int unitIndex)
{
disconnectPESignals();
QString prefix = pstyles[0]->numPrefix();
751,7 → 751,7
connectPESignals();
}
 
void SMPStyleWidget::showAlignment(QList<ParagraphStyle*> &pstyles)
void SMPStyleWidget::showAlignment(const QList<ParagraphStyle*> &pstyles)
{
if (pstyles.isEmpty())
{
775,7 → 775,7
alignment->setStyle(a, direction->getStyle());
}
 
void SMPStyleWidget::showDirection(QList<ParagraphStyle*> &pstyles)
void SMPStyleWidget::showDirection(const QList<ParagraphStyle*> &pstyles)
{
if (pstyles.isEmpty())
{
799,7 → 799,7
direction->setStyle(a);
}
 
void SMPStyleWidget::showOpticalMargin(QList< ParagraphStyle * > & pstyles)
void SMPStyleWidget::showOpticalMargin(const QList< ParagraphStyle * > & pstyles)
{
if (pstyles.isEmpty())
{
829,7 → 829,7
setOpticalMargins(pstyles[0]->opticalMargins());
}
 
void SMPStyleWidget::showMinSpace(QList< ParagraphStyle * > & pstyles)
void SMPStyleWidget::showMinSpace(const QList< ParagraphStyle * > & pstyles)
{
if (pstyles.isEmpty())
{
849,7 → 849,7
minSpaceSpin->setValue(ms * 100.0);
}
 
void SMPStyleWidget::showMinGlyphExt(QList< ParagraphStyle * > & pstyles)
void SMPStyleWidget::showMinGlyphExt(const QList< ParagraphStyle * > & pstyles)
{
if (pstyles.isEmpty())
{
869,7 → 869,7
minGlyphExtSpin->setValue(mge * 100.0);
}
 
void SMPStyleWidget::showMaxGlyphExt(QList< ParagraphStyle * > & pstyles)
void SMPStyleWidget::showMaxGlyphExt(const QList< ParagraphStyle * > & pstyles)
{
if (pstyles.isEmpty())
{
889,7 → 889,7
maxGlyphExtSpin->setValue(mge * 100.0);
}
 
void SMPStyleWidget::showConsecutiveLines(QList<ParagraphStyle *> &pstyles)
void SMPStyleWidget::showConsecutiveLines(const QList<ParagraphStyle *> &pstyles)
{
 
if (pstyles.isEmpty())
912,7 → 912,7
}
 
 
void SMPStyleWidget::showTabs(QList<ParagraphStyle*> &pstyles, int unitIndex)
void SMPStyleWidget::showTabs(const QList<ParagraphStyle*> &pstyles, int unitIndex)
{
double unitRatio = unitGetRatioFromIndex(unitIndex);
QList<ParagraphStyle::TabRecord> t = pstyles[0]->tabValues();
982,7 → 982,7
 
}
 
void SMPStyleWidget::showCStyle(QList<ParagraphStyle*> &pstyles, QList<CharStyle> &cstyles, const QString &defLang, int unitIndex)
void SMPStyleWidget::showCStyle(const QList<ParagraphStyle*> &pstyles, const QList<CharStyle> &cstyles, const QString &defLang, int unitIndex)
{
cpage->parentLabel->setText( tr("Based On:"));
 
993,7 → 993,7
cpage->show(cstyle, cstyles, defLang, unitIndex);
}
 
void SMPStyleWidget::showParent(QList<ParagraphStyle*> &pstyles)
void SMPStyleWidget::showParent(const QList<ParagraphStyle*> &pstyles)
{
parentCombo->setEnabled(false);
 
1187,11 → 1187,6
connectPESignals();
}
 
SMPStyleWidget::~SMPStyleWidget()
{
}
 
void SMPStyleWidget::openEnhanced()
{
if (m_enhanced)
/trunk/Scribus/scribus/ui/smpstylewidget.h
24,7 → 24,7
 
public:
SMPStyleWidget(ScribusDoc *doc, StyleSet<CharStyle> *cstyles);
~SMPStyleWidget();
~SMPStyleWidget() = default;
 
void show(ParagraphStyle *pstyle, QList<ParagraphStyle> &pstyles, QList<CharStyle> &cstyles, int unitIndex, const QString &defLang);
void show(QList<ParagraphStyle*> &pstyles, QList<ParagraphStyle> &pstylesAll, QList<CharStyle> &cstyles, int unitIndex, const QString &defLang);
54,21 → 54,21
void fillNumRestartCombo();
void checkParEffectState();
void showColors(const QList<ParagraphStyle*> &cstyles);
void showLineSpacing(QList<ParagraphStyle*> &pstyles);
void showSpaceAB(QList<ParagraphStyle*> &pstyles, int unitIndex);
void showDropCap(QList<ParagraphStyle*> &pstyles, QList<CharStyle> &cstyles, int unitIndex);
void showBullet(QList<ParagraphStyle*> &pstyles, QList<CharStyle> &cstyles, int unitIndex);
void showNumeration(QList<ParagraphStyle*> &pstyles, QList<CharStyle> &cstyles, int unitIndex);
void showAlignment(QList<ParagraphStyle*> &pstyles);
void showDirection(QList<ParagraphStyle*> &pstyles);
void showOpticalMargin(QList<ParagraphStyle*> &pstyles);
void showMinSpace(QList<ParagraphStyle*> &pstyles);
void showMinGlyphExt(QList<ParagraphStyle*> &pstyles);
void showMaxGlyphExt(QList<ParagraphStyle*> &pstyles);
void showConsecutiveLines(QList<ParagraphStyle*> &pstyles);
void showTabs(QList<ParagraphStyle*> &pstyles, int unitIndex);
void showCStyle(QList<ParagraphStyle*> &pstyles, QList<CharStyle> &cstyles, const QString &defLang, int unitIndex);
void showParent(QList<ParagraphStyle*> &pstyles);
void showLineSpacing(const QList<ParagraphStyle*> &pstyles);
void showSpaceAB(const QList<ParagraphStyle*> &pstyles, int unitIndex);
void showDropCap(const QList<ParagraphStyle*> &pstyles, const QList<CharStyle> &cstyles, int unitIndex);
void showBullet(const QList<ParagraphStyle*> &pstyles, const QList<CharStyle> &cstyles, int unitIndex);
void showNumeration(const QList<ParagraphStyle*> &pstyles, const QList<CharStyle> &cstyles, int unitIndex);
void showAlignment(const QList<ParagraphStyle*> &pstyles);
void showDirection(const QList<ParagraphStyle*> &pstyles);
void showOpticalMargin(const QList<ParagraphStyle*> &pstyles);
void showMinSpace(const QList<ParagraphStyle*> &pstyles);
void showMinGlyphExt(const QList<ParagraphStyle*> &pstyles);
void showMaxGlyphExt(const QList<ParagraphStyle*> &pstyles);
void showConsecutiveLines(const QList<ParagraphStyle*> &pstyles);
void showTabs(const QList<ParagraphStyle*> &pstyles, int unitIndex);
void showCStyle(const QList<ParagraphStyle*> &pstyles, const QList<CharStyle> &cstyles, const QString &defLang, int unitIndex);
void showParent(const QList<ParagraphStyle*> &pstyles);
void setOpticalMargins(int o, bool inhO=false, const ParagraphStyle *parent=nullptr);
 
void openEnhanced();
/trunk/Scribus/scribus/ui/smreplacedia.cpp
25,12 → 25,12
layout->addWidget(optionsCombo);
}
 
QString SMRowWidget::toBeDeleted()
QString SMRowWidget::toBeDeleted() const
{
return deleteLabel->text();
}
 
QString SMRowWidget::replaceWith()
QString SMRowWidget::replaceWith() const
{
return optionsCombo->currentIndex() == 0 ? "" : optionsCombo->currentText();
}
77,7 → 77,7
layout->addStretch(10);
}
 
QList<RemoveItem> SMReplaceDia::items()
QList<RemoveItem> SMReplaceDia::items() const
{
QList<RemoveItem> tmp;
for (int i = 0; i < rowWidgets.count(); ++i)
/trunk/Scribus/scribus/ui/smreplacedia.h
25,8 → 25,8
SMRowWidget(const QString &toBeDeleted, const QStringList& replaceOptions, QWidget *parent);
~SMRowWidget();
 
QString toBeDeleted();
QString replaceWith();
QString toBeDeleted() const;
QString replaceWith() const;
 
private:
QHBoxLayout *layout;
44,7 → 44,7
SMReplaceDia(const QStringList &toBeDeleted, const QStringList &replaceOptions, QWidget *parent);
~SMReplaceDia();
 
QList<RemoveItem> items();
QList<RemoveItem> items() const;
 
private:
QVBoxLayout *layout;
/trunk/Scribus/scribus/ui/smshadebutton.cpp
55,7 → 55,7
return ret;
}
 
QString SMShadeButton::useParentValueText()
QString SMShadeButton::useParentValueText() const
{
QString trText = tr("Use Parent Value");
return trText;
/trunk/Scribus/scribus/ui/smshadebutton.h
28,7 → 28,7
bool m_useParentValue = false;
int m_pValue = 0;
 
QString useParentValueText();
QString useParentValueText() const;
void setFont(bool wantBold);
 
private slots:
/trunk/Scribus/scribus/ui/smtablestylewidget.cpp
13,6 → 13,7
#include "smtablestylewidget.h"
 
SMTableStyleWidget::SMTableStyleWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
 
24,10 → 25,6
connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
}
 
SMTableStyleWidget::~SMTableStyleWidget()
{
}
 
void SMTableStyleWidget::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
63,7 → 60,7
connect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
}
 
void SMTableStyleWidget::show(TableStyle *tableStyle, QList<TableStyle> &tableStyles, const QString &defLang, int unitIndex)
void SMTableStyleWidget::show(TableStyle *tableStyle, QList<TableStyle> &tableStyles, const QString& /*defLang*/, int /*unitIndex*/)
{
Q_ASSERT(tableStyle);
if (!tableStyle)
/trunk/Scribus/scribus/ui/smtablestylewidget.h
27,7 → 27,7
/// Constructor.
SMTableStyleWidget(QWidget* parent = nullptr);
/// Destructor.
~SMTableStyleWidget();
~SMTableStyleWidget() = default;
 
void setDoc(ScribusDoc* doc);
 
/trunk/Scribus/scribus/ui/smtabruler.cpp
1,38 → 1,38
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include <QToolButton>
#include <QSignalBlocker>
 
#include "smtabruler.h"
#include "smscrspinbox.h"
#include "units.h"
 
 
SMTabruler::SMTabruler(QWidget* parent, bool haveFirst, int dEin, QList<ParagraphStyle::TabRecord> Tabs, double wid)
: Tabruler(parent, haveFirst, dEin, Tabs, wid)
{
m_parentButton = new QToolButton(this);
Q_CHECK_PTR(m_parentButton);
m_parentButton->setText( tr(" Parent Tabs "));
indentLayout->addWidget(m_parentButton);
m_parentButton->hide();
QFont f(font());
f.setBold(true);
m_parentButton->setFont(f);
connect(m_parentButton, SIGNAL(clicked()), this, SLOT(pbClicked()));
firstLineSpin = new SMScrSpinBox(-3000, 4000, this, dEin);
Q_CHECK_PTR(firstLineSpin);
leftIndentSpin = new SMScrSpinBox(0, 4000, this, dEin);
Q_CHECK_PTR(leftIndentSpin);
rightIndentSpin = new SMScrSpinBox(0, 4000, this, dEin);
Q_CHECK_PTR(rightIndentSpin);
 
indentLayout->removeWidget(firstLineData);
firstLineData->hide();
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include <QToolButton>
#include <QSignalBlocker>
 
#include "smtabruler.h"
#include "smscrspinbox.h"
#include "units.h"
 
 
SMTabruler::SMTabruler(QWidget* parent, bool haveFirst, int dEin, QList<ParagraphStyle::TabRecord> Tabs, double wid)
: Tabruler(parent, haveFirst, dEin, Tabs, wid)
{
m_parentButton = new QToolButton(this);
Q_CHECK_PTR(m_parentButton);
m_parentButton->setText( tr(" Parent Tabs "));
indentLayout->addWidget(m_parentButton);
m_parentButton->hide();
QFont f(font());
f.setBold(true);
m_parentButton->setFont(f);
connect(m_parentButton, SIGNAL(clicked()), this, SLOT(pbClicked()));
firstLineSpin = new SMScrSpinBox(-3000, 4000, this, dEin);
Q_CHECK_PTR(firstLineSpin);
leftIndentSpin = new SMScrSpinBox(0, 4000, this, dEin);
Q_CHECK_PTR(leftIndentSpin);
rightIndentSpin = new SMScrSpinBox(0, 4000, this, dEin);
Q_CHECK_PTR(rightIndentSpin);
 
indentLayout->removeWidget(firstLineData);
firstLineData->hide();
indentLayout->insertWidget(1, firstLineSpin);
firstLineSpin->show();
 
47,340 → 47,340
rightIndentSpin->show();
 
connect(firstLineData, SIGNAL(valueChanged(double)), this, SLOT(firstDataChanged()));
connect(rightIndentData, SIGNAL(valueChanged(double)), this, SLOT(rightDataChanged()));
connect(leftIndentData, SIGNAL(valueChanged(double)), this, SLOT(leftDataChanged()));
 
connect(firstLineSpin, SIGNAL(valueChanged(double)), this, SLOT(firstValueChanged()));
connect(rightIndentSpin, SIGNAL(valueChanged(double)), this, SLOT(rightValueChanged()));
connect(leftIndentSpin, SIGNAL(valueChanged(double)), this, SLOT(leftValueChanged()));
}
 
void SMTabruler::unitChange(int unitIndex)
{
this->blockSignals(true);
Tabruler::setTabs(ruler->tabValues, unitIndex);
Tabruler::repaint();
 
firstLineSpin->blockSignals(true);
leftIndentSpin->blockSignals(true);
rightIndentSpin->blockSignals(true);
tabData->blockSignals(true);
 
firstLineSpin->setNewUnit(unitIndex);
leftIndentSpin->setNewUnit(unitIndex);
rightIndentSpin->setNewUnit(unitIndex);
tabData->setNewUnit(unitIndex);
 
firstLineSpin->blockSignals(false);
leftIndentSpin->blockSignals(false);
rightIndentSpin->blockSignals(false);
tabData->blockSignals(false);
 
m_unitIndex = unitIndex;
this->blockSignals(false);
}
 
void SMTabruler::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int unitIndex)
{
disconnect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
disconnect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
m_hasParent = false;
m_parentButton->hide();
Tabruler::setTabs(Tabs, unitIndex);
Tabruler::repaint();
firstLineSpin->setNewUnit(unitIndex);
leftIndentSpin->setNewUnit(unitIndex);
rightIndentSpin->setNewUnit(unitIndex);
tabData->setNewUnit(unitIndex);
}
 
void SMTabruler::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int unitIndex, bool isParentValue)
{
disconnect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
disconnect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
m_hasParent = true;
m_unitIndex = unitIndex;
if (isParentValue)
m_parentButton->hide();
else
m_parentButton->show();
Tabruler::setTabs(Tabs, unitIndex);
Tabruler::repaint();
firstLineSpin->setNewUnit(unitIndex);
leftIndentSpin->setNewUnit(unitIndex);
rightIndentSpin->setNewUnit(unitIndex);
tabData->setNewUnit(unitIndex);
 
connect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
connect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
}
 
void SMTabruler::setParentTabs(const QList<ParagraphStyle::TabRecord>& Tabs)
{
m_hasParent = true;
m_parentTabs = Tabs;
}
 
void SMTabruler::setFirstLineValue(double t)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
firstLineSpin->setValue(t);
firstLineData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setFirstLineValue(double t, bool isParentValue)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
m_isSetupFirst = true;
firstLineSpin->setValue(t, isParentValue);
firstLineData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setParentFirstLine(double t)
{
firstLineSpin->setParentValue(t);
}
 
void SMTabruler::setLeftIndentValue(double t)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
leftIndentSpin->setValue(t);
leftIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setLeftIndentValue(double t, bool isParentValue)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
m_isSetupLeft = true;
leftIndentSpin->setValue(t, isParentValue);
leftIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setParentLeftIndent(double t)
{
leftIndentSpin->setParentValue(t);
}
 
void SMTabruler::setRightIndentValue(double t)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
rightIndentSpin->setValue(t);
rightIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setRightIndentValue(double t, bool isParentValue)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
m_isSetupRight = true;
rightIndentSpin->setValue(t, isParentValue);
rightIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setParentRightIndent(double t)
{
rightIndentSpin->setParentValue(t);
}
 
bool SMTabruler::useParentTabs()
{
bool ret = m_useParentTabs;
if (ret && m_hasParent)
{
setTabs(m_parentTabs, m_unitIndex, true);
Tabruler::repaint();
m_parentButton->hide();
m_useParentTabs = false;
}
else if (m_hasParent)
{
m_parentButton->show();
}
 
return ret;
}
 
bool SMTabruler::useParentFirstLine()
{
return firstLineSpin->useParentValue();
}
 
bool SMTabruler::useParentLeftIndent()
{
return leftIndentSpin->useParentValue();
}
 
bool SMTabruler::useParentRightIndent()
{
return rightIndentSpin->useParentValue();
}
 
void SMTabruler::slotTabsChanged()
{
if (m_hasParent)
{
m_useParentTabs = false;
m_tabsChanged = true;
}
}
 
void SMTabruler::pbClicked()
{
if (m_hasParent)
{
m_useParentTabs = true;
emit mouseReleased();
}
}
 
void SMTabruler::leftDataChanged()
{
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
double a, b, value;
int c;
leftIndentData->getValues(&a, &b, &c, &value);
if (m_hasParent && !m_isSetupLeft)
leftIndentSpin->setValue(value, false);
else if (!m_hasParent)
leftIndentSpin->setValue(value);
 
m_isSetupLeft = false;
}
 
void SMTabruler::rightDataChanged()
{
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
double a, b, value;
int c;
rightIndentData->getValues(&a, &b, &c, &value);
if (m_hasParent && !m_isSetupRight)
rightIndentSpin->setValue(value, false);
else if (!m_hasParent)
rightIndentSpin->setValue(value);
 
m_isSetupRight = false;
}
 
void SMTabruler::firstDataChanged()
{
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
double a, b, value;
int c;
firstLineData->getValues(&a, &b, &c, &value);
if (m_hasParent && !m_isSetupFirst)
firstLineSpin->setValue(value, false);
else if (!m_hasParent)
firstLineSpin->setValue(value);
 
m_isSetupFirst = false;
}
 
void SMTabruler::firstValueChanged()
{
// QSignalBlocker firstLineDataBlocker(firstLineData);
// QSignalBlocker rightIndentDataBlocker(rightIndentData);
// QSignalBlocker leftIndentDataBlocker(leftIndentData);
 
double a, b, value;
int c;
firstLineSpin->getValues(&a, &b, &c, &value);
setFirstLineData(value / m_docUnitRatio);
setFirstLine();
setLeftIndent();
setRightIndent();
m_isSetupFirst = true;
}
 
void SMTabruler::leftValueChanged()
{
// QSignalBlocker firstLineDataBlocker(firstLineData);
// QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
 
double a, b, value;
int c;
leftIndentSpin->getValues(&a, &b, &c, &value);
setLeftIndentData(value / m_docUnitRatio);
setLeftIndent();
// setFirstLine();
setRightIndent();
m_isSetupLeft = true;
}
 
void SMTabruler::rightValueChanged()
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
 
double a, b, value;
int c;
rightIndentSpin->getValues(&a, &b, &c, &value);
setRightIndentData(value / m_docUnitRatio);
setLeftIndent();
setFirstLine();
setRightIndent();
m_isSetupRight = true;
}
connect(rightIndentData, SIGNAL(valueChanged(double)), this, SLOT(rightDataChanged()));
connect(leftIndentData, SIGNAL(valueChanged(double)), this, SLOT(leftDataChanged()));
 
connect(firstLineSpin, SIGNAL(valueChanged(double)), this, SLOT(firstValueChanged()));
connect(rightIndentSpin, SIGNAL(valueChanged(double)), this, SLOT(rightValueChanged()));
connect(leftIndentSpin, SIGNAL(valueChanged(double)), this, SLOT(leftValueChanged()));
}
 
void SMTabruler::unitChange(int unitIndex)
{
this->blockSignals(true);
Tabruler::setTabs(ruler->tabValues, unitIndex);
Tabruler::repaint();
 
firstLineSpin->blockSignals(true);
leftIndentSpin->blockSignals(true);
rightIndentSpin->blockSignals(true);
tabData->blockSignals(true);
 
firstLineSpin->setNewUnit(unitIndex);
leftIndentSpin->setNewUnit(unitIndex);
rightIndentSpin->setNewUnit(unitIndex);
tabData->setNewUnit(unitIndex);
 
firstLineSpin->blockSignals(false);
leftIndentSpin->blockSignals(false);
rightIndentSpin->blockSignals(false);
tabData->blockSignals(false);
 
m_unitIndex = unitIndex;
this->blockSignals(false);
}
 
void SMTabruler::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int unitIndex)
{
disconnect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
disconnect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
m_hasParent = false;
m_parentButton->hide();
Tabruler::setTabs(Tabs, unitIndex);
Tabruler::repaint();
firstLineSpin->setNewUnit(unitIndex);
leftIndentSpin->setNewUnit(unitIndex);
rightIndentSpin->setNewUnit(unitIndex);
tabData->setNewUnit(unitIndex);
}
 
void SMTabruler::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int unitIndex, bool isParentValue)
{
disconnect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
disconnect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
m_hasParent = true;
m_unitIndex = unitIndex;
if (isParentValue)
m_parentButton->hide();
else
m_parentButton->show();
Tabruler::setTabs(Tabs, unitIndex);
Tabruler::repaint();
firstLineSpin->setNewUnit(unitIndex);
leftIndentSpin->setNewUnit(unitIndex);
rightIndentSpin->setNewUnit(unitIndex);
tabData->setNewUnit(unitIndex);
 
connect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
connect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
}
 
void SMTabruler::setParentTabs(const QList<ParagraphStyle::TabRecord>& Tabs)
{
m_hasParent = true;
m_parentTabs = Tabs;
}
 
void SMTabruler::setFirstLineValue(double t)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
firstLineSpin->setValue(t);
firstLineData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setFirstLineValue(double t, bool isParentValue)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
m_isSetupFirst = true;
firstLineSpin->setValue(t, isParentValue);
firstLineData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setParentFirstLine(double t)
{
firstLineSpin->setParentValue(t);
}
 
void SMTabruler::setLeftIndentValue(double t)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
leftIndentSpin->setValue(t);
leftIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setLeftIndentValue(double t, bool isParentValue)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
m_isSetupLeft = true;
leftIndentSpin->setValue(t, isParentValue);
leftIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setParentLeftIndent(double t)
{
leftIndentSpin->setParentValue(t);
}
 
void SMTabruler::setRightIndentValue(double t)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
rightIndentSpin->setValue(t);
rightIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setRightIndentValue(double t, bool isParentValue)
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
m_isSetupRight = true;
rightIndentSpin->setValue(t, isParentValue);
rightIndentData->setValue(t);
setLeftIndent();
setFirstLine();
setRightIndent();
}
 
void SMTabruler::setParentRightIndent(double t)
{
rightIndentSpin->setParentValue(t);
}
 
bool SMTabruler::useParentTabs()
{
bool ret = m_useParentTabs;
if (ret && m_hasParent)
{
setTabs(m_parentTabs, m_unitIndex, true);
Tabruler::repaint();
m_parentButton->hide();
m_useParentTabs = false;
}
else if (m_hasParent)
{
m_parentButton->show();
}
 
return ret;
}
 
bool SMTabruler::useParentFirstLine()
{
return firstLineSpin->useParentValue();
}
 
bool SMTabruler::useParentLeftIndent()
{
return leftIndentSpin->useParentValue();
}
 
bool SMTabruler::useParentRightIndent()
{
return rightIndentSpin->useParentValue();
}
 
void SMTabruler::slotTabsChanged()
{
if (m_hasParent)
{
m_useParentTabs = false;
m_tabsChanged = true;
}
}
 
void SMTabruler::pbClicked()
{
if (m_hasParent)
{
m_useParentTabs = true;
emit mouseReleased();
}
}
 
void SMTabruler::leftDataChanged()
{
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
double a, b, value;
int c;
leftIndentData->getValues(&a, &b, &c, &value);
if (m_hasParent && !m_isSetupLeft)
leftIndentSpin->setValue(value, false);
else if (!m_hasParent)
leftIndentSpin->setValue(value);
 
m_isSetupLeft = false;
}
 
void SMTabruler::rightDataChanged()
{
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
double a, b, value;
int c;
rightIndentData->getValues(&a, &b, &c, &value);
if (m_hasParent && !m_isSetupRight)
rightIndentSpin->setValue(value, false);
else if (!m_hasParent)
rightIndentSpin->setValue(value);
 
m_isSetupRight = false;
}
 
void SMTabruler::firstDataChanged()
{
QSignalBlocker firstLineSpinBlocker(firstLineSpin);
QSignalBlocker rightIndentSpinBlocker(rightIndentSpin);
QSignalBlocker leftIndentSpinBlocker(leftIndentSpin);
 
double a, b, value;
int c;
firstLineData->getValues(&a, &b, &c, &value);
if (m_hasParent && !m_isSetupFirst)
firstLineSpin->setValue(value, false);
else if (!m_hasParent)
firstLineSpin->setValue(value);
 
m_isSetupFirst = false;
}
 
void SMTabruler::firstValueChanged()
{
// QSignalBlocker firstLineDataBlocker(firstLineData);
// QSignalBlocker rightIndentDataBlocker(rightIndentData);
// QSignalBlocker leftIndentDataBlocker(leftIndentData);
 
double a, b, value;
int c;
firstLineSpin->getValues(&a, &b, &c, &value);
setFirstLineData(value / m_docUnitRatio);
setFirstLine();
setLeftIndent();
setRightIndent();
m_isSetupFirst = true;
}
 
void SMTabruler::leftValueChanged()
{
// QSignalBlocker firstLineDataBlocker(firstLineData);
// QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
 
double a, b, value;
int c;
leftIndentSpin->getValues(&a, &b, &c, &value);
setLeftIndentData(value / m_docUnitRatio);
setLeftIndent();
// setFirstLine();
setRightIndent();
m_isSetupLeft = true;
}
 
void SMTabruler::rightValueChanged()
{
QSignalBlocker firstLineDataBlocker(firstLineData);
QSignalBlocker rightIndentDataBlocker(rightIndentData);
QSignalBlocker leftIndentDataBlocker(leftIndentData);
 
double a, b, value;
int c;
rightIndentSpin->getValues(&a, &b, &c, &value);
setRightIndentData(value / m_docUnitRatio);
setLeftIndent();
setFirstLine();
setRightIndent();
m_isSetupRight = true;
}
/trunk/Scribus/scribus/ui/smtextstyles.cpp
164,7 → 164,7
setupConnections();
}
 
QList<CharStyle> SMParagraphStyle::getCharStyles()
QList<CharStyle> SMParagraphStyle::getCharStyles() const
{
QList<CharStyle> charStyles;
if (!m_doc)
1871,7 → 1871,6
m_widget->setContentsMargins(5, 5, 5, 5);//CB the SMCStylePage parent has a 0 value to fit properly onto the pstyle page, so add it here
m_page = new SMCStyleWidget();
Q_CHECK_PTR(m_page);
// m_widget->addTab(m_page, tr("Properties"));
}
 
QTabWidget* SMCharacterStyle::widget()
2075,8 → 2074,6
m_deleted.clear(); // deletion done at this point
 
m_doc->scMW()->requestUpdate(reqTextStylesUpdate);
// Better not call DrawNew() here, as this will cause several unnecessary calls
// m_doc->view()->DrawNew();
m_doc->changed();
}
 
/trunk/Scribus/scribus/ui/smtextstyles.h
67,7 → 67,7
void removeConnections();
void updateStyleList();
void reloadTmpStyles();
QList<CharStyle> getCharStyles();
QList<CharStyle> getCharStyles() const;
 
private slots:
// pstyle