File indexing completed on 2024-04-14 05:34:16

0001 /*
0002     SPDX-FileCopyrightText: 2020 Kwon-Young Choi <kwon-young.choi@hotmail.fr>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef MOUNTISOACTION_H
0008 #define MOUNTISOACTION_H
0009 
0010 #include <KAbstractFileItemActionPlugin>
0011 #include <KFileItemListProperties>
0012 
0013 class QAction;
0014 class QWidget;
0015 
0016 class KFileItemListProperties;
0017 
0018 /**
0019  * File item action plugin to mount and unmount an iso file.
0020  *
0021  * This class adds a mount or unmount entry to an iso file contextual menu. If
0022  * the iso file is already mounted, only the unmount entry will be shown while
0023  * if the iso file is not mounted, only the mount entry will be shown.
0024  *
0025  * The current implementation uses a loop device to mount the iso file.
0026  *
0027  */
0028 class MountIsoAction : public KAbstractFileItemActionPlugin
0029 {
0030 
0031     Q_OBJECT
0032 
0033 public:
0034     MountIsoAction(QObject *parent, const QVariantList &args);
0035 
0036     /**
0037      * Adds a mount or unmount entry to the contextual menu of an iso file.
0038      *
0039      * For a menu entry to be shown, only one file should be selected, the
0040      * mimetype of the file should be "application/x-cd-image" and the file
0041      * should be local. Then, the mount state of the iso file is checked and if
0042      * the iso file is already mounted, we get the corresponding block device.
0043      * If the iso file is not already mounted, we show a mount entry and create
0044      * a callback to mount the iso file using udisksctl.
0045      * If the iso file is already mounted, we show a unmount entry and create a
0046      * callback to unmount the iso file using udisksctl.
0047      */
0048     QList<QAction *> actions(const KFileItemListProperties &fileItemInfos,
0049                              QWidget *parentWidget) override;
0050 };
0051 
0052 #endif