38 setWindowTitle(caption);
42 preview->setScaledContents(
true);
51 lblWarning->setVisible(
false);
66 const qint32 maxSize = 150;
69 qint32 scaledWidth, scaledHeight;
72 scaledWidth = maxSize;
73 scaledHeight = maxSize / aspectRatio;
75 scaledWidth = maxSize * aspectRatio;
76 scaledHeight = maxSize;
79 if (scaledWidth == 0) scaledWidth++;
80 if (scaledHeight == 0) scaledHeight++;
82 QPixmap scaledPixmap = QPixmap::fromImage(
m_pattern->pattern());
83 preview->setPixmap(scaledPixmap.scaled(scaledWidth, scaledHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
85 preview->setPixmap(QPixmap::fromImage(
m_pattern->pattern()));
103 dlg.
setCaption(i18n(
"Add to Predefined Patterns"));
107 if (filename ==
"") {
111 bool hadToChangeFilename =
false;
113 QFileInfo fi(filename);
114 if (fi.suffix().isEmpty()) {
115 fi.setFile(fi.baseName() +
m_pattern->defaultFileExtension());
116 hadToChangeFilename =
true;
119 if (fi.baseName() !=
m_pattern->name()) {
123 bool overwrite =
false;
125 if (hadToChangeFilename) {
126 if (QMessageBox::warning(
this, i18nc(
"@title:window",
"Krita"), i18n(
"This pattern already exists. Do you want to overwrite it?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
134 if (!filename.isEmpty()) {
138 qWarning() <<
"Could not add pattern with filename" << filename;
144 else if (overwrite) {
146 qWarning() <<
"Could not add pattern with filename" << filename;
172 QRect rc = image->
bounds();
174 if (cmbSource->currentIndex() == 0) {
178 rc = rc.intersected(rc2);
184 name = image->objectName();
194 gc.
bitBlt(selectionRect.topLeft(), dev, selectionRect);
204 QSize size = rc.size();
205 if (size.height() > 1000 || size.width() > 1000) {
206 lblWarning->setVisible(
true);
207 size.scale(1000, 1000, Qt::KeepAspectRatio);
210 lblWarning->setVisible(
false);
QSharedPointer< KoPattern > KoPatternSP
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void slotUpdateCurrentPattern()
~KisCustomPattern() override
void patternAdded(KoResourceSP)
void activatedResource(KoResourceSP)
KisCustomPattern(QWidget *parent, const char *name, const QString &caption, KisViewManager *view)
void patternUpdated(KoResourceSP)
KoResourceServer< KoPattern > * m_rServer
void barrierLock(bool readOnly=false)
Wait until all the queued background jobs are completed and lock the image.
KisPaintDeviceSP projection() const
QRect bounds() const override
KisPaintDeviceSP createCompositionSourceDevice() const
QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
QRect exactBounds() const
void setSelection(KisSelectionSP selection)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
static KisResourceLoaderRegistry * instance()
static bool addResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource, QString storageLocation="")
static bool updateResourceWithUserInput(QWidget *widgetParent, KoResourceSP resource)
KisSelectionSP selection()
KisImageWSP image() const
Return the image this view is displaying.
QString filename()
Get the file name the user selected in the file dialog.
void setDefaultDir(const QString &defaultDir, bool force=false)
setDefaultDir set the default directory to defaultDir.
void setCaption(const QString &caption)
void setMimeTypeFilters(const QStringList &mimeTypeList, QString defaultMimeType=QString())
setMimeTypeFilters Update the list of file filters from mime types.
QString saveLocation()
Returns path where to save user defined and imported resources to.
virtual KisPaintDeviceSP projection() const =0
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.
static KoResourceServerProvider * instance()
KoResourceServer< KoPattern > * patternServer