r14061 by fschmid - Made the filterlists in the filedialogs a bit more userfriendly (hiding the fileextensions)

scribus-commit scribus-commit at lists.scribus.net
Tue Sep 29 11:50:26 CEST 2009


Revision: 14061
Author: fschmid
Date: 2009-09-29T09:47:47.114189Z
Commit message: Made the filterlists in the filedialogs a bit more userfriendly (hiding the fileextensions)

Changeset: 
M  /trunk/Scribus/scribus/plugins/psimport/importpsplugin.cpp
M  /trunk/Scribus/scribus/scribus.cpp
M  /trunk/Scribus/scribus/ui/customfdialog.cpp
M  /trunk/Scribus/scribus/fileloader.cpp
M  /trunk/Scribus/scribus/ui/newfile.cpp
M  /trunk/Scribus/scribus/plugins/formatidlist.h

Diffs:
Index: scribus/fileloader.cpp
===================================================================
--- scribus/fileloader.cpp	(revision 14060)
+++ scribus/fileloader.cpp	(revision 14061)
@@ -78,7 +78,28 @@
 // measure during the process of converting to file loader plugins.
 const QString FileLoader::getLoadFilterString()
 {
-	return LoadSavePlugin::fileDialogLoadFilter().join(";;");
+//	return LoadSavePlugin::fileDialogLoadFilter().join(";;");
+	QStringList fmts = LoadSavePlugin::fileDialogLoadFilter();
+	QString fmtString = QObject::tr("All Supported Formats")+" (";
+	int ind = -1;
+	for (int a = 0; a < fmts.count()-1; a++)
+	{
+		QString fmt = fmts[a];
+		int s = fmt.indexOf("(");
+		int e = fmt.lastIndexOf(")");
+		QString f = fmt.mid(s+1, e-s-1);
+		if (f.contains("pdf"))	// for removing PDF from the list
+		{
+			ind = a;
+			continue;
+		}
+		fmtString += f + " ";
+	}
+	fmtString += ");;";
+	if (ind != -1)
+		fmts.removeAt(ind);
+	fmtString += fmts.join(";;");
+	return fmtString.simplified();
 }
 
 /*!
Index: scribus/ui/customfdialog.cpp
===================================================================
--- scribus/ui/customfdialog.cpp	(revision 14060)
+++ scribus/ui/customfdialog.cpp	(revision 14061)
@@ -26,7 +26,6 @@
 #include <QDir>
 #include <QFileInfo>
 #include <QFrame>
-#include <QFrame>
 #include <QHBoxLayout>
 #include <QIcon>
 #include <QImageReader>
@@ -34,7 +33,6 @@
 #include <QPainter>
 #include <QPixmap>
 #include <QPushButton>
-#include <QPushButton>
 #include <QTextCodec>
 #include <QVBoxLayout>
 
@@ -397,6 +395,11 @@
 		if (flags & fdCompressFile)
 			connect(SaveZip, SIGNAL(clicked()), this, SLOT(handleCompress()));
 	}
+#if QT_VERSION >= 0x040600
+	fileDialog->setNameFilterDetailsVisible(false);
+#else
+	fileDialog->setOption(QFileDialog::HideNameFilterDetails);
+#endif
 	extZip = "gz";
 	connect(OKButton, SIGNAL(clicked()), this, SLOT(accept()));
 	connect(CancelB, SIGNAL(clicked()), this, SLOT(reject()));
Index: scribus/ui/newfile.cpp
===================================================================
--- scribus/ui/newfile.cpp	(revision 14060)
+++ scribus/ui/newfile.cpp	(revision 14061)
@@ -356,7 +356,7 @@
 	else
 		docDir = docContext->get("docsopen", ".");
 	QString formats(FileLoader::getLoadFilterString());
-	formats.remove("PDF (*.pdf *.PDF);;");
+//	formats.remove("PDF (*.pdf *.PDF);;");
 	openDocFrame = new QFrame(this);
 	openDocLayout = new QVBoxLayout(openDocFrame);
 	openDocLayout->setMargin(5);
@@ -366,6 +366,11 @@
 	fileDialog = new QFileDialog(openDocFrame, tr("Open"), docDir, formats);
 	fileDialog->setFileMode(QFileDialog::ExistingFile);
 	fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
+#if QT_VERSION >= 0x040600
+	fileDialog->setNameFilterDetailsVisible(false);
+#else
+	fileDialog->setOption(QFileDialog::HideNameFilterDetails);
+#endif
 	fileDialog->setReadOnly(true);
 #else
 	fileDialog = new CustomFDialog(openDocFrame, docDir, tr("Open"), formats, fdNone);
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 14060)
+++ scribus/scribus.cpp	(revision 14061)
@@ -3690,7 +3690,7 @@
 	else
 		docDir = docContext->get("docsopen", ".");
 	QString formats(FileLoader::getLoadFilterString());
-	formats.remove("PDF (*.pdf *.PDF);;");
+//	formats.remove("PDF (*.pdf *.PDF);;");
 	QString fileName = CFileDialog( docDir, tr("Open"), formats);
 	if (fileName.isEmpty())
 		// User cancelled
Index: scribus/plugins/formatidlist.h
===================================================================
--- scribus/plugins/formatidlist.h	(revision 14060)
+++ scribus/plugins/formatidlist.h	(revision 14061)
@@ -18,7 +18,7 @@
 #define FORMATID_ODGIMPORT 100
 #define FORMATID_SXDIMPORT 101
 #define FORMATID_SVGIMPORT 102
-#define FORMATID_PSIMPORT  103
+#define FORMATID_EPSIMPORT  103
 #define FORMATID_WMFIMPORT 104
 #define FORMATID_AIIMPORT  105
 #define FORMATID_XFIGIMPORT  106
@@ -26,7 +26,8 @@
 #define FORMATID_WPGIMPORT  108
 #define FORMATID_UNICONVIMPORT 109
 #define FORMATID_PCTIMPORT 110
-#define FORMATID_PDFIMPORT 120
+#define FORMATID_PSIMPORT  111
+#define FORMATID_PDFIMPORT 112
 
 // EXPORT
 
Index: scribus/plugins/psimport/importpsplugin.cpp
===================================================================
--- scribus/plugins/psimport/importpsplugin.cpp	(revision 14060)
+++ scribus/plugins/psimport/importpsplugin.cpp	(revision 14061)
@@ -91,26 +91,37 @@
 void ImportPSPlugin::registerFormats()
 {
 	FileFormat fmt(this);
-	fmt.trName = FormatsManager::instance()->nameOfFormat(FormatsManager::PS); // Human readable name
-	fmt.formatId = FORMATID_PSIMPORT;
-	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::EPS|FormatsManager::PS);// QFileDialog filter
- 	fmt.nameMatch = QRegExp("\\.("+FormatsManager::instance()->extensionListForFormat(FormatsManager::EPS|FormatsManager::PS, 1)+")$", Qt::CaseInsensitive);
+	fmt.trName = FormatsManager::instance()->nameOfFormat(FormatsManager::EPS); // Human readable name
+	fmt.formatId = FORMATID_EPSIMPORT;
+	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::EPS);// QFileDialog filter
+ 	fmt.nameMatch = QRegExp("\\.("+FormatsManager::instance()->extensionListForFormat(FormatsManager::EPS, 1)+")$", Qt::CaseInsensitive);
 	fmt.load = true;
 	fmt.save = false;
-	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PS); // MIME types
+	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::EPS); // MIME types
 	fmt.priority = 64; // Priority
 	registerFormat(fmt);
-
+	
 	FileFormat fmt2(this);
-	fmt2.trName = FormatsManager::instance()->nameOfFormat(FormatsManager::PDF); // Human readable name
-	fmt2.formatId = FORMATID_PDFIMPORT;
-	fmt2.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::PDF);// QFileDialog filter
-	fmt2.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::PDF, 1)+"$", Qt::CaseInsensitive);
+	fmt2.trName = FormatsManager::instance()->nameOfFormat(FormatsManager::PS); // Human readable name
+	fmt2.formatId = FORMATID_PSIMPORT;
+	fmt2.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::PS);// QFileDialog filter
+ 	fmt2.nameMatch = QRegExp("\\.("+FormatsManager::instance()->extensionListForFormat(FormatsManager::PS, 1)+")$", Qt::CaseInsensitive);
 	fmt2.load = true;
 	fmt2.save = false;
-	fmt2.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PDF); // MIME types
+	fmt2.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PS); // MIME types
 	fmt2.priority = 64; // Priority
 	registerFormat(fmt2);
+
+	FileFormat fmt3(this);
+	fmt3.trName = FormatsManager::instance()->nameOfFormat(FormatsManager::PDF); // Human readable name
+	fmt3.formatId = FORMATID_PDFIMPORT;
+	fmt3.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::PDF);// QFileDialog filter
+	fmt3.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::PDF, 1)+"$", Qt::CaseInsensitive);
+	fmt3.load = true;
+	fmt3.save = false;
+	fmt3.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PDF); // MIME types
+	fmt3.priority = 64; // Priority
+	registerFormat(fmt3);
 }
 
 bool ImportPSPlugin::fileSupported(QIODevice* /* file */, const QString & fileName) const




More information about the scribus-commit mailing list