From b34a0e635f7ca07342d7f131f2c1ec0796b09e6b Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 14 Mar 2017 23:24:10 +0100 Subject: [PATCH] Use JS provider defs provided by qtutilities --- CMakeLists.txt | 2 +- renamingutility/scriptdefs.h => gui/jsdefs.h | 22 ++++++++---- gui/jsincludes.h | 19 +++++++++++ renamingutility/jsdefs.h | 36 ++++++++++++++++++++ renamingutility/jsincludes.h | 19 +++++++++++ renamingutility/renamingengine.h | 10 ++---- renamingutility/tageditorobject.cpp | 9 +---- renamingutility/tageditorobject.h | 7 +--- 8 files changed, 94 insertions(+), 30 deletions(-) rename renamingutility/scriptdefs.h => gui/jsdefs.h (63%) create mode 100644 gui/jsincludes.h create mode 100644 renamingutility/jsdefs.h create mode 100644 renamingutility/jsincludes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dbd63c..c94aed5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "A tageditor with Qt GUI and command line interface. Supports MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska") set(META_GUI_OPTIONAL true) +set(META_JS_SRC_DIR renamingutility) set(META_VERSION_MAJOR 2) set(META_VERSION_MINOR 2) set(META_VERSION_PATCH 1) @@ -71,7 +72,6 @@ set(WIDGETS_HEADER_FILES renamingutility/filesystemitemmodel.h renamingutility/filteredfilesystemitemmodel.h renamingutility/renamingengine.h - renamingutility/scriptdefs.h renamingutility/tageditorobject.h ) set(WIDGETS_SRC_FILES diff --git a/renamingutility/scriptdefs.h b/gui/jsdefs.h similarity index 63% rename from renamingutility/scriptdefs.h rename to gui/jsdefs.h index f096207..cd1475b 100644 --- a/renamingutility/scriptdefs.h +++ b/gui/jsdefs.h @@ -1,5 +1,8 @@ -#ifndef SCRIPTDEFS_H -#define SCRIPTDEFS_H +// Created via CMake from template webviewdefs.h.in +// WARNING! Any changes to this file will be overwritten by the next CMake run! + +#ifndef TAGEDITOR_JAVA_SCRIPT_DEFINES +#define TAGEDITOR_JAVA_SCRIPT_DEFINES #include @@ -11,8 +14,6 @@ # define TAGEDITOR_JS_QOBJECT(engine, obj) engine.newQObject(obj) # define TAGEDITOR_JS_INT(value) value.toInt() # define TAGEDITOR_JS_IS_VALID_PROG(program) (!program.isError() && program.isCallable()) -QT_FORWARD_DECLARE_CLASS(QJSValue) -QT_FORWARD_DECLARE_CLASS(QJSEngine) #elif defined(TAGEDITOR_USE_SCRIPT) # define TAGEDITOR_JS_ENGINE QScriptEngine # define TAGEDITOR_JS_VALUE QScriptValue @@ -21,8 +22,15 @@ QT_FORWARD_DECLARE_CLASS(QJSEngine) # define TAGEDITOR_JS_QOBJECT(engine, obj) engine.newQObject(obj, QScriptEngine::ScriptOwnership) # define TAGEDITOR_JS_INT(value) value.toInt32() # define TAGEDITOR_JS_IS_VALID_PROG(program) (!program.isError() && program.isFunction()) -QT_FORWARD_DECLARE_CLASS(QScriptValue) -QT_FORWARD_DECLARE_CLASS(QScriptEngine) +#elif !defined(TAGEDITOR_NO_WEBVIEW) +# error "No definition for JavaScript provider present." #endif -#endif // SCRIPTDEFS_H +#ifdef TAGEDITOR_JS_ENGINE +QT_FORWARD_DECLARE_CLASS(TAGEDITOR_JS_ENGINE) +#endif +#ifdef TAGEDITOR_JS_VALUE +QT_FORWARD_DECLARE_CLASS(TAGEDITOR_JS_VALUE) +#endif + +#endif // TAGEDITOR_JAVA_SCRIPT_DEFINES diff --git a/gui/jsincludes.h b/gui/jsincludes.h new file mode 100644 index 0000000..c3a4984 --- /dev/null +++ b/gui/jsincludes.h @@ -0,0 +1,19 @@ +// Created via CMake from template webviewdefs.h.in +// WARNING! Any changes to this file will be overwritten by the next CMake run! + +#ifndef TAGEDITOR_JAVA_SCRIPT_INCLUDES +#define TAGEDITOR_JAVA_SCRIPT_INCLUDES + +#include + +#if defined(TAGEDITOR_USE_JSENGINE) +# include +# include +#elif defined(TAGEDITOR_USE_SCRIPT) +# include +# include +#elif !defined(TAGEDITOR_NO_WEBVIEW) +# error "No definition for JavaScript provider present." +#endif + +#endif // TAGEDITOR_JAVA_SCRIPT_INCLUDES diff --git a/renamingutility/jsdefs.h b/renamingutility/jsdefs.h new file mode 100644 index 0000000..cd1475b --- /dev/null +++ b/renamingutility/jsdefs.h @@ -0,0 +1,36 @@ +// Created via CMake from template webviewdefs.h.in +// WARNING! Any changes to this file will be overwritten by the next CMake run! + +#ifndef TAGEDITOR_JAVA_SCRIPT_DEFINES +#define TAGEDITOR_JAVA_SCRIPT_DEFINES + +#include + +#if defined(TAGEDITOR_USE_JSENGINE) +# define TAGEDITOR_JS_ENGINE QJSEngine +# define TAGEDITOR_JS_VALUE QJSValue +# define TAGEDITOR_JS_READONLY +# define TAGEDITOR_JS_UNDELETABLE +# define TAGEDITOR_JS_QOBJECT(engine, obj) engine.newQObject(obj) +# define TAGEDITOR_JS_INT(value) value.toInt() +# define TAGEDITOR_JS_IS_VALID_PROG(program) (!program.isError() && program.isCallable()) +#elif defined(TAGEDITOR_USE_SCRIPT) +# define TAGEDITOR_JS_ENGINE QScriptEngine +# define TAGEDITOR_JS_VALUE QScriptValue +# define TAGEDITOR_JS_READONLY ,QScriptValue::ReadOnly +# define TAGEDITOR_JS_UNDELETABLE ,QScriptValue::Undeletable +# define TAGEDITOR_JS_QOBJECT(engine, obj) engine.newQObject(obj, QScriptEngine::ScriptOwnership) +# define TAGEDITOR_JS_INT(value) value.toInt32() +# define TAGEDITOR_JS_IS_VALID_PROG(program) (!program.isError() && program.isFunction()) +#elif !defined(TAGEDITOR_NO_WEBVIEW) +# error "No definition for JavaScript provider present." +#endif + +#ifdef TAGEDITOR_JS_ENGINE +QT_FORWARD_DECLARE_CLASS(TAGEDITOR_JS_ENGINE) +#endif +#ifdef TAGEDITOR_JS_VALUE +QT_FORWARD_DECLARE_CLASS(TAGEDITOR_JS_VALUE) +#endif + +#endif // TAGEDITOR_JAVA_SCRIPT_DEFINES diff --git a/renamingutility/jsincludes.h b/renamingutility/jsincludes.h new file mode 100644 index 0000000..c3a4984 --- /dev/null +++ b/renamingutility/jsincludes.h @@ -0,0 +1,19 @@ +// Created via CMake from template webviewdefs.h.in +// WARNING! Any changes to this file will be overwritten by the next CMake run! + +#ifndef TAGEDITOR_JAVA_SCRIPT_INCLUDES +#define TAGEDITOR_JAVA_SCRIPT_INCLUDES + +#include + +#if defined(TAGEDITOR_USE_JSENGINE) +# include +# include +#elif defined(TAGEDITOR_USE_SCRIPT) +# include +# include +#elif !defined(TAGEDITOR_NO_WEBVIEW) +# error "No definition for JavaScript provider present." +#endif + +#endif // TAGEDITOR_JAVA_SCRIPT_INCLUDES diff --git a/renamingutility/renamingengine.h b/renamingutility/renamingengine.h index a3f9ae3..56ab5d5 100644 --- a/renamingutility/renamingengine.h +++ b/renamingutility/renamingengine.h @@ -2,19 +2,13 @@ #define RENAMINGUTILITY_RENAMINGENGINE_H #include "./filesystemitem.h" -#include "./scriptdefs.h" +#include "./jsdefs.h" +#include "./jsincludes.h" #include #include #include #include -#if defined(TAGEDITOR_USE_JSENGINE) -# include -# include -#elif defined(TAGEDITOR_USE_SCRIPT) -# include -# include -#endif #include diff --git a/renamingutility/tageditorobject.cpp b/renamingutility/tageditorobject.cpp index a8e069d..171f950 100644 --- a/renamingutility/tageditorobject.cpp +++ b/renamingutility/tageditorobject.cpp @@ -2,6 +2,7 @@ #include "./tageditorobject.h" #include "./filesystemitem.h" +#include "./jsincludes.h" #include "../misc/utility.h" @@ -17,14 +18,6 @@ #include -#if defined(TAGEDITOR_USE_JSENGINE) -# include -# include -#elif defined(TAGEDITOR_USE_SCRIPT) -# include -# include -#endif - #include using namespace ConversionUtilities; diff --git a/renamingutility/tageditorobject.h b/renamingutility/tageditorobject.h index 74b4ab3..b0eac86 100644 --- a/renamingutility/tageditorobject.h +++ b/renamingutility/tageditorobject.h @@ -3,14 +3,9 @@ #ifndef TAGEDITOR_NO_JSENGINE -#include "./scriptdefs.h" +#include "./jsdefs.h" #include -#if defined(TAGEDITOR_USE_JSENGINE) -# include -#elif defined(TAGEDITOR_USE_SCRIPT) -# include -#endif QT_FORWARD_DECLARE_CLASS(QFileInfo)