Merged dismine/valentina into develop

--HG--
branch : develop
This commit is contained in:
grumpi 2014-02-22 17:24:25 +01:00
commit d4a12cced8
18 changed files with 29316 additions and 114 deletions

6
README
View file

@ -24,8 +24,12 @@ Prerequisites:
* On Unix: * On Unix:
- ccache - ccache
- g++ (at least GCC 4.6 is needed and GCC 4.8 is recommended) - g++ (at least GCC 4.6 is needed and GCC 4.8 is recommended)
- xpdf package (tool pdftops).
* On Windows: * On Windows:
- MinGW or Visual Studio - MinGW or Visual Studio
- Xpdf is an open source viewer for Portable Document Format (PDF)
files. Website http://www.foolabs.com/xpdf/. Put tool pdftops.exe
in the same directory with Valentina's binary file.
The installed toolchains have to match the one Qt was compiled with. The installed toolchains have to match the one Qt was compiled with.

View file

@ -124,6 +124,13 @@ QMAKE_DISTCLEAN += $${DESTDIR}/* \
$${RCC_DIR}/* \ $${RCC_DIR}/* \
$$PWD/share/translations/valentina_*.qm $$PWD/share/translations/valentina_*.qm
INSTALL_TRANSLATIONS += share/translations/valentina_ru.qm \
share/translations/valentina_uk.qm \
share/translations/valentina_de.qm \
share/translations/valentina_cs.qm \
share/translations/valentina_he_IL.qm \
share/translations/valentina_fr.qm
unix { unix {
#VARIABLES #VARIABLES
isEmpty(PREFIX) { isEmpty(PREFIX) {
@ -138,12 +145,6 @@ desktop.path = $$DATADIR/applications/
desktop.files += dist/$${TARGET}.desktop desktop.files += dist/$${TARGET}.desktop
pixmaps.path = $$DATADIR/pixmaps/ pixmaps.path = $$DATADIR/pixmaps/
pixmaps.files += dist/$${TARGET}.png pixmaps.files += dist/$${TARGET}.png
INSTALL_TRANSLATIONS += share/translations/valentina_ru.qm \
share/translations/valentina_uk.qm \
share/translations/valentina_de.qm \
share/translations/valentina_cs.qm \
share/translations/valentina_he_IL.qm \
share/translations/valentina_fr.qm
translations.path = $$DATADIR/$${TARGET}/translations/ translations.path = $$DATADIR/$${TARGET}/translations/
translations.files = $$INSTALL_TRANSLATIONS translations.files = $$INSTALL_TRANSLATIONS
INSTALLS += target \ INSTALLS += target \
@ -169,9 +170,10 @@ defineTest(copyToDestdir) {
for(FILE, files) { for(FILE, files) {
# Replace slashes in paths with backslashes for Windows # Replace slashes in paths with backslashes for Windows
win32:FILE ~= s,/,\\,g win32{
win32:DDIR ~= s,/,\\,g FILE ~= s,/,\\,g
DDIR ~= s,/,\\,g
}
QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
} }

2
dist/debian/control vendored
View file

@ -8,7 +8,7 @@ Homepage: https://bitbucket.org/dismine/valentina
Package: valentina Package: valentina
Architecture: i386 amd64 Architecture: i386 amd64
Depends: ${shlibs:Depends}, ${misc:Depends} Depends: ${shlibs:Depends}, ${misc:Depends}, xpdf
Description: Pattern making program. Description: Pattern making program.
Open source project of creating a pattern making program, whose allow Open source project of creating a pattern making program, whose allow
create and modeling patterns of clothing. create and modeling patterns of clothing.

28855
share/resources/icon/logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 2.5 MiB

View file

@ -3,7 +3,10 @@
<!-- XML Schema Generated from XML Document--> <!-- XML Schema Generated from XML Document-->
<xs:element name="pattern"> <xs:element name="pattern">
<xs:complexType> <xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1"> <xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType> <xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:sequence minOccurs="0" maxOccurs="unbounded">

View file

@ -0,0 +1,114 @@
/************************************************************************
**
** @file dialogpatternproperties.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 18 2, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina 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 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialogpatternproperties.h"
#include "ui_dialogpatternproperties.h"
#include <QSettings>
DialogPatternProperties::DialogPatternProperties(VDomDocument *doc, QWidget *parent) :
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc)
{
ui->setupUi(this);
Q_CHECK_PTR(doc);
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
#ifdef Q_OS_WIN32
QString user = settings.value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
#else
QString user = settings.value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
#endif
ui->lineEditAuthor->setText(this->doc->UniqueTagText("author", user));
ui->plainTextEditDescription->setPlainText(this->doc->UniqueTagText("description"));
ui->plainTextEditTechNotes->setPlainText(this->doc->UniqueTagText("notes"));
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
Q_CHECK_PTR(bOk);
connect(bOk, &QPushButton::clicked, this, &DialogPatternProperties::Apply);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
Q_CHECK_PTR(bCansel);
connect(bCansel, &QPushButton::clicked, this, &DialogPatternProperties::close);
connect(this, &DialogPatternProperties::haveChange, this->doc, &VDomDocument::haveLiteChange);
}
DialogPatternProperties::~DialogPatternProperties()
{
delete ui;
}
void DialogPatternProperties::Apply()
{
Write("notes", ui->plainTextEditTechNotes->document()->toPlainText());
Write("description", ui->plainTextEditDescription->document()->toPlainText());
Write("author", ui->lineEditAuthor->text());
emit haveChange();
close();
}
void DialogPatternProperties::Write(const QString &tagName, const QString &text) const
{
QDomNodeList nodeList = doc->elementsByTagName(tagName);
if (nodeList.isEmpty())
{
QDomElement pattern = doc->documentElement();
QDomElement tag = doc->createElement(tagName);
QDomText domText = doc->createTextNode(text);
tag.appendChild(domText);
//Old pattern file doesn't have comment. But here we try insert tag after first child (comment).
// <pattern>
// <!--Valentina pattern format.-->
// -->place for new tag<--
// </pattern>
if (pattern.firstChild().isComment())
{
pattern.insertAfter(tag, pattern.firstChild());
}
else
{
pattern.insertBefore(tag, pattern.firstChild());
}
}
else
{
QDomElement oldTag = nodeList.at(0).toElement();
if (oldTag.isElement())
{
QDomElement newTag = doc->createElement(tagName);
QDomText domText = doc->createTextNode(text);
newTag.appendChild(domText);
QDomElement pattern = doc->documentElement();
pattern.replaceChild(newTag, oldTag);
}
}
}

View file

@ -0,0 +1,56 @@
/************************************************************************
**
** @file dialogpatternproperties.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 18 2, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina 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 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGPATTERNPROPERTIES_H
#define DIALOGPATTERNPROPERTIES_H
#include <QDialog>
#include "../xml/vdomdocument.h"
namespace Ui {
class DialogPatternProperties;
}
class DialogPatternProperties : public QDialog
{
Q_OBJECT
public:
DialogPatternProperties(VDomDocument *doc, QWidget *parent = 0);
virtual ~DialogPatternProperties();
signals:
void haveChange();
public slots:
void Apply();
private:
Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui;
VDomDocument *doc;
void Write(const QString &tagName, const QString &text) const;
};
#endif // DIALOGPATTERNPROPERTIES_H

View file

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPatternProperties</class>
<widget class="QDialog" name="DialogPatternProperties">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>646</width>
<height>605</height>
</rect>
</property>
<property name="windowTitle">
<string>Pattern properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Author name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditAuthor"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Pattern description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEditDescription">
<property name="documentTitle">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>For technical notes.</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEditTechNotes"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogPatternProperties</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogPatternProperties</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -52,5 +52,6 @@
#include "dialogtriangle.h" #include "dialogtriangle.h"
#include "dialogpointofintersection.h" #include "dialogpointofintersection.h"
#include "configdialog.h" #include "configdialog.h"
#include "dialogpatternproperties.h"
#endif // DIALOGS_H #endif // DIALOGS_H

View file

@ -24,7 +24,8 @@ HEADERS += \
src/dialogs/dialoguniondetails.h \ src/dialogs/dialoguniondetails.h \
src/dialogs/dialogcutarc.h \ src/dialogs/dialogcutarc.h \
src/dialogs/configdialog.h \ src/dialogs/configdialog.h \
src/dialogs/pages.h src/dialogs/pages.h \
src/dialogs/dialogpatternproperties.h
SOURCES += \ SOURCES += \
src/dialogs/dialogtriangle.cpp \ src/dialogs/dialogtriangle.cpp \
@ -51,7 +52,8 @@ SOURCES += \
src/dialogs/dialoguniondetails.cpp \ src/dialogs/dialoguniondetails.cpp \
src/dialogs/dialogcutarc.cpp \ src/dialogs/dialogcutarc.cpp \
src/dialogs/configdialog.cpp \ src/dialogs/configdialog.cpp \
src/dialogs/pages.cpp src/dialogs/pages.cpp \
src/dialogs/dialogpatternproperties.cpp
FORMS += \ FORMS += \
src/dialogs/dialogtriangle.ui \ src/dialogs/dialogtriangle.ui \
@ -75,4 +77,5 @@ FORMS += \
src/dialogs/dialogcutspline.ui \ src/dialogs/dialogcutspline.ui \
src/dialogs/dialogcutsplinepath.ui \ src/dialogs/dialogcutsplinepath.ui \
src/dialogs/dialoguniondetails.ui \ src/dialogs/dialoguniondetails.ui \
src/dialogs/dialogcutarc.ui src/dialogs/dialogcutarc.ui \
src/dialogs/dialogpatternproperties.ui

View file

@ -94,9 +94,27 @@ int main(int argc, char *argv[])
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
QTranslator appTranslator; QTranslator appTranslator;
appTranslator.load("valentina_" + checkedLocale, translationsPath); #ifdef Q_OS_WIN32
appTranslator.load("valentina_" + checkedLocale, "."+translationsPath);
#else
#ifdef QT_DEBUG
appTranslator.load("valentina_" + checkedLocale, "."+translationsPath);
#else
appTranslator.load("valentina_" + checkedLocale, translationsPath);
#endif
#endif
app.installTranslator(&appTranslator); app.installTranslator(&appTranslator);
static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
{
//If there is no default working icon theme then we should
//use an icon theme that we provide via a .qrc file
//This case happens under Windows and Mac OS X
//This does not happen under GNOME or KDE
QIcon::setThemeName("win.icon.theme");
}
MainWindow w; MainWindow w;
w.setWindowState(w.windowState() ^ Qt::WindowMaximized); w.setWindowState(w.windowState() ^ Qt::WindowMaximized);
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png")); app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));

View file

@ -545,6 +545,12 @@ void MainWindow::OpenRecentFile()
} }
} }
void MainWindow::PatternProperties()
{
DialogPatternProperties proper(doc, this);
proper.exec();
}
void MainWindow::showEvent( QShowEvent *event ) void MainWindow::showEvent( QShowEvent *event )
{ {
QMainWindow::showEvent( event ); QMainWindow::showEvent( event );
@ -988,6 +994,7 @@ void MainWindow::Clear()
comboBoxDraws->clear(); comboBoxDraws->clear();
ui->actionOptionDraw->setEnabled(false); ui->actionOptionDraw->setEnabled(false);
ui->actionSave->setEnabled(false); ui->actionSave->setEnabled(false);
ui->actionPattern_properties->setEnabled(false);
SetEnableTool(false); SetEnableTool(false);
} }
@ -1085,7 +1092,8 @@ void MainWindow::ActionLayout(bool checked)
QPainterPath path = VEquidistant().ContourPath(idetail.key(), pattern); QPainterPath path = VEquidistant().ContourPath(idetail.key(), pattern);
listDetails.append(new VItem(path, listDetails.size())); listDetails.append(new VItem(path, listDetails.size()));
} }
emit ModelChosen(listDetails, curFile); QString description = doc->UniqueTagText("description");
emit ModelChosen(listDetails, curFile, description);
} }
void MainWindow::ClosedActionHistory() void MainWindow::ClosedActionHistory()
@ -1374,19 +1382,6 @@ void MainWindow::CreateMenus()
void MainWindow::CreateActions() void MainWindow::CreateActions()
{ {
ui->setupUi(this); ui->setupUi(this);
static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
{
//If there is no default working icon theme then we should
//use an icon theme that we provide via a .qrc file
//This case happens under Windows and Mac OS X
//This does not happen under GNOME or KDE
QIcon::setThemeName("win.icon.theme");
ui->actionNew->setIcon(QIcon::fromTheme("document-new"));
ui->actionOpen->setIcon(QIcon::fromTheme("document-open"));
ui->actionSave->setIcon(QIcon::fromTheme("document-save"));
ui->actionSaveAs->setIcon(QIcon::fromTheme("document-save-as"));
}
connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ActionAroowTool); connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ActionAroowTool);
connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw);
@ -1402,6 +1397,8 @@ void MainWindow::CreateActions()
connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About); connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About);
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
connect(ui->actionOptions, &QAction::triggered, this, &MainWindow::Options); connect(ui->actionOptions, &QAction::triggered, this, &MainWindow::Options);
connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties);
ui->actionPattern_properties->setEnabled(false);
//Actions for recent files loaded by a main window application. //Actions for recent files loaded by a main window application.
for (int i = 0; i < MaxRecentFiles; ++i) for (int i = 0; i < MaxRecentFiles; ++i)
@ -1475,6 +1472,7 @@ void MainWindow::LoadPattern(const QString &fileName)
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
#endif #endif
ui->actionPattern_properties->setEnabled(true);
} }
catch (const VExceptionObjectError &e) catch (const VExceptionObjectError &e)
{ {

View file

@ -362,12 +362,14 @@ public slots:
*/ */
void tableClosed(); void tableClosed();
void OpenRecentFile(); void OpenRecentFile();
void PatternProperties();
signals: signals:
/** /**
* @brief ModelChosen emit after calculation all details. * @brief ModelChosen emit after calculation all details.
* @param listDetails list of details. * @param listDetails list of details.
* @param description pattern description.
*/ */
void ModelChosen(QVector<VItem*> listDetails, const QString &curFile); void ModelChosen(QVector<VItem*> listDetails, const QString &curFile, const QString &description);
protected: protected:
/** /**
* @brief keyPressEvent handle key press events. * @brief keyPressEvent handle key press events.

View file

@ -302,7 +302,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>137</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -378,7 +378,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>137</width>
<height>104</height> <height>104</height>
</rect> </rect>
</property> </property>
@ -579,7 +579,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>137</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -695,6 +695,7 @@
<addaction name="actionHistory"/> <addaction name="actionHistory"/>
<addaction name="actionLayout"/> <addaction name="actionLayout"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionPattern_properties"/>
<addaction name="actionOptions"/> <addaction name="actionOptions"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
@ -993,6 +994,11 @@
<string>Options...</string> <string>Options...</string>
</property> </property>
</action> </action>
<action name="actionPattern_properties">
<property name="text">
<string>Pattern properties</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<tabstops> <tabstops>

View file

@ -37,7 +37,7 @@ TableWindow::TableWindow(QWidget *parent)
:QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow), :QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow),
listDetails(QVector<VItem*>()), outItems(false), collidingItems(false), tableScene(0), listDetails(QVector<VItem*>()), outItems(false), collidingItems(false), tableScene(0),
paper(0), shadowPaper(0), listOutItems(0), listCollidingItems(QList<QGraphicsItem*>()), paper(0), shadowPaper(0), listOutItems(0), listCollidingItems(QList<QGraphicsItem*>()),
indexDetail(0), sceneRect(QRectF()), fileName(QString()) indexDetail(0), sceneRect(QRectF()), fileName(QString()), description(QString())
{ {
ui->setupUi(this); ui->setupUi(this);
numberDetal = new QLabel(tr("0 details left."), this); numberDetal = new QLabel(tr("0 details left."), this);
@ -118,10 +118,13 @@ void TableWindow::AddDetail()
/* /*
* Get details for creation layout. * Get details for creation layout.
*/ */
void TableWindow::ModelChosen(QVector<VItem*> listDetails, const QString &fileName) void TableWindow::ModelChosen(QVector<VItem*> listDetails, const QString &fileName, const QString &description)
{ {
this->fileName = fileName; this->description = description;
this->fileName.remove(this->fileName.size()-4, 4);
QFileInfo fi( fileName );
this->fileName = fi.baseName();
this->listDetails = listDetails; this->listDetails = listDetails;
listOutItems = new QBitArray(this->listDetails.count()); listOutItems = new QBitArray(this->listDetails.count());
AddPaper(); AddPaper();
@ -183,7 +186,7 @@ void TableWindow::saveScene()
QString sf; QString sf;
// the save function // the save function
QString dir = QDir::homePath()+fileName; QString dir = QDir::homePath()+"/"+fileName;
QString name = QFileDialog::getSaveFileName(this, tr("Save layout"), dir, saveMessage, &sf); QString name = QFileDialog::getSaveFileName(this, tr("Save layout"), dir, saveMessage, &sf);
if (name.isEmpty()) if (name.isEmpty())
@ -207,34 +210,35 @@ void TableWindow::saveScene()
QFileInfo fi( name ); QFileInfo fi( name );
QStringList suffix; QStringList suffix;
suffix << "svg" << "png" << "pdf" << "eps" << "ps"; suffix << "svg" << "png" << "pdf" << "eps" << "ps";
switch (suffix.indexOf(fi.suffix())) { switch (suffix.indexOf(fi.suffix()))
case 0: {
case 0: //svg
paper->setVisible(false); paper->setVisible(false);
SvgFile(name); SvgFile(name);
paper->setVisible(true); paper->setVisible(true);
break; break;
case 1: case 1: //png
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
PngFile(name); PngFile(name);
paper->setPen(QPen(Qt::black, widthMainLine)); paper->setPen(QPen(Qt::black, widthMainLine));
break; break;
case 2: case 2: //pdf
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
PdfFile(name); PdfFile(name);
paper->setPen(QPen(Qt::black, widthMainLine)); paper->setPen(QPen(Qt::black, widthMainLine));
break; break;
case 3: case 3: //eps
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
EpsFile(name); EpsFile(name);
paper->setPen(QPen(Qt::black, widthMainLine)); paper->setPen(QPen(Qt::black, widthMainLine));
break; break;
case 4: case 4: //ps
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
PsFile(name); PsFile(name);
paper->setPen(QPen(Qt::black, widthMainLine)); paper->setPen(QPen(Qt::black, widthMainLine));
break; break;
default: default:
qWarning() << "Bad file suffix in TableWindow::saveScene()."; qWarning() << "Bad file suffix"<<Q_FUNC_INFO;
break; break;
} }
brush->setColor( QColor( Qt::gray ) ); brush->setColor( QColor( Qt::gray ) );
@ -421,11 +425,9 @@ void TableWindow::SvgFile(const QString &name) const
QSvgGenerator generator; QSvgGenerator generator;
generator.setFileName(name); generator.setFileName(name);
generator.setSize(paper->rect().size().toSize()); generator.setSize(paper->rect().size().toSize());
generator.setTitle(tr("SVG Generator Example Drawing")); generator.setTitle("Valentina pattern");
generator.setDescription(tr("An SVG drawing created by the SVG Generator " generator.setDescription(description);
"Example provided with Qt."));
generator.setResolution(PrintDPI); generator.setResolution(PrintDPI);
qDebug()<<"resolution is" << generator.resolution();
QPainter painter; QPainter painter;
painter.begin(&generator); painter.begin(&generator);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
@ -480,75 +482,58 @@ void TableWindow::PdfFile(const QString &name) const
void TableWindow::EpsFile(const QString &name) const void TableWindow::EpsFile(const QString &name) const
{ {
QTemporaryFile tmp; QTemporaryFile tmp;
if (tmp.open()) { if (tmp.open())
QProcess proc; {
QString program;
QStringList params;
PdfFile(tmp.fileName()); PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32 QStringList params;
program = "pdftops.exe";
#else
program = "pdftops";
#endif
params << "-eps" << tmp.fileName() << name; params << "-eps" << tmp.fileName() << name;
#ifndef QT_NO_CURSOR PdfToPs(name, params);
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
proc.start(program, params);
proc.waitForFinished(15000);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
qDebug() << proc.errorString();
QFile F(name);
if(!F.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
"Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
} }
} }
void TableWindow::PsFile(const QString &name) const void TableWindow::PsFile(const QString &name) const
{ {
QTemporaryFile tmp; QTemporaryFile tmp;
if (tmp.open()) { if (tmp.open())
QProcess proc; {
QString program;
QStringList params;
PdfFile(tmp.fileName()); PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32 QStringList params;
program = "pdftops.exe";
#else
program = "pdftops";
#endif
params << tmp.fileName() << name; params << tmp.fileName() << name;
#ifndef QT_NO_CURSOR PdfToPs(name, params);
QApplication::setOverrideCursor(Qt::WaitCursor); }
#endif }
proc.start(program, params);
proc.waitForFinished(15000); //TODO delete parametr name and use last parameter in string list instead.
#ifndef QT_NO_CURSOR void TableWindow::PdfToPs(const QString &name, const QStringList &params) const
QApplication::restoreOverrideCursor(); {
#endif QProcess proc;
qDebug() << proc.errorString(); QString program;
QFile F(name); #ifdef Q_OS_WIN32
if(!F.exists()) program = "pdftops.exe";
{ #else
QMessageBox msgBox(QMessageBox::Critical, "Critical error!", program = "pdftops";
"Creating file '"+name+"' failed!", #endif
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec(); #ifndef QT_NO_CURSOR
} QApplication::setOverrideCursor(Qt::WaitCursor);
} #endif
proc.start(program, params);
proc.waitForFinished(15000);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
qDebug() << proc.errorString();
QFile f(name);
if (!f.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!", "Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
} }

View file

@ -63,8 +63,9 @@ public slots:
/** /**
* @brief ModelChosen show window when user want create new layout. * @brief ModelChosen show window when user want create new layout.
* @param listDetails list of details. * @param listDetails list of details.
* @param description pattern description.
*/ */
void ModelChosen(QVector<VItem*> listDetails, const QString &fileName); void ModelChosen(QVector<VItem*> listDetails, const QString &fileName, const QString &description);
/** /**
* @brief StopTable stop creation layout. * @brief StopTable stop creation layout.
*/ */
@ -193,6 +194,10 @@ private:
* @brief fileName keep name of pattern file. * @brief fileName keep name of pattern file.
*/ */
QString fileName; QString fileName;
/**
* @brief description pattern description
*/
QString description;
/** /**
* @brief SvgFile save layout to svg file. * @brief SvgFile save layout to svg file.
* @param name name layout file. * @param name name layout file.
@ -218,6 +223,13 @@ private:
* @param name name layout file. * @param name name layout file.
*/ */
void PsFile(const QString &name)const; void PsFile(const QString &name)const;
/**
* @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format.
* @param name name output file.
* @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when
* need create eps file.
*/
void PdfToPs(const QString &name, const QStringList &params)const;
}; };
#endif // TABLEWINDOW_H #endif // TABLEWINDOW_H

View file

@ -125,15 +125,25 @@ bool VDomDocument::find(const QDomElement &node, const QString& id)
void VDomDocument::CreateEmptyFile() void VDomDocument::CreateEmptyFile()
{ {
QDomElement domElement = this->createElement("pattern"); QDomElement patternElement = this->createElement("pattern");
this->appendChild(patternElement);
this->appendChild(domElement);
QDomComment info = this->createComment("Valentina pattern format."); QDomComment info = this->createComment("Valentina pattern format.");
domElement.appendChild(info); patternElement.appendChild(info);
QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
this->insertBefore(xmlNode, this->firstChild()); this->insertBefore(xmlNode, this->firstChild());
QDomElement authorElement = this->createElement("author");
patternElement.appendChild(authorElement);
QDomElement descElement = this->createElement("description");
patternElement.appendChild(descElement);
QDomElement notesElement = this->createElement("notes");
patternElement.appendChild(notesElement);
QDomElement incrElement = this->createElement("increments"); QDomElement incrElement = this->createElement("increments");
domElement.appendChild(incrElement); patternElement.appendChild(incrElement);
} }
bool VDomDocument::CheckNameDraw(const QString& name) const bool VDomDocument::CheckNameDraw(const QString& name) const
@ -1364,6 +1374,28 @@ void VDomDocument::setPatternModified(bool value)
patternModified = value; patternModified = value;
} }
QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal)
{
QDomNodeList nodeList = this->elementsByTagName(tagName);
if (nodeList.isEmpty())
{
return defVal;
}
else
{
QDomNode domNode = nodeList.at(0);
if (domNode.isNull() == false && domNode.isElement())
{
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
return domElement.text();
}
}
}
return defVal;
}
void VDomDocument::setCursor(const qint64 &value) void VDomDocument::setCursor(const qint64 &value)
{ {

View file

@ -241,6 +241,7 @@ public:
qint64 SPointActiveDraw(); qint64 SPointActiveDraw();
bool isPatternModified() const; bool isPatternModified() const;
void setPatternModified(bool value); void setPatternModified(bool value);
QString UniqueTagText(const QString &tagName, const QString &defVal = QString());
signals: signals:
/** /**
* @brief ChangedActivDraw change active pattern peace. * @brief ChangedActivDraw change active pattern peace.