blob: d4f68dc95428e065dbc0ba5b13903cb88acfcb99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <QDir>
#include <QQmlContext>
#include <QApplication>
#include <QQmlApplicationEngine>
class WorkingDirectory : public QObject {
Q_OBJECT
public:
Q_INVOKABLE bool cd(const QString& path) const {
QDir current(QDir::current());
const bool result = current.cd(path);
QDir::setCurrent(current.absolutePath());
return result;
}
Q_INVOKABLE QString current() const {
return QDir::current().absolutePath();
}
Q_INVOKABLE QString currentOfPID(const int pid) const {
return QDir("/proc/" + QString::number(pid) + "/cwd/").canonicalPath();
}
};
int main(int argc, char *argv[]) {
WorkingDirectory directory;
QApplication application(argc, argv);
QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:/main.qml")));
application.setOrganizationName("akr");
application.setApplicationName("MetaTerm");
engine.rootContext()->setContextProperty("cwd", &directory);
QObject::connect(
static_cast<QObject*>(&engine),
SIGNAL(quit()),
static_cast<QObject*>(&application),
SLOT(quit())
);
return application.exec();
}
#include "main.moc"
|