r14715 by fschmid - Scrapbook: - Added an option in the Preferences to en/disable the saving of the previews. - Added the ability to drop any loadable vector file onto the scrapbook.

scribus-commit scribus-commit at lists.scribus.net
Sun Feb 14 13:20:40 CET 2010


Revision: 14715
Author: fschmid
Date: 2010-02-14T12:18:01.936524Z
Commit message: Scrapbook:
- Added an option in the Preferences to en/disable the saving of the previews.
- Added the ability to drop any loadable vector file onto the scrapbook.

Changeset: 
M  /trunk/Scribus/scribus/prefsmanager.cpp
M  /trunk/Scribus/scribus/prefsstructs.h
M  /trunk/Scribus/scribus/ui/prefs.cpp
M  /trunk/Scribus/scribus/ui/prefs_scrapbook.cpp
M  /trunk/Scribus/scribus/ui/scrapbookpalette.cpp
M  /trunk/Scribus/scribus/ui/tabscrapbook.ui
M  /trunk/Scribus/scribus/ui/scrapbookpalette.h
M  /trunk/Scribus/scribus/ui/prefs_scrapbookbase.ui
M  /trunk/Scribus/scribus/ui/tabscrapbook.cpp

Diffs:
Index: scribus/prefsmanager.cpp
===================================================================
--- scribus/prefsmanager.cpp	(revision 14714)
+++ scribus/prefsmanager.cpp	(revision 14715)
@@ -304,6 +304,7 @@
 	appPrefs.uiPrefs.recentDocCount = 5;
 	appPrefs.scrapbookPrefs.doCopyToScrapbook = true;
 	appPrefs.scrapbookPrefs.persistentScrapbook = false;
+	appPrefs.scrapbookPrefs.writePreviews = true;
 	appPrefs.scrapbookPrefs.numScrapbookCopies = 10;
 	appPrefs.displayPrefs.marginColored = false;
 	appPrefs.docSetupPrefs.pageSize = "A4";
@@ -1418,6 +1419,7 @@
 	QDomElement dc73=docu.createElement("SCRAPBOOK");
 	dc73.setAttribute("CopyToScrapbook",static_cast<int>(appPrefs.scrapbookPrefs.doCopyToScrapbook));
 	dc73.setAttribute("persistentScrapbook",static_cast<int>(appPrefs.scrapbookPrefs.persistentScrapbook));
