Permalink
Browse files

Fixed:

 Cells size to fit big characters (Font Select dialog).

Added:
 New encodings;
 Sorting table characters by codes;
 Dialog to select new characters by range;
 Ability to specify custom font size;
 Control characters (0x01...0x1f) support;
 New tag 'out_images_max_blocks_count';
 Optional value of trailing bits;
 Custom prefix, suffix and delimiter for data blocks;
 Copy and Paste operations;
 Alpha-channel support;
 User-defined script to specify pixel's scan order.

Merge branch 'develop'
  • Loading branch information...
riuson committed Oct 28, 2013
2 parents ce530e1 + 469a35b commit c026d86327e5f04f3abec55993f611256557efd6
Showing with 5,045 additions and 2,819 deletions.
  1. +94 −7 classes/action-handlers/actionedithandlers.cpp
  2. +2 −0 classes/action-handlers/actionedithandlers.h
  3. +50 −60 classes/action-handlers/actionfilehandlers.cpp
  4. +3 −3 classes/action-handlers/actionfilehandlers.h
  5. +30 −29 classes/action-handlers/actionfonthandlers.cpp
  6. +4 −4 classes/action-handlers/actionhandlersbase.cpp
  7. +2 −2 classes/action-handlers/actionhandlersbase.h
  8. +7 −1 classes/action-handlers/actionhelphandlers.cpp
  9. +2 −1 classes/action-handlers/actionhelphandlers.h
  10. +86 −85 classes/action-handlers/actionimagehandlers.cpp
  11. +3 −2 classes/action-handlers/actionsetuphandlers.cpp
  12. +20 −0 classes/data/datacontainer.cpp
  13. +5 −0 classes/data/datacontainer.h
  14. +678 −0 classes/data/fontdocument.cpp
  15. +103 −0 classes/data/fontdocument.h
  16. +326 −0 classes/data/imagedocument.cpp
  17. +70 −0 classes/data/imagedocument.h
  18. +2 −1 classes/data/imagesmodel.cpp
  19. +17 −2 classes/parser/convert/bitstream.cpp
  20. +1 −0 classes/parser/convert/bitstream.h
  21. +8 −0 classes/parser/convert/conversion_options.h
  22. +212 −136 classes/parser/convert/converterhelper.cpp
  23. +6 −4 classes/parser/convert/converterhelper.h
  24. +89 −0 classes/parser/convert/convimage.cpp
  25. +63 −0 classes/parser/convert/convimage.h
  26. +54 −0 classes/parser/convert/fonthelper.cpp
  27. +2 −0 classes/parser/convert/fonthelper.h
  28. +93 −0 classes/parser/parsedimagedata.cpp
  29. +42 −0 classes/parser/parsedimagedata.h
  30. +134 −82 classes/parser/parser.cpp
  31. +10 −6 classes/parser/parser.h
  32. +14 −1 classes/parser/tags.cpp
  33. +3 −1 classes/parser/tags.h
  34. +30 −17 classes/settings/presets/fontoptions.cpp
  35. +7 −0 classes/settings/presets/fontoptions.h
  36. +73 −5 classes/settings/presets/imageoptions.cpp
  37. +12 −0 classes/settings/presets/imageoptions.h
  38. +100 −25 classes/settings/presets/prepareoptions.cpp
  39. +6 −0 classes/settings/presets/prepareoptions.h
  40. +6 −6 classes/settings/presets/templateoptions.cpp
  41. +49 −0 classes/settings/setupdialogoptions.cpp
  42. +16 −0 classes/settings/setupdialogoptions.h
  43. +167 −735 controls/fonts/font-editor/editortabfont.cpp
  44. +13 −42 controls/fonts/font-editor/editortabfont.h
  45. +3 −6 controls/fonts/font-new/charactersmodel.cpp
  46. +92 −38 controls/fonts/font-new/dialogfontselect.cpp
  47. +9 −3 controls/fonts/font-new/dialogfontselect.h
  48. +32 −4 controls/fonts/font-new/dialogfontselect.ui
  49. +88 −0 controls/fonts/font-range/dialogfontrange.cpp
  50. +30 −0 controls/fonts/font-range/dialogfontrange.h
  51. +146 −0 controls/fonts/font-range/dialogfontrange.ui
  52. +47 −312 controls/images/editortabimage.cpp
  53. +11 −28 controls/images/editortabimage.h
  54. +58 −51 controls/main/mainwindow.cpp
  55. +4 −3 controls/main/mainwindow.h
  56. +27 −2 controls/main/mainwindow.ui
  57. +1 −1 controls/setup/dialogexternaleditor.cpp
  58. +4 −2 controls/setup/dialogpreview.cpp
  59. +43 −0 controls/setup/parts/font/setuptabfont.cpp
  60. +7 −0 controls/setup/parts/font/setuptabfont.h
  61. +11 −1 controls/setup/parts/font/setuptabfont.ui
  62. +25 −0 controls/setup/parts/image/setuptabimage.cpp
  63. +4 −0 controls/setup/parts/image/setuptabimage.h
  64. +93 −1 controls/setup/parts/image/setuptabimage.ui
  65. +4 −0 controls/setup/parts/matrix/matrixitemdelegate.h
  66. +57 −9 controls/setup/parts/matrix/matrixpreviewmodel.cpp
  67. +1 −0 controls/setup/parts/matrix/matrixpreviewmodel.h
  68. +4 −0 controls/setup/parts/matrix/setuptabmatrix.cpp
  69. +158 −0 controls/setup/parts/prepare/demogenerator.cpp
  70. +71 −0 controls/setup/parts/prepare/demogenerator.h
  71. +112 −148 controls/setup/parts/prepare/setuptabprepare.cpp
  72. +11 −6 controls/setup/parts/prepare/setuptabprepare.h
  73. +122 −18 controls/setup/parts/prepare/setuptabprepare.ui
  74. +4 −0 controls/setup/parts/reordering/reorderingitemdelegate.h
  75. +2 −1 controls/setup/parts/reordering/reorderingpreviewmodel.cpp
  76. +2 −2 controls/setup/parts/templates/setuptabtemplates.cpp
  77. +1 −6 interfaces/idocument.h
  78. +47 −0 interfaces/ieditor.h
  79. +2 −2 interfaces/imainwindow.h
  80. +41 −2 lcd-image-converter.pro
  81. +5 −0 main.cpp
  82. BIN resources/demos/scanning.png
  83. +0 −369 resources/demos/scanning.svg
  84. BIN resources/demos/scanning_background.png
  85. +303 −0 resources/demos/scanning_background.svg
  86. BIN resources/demos/scanning_band.png
  87. +0 −394 resources/demos/scanning_band.svg
  88. +37 −0 resources/history.xml
  89. +271 −118 resources/lcd-image-converter-ru.ts
  90. +19 −2 resources/resources.qrc
  91. +10 −0 resources/scan_scripts/scan_bottom2top_backward.js
  92. +16 −0 resources/scan_scripts/scan_bottom2top_backward_band.js
  93. +10 −0 resources/scan_scripts/scan_bottom2top_forward.js
  94. +16 −0 resources/scan_scripts/scan_bottom2top_forward_band.js
  95. +10 −0 resources/scan_scripts/scan_left2right_backward.js
  96. +16 −0 resources/scan_scripts/scan_left2right_backward_band.js
  97. +10 −0 resources/scan_scripts/scan_left2right_forward.js
  98. +16 −0 resources/scan_scripts/scan_left2right_forward_band.js
  99. +10 −0 resources/scan_scripts/scan_right2left_backward.js
  100. +16 −0 resources/scan_scripts/scan_right2left_backward_band.js
  101. +10 −0 resources/scan_scripts/scan_right2left_forward.js
  102. +16 −0 resources/scan_scripts/scan_right2left_forward_band.js
  103. +10 −0 resources/scan_scripts/scan_top2bottom_backward.js
  104. +16 −0 resources/scan_scripts/scan_top2bottom_backward_band.js
  105. +10 −0 resources/scan_scripts/scan_top2bottom_forward.js
  106. +16 −0 resources/scan_scripts/scan_top2bottom_forward_band.js
  107. +18 −18 tests/parts/testbitmaphelper.cpp
  108. +11 −8 tests/parts/testconverterhelper.cpp
  109. +60 −0 tests/parts/testimageoptions.cpp
  110. +4 −0 tests/parts/testimageoptions.h
  111. +16 −4 tests/parts/testpresets.cpp
  112. +5 −3 tests/test.pro
