Support open file manager

pull/2/head
reionwong 4 years ago
parent 840892753e
commit 3bbe700f96

@ -31,6 +31,8 @@ endif()
set(SRCS
src/main.cpp
src/processhelper.h
src/processhelper.cpp
)
set(RESOURCES

@ -24,6 +24,8 @@
#include <QTranslator>
#include <QFile>
#include "processhelper.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@ -44,6 +46,7 @@ int main(int argc, char *argv[])
}
}
engine.rootContext()->setContextProperty("Process", new ProcessHelper);
engine.addImportPath(QStringLiteral("qrc:/"));
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));

@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Reion Wong <reionwong@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processhelper.h"
#include <QProcess>
ProcessHelper *SELF = nullptr;
ProcessHelper *ProcessHelper::self()
{
if (!SELF)
SELF = new ProcessHelper;
return SELF;
}
ProcessHelper::ProcessHelper(QObject *parent)
: QObject(parent)
{
}
bool ProcessHelper::startDetached(const QString &program, const QStringList &arguments)
{
return QProcess::startDetached(program, arguments);
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Reion Wong <reionwong@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROCESSHELPER_H
#define PROCESSHELPER_H
#include <QObject>
class ProcessHelper : public QObject
{
Q_OBJECT
public:
static ProcessHelper *self();
explicit ProcessHelper(QObject *parent = nullptr);
Q_INVOKABLE bool startDetached(const QString &program, const QStringList &arguments);
};
#endif // PROCESSHELPER_H

@ -174,7 +174,7 @@ Page {
MenuItem {
text: qsTr("Open File Manager")
onTriggered: {}
onTriggered: Process.startDetached("gio", ["open", _session.currentDir])
}
}

Loading…
Cancel
Save