+	dc73.setAttribute("writePreviews",static_cast<int>(appPrefs.scrapbookPrefs.writePreviews));
 	dc73.setAttribute("numScrapbookCopies",appPrefs.scrapbookPrefs.numScrapbookCopies);
 	for (int rd=0; rd<appPrefs.scrapbookPrefs.RecentScrapbooks.count(); ++rd)
 	{
@@ -2034,6 +2036,7 @@
 		{
 			appPrefs.scrapbookPrefs.doCopyToScrapbook = static_cast<bool>(dc.attribute("CopyToScrapbook", "1").toInt());
 			appPrefs.scrapbookPrefs.persistentScrapbook = static_cast<bool>(dc.attribute("persistentScrapbook", "0").toInt());
+			appPrefs.scrapbookPrefs.writePreviews = static_cast<bool>(dc.attribute("writePreviews", "1").toInt());
 			appPrefs.scrapbookPrefs.numScrapbookCopies = dc.attribute("numScrapbookCopies", "10").toInt();
 			QDomNode scrp = dc.firstChild();
 			while(!scrp.isNull())
Index: scribus/prefsstructs.h
===================================================================
--- scribus/prefsstructs.h	(revision 14714)
+++ scribus/prefsstructs.h	(revision 14715)
@@ -273,6 +273,7 @@
 	int numScrapbookCopies;
 	bool doCopyToScrapbook; //! When copying (copy/paste), also copy to a scrapbook
 	bool persistentScrapbook; //! Keep the scrapbook contents between sessions
+	bool writePreviews;		//! Write previews to the scrapbook dir;
 };
 
 struct DisplayPrefs
Index: scribus/ui/prefs.cpp
===================================================================
--- scribus/ui/prefs.cpp	(revision 14714)
+++ scribus/ui/prefs.cpp	(revision 14715)
@@ -390,6 +390,7 @@
 
 	prefsManager->appPrefs.scrapbookPrefs.doCopyToScrapbook = tabScrapbook->useScrapBookasExtension->isChecked();
 	prefsManager->appPrefs.scrapbookPrefs.persistentScrapbook = tabScrapbook->persistentScrapbook->isChecked();
+	prefsManager->appPrefs.scrapbookPrefs.writePreviews = tabScrapbook->writePreviews->isChecked();
 	prefsManager->appPrefs.scrapbookPrefs.numScrapbookCopies = tabScrapbook->numScrapCopies->value();
 
 	tabTools->polyWidget->getValues(&prefsManager->appPrefs.itemToolPrefs.polyCorners,
Index: scribus/ui/prefs_scrapbookbase.ui
===================================================================
--- scribus/ui/prefs_scrapbookbase.ui	(revision 14714)
+++ scribus/ui/prefs_scrapbookbase.ui	(revision 14715)
@@ -45,8 +45,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>677</width>
-        <height>315</height>
+        <width>683</width>
+        <height>327</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -65,6 +65,13 @@
         </widget>
        </item>
        <item>
+        <widget class="QCheckBox" name="writePreviews">
+         <property name="text">
+          <string>Write Item Previews to the Scrapbook Directory</string>
+         </property>
+        </widget>
+       </item>
+       <item>
         <layout class="QHBoxLayout" name="horizontalLayout">
          <property name="sizeConstraint">
           <enum>QLayout::SetDefaultConstraint</enum>
Index: scribus/ui/prefs_scrapbook.cpp
===================================================================
--- scribus/ui/prefs_scrapbook.cpp	(revision 14714)
+++ scribus/ui/prefs_scrapbook.cpp	(revision 14715)
@@ -30,6 +30,7 @@
 {
 	autoSendCopiedToScrapCheckBox->setChecked(prefsData->scrapbookPrefs.doCopyToScrapbook);
 	keepCopiedAcrossSessionsCheckBox->setChecked(prefsData->scrapbookPrefs.persistentScrapbook);
+	writePreviews->setChecked(prefsData->scrapbookPrefs.writePreviews);
 	itemCountKeptInScrapbookSpinBox->setValue(prefsData->scrapbookPrefs.numScrapbookCopies);
 }
 
@@ -37,6 +38,7 @@
 {
 	prefsData->scrapbookPrefs.doCopyToScrapbook=autoSendCopiedToScrapCheckBox->isChecked();
 	prefsData->scrapbookPrefs.persistentScrapbook=keepCopiedAcrossSessionsCheckBox->isChecked();
+	prefsData->scrapbookPrefs.writePreviews=writePreviews->isChecked();
 	prefsData->scrapbookPrefs.numScrapbookCopies=itemCountKeptInScrapbookSpinBox->value();
 }
 
Index: scribus/ui/tabscrapbook.cpp
===================================================================
--- scribus/ui/tabscrapbook.cpp	(revision 14714)
+++ scribus/ui/tabscrapbook.cpp	(revision 14715)
@@ -20,5 +20,6 @@
 {
 	useScrapBookasExtension->setChecked(prefsData->scrapbookPrefs.doCopyToScrapbook);
 	persistentScrapbook->setChecked(prefsData->scrapbookPrefs.persistentScrapbook);
+	writePreviews->setChecked(prefsData->scrapbookPrefs.writePreviews);
 	numScrapCopies->setValue(prefsData->scrapbookPrefs.numScrapbookCopies);
 }
Index: scribus/ui/scrapbookpalette.cpp
===================================================================
--- scribus/ui/scrapbookpalette.cpp	(revision 14714)
+++ scribus/ui/scrapbookpalette.cpp	(revision 14715)
@@ -148,6 +148,25 @@
 		if (text.startsWith("<SCRIBUSELEM"))
 			emit objDropped(text);
 	}
+	else if ( e->mimeData()->hasFormat("text/uri-list"))
+	{
+		QStringList vectorFiles = LoadSavePlugin::getExtensionsForPreview(FORMATID_ODGIMPORT);
+		QList<QUrl> fileUrls = e->mimeData()->urls();
+		e->acceptProposedAction();
+		for( int i = 0; i < fileUrls.count(); ++i )
+		{
+			QUrl url( fileUrls[i] );
+			QFileInfo fi(url.path());
+			if (vectorFiles.contains(fi.suffix().toLower()))
+			{
+				FileLoader *fileLoader = new FileLoader(url.path());
+				int testResult = fileLoader->TestFile();
+				delete fileLoader;
+				if ((testResult != -1) && (testResult >= FORMATID_ODGIMPORT) && (fi.exists()))
+					emit fileDropped(url.path(), testResult);
+			}
+		}
+	}
 	else
 		e->ignore();
 }
@@ -306,7 +325,8 @@
 				delete pre;
 			}
 			QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])));
-			pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
+			if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+				pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
 			checkAndChange(ff, QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])), QDir::cleanPath(QDir::convertSeparators(name)));
 		}
 	}
@@ -337,7 +357,8 @@
 				delete pre;
 			}
 			QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])));
-			pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
+			if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+				pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
 		}
 	}
 	QDir d3(name, "*.shape", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
@@ -370,7 +391,8 @@
 				delete pre2;
 			}
 			QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(name + "/" + d3[dc])));
-			pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
+			if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+				pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
 		}
 	}
 	QStringList vectorFiles = LoadSavePlugin::getExtensionsForPreview(FORMATID_ODGIMPORT);
@@ -407,14 +429,14 @@
 						if( fmt )
 						{
 							QImage im = fmt->readThumbnail(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
-							if (canWrite)
-								im.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
+							im = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
 							pm = QPixmap::fromImage(im);
 						}
 					}
 				}
 				QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
-				pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
+				if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+					pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/"+fi3.baseName()+".png")), "PNG");
 			}
 		}
 	}
@@ -488,7 +510,7 @@
 					f = cf.data();
 				ScPreview *pre = new ScPreview();
 				pm = pre->createPreview(f);
-				if (canWrite)
+				if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
 					pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
 				delete pre;
 			}
@@ -513,7 +535,7 @@
 				QString f = QString::fromUtf8(cf.data());
 				StencilReader *pre = new StencilReader();
 				pm = pre->createPreview(f);
-				if (canWrite)
+				if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
 					pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
 				delete pre;
 			}
@@ -546,7 +568,7 @@
 				QString f2 = pre->createShape(f);
 				ScPreview *pre2 = new ScPreview();
 				pm = pre2->createPreview(f2);
-				if (canWrite)
+				if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
 					pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
 				delete pre;
 				delete pre2;
@@ -579,7 +601,8 @@
 						if( fmt )
 						{
 							QImage im = fmt->readThumbnail(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
-							if (canWrite)
+							im = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+							if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
 								im.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
 							pm = QPixmap::fromImage(im);
 						}
@@ -669,6 +692,7 @@
 void Biblio::setOpenScrapbooks(QStringList &fileNames)
 {
 	disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+	disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 	disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 	disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 	disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
@@ -695,6 +719,7 @@
 	Frame3->setCurrentIndex(0);
 	connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
 	connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+	connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 	connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 	connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 }
@@ -767,6 +792,7 @@
 				return;
 		}
 		disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+		disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 		disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 		disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 		disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
@@ -779,6 +805,7 @@
 		dirs->set("scrap_load", d.absolutePath());
 		connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
 		connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+		connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 		connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 		connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 	}
@@ -797,6 +824,7 @@
 				return;
 		}
 		disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+		disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 		disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 		disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 		disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
@@ -817,6 +845,7 @@
 		activeBView->scrollToTop();
 		connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
 		connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+		connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 		connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 		connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 	}
@@ -874,6 +903,7 @@
 	else
 	{
 		disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+		disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 		disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 		disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 		disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
@@ -883,6 +913,7 @@
 		Frame3->setCurrentIndex(0);
 		connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
 		connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+		connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 		connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 		connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 	}
@@ -891,10 +922,12 @@
 void Biblio::libChanged(int index)
 {
 	disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+	disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 	disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 	disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 	activeBView = (BibView*)Frame3->widget(index);
 	connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+	connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
 	connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
 	connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 }
@@ -1306,6 +1339,108 @@
 	return result;
 }
 
