Commit 7a28649a authored by L. E. Segovia's avatar L. E. Segovia

Extract strings for translation

This also includes certain optimizations (QString::null, isEmpty, redundant constructors, etc...)
parent 58880c55
# Copyright Disney Enterprises, Inc. All rights reserved.
# Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License
......@@ -202,7 +203,7 @@ if (ENABLE_QT5)
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
endif()
else()
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
find_package(Qt4 4.2.0 COMPONENTS QtCore QtGui QtOpenGL)
if (Qt4_FOUND)
message(STATUS "Qt4 Enabled")
message(STATUS "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}")
......
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -33,6 +34,7 @@
#include <QSortFilterProxyModel>
#include <QFileDialog>
#include <QMessageBox>
#include <QTextStream>
#include <cassert>
#include "ExprEditor.h"
......@@ -79,7 +81,7 @@ class ExprTreeItem {
// std::cerr<<"is dir and populating "<<path.toStdString()<<std::endl;
for (QList<QFileInfo>::ConstIterator it = infos.constBegin(); it != infos.constEnd(); ++it) {
const QFileInfo* fi = &*it;
if (fi->isDir() || fi->fileName().endsWith(".se")) {
if (fi->isDir() || fi->fileName().endsWith(QString::fromLatin1(".se"))) {
addChild(new ExprTreeItem(this, fi->fileName(), fi->filePath()));
}
}
......@@ -130,7 +132,7 @@ class ExprTreeModel : public QAbstractItemModel {
ExprTreeItem* root;
public:
ExprTreeModel() : root(new ExprTreeItem(0, "", "")) {}
ExprTreeModel() : root(new ExprTreeItem(0, QString(), QString())) {}
~ExprTreeModel() { delete root; }
......@@ -146,7 +148,7 @@ class ExprTreeModel : public QAbstractItemModel {
endResetModel();
}
void addPath(const char* label, const char* path) { root->addChild(new ExprTreeItem(root, label, path)); }
void addPath(const char* label, const char* path) { root->addChild(new ExprTreeItem(root, QString::fromLatin1(label), QString::fromLatin1(path))); }
QModelIndex parent(const QModelIndex& index) const {
if (!index.isValid()) return QModelIndex();
......@@ -240,7 +242,7 @@ class ExprTreeFilterModel : public QSortFilterProxyModel {
ExprBrowser::~ExprBrowser() { delete treeModel; }
ExprBrowser::ExprBrowser(QWidget* parent, ExprEditor* editor)
: QWidget(parent), editor(editor), _context(""), _searchPath(""), _applyOnSelect(true) {
: QWidget(parent), editor(editor), _context(QString()), _searchPath(QString()), _applyOnSelect(true) {
QVBoxLayout* rootLayout = new QVBoxLayout;
rootLayout->setMargin(0);
this->setLayout(rootLayout);
......@@ -249,7 +251,7 @@ ExprBrowser::ExprBrowser(QWidget* parent, ExprEditor* editor)
exprFilter = new QLineEdit();
connect(exprFilter, SIGNAL(textChanged(const QString&)), SLOT(filterChanged(const QString&)));
searchAndClearLayout->addWidget(exprFilter, 2);
QPushButton* clearFilterButton = new QPushButton("X");
QPushButton* clearFilterButton = new QPushButton(tr("X"));
clearFilterButton->setFixedWidth(24);
searchAndClearLayout->addWidget(clearFilterButton, 1);
rootLayout->addLayout(searchAndClearLayout);
......@@ -278,8 +280,8 @@ void ExprBrowser::addPath(const std::string& name, const std::string& path) {
}
void ExprBrowser::setSearchPath(const QString& context, const QString& path) {
_context = context.toStdString();
_searchPath = path.toStdString();
_context = context;
_searchPath = path;
}
std::string ExprBrowser::getSelectedPath() {
......@@ -293,7 +295,7 @@ std::string ExprBrowser::getSelectedPath() {
}
void ExprBrowser::selectPath(const char* path) {
QModelIndex index = treeModel->find(path);
QModelIndex index = treeModel->find(QString::fromLatin1(path));
treeNew->setCurrentIndex(proxyModel->mapFromSource(index));
}
......@@ -308,10 +310,12 @@ void ExprBrowser::handleSelection(const QModelIndex& current, const QModelIndex&
QModelIndex realCurrent = proxyModel->mapToSource(current);
ExprTreeItem* item = (ExprTreeItem*)realCurrent.internalPointer();
QString path = item->path;
if (path.endsWith(".se")) {
std::ifstream file(path.toStdString().c_str());
std::string fileContents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
editor->setExpr(fileContents, _applyOnSelect);
if (path.endsWith(QString::fromLatin1(".se"))) {
QFile file(path);
if (file.open(QIODevice::ReadOnly)) {
QTextStream fileContents(&file);
editor->setExpr(fileContents.readAll(), _applyOnSelect);
}
}
}
}
......@@ -331,7 +335,7 @@ void ExprBrowser::clearFilter() { exprFilter->clear(); }
void ExprBrowser::filterChanged(const QString& str) {
proxyModel->setFilterRegExp(QRegExp(str));
proxyModel->setFilterKeyColumn(0);
if (str != "") {
if (!str.isEmpty()) {
treeNew->expandAll();
} else {
treeNew->collapseAll();
......@@ -339,16 +343,16 @@ void ExprBrowser::filterChanged(const QString& str) {
}
void ExprBrowser::saveExpressionAs() {
QString path = QFileDialog::getSaveFileName(this, "Save Expression", QString::fromStdString(_userExprDir), "*.se");
QString path = QFileDialog::getSaveFileName(this, tr("Save Expression"), QString::fromStdString(_userExprDir), tr("*.se"));
if (path.length() > 0) {
std::ofstream file(path.toStdString().c_str());
if (!file) {
QString msg = QString("Could not open file %1 for writing").arg(path);
QMessageBox::warning(this, "Error", QString("<font face=fixed>%1</font>").arg(msg));
QString msg = tr("Could not open file %1 for writing").arg(path);
QMessageBox::warning(this, tr("Error"), QString::fromLatin1("<font face=fixed>%1</font>").arg(msg));
return;
}
file << editor->getExpr();
file << editor->getExpr().toStdString();
file.close();
update();
......@@ -357,16 +361,16 @@ void ExprBrowser::saveExpressionAs() {
}
void ExprBrowser::saveLocalExpressionAs() {
QString path = QFileDialog::getSaveFileName(this, "Save Expression", QString::fromStdString(_localExprDir), "*.se");
QString path = QFileDialog::getSaveFileName(this, tr("Save Expression"), QString::fromStdString(_localExprDir), tr("*.se"));
if (path.length() > 0) {
std::ofstream file(path.toStdString().c_str());
if (!file) {
QString msg = QString("Could not open file %1 for writing").arg(path);
QMessageBox::warning(this, "Error", QString("<font face=fixed>%1</font>").arg(msg));
QString msg = tr("Could not open file %1 for writing").arg(path);
QMessageBox::warning(this, tr("Error"), QString::fromLatin1("<font face=fixed>%1</font>").arg(msg));
return;
}
file << editor->getExpr();
file << editor->getExpr().toStdString();
file.close();
update();
......@@ -383,11 +387,11 @@ void ExprBrowser::saveExpression() {
std::ofstream file(path.c_str());
if (!file) {
QString msg =
QString("Could not open file %1 for writing. Is it read-only?").arg(QString::fromStdString(path));
QMessageBox::warning(this, "Error", QString("<font face=fixed>%1</font>").arg(msg));
tr("Could not open file %1 for writing. Is it read-only?").arg(QString::fromStdString(path));
QMessageBox::warning(this, tr("Error"), tr("<font face=fixed>%1</font>").arg(msg));
return;
}
file << editor->getExpr();
file << editor->getExpr().toStdString();
file.close();
}
......@@ -400,7 +404,7 @@ void ExprBrowser::addUserExpressionPath(const std::string& context) {
char* homepath = getenv("HOME");
if (homepath) {
std::string path = std::string(homepath) + "/" + context + "/expressions/";
if (QDir(QString(path.c_str())).exists()) {
if (QDir(QString::fromStdString(path)).exists()) {
_userExprDir = path;
addPath("My Expressions", path);
}
......@@ -418,7 +422,7 @@ bool ExprBrowser::getExpressionDirs() {
/*bool homeFound = false; -- for xgen's config.txt UserRepo section below */
if (_searchPath.length() > 0)
env = _searchPath.c_str();
env = _searchPath.toStdString().c_str();
else
env = getenv(P3D_CONFIG_ENVVAR); /* For backwards compatibility */
......@@ -426,7 +430,7 @@ bool ExprBrowser::getExpressionDirs() {
std::string context;
if (_context.length() > 0) {
context = _context;
context = _context.toStdString();
} else {
context = "paint3d"; /* For backwards compatibility */
}
......@@ -449,12 +453,12 @@ bool ExprBrowser::getExpressionDirs() {
std::string label, path;
file >> label;
file >> path;
if (QDir(QString(path.c_str())).exists()) addPath(label, path);
if (QDir(QString::fromStdString(path)).exists()) addPath(label, path);
} else if (key == "ExpressionSubDir") {
std::string path;
file >> path;
_localExprDir = path;
if (QDir(QString(path.c_str())).exists()) {
if (QDir(QString::fromStdString(path)).exists()) {
addPath("Local", _localExprDir);
enableLocal = true;
}
......@@ -465,13 +469,13 @@ bool ExprBrowser::getExpressionDirs() {
std::string path;
file >> path;
path += "/expressions/";
if (QDir(QString(path.c_str())).exists()) addPath("Global", path);
if (QDir(QString::fromStdString(path)).exists()) addPath("Global", path);
} else if (key == "LocalRepo") {
std::string path;
file >> path;
path += "/expressions/";
_localExprDir = path;
if (QDir(QString(path.c_str())).exists()) {
if (QDir(QString::fromStdString(path)).exists()) {
addPath("Local", _localExprDir);
enableLocal = true;
}
......
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -52,8 +53,8 @@ class ExprBrowser : public QWidget {
QLineEdit* exprFilter;
std::string _userExprDir;
std::string _localExprDir;
std::string _context;
std::string _searchPath;
QString _context;
QString _searchPath;
bool _applyOnSelect;
public:
......
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -161,7 +162,7 @@ void CCurveScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) {
void CCurveScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
if (_selectedItem >= 0) {
QMenu *menu = new QMenu(event->widget());
QAction *deleteAction = menu->addAction("Delete Point");
QAction *deleteAction = menu->addAction(tr("Delete Point"));
QAction *action = menu->exec(event->screenPos());
if (action == deleteAction) removePoint(_selectedItem);
}
......@@ -216,7 +217,7 @@ void CCurveScene::emitCurveChanged() { emit curveChanged(); }
QPixmap &CCurveScene::getPixmap() {
if (_pixmapDirty) {
QByteArray buf;
buf.append(QString("P6\n%1 %2\n255\n").arg(_width).arg(_height));
buf.append(QString::fromLatin1("P6\n%1 %2\n255\n").arg(_width).arg(_height));
buf.append(getCPixmap());
_pixmap.loadFromData(buf, "PPM");
_pixmapDirty = false;
......@@ -370,7 +371,7 @@ ExprColorCurve::ExprColorCurve(QWidget *parent, QString pLabel, QString vLabel,
selPosLayout->addStretch(50);
QLabel *posLabel;
if (pLabel.isEmpty()) {
posLabel = new QLabel("Selected Position: ");
posLabel = new QLabel(tr("Selected Position: "));
} else {
posLabel = new QLabel(pLabel);
}
......@@ -388,7 +389,7 @@ ExprColorCurve::ExprColorCurve(QWidget *parent, QString pLabel, QString vLabel,
selValLayout->addStretch(50);
QLabel *valLabel;
if (vLabel.isEmpty()) {
valLabel = new QLabel("Selected Color: ");
valLabel = new QLabel(tr("Selected Color: "));
} else {
valLabel = new QLabel(vLabel);
}
......@@ -396,11 +397,11 @@ ExprColorCurve::ExprColorCurve(QWidget *parent, QString pLabel, QString vLabel,
selValLayout->addWidget(_selValEdit);
_interpComboBox = new QComboBox;
_interpComboBox->addItem("None");
_interpComboBox->addItem("Linear");
_interpComboBox->addItem("Smooth");
_interpComboBox->addItem("Spline");
_interpComboBox->addItem("MSpline");
_interpComboBox->addItem(tr("None"));
_interpComboBox->addItem(tr("Linear"));
_interpComboBox->addItem(tr("Smooth"));
_interpComboBox->addItem(tr("Spline"));
_interpComboBox->addItem(tr("MSpline"));
_interpComboBox->setCurrentIndex(4);
_interpComboBox->setFixedWidth(70);
_interpComboBox->setFixedHeight(20);
......@@ -431,7 +432,8 @@ ExprColorCurve::ExprColorCurve(QWidget *parent, QString pLabel, QString vLabel,
mainLayout->addWidget(edits);
mainLayout->addWidget(curveFrame);
if (expandable) {
QPushButton *expandButton = new QPushButton(">");
// TODO replace with QToolButton - amyspark
QPushButton *expandButton = new QPushButton(tr(">"));
expandButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
expandButton->setFixedWidth(15);
mainLayout->addWidget(expandButton);
......@@ -478,7 +480,7 @@ void ExprColorCurve::cvSelectedSlot(const double pos, const SeExpr2::Vec3d val,
// User entered new position, round and send signal to redraw curve.
void ExprColorCurve::selPosChanged() {
double pos = SeExpr2::clamp(QString(_selPosEdit->text()).toFloat(), 0, 1);
_selPosEdit->setText(QString("%1").arg(pos, 0, 'f', 3));
_selPosEdit->setText(QString(tr("%1")).arg(pos, 0, 'f', 3));
emit selPosChangedSignal(pos);
}
......@@ -503,7 +505,7 @@ void ExprColorCurve::openDetail() {
QDialog *dialog = new QDialog();
dialog->setMinimumWidth(1024);
dialog->setMinimumHeight(400);
ExprColorCurve *curve = new ExprColorCurve(0, "", "", "", false);
ExprColorCurve *curve = new ExprColorCurve(0, QString(), QString(), QString(), false);
// copy points into new data
const std::vector<T_CURVE::CV> &data = _scene->_cvs;
......
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -142,9 +143,9 @@ class ExprColorCurve : public QWidget {
public:
ExprColorCurve(QWidget *parent = 0,
QString pLabel = "",
QString vLabel = "",
QString iLabel = "",
QString pLabel = QString(),
QString vLabel = QString(),
QString iLabel = QString(),
bool expandable = true);
~ExprColorCurve() {}
......
......@@ -71,8 +71,8 @@ void ExprColorFrame::mouseReleaseEvent(QMouseEvent *event) {
void ExprColorFrame::deleteSwatchMenu(const QPoint &pos) {
QMenu *menu = new QMenu(this);
QAction *deleteAction = menu->addAction("Delete Swatch");
menu->addAction("Cancel");
QAction *deleteAction = menu->addAction(tr("Delete Swatch"));
menu->addAction(tr("Cancel"));
QAction *action = menu->exec(mapToGlobal(pos));
if (action == deleteAction) emit deleteSwatch(this);
}
......@@ -89,9 +89,7 @@ ExprColorWidget::ExprColorWidget(SeExpr2::Vec3d value, int index, bool indexLabe
vbox->addWidget(_colorFrame);
if (indexLabel) {
std::stringstream indexSS;
indexSS << index;
QLabel *label = new QLabel(indexSS.str().c_str());
QLabel *label = new QLabel(tr("%1").arg(index));
vbox->addWidget(label);
}
......@@ -108,7 +106,8 @@ ExprColorSwatchWidget::ExprColorSwatchWidget(bool indexLabel, QWidget *parent)
hboxLayout->setContentsMargins(0, 0, 0, 0);
setLayout(hboxLayout);
QPushButton *addBtn = new QPushButton("+");
// TODO replace with QToolButton - amyspark
QPushButton *addBtn = new QPushButton(tr("+"));
addBtn->setFixedWidth(16);
addBtn->setFixedHeight(16);
QVBoxLayout *swatchControlLayout = new QVBoxLayout();
......
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -29,7 +30,10 @@ ExprCompletionModel::ExprCompletionModel(QObject* parent) : QAbstractItemModel(p
if (builtins.size() == 0) {
std::vector<std::string> builtins_std;
SeExpr2::ExprFunc::getFunctionNames(builtins_std);
for (unsigned int i = 0; i < builtins_std.size(); i++) builtins.push_back(QString(builtins_std[i].c_str()));
for (unsigned int i = 0; i < builtins_std.size(); i++) {
// Remember to extract all strings from the builtins! -- amyspark
builtins.push_back(tr(builtins_std[i].c_str()));
}
}
}
......@@ -115,7 +119,7 @@ QVariant ExprCompletionModel::data(const QModelIndex& index, int role) const {
if (column == 0)
return QVariant(local_variables[index]);
else if (column == 1)
return QVariant("Local");
return QVariant(tr("Local"));
} else if (role == Qt::ForegroundRole)
return variableColor;
}
......@@ -127,5 +131,5 @@ QString ExprCompletionModel::getDocString(const QString& s) {
if (i != functionNameToFunction.end()) {
return functions_comment[i->second];
} else
return SeExpr2::ExprFunc::getDocString(s.toStdString().c_str()).c_str();
return tr(SeExpr2::ExprFunc::getDocString(s.toStdString().c_str()).c_str());
}
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -61,9 +62,9 @@ class ExprCompletionModel : public QAbstractItemModel // ItemModel
QString getFirstLine(const std::string& all) const {
size_t newline = all.find("\n");
if (newline != std::string::npos)
return QString(all.substr(0, newline).c_str());
return QString::fromStdString(all.substr(0, newline));
else
return QString(all.c_str());
return QString::fromStdString(all);
}
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
......@@ -71,7 +72,7 @@ class ExprCompletionModel : public QAbstractItemModel // ItemModel
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const {
Q_UNUSED(orientation);
if (role == Qt::DisplayRole)
return QVariant("");
return QVariant();
else if (role == Qt::SizeHintRole) {
if (section == 0)
return QVariant(QSize(100, 1));
......
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -175,7 +176,10 @@ ExprControl::ExprControl(int id, Editable* editable, bool showColorLink)
connect(_colorLinkCB, SIGNAL(stateChanged(int)), this, SLOT(linkStateChange(int)));
hbox->addWidget(_colorLinkCB);
_label = new QLabel(QString("<b>") + editable->name.c_str() + "</b>");
// see parser's specRegisterEditable
// TODO these labels are untranslatable
QString editableLabel = QString::fromStdString(editable->name);
_label = new QLabel(QString(tr("<b>%1</b>")).arg(editableLabel));
_label->setFixedWidth(72);
_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
_label->setIndent(2);
......@@ -258,7 +262,7 @@ void NumberControl::updateControl() {
_updating = 1;
int sliderval = int(_numberEditable->isInt ? _numberEditable->v : _numberEditable->v * 1e5);
if (sliderval != _slider->value()) _slider->setValue(sliderval);
_edit->setText(QString("%1").arg(_numberEditable->v, 0, 'f', _numberEditable->isInt ? 0 : 3));
_edit->setText(QString(tr("%1")).arg(_numberEditable->v, 0, 'f', _numberEditable->isInt ? 0 : 3));
_updating = 0;
}
......@@ -343,7 +347,9 @@ void VectorControl::editChanged(int id, const QString& text) {
void VectorControl::updateControl() {
// //std::cerr<<"In update control "<<_id<<std::endl;
_updating = 1;
for (unsigned int i = 0; i < 3; i++) _edits[i]->setText(QString("%1").arg(_numberEditable->v[i], 0, 'f', 3));
for (unsigned int i = 0; i < 3; i++) {
_edits[i]->setText(QString(tr("%1")).arg(_numberEditable->v[i], 0, 'f', 3));
}
double min = _numberEditable->min, max = _numberEditable->max;
for (unsigned int i = 0; i < 3; i++) {
_sliders[i]->setValue((_numberEditable->v[i] - min) / (max - min));
......@@ -405,18 +411,21 @@ void StringControl::fileBrowse() {
ExprFileDialog dialog(this);
dialog.setPreview();
QString newFilename =
dialog.getOpenFileName("Please choose a file", _edit->text(), tr("Images (*.tif *.tx *.jpg *.ptx *.png)"));
if (newFilename != "") _edit->setText(newFilename);
dialog.getOpenFileName(tr("Please choose a file"), _edit->text(), tr("Images (*.tif *.tx *.jpg *.ptx *.png)"));
if (!newFilename.isEmpty()) _edit->setText(newFilename);
}
void StringControl::directoryBrowse() {
ExprFileDialog dialog(this);
dialog.setPreview();
QString newFilename = dialog.getExistingDirectory("Please choose a file", _edit->text());
if (newFilename != "") _edit->setText(newFilename);
QString newFilename = dialog.getExistingDirectory(tr("Please choose a file"), _edit->text());
if (!newFilename.isEmpty()) _edit->setText(newFilename);
}
void StringControl::updateControl() { _edit->setText(_stringEditable->v.c_str()); }
void StringControl::updateControl() {
QString newText = QString::fromStdString(_stringEditable->v);
_edit->setText(newText);
}
void StringControl::textChanged(const QString& newText) {
if (_updating) return;
......@@ -426,7 +435,7 @@ void StringControl::textChanged(const QString& newText) {
CurveControl::CurveControl(int id, CurveEditable* editable)
: ExprControl(id, editable, false), _curveEditable(editable) {
_curve = new ExprCurve(this, "Pos:", "Val:", "Interp:");
_curve = new ExprCurve(this, tr("Pos:"), tr("Val:"), tr("Interp:"));
_curve->setFixedHeight(80);
const int numVal = _curveEditable->cvs.size();
......@@ -448,7 +457,7 @@ void CurveControl::curveChanged() {
CCurveControl::CCurveControl(int id, ColorCurveEditable* editable)
: ExprControl(id, editable, true), _curveEditable(editable) {
_curve = new ExprColorCurve(this, "Pos:", "Val:", "Interp:");
_curve = new ExprColorCurve(this, tr("Pos:"), tr("Val:"), tr("Interp:"));
_curve->setFixedHeight(80);
const int numVal = _curveEditable->cvs.size();
......@@ -537,10 +546,10 @@ public:
painter.drawPath(path);
painter.setPen(QPen());
painter.drawText(right, Qt::AlignTop | Qt::AlignLeft, QString("%1").arg(ymax, 0, 'f', 1));
painter.drawText(right, Qt::AlignBottom | Qt::AlignLeft, QString("%1").arg(ymin, 0, 'f', 1));
painter.drawText(bottom, Qt::AlignTop | Qt::AlignLeft, QString("%1").arg(xmin, 0, 'f', 1));
painter.drawText(bottom, Qt::AlignTop | Qt::AlignRight, QString("%1").arg(xmax, 0, 'f', 1));
painter.drawText(right, Qt::AlignTop | Qt::AlignLeft, QString(tr("%1")).arg(ymax, 0, 'f', 1));
painter.drawText(right, Qt::AlignBottom | Qt::AlignLeft, QString(tr("%1")).arg(ymin, 0, 'f', 1));
painter.drawText(bottom, Qt::AlignTop | Qt::AlignLeft, QString(tr("%1")).arg(xmin, 0, 'f', 1));
painter.drawText(bottom, Qt::AlignTop | Qt::AlignRight, QString(tr("%1")).arg(xmax, 0, 'f', 1));
painter.setBrush(QBrush(QColor(0, 0, 0), Qt::SolidPattern));
for (size_t i = 0; i < cpx.size(); i++) {
......
This diff is collapsed.
/*
* Copyright Disney Enterprises, Inc. All rights reserved.
* Copyright (C) 2020 L. E. Segovia <amy@amyspark.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License
......@@ -140,7 +141,7 @@ void CurveScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) {
void CurveScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
if (_selectedItem >= 0) {
QMenu *menu = new QMenu(event->widget());
QAction *deleteAction = menu->addAction("Delete Point");
QAction *deleteAction = menu->addAction(tr("Delete Point"));
// menu->addAction("Cancel");
QAction *action = menu->exec(event->screenPos());
if (action == deleteAction) removePoint(_selectedItem);
......@@ -279,13 +280,13 @@ ExprCurve::ExprCurve(QWidget *parent, QString pLabel, QString vLabel, QString iL
_selPosEdit = new QLineEdit;
QDoubleValidator *posValidator = new QDoubleValidator(0.0, 1.0, 6, _selPosEdit);
_selPosEdit->setValidator(posValidator);
int editwidth = QFontMetrics(font()).boundingRect("9.999").width() + 8;
int editwidth = QFontMetrics(_selPosEdit->font()).boundingRect(QString::fromLatin1("9.999")).width() + 8;
_selPosEdit->setFixedWidth(editwidth);
_selPosEdit->setFixedHeight(20);
selPosLayout->addStretch(50);
QLabel *posLabel;
if (pLabel.isEmpty()) {
posLabel = new QLabel("Selected Position: ");
posLabel = new QLabel(tr("Selected Position: "));
} else {
posLabel = new QLabel(pLabel);
}
......@@ -305,7 +306,7 @@ ExprCurve::ExprCurve(QWidget *parent, QString pLabel, QString vLabel, QString iL
selValLayout->addStretch(50);
QLabel *valLabel;
if (vLabel.isEmpty()) {
valLabel = new QLabel("Selected Value: ");
valLabel = new QLabel(tr("Selected Value: "));
} else {
valLabel = new QLabel(vLabel);
}
......@@ -313,11 +314,11 @@ ExprCurve::ExprCurve(QWidget *parent, QString pLabel, QString vLabel, QString iL
selValLayout->addWidget(_selValEdit);
_interpComboBox = new QComboBox;
_interpComboBox->addItem("None");
_interpComboBox->addItem("Linear");
_interpComboBox->addItem("Smooth");
_interpComboBox->addItem("Spline");
_interpComboBox->addItem("MSpline");
_interpComboBox->addItem(tr("None"));
_interpComboBox->addItem(tr("Linear"));
_interpComboBox->addItem(tr("Smooth"));
_interpComboBox->addItem(tr("Spline"));
_interpComboBox->addItem(tr("MSpline"));
_interpComboBox->setCurrentIndex(4);
_interpComboBox->setFixedWidth(70);
_interpComboBox->setFixedHeight(20);
......@@ -348,7 +349,8 @@ ExprCurve::ExprCurve(QWidget *parent, QString pLabel, QString vLabel, QString iL
mainLayout->addWidget(edits);
mainLayout->addWidget(curveFrame);
if (expandable) {
QPushButton *expandButton = new QPushButton(">");
// TODO replace with QToolButton - amyspark
QPushButton *expandButton = new QPushButton(tr(">"));
expandButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
expandButton->setFixedWidth(15);
mainLayout->addWidget(expandButton);
......@@ -388,7 +390,7 @@ void ExprCurve::cvSelectedSlot(double pos, double val, T_INTERP interp) {
// User entered new position, round and send signal to redraw curve.
void ExprCurve::selPosChanged() {
double pos = QString(_selPosEdit->text()).toDouble();
_selPosEdit->setText(QString("%1").arg(pos, 0, 'f', 3));
_selPosEdit->setText(QString(tr("%1")).arg(pos, 0, 'f', 3));
emit selPosChangedSignal(pos);