Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
README rewrited.
Browse files Browse the repository at this point in the history
.ts files cleaned.
Added German translation.
New logo.
Some changes for easier translation.
File search in the wizard moved to different thread to prevent GUI
freeze (still testing).
Added progress indicator into input path QLineEdit.
Small fixes.
  • Loading branch information
RazrFalcon committed Mar 25, 2012
1 parent 91a759a commit cad56c1
Show file tree
Hide file tree
Showing 25 changed files with 1,733 additions and 1,233 deletions.
15 changes: 8 additions & 7 deletions README
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Generally, SVG files produced by vector editors contain a lot of unused elements and attributes that just blow up their size, but not add quality. SVG Cleaner could help you to clean up your SVG files from unnecessary data. It works in batch mode and basically does two things:
- removing elements and attributes that don't contribute to the final rendering;
- making those elements and attributes that are actually used more compact.
The app has a lot of options for cleanup and optimization and provides multithreaded file processing on the multicore processors.
Generally, SVG files produced by vector editors contain a lot of unused elements and attributes that just blow up their size without providing better visible quality.

Usually, images cleaned by SVG Cleaner may be as small as 10-60% of the original sizes.
SVG Cleaner could help you to clean up your SVG files from unnecessary data. It has a lot of options for cleanup and optimization, works in batch mode, provides threaded processing on the multicore processors and basically does two things:
- removing elements and attributes that don't contribute to the final rendering;
- making those elements and attributes in use more compact.

Important! Internal image viewer in SVG Cleaner uses QtSvg for rendering SVG images. Since Qt supports only the static features of SVG 1.2 Tiny that imposes a number of restrictions on rendering of advanced features. For instance, elements such as clipPath, mask, filters etc. will not be rendered at all.
Images cleaned by SVG Cleaner are typically 10-60 percent smaller than the original ones.

We apologize in advance for any bugs. Please send bug reports to [email protected]
Important! The internal image viewer in SVG Cleaner uses the QtSvg module for rendering SVG images. Qt supports only the static features of SVG 1.2 Tiny, and that imposes a number of restrictions on rendering of advanced features. For instance, elements such as clipPath, mask, filters etc. will not be rendered at all.

We apologize for any bugs in advance. Please send bug reports to [email protected].
Binary file modified icons/svgcleaner.ico
Binary file not shown.
Binary file modified icons/svgcleaner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 52 additions & 29 deletions icons/svgcleaner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/svgcleaner.svgz
Binary file not shown.
1 change: 1 addition & 0 deletions src/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent)
{
setupUi(this);
// FIXME: move all text from .ui to .cpp for easier translation
}
26 changes: 21 additions & 5 deletions src/aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</font>
</property>
<property name="text">
<string notr="true">SVG Cleaner 0.4</string>
<string notr="true">SVG Cleaner 0.5</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand All @@ -52,9 +52,17 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Verdana'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; color:#000000;&quot;&gt;Generally, SVG files produced by vector editors contain a lot of unused elements and attributes that just blow up their size, but not add quality.&lt;br /&gt;&lt;br /&gt;SVG Cleaner could help you to clean up your SVG files from unnecessary data. It works in batch mode and basically does two things:&lt;br /&gt;- removing elements and attributes that don't contribute to the final rendering; &lt;br /&gt;- making those elements and attributes that are actually used more compact.&lt;br /&gt;The app has a lot of options for cleanup and optimization and provides multithreaded file processing on the multicore processors.&lt;br /&gt;Usually, images cleaned by SVG Cleaner may be as small as 10-60% of the original sizes.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; color:#000000;&quot;&gt;Important! Internal image viewer in SVG Cleaner uses QtSvg for rendering SVG images. Since Qt supports only the static features of SVG 1.2 Tiny that imposes a number of restrictions on rendering of advanced features. For instance, elements such as clipPath, mask, filters etc. will not be rendered at all.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; color:#000000;&quot;&gt;We apologize in advance for any bugs. Please send bug reports to &lt;/span&gt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Generally, SVG files produced by vector editors contain a lot of unused elements and attributes that just blow up their size without providing better visible quality.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;SVG Cleaner could help you to clean up your SVG files from unnecessary data. It has a lot of options for cleanup and optimization, works in batch mode, provides threaded processing on the multicore processors and basically does two things:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;- removing elements and attributes that don't contribute to the final rendering;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;- making those elements and attributes in use more compact.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Images cleaned by SVG Cleaner are typically 10-60 percent smaller than the original ones.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Important! The internal image viewer in SVG Cleaner uses the QtSvg module for rendering SVG images. Qt supports only the static features of SVG 1.2 Tiny, and that imposes a number of restrictions on rendering of advanced features. For instance, elements such as clipPath, mask, filters etc. will not be rendered at all.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;We apologize for any bugs in advance. Please send bug reports to &lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand All @@ -76,7 +84,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Andrey Bayrak &amp;lt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Evgeniy Raizner &amp;lt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;br /&gt;&lt;br /&gt;Special thanks:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Alexandre Prokoudine &amp;lt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;br /&gt;&lt;br /&gt;Translators:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Czech - Pavel Fric &amp;lt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Czech - Pavel Fric &amp;lt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;br /&gt;German - Seb Adler &amp;lt;&lt;a href=&quot;[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -145,6 +153,14 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>textBrowser</tabstop>
<tabstop>textBrowser_2</tabstop>
<tabstop>textBrowser_3</tabstop>
<tabstop>textBrowser_4</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
Expand Down
36 changes: 36 additions & 0 deletions src/filefinder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <QDir>
#include <QTime>
#include <QtDebug>

