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

@ -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() << "----------------------";