r14150 by fschmid - Fixed Bug #5462: "Request for feature: Save and reuse gradient settings"
scribus-commit
scribus-commit at lists.scribus.net
Tue Oct 13 14:41:35 CEST 2009
Revision: 14150
Author: fschmid
Date: 2009-10-13T11:22:47.512537Z
Commit message: Fixed Bug #5462: "Request for feature: Save and reuse gradient settings"
Changeset:
M /trunk/Scribus/scribus/ui/propertiespalette.cpp
A /trunk/Scribus/scribus/ui/gradientaddedit.cpp
M /trunk/Scribus/scribus/scribusXml.cpp
M /trunk/Scribus/scribus/pageitem.cpp
M /trunk/Scribus/scribus/CMakeLists.txt
A /trunk/Scribus/scribus/ui/gradientaddedit.h
A /trunk/Scribus/scribus/ui/gradientmanager.ui
M /trunk/Scribus/scribus/pageitem.h
M /trunk/Scribus/scribus/scribusdoc.cpp
A /trunk/Scribus/scribus/ui/gradientmanager.cpp
M /trunk/Scribus/scribus/ui/colorpalette.ui
M /trunk/Scribus/scribus/scribusdoc.h
M /trunk/Scribus/scribus/actionmanager.cpp
M /trunk/Scribus/scribus/resourcecollection.h
M /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
A /trunk/Scribus/scribus/ui/gradientmanager.h
M /trunk/Scribus/scribus/prefsmanager.cpp
M /trunk/Scribus/scribus/scribus.cpp
M /trunk/Scribus/scribus/ui/gradientpreview.cpp
M /trunk/Scribus/scribus/ui/gradienteditor.ui
M /trunk/Scribus/scribus/prefsstructs.h
M /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
M /trunk/Scribus/scribus/ui/cpalette.cpp
M /trunk/Scribus/scribus/scribus.h
M /trunk/Scribus/scribus/ui/gradienteditor.cpp
M /trunk/Scribus/scribus/ui/gradientpreview.h
M /trunk/Scribus/scribus/ui/cpalette.h
M /trunk/Scribus/scribus/pageitem_desaxe.cpp
A /trunk/Scribus/scribus/ui/gradientaddedit.ui
M /trunk/Scribus/scribus/ui/gradienteditor.h
M /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
Diffs:
Index: scribus/resourcecollection.h
===================================================================
--- scribus/resourcecollection.h (revision 14149)
+++ scribus/resourcecollection.h (revision 14150)
@@ -20,6 +20,7 @@
#include <QList>
#include <QMap>
#include <QString>
+#include "vgradient.h"
/**
* A simple structure which holds the names of all resources & styles used in a doc or part of a document.
@@ -40,6 +41,7 @@
void collectFont(const QString& name) { if (!name.isEmpty()) m_fonts.insert(name,name); }
void collectPattern(const QString& name) { if (!name.isEmpty()) m_patterns.insert(name,name); }
void collectColor(const QString& name) { if (!name.isEmpty()) m_colors.insert(name,name); }
+ void collectGradient(const QString& name) { if (!name.isEmpty()) m_gradients.insert(name,name); }
void collectStyle(const QString& name) { if (!name.isEmpty()) m_pstyles.insert(name,name); }
void collectCharStyle(const QString& name) { if (!name.isEmpty()) m_cstyles.insert(name,name); }
void collectLineStyle(const QString& name) { if (!name.isEmpty()) m_linestyles.insert(name,name); }
@@ -47,6 +49,7 @@
void mapFont(const QString& oldname, const QString& newname) { m_fonts.insert(oldname, newname); }
void mapPattern(const QString& oldname, const QString& newname) { m_patterns.insert(oldname, newname); }
void mapColor(const QString& oldname, const QString& newname) { m_colors.insert(oldname, newname); }
+ void mapGradients(const QString& oldname, const QString& newname) { m_gradients.insert(oldname, newname); }
void mapStyle(const QString& oldname, const QString& newname) { m_pstyles.insert(oldname, newname); }
void mapCharStyle(const QString& oldname, const QString& newname) { m_cstyles.insert(oldname, newname); }
void mapLineStyle(const QString& oldname, const QString& newname) { m_linestyles.insert(oldname, newname); }
@@ -54,6 +57,7 @@
void mapFonts(const QMap<QString,QString>& newnames) { m_fonts = newnames; }
void mapPatterns(const QMap<QString,QString>& newnames) { m_patterns = newnames; }
void mapColors(const QMap<QString,QString>& newnames) { m_colors = newnames; }
+ void mapGradients(const QMap<QString,QString>& newnames) { m_gradients = newnames; }
void mapStyles(const QMap<QString,QString>& newnames) { m_pstyles = newnames; }
void mapCharStyles(const QMap<QString,QString>& newnames) { m_cstyles = newnames; }
void mapLineStyles(const QMap<QString,QString>& newnames) { m_linestyles = newnames; }
@@ -61,6 +65,7 @@
const QMap<QString, QString>& fonts() { return m_fonts; }
const QMap<QString, QString>& patterns() { return m_patterns; }
const QMap<QString, QString>& colors() { return m_colors; }
+ const QMap<QString, QString>& gradients() { return m_gradients; }
const QMap<QString, QString>& styles() { return m_pstyles; }
const QMap<QString, QString>& charStyles() { return m_cstyles; }
const QMap<QString, QString>& lineStyles() { return m_linestyles; }
@@ -68,6 +73,7 @@
QList<QString> fontNames() const { return m_fonts.keys(); }
QList<QString> patternNames() const { return m_patterns.keys(); }
QList<QString> colorNames() const { return m_colors.keys(); }
+ QList<QString> gradientNames() const { return m_gradients.keys(); }
QList<QString> styleNames() const { return m_pstyles.keys(); }
QList<QString> charStyleNames() const { return m_cstyles.keys(); }
QList<QString> lineStyleNames() const { return m_linestyles.keys(); }
@@ -79,10 +85,12 @@
SCFonts* availableFonts;
ColorList* availableColors;
+ QMap<QString, VGradient> *availableGradients;
private:
QMap<QString,QString> m_fonts;
QMap<QString,QString> m_patterns;
QMap<QString,QString> m_colors;
+ QMap<QString,QString> m_gradients;
QMap<QString,QString> m_pstyles;
QMap<QString,QString> m_cstyles;
QMap<QString,QString> m_linestyles;
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp (revision 14149)
+++ scribus/scribusdoc.cpp (revision 14150)
@@ -36,6 +36,7 @@
#include "canvas.h"
#include "cmserrorhandling.h"
+#include "colorblind.h"
#include "commonstrings.h"
#include "fileloader.h"
#include "filewatcher.h"
@@ -480,6 +481,7 @@
PDF_Options.firstUse = true;
docPatterns.clear();
+ docGradients.clear();
if (AutoSave && ScCore->usingGUI())
autoSaveTimer->start(AutoSaveTime);
@@ -555,6 +557,9 @@
appMode = modeNormal;
PrefsManager *prefsManager=PrefsManager::instance();
+
+ docGradients = prefsManager->appPrefs.defaultGradients;
+
PageColors = prefsManager->colorSet();
PageColors.ensureBlackAndWhite();
PageColors.setDocument(this);
@@ -997,6 +1002,27 @@
}
}
}
+
+ QMap<QString,VGradient>::Iterator itg;
+ for (itg = docGradients.begin(); itg != docGradients.end(); ++itg)
+ {
+ if (newNames.gradients().contains(itg.key()))
+ docGradients.erase(itg);
+ else
+ {
+ QMap<QString,QString>::ConstIterator itc;
+ QList<VColorStop*> cstops = itg.value().colorStops();
+ for (uint cst = 0; cst < itg.value().Stops(); ++cst)
+ {
+ itc = newNames.colors().find(cstops.at(cst)->name);
+ if (itc != newNames.colors().end())
+ {
+ if (*itc != CommonStrings::None)
+ cstops.at(cst)->name = *itc;
+ }
+ }
+ }
+ }
if (newNames.colors().count() > 0 || newNames.fonts().count() > 0)
{
@@ -2671,7 +2697,20 @@
return found;
}
+bool ScribusDoc::addGradient(QString &name, VGradient &gradient)
+{
+ if (docGradients.contains(name))
+ name = tr("Copy_of_")+name;
+ docGradients.insert(name, gradient);
+ return true;
+}
+void ScribusDoc::setGradients(QMap<QString, VGradient> &gradients)
+{
+ docGradients.clear();
+ docGradients = gradients;
+}
+
bool ScribusDoc::addPattern(QString &name, ScPattern& pattern)
{
if (docPatterns.contains(name))
@@ -2680,7 +2719,6 @@
return true;
}
-
void ScribusDoc::setPatterns(QMap<QString, ScPattern> &patterns)
{
docPatterns.clear();
@@ -3361,6 +3399,22 @@
//Adjust Items of the 3 types to the colors
uint itemsCount=Items->count();
updateAllItemQColors();
+ QMap<QString, VGradient>::Iterator itGrad;
+ for (itGrad = docGradients.begin(); itGrad != docGradients.end(); ++itGrad)
+ {
+ QList<VColorStop*> cstops = itGrad.value().colorStops();
+ for (uint cst = 0; cst < itGrad.value().Stops(); ++cst)
+ {
+ const ScColor& col = PageColors[cstops.at(cst)->name];
+ QColor tmp = ScColorEngine::getShadeColorProof(col, this, cstops.at(cst)->shade);
+ if ((view()) && (view()->m_canvas->usePreviewVisual()))
+ {
+ VisionDefectColor defect;
+ tmp = defect.convertDefect(tmp, view()->m_canvas->previewVisual());
+ }
+ cstops.at(cst)->color = tmp;
+ }
+ }
for (uint c=0; c<itemsCount; ++c)
{
PageItem *ite = Items->at(c);
Index: scribus/prefsmanager.cpp
===================================================================
--- scribus/prefsmanager.cpp (revision 14149)
+++ scribus/prefsmanager.cpp (revision 14150)
@@ -44,6 +44,7 @@
#include "pdfoptions.h"
#include "prefsfile.h"
#include "scclocale.h"
+#include "sccolorengine.h"
#include "scfonts.h"
#include "ui/scmessagebox.h"
#include "scpaths.h"
@@ -140,6 +141,7 @@
appPrefs.itemToolPrefs.textSize = 120;
/** Default colours **/
+ appPrefs.defaultGradients.clear();
appPrefs.colorPrefs.DColors.clear();
ColorSetManager csm;
@@ -1556,6 +1558,24 @@
co.setAttribute("Register", static_cast<int>(itc.value().isRegistrationColor()));
elem.appendChild(co);
}
+ QMap<QString, VGradient>::Iterator itGrad;
+ for (itGrad = appPrefs.defaultGradients.begin(); itGrad != appPrefs.defaultGradients.end(); ++itGrad)
+ {
+ QDomElement grad = docu.createElement("Gradient");
+ grad.setAttribute("Name",itGrad.key());
+ VGradient gra = itGrad.value();
+ QList<VColorStop*> cstops = gra.colorStops();
+ for (uint cst = 0; cst < gra.Stops(); ++cst)
+ {
+ QDomElement stop = docu.createElement("CSTOP");
+ stop.setAttribute("NAME", cstops.at(cst)->name);
+ stop.setAttribute("RAMP", ScCLocale::toQStringC(cstops.at(cst)->rampPoint));
+ stop.setAttribute("TRANS", ScCLocale::toQStringC(cstops.at(cst)->opacity));
+ stop.setAttribute("SHADE", cstops.at(cst)->shade);
+ grad.appendChild(stop);
+ }
+ elem.appendChild(grad);
+ }
for ( SCFontsIterator itf(appPrefs.fontPrefs.AvailFonts); itf.hasNext(); itf.next())
{
if (!itf.currentKey().isEmpty())
@@ -2261,6 +2281,31 @@
lf.setRegistrationColor(false);
appPrefs.colorPrefs.DColors[dc.attribute("NAME")] = lf;
}
+ if (dc.tagName() == "Gradient")
+ {
+ VGradient gra = VGradient(VGradient::linear);
+ gra.clearStops();
+ QDomNode grad = dc.firstChild();
+ while(!grad.isNull())
+ {
+ QDomElement stop = grad.toElement();
+ QString name = stop.attribute("NAME");
+ double ramp = ScCLocale::toDoubleC(stop.attribute("RAMP"), 0.0);
+ int shade = stop.attribute("SHADE", "100").toInt();
+ double opa = ScCLocale::toDoubleC(stop.attribute("TRANS"), 1.0);
+ QColor color;
+ if (name == CommonStrings::None)
+ color = QColor(255, 255, 255, 0);
+ else
+ {
+ const ScColor& col = appPrefs.colorPrefs.DColors[name];
+ color = ScColorEngine::getShadeColorProof(col, NULL, shade);
+ }
+ gra.addStop(color, ramp, 0.5, opa, name, shade);
+ grad = grad.nextSibling();
+ }
+ appPrefs.defaultGradients.insert(dc.attribute("Name"), gra);
+ }
if (dc.tagName()=="Substitute")
appPrefs.fontPrefs.GFontSub[dc.attribute("Name")] = dc.attribute("Replace");
if (dc.tagName()=="COLORSET")
Index: scribus/scribusXml.cpp
===================================================================
--- scribus/scribusXml.cpp (revision 14149)
+++ scribus/scribusXml.cpp (revision 14150)
@@ -1147,6 +1147,29 @@
if (!doc->MLineStyles.contains(mlName))
doc->MLineStyles.insert(mlName, ml);
}
+ if (tagName == "Gradient")
+ {
+ VGradient gra;
+ QString grName = attrs.value("Name").toString();gra = VGradient(VGradient::linear);
+ gra.clearStops();
+ while(!(sReader.isEndElement() && sReader.name() == tagName))
+ {
+ if (sReader.readNext() != QXmlStreamReader::StartElement)
+ continue;
+ QString tagName1 = sReader.name().toString();
+ QXmlStreamAttributes attrs1 = sReader.attributes();
+ if (tagName1 == "CSTOP")
+ {
+ QString name = attrs1.value("NAME").toString();
+ double ramp = ScCLocale::toDoubleC(attrs1.value("RAMP").toString());
+ double opa = ScCLocale::toDoubleC(attrs1.value("TRANS").toString());
+ int shade = attrAsInt(attrs1, "SHADE");
+ gra.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade);
+ }
+ }
+ if (!doc->docGradients.contains(grName))
+ doc->docGradients.insert(grName, gra);
+ }
if (tagName=="STYLE")
{
GetStyle(sReader, vg, NULL, doc, true);
@@ -1182,6 +1205,7 @@
int actualPageNumber = 0;
QString modelFile;
QString currentView;
+ QString gradName;
while(!sReader.atEnd() && !sReader.hasError())
{
sReader.readNext();
@@ -1201,6 +1225,7 @@
OB.endArrowIndex = arrowID[ attrAsInt(attrs, "endArrowIndex", 0)];
OB.isBookmark = attrAsInt(attrs, "BOOKMARK");
OB.NamedLStyle = attrAsString(attrs, "NAMEDLST", "");
+ gradName = attrAsString(attrs, "GRNAME", "");
isGroupControl = attrAsBool(attrs, "isGroupControl", false);
groupsLastItem = attrAsInt (attrs, "groupsLastItem", 0);
itemOwnLink = attrAsInt (attrs, "OwnLINK", 0);
@@ -1406,6 +1431,7 @@
LastStyles lastStyle;
view->PasteItem(&OB, true, true, false);
PageItem* Neu = doc->Items->at(doc->Items->count()-1);
+ Neu->setGradient(gradName);
storyText.setDefaultStyle(Neu->itemText.defaultStyle());
if (Neu->asLatexFrame())
{
@@ -2102,6 +2128,23 @@
}
writer.writeEndElement();
}
+ QMap<QString, VGradient>::Iterator itGrad;
+ for (itGrad = doc->docGradients.begin(); itGrad != doc->docGradients.end(); ++itGrad)
+ {
+ writer.writeStartElement("Gradient");
+ writer.writeAttribute("Name",itGrad.key());
+ VGradient gra = itGrad.value();
+ QList<VColorStop*> cstops = gra.colorStops();
+ for (uint cst = 0; cst < gra.Stops(); ++cst)
+ {
+ writer.writeEmptyElement("CSTOP");
+ writer.writeAttribute("RAMP", cstops.at(cst)->rampPoint);
+ writer.writeAttribute("NAME", cstops.at(cst)->name);
+ writer.writeAttribute("SHADE", cstops.at(cst)->shade);
+ writer.writeAttribute("TRANS", cstops.at(cst)->opacity);
+ }
+ writer.writeEndElement();
+ }
QMap<int, ArrowDesc> usedArrows;
QMap<int, ArrowDesc>::Iterator itar;
struct ArrowDesc arrow;
@@ -2223,6 +2266,7 @@
writer.writeAttribute("GRSTARTY", item->GrStartY);
writer.writeAttribute("GRENDX" , item->GrEndX);
writer.writeAttribute("GRENDY" , item->GrEndY);
+ writer.writeAttribute("GRNAME" , item->gradient());
}
if (item->effectsInUse.count() != 0)
Index: scribus/prefsstructs.h
===================================================================
--- scribus/prefsstructs.h (revision 14149)
+++ scribus/prefsstructs.h (revision 14150)
@@ -18,6 +18,7 @@
#include <QHash>
#include "pdfoptions.h"
#include "scfonts.h"
+#include "vgradient.h"
struct CheckerPrefs
{
@@ -378,6 +379,7 @@
PrintPreviewPrefs printPreviewPrefs;
QList<ArrowDesc> arrowStyles;
+ QMap<QString, VGradient> defaultGradients;
QList<PageSet> pageSets;
QString curCheckProfile;
Index: scribus/pageitem.h
===================================================================
--- scribus/pageitem.h (revision 14149)
+++ scribus/pageitem.h (revision 14150)
@@ -667,6 +667,15 @@
*/
void setItemName(const QString& newName);
+ /** @brief Get the name of the gradient of the object */
+ QString gradient() const { return gradientVal; }
+
+ /**
+ * @brief Set the fill gradient of the object.
+ * @param newGradient fill gradient for the object
+ */
+ void setGradient(const QString &newGradient);
+
/** @brief Get the name of the pattern of the object */
QString pattern() const { return patternVal; }
@@ -1101,6 +1110,12 @@
QString AnName;
/**
+ * @brief Fill gradient name
+ * @sa PageItem::gradient(), PageItem::setGradient()
+ */
+ QString gradientVal;
+
+ /**
* @brief Fill pattern name
* @sa PageItem::pattern(), PageItem::setPattern()
*/
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp (revision 14149)
+++ scribus/pageitem.cpp (revision 14150)
@@ -183,6 +183,7 @@
undoManager(other.undoManager),
m_ItemType(other.m_ItemType),
AnName(other.AnName),
+ gradientVal(other.gradientVal),
patternVal(other.patternVal),
patternScaleX(other.patternScaleX),
patternScaleY(other.patternScaleY),
@@ -309,6 +310,7 @@
GrStartY = 0;
GrEndX = w;
GrEndY = 0;
+ gradientVal = "";
patternVal = "";
patternScaleX = 100;
patternScaleY = 100;
@@ -1042,6 +1044,10 @@
}
else
{
+ if ((!gradientVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientVal)))
+ gradientVal = "";
+ if (!(gradientVal.isEmpty()) && (m_Doc->docGradients.contains(gradientVal)))
+ fill_gradient = m_Doc->docGradients[gradientVal];
if (fill_gradient.Stops() < 2) // fall back to solid filling if there are not enough colorstops in the gradient.
{
if (fillColor() != CommonStrings::None)
@@ -2226,6 +2232,12 @@
setUName(AnName); // set the name for the UndoObject too
}
+void PageItem::setGradient(const QString &newGradient)
+{
+ if (gradientVal != newGradient)
+ gradientVal = newGradient;
+}
+
void PageItem::setPattern(const QString &newPattern)
{
if (patternVal != newPattern)
@@ -3940,6 +3952,10 @@
it = newNames.patterns().find(pattern());
if (it != newNames.patterns().end())
setPattern(*it);
+
+ it = newNames.gradients().find(gradient());
+ if (it != newNames.gradients().end())
+ setGradient(*it);
it = newNames.lineStyles().find(customLineStyle());
if (it != newNames.lineStyles().end())
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h (revision 14149)
+++ scribus/scribusdoc.h (revision 14150)
@@ -523,6 +523,11 @@
*/
bool lineStylesUseColor(const QString& colorName);
/*!
+ * @brief Set the gradients for a document
+ */
+ bool addGradient(QString &name, VGradient &gradient);
+ void setGradients(QMap<QString, VGradient> &gradients);
+ /*!
* @brief Set the patterns for a document
*/
bool addPattern(QString &name, ScPattern& pattern);
@@ -1078,6 +1083,7 @@
QMap<QString,multiLine> MLineStyles;
QList<ArrowDesc> arrowStyles;
QMap<QString, ScPattern> docPatterns;
+ QMap<QString, VGradient> docGradients;
QWidget* WinHan;
bool DoDrawing;
struct OpenNodesList
Index: scribus/actionmanager.cpp
===================================================================
--- scribus/actionmanager.cpp (revision 14149)
+++ scribus/actionmanager.cpp (revision 14150)
@@ -228,6 +228,8 @@
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="editPatterns";
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+ name="editGradients";
+ scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="editStyles";
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="editMasterPages";
@@ -255,6 +257,7 @@
connect( (*scrActions)["editColors"], SIGNAL(triggered()), mainWindow, SLOT(slotEditColors()) );
connect( (*scrActions)["editReplaceColors"], SIGNAL(triggered()), mainWindow, SLOT(slotReplaceColors()) );
connect( (*scrActions)["editPatterns"], SIGNAL(triggered()), mainWindow, SLOT(managePatterns()) );
+ connect( (*scrActions)["editGradients"], SIGNAL(triggered()), mainWindow, SLOT(manageGradients()) );
connect( (*scrActions)["editMasterPages"], SIGNAL(triggered()), mainWindow, SLOT(manageMasterPages()) );
connect( (*scrActions)["editJavascripts"], SIGNAL(triggered()), mainWindow, SLOT(ManageJava()) );
}
@@ -1304,6 +1307,7 @@
(*scrActions)["editColors"]->setTexts( tr("C&olors..."));
(*scrActions)["editReplaceColors"]->setTexts( tr("Replace Colors..."));
(*scrActions)["editPatterns"]->setTexts( tr("Patterns..."));
+ (*scrActions)["editGradients"]->setTexts( tr("Gradients..."));
(*scrActions)["editStyles"]->setTexts( tr("S&tyles..."));
(*scrActions)["editMasterPages"]->setTexts( tr("&Master Pages..."));
(*scrActions)["editJavascripts"]->setTexts( tr("&JavaScripts..."));
@@ -1754,7 +1758,7 @@
itmenu->second << "fileDocSetup" << "filePreferences" << "filePreferences150" << "filePrint" << "PrintPreview" << "fileQuit";
++itmenu;
//Edit
- itmenu->second << "editUndoAction" << "editRedoAction" << "editActionMode" << "editCut" << "editCopy" << "editPaste" << "editCopyContents" << "editPasteContents" << "editPasteContentsAbs" << "editClearContents" << "editSelectAll" << "editSelectAllOnLayer" << "editDeselectAll" << "editSearchReplace" << "toolsEditWithStoryEditor" << "editEditWithImageEditor" << "editEditRenderSource" << "editExtendedImageProperties" << "editColors" << "editReplaceColors" << "editPatterns" << "editStyles" << "editMasterPages" << "editJavascripts";
+ itmenu->second << "editUndoAction" << "editRedoAction" << "editActionMode" << "editCut" << "editCopy" << "editPaste" << "editCopyContents" << "editPasteContents" << "editPasteContentsAbs" << "editClearContents" << "editSelectAll" << "editSelectAllOnLayer" << "editDeselectAll" << "editSearchReplace" << "toolsEditWithStoryEditor" << "editEditWithImageEditor" << "editEditRenderSource" << "editExtendedImageProperties" << "editColors" << "editReplaceColors" << "editPatterns" << "editGradients" << "editStyles" << "editMasterPages" << "editJavascripts";
//Style
++itmenu;
int font_sizes[] = {7, 9, 10, 11, 12, 14, 18, 24, 36, 48, 60, 72};
Index: scribus/ui/gradientaddedit.cpp
===================================================================
--- scribus/ui/gradientaddedit.cpp (revision 0)
+++ scribus/ui/gradientaddedit.cpp (revision 14150)
@@ -0,0 +1,77 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+/**************************************************************************
+* Copyright (C) 2009 by Franz Schmid *
+* franz.schmid at altmuehlnet.de *
+* *
+* 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., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#include "gradientaddedit.h"
+#include <QMessageBox>
+
+gradientEditDialog::gradientEditDialog(QWidget* parent, QString name, VGradient gradient, ColorList doco, ScribusDoc *doc, QMap<QString, VGradient> *gradients, bool newFlag) : QDialog(parent)
+{
+ setupUi(this);
+ setModal(true);
+ editor->setColors(doco);
+ editor->setGradient(gradient);
+ gradientName->setText(name);
+ m_doc = doc;
+ m_name = name;
+ m_gradients = gradients;
+ isNew = newFlag;
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(quitDialog()));
+}
+
+QString gradientEditDialog::name()
+{
+ return gradientName->text();
+}
+
+VGradient gradientEditDialog::gradient()
+{
+ return editor->gradient();
+}
+
+void gradientEditDialog::quitDialog()
+{
+ if (gradientName->text().isEmpty())
+ {
+ QMessageBox::information(this, CommonStrings::trWarning, tr("You cannot create a gradient without a name\nPlease give it a name"), 0);
+ gradientName->setFocus();
+ gradientName->selectAll();
+ return;
+ }
+ if ((m_name != gradientName->text()) || (isNew))
+ {
+ if (m_gradients->contains(gradientName->text()))
+ {
+ QMessageBox::information(this, CommonStrings::trWarning, tr("The name of the gradient already exists,\nplease choose another one."), CommonStrings::tr_OK, 0, 0, 0, QMessageBox::Ok);
+ gradientName->selectAll();
+ gradientName->setFocus();
+ return;
+ }
+ else
+ accept();
+ }
+ else
+ accept();
+}
Index: scribus/ui/gradienteditor.cpp
===================================================================
--- scribus/ui/gradienteditor.cpp (revision 14149)
+++ scribus/ui/gradienteditor.cpp (revision 14150)
@@ -94,6 +94,15 @@
connect(stopShade, SIGNAL(valueChanged(int)), this, SLOT(setStopShade(int)));
}
+void GradientEditor::setGradientEditable(bool val)
+{
+ stopShade->setEnabled(val);
+ stopOpacity->setEnabled(val);
+ stopColor->setEnabled(val);
+ Position->setEnabled(val);
+ Preview->setGradientEditable(val);
+}
+
void GradientEditor::changePos(int v)
{
Preview->setActStep(static_cast<double>(v) / 100.0);
Index: scribus/ui/gradientaddedit.ui
===================================================================
--- scribus/ui/gradientaddedit.ui (revision 0)
+++ scribus/ui/gradientaddedit.ui (revision 14150)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>gradientAddEditDialog</class>
+ <widget class="QDialog" name="gradientAddEditDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>302</width>
+ <height>279</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>210</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Edit Gradient</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="gradientName"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="GradientEditor" name="editor">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>210</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ </widget>
+ </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>
+ <customwidgets>
+ <customwidget>
+ <class>GradientEditor</class>
+ <extends>QFrame</extends>
+ <header>ui/gradienteditor.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>gradientAddEditDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>292</x>
+ <y>269</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>199</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Index: scribus/ui/cpalette.cpp
===================================================================
--- scribus/ui/cpalette.cpp (revision 14149)
+++ scribus/ui/cpalette.cpp (revision 14150)
@@ -55,7 +55,9 @@
#include "commonstrings.h"
#include "linkbutton.h"
#include "sccolorengine.h"
+#include "scpainter.h"
#include "scpattern.h"
+#include "util.h"
GradientVectorDialog::GradientVectorDialog(QWidget* parent) : ScrPaletteBase( parent, "GradientVectorPalette", false, 0 )
{
@@ -315,6 +317,7 @@
connect(gradientType, SIGNAL(activated(int)), this, SLOT(slotGradType(int)));
connect(gradEdit, SIGNAL(gradientChanged()), this, SIGNAL(gradientChanged()));
connect(editPatternProps, SIGNAL(clicked()), this, SLOT(changePatternProps()));
+ connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
editFillColorSelector->setChecked(true);
editFillColorSelectorButton();
}
@@ -353,10 +356,22 @@
setActFarben(currentItem->lineColor(), currentItem->fillColor(), currentItem->lineShade(), currentItem->fillShade());
ChooseGrad(currentItem->GrType);
gradEdit->setGradient(currentItem->fill_gradient);
+ disconnect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
+ if (!currentItem->gradient().isEmpty())
+ {
+ setCurrentComboItem(namedGradient, currentItem->gradient());
+ gradEdit->setGradientEditable(false);
+ }
+ else
+ {
+ namedGradient->setCurrentIndex(0);
+ gradEdit->setGradientEditable(true);
+ }
if (patternList->count() == 0)
tabWidget->setTabEnabled(2, false);
else
tabWidget->setTabEnabled(2, true);
+ connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
}
void Cpalette::updateCList()
@@ -505,6 +520,58 @@
updateFromItem();
}
+void Cpalette::updateGradientList()
+{
+ disconnect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
+ namedGradient->clear();
+ namedGradient->setIconSize(QSize(48, 12));
+ namedGradient->addItem( tr("Custom"));
+ for (QMap<QString, VGradient>::Iterator it = gradientList->begin(); it != gradientList->end(); ++it)
+ {
+ QImage pixm(48, 12, QImage::Format_ARGB32);
+ QPainter pb;
+ QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
+ pb.begin(&pixm);
+ pb.fillRect(0, 0, 48, 12, b);
+ pb.end();
+ ScPainter *p = new ScPainter(&pixm, 48, 12);
+ p->setPen(Qt::black);
+ p->setLineWidth(1);
+ p->setFillMode(2);
+ p->fill_gradient = it.value();
+ p->setGradient(VGradient::linear, FPoint(0,6), FPoint(48, 6));
+ p->drawRect(0, 0, 48, 12);
+ p->end();
+ delete p;
+ QPixmap pm;
+ pm = QPixmap::fromImage(pixm);
+ namedGradient->addItem(pm, it.key());
+ }
+ connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
+}
+
+void Cpalette::SetGradients(QMap<QString, VGradient> *docGradients)
+{
+ gradientList = docGradients;
+ updateGradientList();
+}
+
+void Cpalette::setNamedGradient(const QString &name)
+{
+ if (namedGradient->currentIndex() == 0)
+ {
+ gradEdit->setGradient(currentItem->fill_gradient);
+ currentItem->setGradient("");
+ gradEdit->setGradientEditable(true);
+ }
+ else
+ {
+ gradEdit->setGradient(gradientList->value(name));
+ gradEdit->setGradientEditable(false);
+ currentItem->setGradient(name);
+ }
+}
+
void Cpalette::updatePatternList()
{
disconnect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
Index: scribus/ui/gradientpreview.h
===================================================================
--- scribus/ui/gradientpreview.h (revision 14149)
+++ scribus/ui/gradientpreview.h (revision 14150)
@@ -53,11 +53,13 @@
void setActColor(QColor c, QString n, int s);
void setActTrans(double t);
void setActStep(double t);
+ void setGradientEditable(bool val);
VGradient fill_gradient;
QList<int> StopM;
bool Mpressed;
bool outside;
bool onlyselect;
+ bool isEditable;
int ActStop;
int contextStop;
QPoint mPos;
Index: scribus/ui/colorpalette.ui
===================================================================
--- scribus/ui/colorpalette.ui (revision 14149)
+++ scribus/ui/colorpalette.ui (revision 14150)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>250</width>
- <height>397</height>
+ <height>418</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
- <number>5</number>
+ <number>2</number>
</property>
<property name="margin">
<number>5</number>
@@ -223,6 +223,12 @@
</widget>
<widget class="QWidget" name="pageFill">
<layout class="QGridLayout" name="gridLayout_2">
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
<item row="0" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
@@ -270,6 +276,12 @@
<string>Gradient</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
@@ -293,6 +305,12 @@
</item>
<item row="1" column="0" colspan="2">
<widget class="GradientEditor" name="gradEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>200</width>
@@ -308,6 +326,9 @@
</widget>
</item>
<item row="2" column="0" colspan="2">
+ <widget class="ScComboBox" name="namedGradient"/>
+ </item>
+ <item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="gradEditButton">
Index: scribus/ui/cpalette.h
===================================================================
--- scribus/ui/cpalette.h (revision 14149)
+++ scribus/ui/cpalette.h (revision 14150)
@@ -144,8 +144,11 @@
void updateCList();
void ToggleColorDisplay();
void SetPatterns(QMap<QString, ScPattern> *docPatterns);
+ void SetGradients(QMap<QString, VGradient> *docGradients);
+ void setNamedGradient(const QString &name);
void selectPattern(QListWidgetItem *c);
void updatePatternList();
+ void updateGradientList();
void setActPattern(QString pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
void setActFarben(QString p, QString b, int shp, int shb);
void selectColorS(QListWidgetItem *c);
@@ -182,6 +185,7 @@
QString sFarbe;
ColorList colorList;
QMap<QString, ScPattern> *patternList;
+ QMap<QString, VGradient> *gradientList;
double m_Pattern_scaleX;
double m_Pattern_scaleY;
double m_Pattern_offsetX;
Index: scribus/ui/gradientmanager.cpp
===================================================================
--- scribus/ui/gradientmanager.cpp (revision 0)
+++ scribus/ui/gradientmanager.cpp (revision 14150)
@@ -0,0 +1,500 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+/**************************************************************************
+* Copyright (C) 2009 by Franz Schmid *
+* franz.schmid at altmuehlnet.de *
+* *
+* 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., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#include "gradientaddedit.h"
+#include "gradientmanager.h"
+#include "scpainter.h"
+#include "fpoint.h"
+#include "util_icon.h"
+#include <QPixmap>
+#include <QImage>
+#include <QPainter>
+
+gradientManagerDialog::gradientManagerDialog(QWidget* parent, QMap<QString, VGradient> *docGradients, ColorList doco, ScribusDoc *doc, ScribusMainWindow *scMW) : QDialog(parent)
+{
+ setupUi(this);
+ setModal(true);
+ m_doc = doc;
+ m_colorList = doco;
+ mainWin = scMW;
+ gradientsList->clear();
+ for (QMap<QString, VGradient>::Iterator it = docGradients->begin(); it != docGradients->end(); ++it)
+ {
+ dialogGradients.insert(it.key(), it.value());
+ origNames.insert(it.key(), it.key());
+ }
+ origGradients = docGradients->keys();
+ updateGradientList();
+ replaceMap.clear();
+ buttonRemove->setEnabled(false);
+ buttonEdit->setEnabled(false);
+ connect(buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(buttonAdd, SIGNAL(clicked()), this, SLOT(addGradient()));
+ connect(buttonRemove, SIGNAL(clicked()), this, SLOT(removeGradient()));
+ connect(buttonEdit, SIGNAL(clicked()), this, SLOT(editGradient()));
+ connect(gradientsList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(gradientSelected(QListWidgetItem*)));
+}
+
+void gradientManagerDialog::updateGradientList()
+{
+ gradientsList->clear();
+ for (QMap<QString, VGradient>::Iterator it = dialogGradients.begin(); it != dialogGradients.end(); ++it)
+ {
+ QImage pixm(48, 12, QImage::Format_ARGB32);
+ QPainter pb;
+ QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
+ pb.begin(&pixm);
+ pb.fillRect(0, 0, 48, 12, b);
+ pb.end();
+ ScPainter *p = new ScPainter(&pixm, 48, 12);
+ p->setPen(Qt::black);
+ p->setLineWidth(1);
+ p->setFillMode(2);
+ p->fill_gradient = it.value();
+ p->setGradient(VGradient::linear, FPoint(0,6), FPoint(48, 6));
+ p->drawRect(0, 0, 48, 12);
+ p->end();
+ delete p;
+ QPixmap pm;
+ pm = QPixmap::fromImage(pixm);
+ QListWidgetItem *item = new QListWidgetItem(pm, it.key(), gradientsList);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ }
+}
+
+void gradientManagerDialog::gradientSelected(QListWidgetItem* it)
+{
+ if (it)
+ {
+ buttonRemove->setEnabled(true);
+ buttonEdit->setEnabled(true);
+ }
+ else
+ {
+ buttonRemove->setEnabled(false);
+ buttonEdit->setEnabled(false);
+ gradientsList->clearSelection();
+ }
+}
+
+void gradientManagerDialog::addGradient()
+{
+ VGradient fill_gradient = VGradient(VGradient::linear);
+ fill_gradient.clearStops();
+ fill_gradient.addStop(QColor(Qt::black), 0.0, 0.5, 1.0, "Black", 100);
+ fill_gradient.addStop(QColor(Qt::white), 1.0, 0.5, 1.0, "White", 100);
+ gradientEditDialog *dia = new gradientEditDialog(this, tr("New Gradient"), fill_gradient, m_colorList, m_doc, &dialogGradients, true);
+ if (dia->exec())
+ {
+ dialogGradients.insert(dia->name(), dia->gradient());
+ updateGradientList();
+ }
+ delete dia;
+}
+
+void gradientManagerDialog::editGradient()
+{
+ QListWidgetItem *it = gradientsList->currentItem();
+ if (it)
+ {
+ QString gradN = it->text();
+ QString patternName = origNames[it->text()];
+ QString newName = "";
+ gradientEditDialog *dia = new gradientEditDialog(this, gradN, dialogGradients[gradN], m_colorList, m_doc, &dialogGradients, false);
+ if (dia->exec())
+ {
+ newName = dia->name();
+ if (newName != gradN)
+ {
+ origNames.remove(patternName);
+ origNames.insert(newName, patternName);
+ replaceMap.insert(patternName, newName);
+ dialogGradients.remove(gradN);
+ dialogGradients.insert(newName, dia->gradient());
+ }
+ else
+ dialogGradients[gradN] = dia->gradient();
+ updateGradientList();
+ }
+ delete dia;
+ }
+}
+
+void gradientManagerDialog::removeGradient()
+{
+ QListWidgetItem *it = gradientsList->currentItem();
+ if (it)
+ {
+ dialogGradients.remove(it->text());
+ replaceMap.insert(it->text(), "");
+ updateGradientList();
+ }
+}
+/*
+void PatternDialog::loadPatternDir()
+{
+ PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
+ QString wdir = dirs->get("patterndir", ".");
+ QString fileName = QFileDialog::getExistingDirectory(this, tr("Choose a Directory"), wdir);
+ if (!fileName.isEmpty())
+ {
+ QStringList formats;
+ formats += "eps";
+ formats += "epsi";
+ formats += "pdf";
+ QString form1 = "";
+ for ( int i = 0; i < QImageReader::supportedImageFormats().count(); ++i )
+ {
+ form1 = QString(QImageReader::supportedImageFormats().at(i)).toLower();
+ if (form1 == "jpeg")
+ form1 = "jpg";
+ if ((form1 == "png") || (form1 == "xpm") || (form1 == "gif"))
+ formats += form1;
+ else if (form1 == "jpg")
+ {
+ formats += "jpg";
+ formats += "jpeg";
+ }
+ }
+ formats += "tif";
+ formats += "tiff";
+ formats += "psd";
+ formats += "pat";
+ QDir d(fileName, "*", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ if ((d.exists()) && (d.count() != 0))
+ {
+ mainWin->setStatusBarInfoText( tr("Loading Patterns"));
+ mainWin->mainWindowProgressBar->reset();
+ mainWin->mainWindowProgressBar->setMaximum(d.count() * 2);
+ qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ for (uint dc = 0; dc < d.count(); ++dc)
+ {
+ mainWin->mainWindowProgressBar->setValue(dc);
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
+ QString ext = fi.suffix().toLower();
+ if ((ext == "sml") || (ext == "shape") || (ext == "sce") || (!formats.contains(ext)))
+ loadVectors(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
+ }
+ for (uint dc = 0; dc < d.count(); ++dc)
+ {
+ mainWin->mainWindowProgressBar->setValue(d.count() + dc);
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
+ QString ext = fi.suffix().toLower();
+ if ((ext == "sml") || (ext == "shape") || (ext == "sce") || (!formats.contains(ext)))
+ continue;
+ else if (formats.contains(ext))
+ {
+ QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
+ if (!dialogPatterns.contains(patNam))
+ {
+ ScPattern pat = ScPattern();
+ pat.setDoc(m_doc);
+ pat.setPattern(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
+ dialogPatterns.insert(patNam, pat);
+ origNames.insert(patNam, patNam);
+ }
+ }
+ else
+ continue;
+ }
+ d.cdUp();
+ dirs->set("patterndir", d.absolutePath());
+ qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ mainWin->setStatusBarInfoText("");
+ mainWin->mainWindowProgressBar->reset();
+ }
+ updatePatternList();
+ }
+}
+
+void PatternDialog::loadPattern()
+{
+ QString fileName;
+ QString formats = "";
+ QString allFormats = tr("All Supported Formats")+" (";
+ int fmtCode = FORMATID_ODGIMPORT;
+ const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode);
+ while (fmt != 0)
+ {
+ if (fmt->load)
+ {
+ formats += fmt->filter + ";;";
+ int an = fmt->filter.indexOf("(");
+ int en = fmt->filter.indexOf(")");
+ while (an != -1)
+ {
+ allFormats += fmt->filter.mid(an+1, en-an-1)+" ";
+ an = fmt->filter.indexOf("(", en);
+ en = fmt->filter.indexOf(")", an);
+ }
+ }
+ fmtCode++;
+ fmt = LoadSavePlugin::getFormatById(fmtCode);
+ }
+ allFormats += "*.sce *.SCE ";
+ allFormats += "*.shape *.SHAPE ";
+ allFormats += "*.sml *.SML ";
+ formats += "Scribus Objects (*.sce *.SCE);;";
+ formats += "Dia Shapes (*.shape *.SHAPE);;";
+ formats += "Kivio Stencils (*.sml *.SML);;";
+ QString form1 = "";
+ QString form2 = "";
+ QStringList imgFormats;
+ bool jpgFound = false;
+ bool tiffFound = false;
+ for (int i = 0; i < QImageReader::supportedImageFormats().count(); ++i )
+ {
+ form1 = QString(QImageReader::supportedImageFormats().at(i)).toLower();
+ form2 = QString(QImageReader::supportedImageFormats().at(i)).toUpper();
+ if ((form1 == "png") || (form1 == "xpm") || (form1 == "gif"))
+ {
+ formats += form2 + " (*."+form1+" *."+form2+");;";
+ allFormats += "*."+form1+" *."+form2+" ";
+ imgFormats.append(form1);
+ }
+ else if ((form1 == "jpg") || (form1 == "jpeg"))
+ {
+ // JPEG is a special case because both .jpg and .jpeg
+ // are acceptable extensions.
+ if (!jpgFound)
+ {
+ formats += "JPEG (*.jpg *.jpeg *.JPG *.JPEG);;";
+ allFormats += "*.jpg *.jpeg *.JPG *.JPEG ";
+ imgFormats.append("jpeg");
+ imgFormats.append("jpg");
+ jpgFound = true;
+ }
+ }
+ else if ((form1 == "tif") || (form1 == "tiff"))
+ {
+ if (!tiffFound)
+ {
+ formats += "TIFF (*.tif *.tiff *.TIF *.TIFF);;";
+ allFormats += "*.tif *.tiff *.TIF *.TIFF ";
+ imgFormats.append("tif");
+ imgFormats.append("tiff");
+ tiffFound = true;
+ }
+ }
+ else if (form1 != "svg")
+ {
+ imgFormats.append(form1);
+ allFormats += "*."+form1+" *."+form2+" ";
+ }
+ }
+ if (!tiffFound)
+ {
+ formats += "TIFF (*.tif *.tiff *.TIF *.TIFF);;";
+ allFormats += "*.tif *.tiff *.TIF *.TIFF ";
+ }
+ if (!jpgFound)
+ {
+ formats += "JPEG (*.jpg *.jpeg *.JPG *.JPEG);;";
+ allFormats += "*.jpg *.jpeg *.JPG *.JPEG ";
+ }
+ formats += "PSD (*.psd *.PSD);;";
+ formats += "Gimp Patterns (*.pat *.PAT);;";
+ formats += tr("All Files (*)");
+ allFormats += "*.psd *.PSD ";
+ allFormats += "*.pat *.PAT);;";
+ imgFormats.append("tif");
+ imgFormats.append("tiff");
+ imgFormats.append("pat");
+ imgFormats.append("psd");
+ imgFormats.append("pdf");
+ imgFormats.append("eps");
+ imgFormats.append("epsi");
+ imgFormats.append("ps");
+ allFormats += formats;
+ PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
+ QString wdir = dirs->get("patterns", ".");
+ CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdHidePreviewCheckBox | fdExistingFiles);
+ if (dia.exec() == QDialog::Accepted)
+ fileName = dia.selectedFile();
+ else
+ return;
+ if (!fileName.isEmpty())
+ {
+ PrefsManager::instance()->prefsFile->getContext("dirs")->set("patterns", fileName.left(fileName.lastIndexOf("/")));
+ QFileInfo fi(fileName);
+ if ((fi.suffix().toLower() == "sml") || (fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sce") || (!imgFormats.contains(fi.suffix().toLower())))
+ {
+ loadVectors(fileName);
+ updatePatternList();
+ }
+ else
+ {
+ QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
+ ScPattern pat = ScPattern();
+ pat.setDoc(m_doc);
+ pat.setPattern(fileName);
+ if (!dialogPatterns.contains(patNam))
+ {
+ dialogPatterns.insert(patNam, pat);
+ origNames.insert(patNam, patNam);
+ updatePatternList();
+ }
+ }
+ }
+}
+
+void PatternDialog::loadVectors(QString data)
+{
+ bool wasUndo = UndoManager::undoEnabled();
+ UndoManager::instance()->setUndoEnabled(false);
+ m_doc->setLoading(true);
+ QFileInfo fi(data);
+ QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
+ if (fi.suffix().toLower() == "sml")
+ {
+ QString f = "";
+ loadText(data, &f);
+ StencilReader *pre = new StencilReader();
+ data = pre->createObjects(f);
+ delete pre;
+ }
+ else if (fi.suffix().toLower() == "shape")
+ {
+ QString f = "";
+ loadText(data, &f);
+ StencilReader *pre = new StencilReader();
+ data = pre->createShape(f);
+ delete pre;
+ }
+ uint ac = m_doc->Items->count();
+ bool savedAlignGrid = m_doc->useRaster;
+ bool savedAlignGuides = m_doc->SnapGuides;
+ m_doc->useRaster = false;
+ m_doc->SnapGuides = false;
+ if (fi.suffix().toLower() == "sce")
+ mainWin->slotElemRead(data, m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset(), true, true, m_doc, m_doc->view());
+ else if ((fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sml"))
+ mainWin->slotElemRead(data, m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset(), false, true, m_doc, m_doc->view());
+ else
+ {
+ FileLoader *fileLoader = new FileLoader(data);
+ int testResult = fileLoader->TestFile();
+ delete fileLoader;
+ if ((testResult != -1) && (testResult >= FORMATID_ODGIMPORT))
+ {
+ const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+ if( fmt )
+ fmt->loadFile(data, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
+ }
+ }
+ m_doc->useRaster = savedAlignGrid;
+ m_doc->SnapGuides = savedAlignGuides;
+ uint ae = m_doc->Items->count();
+ if (ac != ae)
+ {
+ for (uint as = ac; as < ae; ++as)
+ {
+ PageItem* ite = m_doc->Items->at(ac);
+ if (ite->itemType() == PageItem::PathText)
+ {
+ ite->Frame = true;
+ ite->updatePolyClip();
+ }
+ else
+ {
+ ite->layout();
+ }
+ }
+ ScPattern pat = ScPattern();
+ pat.setDoc(m_doc);
+ PageItem* currItem = m_doc->Items->at(ac);
+ pat.pattern = currItem->DrawObj_toImage();
+ pat.width = currItem->gWidth;
+ pat.height = currItem->gHeight;
+ for (uint as = ac; as < ae; ++as)
+ {
+ pat.items.append(m_doc->Items->takeAt(ac));
+ }
+ if (!dialogPatterns.contains(patNam))
+ {
+ dialogPatterns.insert(patNam, pat);
+ origNames.insert(patNam, patNam);
+ }
+ for (QMap<QString, ScPattern>::Iterator it = m_doc->docPatterns.begin(); it != m_doc->docPatterns.end(); ++it)
+ {
+ if (!origPatterns.contains(it.key()))
+ {
+ dialogPatterns.insert(it.key(), it.value());
+ origNames.insert(it.key(), it.key());
+ }
+ }
+ }
+ m_doc->setLoading(false);
+ m_doc->view()->Deselect(false);
+ UndoManager::instance()->setUndoEnabled(wasUndo);
+ m_doc->view()->DrawNew();
+}
+
+void PatternDialog::patternSelected(QListWidgetItem* it)
+{
+ if (it)
+ {
+ buttonRemove->setEnabled(true);
+ buttonRename->setEnabled(true);
+ }
+ else
+ {
+ buttonRemove->setEnabled(false);
+ buttonRename->setEnabled(false);
+ patternView->clearSelection();
+ }
+}
+
+void PatternDialog::removeAllPatterns()
+{
+ dialogPatterns.clear();
+ updatePatternList();
+}
+
+QStringList PatternDialog::getUsedPatternsHelper(QString pattern, QStringList &results)
+{
+ ScPattern *pat = &dialogPatterns[pattern];
+ QStringList pats;
+ pats.clear();
+ for (int c = 0; c < pat->items.count(); ++c)
+ {
+ if ((!results.contains(pat->items.at(c)->pattern())) && (pat->items.at(c)->GrType == 8))
+ pats.append(pat->items.at(c)->pattern());
+ }
+ if (!pats.isEmpty())
+ {
+ for (int c = 0; c < pats.count(); ++c)
+ {
+ getUsedPatternsHelper(pats[c], results);
+ }
+ }
+ return pats;
+}
+*/
\ No newline at end of file
Index: scribus/ui/gradienteditor.ui
===================================================================
--- scribus/ui/gradienteditor.ui (revision 14149)
+++ scribus/ui/gradienteditor.ui (revision 14150)
@@ -6,25 +6,25 @@
<rect>
<x>0</x>
<y>0</y>
- <width>212</width>
- <height>186</height>
+ <width>210</width>
+ <height>172</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
- <enum>QFrame::Panel</enum>
+ <enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
- <number>5</number>
+ <number>4</number>
</property>
<property name="spacing">
- <number>5</number>
+ <number>2</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="GradientPreview" name="Preview">
Index: scribus/ui/gradientpreview.cpp
===================================================================
--- scribus/ui/gradientpreview.cpp (revision 14149)
+++ scribus/ui/gradientpreview.cpp (revision 14150)
@@ -51,6 +51,7 @@
Mpressed = false;
outside = true;
onlyselect = true;
+ isEditable = true;
fill_gradient = VGradient(VGradient::linear);
fill_gradient.clearStops();
@@ -98,17 +99,20 @@
QPainter pw;
pw.begin(this);
pw.drawImage(10, 5, pixm);
- for (uint a = 0; a < fill_gradient.Stops(); ++a)
+ if (isEditable)
{
- int center = qRound(cstops.at(a)->rampPoint * (width()-20))+10;
- pw.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
- if (StopM[qMax(ActStop,0)] == center)
- pw.setBrush(Qt::red);
- else
- pw.setBrush(Qt::blue);
- QPolygon cr;
- cr.setPoints(3, qRound(center), 43, qRound(center-4), 56, qRound(center+4), 56);
- pw.drawPolygon(cr);
+ for (uint a = 0; a < fill_gradient.Stops(); ++a)
+ {
+ int center = qRound(cstops.at(a)->rampPoint * (width()-20))+10;
+ pw.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ if (StopM[qMax(ActStop,0)] == center)
+ pw.setBrush(Qt::red);
+ else
+ pw.setBrush(Qt::blue);
+ QPolygon cr;
+ cr.setPoints(3, qRound(center), 43, qRound(center-4), 56, qRound(center+4), 56);
+ pw.drawPolygon(cr);
+ }
}
pw.end();
QFrame::paintEvent(e);
@@ -119,89 +123,95 @@
QRect fpo;
Mpressed = true;
ActStop = -1;
- QList<VColorStop*> cstops = fill_gradient.colorStops();
- for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
+ if (isEditable)
{
- fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
- if (fpo.contains(m->pos()))
+ QList<VColorStop*> cstops = fill_gradient.colorStops();
+ for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
{
- ActStop = yg;
- emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
- emit currTrans(cstops.at(ActStop)->opacity);
- emit currStep(cstops.at(ActStop)->rampPoint);
- repaint();
- onlyselect = true;
- return;
+ fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
+ if (fpo.contains(m->pos()))
+ {
+ ActStop = yg;
+ emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
+ emit currTrans(cstops.at(ActStop)->opacity);
+ emit currStep(cstops.at(ActStop)->rampPoint);
+ repaint();
+ onlyselect = true;
+ return;
+ }
}
}
}
void GradientPreview::mouseReleaseEvent(QMouseEvent *m)
{
- QRect fpo;
- if (m->button() == Qt::LeftButton)
+ if (isEditable)
{
- if ((Mpressed) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)) && (outside || m->y() > 60))
+ QRect fpo;
+ if (m->button() == Qt::LeftButton)
{
- onlyselect = false;
- fill_gradient.removeStop(ActStop);
- ActStop = 0;
- repaint();
- QList<VColorStop*> cstops = fill_gradient.colorStops();
- emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
- emit currTrans(cstops.at(ActStop)->opacity);
- emit currStep(cstops.at(ActStop)->rampPoint);
+ if ((Mpressed) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)) && (outside || m->y() > 60))
+ {
+ onlyselect = false;
+ fill_gradient.removeStop(ActStop);
+ ActStop = 0;
+ repaint();
+ QList<VColorStop*> cstops = fill_gradient.colorStops();
+ emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
+ emit currTrans(cstops.at(ActStop)->opacity);
+ emit currStep(cstops.at(ActStop)->rampPoint);
+ }
+ if ((m->y() < height()) && (m->y() > 43) && (m->x() > 0) && (m->x() < width()) && (ActStop == -1))
+ {
+ QList<VColorStop*> cstops = fill_gradient.colorStops();
+ double newStop = static_cast<double>((m->x() - 10)) / (static_cast<double>(width())-20);
+ QColor stopColor = (cstops.count() > 0) ? cstops.at(0)->color : QColor(255, 255, 255);
+ QString stopName = (cstops.count() > 0) ? cstops.at(0)->name : QString("White");
+ int stopShade = (cstops.count() > 0) ? cstops.at(0)->shade : 100;
+ fill_gradient.addStop(stopColor, newStop, 0.5, 1.0, stopName, stopShade);
+ repaint();
+ onlyselect = false;
+ cstops = fill_gradient.colorStops();
+ for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
+ {
+ fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
+ if (fpo.contains(m->pos()))
+ {
+ ActStop = yg;
+ emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
+ emit currTrans(cstops.at(ActStop)->opacity);
+ emit currStep(cstops.at(ActStop)->rampPoint);
+ repaint();
+ break;
+ }
+ }
+ }
}
- if ((m->y() < height()) && (m->y() > 43) && (m->x() > 0) && (m->x() < width()) && (ActStop == -1))
+ else if (m->button() == Qt::RightButton)
{
+ Mpressed = false;
QList<VColorStop*> cstops = fill_gradient.colorStops();
- double newStop = static_cast<double>((m->x() - 10)) / (static_cast<double>(width())-20);
- QColor stopColor = (cstops.count() > 0) ? cstops.at(0)->color : QColor(255, 255, 255);
- QString stopName = (cstops.count() > 0) ? cstops.at(0)->name : QString("White");
- int stopShade = (cstops.count() > 0) ? cstops.at(0)->shade : 100;
- fill_gradient.addStop(stopColor, newStop, 0.5, 1.0, stopName, stopShade);
- repaint();
- onlyselect = false;
- cstops = fill_gradient.colorStops();
+ int stop = -1;
for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
{
fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
if (fpo.contains(m->pos()))
{
- ActStop = yg;
- emit selectedColor(cstops.at(ActStop)->name, cstops.at(ActStop)->shade);
- emit currTrans(cstops.at(ActStop)->opacity);
- emit currStep(cstops.at(ActStop)->rampPoint);
- repaint();
+ stop = yg;
break;
}
}
+ contextStop = stop;
+ mPos = m->pos();
+ QMenu *pmen = new QMenu();
+ qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ pmen->addAction( tr("Add Stop"), this, SLOT(addStop()));
+ if (stop != -1)
+ pmen->addAction( tr("Remove Stop"), this, SLOT(removeStop()));
+ pmen->exec(QCursor::pos());
+ delete pmen;
}
}
- else if (m->button() == Qt::RightButton)
- {
- Mpressed = false;
- QList<VColorStop*> cstops = fill_gradient.colorStops();
- int stop = -1;
- for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
- {
- fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
- if (fpo.contains(m->pos()))
- {
- stop = yg;
- break;
- }
- }
- contextStop = stop;
- mPos = m->pos();
- QMenu *pmen = new QMenu();
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
- pmen->addAction( tr("Add Stop"), this, SLOT(addStop()));
- if (stop != -1)
- pmen->addAction( tr("Remove Stop"), this, SLOT(removeStop()));
- pmen->exec(QCursor::pos());
- delete pmen;
- }
Mpressed = false;
if (!onlyselect)
emit gradientChanged();
@@ -209,57 +219,63 @@
void GradientPreview::mouseMoveEvent(QMouseEvent *m)
{
- QRect fpo;
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
- if ((!Mpressed) && (m->y() < height()) && (m->y() > 43) && (m->x() > 9) && (m->x() < width()-9))
+ if (isEditable)
{
- qApp->changeOverrideCursor(QCursor(loadIcon("AddPoint.png"), 1, 1));
- for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
+ QRect fpo;
+ qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ if ((!Mpressed) && (m->y() < height()) && (m->y() > 43) && (m->x() > 9) && (m->x() < width()-9))
{
- fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
- if (fpo.contains(m->pos()))
+ qApp->changeOverrideCursor(QCursor(loadIcon("AddPoint.png"), 1, 1));
+ for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg)
{
- qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
- return;
+ fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13);
+ if (fpo.contains(m->pos()))
+ {
+ qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
+ return;
+ }
}
}
- }
- if (m->buttons() & Qt::LeftButton)
- {
- if ((Mpressed) && (m->y() < height()) && (m->y() > 43) && (m->x() > 9) && (m->x() < width()-9) && (ActStop != -1))
+ if (m->buttons() & Qt::LeftButton)
{
- qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
- double newStop = static_cast<double>((m->x() - 10)) / (static_cast<double>(width())-20);
- if (ActStop > 1)
+ if ((Mpressed) && (m->y() < height()) && (m->y() > 43) && (m->x() > 9) && (m->x() < width()-9) && (ActStop != -1))
{
- if (StopM[ActStop-1]+2 >= m->x())
- return;
+ qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
+ double newStop = static_cast<double>((m->x() - 10)) / (static_cast<double>(width())-20);
+ if (ActStop > 1)
+ {
+ if (StopM[ActStop-1]+2 >= m->x())
+ return;
+ }
+ if (ActStop < static_cast<int>(StopM.count()-2))
+ {
+ if (StopM[ActStop+1]-2 < m->x())
+ return;
+ }
+ StopM[ActStop] = m->x();
+ QList<VColorStop*> cstops = fill_gradient.colorStops();
+ cstops.at(ActStop)->rampPoint = newStop;
+ emit currStep(cstops.at(ActStop)->rampPoint);
+ qSort(cstops.begin(), cstops.end());
+ onlyselect = false;
+ repaint();
}
- if (ActStop < static_cast<int>(StopM.count()-2))
- {
- if (StopM[ActStop+1]-2 < m->x())
- return;
- }
- StopM[ActStop] = m->x();
- QList<VColorStop*> cstops = fill_gradient.colorStops();
- cstops.at(ActStop)->rampPoint = newStop;
- emit currStep(cstops.at(ActStop)->rampPoint);
- qSort(cstops.begin(), cstops.end());
- onlyselect = false;
- repaint();
+ if ((Mpressed) && (outside || m->y() > 60) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)))
+ qApp->changeOverrideCursor(QCursor(loadIcon("DelPoint.png"), 1, 1));
}
- if ((Mpressed) && (outside || m->y() > 60) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)))
- qApp->changeOverrideCursor(QCursor(loadIcon("DelPoint.png"), 1, 1));
}
}
void GradientPreview::leaveEvent(QEvent*)
{
- if ((Mpressed) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)))
- qApp->changeOverrideCursor(QCursor(loadIcon("DelPoint.png"), 1, 1));
- else
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
- outside = true;
+ if (isEditable)
+ {
+ if ((Mpressed) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)))
+ qApp->changeOverrideCursor(QCursor(loadIcon("DelPoint.png"), 1, 1));
+ else
+ qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ outside = true;
+ }
}
void GradientPreview::enterEvent(QEvent*)
@@ -349,3 +365,9 @@
cstops.at(ActStop)->rampPoint = t;
repaint();
}
+
+void GradientPreview::setGradientEditable(bool val)
+{
+ isEditable = val;
+ repaint();
+}
Index: scribus/ui/propertiespalette.cpp
===================================================================
--- scribus/ui/propertiespalette.cpp (revision 14149)
+++ scribus/ui/propertiespalette.cpp (revision 14150)
@@ -4676,6 +4676,7 @@
return;
Cpal->SetColors(doc->PageColors);
Cpal->SetPatterns(&doc->docPatterns);
+ Cpal->SetGradients(&doc->docGradients);
assert (doc->PageColors.document());
TxFill->updateBox(doc->PageColors, ColorCombo::fancyPixmaps, true);
TxStroke->updateBox(doc->PageColors, ColorCombo::fancyPixmaps, false);
Index: scribus/ui/gradientmanager.ui
===================================================================
--- scribus/ui/gradientmanager.ui (revision 0)
+++ scribus/ui/gradientmanager.ui (revision 14150)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>gradientManager</class>
+ <widget class="QDialog" name="gradientManager">
+ <property name="windowModality">
+ <enum>Qt::ApplicationModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>301</width>
+ <height>306</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Manage Gradients</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QListWidget" name="gradientsList">
+ <property name="iconSize">
+ <size>
+ <width>48</width>
+ <height>12</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="buttonAdd">
+ <property name="text">
+ <string>Add ...</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonEdit">
+ <property name="text">
+ <string>Edit ...</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonRemove">
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOK">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Index: scribus/ui/gradientmanager.h
===================================================================
--- scribus/ui/gradientmanager.h (revision 0)
+++ scribus/ui/gradientmanager.h (revision 14150)
@@ -0,0 +1,62 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+/***************************************************************************
+* Copyright (C) 2009 by Franz Schmid *
+* franz.schmid at altmuehlnet.de *
+* *
+* 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., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#ifndef GRADIENTMDIALOG_H
+#define GRADIENTMDIALOG_H
+
+#include <QMap>
+#include <QString>
+#include <QDialog>
+#include <QListWidgetItem>
+#include "ui_gradientmanager.h"
+#include "scribusapi.h"
+#include "scribusdoc.h"
+#include "scribus.h"
+#include "vgradient.h"
+
+class SCRIBUS_API gradientManagerDialog : public QDialog, Ui::gradientManager
+{
+ Q_OBJECT
+
+ public:
+ gradientManagerDialog(QWidget* parent, QMap<QString, VGradient> *docGradients, ColorList doco, ScribusDoc *doc, ScribusMainWindow* scMW);
+ ~gradientManagerDialog() {};
+ void updateGradientList();
+ ScribusDoc *m_doc;
+ ScribusMainWindow *mainWin;
+ QMap<QString, VGradient> dialogGradients;
+ QMap<QString,QString> replaceMap;
+ QMap<QString,QString> origNames;
+ QStringList origGradients;
+ ColorList m_colorList;
+ public slots:
+ void gradientSelected(QListWidgetItem* it);
+ void addGradient();
+ void editGradient();
+ void removeGradient();
+};
+
+#endif
Index: scribus/ui/gradientaddedit.h
===================================================================
--- scribus/ui/gradientaddedit.h (revision 0)
+++ scribus/ui/gradientaddedit.h (revision 14150)
@@ -0,0 +1,54 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+/***************************************************************************
+* Copyright (C) 2009 by Franz Schmid *
+* franz.schmid at altmuehlnet.de *
+* *
+* 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., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#ifndef GRADIENTEADIALOG_H
+#define GRADIENTEADIALOG_H
+
+#include <QDialog>
+#include "ui_gradientaddedit.h"
+#include "scribusapi.h"
+#include "scribusdoc.h"
+#include "vgradient.h"
+
+class SCRIBUS_API gradientEditDialog : public QDialog, Ui::gradientAddEditDialog
+{
+ Q_OBJECT
+
+ public:
+ gradientEditDialog(QWidget* parent, QString name, VGradient gradient, ColorList doco, ScribusDoc *doc, QMap<QString, VGradient> *gradients, bool newFlag);
+ ~gradientEditDialog() {};
+ QString name();
+ VGradient gradient();
+ private slots:
+ void quitDialog();
+ protected:
+ ScribusDoc* m_doc;
+ bool isNew;
+ QString m_name;
+ QMap<QString, VGradient> *m_gradients;
+};
+
+#endif
Index: scribus/ui/gradienteditor.h
===================================================================
--- scribus/ui/gradienteditor.h (revision 14149)
+++ scribus/ui/gradienteditor.h (revision 14150)
@@ -49,6 +49,7 @@
const VGradient gradient();
void setColors(ColorList &colorList);
QColor setColor(QString colorName, int shad);
+ void setGradientEditable(bool val);
virtual void changeEvent(QEvent *e);
public slots:
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp (revision 14149)
+++ scribus/scribus.cpp (revision 14150)
@@ -111,6 +111,7 @@
#include "fpoint.h"
#include "fpointarray.h"
#include "gtgettext.h"
+#include "ui/gradientmanager.h"
#include "ui/guidemanager.h"
#include "ui/helpbrowser.h"
#include "ui/hruler.h"
@@ -683,6 +684,7 @@
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editReplaceColors"], "Edit");
+ scrMenuMgr->addMenuItem(scrActions["editGradients"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editPatterns"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editStyles"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit");
@@ -705,6 +707,7 @@
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["editReplaceColors"]->setEnabled(false);
scrActions["editPatterns"]->setEnabled(false);
+// scrActions["editGradients"]->setEnabled(false);
scrActions["editStyles"]->setEnabled(false);
scrActions["editMasterPages"]->setEnabled(false);
scrActions["editJavascripts"]->setEnabled(false);
@@ -2746,6 +2749,7 @@
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editReplaceColors"]->setEnabled(true);
scrActions["editPatterns"]->setEnabled(true);
+// scrActions["editGradients"]->setEnabled(true);
scrActions["editStyles"]->setEnabled(true);
scrActions["editMasterPages"]->setEnabled(true);
scrActions["editJavascripts"]->setEnabled(true);
@@ -4671,6 +4675,7 @@
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editReplaceColors"]->setEnabled(false);
scrActions["editPatterns"]->setEnabled(false);
+// scrActions["editGradients"]->setEnabled(false);
scrActions["editStyles"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["editMasterPages"]->setEnabled(false);
@@ -9681,6 +9686,38 @@
}
}
+void ScribusMainWindow::manageGradients()
+{
+ if (HaveDoc)
+ {
+ undoManager->setUndoEnabled(false);
+ gradientManagerDialog *dia = new gradientManagerDialog(this, &doc->docGradients, doc->PageColors, doc, this);
+ if (dia->exec())
+ {
+ doc->setGradients(dia->dialogGradients);
+ if (!dia->replaceMap.isEmpty())
+ {
+ ResourceCollection gradrsc;
+ gradrsc.mapPatterns(dia->replaceMap);
+ doc->replaceNamedResources(gradrsc);
+ }
+ propertiesPalette->updateColorList();
+ view->DrawNew();
+ }
+ delete dia;
+ undoManager->setUndoEnabled(true);
+ }
+ else
+ {
+ gradientManagerDialog *dia = new gradientManagerDialog(this, &prefsManager->appPrefs.defaultGradients, prefsManager->colorSet(), NULL, this);
+ if (dia->exec())
+ {
+ prefsManager->appPrefs.defaultGradients = dia->dialogGradients;
+ }
+ delete dia;
+ }
+}
+
void ScribusMainWindow::enableTextActions(QMap<QString, QPointer<ScrAction> > *actionMap, bool enabled, const QString& fontName)
{
actionManager->enableUnicodeActions(actionMap, enabled, fontName);
Index: scribus/plugins/fileloader/scribus150format/scribus150format.h
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.h (revision 14149)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.h (revision 14150)
@@ -91,6 +91,7 @@
bool readBookMark(ScribusDoc::BookMa& bookmark, int& elem, ScXmlStreamAttributes& attrs);
bool readCheckProfile(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
bool readColor(ColorList& colors, ScXmlStreamAttributes& attrs);
+ bool readGradient(ScribusDoc *doc, VGradient &gra, ScXmlStreamReader& reader);
void readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
bool readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader);
bool readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader);
@@ -116,6 +117,7 @@
void writeJavascripts(ScXmlStreamWriter& docu);
void writeBookmarks(ScXmlStreamWriter& docu);
void writeColors(ScXmlStreamWriter& docu);
+ void writeGradients(ScXmlStreamWriter & docu);
void writeHyphenatorLists(ScXmlStreamWriter& docu);
void writePStyles(ScXmlStreamWriter& docu);
void writeCStyles(ScXmlStreamWriter& docu);
Index: scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (revision 14149)
+++ scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (revision 14150)
@@ -240,6 +240,7 @@
writeJavascripts(docu);
writeBookmarks(docu);
writeColors(docu);
+ writeGradients(docu);
writeHyphenatorLists(docu);
writePStyles(docu);
writeCStyles(docu);
@@ -400,6 +401,27 @@
}
+void Scribus150Format::writeGradients(ScXmlStreamWriter & docu)
+{
+ QMap<QString, VGradient>::Iterator itGrad;
+ for (itGrad = m_Doc->docGradients.begin(); itGrad != m_Doc->docGradients.end(); ++itGrad)
+ {
+ docu.writeStartElement("Gradient");
+ docu.writeAttribute("Name",itGrad.key());
+ VGradient gra = itGrad.value();
+ QList<VColorStop*> cstops = gra.colorStops();
+ for (uint cst = 0; cst < gra.Stops(); ++cst)
+ {
+ docu.writeEmptyElement("CSTOP");
+ docu.writeAttribute("RAMP", cstops.at(cst)->rampPoint);
+ docu.writeAttribute("NAME", cstops.at(cst)->name);
+ docu.writeAttribute("SHADE", cstops.at(cst)->shade);
+ docu.writeAttribute("TRANS", cstops.at(cst)->opacity);
+ }
+ docu.writeEndElement();
+ }
+}
+
void Scribus150Format::writeHyphenatorLists(ScXmlStreamWriter &docu)
{
docu.writeStartElement("HYPHEN");
@@ -1160,6 +1182,7 @@
docu.writeAttribute("GRSTARTY", item->GrStartY);
docu.writeAttribute("GRENDX", item->GrEndX);
docu.writeAttribute("GRENDY", item->GrEndY);
+ docu.writeAttribute("GRNAME", item->gradient());
}
}
if (item->itemText.defaultStyle().hasParent())
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp (revision 14149)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp (revision 14150)
@@ -295,6 +295,17 @@
success = readColor(m_Doc->PageColors, attrs);
if (!success) break;
}
+ if (tagName == "Gradient")
+ {
+ VGradient gra;
+ QString grName = attrs.valueAsString("Name");
+ success = readGradient(m_Doc, gra, reader);
+ if (!success) break;
+ if (!grName.isEmpty())
+ {
+ m_Doc->docGradients.insert(grName, gra);
+ }
+ }
if (tagName == "STYLE")
{
readParagraphStyle(m_Doc, reader, vg, *m_AvailableFonts);
@@ -1008,6 +1019,30 @@
return true;
}
+bool Scribus150Format::readGradient(ScribusDoc *doc, VGradient &gra, ScXmlStreamReader& reader)
+{
+ gra = VGradient(VGradient::linear);
+ gra.clearStops();
+ ScXmlStreamAttributes rattrs = reader.scAttributes();
+ QStringRef tagName = reader.name();
+ while(!reader.atEnd() && !reader.hasError())
+ {
+ ScXmlStreamReader::TokenType tType = reader.readNext();
+ if (tType == ScXmlStreamReader::EndElement && reader.name() == tagName)
+ break;
+ if (tType == ScXmlStreamReader::StartElement && reader.name() == "CSTOP")
+ {
+ ScXmlStreamAttributes attrs = reader.scAttributes();
+ QString name = attrs.valueAsString("NAME");
+ double ramp = attrs.valueAsDouble("RAMP", 0.0);
+ int shade = attrs.valueAsInt("SHADE", 100);
+ double opa = attrs.valueAsDouble("TRANS", 1.0);
+ gra.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade);
+ }
+ }
+ return !reader.hasError();
+}
+
void Scribus150Format::readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle)
{
static const QString CNAME("CNAME");
@@ -2725,6 +2760,10 @@
GrShade = attrs.valueAsInt("GRSHADE", 100);
GrShade2 = attrs.valueAsInt("GRSHADE2", 100);
}
+ QString GrName = "";
+ GrName = attrs.valueAsString("GRNAME","");
+ if (!GrName.isEmpty())
+ currItem->setGradient(GrName);
}
}
if ((currItem->GrType != 0) && (currItem->GrType != 8))
Index: scribus/scribus.h
===================================================================
--- scribus/scribus.h (revision 14149)
+++ scribus/scribus.h (revision 14150)
@@ -537,6 +537,8 @@
void slotInsertFrame();
//! \brief manages the documents patterns
void managePatterns();
+ //! \brief manages the documents gradients
+ void manageGradients();
//! \brief enable or disable the unicode actions and their menus
void enableTextActions(QMap<QString, QPointer<ScrAction> > *actionMap, bool enabled, const QString& fontName=QString::null);
//! \brief allow SE to get the SM for edit stlyes
Index: scribus/pageitem_desaxe.cpp
===================================================================
--- scribus/pageitem_desaxe.cpp (revision 14149)
+++ scribus/pageitem_desaxe.cpp (revision 14150)
@@ -272,13 +272,14 @@
}
else
{
- Xml_attr gradient;
- gradient.insert("GRTYPE", toXMLString(GrType));
- gradient.insert("GRSTARTX", toXMLString(GrStartX));
- gradient.insert("GRSTARTY", toXMLString(GrStartY));
- gradient.insert("GRENDX", toXMLString(GrEndX));
- gradient.insert("GRENDY", toXMLString(GrEndY));
- handler.begin("Gradient", gradient);
+ Xml_attr gradientV;
+ gradientV.insert("GRTYPE", toXMLString(GrType));
+ gradientV.insert("GRSTARTX", toXMLString(GrStartX));
+ gradientV.insert("GRSTARTY", toXMLString(GrStartY));
+ gradientV.insert("GRENDX", toXMLString(GrEndX));
+ gradientV.insert("GRENDY", toXMLString(GrEndY));
+ gradientV.insert("GRNAME", toXMLString(gradient()));
+ handler.begin("Gradient", gradientV);
QList<VColorStop*> cstops = fill_gradient.colorStops();
for (uint cst = 0; cst < const_cast<VGradient&>(fill_gradient).Stops(); ++cst) //FIXME make const
{
@@ -507,6 +508,7 @@
item->GrStartY = parseDouble(attr["GRSTARTY"]);
item->GrEndX = parseDouble(attr["GRENDX"]);
item->GrEndY = parseDouble(attr["GRENDY"]);
+ item->setGradient(attr["GRNAME"]);
item->fill_gradient.clearStops();
}
}
Index: scribus/CMakeLists.txt
===================================================================
--- scribus/CMakeLists.txt (revision 14149)
+++ scribus/CMakeLists.txt (revision 14150)
@@ -75,7 +75,9 @@
ui/colorpalette.ui
ui/docitemattrprefs.ui
ui/docsections.ui
+ ui/gradientaddedit.ui
ui/gradienteditor.ui
+ ui/gradientmanager.ui
ui/gtfiledialog.ui
ui/guidemanager.ui
ui/hysettingsBase.ui
@@ -208,7 +210,9 @@
ui/fontlistview.h
ui/fontprefs.h
ui/fontreplacedialog.h
+ ui/gradientaddedit.h
ui/gradienteditor.h
+ ui/gradientmanager.h
ui/gradientpreview.h
ui/gtdialogs.h
ui/gtfiledialog.h
@@ -490,7 +494,9 @@
fpoint.cpp
fpointarray.cpp
fpoptimizer.cpp
+ ui/gradientaddedit.cpp
ui/gradienteditor.cpp
+ ui/gradientmanager.cpp
ui/gradientpreview.cpp
gtaction.cpp
ui/gtdialogs.cpp
More information about the scribus-commit
mailing list