Permalink
Browse files

Font regeneration algorithm was changed, possible add new character w…

…ithout changing others;

Implemented Undo/Redo support.

Merge branch 'develop'
  • Loading branch information...
riuson committed Dec 23, 2012
2 parents d2c5421 + be86a69 commit b4efed4af0b9d1237c2c386ce81ffd3a6ab09a47
Showing with 1,759 additions and 904 deletions.
  1. +55 −0 classes/action-handlers/actionedithandlers.cpp
  2. +16 −16 interfaces/idatacontainer.h → classes/action-handlers/actionedithandlers.h
  3. +7 −6 classes/action-handlers/actionfilehandlers.cpp
  4. +1 −1 classes/action-handlers/actionfilehandlers.h
  5. +37 −24 classes/action-handlers/actionfonthandlers.cpp
  6. +1 −1 classes/action-handlers/actionfonthandlers.h
  7. +3 −7 classes/action-handlers/actionhandlersbase.cpp
  8. +6 −5 classes/action-handlers/actionhandlersbase.h
  9. +1 −1 classes/action-handlers/actionhelphandlers.cpp
  10. +1 −1 classes/action-handlers/actionhelphandlers.h
  11. +86 −74 classes/action-handlers/actionimagehandlers.cpp
  12. +1 −1 classes/action-handlers/actionimagehandlers.h
  13. +6 −6 classes/action-handlers/actionsetuphandlers.cpp
  14. +1 −1 classes/action-handlers/actionsetuphandlers.h
  15. +1 −1 classes/charactersmodel.cpp
  16. +1 −1 classes/charactersmodel.h
  17. +48 −26 classes/convert/bitmaphelper.cpp
  18. +14 −13 classes/convert/bitmaphelper.h
  19. +1 −1 classes/convert/bitstream.cpp
  20. +1 −1 classes/convert/bitstream.h
  21. +1 −1 classes/convert/conversion_options.h
  22. +1 −1 classes/convert/converterhelper.cpp
  23. +1 −1 classes/convert/converterhelper.h
  24. +5 −5 classes/convert/fonthelper.cpp
  25. +3 −3 classes/convert/fonthelper.h
  26. +130 −0 classes/data/datacontainer.cpp
  27. +32 −19 classes/{fontcontainer.h → data/datacontainer.h}
  28. +140 −0 classes/data/historykeeper.cpp
  29. +49 −0 classes/data/historykeeper.h
  30. +52 −0 classes/data/historyrecord.cpp
  31. +33 −0 classes/data/historyrecord.h
  32. +3 −3 classes/fontcharactersmodel.cpp
  33. +4 −4 classes/fontcharactersmodel.h
  34. +0 −81 classes/fontcontainer.cpp
  35. +3 −3 classes/parser.cpp
  36. +1 −1 classes/parser.h
  37. +1 −1 classes/preview-models/matrixitemdelegate.cpp
  38. +1 −1 classes/preview-models/matrixitemdelegate.h
  39. +1 −1 classes/preview-models/matrixpreviewmodel.cpp
  40. +1 −1 classes/preview-models/matrixpreviewmodel.h
  41. +1 −1 classes/revisioninfo.cpp
  42. +1 −1 classes/revisioninfo.h
  43. +1 −1 classes/settings/bitmapeditoroptions.cpp
  44. +1 −1 classes/settings/bitmapeditoroptions.h
  45. +1 −1 classes/settings/externaltooloptions.cpp
  46. +1 −1 classes/settings/externaltooloptions.h
  47. +1 −1 classes/settings/languageoptions.cpp
  48. +1 −1 classes/settings/languageoptions.h
  49. +1 −1 classes/settings/presets/fontoptions.cpp
  50. +1 −1 classes/settings/presets/fontoptions.h
  51. +1 −1 classes/settings/presets/imageoptions.cpp
  52. +1 −1 classes/settings/presets/imageoptions.h
  53. +1 −1 classes/settings/presets/matrixoptions.cpp
  54. +1 −1 classes/settings/presets/matrixoptions.h
  55. +1 −1 classes/settings/presets/prepareoptions.cpp
  56. +1 −1 classes/settings/presets/prepareoptions.h
  57. +1 −1 classes/settings/presets/preset.cpp
  58. +1 −1 classes/settings/presets/preset.h
  59. +1 −1 classes/settings/presets/templateoptions.cpp
  60. +1 −1 classes/settings/presets/templateoptions.h
  61. +1 −1 classes/settings/recentlist.cpp
  62. +1 −1 classes/settings/recentlist.h
  63. +1 −1 controls/dialogabout.cpp
  64. +1 −1 controls/dialogabout.h
  65. +28 −29 classes/bitmapcontainer.cpp → controls/dialogfontchanged.cpp
  66. +24 −24 classes/bitmapcontainer.h → controls/dialogfontchanged.h
  67. +60 −0 controls/dialogfontchanged.ui
  68. +6 −7 controls/dialogfontpreview.cpp
  69. +4 −4 controls/dialogfontpreview.h
  70. +1 −1 controls/dialogfontselect.cpp
  71. +1 −1 controls/dialogfontselect.h
  72. +1 −1 controls/dialogresize.cpp
  73. +1 −1 controls/dialogresize.h
  74. +1 −1 controls/dialogsavechanges.cpp
  75. +1 −1 controls/dialogsavechanges.h
  76. +301 −147 controls/editortabfont.cpp
  77. +38 −26 controls/editortabfont.h
  78. +139 −40 controls/editortabimage.cpp
  79. +24 −13 controls/editortabimage.h
  80. +53 −42 controls/mainwindow.cpp
  81. +4 −3 controls/mainwindow.h
  82. +25 −1 controls/mainwindow.ui
  83. +1 −1 controls/revisionlabel.cpp
  84. +1 −1 controls/revisionlabel.h
  85. +3 −3 controls/setup/dialogoptions.cpp
  86. +4 −4 controls/setup/dialogoptions.h
  87. +3 −3 controls/setup/dialogpreview.cpp
  88. +4 −4 controls/setup/dialogpreview.h
  89. +1 −1 controls/setup/parts/setuptabfont.cpp
  90. +1 −1 controls/setup/parts/setuptabfont.h
  91. +1 −1 controls/setup/parts/setuptabimage.cpp
  92. +1 −1 controls/setup/parts/setuptabimage.h
  93. +1 −1 controls/setup/parts/setuptabmatrix.cpp
  94. +1 −1 controls/setup/parts/setuptabmatrix.h
  95. +1 −1 controls/setup/parts/setuptabprepare.cpp
  96. +1 −1 controls/setup/parts/setuptabprepare.h
  97. +1 −1 controls/setup/parts/setuptabtemplates.cpp
  98. +1 −1 controls/setup/parts/setuptabtemplates.h
  99. +1 −1 controls/starttab.cpp
  100. +1 −1 controls/starttab.h
  101. +47 −75 controls/widgetbitmapeditor.cpp
  102. +9 −12 controls/widgetbitmapeditor.h
  103. +16 −8 interfaces/idocument.h
  104. +1 −1 interfaces/imainwindow.h
  105. +15 −8 lcd-image-converter.pro
  106. +1 −1 main.cpp
  107. +21 −0 resources/history.xml
  108. +135 −92 resources/lcd-image-converter-ru.ts
