Commit eda3f590 authored by Casper Boemann's avatar Casper Boemann

Implement the new customDocumentWidget in krita of

the new statup dialog

This removes the old dialog, and the mess of having 
to select an empty document.

The new widget is just the old dialog in new 
disguise. But a new thing is that the colorspace is 
taken form settings->workingColorSpace and that 
default resolution is saved for next time the 
dialog is shown.

All in all a very nice and very visible 
improvement.


svn path=/trunk/koffice/; revision=488563
parent e1c49e1b
SUBDIRS = . brushes patterns gradients templates profiles palettes
SUBDIRS = . brushes patterns gradients profiles palettes
kde_servicetypes_DATA = \
krita_filter.desktop \
krita_paintop.desktop \
......
templates_DATA = .directory empty.desktop
templatesdir = $(kde_datadir)/krita/templates/empty
templatesrc_DATA = empty.kra
templatesrcdir = $(kde_datadir)/krita/templates/empty/.source
templatesicon_ICON = AUTO
templatesicondir = $(kde_datadir)/krita/icons
[Desktop Entry]
Encoding=UTF-8
Type=Link
URL=.source/empty.kra
Icon=template_empty
Name=Empty Document
Name[bg]=Празен документ
Name[br]=Teul goullo
Name[ca]=Document buit
Name[cs]=Prázdný dokument
Name[cy]=Dogfen Wag
Name[da]=Tomt dokument
Name[de]=Leeres Dokument
Name[el]=Κενό έγγραφο
Name[es]=Documento vacío
Name[et]=Tühi dokument
Name[eu]=Dokumentu hutsa
Name[fi]=Tyhjä asiakirja
Name[fr]=Document vide
Name[ga]=Cáipéis Fholamh
Name[he]=מסמך ריק
Name[hu]=Üres dokumentum
Name[it]=Documento vuoto
Name[ja]=空のドキュメント
Name[ms]=Dokumen Kosong
Name[nb]=Tomt dokument
Name[nl]=Leeg Document
Name[nn]=Tomt dokument
Name[pt]=Documento Vazio
Name[pt_BR]=Documento Vazio
Name[ru]=Пустой документ
Name[se]=Guorus dokumeanta
Name[sk]=Prázdny dokument
Name[sl]=Prazen dokument
Name[sr]=Празан документ
Name[sr@Latn]=Prazan dokument
Name[sv]=Tomt dokument
Name[ta]=காலி ஆவணம்
Name[tg]=Ҳуҷҷати Холӣ
Name[tr]=Boş Belge
Name[uk]=Порожній документ
Name[uz]=Бўш ҳужжат
Name[wa]=Documint vude
Name[xx]=xxEmpty Documentxx
Name[zh_CN]=空文档
Comment=Create an empty document
Comment[bg]=Създаване на празен документ
Comment[cy]=Creu dogfen wag
Comment[da]=Opretter et tomt dokument
Comment[de]=Erstellt ein leeres Dokument
Comment[el]=Δημιουργία ενός κενού εγγράφου
Comment[eo]=Tio ĉi kreas malplenan dokumenton
Comment[es]=Crea un documento vacío.
Comment[et]=Tühja dokumendi loomine
Comment[eu]=Sortu dokumentu huts bat
Comment[fi]=Luo tyhjä asiakirja
Comment[fr]=Créer un document vide
Comment[ga]=Cruthaigh cáipéis fholamh
Comment[he]=יצירת מסמך ריק
Comment[hu]=Üres dokumentum létrehozása
Comment[it]=Crea un documento vuoto
Comment[ja]=空のドキュメントを作成
Comment[nb]=Lag et tomt dokument.
Comment[nl]=Een leeg document aanmaken
Comment[nn]=Lag eit tomt dokument
Comment[pt]=Cria um documento vazio
Comment[pt_BR]=Cria um documento vazio
Comment[ru]=Пустой документ
Comment[sl]=Ustvari prazen dokument
Comment[sr]=Прави празан документ
Comment[sr@Latn]=Pravi prazan dokument
Comment[sv]=Skapar ett tomt dokument
Comment[ta]= ஒரு வெற்று ஆவணத்தை உருவாக்கு
Comment[tr]=Boş bir belge oluştur
Comment[uk]=Створити порожній документ
Comment[xx]=xxCreate an empty documentxx
Comment[zh_CN]=创建空文档
X-KDE-DefaultTemplate=true
......@@ -102,8 +102,6 @@ void ImageSize::slotImageSize()
dlgImageSize -> setWidth(image -> width());
dlgImageSize -> setHeight(image -> height());
dlgImageSize -> setMaximumWidth(cfg.maxImgWidth());
dlgImageSize -> setMaximumHeight(cfg.maxImgHeight());
if (dlgImageSize -> exec() == QDialog::Accepted) {
Q_INT32 w = dlgImageSize -> width();
......@@ -138,8 +136,6 @@ void ImageSize::slotLayerSize()
dlgLayerSize -> setWidth(image -> width());
dlgLayerSize -> setHeight(image -> height());
dlgLayerSize -> setMaximumWidth(cfg.maxImgWidth());
dlgLayerSize -> setMaximumHeight(cfg.maxImgHeight());
if (dlgLayerSize -> exec() == QDialog::Accepted) {
Q_INT32 w = dlgLayerSize -> width();
......@@ -177,8 +173,6 @@ void ImageSize::slotSelectionScale()
dlgImageSize -> setWidth(image -> width());
dlgImageSize -> setHeight(image -> height());
dlgImageSize -> setMaximumWidth(cfg.maxImgWidth());
dlgImageSize -> setMaximumHeight(cfg.maxImgHeight());
dlgImageSize -> hideScaleBox();
......
......@@ -29,7 +29,6 @@ libkritaui_la_SOURCES = \
kis_controlframe.cc \
kis_cursor.cc \
kis_dlg_apply_profile.cc \
kis_dlg_create_img.cc \
kis_dlg_image_properties.cc \
kis_dlg_layer_properties.cc \
kis_dlg_new_layer.cc \
......@@ -82,6 +81,7 @@ libkritaui_la_SOURCES = \
kis_view.cc \
kis_view_iface.cc \
kis_custom_brush.cc \
kis_custom_image_widget.cc\
kis_view_iface.skel \
kobirdeyepanel.cpp \
kis_matrix_widget.ui \
......@@ -123,7 +123,6 @@ noinst_HEADERS = \
kis_controlframe.h \
kis_cursor.h \
kis_dlg_apply_profile.h \
kis_dlg_create_img.h \
kis_dlg_image_properties.h \
kis_dlg_layer_properties.h \
kis_dlg_new_layer.h \
......@@ -169,7 +168,8 @@ noinst_HEADERS = \
kis_view.h \
kis_view_iface.h \
kobirdeyepanel.h \
kis_custom_brush.h
kis_custom_brush.h\
kis_custom_image_widget.h
METASOURCES = AUTO
......
......@@ -29,8 +29,7 @@
#include "kis_config.h"
namespace {
const Q_INT32 IMG_WIDTH_MAX = USHRT_MAX;
const Q_INT32 IMG_HEIGHT_MAX = USHRT_MAX;
const double IMG_DEFAULT_RESOLUTION = 100.0;
const Q_INT32 IMG_DEFAULT_WIDTH = 512;
const Q_INT32 IMG_DEFAULT_HEIGHT = 512;
const enumCursorStyle DEFAULT_CURSOR_STYLE = CURSOR_STYLE_OUTLINE;
......@@ -58,24 +57,19 @@ KisConfig::~KisConfig()
m_cfg -> sync();
}
Q_INT32 KisConfig::maxImgWidth() const
{
return m_cfg -> readNumEntry("imgWidthMax", IMG_WIDTH_MAX);
}
Q_INT32 KisConfig::defImgWidth() const
{
return m_cfg -> readNumEntry("imgWidthDef", IMG_DEFAULT_WIDTH);
}
Q_INT32 KisConfig::maxImgHeight() const
Q_INT32 KisConfig::defImgHeight() const
{
return m_cfg -> readNumEntry("imgHeightMax", IMG_HEIGHT_MAX);
return m_cfg -> readNumEntry("imgHeightDef", IMG_DEFAULT_HEIGHT);
}
Q_INT32 KisConfig::defImgHeight() const
double KisConfig::defImgResolution() const
{
return m_cfg -> readNumEntry("imgHeightDef", IMG_DEFAULT_HEIGHT);
return m_cfg -> readDoubleNumEntry("imgResolutionDef", IMG_DEFAULT_RESOLUTION);
}
void KisConfig::defImgWidth(Q_INT32 width)
......@@ -88,6 +82,11 @@ void KisConfig::defImgHeight(Q_INT32 height)
m_cfg -> writeEntry("imgHeightDef", height);
}
void KisConfig::defImgResolution(double res)
{
m_cfg->writeEntry("imgResolutionDef", res);
}
enumCursorStyle KisConfig::cursorStyle() const
{
return (enumCursorStyle) m_cfg -> readNumEntry("cursorStyleDef", DEFAULT_CURSOR_STYLE);
......
......@@ -26,14 +26,15 @@ public:
KisConfig();
~KisConfig();
Q_INT32 maxImgWidth() const;
Q_INT32 defImgWidth() const;
void defImgWidth(Q_INT32 width);
Q_INT32 maxImgHeight() const;
Q_INT32 defImgHeight() const;
void defImgHeight(Q_INT32 height);
double defImgResolution() const;
void defImgResolution(double res);
enumCursorStyle cursorStyle() const;
enumCursorStyle getDefaultCursorStyle() const;
void setCursorStyle(enumCursorStyle style);
......
/* This file is part of the KOffice project
* Copyright (C) 2005 Thomas Zander <zander@kde.org>
* Copyright (C) 2005 Casper Boemann <cbr@boemann.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; version 2.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <kis_custom_image_widget.h>
#include <kis_doc.h>
#include <kis_meta_registry.h>
#include "kis_colorspace_factory_registry.h"
#include "kis_profile.h"
#include "kis_colorspace.h"
#include "kis_id.h"
#include "kis_cmb_idlist.h"
#include "kis_color.h"
#include <kcolorcombo.h>
#include <kdebug.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qtextedit.h>
#include <koUnitWidgets.h>
KisCustomImageWidget::KisCustomImageWidget(QWidget *parent, KisDoc *doc, Q_INT32 defHeight, Q_INT32 defWidth, double resolution, QString defColorSpaceName, QString imageName)
: WdgNewImage(parent) {
m_doc = doc;
txtName -> setText(imageName);
intWidth -> setValue(defWidth);
intHeight -> setValue(defHeight);
doubleResolution -> setValue(resolution);
cmbColorSpaces -> setIDList(KisMetaRegistry::instance()->csRegistry() -> listKeys());
cmbColorSpaces -> setCurrentText(defColorSpaceName);
connect(cmbColorSpaces, SIGNAL(activated(const KisID &)),
this, SLOT(fillCmbProfiles(const KisID &)));
// Temporary KisID; this will be matched to the translated ID in the current KisIDList.
fillCmbProfiles(KisID(cmbColorSpaces->currentText(), ""));
connect (m_createButton, SIGNAL( clicked() ), this, SLOT (buttonClicked()) );
}
void KisCustomImageWidget::buttonClicked() {
KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(cmbColorSpaces -> currentItem(), cmbProfile->currentText());
QColor qc(cmbColor->color());
m_doc->newImage(txtName->text(), (Q_INT32)intWidth->value(), (Q_INT32)intHeight->value(), cs, KisColor(qc, cs), txtDescription->text(), doubleResolution->value());
emit documentSelected();
}
Q_UINT8 KisCustomImageWidget::backgroundOpacity() const
{
Q_INT32 opacity = sliderOpacity -> value();
if (!opacity)
return 0;
return (opacity * 255) / 100;
}
void KisCustomImageWidget::fillCmbProfiles(const KisID & s)
{
cmbProfile -> clear();
if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
return;
}
KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry() -> get(s);
if (csf == 0) return;
QValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
QValueVector<KisProfile *> ::iterator it;
for ( it = profileList.begin(); it != profileList.end(); ++it ) {
cmbProfile -> insertItem((*it) -> productName());
}
}
#include "kis_custom_image_widget.moc"
/* This file is part of the KOffice project
* Copyright (C) 2005 Thomas Zander <zander@kde.org>
* Copyright (C) 2005 Casper Boemann <cbr@boemann.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; version 2.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KIS_CUSTOM_IMAGE_WIDGET_H
#define KIS_CUSTOM_IMAGE_WIDGET_H
#include <wdgnewimage.h>
#include "kis_global.h"
class KisDoc;
class KisID;
/**
* The 'Custom Document' widget in the Krita startup widget.
* This class embeds the image size and colorspace to allow the user to select the image properties
* for a new empty image document.
*/
class KisCustomImageWidget : public WdgNewImage {
Q_OBJECT;
public:
/**
* Constructor. Please note that this class is being used/created by KisDoc.
* @param parent the parent widget
* @param doc the document that wants to be altered
*/
KisCustomImageWidget(QWidget *parent, KisDoc *doc, Q_INT32 defHeight, Q_INT32 defWidth, double resolution, QString defColorSpaceName, QString imageName);
private slots:
void buttonClicked();
void fillCmbProfiles(const KisID & s);
signals:
/// this signal is emitted (as defined by KoDocument) the moment the document is 'ready'
void documentSelected();
private:
Q_UINT8 backgroundOpacity() const;
KisDoc *m_doc;
};
#endif
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <qbuttongroup.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qgroupbox.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qslider.h>
#include <qtextedit.h>
#include <qcheckbox.h>
#include <qwidget.h>
#include <qcursor.h>
#include <klocale.h>
#include <kcolorcombo.h>
#include <kdebug.h>
#include <koUnitWidgets.h>
#include "kis_factory.h"
#include "kis_colorspace_factory_registry.h"
#include "kis_dlg_create_img.h"
#include "wdgnewimage.h"
#include <kis_meta_registry.h>
#include "kis_profile.h"
#include "kis_colorspace.h"
#include "kis_id.h"
#include "kis_cmb_idlist.h"
KisDlgCreateImg::KisDlgCreateImg(Q_INT32 maxWidth, Q_INT32 defWidth,
Q_INT32 maxHeight, Q_INT32 defHeight,
QString colorSpaceName, QString imageName,
QWidget *parent, const char *name)
: super(parent, name, true, "", Ok | Cancel)
{
setCaption(i18n("New Image"));
m_page = new WdgNewImage(this);
setMainWidget(m_page);
resize(m_page -> sizeHint());
m_page -> txtName -> setText(imageName);
m_page -> intWidth -> setValue(defWidth);
m_page -> intWidth -> setMaxValue(maxWidth);
m_page -> intHeight -> setValue(defHeight);
m_page -> intHeight -> setMaxValue(maxHeight);
m_page -> doubleResolution -> setValue(100.0); // XXX: Get this from settings?
m_page -> cmbColorSpaces -> setIDList(KisMetaRegistry::instance()->csRegistry() -> listKeys());
m_page -> cmbColorSpaces -> setCurrentText(colorSpaceName);
connect(m_page -> cmbColorSpaces, SIGNAL(activated(const KisID &)),
this, SLOT(fillCmbProfiles(const KisID &)));
// Temporary KisID; this will be matched to the translated ID in the current KisIDList.
fillCmbProfiles(KisID(colorSpaceName, ""));
}
KisDlgCreateImg::~KisDlgCreateImg()
{
delete m_page;
}
Q_INT32 KisDlgCreateImg::imgWidth() const
{
return m_page -> intWidth -> value();
}
Q_INT32 KisDlgCreateImg::imgHeight() const
{
return m_page -> intHeight -> value();
}
KisID KisDlgCreateImg::colorSpaceID() const
{
return m_page -> cmbColorSpaces -> currentItem();
}
QColor KisDlgCreateImg::backgroundColor() const
{
return QColor(m_page -> cmbColor -> color());
}
Q_UINT8 KisDlgCreateImg::backgroundOpacity() const
{
Q_INT32 opacity = m_page -> sliderOpacity -> value();
if (!opacity)
return 0;
opacity = opacity * 255 / 100;
return opacity;
}
QString KisDlgCreateImg::imgName() const
{
return m_page -> txtName -> text();
}
double KisDlgCreateImg::imgResolution() const
{
return m_page -> doubleResolution -> value();
}
QString KisDlgCreateImg::imgDescription() const
{
return m_page -> txtDescription -> text();
}
QString KisDlgCreateImg::profileName() const
{
return m_page -> cmbProfile -> currentText();
}
void KisDlgCreateImg::fillCmbProfiles(const KisID & s)
{
m_page -> cmbProfile -> clear();
if (!KisMetaRegistry::instance()->csRegistry()->exists(s)) {
return;
}
KisColorSpaceFactory * csf = KisMetaRegistry::instance()->csRegistry() -> get(s);
if (csf == 0) return;
QValueVector<KisProfile *> profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor( csf );
QValueVector<KisProfile *> ::iterator it;
for ( it = profileList.begin(); it != profileList.end(); ++it ) {
m_page -> cmbProfile -> insertItem((*it) -> productName());
}
}
#include "kis_dlg_create_img.moc"
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_DLG_CREATE_IMG_H_
#define KIS_DLG_CREATE_IMG_H_
#include <kdialogbase.h>
#include <qcolor.h>
#include "kis_global.h"
class KisProfile;
class KisID;
class QButtonGroup;
class WdgNewImage;
class KisDlgCreateImg : public KDialogBase {
typedef KDialogBase super;
Q_OBJECT
public:
KisDlgCreateImg(Q_INT32 maxWidth, Q_INT32 defWidth,
Q_INT32 maxHeight, Q_INT32 defHeight,
QString colorSpaceName,
QString imageName,
QWidget *parent = 0, const char *name = 0);
virtual ~KisDlgCreateImg();
public:
QColor backgroundColor() const;
Q_UINT8 backgroundOpacity() const;
KisID colorSpaceID() const;
Q_INT32 imgWidth() const;
Q_INT32 imgHeight() const;
QString imgName() const;
double imgResolution() const;
QString imgDescription() const;
QString profileName() const;
private slots:
void fillCmbProfiles(const KisID &);
private:
WdgNewImage * m_page;
};
#endif // KIS_DLG_CREATE_IMG_H_
......@@ -60,9 +60,7 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageSP image, QWidget *parent,
KisConfig cfg;
m_page -> intWidth -> setValue(image -> width());
m_page -> intWidth -> setMaxValue(cfg.maxImgWidth());
m_page -> intHeight -> setValue(image -> height());
m_page -> intHeight -> setMaxValue(cfg.maxImgHeight());
m_page -> doubleResolution -> setValue(image -> xRes()); // XXX: separate values for x & y?
......
......@@ -58,7 +58,6 @@
#include "kis_types.h"
#include "kis_config.h"
#include "kis_debug_areas.h"
#include "kis_dlg_create_img.h"
#include "kis_doc.h"
#include "kis_factory.h"
#include "kis_image.h"
......@@ -76,6 +75,7 @@
#include "kis_part_layer.h"
#include "kis_doc_iface.h"
#include "kis_paint_device_action.h"
#include "kis_custom_image_widget.h"
static const char *CURRENT_DTD_VERSION = "1.3";
......@@ -184,13 +184,14 @@ bool KisDoc::initDoc(InitDocFlags flags, QWidget* parentWidget)
if (flags==KoDocument::InitDocEmpty)
{
/*
if ((ok = slotNewImage()))
emit imageListUpdated();
setModified(false);
KoDocument::setEmpty();
setUndo(true);
return ok;
}
*/ }
QString file;
KoTemplateChooseDia::DialogType dlgtype;
......@@ -210,12 +211,10 @@ bool KisDoc::initDoc(InitDocFlags flags, QWidget* parentWidget)
setUndo(false);