Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 6421 → Rev 6422

/branches/Version13x/Scribus/scribus/patterndialogbase.ui
33,7 → 33,7
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout1</cstring>
<cstring>layout2</cstring>
</property>
<vbox>
<property name="name">
49,6 → 49,14
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonLoadDir</cstring>
</property>
<property name="text">
<string>Load Set</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonRemove</cstring>
</property>
<property name="text">
68,7 → 76,7
<property name="sizeHint">
<size>
<width>21</width>
<height>81</height>
<height>30</height>
</size>
</property>
</spacer>
/branches/Version13x/Scribus/scribus/patterndialog.cpp
34,6 → 34,8
#include "scconfig.h"
#include <qpixmap.h>
#include <qimage.h>
#include <qdir.h>
#include <qfiledialog.h>
 
PatternDialog::PatternDialog(QWidget* parent, QMap<QString, ScPattern> *docPatterns, ScribusDoc *doc, ScribusMainWindow *scMW) : patternDialogBase(parent)
{
50,6 → 52,7
connect(buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonLoad, SIGNAL(clicked()), this, SLOT(loadPattern()));
connect(buttonLoadDir, SIGNAL(clicked()), this, SLOT(loadPatternDir()));
connect(buttonRemove, SIGNAL(clicked()), this, SLOT(removePattern()));
connect(patternView, SIGNAL(clicked(QIconViewItem*)), this, SLOT(patternSelected(QIconViewItem*)));
}
68,6 → 71,64
}
}
 
void PatternDialog::loadPatternDir()
{
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString wdir = dirs->get("patterns", ".");
QString fileName = QFileDialog::getExistingDirectory(wdir, this, "d", tr("Choose a Directory"), true);
if (!fileName.isEmpty())
{
QStringList formats;
formats += "eps";
formats += "pdf";
QString form1 = "";
for ( uint i = 0; i < QImageIO::inputFormats().count(); ++i )
{
form1 = QString(QImageIO::inputFormats().at(i)).lower();
if (form1 == "jpeg")
form1 = "jpg";
if ((form1 == "png") || (form1 == "xpm") || (form1 == "gif"))
formats += form1;
else if (form1 == "jpg")
{
formats += "jpg";
formats += "jpeg";
}
}
#ifdef HAVE_TIFF
formats += "tif";
formats += "tiff";
#endif
formats += "psd";
formats += "pat";
QDir d(fileName, "*", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
if ((d.exists()) && (d.count() != 0))
{
for (uint dc = 0; dc < d.count(); ++dc)
{
QFileInfo fi(QDir::cleanDirPath(QDir::convertSeparators(fileName + "/" + d[dc])));
QString ext = fi.extension(true).lower();
if ((ext == "sml") || (ext == "shape") || (ext == "sce"))
loadVectors(QDir::cleanDirPath(QDir::convertSeparators(fileName + "/" + d[dc])));
else if (formats.contains(ext))
{
QString patNam = fi.baseName().stripWhiteSpace().simplifyWhiteSpace().replace(" ", "_");
ScPattern pat = ScPattern();
pat.setDoc(m_doc);
pat.setPattern(QDir::cleanDirPath(QDir::convertSeparators(fileName + "/" + d[dc])));
if (!dialogPatterns.contains(patNam))
dialogPatterns.insert(patNam, pat);
}
else
continue;
}
}
d.cdUp();
dirs->set("patterns", d.absPath());
updatePatternList();
}
}
 
void PatternDialog::loadPattern()
{
QString fileName;
112,7 → 173,10
PrefsManager::instance()->prefsFile->getContext("dirs")->set("patterns", fileName.left(fileName.findRev("/")));
QFileInfo fi(fileName);
if ((fi.extension(true).lower() == "sml") || (fi.extension(true).lower() == "shape") || (fi.extension(true).lower() == "sce"))
{
loadVectors(fileName);
updatePatternList();
}
else
{
QString patNam = fi.baseName().stripWhiteSpace().simplifyWhiteSpace().replace(" ", "_");
182,7 → 246,6
if (!origPatterns.contains(it.key()))
dialogPatterns.insert(it.key(), it.data());
}
updatePatternList();
}
 
void PatternDialog::patternSelected(QIconViewItem* it)
/branches/Version13x/Scribus/scribus/patterndialog.h
53,6 → 53,7
QMap<QString, ScPattern> dialogPatterns;
QStringList origPatterns;
public slots:
void loadPatternDir();
void loadPattern();
void patternSelected(QIconViewItem* it);
void removePattern();