Commit 17b54bae authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Make title widget guides configurable

parent 5cc1bf20
......@@ -985,5 +985,13 @@
<label>Show guides in titler.</label>
<default>false</default>
</entry>
<entry name="titlerHGuides" type="Int">
<label>Number of horizontal guides in titler.</label>
<default>2</default>
</entry>
<entry name="titlerVGuides" type="Int">
<label>Number of vertical guides in titler.</label>
<default>3</default>
</entry>
</group>
</kcfg>
......@@ -45,7 +45,7 @@
#include <QTimer>
#include <QToolBar>
#include <QButtonGroup>
#include <QSpinBox>
#include <QGraphicsBlurEffect>
#include <QGraphicsDropShadowEffect>
#include <QGraphicsEffect>
......@@ -456,48 +456,14 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &pro
m_frameBorder->setData(-1, -1);
graphicsView->scene()->addItem(m_frameBorder);
QGraphicsLineItem *line1 = new QGraphicsLineItem(0, m_frameHeight / 3, m_frameWidth, m_frameHeight / 3, m_frameBorder);
line1->setPen(framepen);
line1->setFlags(nullptr);
line1->setData(-1, -1);
m_guides << line1;
QGraphicsLineItem *line2 = new QGraphicsLineItem(0, 2 *m_frameHeight / 3, m_frameWidth, 2 * m_frameHeight / 3, m_frameBorder);
line2->setPen(framepen);
line2->setFlags(nullptr);
line2->setData(-1, -1);
m_guides << line2;
QGraphicsLineItem *line3 = new QGraphicsLineItem(m_frameWidth / 4, 0, m_frameWidth / 4, m_frameHeight, m_frameBorder);
line3->setPen(framepen);
line3->setFlags(nullptr);
line3->setData(-1, -1);
m_guides << line3;
QGraphicsLineItem *line4 = new QGraphicsLineItem(m_frameWidth / 2, 0, m_frameWidth / 2, m_frameHeight, m_frameBorder);
line4->setPen(framepen);
line4->setFlags(nullptr);
line4->setData(-1, -1);
m_guides << line4;
QGraphicsLineItem *line5 = new QGraphicsLineItem(3 * m_frameWidth / 4, 0, 3 * m_frameWidth / 4, m_frameHeight, m_frameBorder);
line5->setPen(framepen);
line5->setFlags(nullptr);
line5->setData(-1, -1);
m_guides << line5;
framepen.setColor(QColor(255, 0, 0, 160));
QGraphicsLineItem *line6 = new QGraphicsLineItem(0, 0, m_frameWidth, m_frameHeight, m_frameBorder);
line6->setPen(framepen);
line6->setFlags(nullptr);
line6->setData(-1, -1);
m_guides << line6;
QGraphicsLineItem *line7 = new QGraphicsLineItem(m_frameWidth, 0, 0, m_frameHeight, m_frameBorder);
line7->setPen(framepen);
line7->setFlags(nullptr);
line7->setData(-1, -1);
m_guides << line7;
// Guides
connect(show_guides, &QCheckBox::stateChanged, this, &TitleWidget::showGuides);
show_guides->setChecked(KdenliveSettings::titlerShowGuides());
hguides->setValue(KdenliveSettings::titlerHGuides());
vguides->setValue(KdenliveSettings::titlerVGuides());
connect(hguides, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &TitleWidget::updateGuides);
connect(vguides, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &TitleWidget::updateGuides);
updateGuides(0);
showGuides(show_guides->checkState());
// semi transparent safe zones
......@@ -3023,3 +2989,46 @@ void TitleWidget::showGuides(int state)
}
KdenliveSettings::setTitlerShowGuides(state == Qt::Checked);
}
void TitleWidget::updateGuides(int)
{
KdenliveSettings::setTitlerHGuides(hguides->value());
KdenliveSettings::setTitlerVGuides(vguides->value());
qDeleteAll(m_guides);
m_guides.clear();
QPen framepen;
framepen.setColor(Qt::red);
// Guides
// Horizontal guides
int max = hguides->value();
for (int i = 0; i < max; i++) {
QGraphicsLineItem *line1 = new QGraphicsLineItem(0, (i + 1) * m_frameHeight / (max + 1), m_frameWidth, (i + 1) * m_frameHeight / (max + 1), m_frameBorder);
line1->setPen(framepen);
line1->setFlags(nullptr);
line1->setData(-1, -1);
m_guides << line1;
}
max = vguides->value();
for (int i = 0; i < max; i++) {
QGraphicsLineItem *line1 = new QGraphicsLineItem((i + 1) * m_frameWidth / (max + 1), 0, (i + 1) * m_frameWidth / (max + 1), m_frameHeight, m_frameBorder);
line1->setPen(framepen);
line1->setFlags(nullptr);
line1->setData(-1, -1);
m_guides << line1;
}
framepen.setColor(QColor(255, 0, 0, 160));
QGraphicsLineItem *line6 = new QGraphicsLineItem(0, 0, m_frameWidth, m_frameHeight, m_frameBorder);
line6->setPen(framepen);
line6->setFlags(nullptr);
line6->setData(-1, -1);
m_guides << line6;
QGraphicsLineItem *line7 = new QGraphicsLineItem(m_frameWidth, 0, 0, m_frameHeight, m_frameBorder);
line7->setPen(framepen);
line7->setFlags(nullptr);
line7->setData(-1, -1);
m_guides << line7;
}
......@@ -341,6 +341,8 @@ private slots:
void slotResize200();
/** @brief Show hide guides */
void showGuides(int state);
/** @brief Build guides */
void updateGuides(int);
/** @brief Called when accepted, stores user selections for next time use.
* @ref writeChoices */
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1418</width>
<width>1281</width>
<height>1306</height>
</rect>
</property>
......@@ -354,7 +354,7 @@
</property>
</widget>
</item>
<item row="2" column="7">
<item row="2" column="9">
<spacer name="spacerBottomStack">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -367,7 +367,7 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="8">
<item row="0" column="0" colspan="10">
<widget class="QGraphicsView" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
......@@ -424,6 +424,35 @@
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QSpinBox" name="vguides">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Vertical guides</string>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
<item row="2" column="8">
<widget class="QSpinBox" name="hguides">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Horizontal guides</string>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
......@@ -1496,5 +1525,37 @@
</hint>
</hints>
</connection>
<connection>
<sender>show_guides</sender>
<signal>toggled(bool)</signal>
<receiver>hguides</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>488</x>
<y>1211</y>
</hint>
<hint type="destinationlabel">
<x>813</x>
<y>1211</y>
</hint>
</hints>
</connection>
<connection>
<sender>show_guides</sender>
<signal>toggled(bool)</signal>
<receiver>vguides</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>504</x>
<y>1211</y>
</hint>
<hint type="destinationlabel">
<x>640</x>
<y>1211</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Markdown is supported
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