Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
riuson committed Jun 24, 2012
2 parents 0dc5abc + 36e5243 commit 53c6001d23038f699ee4aeb30e46a1f77c7fc956
@@ -5,11 +5,12 @@ _windows/
.obj/
Makefile.*
Makefile
.user
*.user
qrc_*
moc_*
.user/
.Debug
.Release
.sh
.qm
*.Debug
*.Release
*.sh
*.qm
version-included.txt
@@ -287,6 +287,10 @@ QString Converter::convert(IDocument *document,
tags["encoding"] = "UTF-8";
}

this->addPreprocessInfo(tags);

this->addOrderInfo(tags);

this->parse(templateString, result, tags, document);

return result;
@@ -490,3 +494,55 @@ QString Converter::hexCode(const QChar &ch, const QString &encoding)
return result;
}
//-----------------------------------------------------------------------------
void Converter::addOrderInfo(QMap<QString, QString> &tags)
{
if (this->swapBytes())
tags.insert("swapBytes", "yes");
else
tags.insert("swapBytes", "no");

if (this->mirror())
tags.insert("mirror", "yes");
else
tags.insert("mirror", "no");

if (this->pack())
tags.insert("pack", "yes");
else
tags.insert("pack", "no");
}
//-----------------------------------------------------------------------------
void Converter::addPreprocessInfo(QMap<QString, QString> &tags)
{
switch (this->mPreprocessTransform & 0x03)
{
case BitmapHelper::Rotate90:
tags.insert("rotate", "90°");
break;
case BitmapHelper::Rotate180:
tags.insert("rotate", "180°");
break;
case BitmapHelper::Rotate270:
tags.insert("rotate", "270°");
break;
case BitmapHelper::None:
tags.insert("rotate", "none");
break;
}

if ((this->mPreprocessTransform & BitmapHelper::FlipHorizontal) == BitmapHelper::FlipHorizontal)
tags.insert("flipHorizontal", "yes");
else
tags.insert("flipHorizontal", "no");

if ((this->mPreprocessTransform & BitmapHelper::FlipVertical) == BitmapHelper::FlipVertical)
tags.insert("flipVertical", "yes");
else
tags.insert("flipVertical", "no");

if ((this->mPreprocessTransform & BitmapHelper::Inverse) == BitmapHelper::Inverse)
tags.insert("inverse", "yes");
else
tags.insert("inverse", "no");
}
//-----------------------------------------------------------------------------
@@ -71,6 +71,8 @@ class Converter : public QObject, public IConverter
void parseImagesTable(const QString &templateString, QString &resultString, QMap<QString, QString> &tags, IDocument *doc);
void parseSimple(const QString &templateString, QString &resultString, QMap<QString, QString> &tags, IDocument *doc);
QString hexCode(const QChar &ch, const QString &encoding);
void addOrderInfo(QMap<QString, QString> &tags);
void addPreprocessInfo(QMap<QString, QString> &tags);
};
//-----------------------------------------------------------------------------
#endif // CONVERTER_H
@@ -0,0 +1,59 @@
#include "recentlist.h"
//-----------------------------------------------------------------------------
#include <QStringList>
#include <QStringListIterator>
#include <QSettings>
//-----------------------------------------------------------------------------
RecentList::RecentList(QObject *parent) :
QObject(parent)
{
this->mFiles = new QStringList();

// load from settings
QSettings sett;
int size = sett.beginReadArray("recent");
for (int i = 0; i < size; i++)
{
sett.setArrayIndex(i);
this->mFiles->append(sett.value("filename").toString());
}
sett.endArray();
}
//-----------------------------------------------------------------------------
RecentList::~RecentList()
{
// save to settings
QSettings sett;
sett.beginWriteArray("recent");
QStringListIterator recentFilesIterator(*this->mFiles);
int i = 0;
while (recentFilesIterator.hasNext())
{
sett.setArrayIndex(i++);
sett.setValue("filename", recentFilesIterator.next());
}
sett.endArray();

delete this->mFiles;
}
//-----------------------------------------------------------------------------
void RecentList::add(const QString &filename)
{
if (this->mFiles->contains(filename))
this->mFiles->removeOne(filename);
this->mFiles->insert(0, filename);

if (this->mFiles->count() > MaxRecentFiles)
{
for (int i = this->mFiles->count() - 1; i >= 10; i--)
this->mFiles->removeAt(i);
}

emit this->listChanged();
}
//-----------------------------------------------------------------------------
const QStringList * RecentList::files() const
{
return this->mFiles;
}
//-----------------------------------------------------------------------------
@@ -0,0 +1,27 @@
#ifndef RECENTLIST_H
#define RECENTLIST_H
//-----------------------------------------------------------------------------
#include <QObject>
//-----------------------------------------------------------------------------
//class QStringList;
//class QStringListIterator;
//-----------------------------------------------------------------------------
class RecentList : public QObject
{
Q_OBJECT
public:
explicit RecentList(QObject *parent = 0);
virtual ~RecentList();
void add(const QString &filename);
enum { MaxRecentFiles = 10 };
const QStringList * files() const;

private:
QStringList *mFiles;
signals:
void listChanged();
public slots:

};
//-----------------------------------------------------------------------------
#endif // RECENTLIST_H
@@ -29,15 +29,71 @@ DialogAbout::DialogAbout(QWidget *parent) :
{
ui->setupUi(this);

QFile file(":/text/gpl3");
if (file.open(QIODevice::ReadOnly))
// hide ? button from title
this->setWindowFlags(this->windowFlags() & (~Qt::WindowContextHelpButtonHint));

// update icon
QIcon icon;
icon.addFile(":/images/icon64", QSize(64, 64));
this->setWindowIcon(icon);

// load license text to textEdit
QFile file_license(":/text/gpl3");
if (file_license.open(QIODevice::ReadOnly))
{
QTextStream stream(&file);
QTextStream stream(&file_license);
QString license = stream.readAll();
file.close();
file_license.close();

this->ui->textEdit->setText(license);
}

// load version info
QFile file_version(":/text/version_info");
if (file_version.open(QIODevice::ReadOnly))
{
QTextStream stream(&file_version);
QString version = stream.readAll();
file_version.close();

// git-commit-info d693078 Sat May 26 22:30:51 2012 +0600

QString start = "git-commit-info ";
if (version.startsWith(start, Qt::CaseInsensitive))
{
// get hash of commit
QRegExp reg = QRegExp("[0-9a-f]+", Qt::CaseInsensitive);
int index;
if ((index = reg.indexIn(version, start.length())) >= 0)
{
QString hash = reg.cap();

// get date
QString date = version.mid(index + hash.length() + 1);

// show
QString about = this->ui->labelInfo->text();
QString formattedAbout = QString(about).arg(hash, date);
this->ui->labelInfo->setText(formattedAbout);
}
}
}
else
{
QString about = this->ui->labelInfo->text();
QString formattedAbout = QString(about).arg("unknown", "???");
this->ui->labelInfo->setText(formattedAbout);
}

// show Qt version
{
QString about = this->ui->labelInfo->text();
QString formattedAbout = QString(about).arg(qVersion());
this->ui->labelInfo->setText(formattedAbout);
}

// focus on Close button
this->ui->buttonBox->setFocus();
}
//-----------------------------------------------------------------------------
DialogAbout::~DialogAbout()
@@ -18,22 +18,53 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>LCD Image Converter&lt;br/&gt;
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources/resources.qrc">:/images/icon96</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelInfo">
<property name="text">
<string>LCD Image Converter&lt;br/&gt;
Tool to create image and font source files for embedded applications.&lt;br/&gt;
&lt;br/&gt;
Author:
&lt;a href=&quot;mailto:riuson@gmail.com?subject=lcd-image-converter&amp;&quot;&gt;riuson@gmail.com&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://code.google.com/p/lcd-image-converter&quot;&gt;http://code.google.com/p/lcd-image-converter&lt;/a&gt;</string>
</property>
<property name="openExternalLinks">
Project's home page: &lt;a href=&quot;http://code.google.com/p/lcd-image-converter&quot;&gt;http://code.google.com/p/lcd-image-converter&lt;/a&gt;
&lt;hr/&gt;
Version: &lt;b&gt;%1&lt;/b&gt; from &lt;i&gt;%2&lt;/i&gt;&lt;br/&gt;
Qt: %3</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@@ -46,7 +77,9 @@ Author:
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../resources/resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
@@ -291,6 +291,11 @@ bool EditorTabFont::changed()
return this->mDataChanged;
}
//-----------------------------------------------------------------------------
void EditorTabFont::setChanged(bool value)
{
this->mDataChanged = value;
}
//-----------------------------------------------------------------------------
QString EditorTabFont::fileName()
{
return this->mFileName;
@@ -303,8 +308,12 @@ QString EditorTabFont::documentName()
//-----------------------------------------------------------------------------
void EditorTabFont::setDocumentName(const QString &value)
{
this->mDocumentName = value;
emit this->dataChanged();
if (this->mDocumentName != value)
{
this->mDocumentName = value;
this->mDataChanged = true;
emit this->dataChanged();
}
}
//-----------------------------------------------------------------------------
IDataContainer *EditorTabFont::dataContainer()
@@ -44,6 +44,7 @@ class EditorTabFont : public QWidget, public IDocument
bool load(const QString &fileName);
bool save(const QString &fileName);
bool changed();
void setChanged(bool value);
QString fileName();
QString documentName();
void setDocumentName(const QString &value);
@@ -169,6 +169,11 @@ bool EditorTabImage::changed()
return this->mDataChanged;
}
//-----------------------------------------------------------------------------
void EditorTabImage::setChanged(bool value)
{
this->mDataChanged = value;
}
//-----------------------------------------------------------------------------
QString EditorTabImage::fileName()
{
return this->mFileName;
@@ -181,8 +186,12 @@ QString EditorTabImage::documentName()
//-----------------------------------------------------------------------------
void EditorTabImage::setDocumentName(const QString &value)
{
this->mDocumentName = value;
emit this->dataChanged();
if (this->mDocumentName != value)
{
this->mDocumentName = value;
this->mDataChanged = true;
emit this->dataChanged();
}
}
//-----------------------------------------------------------------------------
IDataContainer *EditorTabImage::dataContainer()
Oops, something went wrong.

0 comments on commit 53c6001

Please sign in to comment.