@@ -19,13 +19,22 @@

#include "actionedithandlers.h"

#include "editortabimage.h"
#include "editortabfont.h"
#include "dialogfontselect.h"
#ifdef USED_QT5
#include <QtWidgets/QApplication>
#else
#include <QtGui/QApplication>
#endif

#include <QFileDialog>
#include <QTextStream>
#include <QInputDialog>
#include <QLineEdit>
#include <QMessageBox>
#include <QClipboard>
#include <QMimeData>
#include "editortabimage.h"
#include "editortabfont.h"
#include "dialogfontselect.h"
#include "parser.h"
#include "widgetbitmapeditor.h"
#include "imainwindow.h"
@@ -39,17 +48,95 @@ ActionEditHandlers::ActionEditHandlers(QObject *parent) :
//-----------------------------------------------------------------------------
void ActionEditHandlers::undo_triggered()
{
if (this->document() != NULL)
if (this->editor() != NULL)
{
this->document()->undo();
this->editor()->document()->undo();
}
}
//-----------------------------------------------------------------------------
void ActionEditHandlers::redo_triggered()
{
if (this->document() != NULL)
if (this->editor() != NULL)
{
this->editor()->document()->redo();
}
}
//-----------------------------------------------------------------------------
void ActionEditHandlers::copy_triggered()
{
if (this->editor() != NULL)
{
QStringList keys = this->editor()->selectedKeys();

if (keys.length() > 0)
{
QString key = keys.at(0);

if (keys.length() > 1)
{
QString message = tr("More than 1 image(s) selected. But only one will be copied - \"%1\".", "Warning about image copy").arg(key);

QMessageBox msgBox(this->mMainWindow->parentWidget());
msgBox.setTextFormat(Qt::PlainText);
msgBox.setWindowTitle(tr("Copy - Attention"));
msgBox.setText(message);
msgBox.setStandardButtons(QMessageBox::Ok| QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
if (msgBox.exec() != QMessageBox::Ok)
{
return;
}
}

const QImage *image = this->editor()->document()->dataContainer()->image(key);

QClipboard *clipboard = QApplication::clipboard();
clipboard->setImage(*image);
}
}
}
//-----------------------------------------------------------------------------
void ActionEditHandlers::paste_triggered()
{
if (this->editor() != NULL)
{
this->document()->redo();
QClipboard *clipboard = QApplication::clipboard();
if (clipboard->mimeData()->hasImage())
{
QImage image = clipboard->image();

QStringList keys = this->editor()->selectedKeys();

if (keys.length() > 0)
{
if (keys.length() > 1)
{
QString message = tr("More than 1 image(s) selected. All of them will be overwritten.", "Warning about image paste");

QMessageBox msgBox(this->mMainWindow->parentWidget());
msgBox.setTextFormat(Qt::PlainText);
msgBox.setWindowTitle(tr("Paste - Attention"));
msgBox.setText(message);
msgBox.setStandardButtons(QMessageBox::Ok| QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
if (msgBox.exec() != QMessageBox::Ok)
{
return;
}
}

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

QStringListIterator iterator(keys);
while (iterator.hasNext())
{
QString key = iterator.next();
this->editor()->document()->dataContainer()->setImage(key, &image);
}

this->editor()->document()->endChanges();
}
}
}
}
//-----------------------------------------------------------------------------
@@ -36,6 +36,8 @@ class ActionEditHandlers : public ActionHandlersBase
public slots:
void undo_triggered();
void redo_triggered();
void copy_triggered();
void paste_triggered();
};
//-----------------------------------------------------------------------------
#endif // ACTIONEDITHANDLERS_H
@@ -49,12 +49,12 @@ void ActionFileHandlers::newImage_triggered()
if (ok)
{
EditorTabImage *ed = new EditorTabImage(this->mMainWindow->parentWidget());
this->connect(ed, SIGNAL(documentChanged(bool,QString,QString)), SLOT(documentChanged(bool,QString,QString)));
this->connect(ed, SIGNAL(documentChanged()), SLOT(documentChanged()));

emit this->tabCreated(ed);

name = this->mMainWindow->findAvailableName(name);
ed->setDocumentName(name);
ed->setChanged(false);
emit this->tabCreated(ed, name, ed->fileName());
ed->document()->setDocumentName(name);
}
}
//-----------------------------------------------------------------------------
@@ -73,7 +73,7 @@ void ActionFileHandlers::newFont_triggered()
if (dialog.exec() == QDialog::Accepted)
{
EditorTabFont *ed = new EditorTabFont(this->mMainWindow->parentWidget());
this->connect(ed, SIGNAL(documentChanged(bool,QString,QString)), SLOT(documentChanged(bool,QString,QString)));
this->connect(ed, SIGNAL(documentChanged()), SLOT(documentChanged()));

QString chars = dialog.characters();
int size;
@@ -88,10 +88,10 @@ void ActionFileHandlers::newFont_triggered()

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

emit this->tabCreated(ed);

name = this->mMainWindow->findAvailableName(name);
ed->setDocumentName(name);
ed->setChanged(false);
emit this->tabCreated(ed, name, ed->fileName());
ed->document()->setDocumentName(name);
}
}
}
@@ -101,7 +101,7 @@ void ActionFileHandlers::open_triggered()
QFileDialog dialog(this->mMainWindow->parentWidget());
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setFileMode(QFileDialog::ExistingFiles);
dialog.setFilter(tr("XML Files (*.xml);;Images (*.bmp *.gif *.jpg *.jpeg *.png *.pbm *.pgm *.ppm *.tiff *.xbm *.xpm)"));
dialog.setNameFilter(tr("XML Files (*.xml);;Images (*.bmp *.gif *.jpg *.jpeg *.png *.pbm *.pgm *.ppm *.tiff *.xbm *.xpm)"));
dialog.setWindowTitle(tr("Open xml or image file"));

