Commit 7b064297 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Subtitles styling: add shadow and opaque background box options.

parent 0e2a23f7
Pipeline #192168 passed with stage
in 6 minutes and 5 seconds
......@@ -133,6 +133,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
// Styling dialog
connect(fontSize, QOverload<int>::of(&QSpinBox::valueChanged), this, &SubtitleEdit::updateStyle);
connect(outlineSize, QOverload<int>::of(&QSpinBox::valueChanged), this, &SubtitleEdit::updateStyle);
connect(shadowSize, QOverload<int>::of(&QSpinBox::valueChanged), this, &SubtitleEdit::updateStyle);
connect(fontFamily, &QFontComboBox::currentFontChanged, this, &SubtitleEdit::updateStyle);
connect(fontColor, &KColorButton::changed, this, &SubtitleEdit::updateStyle);
connect(outlineColor, &KColorButton::changed, this, &SubtitleEdit::updateStyle);
......@@ -142,6 +143,8 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
connect(checkOutlineColor, &QCheckBox::toggled, this, &SubtitleEdit::updateStyle);
connect(checkOutlineSize, &QCheckBox::toggled, this, &SubtitleEdit::updateStyle);
connect(checkPosition, &QCheckBox::toggled, this, &SubtitleEdit::updateStyle);
connect(checkShadowSize, &QCheckBox::toggled, this, &SubtitleEdit::updateStyle);
connect(checkOpaque, &QCheckBox::toggled, this, &SubtitleEdit::updateStyle);
alignment->addItem(i18n("Bottom Center"), 2);
alignment->addItem(i18n("Bottom Left"), 1);
alignment->addItem(i18n("Bottom Right"), 3);
......@@ -174,6 +177,9 @@ void SubtitleEdit::updateStyle()
if (outlineSize->isEnabled()) {
styleString.append(QStringLiteral("Outline=%1,").arg(outlineSize->value()));
}
if (shadowSize->isEnabled()) {
styleString.append(QStringLiteral("Shadow=%1,").arg(shadowSize->value()));
}
if (outlineColor->isEnabled()) {
// Qt AARRGGBB must be converted to AABBGGRR where AA is 255-AA
QColor color = outlineColor->color();
......@@ -183,6 +189,9 @@ void SubtitleEdit::updateStyle()
colorName.remove(0, 1);
styleString.append(QStringLiteral("OutlineColour=&H%1,").arg(colorName));
}
if (checkOpaque->isChecked()) {
styleString.append(QStringLiteral("BorderStyle=3,"));
}
if (alignment->isEnabled()) {
styleString.append(QStringLiteral("Alignment=%1,").arg(alignment->currentData().toInt()));
}
......@@ -224,20 +233,25 @@ void SubtitleEdit::loadStyle(const QString &style)
QSignalBlocker bk3(checkFontColor);
QSignalBlocker bk4(checkOutlineColor);
QSignalBlocker bk5(checkOutlineSize);
QSignalBlocker bk6(checkPosition);
QSignalBlocker bk6(checkShadowSize);
QSignalBlocker bk7(checkPosition);
QSignalBlocker bk8(checkOpaque);
checkFont->setChecked(false);
checkFontSize->setChecked(false);
checkFontColor->setChecked(false);
checkOutlineColor->setChecked(false);
checkOutlineSize->setChecked(false);
checkShadowSize->setChecked(false);
checkPosition->setChecked(false);
checkOpaque->setChecked(false);
fontFamily->setEnabled(false);
fontSize->setEnabled(false);
fontColor->setEnabled(false);
outlineColor->setEnabled(false);
outlineSize->setEnabled(false);
shadowSize->setEnabled(false);
alignment->setEnabled(false);
for (const QString &p : params) {
......@@ -267,6 +281,13 @@ void SubtitleEdit::loadStyle(const QString &style)
QSignalBlocker bk(outlineSize);
outlineSize->setEnabled(true);
outlineSize->setValue(pValue.toInt());
} else if (pName == QLatin1String("Shadow")) {
checkShadowSize->setChecked(true);
QSignalBlocker bk(shadowSize);
shadowSize->setEnabled(true);
shadowSize->setValue(pValue.toInt());
} else if (pName == QLatin1String("BorderStyle")) {
checkOpaque->setChecked(true);
} else if (pName == QLatin1String("Alignment")) {
checkPosition->setChecked(true);
QSignalBlocker bk(alignment);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>322</height>
<width>285</width>
<height>332</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
......@@ -174,61 +174,30 @@
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="checkFont">
<property name="text">
<string>Custom Font</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QFontComboBox" name="fontFamily">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="7" column="2">
<widget class="QComboBox" name="alignment">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkFontSize">
<property name="text">
<string>Custom Font Size</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="fontSize">
<item row="4" column="2">
<widget class="KColorButton" name="outlineColor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string>pt</string>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkFontColor">
<property name="text">
<string>Custom Font Color</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkOutlineColor">
<property name="text">
<string>Custom Outline Color</string>
<property name="defaultColor">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkOutlineSize">
<property name="text">
<string>Custom Outline Size</string>
<property name="alphaChannelEnabled">
<bool>true</bool>
</property>
</widget>
</item>
......@@ -246,20 +215,36 @@
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkPosition">
<widget class="QCheckBox" name="checkShadowSize">
<property name="text">
<string>Custom Position</string>
<string>Custom Shadow</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QComboBox" name="alignment">
<item row="0" column="0">
<widget class="QCheckBox" name="checkFont">
<property name="text">
<string>Custom Font</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="fontSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string>pt</string>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
<item row="7" column="2">
<item row="9" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -272,6 +257,27 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkFontColor">
<property name="text">
<string>Custom Font Color</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkPosition">
<property name="text">
<string>Custom Position</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkFontSize">
<property name="text">
<string>Custom Font Size</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="KColorButton" name="fontColor">
<property name="enabled">
......@@ -296,20 +302,41 @@
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="KColorButton" name="outlineColor">
<item row="6" column="2">
<widget class="QSpinBox" name="shadowSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="defaultColor">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<property name="suffix">
<string>px</string>
</property>
<property name="alphaChannelEnabled">
<bool>true</bool>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QFontComboBox" name="fontFamily">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkOutlineColor">
<property name="text">
<string>Custom Outline Color</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkOutlineSize">
<property name="text">
<string>Custom Outline Size</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="checkOpaque">
<property name="text">
<string>Opaque background</string>
</property>
</widget>
</item>
......@@ -452,5 +479,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>checkShadowSize</sender>
<signal>toggled(bool)</signal>
<receiver>shadowSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>92</x>
<y>207</y>
</hint>
<hint type="destinationlabel">
<x>229</x>
<y>207</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment