r15696 by fschmid - Palette Name do not need to be unique in the swatches file tree.
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 30 14:07:36 CEST 2010
Author: fschmid
Date: Sat Oct 30 12:07:36 2010
New Revision: 15696
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15696
Log:
Palette Name do not need to be unique in the swatches file tree.
Modified:
trunk/Scribus/scribus/colorsetmanager.cpp
trunk/Scribus/scribus/ui/cmykfw.cpp
trunk/Scribus/scribus/ui/cmykfw.h
trunk/Scribus/scribus/ui/paintmanager.cpp
trunk/Scribus/scribus/ui/paintmanager.h
trunk/Scribus/scribus/ui/swatchcombo.cpp
trunk/Scribus/scribus/ui/swatchcombo.h
Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Sat Oct 30 12:07:36 2010
@@ -18,6 +18,7 @@
#include <QDomElement>
#include <QTextStream>
#include <QByteArray>
+#include <QDebug>
ColorSetManager::ColorSetManager()
{
@@ -177,12 +178,13 @@
{
QString setName = fi.baseName();
setName.replace("_", " ");
- pList.insert(setName, fi.absoluteFilePath());
+ pList.insert(fi.absolutePath() + "/" + setName, fi.absoluteFilePath());
if (parent != 0)
{
QTreeWidgetItem* item = new QTreeWidgetItem(parent);
item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setText(0, setName);
+ item->setData(0, Qt::UserRole, fi.absolutePath());
if ((!fi.isWritable()) || (fi.absolutePath().contains(ScPaths::getApplicationDataDir()+"swatches/locked")))
item->setIcon(0, QIcon(loadIcon("16/lock.png")));
}
Modified: trunk/Scribus/scribus/ui/cmykfw.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/ui/cmykfw.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.cpp (original)
+++ trunk/Scribus/scribus/ui/cmykfw.cpp Sat Oct 30 12:07:36 2010
@@ -49,7 +49,7 @@
#include "util_icon.h"
-CMYKChoose::CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, QStringList Cust, bool newCol )
+CMYKChoose::CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, bool newCol )
: QDialog( parent ), CurrSwatch(doc)
{
setModal(true);
@@ -198,6 +198,7 @@
systemSwatches->setExpanded(true);
userSwatches = Swatches->addTopLevelItem( tr("User Swatches"));
csm.findUserPalettes(userSwatches);
+ customColSet = csm.userPaletteNames();
userSwatches->setExpanded(true);
Swatches->setCurrentComboItem( tr( "HSV Color Map" ));
Frame4Layout->addWidget( Swatches );
@@ -576,10 +577,11 @@
{
CurrSwatch.clear();
QString pfadC2 = "";
- if ( c->parent() != userSwatches)
- pfadC2 = csm.paletteFileFromName(c->text(0));
+ QString txt = c->data(0, Qt::UserRole).toString() + "/" + c->text(0);
+ if (!customColSet.contains(txt))
+ pfadC2 = csm.paletteFileFromName(txt);
else
- pfadC2 = csm.userPaletteFileFromName(c->text(0));
+ pfadC2 = csm.userPaletteFileFromName(txt);
if (importColorsFromFile(pfadC2, CurrSwatch))
{
CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
Modified: trunk/Scribus/scribus/ui/cmykfw.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/ui/cmykfw.h
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.h (original)
+++ trunk/Scribus/scribus/ui/cmykfw.h Sat Oct 30 12:07:36 2010
@@ -39,7 +39,7 @@
Q_OBJECT
public:
- CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, QStringList Cust, bool newCol );
+ CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, bool newCol );
~CMYKChoose() {};
QLabel* TextLabel1;
QLineEdit* Farbname;
@@ -87,7 +87,6 @@
int BlackComp;
ColorList *EColors;
ColorList CurrSwatch;
- QStringList CColSet;
QString Fnam;
public slots:
@@ -125,6 +124,7 @@
QTreeWidgetItem *systemSwatches;
QTreeWidgetItem *userSwatches;
QTreeWidgetItem *hsvSelector;
+ QStringList customColSet;
};
#endif // CMYKFARBEN_H
Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Sat Oct 30 12:07:36 2010
@@ -87,7 +87,8 @@
csm.findUserPalettes(userSwatches);
customColSet = csm.userPaletteNames();
userSwatches->setExpanded(true);
- LoadColSet->setCurrentComboItem(docColSet);
+ QFileInfo fi(docColSet);
+ LoadColSet->setCurrentComboItem(fi.baseName());
if (m_doc != 0)
{
label->setText( tr("Merge Color Set"));
@@ -134,7 +135,8 @@
connect(okButton, SIGNAL(clicked()), this, SLOT(leaveDialog()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(SaveColSet, SIGNAL(clicked()), this, SLOT(saveDefaults()));
- connect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
+// connect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
+ connect(LoadColSet, SIGNAL(activated(QTreeWidgetItem*)), this, SLOT(loadDefaults(QTreeWidgetItem*)));
}
void PaintManagerDialog::leaveDialog()
@@ -379,7 +381,7 @@
else if ((it->parent() == colorItems) || (it == colorItems))
{
ScColor tmpColor = ScColor(0, 0, 0, 0);
- CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, tr("New Color"), &m_colorList, customColSet, true);
+ CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, tr("New Color"), &m_colorList, true);
if (dia->exec())
{
dia->Farbe.setSpotColor(dia->Separations->isChecked());
@@ -438,7 +440,7 @@
else if ((it->parent() == colorItems) || (it == colorItems))
{
ScColor tmpColor = m_colorList[it->text(0)];
- CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, it->text(0), &m_colorList, customColSet, false);
+ CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, it->text(0), &m_colorList, false);
if (dia->exec())
{
dia->Farbe.setSpotColor(dia->Separations->isChecked());
@@ -509,7 +511,7 @@
QString nam = tr("Copy of %1").arg(it->text(0));
m_colorList.insert(nam, m_colorList[it->text(0)]);
ScColor tmpColor = m_colorList[nam];
- CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, nam, &m_colorList, customColSet, false);
+ CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, nam, &m_colorList, false);
if (dia->exec())
{
dia->Farbe.setSpotColor(dia->Separations->isChecked());
@@ -1096,15 +1098,16 @@
}
}
-void PaintManagerDialog::loadDefaults(const QString &txt)
-{
+void PaintManagerDialog::loadDefaults(QTreeWidgetItem* item)
+{
+ QString txt = item->data(0, Qt::UserRole).toString() + "/" + item->text(0);
if (m_doc == NULL)
{
m_colorList.clear();
dialogGradients.clear();
}
QString pfadC2 = "";
- if (txt == "Scribus Small")
+ if (item->text(0) == "Scribus Small")
{
m_colorList.insert("White", ScColor(0, 0, 0, 0));
m_colorList.insert("Black", ScColor(0, 0, 0, 255));
@@ -1136,7 +1139,7 @@
else
paletteLocked = false;
}
- if (txt != "Scribus Small")
+ if (item->text(0) != "Scribus Small")
{
if (importColorsFromFile(pfadC2, m_colorList, &dialogGradients, (m_doc!=0)))
m_colorList.ensureBlackAndWhite();
@@ -1162,9 +1165,11 @@
void PaintManagerDialog::saveDefaults()
{
+ QTreeWidgetItem* item = LoadColSet->currentItem();
+ QString NameK = item->data(0, Qt::UserRole).toString() + "/" + item->text(0);
QString Name = LoadColSet->text();
Query* dia = new Query(this, "Name", 1, 0, tr("&Name:"), tr("Choose a Name"));
- if ((customColSet.contains(Name)) && (!paletteLocked))
+ if ((customColSet.contains(NameK)) && (!paletteLocked))
dia->setEditText(Name, false);
else
dia->setEditText("", false);
@@ -1230,18 +1235,22 @@
QString nameC = name;
nameC.replace(" ", "_");
nameC += ".xml";
- customColSet.append(nameC);
- LoadColSet->addSubItem(name, userSwatches);
- disconnect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
+ QFileInfo fi(Fname);
+ customColSet.append(fi.absolutePath() + "/" + nameC);
+ QTreeWidgetItem *item = LoadColSet->addSubItem(name, userSwatches);
+ item->setData(0, Qt::UserRole, fi.absolutePath());
+ disconnect(LoadColSet, SIGNAL(activated(QTreeWidgetItem*)), this, SLOT(loadDefaults(QTreeWidgetItem*)));
LoadColSet->setCurrentComboItem(name);
- connect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
+ connect(LoadColSet, SIGNAL(activated(QTreeWidgetItem*)), this, SLOT(loadDefaults(QTreeWidgetItem*)));
}
}
}
QString PaintManagerDialog::getColorSetName()
{
- return LoadColSet->text();
+ QTreeWidgetItem* item = LoadColSet->currentItem();
+ QString NameK = item->data(0, Qt::UserRole).toString() + "/" + item->text(0);
+ return NameK;
}
ScColor PaintManagerDialog::selectedColor()
Modified: trunk/Scribus/scribus/ui/paintmanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/ui/paintmanager.h
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.h (original)
+++ trunk/Scribus/scribus/ui/paintmanager.h Sat Oct 30 12:07:36 2010
@@ -74,7 +74,7 @@
void removeColorItem();
void removeUnusedColorItem();
void importColorItems();
- void loadDefaults(const QString &txt);
+ void loadDefaults(QTreeWidgetItem* item);
void saveDefaults();
protected:
QTreeWidgetItem* updateGradientList(QString addedName = "");
Modified: trunk/Scribus/scribus/ui/swatchcombo.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/ui/swatchcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/swatchcombo.cpp (original)
+++ trunk/Scribus/scribus/ui/swatchcombo.cpp Sat Oct 30 12:07:36 2010
@@ -24,6 +24,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "swatchcombo.h"
+#include <QFontMetrics>
+#include <QFileInfo>
SwatchCombo::SwatchCombo( QWidget* parent ) : QToolButton(parent)
{
@@ -48,7 +50,12 @@
{
menu()->hide();
setText(item->text(0));
+ QFontMetrics fm(font());
+ QString elText = fm.elidedText(item->text(0), Qt::ElideMiddle, width());
+ setText(elText);
+ setToolTip(item->text(0));
emit activated(item->text(0));
+ emit activated(item);
}
}
}
@@ -74,11 +81,23 @@
void SwatchCombo::setCurrentComboItem(QString text)
{
- setText(text);
+ QFontMetrics fm(font());
+ QString elText = fm.elidedText(text, Qt::ElideMiddle, width());
+ setText(elText);
+ setToolTip(text);
QList<QTreeWidgetItem*> lg = dataTree->findItems(text, Qt::MatchExactly | Qt::MatchRecursive);
if (lg.count() > 0)
{
- dataTree->setCurrentItem(lg[0]);
+ for (int a = 0; a < lg.count(); a++)
+ {
+ QString pText = lg[a]->data(0, Qt::UserRole).toString();
+ QFileInfo fi(pText);
+ if (fi.baseName() == lg[a]->text(0))
+ {
+ dataTree->setCurrentItem(lg[0]);
+ break;
+ }
+ }
}
}
Modified: trunk/Scribus/scribus/ui/swatchcombo.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15696&path=/trunk/Scribus/scribus/ui/swatchcombo.h
==============================================================================
--- trunk/Scribus/scribus/ui/swatchcombo.h (original)
+++ trunk/Scribus/scribus/ui/swatchcombo.h Sat Oct 30 12:07:36 2010
@@ -45,6 +45,7 @@
QTreeWidgetItem* currentItem();
signals:
void activated(const QString &);
+ void activated(QTreeWidgetItem*);
private slots:
void itemActivated(QTreeWidgetItem* item);
private:
More information about the scribus-commit
mailing list