mirror of
https://github.com/linuxdeepin/gio-qt.git
synced 2024-12-27 07:26:09 +01:00
feat: interfaces for checking drive is removable
This commit is contained in:
parent
8e0557c8c2
commit
1102267f03
3 changed files with 34 additions and 2 deletions
|
@ -43,6 +43,8 @@ public:
|
||||||
bool canStart() const;
|
bool canStart() const;
|
||||||
bool canStop() const;
|
bool canStop() const;
|
||||||
bool canEject() const;
|
bool canEject() const;
|
||||||
|
bool isMediaRemovable() const;
|
||||||
|
bool isRemovable() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<DGioDrivePrivate> d_ptr;
|
QScopedPointer<DGioDrivePrivate> d_ptr;
|
||||||
|
|
|
@ -108,3 +108,33 @@ bool DGioDrive::canEject() const
|
||||||
|
|
||||||
return d->getGmmDriveInstence()->can_eject();
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ int main(int argc, char * argv[])
|
||||||
const QList<QExplicitlySharedDataPointer<DGioDrive> > drvs = DGioVolumeManager::getDrives();
|
const QList<QExplicitlySharedDataPointer<DGioDrive> > drvs = DGioVolumeManager::getDrives();
|
||||||
|
|
||||||
for (const QExplicitlySharedDataPointer<DGioDrive> &p : drvs) {
|
for (const QExplicitlySharedDataPointer<DGioDrive> &p : drvs) {
|
||||||
qDebug() << p->name();
|
qDebug() << p->name() << p->isRemovable() << p->isMediaRemovable();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "----------------------";
|
qDebug() << "----------------------";
|
||||||
|
|
Loading…
Reference in a new issue