10#include <klocalizedstring.h>
29#include <QButtonGroup>
30#include <QRegularExpressionValidator>
31#include <QRegularExpression>
34#include <QInputDialog>
44#include "ui_wdgGamutMaskChooser.h"
56 : QDockWidget(i18n(
"Gamut Masks"))
65 m_dockerUI->maskPropertiesBox->setVisible(
false);
70 QRegularExpression maskTitleRegex(
"^[-_\\(\\)\\sA-Za-z0-9]+$");
71 QRegularExpressionValidator* m_maskTitleValidator =
new QRegularExpressionValidator(maskTitleRegex,
this);
72 m_dockerUI->maskTitleEdit->setValidator(m_maskTitleValidator);
125 QString maskTemplateFile =
":/gamutmasks/GamutMaskTemplate.kra";
126 if (maskTemplateFile.isEmpty() || maskTemplateFile.isNull() || !QFile::exists(maskTemplateFile)) {
127 dbgPlugins <<
"GamutMaskDock::openMaskEditor(): maskTemplateFile (" << maskTemplateFile <<
") was not found on the system";
129 i18n(
"The editor template was not found."),
130 QMessageBox::Ok, QMessageBox::Ok, QMessageBox::Critical);
135 m_dockerUI->maskPropertiesBox->setVisible(
true);
136 m_dockerUI->maskPropertiesBox->setEnabled(
true);
137 m_dockerUI->editControlsBox->setEnabled(
false);
138 m_dockerUI->editControlsBox->setVisible(
false);
153 QString(
"%1%2%3_%4.kra")
154 .arg(QDir::tempPath(),
"/",
"GamutMaskTemplate", QString::number(std::time(
nullptr)));
180 view->activateWindow();
218 if (notifyItemChooser) {
233 bool maskSaved =
false;
238 if (shapes.count() > 0) {
263 i18n(
"<p>The mask template is invalid.</p>"
264 "<p>Please check that:"
266 "<li>your template contains a vector layer named 'maskShapesLayer'</li>"
267 "<li>there are one or more vector shapes on the 'maskShapesLayer'</li>"
270 QMessageBox::Ok, QMessageBox::Ok);
289 QMessageBox::StandardButtons
buttons, QMessageBox::StandardButton defaultButton,
290 QMessageBox::Icon severity)
293 msgBox.setWindowTitle(i18nc(
"@title:window",
"Krita"));
294 msgBox.setText(QString(
"<p><b>%1</b></p>").arg(text));
295 msgBox.setInformativeText(informativeText);
296 msgBox.setStandardButtons(
buttons);
297 msgBox.setDefaultButton(defaultButton);
298 msgBox.setIcon(severity);
299 int res = msgBox.exec();
310 i18n(
"Do you want to save it?"),
311 QMessageBox::Cancel | QMessageBox::Close | QMessageBox::Save, defaultAction);
314 response = QMessageBox::Save;
317 response = QMessageBox::Close;
320 response = defaultAction;
324 case QMessageBox::Save : {
328 case QMessageBox::Close : {
344 newMask->setVersion(-1);
345 newMask->setResourceId(-1);
346 newMask->setImage(sourceMask->image());
350 QString defaultPreviewPath =
":/gamutmasks/empty_mask_preview.png";
353 newMask->setImage(QImage(defaultPreviewPath,
"PNG"));
359 QString name = newTitle;
361 QFileInfo fileInfo(saveLocation +
"/" + name + newMask->defaultFileExtension());
363 newMask->setTitle(name);
364 newMask->setFilename(fileInfo.fileName());
365 newMask->setValid(
true);
402 m_dockerUI->maskPropertiesBox->setVisible(
false);
403 m_dockerUI->editControlsBox->setVisible(
true);
404 m_dockerUI->editControlsBox->setEnabled(
true);
426 newShapes.append(newShape);
445 QString newTitle =
m_dockerUI->maskTitleEdit->text();
487 if (res == QMessageBox::Cancel) {
498 setEnabled(canvas != 0);
562 int res =
getUserFeedback(i18n(
"Are you sure you want to delete mask <b>'%1'</b>?"
565 if (res == QMessageBox::Yes) {
598 m_dockerUI->maskPropertiesBox->setEnabled(
true);
600 m_dockerUI->maskPropertiesBox->setEnabled(
false);
QSharedPointer< KoShapeStrokeModel > KoShapeStrokeModelSP
QSharedPointer< KoGamutMask > KoGamutMaskSP
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void slotGamutMaskDelete()
int saveOrCancel(QMessageBox::StandardButton defaultAction=QMessageBox::Save)
~GamutMaskDock() override
void setViewManager(KisViewManager *kisview) override
void resourceChanged(KoGamutMaskSP resource) override
bool m_externalTemplateClose
void slotGamutMaskPreview()
void unsetResourceServer() override
void removingResource(KoGamutMaskSP resource) override
void selectMask(KoGamutMaskSP mask, bool notifyItemChooser=true)
GamutMaskChooserUI * m_dockerUI
QList< KoShape * > getShapesFromLayer()
void setCanvas(KoCanvasBase *canvas) override
KoGamutMaskSP m_selectedMask
KisShapeLayerSP getShapeLayer()
KisDocument * m_maskDocument
bool saveSelectedMaskResource()
void slotGamutMaskCreateNew()
void sigGamutMaskChanged(KoGamutMaskSP mask)
void sigGamutMaskPreviewUpdate()
void slotGamutMaskSelected(KoGamutMaskSP mask)
void slotDocumentRemoved(QString filename)
void unsetCanvas() override
KisCanvasResourceProvider * m_resourceProvider
void sigGamutMaskSet(KoGamutMaskSP mask)
void slotGamutMaskCancelEdit()
void slotGamutMaskDuplicate()
int getUserFeedback(QString text, QString informativeText="", QMessageBox::StandardButtons buttons=QMessageBox::Yes|QMessageBox::No, QMessageBox::StandardButton defaultButton=QMessageBox::Yes, QMessageBox::Icon severity=QMessageBox::Warning)
KoGamutMaskSP createMaskResource(KoGamutMaskSP sourceMask, QString newTitle)
bool m_selfClosingTemplate
bool setResourceInactive(const QModelIndex &index)
KoGamutMaskSP currentGamutMask() const
void waitForSavingToComplete()
QString localFilePath() const
void setModified(bool _mod)
void setPath(const QString &path)
void setLocalFilePath(const QString &localFilePath)
void setPreActivatedNode(KisNodeSP activatedNode)
bool closePath(bool promptToSave=true)
void setInfiniteAutoSaveInterval()
bool openPath(const QString &path, OpenFlags flags=None)
openPath Open a Path
QImage convertToQImage(qint32 x1, qint32 y1, qint32 width, qint32 height, const KoColorProfile *profile)
KisGroupLayerSP rootLayer() const
QRect bounds() const override
const KoColorProfile * profile() const
KisView * addViewAndNotifyLoadingCompleted(KisDocument *document, QMdiSubWindow *subWindow=0)
static KisPart * instance()
void removeView(KisView *view)
void addDocument(KisDocument *document, bool notify=true)
KisMainWindow * currentMainwindow() const
void removeDocument(KisDocument *document, bool deleteDocument=true)
KisDocument * createDocument() const
QList< QPointer< KisView > > views
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...
QModelIndex indexForResource(KoResourceSP resource) const override
indexFromResource
QModelIndex indexForResourceId(int resourceId) const override
indexFromResource
static bool addResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource, QString storageLocation="")
static bool updateResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource)
KisDocument * document() const
KisCanvasResourceProvider * canvasResourceProvider()
KisViewManager * viewManager
A simple solid color shape background.
The resource type for gamut masks used by the artistic color selector.
void addObserver(ObserverType *observer)
void removeObserver(ObserverType *observer)
QString saveLocation()
Returns path where to save user defined and imported resources to.
QList< KoShape * > shapes() const
void addShape(KoShape *shape)
virtual void setStroke(KoShapeStrokeModelSP stroke)
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
QString buttons(const T &ev)
KisSharedPtr< KisShapeLayer > KisShapeLayerSP
QIcon loadIcon(const QString &name)
KisNodeSP findNodeByName(KisNodeSP root, const QString &name)
static KoResourceServerProvider * instance()
KoResourceServer< KoGamutMask > * gamutMaskServer