+void Biblio::ObjFromFile(QString path, int testResult)
+{
+	if (!activeBView->canWrite)
+		return;
+	QString tmp;
+	QFileInfo fi(path);
+	if ( fi.exists() )
+	{
+		QString nam = "";
+		nam = fi.baseName();
+		if (Frame3->currentIndex() == 1)
+		{
+			if (activeBView->objectMap.contains(nam))
+				nam += "("+ tmp.setNum(tempCount) + ")";
+			tempCount++;
+		}
+		else
+		{
+			if (activeBView->objectMap.contains(nam))
+				nam += "("+ tmp.setNum(tempCount) + ")";
+		}
+		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+		Query *dia = new Query(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
+		dia->setEditText(nam, true);
+		dia->setTestList(activeBView->objectMap.keys());
+		if (dia->exec())
+			nam = dia->getEditText();
+		else
+		{
+			delete dia;
+			return;
+		}
+		const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+		if( fmt )
+		{
+			QImage im = fmt->readThumbnail(path);
+			im = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+			QByteArray cf;
+			if (!loadRawText(path, cf))
+				return;
+			QPixmap pm = QPixmap::fromImage(im);
+			QFile f(QDir::cleanPath(QDir::convertSeparators(activeBView->ScFilename + "/" + nam + "." + fi.completeSuffix())));
+			if(!f.open(QIODevice::WriteOnly))
+				return;
+			QDataStream s;
+			s.setDevice(&f);
+			s.writeRawData(cf.data(), cf.length());
+			f.close();
+			if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+				im.save(QDir::cleanPath(QDir::convertSeparators(activeBView->ScFilename + "/" + nam +".png")), "PNG");
+			activeBView->AddObj(nam, QDir::cleanPath(QDir::convertSeparators(activeBView->ScFilename + "/" + nam + "." + fi.completeSuffix())), pm);
+			QPixmap pm2(60, 60);
+			pm2.fill(palette().color(QPalette::Base));
+			QPainter p;
+			p.begin(&pm2);
+			p.drawPixmap(30 - pm.width() / 2, 30 - pm.height() / 2, pm);
+			p.end();
+			new QListWidgetItem(QIcon(pm2), nam, activeBView);
+			if (Frame3->currentIndex() == 1)
+			{
+				if (tempBView->objectMap.count() > PrefsManager::instance()->appPrefs.scrapbookPrefs.numScrapbookCopies)
+				{
+					QMap<QString,BibView::Elem>::Iterator it;
+					it = tempBView->objectMap.begin();
+					QFile f(it.value().Data);
+					f.remove();
+					QFileInfo fi(QDir::convertSeparators(tempBView->ScFilename + "/" + it.key() + ".png"));
+					if (fi.exists())
+					{
+						QFile f2(QDir::convertSeparators(tempBView->ScFilename + "/" + it.key() + ".png"));
+						f2.remove();
+					}
+					QFileInfo fiD(QDir::convertSeparators(tempBView->ScFilename + "/" + it.key()));
+					if ((fiD.exists()) && (fiD.isDir()))
+					{
+						QDir dd = QDir(QDir::convertSeparators(tempBView->ScFilename));
+						QDir d(QDir::convertSeparators(tempBView->ScFilename + "/" + it.key()), "*", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+						if ((d.exists()) && (d.count() != 0))
+						{
+							for (uint dc = 0; dc < d.count(); ++dc)
+							{
+								QFile::remove(QDir::convertSeparators(tempBView->ScFilename + "/" + it.key() + "/" + d[dc]));
+							}
+						}
+						dd.rmdir(QDir::convertSeparators(tempBView->ScFilename + "/" + it.key()));
+					}
+					QString name = it.key();
+					tempBView->objectMap.erase(it);
+					QList<QListWidgetItem *> itL = tempBView->findItems(name, Qt::MatchExactly);
+					if (itL.count() > 0)
+					{
+						QListWidgetItem *ite = itL.at(0);
+						delete tempBView->takeItem(tempBView->row(ite));
+					}
+					tempBView->sortItems();
+				}
+				emit updateRecentMenue();
+			}
+		}
+	}
+}
+
 void Biblio::ObjFromMenu(QString text)
 {
 	QString nam = "";
@@ -1347,7 +1482,8 @@
 	ScPreview *pre = new ScPreview();
 	QPixmap pm = pre->createPreview(ff);
 	activeBView->AddObj(nam, QDir::cleanPath(QDir::convertSeparators(activeBView->ScFilename + "/" + nam + ".sce")), pm);
-	pm.save(QDir::cleanPath(QDir::convertSeparators(activeBView->ScFilename + "/" + nam +".png")), "PNG");
+	if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+		pm.save(QDir::cleanPath(QDir::convertSeparators(activeBView->ScFilename + "/" + nam +".png")), "PNG");
 	if (pm.width() > 60)
 		pm = pm.scaledToWidth(60, Qt::SmoothTransformation);
 	if (pm.height() > 60)
@@ -1417,7 +1553,8 @@
 	ScPreview *pre = new ScPreview();
 	QPixmap pm = pre->createPreview(ff);
 	tempBView->AddObj(nam, QDir::cleanPath(QDir::convertSeparators(tempBView->ScFilename + "/" + nam + ".sce")), pm);
-	pm.save(QDir::cleanPath(QDir::convertSeparators(tempBView->ScFilename + "/" + nam +".png")), "PNG");
+	if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+		pm.save(QDir::cleanPath(QDir::convertSeparators(tempBView->ScFilename + "/" + nam +".png")), "PNG");
 	if (pm.width() > 60)
 		pm = pm.scaledToWidth(60, Qt::SmoothTransformation);
 	if (pm.height() > 60)
Index: scribus/ui/tabscrapbook.ui
===================================================================
--- scribus/ui/tabscrapbook.ui	(revision 14714)
+++ scribus/ui/tabscrapbook.ui	(revision 14715)
@@ -1,9 +1,10 @@
-<ui version="4.0" >
- <author>Petr Vanek &lt;petr at scribus.info></author>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <author>Petr Vanek &lt;petr at scribus.info&gt;</author>
  <comment>scrapbook panel for prefs UI</comment>
  <class>TabScrapbook</class>
- <widget class="QWidget" name="TabScrapbook" >
-  <property name="geometry" >
+ <widget class="QWidget" name="TabScrapbook">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -11,73 +12,74 @@
     <height>203</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" >
-   <property name="margin" >
-    <number>11</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <widget class="QCheckBox" name="useScrapBookasExtension" >
-     <property name="toolTip" >
+    <widget class="QCheckBox" name="useScrapBookasExtension">
+     <property name="toolTip">
       <string>This enables the scrapbook to be used an extension to the copy/paste buffers. Simply copying an object or grouped object will send this to the Scrapbook automatically</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>Send Copied Items Automatically to Scrapbook</string>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="QCheckBox" name="persistentScrapbook" >
-     <property name="toolTip" >
+    <widget class="QCheckBox" name="persistentScrapbook">
+     <property name="toolTip">
       <string>This enables copied items to be kept permanently in the scrapbook.</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>Keep Copied Items Permanently Across Sessions</string>
      </property>
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
+    <widget class="QCheckBox" name="writePreviews">
+     <property name="text">
+      <string>Write Item Previews into the Scrapbook Directory</string>
      </property>
-     <property name="spacing" >
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout">
+     <property name="spacing">
       <number>6</number>
      </property>
+     <property name="margin">
+      <number>0</number>
+     </property>
      <item>
-      <widget class="QLabel" name="textLabel2" >
-       <property name="toolTip" >
+      <widget class="QLabel" name="textLabel2">
+       <property name="toolTip">
         <string>The minimum number is 1; the maximum us 100.</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string>Number of Copied Items to Keep in Scrapbook:</string>
        </property>
-       <property name="wordWrap" >
+       <property name="wordWrap">
         <bool>false</bool>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QSpinBox" name="numScrapCopies" >
-       <property name="maximum" >
+      <widget class="QSpinBox" name="numScrapCopies">
+       <property name="minimum">
+        <number>1</number>
+       </property>
+       <property name="maximum">
         <number>100</number>
        </property>
-       <property name="minimum" >
-        <number>1</number>
-       </property>
       </widget>
      </item>
      <item>
       <spacer>
-       <property name="orientation" >
+       <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeType" >
+       <property name="sizeType">
         <enum>QSizePolicy::Expanding</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
@@ -89,13 +91,13 @@
    </item>
    <item>
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeType" >
+     <property name="sizeType">
       <enum>QSizePolicy::Expanding</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>97</height>
@@ -105,7 +107,7 @@
    </item>
   </layout>
  </widget>
- <layoutdefault spacing="6" margin="11" />
+ <layoutdefault spacing="6" margin="11"/>
  <resources/>
  <connections/>
 </ui>
Index: scribus/ui/scrapbookpalette.h
===================================================================
--- scribus/ui/scrapbookpalette.h	(revision 14714)
+++ scribus/ui/scrapbookpalette.h	(revision 14715)
@@ -52,6 +52,7 @@
 	void CloseMpal();
 	void CloseTpal();
 	void objDropped(QString text);
+	void fileDropped(QString path, int testResult);
 
 protected:
 	void dragEnterEvent(QDragEnterEvent *e);
@@ -89,6 +90,7 @@
 	
 public slots:
 	void languageChange();
+	void ObjFromFile(QString path, int testResult);
 	void ObjFromMenu(QString text);
 
 private slots:




More information about the scribus-commit mailing list