Commit 5e8be062 authored by L. E. Segovia's avatar L. E. Segovia

Integrate translations with the SeExpr UI library

This allows translations to be extracted, bundled and integrated using the KDE infrastructure.

Fixes T13273
parent 2dd67999
......@@ -93,6 +93,14 @@ option(BUILD_DOC "Whether to build the documentation" TRUE)
option(BUILD_TESTS "Whether to build the tests" TRUE)
option(ENABLE_SLOW_TESTS "Whether to enable slow tests" FALSE)
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/po")
find_package(ECM 5.64.0 NO_MODULE)
if (ECM_FOUND)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
option(BUILD_TRANSLATIONS "Whether to include translations" TRUE)
endif ()
endif ()
set(LLVM_LIB "")
if (ENABLE_LLVM_BACKEND)
set(LLVM_DIR /usr/share/llvm/cmake CACHE PATH "Where to search for LLVM i.e. ")
......
#!/usr/bin/env bash
$EXTRACT_TR_STRINGS $(find . -name \*.cpp -o -name \*.h -o -name \*.ui -o -name \*.qml) -o $podir/seexpr2_qt.pot
......@@ -39,19 +39,39 @@ if (Qt5_FOUND OR QT4_FOUND)
option(ENABLE_ANIMCURVE "Whether to build controls for anim curves" FALSE)
option(ENABLE_EXPRMAIN "Whether to build the ExprMain entrypoint" FALSE)
set(EDITOR_MOC_HDRS ExprBrowser.h ExprColorCurve.h
ExprColorSwatch.h ExprControlCollection.h
ExprControl.h ExprCurve.h ExprDialog.h ExprEditor.h
ExprFileDialog.h ExprGrapher2d.h ExprPopupDoc.h
ExprShortEdit.h)
set(EDITOR_CPPS ExprFileDialog.cpp ExprControl.cpp
ExprEditor.cpp ExprShortEdit.cpp
ExprCurve.cpp ExprColorCurve.cpp ExprColorSwatch.cpp
EditableExpression.cpp ExprPopupDoc.cpp
ExprCompletionModel.cpp ExprDialog.cpp
ExprControlCollection.cpp ExprGrapher2d.cpp ExprBrowser.cpp
BasicExpression.cpp)
set(EDITOR_MOC_HDRS
ExprBrowser.h
ExprColorCurve.h
ExprColorSwatch.h
ExprCompletionModel.h
ExprControlCollection.h
ExprControl.h
ExprCurve.h
ExprDialog.h
ExprEditor.h
ExprFileDialog.h
ExprGrapher2d.h
ExprPopupDoc.h
ExprShortEdit.h
)
set(EDITOR_CPPS
BasicExpression.cpp
EditableExpression.cpp
ExprBrowser.cpp
ExprColorCurve.cpp
ExprColorSwatch.cpp
ExprCompletionModel.cpp
ExprControl.cpp
ExprControlCollection.cpp
ExprCurve.cpp
ExprDialog.cpp
ExprEditor.cpp
ExprFileDialog.cpp
ExprGrapher2d.cpp
ExprPopupDoc.cpp
ExprShortEdit.cpp
)
if (ENABLE_DEEPWATER)
add_definitions(-DSEEXPR_ENABLE_DEEPWATER)
......@@ -95,6 +115,15 @@ if (Qt5_FOUND OR QT4_FOUND)
set(ANIMLIB_SRCS "${CE_CPPS} ${CE_MOC_SRCS}")
endif()
if (BUILD_TRANSLATIONS)
include(ECMPoQmTools)
ecm_install_po_files_as_qm("${CMAKE_SOURCE_DIR}/po")
ecm_create_qm_loader(SeExpr2Editor_QM_LOADER seexpr2_qt)
set(EDITOR_CPPS
${EDITOR_CPPS}
${SeExpr2Editor_QM_LOADER})
endif()
if (WIN32)
add_library(SeExpr2Editor ${EDITOR_CPPS} ${EDITOR_MOC_SRCS}
${ANIMLIB_SRCS}
......
......@@ -17,23 +17,22 @@
*
* @file ExprCompletionModel.h
* @brief This provides an expression editor for SeExpr syntax with auto ui features
* @author aselle
* @author aselle, amyspark
*/
#include <QCoreApplication>
#include <QLineEdit>
#include <SeExpr2/Expression.h>
#include <SeExpr2/ExprFunc.h>
#include "ExprCompletionModel.h"
std::vector<QString> ExprCompletionModel::builtins;
static const char* CONTEXT = "builtin";
ExprCompletionModel::ExprCompletionModel(QObject* parent) : QAbstractItemModel(parent) {
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++) {
// Remember to extract all strings from the builtins! -- amyspark
builtins.push_back(tr(builtins_std[i].c_str()));
}
std::vector<std::string> builtins_std;
SeExpr2::ExprFunc::getFunctionNames(builtins_std);
for (unsigned int i = 0; i < builtins_std.size(); i++) {
// Remember to extract all strings from the builtins! -- amyspark
builtins.push_back(QCoreApplication::translate(CONTEXT, builtins_std[i].c_str()));
}
}
......
......@@ -29,7 +29,7 @@
#include <vector>
class ExprCompletionModel : public QAbstractItemModel // ItemModel
{
{
public:
// clear/add functions (these are ones that will be resolved with resolveFunc()
void clearFunctions();
......@@ -86,7 +86,9 @@ class ExprCompletionModel : public QAbstractItemModel // ItemModel
QString getDocString(const QString& s);
private:
static std::vector<QString> builtins;
Q_OBJECT;
std::vector<QString> builtins;
std::vector<QString> functions, functions_comment;
std::map<QString, int> functionNameToFunction;
std::vector<QString> variables, variables_comment;
......
......@@ -484,6 +484,7 @@ QColor CCurveControl::getColor() { return _curve->getSwatchColor(); }
void CCurveControl::setColor(QColor color) { _curve->setSwatchColor(color); }
class ExprGraphPreview : public QWidget {
Q_OBJECT
public:
std::vector<float> x, y;
std::vector<float> cpx, cpy;
......
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