Commit 2c5bb8d4 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add some breathing spaces

parent c0dcf58f
......@@ -28,8 +28,8 @@
#include <kis_image.h>
#include <kis_paint_device.h>
DlgImagesplit::DlgImagesplit(KisViewManager* view,QString suffix,QStringList listMimeFilter)
: KDialog(view->mainWindow())
DlgImagesplit::DlgImagesplit(KisViewManager* view, QString suffix, QStringList listMimeFilter)
: KDialog(view->mainWindow())
{
m_page = new WdgImagesplit(this);
......@@ -38,19 +38,19 @@ DlgImagesplit::DlgImagesplit(KisViewManager* view,QString suffix,QStringList lis
setButtons(Apply | Close);
setDefaultButton(Apply);
connect(this, SIGNAL(applyClicked()),this, SLOT(applyClicked()));
connect(this, SIGNAL(applyClicked()), this, SLOT(applyClicked()));
setMainWidget(m_page);
m_page->lineEdit->setText(suffix);
m_page->setMinimumWidth (200);
m_page->setMinimumWidth(200);
m_page->setMinimumHeight(160);
resize(m_page->sizeHint());
m_page->cmbFileType->clear();
m_page->cmbFileType->addItems(listMimeFilter);
m_page->cmbFileType->setCurrentIndex(0);
cmbIndex=0;
cmbIndex = 0;
connect(m_page->chkAutoSave,SIGNAL(stateChanged(int)),SLOT(lineEditEnable()));
connect(m_page->chkAutoSave, SIGNAL(stateChanged(int)), SLOT(lineEditEnable()));
connect(m_page->cmbFileType, SIGNAL(activated(int)), this, SLOT(setMimeType(int)));
}
......@@ -60,7 +60,7 @@ DlgImagesplit::~DlgImagesplit()
void DlgImagesplit::lineEditEnable()
{
if(m_page->chkAutoSave->isChecked()) {
if (m_page->chkAutoSave->isChecked()) {
m_page->lblSuffix->setEnabled(true);
m_page->lineEdit->setEnabled(true);
m_page->lblFileType->setEnabled(true);
......@@ -79,7 +79,7 @@ void DlgImagesplit::lineEditEnable()
bool DlgImagesplit::autoSave()
{
if (m_page->chkAutoSave->isChecked())
return true;
return true;
else
return false;
}
......@@ -91,7 +91,7 @@ int DlgImagesplit::horizontalLines()
int DlgImagesplit::verticalLines()
{
return m_page->intVerticalSplitLines->value();
return m_page->intVerticalSplitLines->value();
}
QString DlgImagesplit::suffix()
......@@ -101,7 +101,7 @@ QString DlgImagesplit::suffix()
void DlgImagesplit::setMimeType(int index)
{
cmbIndex=index;
cmbIndex = index;
}
void DlgImagesplit::applyClicked()
......
......@@ -39,7 +39,7 @@ class DlgImagesplit: public KDialog
public:
DlgImagesplit(KisViewManager* view,QString suffix,QStringList listMimeType);
DlgImagesplit(KisViewManager* view, QString suffix, QStringList listMimeType);
~DlgImagesplit();
bool autoSave();
int horizontalLines();
......
......@@ -50,7 +50,7 @@ K_PLUGIN_FACTORY(ImagesplitFactory, registerPlugin<Imagesplit>();)
K_EXPORT_PLUGIN(ImagesplitFactory("krita"))
Imagesplit::Imagesplit(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
: KisViewPlugin(parent)
{
KisAction *action = new KisAction(i18n("Image Split "), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
......@@ -62,20 +62,20 @@ Imagesplit::~Imagesplit()
{
}
void Imagesplit::saveAsImage(QRect imgSize,QString mimeType,KUrl url)
void Imagesplit::saveAsImage(QRect imgSize, QString mimeType, KUrl url)
{
KisImageWSP image = m_view->image();
KisDocument *d = KisPart::instance()->createDocument();
d->prepareForImport();
KisImageWSP dst = new KisImage(d->createUndoStore(), imgSize.width(),imgSize.height(), image->colorSpace(), image->objectName());
KisImageWSP dst = new KisImage(d->createUndoStore(), imgSize.width(), imgSize.height(), image->colorSpace(), image->objectName());
dst->setResolution(image->xRes(), image->yRes());
d->setCurrentImage(dst);
KisPaintLayer* paintLayer = new KisPaintLayer(dst,dst->nextLayerName(), 255);
KisPaintLayer* paintLayer = new KisPaintLayer(dst, dst->nextLayerName(), 255);
KisPainter gc(paintLayer->paintDevice());
gc.bitBlt(QPoint(0,0), image->projection(), imgSize);
gc.bitBlt(QPoint(0, 0), image->projection(), imgSize);
dst->addNode(paintLayer, KisNodeSP(0));
dst->refreshGraph();
......@@ -94,15 +94,15 @@ void Imagesplit::slotImagesplit()
// Getting all mime types and converting them into names which are displayed at combo box
QStringList listMimeFilter = KisImportExportManager::mimeFilter("application/x-krita", KisImportExportManager::Export);
QStringList listFileType;
foreach(const QString &tempStr, listMimeFilter) {
KMimeType::Ptr type = KMimeType::mimeType( tempStr );
foreach(const QString & tempStr, listMimeFilter) {
KMimeType::Ptr type = KMimeType::mimeType(tempStr);
if (type) {
listFileType.append(type->comment());
}
}
DlgImagesplit * dlgImagesplit = new DlgImagesplit(m_view,suffix,listFileType);
DlgImagesplit * dlgImagesplit = new DlgImagesplit(m_view, suffix, listFileType);
dlgImagesplit->setObjectName("Imagesplit");
Q_CHECK_PTR(dlgImagesplit);
......@@ -113,27 +113,27 @@ void Imagesplit::slotImagesplit()
int numHorizontalLines = dlgImagesplit->horizontalLines();
int numVerticalLines = dlgImagesplit->verticalLines();
int img_width = image->width()/(numVerticalLines+1);
int img_height = image->height()/(numHorizontalLines+1);
int img_width = image->width() / (numVerticalLines + 1);
int img_height = image->height() / (numHorizontalLines + 1);
if (dlgImagesplit->autoSave()) {
for(int i=0,k=1;i<(numVerticalLines+1);i++) {
for(int j=0;j<(numHorizontalLines+1);j++,k++)
for (int i = 0, k = 1; i < (numVerticalLines + 1); i++) {
for (int j = 0; j < (numHorizontalLines + 1); j++, k++)
{
KMimeType::Ptr mimeTypeSelected = KMimeType::mimeType( listMimeFilter.at(dlgImagesplit->cmbIndex));
KUrl url( QDir::homePath());
QString fileName = dlgImagesplit->suffix()+'_'+ QString::number(k)+mimeTypeSelected->mainExtension();
url.addPath( fileName );
KUrl kurl=url.url();
saveAsImage(QRect((i*img_width),(j*img_height),img_width,img_height),listMimeFilter.at(dlgImagesplit->cmbIndex),kurl);
KMimeType::Ptr mimeTypeSelected = KMimeType::mimeType(listMimeFilter.at(dlgImagesplit->cmbIndex));
KUrl url(QDir::homePath());
QString fileName = dlgImagesplit->suffix() + '_' + QString::number(k) + mimeTypeSelected->mainExtension();
url.addPath(fileName);
KUrl kurl = url.url();
saveAsImage(QRect((i * img_width), (j * img_height), img_width, img_height), listMimeFilter.at(dlgImagesplit->cmbIndex), kurl);
}
}
}
else {
for(int i=0;i<(numVerticalLines+1);i++) {
for(int j=0;j<(numHorizontalLines+1);j++)
for (int i = 0; i < (numVerticalLines + 1); i++) {
for (int j = 0; j < (numHorizontalLines + 1); j++)
{
KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::SaveFile, "OpenDocument");
dialog.setCaption(i18n("Save Image on Split"));
......@@ -146,7 +146,7 @@ void Imagesplit::slotImagesplit()
if (url.isEmpty())
return;
saveAsImage(QRect((i*img_width),(j*img_height),img_width,img_height),mimefilter,url);
saveAsImage(QRect((i * img_width), (j * img_height), img_width, img_height), mimefilter, url);
}
}
......
......@@ -36,7 +36,7 @@ public:
private Q_SLOTS:
void slotImagesplit();
void saveAsImage(QRect ,QString, KUrl);
void saveAsImage(QRect , QString, KUrl);
};
#endif // IMAGESPLIT_H
......@@ -32,7 +32,7 @@
#include "kis_config.h"
WdgImagesplit::WdgImagesplit(QWidget* parent)
: QWidget(parent)
: QWidget(parent)
{
setupUi(this);
......
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