Improve ergonomic. Allow a user to define both text and image, and control
which will of them be active. --HG-- branch : develop
This commit is contained in:
parent
d0dc209c45
commit
6fc51d83b0
|
@ -68,7 +68,7 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) :
|
|||
WatermarkChangesWereSaved(false);
|
||||
});
|
||||
|
||||
connect(ui->spinBoxTextRotation, QOverload<int>::of(&QSpinBox::valueChanged),this,
|
||||
connect(ui->spinBoxTextRotation, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
[this](){WatermarkChangesWereSaved(false);});
|
||||
|
||||
connect(ui->toolButtonFont, &QToolButton::clicked, this, [this]()
|
||||
|
@ -104,6 +104,9 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) :
|
|||
[this](){WatermarkChangesWereSaved(false);});
|
||||
|
||||
connect(ui->checkBoxGrayColor, &QCheckBox::stateChanged, this, [this](){WatermarkChangesWereSaved(false);});
|
||||
|
||||
connect(ui->groupBoxWatermarkText, &QGroupBox::toggled, this, [this](){WatermarkChangesWereSaved(false);});
|
||||
connect(ui->groupBoxWatermarkImage, &QGroupBox::toggled, this, [this](){WatermarkChangesWereSaved(false);});
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -385,13 +388,13 @@ bool WatermarkWindow::on_actionSave_triggered()
|
|||
|
||||
if (not changed)
|
||||
{
|
||||
QMessageBox messageBox(this);
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(m_curFile));
|
||||
messageBox.setInformativeText(tr("Could not save the file."));
|
||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||
messageBox.exec();
|
||||
QMessageBox messageBoxWarning(this);
|
||||
messageBoxWarning.setIcon(QMessageBox::Warning);
|
||||
messageBoxWarning.setText(tr("Cannot set permissions for %1 to writable.").arg(m_curFile));
|
||||
messageBoxWarning.setInformativeText(tr("Could not save the file."));
|
||||
messageBoxWarning.setDefaultButton(QMessageBox::Ok);
|
||||
messageBoxWarning.setStandardButtons(QMessageBox::Ok);
|
||||
messageBoxWarning.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -581,8 +584,10 @@ bool WatermarkWindow::ContinueFormatRewrite(const QString ¤tFormatVersion,
|
|||
bool WatermarkWindow::SaveWatermark(const QString &fileName, QString &error)
|
||||
{
|
||||
m_data.opacity = ui->spinBoxOpacity->value();
|
||||
m_data.showText = ui->groupBoxWatermarkText->isChecked();
|
||||
m_data.text = ui->lineEditText->text();
|
||||
m_data.textRotation = ui->spinBoxTextRotation->value();
|
||||
m_data.showImage = ui->groupBoxWatermarkImage->isChecked();
|
||||
m_data.path = RelativeMPath(fileName, ui->lineEditPath->text());
|
||||
m_data.imageRotation = ui->spinBoxImageRotation->value();
|
||||
m_data.grayscale = ui->checkBoxGrayColor->isChecked();
|
||||
|
@ -677,6 +682,10 @@ void WatermarkWindow::ShowWatermark()
|
|||
ui->spinBoxOpacity->setValue(m_data.opacity);
|
||||
ui->spinBoxOpacity->blockSignals(false);
|
||||
|
||||
ui->groupBoxWatermarkText->blockSignals(true);
|
||||
ui->groupBoxWatermarkText->setChecked(m_data.showText);
|
||||
ui->groupBoxWatermarkText->blockSignals(false);
|
||||
|
||||
ui->lineEditText->blockSignals(true);
|
||||
ui->lineEditText->setText(m_data.text);
|
||||
ui->lineEditText->blockSignals(false);
|
||||
|
@ -689,6 +698,10 @@ void WatermarkWindow::ShowWatermark()
|
|||
ui->lineEditFontSample->setFont(m_data.font);
|
||||
ui->lineEditFontSample->blockSignals(false);
|
||||
|
||||
ui->groupBoxWatermarkImage->blockSignals(true);
|
||||
ui->groupBoxWatermarkImage->setChecked(m_data.showImage);
|
||||
ui->groupBoxWatermarkImage->blockSignals(false);
|
||||
|
||||
ui->lineEditPath->blockSignals(true);
|
||||
ui->lineEditPath->setText(AbsoluteMPath(m_curFile, m_data.path));
|
||||
ValidatePath();
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<widget class="QGroupBox" name="groupBoxWatermarkText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -87,6 +87,12 @@
|
|||
<property name="title">
|
||||
<string>Text</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
|
@ -182,7 +188,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<widget class="QGroupBox" name="groupBoxWatermarkImage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -192,6 +198,9 @@
|
|||
<property name="title">
|
||||
<string>Image</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
|
|
|
@ -241,9 +241,11 @@ struct VLabelTemplateLine
|
|||
struct VWatermarkData
|
||||
{
|
||||
int opacity{20};
|
||||
bool showText{true};
|
||||
QString text{};
|
||||
int textRotation{0};
|
||||
QFont font{};
|
||||
bool showImage{true};
|
||||
QString path{};
|
||||
int imageRotation{0};
|
||||
bool grayscale{false};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:boolean" name="show"/>
|
||||
<xs:attribute type="xs:string" name="text"/>
|
||||
<xs:attribute type="rotationType" name="rotation"/>
|
||||
<xs:attribute type="xs:string" name="font"/>
|
||||
|
@ -18,6 +19,7 @@
|
|||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:boolean" name="show"/>
|
||||
<xs:attribute type="xs:string" name="path"/>
|
||||
<xs:attribute type="rotationType" name="rotation"/>
|
||||
<xs:attribute type="xs:boolean" name="grayscale"/>
|
||||
|
|
|
@ -38,6 +38,7 @@ const QString VWatermark::AttrRotation = QStringLiteral("rotation");
|
|||
const QString VWatermark::AttrFont = QStringLiteral("font");
|
||||
const QString VWatermark::AttrPath = QStringLiteral("path");
|
||||
const QString VWatermark::AttrGrayscale = QStringLiteral("grayscale");
|
||||
const QString VWatermark::AttrShow = QStringLiteral("show");
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -97,6 +98,7 @@ VWatermarkData VWatermark::GetWatermark() const
|
|||
QDomElement text = rootElement.firstChildElement(TagText);
|
||||
if (not text.isNull())
|
||||
{
|
||||
data.showText = GetParametrBool(text, AttrShow, trueStr);
|
||||
data.text = GetParametrEmptyString(text, AttrText);
|
||||
data.textRotation = GetParametrInt(text, AttrRotation, QChar('0'));
|
||||
data.font.fromString(GetParametrEmptyString(text, AttrFont));
|
||||
|
@ -105,6 +107,7 @@ VWatermarkData VWatermark::GetWatermark() const
|
|||
QDomElement image = rootElement.firstChildElement(TagImage);
|
||||
if (not image.isNull())
|
||||
{
|
||||
data.showImage = GetParametrBool(image, AttrShow, trueStr);
|
||||
data.path = GetParametrEmptyString(image, AttrPath);
|
||||
data.imageRotation = GetParametrInt(image, AttrRotation, QChar('0'));
|
||||
data.grayscale = GetParametrBool(image, AttrGrayscale, falseStr);
|
||||
|
@ -126,6 +129,7 @@ void VWatermark::SetWatermark(const VWatermarkData &data)
|
|||
QDomElement text = rootElement.firstChildElement(TagText);
|
||||
if (not text.isNull())
|
||||
{
|
||||
SetAttribute(text, AttrShow, data.showText);
|
||||
SetAttributeOrRemoveIf(text, AttrText, data.text, data.text.isEmpty());
|
||||
SetAttributeOrRemoveIf(text, AttrRotation, data.textRotation, data.textRotation == 0);
|
||||
const QString fontString = data.font.toString();
|
||||
|
@ -135,6 +139,7 @@ void VWatermark::SetWatermark(const VWatermarkData &data)
|
|||
QDomElement image = rootElement.firstChildElement(TagImage);
|
||||
if (not image.isNull())
|
||||
{
|
||||
SetAttribute(image, AttrShow, data.showImage);
|
||||
SetAttributeOrRemoveIf(image, AttrPath, data.path, data.path.isEmpty());
|
||||
SetAttributeOrRemoveIf(image, AttrRotation, data.imageRotation, data.imageRotation == 0);
|
||||
SetAttributeOrRemoveIf(image, AttrGrayscale, data.grayscale, data.grayscale == false);
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
static const QString AttrFont;
|
||||
static const QString AttrPath;
|
||||
static const QString AttrGrayscale;
|
||||
static const QString AttrShow;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VWatermark)
|
||||
|
|
|
@ -160,12 +160,12 @@ QVector<QGraphicsItem *> VPoster::Tile(QGraphicsItem *parent, const PosterData &
|
|||
|
||||
if (watermarkData.opacity > 0)
|
||||
{
|
||||
if (not watermarkData.path.isEmpty())
|
||||
if (watermarkData.showImage && not watermarkData.path.isEmpty())
|
||||
{
|
||||
data += ImageWatermark(parent, img, watermarkData, watermarkPath);
|
||||
}
|
||||
|
||||
if (not watermarkData.text.isEmpty())
|
||||
if (watermarkData.showText && not watermarkData.text.isEmpty())
|
||||
{
|
||||
data += TextWatermark(parent, img, watermarkData);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user