#include "filefinder.h"

FileFinder::FileFinder(QObject *parent) :
QObject(parent)
{
}

void FileFinder::startSearch(const QString &startDir, bool recursive)
{
QTime time = QTime::currentTime();
time.start();
QFileInfoList list = searchForFiles(startDir, recursive);
emit finished(list);
}

QFileInfoList FileFinder::searchForFiles(const QString &startDir, bool recursive)
{
QDir dir(startDir);
QFileInfoList list;
foreach (QString file, dir.entryList(QStringList()<<"*.svg"<<"*.svgz", QDir::Files))
list += QFileInfo(startDir+"/"+file);
if (recursive && !stop) {
foreach (QString subdir, dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot))
list += searchForFiles(startDir+"/"+subdir, recursive);
}
return list;
}

void FileFinder::stopSearch()
{
stop = true;
}
26 changes: 26 additions & 0 deletions src/filefinder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef FILEFINDER_H
#define FILEFINDER_H

#include <QObject>
#include <QFileInfoList>

class FileFinder : public QObject
{
Q_OBJECT

public:
explicit FileFinder(QObject *parent = 0);

public slots:
void startSearch(const QString &startDir, bool recursive);
void stopSearch();

private:
bool stop;
QFileInfoList searchForFiles(const QString &startDir, bool recursive);

signals:
void finished(QFileInfoList);
};

#endif // FILEFINDER_H
100 changes: 94 additions & 6 deletions src/lineedit.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
#include <QPainter>
#include <QtDebug>

#include "lineedit.h"

LineEdit::LineEdit(QWidget *parent) :
QLineEdit(parent),
lbl(new QLabel(this))
QLineEdit(parent)
{
this->setObjectName("path");

angle = 0;
timerId = -1;

lbl = new QLabel(this);
lbl->setObjectName("files");
lbl->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
lbl->setStyleSheet("QLabel#files { border: none; padding: 4px; padding-left: 1px;"
"background-color: rgba(255, 255, 255, 0); color: #808080; }");
lbl->setStyleSheet("QLabel#files {border: none; padding: 4px; padding-left: 1px;"
"background-color: rgba(255, 255, 255, 0); color: #808080;}");
}

void LineEdit::initStyleOption(QStyleOptionFrameV2 *option) const
{
option->initFrom(this);
option->rect = contentsRect();
option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this);
option->midLineWidth = 0;
option->state |= QStyle::State_Sunken;
if (this->isReadOnly())
option->state |= QStyle::State_ReadOnly;
#ifdef QT_KEYPAD_NAVIGATION
if (hasEditFocus())
option->state |= QStyle::State_HasEditFocus;
#endif
option->features = QStyleOptionFrameV2::None;
}

LineEdit::~LineEdit()
Expand All @@ -21,8 +43,74 @@ void LineEdit::setValue(const int &value)
{
lbl->setText(QString(tr("%1 files")).arg(value));
QFontMetrics fm(QFont().defaultFamily());
// setStyleSheet(QString("padding-left: %1px;").arg(fm.width(lbl->text())+6));
// lbl->setFixedWidth(fm.width(lbl->text())+8);
// FIXME: make padding only for text
setStyleSheet(QString("padding-left: %1px;").arg(fm.boundingRect(lbl->text()).width()));
lbl->setFixedWidth(fm.boundingRect(lbl->text()).width()+8);
}

void LineEdit::showLoading(bool value)
{
if (value) {
angle = 0;
if (timerId == -1)
timerId = startTimer(100);
timerId = 0;
setStyleSheet(QString("padding-left: %1px;").arg(progressRect.height()));
} else {
if (timerId != -1)
killTimer(timerId);
timerId = -1;
update();
}

lbl->setVisible(!value);
}

