feat: interfaces for checking drive is removable

This commit is contained in:
Gary Wang 2019-11-29 16:15:07 +08:00
parent 8e0557c8c2
commit 1102267f03
3 changed files with 34 additions and 2 deletions

View file

@ -31,7 +31,7 @@ class Drive;
}
class DGioDrivePrivate;
class DGioDrive : public QObject, public QSharedData{
class DGioDrive : public QObject, public QSharedData {
Q_OBJECT
public:
explicit DGioDrive(Gio::Drive *gmmDrivePtr, QObject *parent = nullptr);
@ -43,6 +43,8 @@ public:
bool canStart() const;
bool canStop() const;
bool canEject() const;
bool isMediaRemovable() const;
bool isRemovable() const;
private:
QScopedPointer<DGioDrivePrivate> d_ptr;

View file

@ -108,3 +108,33 @@ bool DGioDrive::canEject() const
return d->getGmmDriveInstence()->can_eject();
}
/*!
* \brief Checks if the drive supports removable media.
*
* Wrapper of Gio::Drive::is_media_removable()
*
* \return true if drive supports removable media, false otherwise.
*/
bool DGioDrive::isMediaRemovable() const
{
Q_D(const DGioDrive);
return d->getGmmDriveInstence()->is_media_removable();
}
/*!
* \brief Checks if the drive and/or its media is considered removable by the user.
*
* Wrapper of Gio::Drive::is_removable()
*
* \return true if drive and/or its media is considered removable, false otherwise.
*
* \sa isMediaRemovable()
*/
bool DGioDrive::isRemovable() const
{
Q_D(const DGioDrive);
return d->getGmmDriveInstence()->is_removable();
}

View file

@ -136,7 +136,7 @@ int main(int argc, char * argv[])
const QList<QExplicitlySharedDataPointer<DGioDrive> > drvs = DGioVolumeManager::getDrives();
for (const QExplicitlySharedDataPointer<DGioDrive> &p : drvs) {
qDebug() << p->name();
qDebug() << p->name() << p->isRemovable() << p->isMediaRemovable();
}
qDebug() << "----------------------";