if (dialog.exec() == QDialog::Accepted)
@@ -118,52 +118,52 @@ void ActionFileHandlers::open_triggered()
void ActionFileHandlers::rename_triggered()
{
bool ok;
IDocument *doc = this->mMainWindow->currentDocument();
if (doc != NULL)
IEditor *editor = this->editor();
if (editor != NULL)
{
QString name = QInputDialog::getText(this->mMainWindow->parentWidget(),
tr("Rename"),
tr("New name:"),
QLineEdit::Normal,
doc->documentName(),
editor->document()->documentName(),
&ok);
if (ok)
{
doc->beginChanges();
doc->setDocumentName(name);
doc->endChanges();
editor->document()->beginChanges();
editor->document()->setDocumentName(name);
editor->document()->endChanges();
}
}
}
//-----------------------------------------------------------------------------
void ActionFileHandlers::save_triggered()
{
IDocument *doc = this->mMainWindow->currentDocument();
if (doc != NULL)
IEditor *editor = this->editor();
if (editor != NULL)
{
if (QFile::exists(doc->fileName()))
doc->save(doc->fileName());
if (QFile::exists(editor->document()->documentFilename()))
editor->document()->save(editor->document()->documentFilename());
else
this->saveAs_triggered();
}
}
//-----------------------------------------------------------------------------
void ActionFileHandlers::saveAs_triggered()
{
IDocument *doc = this->mMainWindow->currentDocument();
if (doc != NULL)
IEditor *editor = this->editor();
if (editor != NULL)
{
QFileDialog dialog(this->mMainWindow->parentWidget());
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.selectFile(doc->fileName());
dialog.selectFile(editor->document()->documentFilename());
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setFilter(tr("XML Files (*.xml)"));
dialog.setNameFilter(tr("XML Files (*.xml)"));
dialog.setDefaultSuffix(QString("xml"));
dialog.setWindowTitle(tr("Save file as"));
if (dialog.exec() == QDialog::Accepted)
{
QString filename = dialog.selectedFiles().at(0);
doc->save(filename);
editor->document()->save(filename);

emit this->rememberFilename(filename);
}
@@ -177,11 +177,10 @@ void ActionFileHandlers::close_triggered()
//-----------------------------------------------------------------------------
void ActionFileHandlers::convert_triggered()
{
QWidget *w = this->mMainWindow->currentTab();
IDocument *doc = dynamic_cast<IDocument *> (w);
if (doc != NULL)
IEditor *editor = this->mMainWindow->currentEditor();
if (editor != NULL)
{
doc->convert(true);
editor->document()->convert(true);
}
}
//-----------------------------------------------------------------------------
@@ -193,10 +192,10 @@ void ActionFileHandlers::convertAll_triggered()

for (int i = 0; i < list.count(); i++)
{
IDocument *doc = dynamic_cast<IDocument *> (list.at(i));
if (doc != NULL)
IEditor *editor = dynamic_cast<IEditor *> (list.at(i));
if (editor != NULL)
{
doc->convert(false);
editor->document()->convert(false);
}
}
}
@@ -216,15 +215,17 @@ void ActionFileHandlers::openFile(const QString &filename)
if (file.open(QIODevice::ReadWrite))
{
QTextStream stream(&file);
QRegExp regImage("<data.+type=\"image\"", Qt::CaseInsensitive);
QRegExp regFont("<data.+type=\"font\"", Qt::CaseInsensitive);
while (!stream.atEnd())
{
QString readedLine = stream.readLine();
if (readedLine.contains("<data type=\"image\""))
if (readedLine.contains(regImage))
{
isImage = true;
break;
}
if (readedLine.contains("<data type=\"font\""))
if (readedLine.contains(regFont))
{
isFont = true;
break;
@@ -245,26 +246,26 @@ void ActionFileHandlers::openFile(const QString &filename)
if (isImage)
{
EditorTabImage *ed = new EditorTabImage(this->mMainWindow->parentWidget());
this->connect(ed, SIGNAL(documentChanged(bool,QString,QString)), SLOT(documentChanged(bool,QString,QString)));
this->connect(ed, SIGNAL(documentChanged()), SLOT(documentChanged()));

emit this->tabCreated(ed, "", filename);
ed->load(filename);
emit this->tabCreated(ed);
ed->document()->load(filename);
}
if (isFont)
{
EditorTabFont *ed = new EditorTabFont(this->mMainWindow->parentWidget());
this->connect(ed, SIGNAL(documentChanged(bool,QString,QString)), SLOT(documentChanged(bool,QString,QString)));
this->connect(ed, SIGNAL(documentChanged()), SLOT(documentChanged()));

emit this->tabCreated(ed, "", filename);
ed->load(filename);
emit this->tabCreated(ed);
ed->document()->load(filename);
}
if (isImageBinary)
{
QImage image;
if (image.load(filename))
{
EditorTabImage *ed = new EditorTabImage(this->mMainWindow->parentWidget());
this->connect(ed, SIGNAL(documentChanged(bool,QString,QString)), SLOT(documentChanged(bool,QString,QString)));
this->connect(ed, SIGNAL(documentChanged()), SLOT(documentChanged()));

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

@@ -276,13 +277,12 @@ void ActionFileHandlers::openFile(const QString &filename)
while (iterator.hasNext())
{
QString key = iterator.next();
ed->dataContainer()->setImage(key, &image);
ed->document()->dataContainer()->setImage(key, &image);
}
}

ed->setDocumentName(name);
ed->setChanged(false);
emit this->tabCreated(ed, name, filename);
emit this->tabCreated(ed);
ed->document()->setDocumentName(name);
}
}
}
@@ -291,7 +291,7 @@ void ActionFileHandlers::openFile(const QString &filename)
void ActionFileHandlers::openImage(QImage *image, const QString &documentName)
{
EditorTabImage *ed = new EditorTabImage(this->mMainWindow->parentWidget());
this->connect(ed, SIGNAL(documentChanged(bool,QString,QString)), SLOT(documentChanged(bool,QString,QString)));
this->connect(ed, SIGNAL(documentChanged()), SLOT(documentChanged()));

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

@@ -303,28 +303,18 @@ void ActionFileHandlers::openImage(QImage *image, const QString &documentName)
while (iterator.hasNext())
{
QString key = iterator.next();
ed->dataContainer()->setImage(key, image);
ed->document()->dataContainer()->setImage(key, image);
}
}

ed->setDocumentName(name);
ed->setChanged(true);

emit this->tabCreated(ed, name, "");
ed->document()->setDocumentName(name);

emit this->tabChanged(ed, "* " + name, "");
emit this->tabCreated(ed);
}
//-----------------------------------------------------------------------------
void ActionFileHandlers::documentChanged(bool changed, const QString &documentName, const QString &filename)
void ActionFileHandlers::documentChanged()
{
QWidget *w = qobject_cast<QWidget *>(sender());
IDocument *doc = dynamic_cast<IDocument *> (w);
if (doc != NULL)
{
if (changed)
emit this->tabChanged(w, "* " + documentName, filename);
else
emit this->tabChanged(w, documentName, filename);
}
emit this->tabChanged(w);
}
//-----------------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit c026d86

Please sign in to comment.