r15680 by fschmid - Implemented simple "Palette locking", the folder $HOME/.scribus/swatches/locked is a protected folder.
scribus-commit
scribus-commit at lists.scribus.net
Fri Oct 29 21:13:37 CEST 2010
Author: fschmid
Date: Fri Oct 29 19:13:37 2010
New Revision: 15680
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15680
Log:
Implemented simple "Palette locking", the folder $HOME/.scribus/swatches/locked is a protected folder.
Modified:
branches/Version135/Scribus/scribus/colorm.cpp
branches/Version135/Scribus/scribus/colorm.h
branches/Version135/Scribus/scribus/colorsetmanager.cpp
Modified: branches/Version135/Scribus/scribus/colorm.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15680&path=/branches/Version135/Scribus/scribus/colorm.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/colorm.cpp (original)
+++ branches/Version135/Scribus/scribus/colorm.cpp Fri Oct 29 19:13:37 2010
@@ -55,6 +55,7 @@
setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
m_Doc=doc;
customColSet = custColSet;
+ paletteLocked = false;
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setSizeGripEnabled(true);
Layout2 = new QVBoxLayout( this );
@@ -141,6 +142,26 @@
SaveColSet->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
ColsSetGroupLayout->addWidget( SaveColSet );
layout3->addWidget( ColsSetGroup );
+
+ if (docColSet != "Scribus Small")
+ {
+ QString pfadC2 = "";
+ int c = LoadColSet->currentIndex();
+ if ( c < customSetStartIndex)
+ pfadC2 = csm.paletteFileFromName(docColSet);
+ else
+ {
+ QString Fname = docColSet;
+ Fname.replace(" ", "_");
+ Fname += ".xml";
+ pfadC2 = QDir::convertSeparators(ScPaths::getApplicationDataDir()+Fname);
+ }
+ QFileInfo fi(pfadC2);
+ if (fi.absolutePath() == ScPaths::getApplicationDataDir()+"swatches/locked")
+ paletteLocked = true;
+ else
+ paletteLocked = !fi.isWritable();
+ }
}
saveButton = new QPushButton( CommonStrings::tr_OK, this );
layout3->addWidget( saveButton );
@@ -181,6 +202,19 @@
connect( colorListBox, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( selColor(QListWidgetItem*) ) );
connect( colorListBox, SIGNAL( itemActivated(QListWidgetItem*) ), this, SLOT( selEditColor(QListWidgetItem*) ) );
resize(minimumSizeHint());
+ if (paletteLocked)
+ {
+ duplicateColorButton->setEnabled(false);
+ editColorButton->setEnabled(false);
+ deleteColorButton->setEnabled(false);
+ importColorsButton->setEnabled(false);
+ newColorButton->setEnabled(false);
+ }
+ else
+ {
+ importColorsButton->setEnabled(true);
+ newColorButton->setEnabled(true);
+ }
}
void ColorManager::saveDefaults()
@@ -273,6 +307,11 @@
pfadC2 = QDir::convertSeparators(ScPaths::getApplicationDataDir()+Fname);
}
}
+ QFileInfo fi(pfadC2);
+ if (fi.absolutePath() == ScPaths::getApplicationDataDir()+"swatches/locked")
+ paletteLocked = true;
+ else
+ paletteLocked = !fi.isWritable();
if (txt != "Scribus Small")
{
if (importColorsFromFile(pfadC2, EditColors))
@@ -297,10 +336,25 @@
}
}
updateCList();
+ if (paletteLocked)
+ {
+ duplicateColorButton->setEnabled(false);
+ editColorButton->setEnabled(false);
+ deleteColorButton->setEnabled(false);
+ importColorsButton->setEnabled(false);
+ newColorButton->setEnabled(false);
+ }
+ else
+ {
+ importColorsButton->setEnabled(true);
+ newColorButton->setEnabled(true);
+ }
}
void ColorManager::importColors()
{
+ if (paletteLocked)
+ return;
QString fileName;
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString wdir = dirs->get("colors", ".");
@@ -326,6 +380,8 @@
void ColorManager::deleteUnusedColors()
{
+ if (paletteLocked)
+ return;
ColorList::Iterator it;
ScColor regColor;
QString regName;
@@ -351,6 +407,8 @@
void ColorManager::duplicateColor()
{
+ if (paletteLocked)
+ return;
QString nam = tr("Copy of %1").arg(sColor);
EditColors.insert(nam, EditColors[sColor]);
sColor = nam;
@@ -361,6 +419,8 @@
void ColorManager::newColor()
{
+ if (paletteLocked)
+ return;
ScColor tmpColor = ScColor(0, 0, 0, 0);
CMYKChoose* dia = new CMYKChoose(this, m_Doc, tmpColor, tr("New Color"), &EditColors, customColSet, true);
// int newItemIndex=0;
@@ -396,6 +456,8 @@
void ColorManager::editColor()
{
+ if (paletteLocked)
+ return;
int selectedIndex = colorListBox->row(colorListBox->currentItem());
ScColor tmpColor = EditColors[sColor];
CMYKChoose* dia = new CMYKChoose(this, m_Doc, tmpColor, sColor, &EditColors, customColSet, false);
@@ -420,6 +482,8 @@
void ColorManager::deleteColor()
{
+ if (paletteLocked)
+ return;
int selectedIndex = colorListBox->row(colorListBox->currentItem());
DelColor *dia = new DelColor(this, EditColors, sColor, (m_Doc!=0));
if (dia->exec())
@@ -453,6 +517,13 @@
void ColorManager::selColor(QListWidgetItem *c)
{
+ if (paletteLocked)
+ {
+ editColorButton->setEnabled(false);
+ duplicateColorButton->setEnabled(false);
+ deleteColorButton->setEnabled(false);
+ return;
+ }
sColor = c->text();
ScColor tmpColor = EditColors[sColor];
bool enableEdit = (sColor != "Black" && sColor != "White" && !tmpColor.isRegistrationColor());
@@ -464,6 +535,8 @@
void ColorManager::selEditColor(QListWidgetItem *c)
{
+ if (paletteLocked)
+ return;
sColor = c->text();
ScColor tmpColor = EditColors[sColor];
bool enableEdit = (sColor != "Black" && sColor != "White" && !tmpColor.isRegistrationColor());
Modified: branches/Version135/Scribus/scribus/colorm.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15680&path=/branches/Version135/Scribus/scribus/colorm.h
==============================================================================
--- branches/Version135/Scribus/scribus/colorm.h (original)
+++ branches/Version135/Scribus/scribus/colorm.h Fri Oct 29 19:13:37 2010
@@ -94,6 +94,7 @@
ColorSetManager csm;
int customSetStartIndex;
+ bool paletteLocked;
};
#endif // FARBMANAGER_H
Modified: branches/Version135/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15680&path=/branches/Version135/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/colorsetmanager.cpp (original)
+++ branches/Version135/Scribus/scribus/colorsetmanager.cpp Fri Oct 29 19:13:37 2010
@@ -114,6 +114,7 @@
paletteLocations.clear();
QStringList locations=ScPaths::instance().getSystemCreateSwatchesDirs();
locations << ScPaths::instance().libDir()+"swatches/";
+ locations << ScPaths::getApplicationDataDir() + "swatches/locked/";
for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it )
{
QFile createDir(*it);
More information about the scribus-commit
mailing list