void LineEdit::resizeEvent(QResizeEvent *)
{
QStyleOptionFrameV2 panel;
initStyleOption(&panel);
progressRect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
if (timerId != -1)
setStyleSheet(QString("padding-left: %1px;").arg(progressRect.height()));
}

void LineEdit::timerEvent(QTimerEvent *)
{
angle = (angle+30)%360;
update();
}

// code from QProgressIndicator
void LineEdit::paintEvent(QPaintEvent *e)
{
QLineEdit::paintEvent(e);

if (timerId == -1)
return;

int width = progressRect.height();

QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);

int outerRadius = (width-1)*0.5;
int innerRadius = (width-1)*0.5*0.38;

int capsuleHeight = outerRadius - innerRadius;
int capsuleWidth = (width > 32 ) ? capsuleHeight *.23 : capsuleHeight *.35;
int capsuleRadius = capsuleWidth/2;

for (int i = 0; i < 12; ++i) {
QColor color(Qt::black);
color.setAlphaF(1.0f - (i/12.0f));
p.setPen(Qt::NoPen);
p.setBrush(color);
p.save();
p.translate(rect().left()+width/2+3,rect().center().y());
p.rotate(angle - i*30.0f);
p.drawRoundedRect(-capsuleWidth*0.5, -(innerRadius+capsuleHeight), capsuleWidth,
capsuleHeight, capsuleRadius, capsuleRadius);
p.restore();
}
}
12 changes: 12 additions & 0 deletions src/lineedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@

#include <QLineEdit>
#include <QLabel>
#include <QStyleOptionFrameV2>

class LineEdit : public QLineEdit
{
Q_OBJECT

public:
explicit LineEdit(QWidget *parent = 0);
void showLoading(bool value);
~LineEdit();

private:
QLabel *lbl;
int angle;
int timerId;
QRect progressRect;
void initStyleOption(QStyleOptionFrameV2 *option) const;

public slots:
void setValue(const int &value);

protected:
void resizeEvent(QResizeEvent *);
void timerEvent(QTimerEvent *event);
void paintEvent(QPaintEvent *event);

};

#endif // LINEEDIT_H
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ int main(int argc, char *argv[])
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

// FIXME: rewrite to libraryPath()
// load translation for SVG Cleaner
QString locale = QLocale::system().name();
qDebug()<<"locale:"<<locale;
#ifdef Q_OS_WIN
QString path = SomeUtils::findFile(QString("svgcleaner_%1.qm").arg(locale),
"./translations/");
Expand Down
16 changes: 9 additions & 7 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ MainWindow::MainWindow(QWidget *parent) :
qRegisterMetaType<SVGInfo>("SVGInfo");

// setup GUI
actionWizard->setIcon(QIcon(":/wizard.svgz"));
actionStart->setIcon(QIcon(":/start.svgz"));
actionPause->setIcon(QIcon(":/pause.svgz"));
actionStop->setIcon(QIcon(":/stop.svgz"));
actionInfo->setIcon(QIcon(":/information.svgz"));
scrollArea->installEventFilter(this);
progressBar->hide();
itemScroll->hide();
actionPause->setVisible(false);

// load settings
settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
"svgcleaner", "config");
"svgcleaner", "config"); // FIXME: rewrite to static

// create sorting combobox
QWidget *w = new QWidget();
QWidget *w = new QWidget(toolBar);
w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
toolBar->addWidget(w);
cmbSort = new QComboBox();
Expand All @@ -50,13 +45,20 @@ MainWindow::MainWindow(QWidget *parent) :
connect(cmbSort,SIGNAL(currentIndexChanged(int)),this,SLOT(sortingChanged(int)));
toolBar->addWidget(cmbSort);

QString suffix = "<br><span style=\"color:#808080;\">%1</span>";
actionWizard->setToolTip(tr("Open the wizard")+suffix.arg("Ctrl+W"));
actionStart->setToolTip(tr("Start processing")+suffix.arg("Ctrl+R"));
actionPause->setToolTip(tr("Pause processing")+suffix.arg("Ctrl+R"));
actionStop->setToolTip(tr("Stop cleaning")+suffix.arg("Ctrl+S"));

actionCompareView->setChecked(settings->value("compareView",true).toBool());
on_actionCompareView_triggered();

// setup shortcuts
QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit,this);
connect(quitShortcut,SIGNAL(activated()),qApp,SLOT(quit()));

setContextMenuPolicy(Qt::NoContextMenu);
setWindowIcon(QIcon(":/svgcleaner.svgz"));
resize(1000,650);
}
Expand Down
Loading

0 comments on commit cad56c1

Please sign in to comment.