@@ -0,0 +1,55 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/
*/

#include "actionedithandlers.h"

#include "editortabimage.h"
#include "editortabfont.h"
#include "dialogfontselect.h"
#include <QFileDialog>
#include <QTextStream>
#include <QInputDialog>
#include <QLineEdit>
#include "parser.h"
#include "widgetbitmapeditor.h"
#include "imainwindow.h"
#include "datacontainer.h"
#include "idocument.h"
//-----------------------------------------------------------------------------
ActionEditHandlers::ActionEditHandlers(QObject *parent) :
ActionHandlersBase(parent)
{
}
//-----------------------------------------------------------------------------
void ActionEditHandlers::undo_triggered()
{
if (this->document() != NULL)
{
this->document()->undo();
}
}
//-----------------------------------------------------------------------------
void ActionEditHandlers::redo_triggered()
{
if (this->document() != NULL)
{
this->document()->redo();
}
}
//-----------------------------------------------------------------------------
@@ -1,6 +1,6 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* Copyright (C) 2010 riuson
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
* This program is free software: you can redistribute it and/or modify
@@ -17,25 +17,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/
*/

#ifndef IDATACONTAINER_H
#define IDATACONTAINER_H
#ifndef ACTIONEDITHANDLERS_H
#define ACTIONEDITHANDLERS_H
//-----------------------------------------------------------------------------
#include <QtGlobal>
#include <QString>
#include <QStringList>
#include <QObject>

