41 d->ui =
new Ui_WdgToolOptions();
44 d->ui->opacitySlider->setRange(0, 100);
45 d->ui->opacitySlider->setTextTemplates(
46 i18nc(
"{n} is the number value, % is the percent sign",
"Opacity: {n}%"),
47 i18nc(
"{n} is the number value, % is the percent sign",
"Opacity [*varies*]: {n}%"));
48 d->ui->opacitySlider->setValueGetter(
52 d->ui->saturationSlider->setRange(0, 100);
53 d->ui->saturationSlider->setTextTemplates(
54 i18nc(
"{n} is the number value, % is the percent sign",
"Saturation: {n}%"),
55 i18nc(
"{n} is the number value, % is the percent sign",
"Saturation [*varies*]: {n}%"));
56 d->ui->saturationSlider->setValueGetter(
60 return 100.0 * r->saturation();
64 d->ui->bnDeleteSelectedImages->setToolTip(i18n(
"Delete Selected Reference Images"));
66 d->ui->bnDeleteSelectedImages->setIconSize(QSize(16, 16));
68 d->ui->bnAddReferenceImage->setToolTip(i18n(
"Add Reference Image From File"));
70 d->ui->bnAddReferenceImage->setIconSize(QSize(16, 16));
72 d->ui->bnPasteReferenceImage->setToolTip(i18n(
"Paste Reference Image From System Clipboard"));
74 d->ui->bnPasteReferenceImage->setIconSize(QSize(16, 16));
77 d->ui->bnAddReferenceImageFromCurrentLayer->setToolTip(i18n(
"Create Reference Image from Active Layer"));
80 d->ui->bnAddReferenceImageFromVisible->setToolTip(i18n(
"Create Reference Image from Visible Canvas"));
83 d->ui->bnDelete->setToolTip(i18n(
"Delete all Reference Images"));
85 d->ui->bnDelete->setIconSize(QSize(16, 16));
87 d->ui->bnLoad->setToolTip(i18n(
"Load Reference Images Set"));
89 d->ui->bnLoad->setIconSize(QSize(16, 16));
91 d->ui->bnSave->setToolTip(i18n(
"Export Reference Images Set"));
93 d->ui->bnSave->setIconSize(QSize(16, 16));
96 connect(
d->ui->bnDeleteSelectedImages, SIGNAL(clicked()), tool, SLOT(removeSelectedReferenceImages()));
97 connect(
d->ui->bnAddReferenceImage, SIGNAL(clicked()), tool, SLOT(addReferenceImage()));
98 connect(
d->ui->bnPasteReferenceImage, SIGNAL(clicked()), tool, SLOT(pasteReferenceImage()));
99 connect(
d->ui->bnAddReferenceImageFromCurrentLayer, SIGNAL(clicked()), tool, SLOT(addReferenceImageFromLayer()));
100 connect(
d->ui->bnAddReferenceImageFromVisible, SIGNAL(clicked()), tool, SLOT(addReferenceImageFromVisible()));
106 connect(
d->ui->bnDelete, SIGNAL(clicked()), tool, SLOT(removeAllReferenceImages()));
107 connect(
d->ui->bnSave, SIGNAL(clicked()), tool, SLOT(saveReferenceImages()));
108 connect(
d->ui->bnLoad, SIGNAL(clicked()), tool, SLOT(loadReferenceImages()));
115 connect(
d->ui->saturationSlider, SIGNAL(valueChanged(qreal)), compressor, SLOT(start()));
116 connect(
d->ui->opacitySlider, SIGNAL(valueChanged(qreal)), compressor, SLOT(start()));
118 d->ui->referenceImageLocationCombobox->addItem(i18n(
"Embed to .KRA"));
119 d->ui->referenceImageLocationCombobox->addItem(i18n(
"Link to Image"));
135 d->ui->opacitySlider->setSelection(shapes);
136 d->ui->saturationSlider->setSelection(shapes);
138 bool anyKeepingAspectRatio =
false;
139 bool anyNotKeepingAspectRatio =
false;
140 bool anyEmbedded =
false;
141 bool anyLinked =
false;
143 bool anySelected = selection->
count() > 0;
145 Q_FOREACH(
KoShape *shape, shapes) {
152 anyEmbedded |= reference->
embed();
153 anyLinked |= !reference->
embed();
159 d->ui->chkKeepAspectRatio,
160 d->ui->referenceImageLocationCombobox
163 d->ui->chkKeepAspectRatio->setCheckState(
164 (anyKeepingAspectRatio && anyNotKeepingAspectRatio) ? Qt::PartiallyChecked :
165 anyKeepingAspectRatio ? Qt::Checked : Qt::Unchecked);
169 bool imagesEmbedded = anyEmbedded && !anyLinked;
170 int comboBoxIndex = imagesEmbedded ? 0 : 1;
171 d->ui->referenceImageLocationCombobox->setCurrentIndex(comboBoxIndex);
242 d->ui->referenceImageLocationCombobox->setVisible(hasSelection);
243 d->ui->chkKeepAspectRatio->setVisible(hasSelection);
244 d->ui->saveLocationLabel->setVisible(hasSelection);
245 d->ui->opacitySlider->setVisible(hasSelection);
246 d->ui->saturationSlider->setVisible(hasSelection);
247 d->ui->bnDeleteSelectedImages->setVisible(hasSelection);
250 d->ui->referenceImageOptionsLabel->setVisible(!hasSelection);
255 bool usesLocalFile =
true;
257 Q_FOREACH(
KoShape *shape, shapes) {
265 QStandardItemModel* model =
dynamic_cast<QStandardItemModel*
>(
d->ui->referenceImageLocationCombobox->model());
268 QStandardItem* item = model->item(1);
269 item->setFlags(usesLocalFile ? item->flags() | Qt::ItemIsEnabled :
270 item->flags() & ~Qt::ItemIsEnabled);