[libcalamaresui] Add openUrl user session method
This commit is contained in:
parent
75ff3ee69c
commit
50918f10b2
@ -23,6 +23,7 @@ set(calamaresui_SOURCES
|
||||
utils/CalamaresUtilsGui.cpp
|
||||
utils/ImageRegistry.cpp
|
||||
utils/Paste.cpp
|
||||
utils/QmlDesktopUtils.cpp
|
||||
viewpages/BlankViewStep.cpp
|
||||
viewpages/ExecutionViewStep.cpp
|
||||
viewpages/Slideshow.cpp
|
||||
|
@ -17,12 +17,14 @@
|
||||
#include "network/Manager.h"
|
||||
#include "utils/Dirs.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/QmlDesktopUtils.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <qqml.h>
|
||||
|
||||
static QDir s_qmlModulesDir( QString( CMAKE_INSTALL_FULL_DATADIR ) + "/qml" );
|
||||
|
||||
@ -246,6 +248,14 @@ registerQmlModels()
|
||||
0,
|
||||
"Network",
|
||||
[]( QQmlEngine*, QJSEngine* ) -> QObject* { return &CalamaresUtils::Network::Manager::instance(); } );
|
||||
|
||||
|
||||
qmlRegisterSingletonType< CalamaresUtils::QmlDesktopUtils >( "org.manjaro.calamares.desktop",
|
||||
1,
|
||||
0,
|
||||
"DesktopUtils",
|
||||
[]( QQmlEngine* e, QJSEngine* ) -> QObject*
|
||||
{ return new QmlDesktopUtils( e ); } );
|
||||
}
|
||||
}
|
||||
|
||||
|
26
src/libcalamaresui/utils/QmlDesktopUtils.cpp
Normal file
26
src/libcalamaresui/utils/QmlDesktopUtils.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
/* === This file is part of Manjaro's Calamares modules - <https://gitlab.manjaro.org/applications/calamares> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2023 Artem Grinev <agrinev@manjaro.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QmlDesktopUtils.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QQmlEngine>
|
||||
|
||||
CalamaresUtils::QmlDesktopUtils::QmlDesktopUtils( QQmlEngine* parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
}
|
||||
void
|
||||
CalamaresUtils::QmlDesktopUtils::openUrl( const QString& url )
|
||||
{
|
||||
QProcess::execute(
|
||||
QLatin1String( "/usr/bin/sudo" ),
|
||||
{ QLatin1String( "-u" ), QLatin1String( "#1000" ), QLatin1String( "-E" ), QLatin1String( "xdg-open" ), url } );
|
||||
}
|
30
src/libcalamaresui/utils/QmlDesktopUtils.h
Normal file
30
src/libcalamaresui/utils/QmlDesktopUtils.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* === This file is part of Manjaro's Calamares modules - <https://gitlab.manjaro.org/applications/calamares> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2023 Artem Grinev <agrinev@manjaro.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UTILS_QMLDESKTOPUTILS_H
|
||||
#define UTILS_QMLDESKTOPUTILS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
class QQmlEngine;
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
class QmlDesktopUtils : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlDesktopUtils( QQmlEngine* parent = 0 );
|
||||
|
||||
Q_INVOKABLE void openUrl( const QString& url );
|
||||
};
|
||||
|
||||
} // namespace CalamaresUtils
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user