Hoxe estou de folga en contra da reforma laboral. Aínda que teño a sorte de traballar nunha empresa na que non me teño que preocupar por se vou ser despedido xa que son socio dela, considero o meu deber loitar tamén polos dereitos dos demais e tratar de botar para atrás algo que vai acentuar a precarización do traballo e sumirnos aínda máis na maldita crise. Eu achegareime á
manifestación da Praza de Vigo á convocada pola CIG, metade por quizais algo máis de afinidade política, como outra metade por aletoriedade a causa do patetismo que me causa que non se poñan dacordo por algo tan importante coma isto.
Monthly Archives: March 2012
Invoking Meego 1.2 Harmattan Gallery
As part of my work at Igalia I am writing an app to record some videos for the Nokia N9. I wanted to get them shown in the gallery so I tried the DBUS approach, that is something similar to what is explained here. The problem is the same they faced, meaning that I got gallery in foreground when it was not previously running, but not otherwise.
The solution to that was using libcontentaction. In order to get this working, first you need to get the vendor name in the tags of your pictures or videos, otherwise Tracker will not index them correctly and this solution can be useless.
With the following solution Gallery will be brought to foreground and show the desired file. Code would be something like:
using ContentAction::Action; [...] { Action action = Action::defaultActionForFile(uri, "x-maemo-nepomuk/device-captured-video"); if (action.isValid()) { qDebug() < < Q_FUNC_INFO << "chosen action:" << action.name(); action.triggerAndWait(); } else { qWarning() << "could not file action for" << m_file; } }
The mime type is one of the defined in the galleryserviceaction.desktop
that you can find in the device. For images, you can also check the mime types in that file and maybe you do not need to specify it, but I have not tried this and let it to you. Please, comment me your findings.
Mixed QML/C++ objects reloaded
Some days ago I was writing about how to have mixed QML/C++ objects in a QML application for Igalia, but I faced a problem with the code that I had written. And the problem was that I needed to receive some events and from the QML elements I was loading. Retaking that code:
#define QML_PATH "/path/to/the/qml/files/" MyObject::MyObject(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent) { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(QML_PATH "MyObject.qml")); QDeclarativeItem *rect = dynamic_cast(component.create()); rect->setParentItem(this); }
and being MyObject.qml something like:
Button { id: "myButton" text: "Do something cool" }
The natural way of connecting that button to some slot you are writing would be something like:
MyObject::MyObject(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent) { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(QML_PATH "MyObject.qml")); QDeclarativeItem *item = dynamic_cast(component.create()); item->setParentItem(this); connect(item, SIGNAL(clicked()), this, SLOT(doCoolStuff())); }
Even if you do this, you are not getting any event in the QML button you declare. It behaves as it were a label or whatever, but the key is the engine. The engine must live while you need the events of the QML component. And the easiest way of getting that done is adding the engine as a private class attribute:
#ifndef MYOBJECT_H #define MYOBJECT_H #include #include #include class PostCapture : public QDeclarativeItem { Q_OBJECT // ... private slots: void doCoolStuff(); private: QDeclarativeEngine m_engine; }; #endif
and of course removing the engine stack declaration from the constructor:
MyObject::MyObject(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent) { QDeclarativeComponent component(&m_engine, QUrl::fromLocalFile(QML_PATH "MyObject.qml")); QDeclarativeItem *item = dynamic_cast(component.create()); item->setParentItem(this); connect(item, SIGNAL(clicked()), this, SLOT(doCoolStuff())); }
Voilà.
Of course, if you need to connect to any element that is not the root element, you can always forward the signals and properties from the QML root object or just use the QObject::findChild method to access the right component.