Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
azubieta
plasma-appimage-integration
Commits
18f5bd1e
Verified
Commit
18f5bd1e
authored
Aug 05, 2019
by
azubieta
Browse files
Add install command
parent
1af17332
Pipeline
#659
passed with stage
in 6 minutes and 48 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/CMakeLists.txt
View file @
18f5bd1e
...
...
@@ -3,6 +3,7 @@ add_executable(
main.cpp
UpdateJob.cpp
RemoveJob.cpp
InstallJob.cpp
)
target_link_libraries
(
plasma-appimage-integration appimageservices-interfaces KF5::KIOWidgets KF5::I18n KF5::Notifications
)
...
...
src/bin/InstallJob.cpp
0 → 100644
View file @
18f5bd1e
// libraries
#include
<QtCore/QTimer>
#include
<QtCore/QDebug>
#include
<KI18n/KLocalizedString>
#include
<utility>
// local
#include
"InstallJob.h"
InstallJob
::
InstallJob
(
QString
target
,
QObject
*
parent
)
:
KJob
(
parent
),
target
(
std
::
move
(
target
))
{}
void
InstallJob
::
start
()
{
process
.
setProgram
(
"pkexec"
);
process
.
setArguments
({
"appimage-services"
,
"install"
,
target
});
qDebug
()
<<
"calling pkexec appimage-services install "
<<
target
;
connect
(
&
process
,
SIGNAL
(
finished
(
int
)),
this
,
SLOT
(
onProcessFinished
(
int
)));
description
(
this
,
i18n
(
"Installing Application"
),
qMakePair
<
QString
,
QString
>
(
i18nc
(
"The AppImage being installed"
,
"Source"
),
target
));
process
.
start
();
}
void
InstallJob
::
onProcessFinished
(
int
exitCode
)
{
qDebug
()
<<
exitCode
;
qDebug
()
<<
process
.
errorString
();
if
(
exitCode
!=
0
)
{
setError
(
exitCode
);
setErrorText
(
process
.
readAllStandardError
());
}
// notify result delayed
QTimer
::
singleShot
(
1000
,
this
,
&
InstallJob
::
emitResult
);
}
src/bin/InstallJob.h
0 → 100644
View file @
18f5bd1e
#pragma once
// libraries
#include
<KJob>
#include
<QtCore/QProcess>
class
InstallJob
:
public
KJob
{
Q_OBJECT
public:
explicit
InstallJob
(
QString
target
,
QObject
*
parent
=
nullptr
);
void
start
()
override
;
protected
slots
:
void
onProcessFinished
(
int
exitCode
);
private:
QString
target
;
QProcess
process
;
};
src/bin/main.cpp
View file @
18f5bd1e
...
...
@@ -11,6 +11,7 @@
// local
#include
"UpdateJob.h"
#include
"RemoveJob.h"
#include
"InstallJob.h"
QString
parseTarget
(
QCommandLineParser
&
parser
)
{
...
...
@@ -51,6 +52,13 @@ void executeRemoveCommand(const QString& target) {
}
void
executeInstallCommand
(
const
QString
&
target
)
{
KJob
*
job
=
new
InstallJob
(
target
);
KIO
::
getJobTracker
()
->
registerJob
(
job
);
job
->
start
();
}
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
app
(
argc
,
argv
);
QApplication
::
setApplicationName
(
"plasma-appimage-integration"
);
...
...
@@ -82,6 +90,10 @@ int main(int argc, char** argv) {
executeRemoveCommand
(
target
);
}
if
(
command
==
"install"
)
{
QString
target
=
parseTarget
(
parser
);
executeInstallCommand
(
target
);
}
return
QApplication
::
exec
();
}
...
...
src/fileitem-actions/AppImageFileItemActions.cpp
View file @
18f5bd1e
...
...
@@ -45,7 +45,7 @@ QList<QAction*> AppImageFileItemActions::actions(const KFileItemListProperties&
actions
+=
createRemoveFromMenuAction
(
fileItemInfos
,
parentWidget
);
}
}
else
{
qWarning
()
<<
"Unable to connect to the AppImage Launcher Service"
;
qWarning
()
<<
"
Discarding AppImage Add/Remove to Menu actions.
Unable to connect to the AppImage Launcher Service"
;
}
if
(
launcherInterface
->
isValid
())
{
...
...
@@ -55,9 +55,11 @@ QList<QAction*> AppImageFileItemActions::actions(const KFileItemListProperties&
connect
(
updateAction
,
&
QAction
::
triggered
,
this
,
&
AppImageFileItemActions
::
update
);
actions
+=
updateAction
;
}
else
{
qWarning
()
<<
"Unable to connect to the AppImage
Updater Service
"
;
qWarning
()
<<
"
Discarding AppImage Update action.
Unable to connect to the AppImage
Launcher Updater
"
;
}
actions
+=
createInstallAction
(
fileItemInfos
,
parentWidget
);
return
actions
;
}
...
...
@@ -81,6 +83,15 @@ QAction* AppImageFileItemActions::createAddToMenuAction(const KFileItemListPrope
return
addToMenuAction
;
}
QAction
*
AppImageFileItemActions
::
createInstallAction
(
const
KFileItemListProperties
&
fileItemInfos
,
QWidget
*
parentWidget
)
const
{
QAction
*
installAction
=
new
QAction
(
QIcon
::
fromTheme
(
"install"
),
"Install"
,
parentWidget
);
installAction
->
setProperty
(
"urls"
,
QVariant
::
fromValue
(
fileItemInfos
.
urlList
()));
installAction
->
setProperty
(
"parentWidget"
,
QVariant
::
fromValue
(
parentWidget
));
connect
(
installAction
,
&
QAction
::
triggered
,
this
,
&
AppImageFileItemActions
::
install
);
return
installAction
;
}
void
AppImageFileItemActions
::
addToMenu
()
{
const
QList
<
QUrl
>
urls
=
sender
()
->
property
(
"urls"
).
value
<
QList
<
QUrl
>>
();
QWidget
*
parentWidget
=
sender
()
->
property
(
"parentWidget"
).
value
<
QWidget
*>
();
...
...
@@ -123,6 +134,18 @@ void AppImageFileItemActions::update() {
}
}
void
AppImageFileItemActions
::
install
()
{
const
QList
<
QUrl
>
urls
=
sender
()
->
property
(
"urls"
).
value
<
QList
<
QUrl
>>
();
QString
program
=
"plasma-appimage-integration"
;
for
(
const
QUrl
&
url
:
urls
)
{
QStringList
arguments
;
arguments
<<
"install"
<<
url
.
toLocalFile
();
QProcess
::
startDetached
(
program
,
arguments
);
}
}
void
AppImageFileItemActions
::
showErrorMessage
(
const
QString
&
title
,
const
QString
&
message
,
QWidget
*
parentWidget
)
{
KNotification
*
notify
=
new
KNotification
(
QStringLiteral
(
"notification"
),
parentWidget
,
KNotification
::
CloseOnTimeout
|
KNotification
::
DefaultEvent
);
...
...
src/fileitem-actions/AppImageFileItemActions.h
View file @
18f5bd1e
...
...
@@ -33,6 +33,8 @@ private Q_SLOTS:
void
update
();
void
install
();
private:
OrgAppimageServices1LauncherInterface
*
launcherInterface
;
OrgAppimageServices1UpdaterInterface
*
updaterInterface
;
...
...
@@ -42,4 +44,6 @@ private:
QAction
*
createAddToMenuAction
(
const
KFileItemListProperties
&
fileItemInfos
,
QWidget
*
parentWidget
)
const
;
QAction
*
createRemoveFromMenuAction
(
const
KFileItemListProperties
&
fileItemInfos
,
QWidget
*
parentWidget
)
const
;
QAction
*
createInstallAction
(
const
KFileItemListProperties
&
fileItemInfos
,
QWidget
*
parentWidget
)
const
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment