+++ /dev/null
-plugins/qmlprocess/ProcessObject.cpp
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include <signal.h>
+#include <sys/types.h>
+
+#include <QtCore/QTime>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtCore/QDebug>
+#include <QtCore/QTextCodec>
+
+#include "ProcessObject.h"
+
+ProcessObject::ProcessObject(QObject *parent):
+ QObject(parent),
+ m_suspend(false), m_started(false)
+{
+ m_process = new QProcess(this);
+ connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
+ this,
+ SLOT(processFinished(int, QProcess::ExitStatus)));
+ connect(m_process, SIGNAL(error(QProcess::ProcessError)),this,
+ SLOT(processErrored(QProcess::ProcessError)));
+}
+
+ProcessObject::~ProcessObject()
+{
+ if (m_started)
+ {
+ terminate();
+ }
+ delete m_process;
+}
+
+void ProcessObject::processErrored(QProcess::ProcessError error) {
+ QString err(m_process->readAllStandardError());
+ qDebug() << "failed with exitCode" << m_process->exitCode();
+ emit failed(m_process->exitCode(), err, error);
+ m_started = false;
+}
+
+void ProcessObject::processFinished(int exitCode,
+ QProcess::ExitStatus exitStatus)
+{
+ QTextCodec* codec = QTextCodec::codecForName("utf-8");
+ if (exitStatus == QProcess::NormalExit)
+ {
+ if (exitCode == 0)
+ {
+ QString out = codec->toUnicode(m_process->readAllStandardOutput());
+ qDebug() << "normal";
+ emit completed(out.trimmed());
+ }
+ else
+ {
+ QString err = codec->toUnicode(m_process->readAllStandardError());
+ qDebug() << "failed";
+ emit failed(exitCode, err.trimmed(), m_process->error());
+ }
+ }
+ else
+ {
+ QString err = codec->toUnicode(m_process->readAllStandardError());
+ qDebug() << "failed";
+ emit failed(exitCode, err, m_process->error());
+ }
+ m_started = false;
+}
+
+QString ProcessObject::command() const
+{
+ return m_command;
+}
+
+void ProcessObject::setCommand(const QString &command)
+{
+ if (m_command != command) {
+ m_command = command;
+ }
+}
+
+void ProcessObject::run()
+{
+ if (m_started)
+ {
+ return;
+ qDebug() << "already started";
+ }
+ qDebug() << m_command;
+ m_process->start(m_command);
+ qDebug() << "started";
+ m_started = true;
+}
+
+bool ProcessObject::isSuspended() const
+{
+ return m_suspend;
+}
+
+void ProcessObject::setSuspend(bool suspend)
+{
+ if (!m_started || m_process->pid() == 0)
+ {
+ qDebug() << "No process running";
+ return;
+ }
+ if (m_suspend != suspend)
+ {
+ if (m_suspend)
+ {
+ ::kill(m_process->pid(), SIGCONT);
+ qDebug() << "Process resumed";
+
+ } else {
+ ::kill(m_process->pid(), SIGSTOP);
+ qDebug() << "Process suspended";
+
+ }
+ emit suspendChanged(suspend);
+ m_suspend = suspend;
+ }
+}
+
+void ProcessObject::terminate()
+{
+ if (m_started && m_process->pid() != 0)
+ {
+ m_process->kill();
+ }
+}
+
+
+QML_DECLARE_TYPE(ProcessObject);
+++ /dev/null
-plugins/qmlprocess/ProcessObject.h
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef EXAMPLEITEM_H
+#define EXAMPLEITEM_H
+
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QProcess>
+
+class ProcessObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString command READ command WRITE setCommand)
+ Q_PROPERTY(bool suspend READ isSuspended WRITE setSuspend NOTIFY suspendChanged)
+
+public:
+ ProcessObject(QObject *parent = 0);
+ ~ProcessObject();
+
+ Q_INVOKABLE void run();
+ Q_INVOKABLE void terminate();
+
+ QString command() const;
+ void setCommand(const QString &command);
+ bool isSuspended() const;
+ void setSuspend(bool suspend);
+
+signals:
+ void completed(const QString& stdout);
+ void failed(int exitCode, const QString& stderr,
+ QProcess::ProcessError error);
+ void suspendChanged(bool);
+
+private slots:
+ void processFinished(int exitCode,
+ QProcess::ExitStatus exitStatus);
+ void processErrored(QProcess::ProcessError error);
+
+private:
+
+ QString m_command;
+ QProcess* m_process;
+ bool m_suspend;
+ bool m_started;
+
+ Q_DISABLE_COPY(ProcessObject)
+};
+
+#endif // EXAMPLEITEM_H
\r
#include "appeventlistener.hpp"\r
#include "quickwidgetsettings.hpp"\r
+#include "quickwidget.hpp"\r
\r
static AppEventListener *_instance = NULL;\r
\r
QObject(parent)\r
{\r
// Connect to the QtSingleApplication's event\r
- QObject::connect(QtSingleApplication::instance(), SIGNAL(messageReceived(const QString&)), this, SLOT(receiveMessage(const QString&)));\r
+ QObject::connect(QtSingleApplication::instance(), SIGNAL(messageReceived(const QString&)), \r
+ this, SLOT(receiveMessage(const QString&)));\r
}\r
\r
void AppEventListener::receiveMessage(const QString& message)\r
{\r
- if (message == APP_MESSAGE_ADDWIDGET)\r
+ if (message.endsWith(".qml")) {\r
+ QuickWidget::createAndShowNew(message);\r
+ \r
+ } else if (message == APP_MESSAGE_SETWIDGET)\r
{\r
- qDebug() << "TTTTTTEEEEST";\r
QuickWidgetSettings settings;\r
settings.exec();\r
}\r
\r
#include <QObject>\r
\r
-#define APP_MESSAGE_ADDWIDGET "Add widget"\r
+#define APP_MESSAGE_SETWIDGET "Add widget"\r
#define APP_MESSAGE_CLOSE "Close"\r
\r
class AppEventListener : public QObject\r
+quick-widgets (0.2.4) unstable; urgency=low
+
+ * enabled adding widgets from the command-line
+
+ -- Malte Marquarding <malte@marquarding.com> Mon, 21 Mar 2011 23:29:30 +1100
+
+quick-widgets (0.2.3) unstable; urgency=low
+
+ * added qt-mobility imports to search locations
+
+ -- Malte Marquarding <malte@marquarding.com> Thu, 17 Mar 2011 09:45:14 +1100
+
quick-widgets (0.2.2) unstable; urgency=low
* added unicode support for standard output
Package: quick-widgets
Architecture: any
-Depends: ${shlibs:Depends}, libhildon-extras1, q-extras (>=1.0.5)
+Depends: ${shlibs:Depends}, libhildon-extras1, q-extras (>=1.0.5), libqtm-12-declarative (>=1.2.0)
XB-Maemo-Display-Name: Quick Widgets
Description: This application simplifies running Qt Quick applications as
home desktop widgets. It only needs the file. Thanks to Timur Kristóf (Venemo)
else
{
qDebug() << "Asking it to offer to create a new widget.";
- app.sendMessage(APP_MESSAGE_ADDWIDGET);
+ QStringList result;
+ result = app.arguments().filter(".qml");
+ if (result.size() == 1 && QFile(result.last()).exists()) {
+ app.sendMessage(QFileInfo(result.last()).absoluteFilePath());
+ } else {
+ app.sendMessage(APP_MESSAGE_SETWIDGET);
+ }
return 0;
}
}
qDebug() << "Restoring all widgets";
QeMaemo5DynamicWidgetHelper::globalInstance()->restoreWidgets<QuickWidget>();
}
-
- if (!app.arguments().contains("in-background"))
+ QStringList result;
+ result = app.arguments().filter(".qml");
+ if (result.size() == 1 && QFile(result.last()).exists()) {
+ app.sendMessage(QFileInfo(result.last()).absoluteFilePath());
+ } else if (!app.arguments().contains("in-background"))
{
// setting for new widget
QuickWidgetSettings settingsDialog;
settingsDialog.exec();
- //app.sendMessage(APP_MESSAGE_ADDWIDGET);
+ //app.sendMessage(APP_MESSAGE_SETWIDGET);
}
return app.exec();
}
}
//layout()->setSizeConstraint(QLayout::SetNoConstraint);
view_ = new QDeclarativeView(this);
+ view_->engine()->addImportPath(QString("/opt/qtm12/imports"));
view_->setStyleSheet("background:transparent");
view_->setAttribute(Qt::WA_TranslucentBackground);
wrapper_ = new QuickWidgetWrapper(this);