Commit 9e143a4e authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Implemented type-safe translations for undo actions

See documentation to a KUndo2MagicString class.

Now KUndo2Command cannot accept a usual string as the operation text().
The supplied text must pass through the kundo2_i18n() function, which
tells the developer to use (qtundo-format) which is mandatory for all the
undo-related strings (because in some languages they should be shown in
different cases in undo/redo action and in undo history, and the
translators should use Magic Split for them).
parent c2e8bf64
#! /bin/sh
$XGETTEXT_QT *.cpp *.h -o $podir/kdgantt.pot
$XGETTEXT -kkundo2_i18nc:1c,2 -kkundo2_i18ncp:1c,2,3 *.cpp *.h -o $podir/kdgantt.pot
......@@ -9,6 +9,5 @@ RCFILES=`find . -name \*.rc \
$EXTRACTRC $RCFILES >> rc.cpp
perl extracti18n.pl > i18ndata
# ignore sdk/templates since it contains templates for use a future plugins, none of the strings there will ever be seen by any user
$XGETTEXT i18ndata rc.cpp `find . -name \*.cc -o -name \*.h -o -name \*.cpp | grep -v '/tests/' | grep -v './sdk/templates'` ui/kis_aboutdata.h -o $podir/krita.pot
$XGETTEXT -kkundo2_i18nc:1c,2 -kkundo2_i18ncp:1c,2,3 -kkundo2_i18nc:1c,2 -kkundo2_i18ncp:1c,2,3 i18ndata rc.cpp `find . -name \*.cc -o -name \*.h -o -name \*.cpp | grep -v '/tests/' | grep -v './sdk/templates'` ui/kis_aboutdata.h -o $podir/krita.pot
rm -f i18ndata
......@@ -166,7 +166,7 @@ void KisFilterSelectionsBenchmark::testUsualSelections(int num)
timer.restart();
for (int i = 0; i < num; i++) {
KisTransaction transac(0, projection, 0);
KisTransaction transac(projection, 0);
m_filter->process(m_device, projection, m_selection, filterRect, m_configuration, 0);
}
avTime = double(timer.elapsed()) / num;
......@@ -189,7 +189,7 @@ void KisFilterSelectionsBenchmark::testNoSelections(int num)
timer.restart();
for (int i = 0; i < num; i++) {
KisTransaction transac(0, projection, 0);
KisTransaction transac(projection, 0);
m_filter->process(m_device, projection, 0, filterRect, m_configuration, 0);
}
avTime = double(timer.elapsed()) / num;
......@@ -244,11 +244,11 @@ void KisFilterSelectionsBenchmark::testBitBltWOSelections(int num)
for (int i = 0; i < num; i++) {
KisPaintDeviceSP cacheDevice = new KisPaintDevice(projection->colorSpace());
KisTransaction transac(0, cacheDevice, 0);
KisTransaction transac(cacheDevice, 0);
m_filter->process(m_device, projection, 0, filterRect, m_configuration, 0);
KisPainter painter(projection);
painter.beginTransaction(0);
painter.beginTransaction();
painter.setCompositeOp(projection->colorSpace()->compositeOp(COMPOSITE_ALPHA_DARKEN));
painter.bitBlt(filterRect.topLeft(), cacheDevice, filterRect);
painter.deleteTransaction();
......@@ -275,11 +275,11 @@ void KisFilterSelectionsBenchmark::testBitBltSelections(int num)
for (int i = 0; i < num; i++) {
KisPaintDeviceSP cacheDevice = new KisPaintDevice(projection->colorSpace());
KisTransaction transac(0, cacheDevice, 0);
KisTransaction transac(cacheDevice, 0);
m_filter->process(m_device, cacheDevice, 0, filterRect, m_configuration, 0);
KisPainter gc(projection);
gc.beginTransaction(0);
gc.beginTransaction();
gc.setCompositeOp(projection->colorSpace()->compositeOp(COMPOSITE_ALPHA_DARKEN));
gc.setSelection(m_selection);
gc.bitBlt(filterRect.topLeft(), cacheDevice, filterRect);
......
......@@ -83,7 +83,7 @@ void KisFloodFillBenchmark::benchmarkFlood()
fillPainter.setPaintColor( fg );
fillPainter.setBackgroundColor( bg );
fillPainter.beginTransaction(i18n("Flood Fill"));
fillPainter.beginTransaction(kundo2_noi18n("Flood Fill"));
//fillPainter.setProgress(updater->startSubtask());
fillPainter.setOpacity(OPACITY_OPAQUE_U8);
......
......@@ -66,7 +66,7 @@ void KisGradientBenchmark::benchmarkGradient()
//setupPainter(&fillPainter);
fillPainter.setGradient(kograd);
fillPainter.beginTransaction(i18n("Gradient Fill"));
fillPainter.beginTransaction(kundo2_noi18n("Gradient Fill"));
//fillPainter.setProgress(updater->startSubtask());
fillPainter.setOpacity(OPACITY_OPAQUE_U8);
......
......@@ -128,7 +128,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
QLineF line(rect.topLeft(), rect.topLeft() + QPointF(rect.width(), 0));
if (createTransaction) {
painter->beginTransaction("test transaction");
painter->beginTransaction();
}
KisDistanceInformation currentDistance;
......
#! /bin/sh
$XGETTEXT *.cpp -o $podir/crashhandler.pot
$XGETTEXT -kkundo2_i18nc:1c,2 -kkundo2_i18ncp:1c,2,3 *.cpp -o $podir/crashhandler.pot
......@@ -45,7 +45,7 @@ public:
const QString &filterNameAfter,
const QString &xmlAfter,
bool useGeneratorRegistry)
: KUndo2Command(i18nc("(qtundo-format)", "Change Filter")) {
: KUndo2Command(kundo2_i18n("Change Filter")) {
m_node = node;
m_filterInterface = dynamic_cast<KisNodeFilterInterface*>(node.data());
Q_ASSERT(m_filterInterface);
......
......@@ -27,7 +27,7 @@
#include "kis_pixel_selection.h"
KisDeselectGlobalSelectionCommand::KisDeselectGlobalSelectionCommand(KisImageWSP image, KUndo2Command * parent) :
KUndo2Command(i18nc("(qtundo-format)", "Deselect"), parent)
KUndo2Command(kundo2_i18n("Deselect"), parent)
, m_image(image)
{
}
......
......@@ -24,8 +24,8 @@
#include <klocale.h>
KisImageChangeLayersCommand::KisImageChangeLayersCommand(KisImageWSP image, KisNodeSP oldRootLayer, KisNodeSP newRootLayer, const QString& name)
: KisImageCommand(name, image)
KisImageChangeLayersCommand::KisImageChangeLayersCommand(KisImageWSP image, KisNodeSP oldRootLayer, KisNodeSP newRootLayer)
: KisImageCommand(kundo2_noi18n("change-layer-command"), image)
{
m_oldRootLayer = oldRootLayer;
m_newRootLayer = newRootLayer;
......
......@@ -28,7 +28,7 @@ class KisImageChangeLayersCommand : public KisImageCommand
{
public:
KisImageChangeLayersCommand(KisImageWSP image, KisNodeSP oldRootLayer, KisNodeSP newRootLayer, const QString& name);
KisImageChangeLayersCommand(KisImageWSP image, KisNodeSP oldRootLayer, KisNodeSP newRootLayer);
virtual void redo();
virtual void undo();
......
......@@ -24,7 +24,7 @@
#include "kis_layer.h"
KisImageCommand::KisImageCommand(const QString& name, KisImageWSP image, KUndo2Command *parent)
KisImageCommand::KisImageCommand(const KUndo2MagicString& name, KisImageWSP image, KUndo2Command *parent)
: KUndo2Command(name, parent)
, m_image(image)
{
......
......@@ -39,7 +39,7 @@ public:
* @param name The name that will be shown in the ui
* @param image The image the command will be working on.
*/
KisImageCommand(const QString& name, KisImageWSP image, KUndo2Command *parent = 0);
KisImageCommand(const KUndo2MagicString& name, KisImageWSP image, KUndo2Command *parent = 0);
virtual ~KisImageCommand();
protected:
......
......@@ -29,7 +29,7 @@ KisImageLayerAddCommand::KisImageLayerAddCommand(KisImageWSP image,
KisNodeSP aboveThis,
bool doRedoUpdates,
bool doUndoUpdates)
: KisImageCommand(i18nc("(qtundo-format)", "Add Layer"), image),
: KisImageCommand(kundo2_i18n("Add Layer"), image),
m_index(-1),
m_doRedoUpdates(doRedoUpdates),
m_doUndoUpdates(doUndoUpdates)
......@@ -45,7 +45,7 @@ KisImageLayerAddCommand::KisImageLayerAddCommand(KisImageWSP image,
quint32 index,
bool doRedoUpdates,
bool doUndoUpdates)
: KisImageCommand(i18nc("(qtundo-format)", "Add Layer"), image),
: KisImageCommand(kundo2_i18n("Add Layer"), image),
m_index(index),
m_doRedoUpdates(doRedoUpdates),
m_doUndoUpdates(doUndoUpdates)
......
......@@ -34,7 +34,7 @@
KisImageLayerMoveCommand::KisImageLayerMoveCommand(KisImageWSP image, KisNodeSP layer, KisNodeSP newParent, KisNodeSP newAbove)
: KisImageCommand(i18nc("(qtundo-format)", "Move Layer"), image)
: KisImageCommand(kundo2_i18n("Move Layer"), image)
{
m_layer = layer;
m_newParent = newParent;
......@@ -46,7 +46,7 @@ KisImageLayerMoveCommand::KisImageLayerMoveCommand(KisImageWSP image, KisNodeSP
}
KisImageLayerMoveCommand::KisImageLayerMoveCommand(KisImageWSP image, KisNodeSP node, KisNodeSP newParent, quint32 index)
: KisImageCommand(i18nc("(qtundo-format)", "Move Layer"), image)
: KisImageCommand(kundo2_i18n("Move Layer"), image)
{
m_layer = node;
m_newParent = newParent;
......
......@@ -24,7 +24,7 @@
KisImageLayerRemoveCommand::KisImageLayerRemoveCommand(KisImageWSP image, KisNodeSP node)
: KisImageCommand(i18nc("(qtundo-format)", "Remove Layer"), image),
: KisImageCommand(kundo2_i18n("Remove Layer"), image),
m_node(node)
{
addSubtree(image, node);
......
......@@ -44,7 +44,7 @@ struct KisImageLayerRemoveCommandImpl::Private {
};
KisImageLayerRemoveCommandImpl::KisImageLayerRemoveCommandImpl(KisImageWSP image, KisNodeSP node, KUndo2Command *parent)
: KisImageCommand(i18nc("(qtundo-format)", "Remove Layer"), image, parent),
: KisImageCommand(kundo2_i18n("Remove Layer"), image, parent),
m_d(new Private(this))
{
m_d->node = node;
......
......@@ -24,7 +24,7 @@
KisImageLockCommand::KisImageLockCommand(KisImageWSP image, bool lockImage)
: KisImageCommand("lock image", image) // Not for translation, this is only ever used inside a macro command.
: KisImageCommand(kundo2_noi18n("lock image"), image)
{
Q_UNUSED(lockImage)
}
......
......@@ -25,7 +25,7 @@
#include "kis_undo_adapter.h"
KisImageNodeLowerCommand::KisImageNodeLowerCommand(KisImageWSP image, KisNodeSP node)
: KisImageCommand(i18nc("(qtundo-format)", "Lower"), image), m_node(node)
: KisImageCommand(kundo2_i18n("Lower"), image), m_node(node)
{
}
......
......@@ -25,7 +25,7 @@
#include "kis_undo_adapter.h"
KisImageNodeRaiseCommand::KisImageNodeRaiseCommand(KisImageWSP image, KisNodeSP node)
: KisImageCommand(i18nc("(qtundo-format)", "Raise"), image), m_node(node)
: KisImageCommand(kundo2_i18n("Raise"), image), m_node(node)
{
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment