Commit 27f4b434 authored by Scott Petrovic's avatar Scott Petrovic

Update UI for reference image tool options

parent 8a777b57
......@@ -64,6 +64,23 @@ ToolReferenceImagesWidget::ToolReferenceImagesWidget(ToolReferenceImages *tool,
}
);
d->ui->bnAddReferenceImage->setToolTip(i18n("Add Reference Image"));
d->ui->bnAddReferenceImage->setIcon(KisIconUtils::loadIcon("addlayer"));
d->ui->bnDelete->setToolTip(i18n("Delete all Reference Images"));
d->ui->bnDelete->setIcon(KisIconUtils::loadIcon("edit-clear"));
d->ui->bnLoad->setToolTip(i18n("Load Reference Images Set"));
d->ui->bnLoad->setIcon(KisIconUtils::loadIcon("document-open"));
d->ui->bnSave->setToolTip(i18n("Export Reference Images Set"));
d->ui->bnSave->setIcon(KisIconUtils::loadIcon("document-save"));
connect(d->ui->bnAddReferenceImage, SIGNAL(clicked()), tool, SLOT(addReferenceImage()));
connect(d->ui->bnDelete, SIGNAL(clicked()), tool, SLOT(removeAllReferenceImages()));
connect(d->ui->bnSave, SIGNAL(clicked()), tool, SLOT(saveReferenceImages()));
......@@ -73,8 +90,11 @@ ToolReferenceImagesWidget::ToolReferenceImagesWidget(ToolReferenceImages *tool,
connect(d->ui->opacitySlider, SIGNAL(valueChanged(qreal)), this, SLOT(slotOpacitySliderChanged(qreal)));
connect(d->ui->saturationSlider, SIGNAL(valueChanged(qreal)), this, SLOT(slotSaturationSliderChanged(qreal)));
connect(d->ui->radioEmbed, SIGNAL(toggled(bool)), this, SLOT(slotEmbeddingChanged()));
connect(d->ui->radioLinkExternal, SIGNAL(toggled(bool)), this, SLOT(slotEmbeddingChanged()));
d->ui->referenceImageLocationCombobox->addItem(i18n("Embed to .KRA"));
d->ui->referenceImageLocationCombobox->addItem(i18n("Link to Image"));
connect(d->ui->referenceImageLocationCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSaveLocationChanged(int)));
updateVisibility(false); // no selection when we start
}
ToolReferenceImagesWidget::~ToolReferenceImagesWidget()
......@@ -110,19 +130,21 @@ void ToolReferenceImagesWidget::selectionChanged(KoSelection *selection)
KisSignalsBlocker blocker(
d->ui->chkKeepAspectRatio,
d->ui->radioEmbed,
d->ui->radioLinkExternal
d->ui->referenceImageLocationCombobox
);
d->ui->chkKeepAspectRatio->setCheckState(
(anyKeepingAspectRatio && anyNotKeepingAspectRatio) ? Qt::PartiallyChecked :
anyKeepingAspectRatio ? Qt::Checked : Qt::Unchecked);
d->ui->radioEmbed->setChecked(anyEmbedded && !anyLinked);
d->ui->radioLinkExternal->setChecked(anyLinked && !anyEmbedded);
d->ui->radioEmbed->setEnabled(!anyNonLinkable && anySelected);
d->ui->radioLinkExternal->setEnabled(!anyNonLinkable && anySelected);
d->ui->chkKeepAspectRatio->setEnabled(anySelected);
// set save location combobox
bool imagesEmbedded = anyEmbedded && !anyLinked;
int comboBoxIndex = imagesEmbedded ? 0 : 1; // maps state to combobox index
d->ui->referenceImageLocationCombobox->setCurrentIndex(comboBoxIndex);
updateVisibility(anySelected);
}
void ToolReferenceImagesWidget::slotKeepAspectChanged()
......@@ -158,19 +180,34 @@ void ToolReferenceImagesWidget::slotSaturationSliderChanged(qreal newSaturation)
d->tool->canvas()->addCommand(cmd);
}
void ToolReferenceImagesWidget::slotEmbeddingChanged()
void ToolReferenceImagesWidget::slotSaveLocationChanged(int index)
{
KoSelection *selection = d->tool->koSelection();
QList<KoShape*> shapes = selection->selectedEditableShapes();
Q_FOREACH(KoShape *shape, shapes) {
KisReferenceImage *reference = dynamic_cast<KisReferenceImage*>(shape);
KIS_SAFE_ASSERT_RECOVER_RETURN(reference);
if (d->ui->radioEmbed->isChecked()) {
if (index == 0) { // embed to KRA
reference->setEmbed(true);
} else if (d->ui->radioLinkExternal->isChecked()) {
} else { // link to file
reference->setEmbed(false);
}
}
}
void ToolReferenceImagesWidget::updateVisibility(bool hasSelection)
{
// hide UI elements if nothing is selected.
d->ui->referenceImageLocationCombobox->setVisible(hasSelection);
d->ui->chkKeepAspectRatio->setVisible(hasSelection);
d->ui->saveLocationLabel->setVisible(hasSelection);
d->ui->opacitySlider->setVisible(hasSelection);
d->ui->saturationSlider->setVisible(hasSelection);
// show a label indicating that a selection is required to show options
d->ui->referenceImageOptionsLabel->setVisible(!hasSelection);
}
......@@ -43,11 +43,14 @@ private Q_SLOTS:
void slotOpacitySliderChanged(qreal);
void slotSaturationSliderChanged(qreal);
void slotKeepAspectChanged();
void slotEmbeddingChanged();
void slotSaveLocationChanged(int index);
private:
struct Private;
const QScopedPointer<Private> d;
void updateVisibility(bool hasSelection);
};
#endif
......@@ -6,72 +6,192 @@
<rect>
<x>0</x>
<y>0</y>
<width>246</width>
<height>196</height>
<width>279</width>
<height>352</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="bnAddReferenceImage">
<property name="text">
<string>Add reference image...</string>
</property>
</widget>
<widget class="KisShapePropertySlider" name="opacitySlider" native="true"/>
</item>
<item>
<widget class="QPushButton" name="bnLoad">
<property name="text">
<string>Load set...</string>
</property>
</widget>
<widget class="KisShapePropertySlider" name="saturationSlider" native="true"/>
</item>
<item>
<widget class="QPushButton" name="bnSave">
<widget class="QCheckBox" name="chkKeepAspectRatio">
<property name="text">
<string>Save set...</string>
<string>Keep aspect ratio</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnDelete">
<widget class="QLabel" name="saveLocationLabel">
<property name="text">
<string>Delete all reference images</string>
<string>Save Location:</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QComboBox" name="referenceImageLocationCombobox"/>
</item>
<item>
<widget class="QCheckBox" name="chkKeepAspectRatio">
<widget class="QLabel" name="referenceImageOptionsLabel">
<property name="text">
<string>Keep aspect ratio</string>
<string>Add/Select an image to show options</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KisShapePropertySlider" name="opacitySlider" native="true"/>
</item>
<item>
<widget class="KisShapePropertySlider" name="saturationSlider" native="true"/>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radioEmbed">
<property name="text">
<string>Embed to .kra</string>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioLinkExternal">
<property name="text">
<string>Link to external file</string>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
</widget>
<item>
<widget class="QPushButton" name="bnAddReferenceImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="bnLoad">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnSave">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnDelete">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>All</string>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
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