Commit 0b66d8c3 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

QML: Rename QML plugin from Kid3App to Kid3.

parent f5e957d7
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Page {
id: page
......
......@@ -25,7 +25,7 @@ import QtQuick 2.2
import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Page {
id: page
......
......@@ -54,8 +54,6 @@ qt4_wrap_cpp(qml_GEN_MOC_SRCS ${qml_MOC_HDRS})
set(qml_SRCS ${qml_SRCS} ${qml_GEN_MOC_SRCS})
add_definitions(${QT_DEFINITIONS} ${QT_EXECUTABLE_COMPILE_FLAGS})
set(qml_RESOURCES )
qt4_add_resources(qml_GEN_RCS ${qml_RESOURCES})
add_executable(kid3-qml MACOSX_BUNDLE WIN32
${qml_SRCS} ${qml_GEN_RCS} ${qml_QML_SRCS})
......@@ -78,7 +76,7 @@ if (NOT HAVE_QT5 OR WITH_UBUNTUCOMPONENTS)
install(CODE "
execute_process(
COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/qmlpp.pl ${_qmlpp_code}
${kid3_SOURCE_DIR}/src/plugins/kid3qml/qmlpp.pl ${_qmlpp_code}
WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_QMLDIR}\"
)
")
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Collapsible {
id: fileCollapsible
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
RaisableRectangle {
function currentFilePath() {
......
......@@ -25,7 +25,7 @@ import QtQuick 2.2
import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Page {
id: page
......
......@@ -25,7 +25,7 @@ import QtQuick 2.2
import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Empty {
id: frameDelegate
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Dialog {
id: page
......
......@@ -25,7 +25,7 @@ import QtQuick 2.2
import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Dialog {
id: page
......
......@@ -22,7 +22,7 @@
*/
import QtQuick 2.2
import Kid3App 1.0
import Kid3 1.0
Collapsible {
text: qsTr("Picture")
......
......@@ -25,7 +25,7 @@ import QtQuick 2.2
import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Page {
id: page
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
AbstractSettingsPage {
id: page
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Collapsible {
id: collapsibleV1
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
Collapsible {
id: collapsibleV2
......
......@@ -26,7 +26,7 @@ import "ComponentsQtQuick" //@!Ubuntu
//import Ubuntu.Components 1.1 //@Ubuntu
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
import Kid3App 1.0
import Kid3 1.0
MainView {
id: root
......
......@@ -39,7 +39,7 @@ add_subdirectory(oggflacmetadata)
add_subdirectory(mp4v2metadata)
if (WITH_QML)
add_subdirectory(qmlcommand)
add_subdirectory(kid3appqml)
add_subdirectory(kid3qml)
endif (WITH_QML)
set(PLUGIN_LIBRARIES ${PLUGIN_LIBRARIES} PARENT_SCOPE)
......
set(plugin_SRCS
kid3appqmlplugin.cpp
kid3qmlplugin.cpp
qmlimageprovider.cpp
scriptutils.cpp
configobjects.cpp
......@@ -7,13 +7,17 @@ set(plugin_SRCS
)
set(plugin_MOC_HDRS
kid3appqmlplugin.h
kid3qmlplugin.h
scriptutils.h
configobjects.h
checkablelistmodel.h
)
set(plugin_NAME Kid3AppQml)
set(plugin_QML_SRCS
Kid3Script.qml
)
set(plugin_NAME Kid3Qml)
if (WITH_GCC_PCH)
add_definitions(${GCC_PCH_COMPILE_FLAGS})
......@@ -23,37 +27,59 @@ string(TOLOWER ${plugin_NAME} plugin_TARGET)
qt4_wrap_cpp(plugin_GEN_MOC_SRCS ${plugin_MOC_HDRS})
set(_targetDependencies ${plugin_SRCS} ${plugin_GEN_MOC_SRCS}
${plugin_QML_SRCS} "${kid3_plugins_BINARY_DIR}/imports/Kid3/Kid3Script.qml")
if (APPLE)
# The extension must be dylib, not so.
add_library(${plugin_TARGET} SHARED ${plugin_SRCS} ${plugin_GEN_MOC_SRCS})
add_library(${plugin_TARGET} SHARED ${_targetDependencies})
else (APPLE)
add_library(${plugin_TARGET} MODULE ${plugin_SRCS} ${plugin_GEN_MOC_SRCS})
add_library(${plugin_TARGET} MODULE ${_targetDependencies})
endif (APPLE)
target_link_libraries(${plugin_TARGET} kid3-core ${BASIC_LIBRARIES})
install(TARGETS ${plugin_TARGET}
LIBRARY DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3App
RUNTIME DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3App)
LIBRARY DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3
RUNTIME DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3)
set_target_properties(
${plugin_TARGET} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${kid3_plugins_BINARY_DIR}/imports/Kid3App
LIBRARY_OUTPUT_DIRECTORY ${kid3_plugins_BINARY_DIR}/imports/Kid3App
RUNTIME_OUTPUT_DIRECTORY ${kid3_plugins_BINARY_DIR}/imports/Kid3
LIBRARY_OUTPUT_DIRECTORY ${kid3_plugins_BINARY_DIR}/imports/Kid3
)
if (WIN32)
set(_qmldirPluginName libkid3appqml)
set(_qmldirPluginName libkid3qml)
else (WIN32)
set(_qmldirPluginName kid3appqml)
set(_qmldirPluginName kid3qml)
endif (WIN32)
add_custom_command(TARGET ${plugin_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "module Kid3App" > "${kid3_plugins_BINARY_DIR}/imports/Kid3App/qmldir"
COMMAND ${CMAKE_COMMAND} -E echo "plugin ${_qmldirPluginName}" >> "${kid3_plugins_BINARY_DIR}/imports/Kid3App/qmldir"
COMMAND ${CMAKE_COMMAND} -E echo "module Kid3" > "${kid3_plugins_BINARY_DIR}/imports/Kid3/qmldir"
COMMAND ${CMAKE_COMMAND} -E echo "plugin ${_qmldirPluginName}" >> "${kid3_plugins_BINARY_DIR}/imports/Kid3/qmldir"
COMMAND ${CMAKE_COMMAND} -E echo "Kid3Script 1.0 Kid3Script.qml" >> "${kid3_plugins_BINARY_DIR}/imports/Kid3/qmldir"
)
add_custom_command(OUTPUT "${kid3_plugins_BINARY_DIR}/imports/Kid3/Kid3Script.qml"
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Kid3Script.qml "${kid3_plugins_BINARY_DIR}/imports/Kid3/"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Kid3Script.qml
WORKING_DIRECTORY "${kid3_plugins_BINARY_DIR}/imports/Kid3"
)
if (WIN32)
install(FILES "${kid3_plugins_BINARY_DIR}/imports/Kid3App/qmldir"
DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3App)
else (WIN32)
# Preprocess QML files for Qt 4 or Ubuntu Components.
if (NOT HAVE_QT5 OR WITH_UBUNTUCOMPONENTS)
if (NOT HAVE_QT5)
set(_qmlpp_code 4)
else (NOT HAVE_QT5)
set(_qmlpp_code U)
endif (NOT HAVE_QT5)
add_custom_command(OUTPUT "${kid3_plugins_BINARY_DIR}/imports/Kid3/Kid3Script.qml"
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qmlpp.pl ${_qmlpp_code}
WORKING_DIRECTORY "${kid3_plugins_BINARY_DIR}/imports/Kid3"
APPEND
)
endif (NOT HAVE_QT5 OR WITH_UBUNTUCOMPONENTS)
install(FILES "${kid3_plugins_BINARY_DIR}/imports/Kid3/qmldir"
"${kid3_plugins_BINARY_DIR}/imports/Kid3/Kid3Script.qml"
DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3)
if (NOT WIN32)
if (HAVE_QT5)
get_target_property(_qmakeLocation Qt5::qmake LOCATION)
else (HAVE_QT5)
......@@ -61,18 +87,17 @@ else (WIN32)
endif (HAVE_QT5)
execute_process(COMMAND "${_qmakeLocation}" -query QT_INSTALL_BINS
OUTPUT_VARIABLE _qtInstallBins OUTPUT_STRIP_TRAILING_WHITESPACE)
add_custom_command(OUTPUT "${kid3_plugins_BINARY_DIR}/imports/Kid3App/plugins.qmltypes"
COMMAND ${_qtInstallBins}/qmlplugindump -notrelocatable Kid3App 1.0
add_custom_command(OUTPUT "${kid3_plugins_BINARY_DIR}/imports/Kid3/plugins.qmltypes"
COMMAND ${_qtInstallBins}/qmlplugindump -notrelocatable Kid3 1.0
"${kid3_plugins_BINARY_DIR}/imports" > plugins.qmltypes
DEPENDS ${plugin_TARGET}
WORKING_DIRECTORY "${kid3_plugins_BINARY_DIR}/imports/Kid3App")
WORKING_DIRECTORY "${kid3_plugins_BINARY_DIR}/imports/Kid3")
add_custom_target(plugins_qmltypes ALL
DEPENDS "${kid3_plugins_BINARY_DIR}/imports/Kid3App/plugins.qmltypes")
DEPENDS "${kid3_plugins_BINARY_DIR}/imports/Kid3/plugins.qmltypes")
install(FILES "${kid3_plugins_BINARY_DIR}/imports/Kid3App/qmldir"
"${kid3_plugins_BINARY_DIR}/imports/Kid3App/plugins.qmltypes"
DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3App)
endif (WIN32)
install(FILES "${kid3_plugins_BINARY_DIR}/imports/Kid3/plugins.qmltypes"
DESTINATION ${WITH_PLUGINSDIR}/imports/Kid3)
endif (NOT WIN32)
if ((WIN32 OR APPLE) AND HAVE_QT5)
# Install essential QML modules.
......@@ -89,5 +114,3 @@ if ((WIN32 OR APPLE) AND HAVE_QT5)
FILES_MATCHING PATTERN "*plugin${CMAKE_SHARED_LIBRARY_SUFFIX}"
PATTERN "qmldir")
endif ()
/**
* \file Kid3Script.qml
* Base component for Kid3 user command scripts.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 27 Feb 2015
*
* Copyright (C) 2015 Urs Fleisch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQml 2.2 //@QtQuick2
//import QtQuick 2.2 //@QtQuick1
import Kid3 1.0
/**
* @qmltype Kid3Script
* @brief Base component for Kid3 user command scripts.
*
* This component can be used to write scripts which can be started as
* user commands from Kid3 or started stand-alone using qml.
* A minimal script could be:
*
* @code
* import Kid3 1.0
*
* Kid3Script {
* onRun: {
* console.log("Hello world")
* Qt.quit()
* }
* }
* @endcode
*/
Timer {
id: timer
signal run
/**
* tagv1, tagv2, tagv2v1 can be used for the tag version with both
* QtQuick 1 (Qt 4) and QtQuick 2 (Qt 5).
* QtQuick 1 needs the enum types from C++, so a helper function is used.
*/
//property variant tagv1: script.toTagVersion(Frame.TagV1) //@QtQuick1
//property variant tagv2: script.toTagVersion(Frame.TagV2) //@QtQuick1
//property variant tagv2v1: script.toTagVersion(Frame.TagV2V1) //@QtQuick1
readonly property int tagv1: Frame.TagV1 //@QtQuick2
readonly property int tagv2: Frame.TagV2 //@QtQuick2
readonly property int tagv2v1: Frame.TagV2V1 //@QtQuick2
// Container for sub module instances.
property list<QtObject> _data: [
ScriptUtils {
id: _script
},
ConfigObjects {
id: _configs
}
]
/** Access to ScriptUtils instance. */
property alias script: _script
/** Access to ConfigObjects instance. */
property alias configs: _configs
/**
* Get arguments after .qml script.
* The arguments are passed to the script when the user command is
* called from Kid3. In Qt 5, it is also possible to get arguments from
* the command line when the script is invoked with qml or qmlscene.
*/
function getArguments() {
var params = []
if (typeof args !== "undefined") {
params = args.slice(0)
} else if (Qt.application.arguments) {
params = Qt.application.arguments.slice(0)
}
while (params.length > 0) {
var p = params.shift()
if (p.substr(-4) === ".qml") {
break
}
}
return params
}
/**
* Signal run() after the directory @a paths has been opened.
* This function is used when the script is called stand-alone and the
* the directory is passed as a command line parameter.
*/
function openDirectory(paths) {
function onDirectoryOpened() {
app.fileRootIndexChanged.disconnect(onDirectoryOpened)
run()
}
app.fileRootIndexChanged.connect(onDirectoryOpened)
app.openDirectory(paths)
}
/**
* Check if script is running stand-alone, i.e. not in the Kid3 application.
*/
function isStandalone() {
return typeof args === "undefined"
}
/**
* Main function.
* When the script is run as a user command from Kid3, simply run() is
* signalled. When the script is called from the command line, run() is
* signalled after opening the directory.
*/
function main() {
if (!isStandalone()) {
// Started as a user action from Kid3.
run()
} else {
// Started as a QML script outside of Kid3, start in current directory.
app.selectedFilesUpdated.connect(app.tagsToFrameModels)
app.readConfig()
openDirectory(".")
}
}
interval: 1
onTriggered: main()
Component.onCompleted: start()
}
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