Reinhard Russinger před 8 roky
revize
b7b38053f4

+ 46 - 0
.gitignore

@@ -0,0 +1,46 @@
+# C++ objects and libs
+
+*.slo
+*.lo
+*.o
+*.a
+*.la
+*.lai
+*.so
+*.dll
+*.dylib
+
+# Qt-es
+
+object_script.*.Release
+object_script.*.Debug
+*_plugin_import.cpp
+/.qmake.cache
+/.qmake.stash
+*.pro.user
+*.pro.user.*
+*.qbs.user
+*.qbs.user.*
+*.moc
+moc_*.cpp
+moc_*.h
+qrc_*.cpp
+ui_*.h
+Makefile*
+*build-*
+
+
+# Qt unit tests
+target_wrapper.*
+
+
+# QtCreator
+
+*.autosave
+
+# QtCtreator Qml
+*.qmlproject.user
+*.qmlproject.user.*
+
+# QtCtreator CMake
+CMakeLists.txt.user*

+ 66 - 0
application.cpp

@@ -0,0 +1,66 @@
+#include "application.h"
+#include <QProcess>
+#include <QDebug>
+Application::Application(QObject *parent) :
+    QObject(parent),
+    m_process(new QProcess(this))
+{
+    connect(m_process,
+               SIGNAL(finished(int, QProcess::ExitStatus)),
+               SLOT(finished(int, QProcess::ExitStatus)));
+}
+
+QString Application::appName() const
+{
+    return m_AppName;
+}
+
+void Application::setAppName(const QString &appName)
+{
+    m_AppName = appName;
+}
+
+QString Application::stdERR() const
+{
+    return m_stdERR;
+}
+
+void Application::setstdERR(const QString &stdERR)
+{
+    m_stdERR = stdERR;
+}
+
+QString Application::stdOUT() const
+{
+    return m_stdOUT;
+}
+
+void Application::setstdOUT(const QString &stdOUT)
+{
+    m_stdOUT = stdOUT;
+}
+
+
+QString Application::arguments() const
+{
+    return m_Arguments;
+}
+
+void Application::setArguments(const QString &arguments)
+{
+    m_Arguments = arguments;
+}
+
+QString Application::launchScriptGetSTDOUT()
+{
+    m_process->start(m_AppName + " " +  m_Arguments);
+//    m_process->waitForStarted(-1);
+    return "Start requested";
+    qDebug() << "launching application" << m_AppName << "\n with the Argument of \n" + m_Arguments  ;
+}
+void Application::finished(int exitCode, QProcess::ExitStatus status)
+{
+    m_stdOUT = QString(m_process->readAllStandardOutput());
+    m_stdERR = QString(m_process->readAllStandardError());
+    emit this->appFinished();
+}

+ 40 - 0
application.h

@@ -0,0 +1,40 @@
+#ifndef APPLICATION_H
+#define APPLICATION_H
+#include <QObject>
+#include <QProcess>
+class Application : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit Application(QObject *parent = 0);
+    Q_PROPERTY( QString         appName                 READ appName                 WRITE setAppName                 )
+    Q_PROPERTY( QString         arguments                 READ arguments                 WRITE setArguments                 )
+    Q_PROPERTY( QString         stdERR                 READ stdERR                 WRITE setstdERR                 )
+    Q_PROPERTY( QString         stdOUT                 READ stdOUT                 WRITE setstdOUT                 )
+
+    QString appName() const;
+    void setAppName(const QString &appName);
+    QString arguments() const;
+    void setArguments(const QString &arguments);
+    QString stdERR() const;
+    void setstdERR(const QString &stdERR);
+    QString stdOUT() const;
+    void setstdOUT(const QString &stdOUT);
+    Q_INVOKABLE void launchScript();
+    Q_INVOKABLE QString launchScriptGetSTDOUT();
+
+ Q_SIGNALS:
+    void appFinished();
+
+private:
+    QProcess *m_process;
+    QString m_AppName;
+    QString m_Arguments;
+    QString m_stdERR;
+    QString m_stdOUT;
+
+private Q_SLOTS:
+    void finished(int exitCode, QProcess::ExitStatus status);
+};
+#endif //APPLICATION_H

+ 16 - 0
applicationlauncher.cpp

@@ -0,0 +1,16 @@
+#include "applicationlauncher.h"
+
+ApplicationLauncher::ApplicationLauncher(QQuickItem *parent):
+    QQuickItem(parent)
+{
+    // By default, QQuickItem does not draw anything. If you subclass
+    // QQuickItem to create a visual item, you will need to uncomment the
+    // following line and re-implement updatePaintNode()
+    
+    // setFlag(ItemHasContents, true);
+}
+
+ApplicationLauncher::~ApplicationLauncher()
+{
+}
+

+ 19 - 0
applicationlauncher.h

@@ -0,0 +1,19 @@
+#ifndef APPLICATIONLAUNCHER_H
+#define APPLICATIONLAUNCHER_H
+
+#include <QQuickItem>
+
+class ApplicationLauncher : public QQuickItem
+{
+    Q_OBJECT
+    Q_DISABLE_COPY(ApplicationLauncher)
+    
+public:
+    ApplicationLauncher(QQuickItem *parent = 0);
+    ~ApplicationLauncher();
+};
+
+QML_DECLARE_TYPE(ApplicationLauncher)
+
+#endif // APPLICATIONLAUNCHER_H
+

+ 37 - 0
applicationlauncher.pro

@@ -0,0 +1,37 @@
+TEMPLATE = lib
+TARGET = ApplicationLauncher
+QT += qml quick
+CONFIG += qt plugin
+
+TARGET = $$qtLibraryTarget($$TARGET)
+uri = ApplicationLauncher
+
+# Input
+SOURCES += \
+    applicationlauncher_plugin.cpp \
+    applicationlauncher.cpp \
+    application.cpp
+
+HEADERS += \
+    applicationlauncher_plugin.h \
+    applicationlauncher.h \
+    application.h
+
+OTHER_FILES = qmldir
+
+!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
+    copy_qmldir.target = $$OUT_PWD/qmldir
+    copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
+    copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
+    QMAKE_EXTRA_TARGETS += copy_qmldir
+    PRE_TARGETDEPS += $$copy_qmldir.target
+}
+
+qmldir.files = qmldir
+unix {
+    installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
+    qmldir.path = $$installPath
+    target.path = $$installPath
+    INSTALLS += target qmldir
+}
+

+ 15 - 0
applicationlauncher_plugin.cpp

@@ -0,0 +1,15 @@
+#include "applicationlauncher_plugin.h"
+#include "applicationlauncher.h"
+#include "application.h"
+// #include "unixmodel.h"
+// #include "appsunixmodel.h"
+#include <qqml.h>
+
+void ApplicationLauncherPlugin::registerTypes(const char *uri)
+{
+    // @uri ApplicationLauncher
+    qmlRegisterType<ApplicationLauncher>(uri, 1, 0 , "ApplicationLauncher");
+    qmlRegisterType<Application>(uri, 1, 0, "Application");
+}
+
+

+ 16 - 0
applicationlauncher_plugin.h

@@ -0,0 +1,16 @@
+#ifndef APPLICATIONLAUNCHER_PLUGIN_H
+#define APPLICATIONLAUNCHER_PLUGIN_H
+
+#include <QQmlExtensionPlugin>
+
+class ApplicationLauncherPlugin : public QQmlExtensionPlugin
+{
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+    
+public:
+    void registerTypes(const char *uri);
+};
+
+#endif // APPLICATIONLAUNCHER_PLUGIN_H
+

+ 3 - 0
qmldir

@@ -0,0 +1,3 @@
+module ApplicationLauncher
+plugin ApplicationLauncher
+