#include "actionhandlersbase.h"
//-----------------------------------------------------------------------------
class QImage;
class IMainWindow;
//-----------------------------------------------------------------------------
class IDataContainer
class ActionEditHandlers : public ActionHandlersBase
{
Q_OBJECT
public:
virtual QImage *image(const QString &key) const = 0;
virtual void setImage(const QString &key, QImage *image) = 0;
virtual int count() const = 0;
virtual QStringList keys() const = 0;
explicit ActionEditHandlers(QObject *parent = 0);

public slots:
void undo_triggered();
void redo_triggered();
};
Q_DECLARE_INTERFACE (IDataContainer,
"riuson.lcd-image-converter/1.0"
)
//-----------------------------------------------------------------------------
#endif // IDATACONTAINER_H
#endif // ACTIONEDITHANDLERS_H
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -29,7 +29,8 @@
#include "parser.h"
#include "widgetbitmapeditor.h"
#include "imainwindow.h"
#include "idatacontainer.h"
#include "datacontainer.h"
#include "idocument.h"
//-----------------------------------------------------------------------------
ActionFileHandlers::ActionFileHandlers(QObject *parent) :
ActionHandlersBase(parent)
@@ -128,7 +129,9 @@ void ActionFileHandlers::rename_triggered()
&ok);
if (ok)
{
doc->beginChanges();
doc->setDocumentName(name);
doc->endChanges();
}
}
}
@@ -265,8 +268,7 @@ void ActionFileHandlers::openFile(const QString &filename)

QString name = this->mMainWindow->findAvailableName(info.baseName());

QString key = ed->editor()->currentImageKey();
ed->dataContainer()->setImage(key, &image);
ed->setImage(&image);

ed->setDocumentName(name);
ed->setChanged(false);
@@ -283,8 +285,7 @@ void ActionFileHandlers::openImage(QImage *image, const QString &documentName)

QString name = this->mMainWindow->findAvailableName(documentName);

QString key = ed->editor()->currentImageKey();
ed->dataContainer()->setImage(key, image);
ed->setImage(image);

ed->setDocumentName(name);
ed->setChanged(true);
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -30,8 +30,9 @@
#include "dialogfontpreview.h"
#include "imainwindow.h"
#include "idocument.h"
#include "idatacontainer.h"
#include "datacontainer.h"
#include "limits"
#include "bitmapeditoroptions.h"
//-----------------------------------------------------------------------------
ActionFontHandlers::ActionFontHandlers(QObject *parent) :
ActionHandlersBase(parent)
@@ -70,68 +71,76 @@ void ActionFontHandlers::fontChange_triggered()
monospaced = dialog.monospaced();
antialiasing = dialog.antialiasing();

this->document()->beginChanges();

etf->setFontCharacters(chars, family, style, size, monospaced, antialiasing);

