Add freedesktop interface
https://github.com/cutefishos/filemanager/issues/16
This commit is contained in:
parent
457da122cc
commit
5b748d35e7
4 changed files with 64 additions and 0 deletions
|
@ -26,6 +26,8 @@ add_executable(cutefish-filemanager
|
||||||
main.cpp
|
main.cpp
|
||||||
application.cpp
|
application.cpp
|
||||||
window.cpp
|
window.cpp
|
||||||
|
dbusinterface.cpp
|
||||||
|
|
||||||
model/foldermodel.cpp
|
model/foldermodel.cpp
|
||||||
model/placesmodel.cpp
|
model/placesmodel.cpp
|
||||||
model/placesitem.cpp
|
model/placesitem.cpp
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
|
#include "dbusinterface.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "desktop/desktop.h"
|
#include "desktop/desktop.h"
|
||||||
#include "thumbnailer/thumbnailprovider.h"
|
#include "thumbnailer/thumbnailprovider.h"
|
||||||
|
@ -42,6 +43,7 @@ Application::Application(int& argc, char** argv)
|
||||||
setWindowIcon(QIcon::fromTheme("file-manager"));
|
setWindowIcon(QIcon::fromTheme("file-manager"));
|
||||||
|
|
||||||
new FileManagerAdaptor(this);
|
new FileManagerAdaptor(this);
|
||||||
|
new DBusInterface;
|
||||||
QDBusConnection::sessionBus().registerObject("/FileManager", this);
|
QDBusConnection::sessionBus().registerObject("/FileManager", this);
|
||||||
|
|
||||||
// Translations
|
// Translations
|
||||||
|
|
41
dbusinterface.cpp
Normal file
41
dbusinterface.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#include "dbusinterface.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusConnectionInterface>
|
||||||
|
|
||||||
|
DBusInterface::DBusInterface()
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().registerObject("/org/freedesktop/FileManager1", this,
|
||||||
|
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||||
|
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
|
||||||
|
|
||||||
|
if (sessionInterface) {
|
||||||
|
sessionInterface->registerService(QStringLiteral("org.freedesktop.FileManager1"), QDBusConnectionInterface::QueueService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusInterface::ShowFolders(const QStringList &uriList, const QString &startUpId)
|
||||||
|
{
|
||||||
|
Q_UNUSED(startUpId);
|
||||||
|
|
||||||
|
qDebug() << uriList;
|
||||||
|
|
||||||
|
QProcess::startDetached("cutefish-filemanager", uriList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusInterface::ShowItems(const QStringList &uriList, const QString &startUpId)
|
||||||
|
{
|
||||||
|
Q_UNUSED(startUpId);
|
||||||
|
|
||||||
|
QProcess::startDetached("cutefish-filemanager", uriList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusInterface::ShowItemProperties(const QStringList &uriList, const QString &startUpId)
|
||||||
|
{
|
||||||
|
Q_UNUSED(uriList);
|
||||||
|
Q_UNUSED(startUpId);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
19
dbusinterface.h
Normal file
19
dbusinterface.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef DBUSINTERFACE_H
|
||||||
|
#define DBUSINTERFACE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class DBusInterface : QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.FileManager1")
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBusInterface();
|
||||||
|
|
||||||
|
Q_SCRIPTABLE void ShowFolders(const QStringList& uriList, const QString& startUpId);
|
||||||
|
Q_SCRIPTABLE void ShowItems(const QStringList& uriList, const QString& startUpId);
|
||||||
|
Q_SCRIPTABLE void ShowItemProperties(const QStringList& uriList, const QString& startUpId);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DBUSINTERFACE_H
|
Loading…
Reference in a new issue