Commit d8dd4bd7 authored by Casper Boemann's avatar Casper Boemann

move title and description from image properties to document info

 

svn path=/trunk/koffice/; revision=667669
parent ca5291d5
......@@ -76,8 +76,6 @@ public:
KisPerspectiveGrid* perspectiveGrid;
KUrl uri;
QString name;
QString description;
qint32 width;
qint32 height;
......@@ -114,8 +112,7 @@ KisImage::KisImage(KisUndoAdapter *adapter, qint32 width, qint32 height, KoColo
: QObject(0), KisShared()
{
setObjectName(name);
init(adapter, width, height, colorSpace, name);
setName(name);
init(adapter, width, height, colorSpace);
}
KisImage::KisImage(const KisImage& rhs) : QObject(), KisShared(rhs)
......@@ -124,7 +121,6 @@ KisImage::KisImage(const KisImage& rhs) : QObject(), KisShared(rhs)
m_d = new KisImagePrivate(*rhs.m_d);
m_d->perspectiveGrid = new KisPerspectiveGrid(*rhs.m_d->perspectiveGrid);
m_d->uri = rhs.m_d->uri;
m_d->name.clear();
m_d->width = rhs.m_d->width;
m_d->height = rhs.m_d->height;
m_d->xres = rhs.m_d->xres;
......@@ -157,28 +153,6 @@ KisImage::~KisImage()
delete m_d;
}
QString KisImage::name() const
{
return m_d->name;
}
void KisImage::setName(const QString& name)
{
if (!name.isEmpty())
m_d->name = name;
}
QString KisImage::description() const
{
return m_d->description;
}
void KisImage::setDescription(const QString& description)
{
if (!description.isEmpty())
m_d->description = description;
}
KisSelectionSP KisImage::globalSelection() const
{
return m_d->globalSelection;
......@@ -222,7 +196,7 @@ void KisImage::rollBackLayerName()
m_d->nserver->rollback();
}
void KisImage::init(KisUndoAdapter *adapter, qint32 width, qint32 height, KoColorSpace * colorSpace, const QString& name)
void KisImage::init(KisUndoAdapter *adapter, qint32 width, qint32 height, KoColorSpace * colorSpace)
{
Q_ASSERT(colorSpace);
......@@ -241,7 +215,6 @@ void KisImage::init(KisUndoAdapter *adapter, qint32 width, qint32 height, KoCol
m_d->adapter = adapter;
m_d->nserver = new KisNameServer(1);
m_d->name = name;
m_d->colorSpace = colorSpace;
......
......@@ -120,12 +120,6 @@ public:
KoColor backgroundColor() const;
void setBackgroundColor(const KoColor & color);
QString name() const;
void setName(const QString& name);
QString description() const;
void setDescription(const QString& description);
/**
* @return the global selection object or 0 if there is none. The
* global selection is always read-write.
......@@ -559,7 +553,7 @@ public slots:
private:
KisImage& operator=(const KisImage& rhs);
void init(KisUndoAdapter * adapter, qint32 width, qint32 height, KoColorSpace * colorSpace, const QString& name);
void init(KisUndoAdapter * adapter, qint32 width, qint32 height, KoColorSpace * colorSpace);
void emitSizeChanged();
void preparePaintLayerAfterAdding( KisLayerSP layer );
......
......@@ -124,13 +124,10 @@ void KisImageConvertTypeCommand::undo()
KisImagePropsCommand::KisImagePropsCommand(KisImageSP image, const QString& newName, const QString& newDescription,
KoColorSpace* newColorSpace, KoColorProfile* newProfile)
KisImagePropsCommand::KisImagePropsCommand(KisImageSP image, KoColorSpace* newColorSpace, KoColorProfile* newProfile)
: super(i18n("Property Changes"), image)
, m_newName(newName), m_newDescription(newDescription), m_newColorSpace(newColorSpace), m_newProfile(newProfile)
, m_newProfile(newProfile)
{
m_oldName = m_image->name();
m_oldDescription = m_image->description();
m_oldColorSpace = m_image->colorSpace();
m_oldProfile = m_image->profile();
}
......@@ -138,9 +135,7 @@ KisImagePropsCommand::KisImagePropsCommand(KisImageSP image, const QString& newN
void KisImagePropsCommand::redo()
{
setUndo(false);
m_image->setName(m_newName);
m_image->setColorSpace(m_newColorSpace);
m_image->setDescription(m_newDescription);
m_image->setProfile(m_newProfile);
setUndo(true);
}
......@@ -148,9 +143,7 @@ void KisImagePropsCommand::redo()
void KisImagePropsCommand::undo()
{
setUndo(false);
m_image->setName(m_oldName);
m_image->setColorSpace(m_oldColorSpace);
m_image->setDescription(m_oldDescription);
m_image->setProfile(m_oldProfile);
setUndo(true);
}
......
......@@ -123,24 +123,17 @@ public:
* This command stores the current image properties and set the new propertys.
*
* @param image the image
* @param newName the new image name
* @param newDescription the new image description
* @param newColorSpace the new image color space
* @param newProfile the new image profile
* @param newResolution the new image resolution which will be used for xRes and yRes
*/
KisImagePropsCommand(KisImageSP image, const QString& newName, const QString& newDescription,
KoColorSpace* newColorSpace, KoColorProfile* newProfile);
KisImagePropsCommand(KisImageSP image, KoColorSpace* newColorSpace, KoColorProfile* newProfile);
virtual ~KisImagePropsCommand() {}
virtual void redo();
virtual void undo();
private:
QString m_newName;
QString m_oldName;
QString m_newDescription;
QString m_oldDescription;
KoColorSpace * m_newColorSpace;
KoColorSpace * m_oldColorSpace;
KoColorProfile* m_newProfile;
......
......@@ -58,8 +58,6 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, QWidget *parent,
setMainWidget(m_page);
resize(m_page->sizeHint());
m_page->txtName->setText(image->name());
m_page->m_createButton->hide();
KisConfig cfg;
m_page->lblWidthValue->setText(QString::number(image->width()));
......@@ -67,8 +65,6 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, QWidget *parent,
m_page->lblResolutionValue->setText(KGlobal::locale()->formatNumber(image->xRes()*72, 2)); // XXX: separate values for x & y?
m_page->txtDescription->setText( m_image->description() );
//m_page->cmbColorSpaces->hide();
//m_page->lblColorSpaces->setText(image->colorSpace()->id().name());
QList<KoID> colorSpaces = KoColorSpaceRegistry::instance()->listKeys();
......@@ -88,18 +84,8 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, QWidget *parent,
m_page->cmbProfile->setCurrentIndex(0);
}
m_page->sliderOpacity->setEnabled(false); // XXX re-enable when figured out a way to do this
m_page->opacityPanel->hide();
m_page->lblOpacity->hide();
m_page->cmbColor->setEnabled(false); // XXX re-enable when figured out a way to do this
m_page->cmbColor->hide();
m_page->lblColor->hide();
connect(m_page->cmbColorSpaces, SIGNAL(activated(const KoID &)),
this, SLOT(fillCmbProfiles(const KoID &)));
}
KisDlgImageProperties::~KisDlgImageProperties()
......@@ -107,21 +93,6 @@ KisDlgImageProperties::~KisDlgImageProperties()
delete m_page;
}
int KisDlgImageProperties::opacity()
{
return m_page->sliderOpacity->value();
}
QString KisDlgImageProperties::imageName()
{
return m_page->txtName->text();
}
QString KisDlgImageProperties::description()
{
return m_page->txtDescription->toPlainText();
}
KoColorSpace * KisDlgImageProperties::colorSpace()
{
return KoColorSpaceRegistry::instance()->colorSpace(m_page->cmbColorSpaces->currentItem(), m_page->cmbProfile->currentText());
......
......@@ -45,9 +45,6 @@ public:
const char *name = 0);
virtual ~KisDlgImageProperties();
int opacity();
QString imageName();
QString description();
KoColorSpace * colorSpace();
KoColorProfile * profile();
......
......@@ -57,6 +57,7 @@
#include <KoStoreDevice.h>
#include <KoXmlWriter.h>
#include <KoSelection.h>
#include <KoDocumentInfo.h>
// Krita Image
#include "kis_adjustment_layer.h"
......@@ -336,12 +337,12 @@ QDomElement KisDoc2::saveImage(QDomDocument& doc, KisImageSP img)
QDomElement image = doc.createElement("IMAGE");
Q_ASSERT(img);
image.setAttribute("name", img->name());
image.setAttribute("name", documentInfo()->aboutInfo("title"));
image.setAttribute("mime", "application/x-kra");
image.setAttribute("width", img->width());
image.setAttribute("height", img->height());
image.setAttribute("colorspacename", img->colorSpace()->id());
image.setAttribute("description", img->description());
image.setAttribute("description", documentInfo()->aboutInfo("comment"));
// XXX: Save profile as blob inside the image, instead of the product name.
if (img->profile() && img->profile()-> valid())
image.setAttribute("profile", img->profile()->name());
......@@ -424,7 +425,8 @@ KisImageSP KisDoc2::loadImage(const QDomElement& element)
img = new KisImage(m_d->undoAdapter, width, height, cs, name);
Q_CHECK_PTR(img);
connect( img.data(), SIGNAL( sigImageModified() ), this, SLOT( slotImageUpdated() ));
img->setDescription(description);
documentInfo()->setAboutInfo("title", name);
documentInfo()->setAboutInfo("comment", description);
img->setResolution(xres, yres);
loadLayers(element, img, img->rootLayer());
......@@ -668,7 +670,7 @@ bool KisDoc2::completeSaving(KoStore *store)
// Save the layers data
quint32 count=0;
KisSaveVisitor visitor( img, store, count);
KisSaveVisitor visitor( img, store, count, documentInfo()->aboutInfo("title"));
if(external)
visitor.setExternalUri(uri);
......@@ -681,7 +683,7 @@ bool KisDoc2::completeSaving(KoStore *store)
KisAnnotationSP annotation = img->annotation("exif");
if (annotation) {
location = external ? QString::null : uri;
location += (m_d->image)->name() + "/annotations/exif";
location += documentInfo()->aboutInfo("title") + "/annotations/exif";
if (store->open(location)) {
store->write(annotation->annotation());
store->close();
......@@ -699,7 +701,7 @@ bool KisDoc2::completeSaving(KoStore *store)
if (annotation) {
location = external ? QString::null : uri;
location += img->name() + "/annotations/icc";
location += documentInfo()->aboutInfo("title") + "/annotations/icc";
if (store->open(location)) {
store->write(annotation->annotation());
store->close();
......@@ -725,7 +727,7 @@ bool KisDoc2::completeLoading(KoStore *store)
setIOSteps(totalSteps);
// Load the layers data
KisLoadVisitor visitor(img, store, m_d->layerFilenames);
KisLoadVisitor visitor(img, store, m_d->layerFilenames, documentInfo()->aboutInfo("title"));
if(external)
visitor.setExternalUri(uri);
......@@ -734,7 +736,7 @@ bool KisDoc2::completeLoading(KoStore *store)
// annotations
// exif
location = external ? QString::null : uri;
location += (img)->name() + "/annotations/exif";
location += documentInfo()->aboutInfo("title") + "/annotations/exif";
if (store->hasFile(location)) {
QByteArray data;
store->open(location);
......@@ -744,7 +746,7 @@ bool KisDoc2::completeLoading(KoStore *store)
}
// icc profile
location = external ? QString::null : uri;
location += (img)->name() + "/annotations/icc";
location += documentInfo()->aboutInfo("title") + "/annotations/icc";
if (store->hasFile(location)) {
QByteArray data;
store->open(location);
......@@ -814,7 +816,7 @@ KisImageSP KisDoc2::newImage(const QString& name, qint32 width, qint32 height, K
return img;
}
bool KisDoc2::newImage(const QString& name, qint32 width, qint32 height, KoColorSpace * cs, const KoColor &bgColor, const QString &imgDescription, const double imgResolution)
bool KisDoc2::newImage(const QString& name, qint32 width, qint32 height, KoColorSpace * cs, const KoColor &bgColor, const QString &description, const double imgResolution)
{
if (!init())
return false;
......@@ -833,8 +835,10 @@ bool KisDoc2::newImage(const QString& name, qint32 width, qint32 height, KoColor
Q_CHECK_PTR(img);
connect( img.data(), SIGNAL( sigImageModified() ), this, SLOT( slotImageUpdated() ));
img->setResolution(imgResolution, imgResolution);
img->setDescription(imgDescription);
img->setProfile(cs->profile());
documentInfo()->setAboutInfo("title", name);
documentInfo()->setAboutInfo("comments", description);
layer = new KisPaintLayer(img.data(), img->nextLayerName(), OPACITY_OPAQUE, cs);
Q_CHECK_PTR(layer);
......@@ -984,7 +988,7 @@ KisImageSP KisDoc2::image()
void KisDoc2::setCurrentImage(KisImageSP image)
{
kDebug(41007) << "KisDoc2::setCurrentImage: " << image->name() << ", active layer: " << image->activeLayer() << endl;
kDebug(41007) << "KisDoc2::setCurrentImage with active layer: " << image->activeLayer() << endl;
if ( m_d->image ) {
// Disconnect existing sig/slot connections
......
......@@ -147,10 +147,7 @@ void KisImageManager::slotImageProperties()
KisDlgImageProperties dlg(img, m_view);
if (dlg.exec() == QDialog::Accepted) {
qint32 opacity = dlg.opacity();
opacity = opacity * 255 / 100;
QUndoCommand* cmd = new KisImagePropsCommand(img, dlg.imageName(), dlg.description(),
dlg.colorSpace(), dlg.profile());
QUndoCommand* cmd = new KisImagePropsCommand(img, dlg.colorSpace(), dlg.profile());
m_view->document()->addCommand(cmd);
}
}
......
......@@ -37,13 +37,14 @@
#include "kis_filter_configuration.h"
#include "kis_datamanager.h"
KisLoadVisitor::KisLoadVisitor(KisImageSP img, KoStore *store, QMap<KisLayer *, QString> &layerFilenames) :
KisLoadVisitor::KisLoadVisitor(KisImageSP img, KoStore *store, QMap<KisLayer *, QString> &layerFilenames, QString name) :
KisLayerVisitor(),
m_layerFilenames(layerFilenames)
{
m_external = false;
m_img = img;
m_store = store;
m_name = name;
}
void KisLoadVisitor::setExternalUri(QString &uri)
......@@ -61,7 +62,7 @@ bool KisLoadVisitor::visit(KisPaintLayer *layer)
{ //connect(*layer->paintDevice(), SIGNAL(ioProgress(qint8)), m_img, SLOT(slotIOProgress(qint8)));
QString location = m_external ? QString::null : m_uri;
location += m_img->name() + "/layers/" + m_layerFilenames[layer];
location += m_name + "/layers/" + m_layerFilenames[layer];
// Layer data
if (m_store->open(location)) {
......@@ -77,7 +78,7 @@ bool KisLoadVisitor::visit(KisPaintLayer *layer)
// icc profile
location = m_external ? QString::null : m_uri;
location += m_img->name() + "/layers/" + m_layerFilenames[layer] + ".icc";
location += m_name + "/layers/" + m_layerFilenames[layer] + ".icc";
if (m_store->hasFile(location)) {
QByteArray data;
......@@ -118,7 +119,7 @@ bool KisLoadVisitor::visit(KisPaintLayer *layer)
bool KisLoadVisitor::visit(KisGroupLayer *layer)
{
KisLoadVisitor visitor(m_img, m_store, m_layerFilenames);
KisLoadVisitor visitor(m_img, m_store, m_layerFilenames, m_name);
if(m_external)
visitor.setExternalUri(m_uri);
......@@ -141,7 +142,7 @@ bool KisLoadVisitor::visit(KisAdjustmentLayer* layer)
// The selection -- if present. If not, we simply cannot open the dratted thing.
QString location = m_external ? QString::null : m_uri;
location += m_img->name() + "/layers/" + m_layerFilenames[layer] + ".selection";
location += m_name + "/layers/" + m_layerFilenames[layer] + ".selection";
if (m_store->hasFile(location)) {
m_store->open(location);
KisSelectionSP selection = KisSelectionSP(new KisSelection());
......@@ -157,7 +158,7 @@ bool KisLoadVisitor::visit(KisAdjustmentLayer* layer)
// filter configuration
location = m_external ? QString::null : m_uri;
location += m_img->name() + "/layers/" + m_layerFilenames[layer] + ".filterconfig";
location += m_name + "/layers/" + m_layerFilenames[layer] + ".filterconfig";
if (m_store->hasFile(location) && layer->filter()) {
QByteArray data;
......
......@@ -29,7 +29,7 @@ class KoStore;
class KisLoadVisitor : public KisLayerVisitor {
public:
KisLoadVisitor(KisImageSP img, KoStore *store, QMap<KisLayer *, QString> &layerFilenames);
KisLoadVisitor(KisImageSP img, KoStore *store, QMap<KisLayer *, QString> &layerFilenames, QString name);
public:
void setExternalUri(QString &uri);
......@@ -47,6 +47,7 @@ private:
bool m_external;
QString m_uri;
QMap<KisLayer *, QString> m_layerFilenames;
QString m_name;
};
#endif // KIS_LOAD_VISITOR_H_
......
......@@ -31,13 +31,14 @@
#include "kis_paint_layer.h"
#include "kis_selection.h"
KisSaveVisitor::KisSaveVisitor(KisImageSP img, KoStore *store, quint32 &count) :
KisSaveVisitor::KisSaveVisitor(KisImageSP img, KoStore *store, quint32 &count, QString name) :
KisLayerVisitor(),
m_count(count)
{
m_external = false;
m_img = img;
m_store = store;
m_name = name;
}
void KisSaveVisitor::setExternalUri(QString &uri)
......@@ -56,7 +57,7 @@ bool KisSaveVisitor::visit(KisPaintLayer *layer)
//connect(*layer->paintDevice(), SIGNAL(ioProgress(qint8)), m_img, SLOT(slotIOProgress(qint8)));
QString location = m_external ? QString::null : m_uri;
location += m_img->name() + QString("/layers/layer%1").arg(m_count);
location += m_name + QString("/layers/layer%1").arg(m_count);
// Layer data
if (m_store->open(location)) {
......@@ -83,7 +84,7 @@ bool KisSaveVisitor::visit(KisPaintLayer *layer)
if (annotation) {
// save layer profile
location = m_external ? QString::null : m_uri;
location += m_img->name() + QString("/layers/layer%1").arg(m_count) + ".icc";
location += m_name + QString("/layers/layer%1").arg(m_count) + ".icc";
if (m_store->open(location)) {
m_store->write(annotation->annotation());
......@@ -118,7 +119,7 @@ bool KisSaveVisitor::visit(KisPaintLayer *layer)
bool KisSaveVisitor::visit(KisGroupLayer *layer)
{
KisSaveVisitor visitor(m_img, m_store, m_count);
KisSaveVisitor visitor(m_img, m_store, m_count, m_name);
if(m_external)
visitor.setExternalUri(m_uri);
......@@ -138,7 +139,7 @@ bool KisSaveVisitor::visit(KisAdjustmentLayer* layer)
if (layer->selection()) {
QString location = m_external ? QString::null : m_uri;
location += m_img->name() + QString("/layers/layer%1").arg(m_count) + ".selection";
location += m_name + QString("/layers/layer%1").arg(m_count) + ".selection";
// Layer data
if (m_store->open(location)) {
......@@ -155,7 +156,7 @@ bool KisSaveVisitor::visit(KisAdjustmentLayer* layer)
if (layer->filter()) {
QString location = m_external ? QString::null : m_uri;
location = m_external ? QString::null : m_uri;
location += m_img->name() + QString("/layers/layer%1").arg(m_count) + ".filterconfig";
location += m_name + QString("/layers/layer%1").arg(m_count) + ".filterconfig";
if (m_store->open(location)) {
QString s = layer->filter()->toString();
......
......@@ -28,7 +28,7 @@ class KoStore;
class KisSaveVisitor : public KisLayerVisitor {
public:
KisSaveVisitor(KisImageSP img, KoStore *store, quint32 &count);
KisSaveVisitor(KisImageSP img, KoStore *store, quint32 &count, QString name);
public:
void setExternalUri(QString &uri);
......@@ -47,6 +47,7 @@ private:
bool m_external;
QString m_uri;
quint32 &m_count;
QString m_name;
};
#endif // KIS_SAVE_VISITOR_H_
......
......@@ -6,30 +6,13 @@
<x>0</x>
<y>0</y>
<width>590</width>
<height>706</height>
<height>227</height>
</rect>
</property>
<property name="windowTitle" >
<string>New Image</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="lblName" >
<property name="text" >
<string>&amp;Name:</string>
</property>
<property name="buddy" >
<cstring>txtName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtName" >
<property name="text" >
<string>untitled-1</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpImage" >
<property name="title" >
......@@ -170,180 +153,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpContents" >
<property name="title" >
<string>Contents</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<number>11</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="2" column="1" >
<widget class="QTextEdit" name="txtDescription" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="lblColor" >
<property name="text" >
<string>Canvas color:</string>
</property>
<property name="buddy" >
<cstring>cmbColor</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KColorCombo" native="1" name="cmbColor" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="lblDescription" >
<property name="text" >
<string>Description:</string>
</property>
<property name="alignment" >
<set>Qt::AlignTop</set>
</property>
<property name="buddy" >
<cstring>txtDescription</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="lblOpacity" >
<property name="text" >
<string>Opacity:</string>
</property>
<property name="buddy" >
<cstring>sliderOpacity</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QFrame" name="opacityPanel" >
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Transparent</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="sliderOpacity" >
<property name="toolTip" >
<string>Opacity of the background color</string>
</property>
<property name="whatsThis" >
<string>Opacity of the background color.</string>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="pageStep" >
<number>10</number>
</property>
<property name="value" >