this->document()->endChanges();
}
}
}
//-----------------------------------------------------------------------------
void ActionFontHandlers::fontInverse_triggered()
{
if (this->editor() != NULL)
if (this->document() != NULL)
{
WidgetBitmapEditor *editor = this->editor();
this->document()->beginChanges();;

QStringList keys = editor->dataContainer()->keys();
QStringList keys = this->document()->dataContainer()->keys();
QListIterator<QString> it(keys);
it.toFront();
while (it.hasNext())
{
QString key = it.next();
QImage *original = editor->dataContainer()->image(key);
const QImage *original = this->document()->dataContainer()->image(key);
QImage result(*original);
result.invertPixels();
editor->dataContainer()->setImage(key, &result);
this->document()->dataContainer()->setImage(key, &result);
}

this->document()->endChanges();
}
}
//-----------------------------------------------------------------------------
void ActionFontHandlers::fontResize_triggered()
{
if (this->editor() != NULL)
IDocument *doc = this->document();
if (doc != NULL)
{
WidgetBitmapEditor *editor = this->editor();
const QImage *original = doc->dataContainer()->image(doc->dataContainer()->keys().at(0));

QString key = editor->currentImageKey();
QImage *original = editor->dataContainer()->image(key);
DialogResize dialog(original->width(), original->height(), 0, 0, true, true, false, this->mMainWindow->parentWidget());
if (dialog.exec() == QDialog::Accepted)
{
int width, height, offsetX, offsetY;
bool center, changeWidth, changeHeight;
dialog.getResizeInfo(&width, &height, &offsetX, &offsetY, &center, &changeWidth, &changeHeight);

QStringList keys = editor->dataContainer()->keys();
this->document()->beginChanges();

QStringList keys = this->document()->dataContainer()->keys();
QListIterator<QString> it(keys);
it.toFront();
while (it.hasNext())
{
QString key = it.next();
original = editor->dataContainer()->image(key);
original = doc->dataContainer()->image(key);

QImage result = BitmapHelper::resize(original, width, height, offsetX, offsetY, center, changeWidth, changeHeight, editor->color2());
QImage result = BitmapHelper::resize(original, width, height, offsetX, offsetY, center, changeWidth, changeHeight, BitmapEditorOptions::color2());

editor->dataContainer()->setImage(key, &result);
doc->dataContainer()->setImage(key, &result);
}

this->document()->endChanges();
}
}
}
//-----------------------------------------------------------------------------
void ActionFontHandlers::fontMinimizeHeight_triggered()
{
if (this->editor() != NULL)
IDocument *doc = this->document();
if (doc != NULL)
{
WidgetBitmapEditor *editor = this->editor();

int left = std::numeric_limits<int>::max();
int top = std::numeric_limits<int>::max();
int right = 0;
@@ -141,13 +150,13 @@ void ActionFontHandlers::fontMinimizeHeight_triggered()
int height = 0;

// find limits
QStringList keys = editor->dataContainer()->keys();
QStringList keys = doc->dataContainer()->keys();
QListIterator<QString> it(keys);
it.toFront();
while (it.hasNext())
{
QString key = it.next();
QImage *original = editor->dataContainer()->image(key);
const QImage *original = doc->dataContainer()->image(key);

BitmapHelper::findEmptyArea(original, &l, &t, &r, &b);

@@ -167,18 +176,22 @@ void ActionFontHandlers::fontMinimizeHeight_triggered()
bool center, changeWidth, changeHeight;
dialog.getResizeInfo(&width, &height, &offsetX, &offsetY, &center, &changeWidth, &changeHeight);

QStringList keys = editor->dataContainer()->keys();
this->document()->beginChanges();

QStringList keys = doc->dataContainer()->keys();
QListIterator<QString> it(keys);
it.toFront();
while (it.hasNext())
{
QString key = it.next();
QImage *original = editor->dataContainer()->image(key);
const QImage *original = doc->dataContainer()->image(key);

QImage result = BitmapHelper::resize(original, original->width(), height, width, offsetY, center, changeWidth, changeHeight, editor->color2());
QImage result = BitmapHelper::resize(original, original->width(), height, width, offsetY, center, changeWidth, changeHeight, BitmapEditorOptions::color2());

editor->dataContainer()->setImage(key, &result);
doc->dataContainer()->setImage(key, &result);
}

this->document()->endChanges();
}
}
}
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -28,13 +28,9 @@ ActionHandlersBase::ActionHandlersBase(QObject *parent) :
this->mMainWindow = qobject_cast<IMainWindow *>(parent);
}
//-----------------------------------------------------------------------------
WidgetBitmapEditor *ActionHandlersBase::editor()
IDocument *ActionHandlersBase::document()
{
IDocument *doc = this->mMainWindow->currentDocument();
if (doc != NULL)
{
return doc->editor();
}
return NULL;
return doc;
}
//-----------------------------------------------------------------------------
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -24,21 +24,22 @@
//-----------------------------------------------------------------------------
class IMainWindow;
class WidgetBitmapEditor;
class IDocument;
//-----------------------------------------------------------------------------
class ActionHandlersBase : public QObject
{
Q_OBJECT
public:
explicit ActionHandlersBase(QObject *parent = 0);

protected:
IMainWindow *mMainWindow;
WidgetBitmapEditor *editor();
IDocument *document();

signals:

public slots:

};
//-----------------------------------------------------------------------------
#endif // ACTIONHANDLERSBASE_H
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
@@ -1,5 +1,5 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applciations.
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
Oops, something went wrong.

0 comments on commit b4efed4

Please sign in to comment.