mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: handle optical drive/disc as block devices
This commit is contained in:
parent
9e3f9c37a6
commit
12e5949d9d
6 changed files with 13 additions and 31 deletions
|
@ -98,10 +98,10 @@ void KSolidNotify::onDeviceRemoved(const QString &udi)
|
|||
|
||||
bool KSolidNotify::isSafelyRemovable(const QString &udi)
|
||||
{
|
||||
Solid::Device parent = m_devices[udi].parent();
|
||||
if (parent.is<Solid::StorageDrive>())
|
||||
Solid::Device device = m_devices[udi];
|
||||
if (device.is<Solid::StorageDrive>())
|
||||
{
|
||||
Solid::StorageDrive *drive = parent.as<Solid::StorageDrive>();
|
||||
Solid::StorageDrive *drive = device.as<Solid::StorageDrive>();
|
||||
return (!drive->isInUse() && (drive->isHotpluggable() || drive->isRemovable()));
|
||||
}
|
||||
Solid::StorageAccess* access = m_devices[udi].as<Solid::StorageAccess>();
|
||||
|
@ -126,7 +126,7 @@ void KSolidNotify::connectSignals(Solid::Device* device)
|
|||
}
|
||||
if (device->is<Solid::OpticalDisc>())
|
||||
{
|
||||
Solid::OpticalDrive *drive = device->parent().as<Solid::OpticalDrive>();
|
||||
Solid::OpticalDrive *drive = device->as<Solid::OpticalDrive>();
|
||||
connect(drive, SIGNAL(ejectDone(Solid::ErrorType, QVariant, const QString &)),
|
||||
this, SLOT(storageEjectDone(Solid::ErrorType, QVariant , const QString &)));
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ void ContextMenuFactory::showContextMenu(QAbstractItemView *view,
|
|||
}
|
||||
} else if (ejectAction && result == ejectAction) {
|
||||
if (device.is<Solid::OpticalDisc>()) {
|
||||
Solid::OpticalDrive *drive = device.parent().as<Solid::OpticalDrive>();
|
||||
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
|
||||
drive->eject();
|
||||
} else {
|
||||
access->teardown();
|
||||
|
|
|
@ -367,7 +367,7 @@ void Trash::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||
Solid::Device device = devList.first();
|
||||
|
||||
if (device.is<Solid::OpticalDisc>()) {
|
||||
device.parent().as<Solid::OpticalDrive>()->eject();
|
||||
device.as<Solid::OpticalDrive>()->eject();
|
||||
} else {
|
||||
device.as<Solid::StorageAccess>()->teardown();
|
||||
}
|
||||
|
|
|
@ -29,22 +29,6 @@
|
|||
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
//TODO: implement in libsolid2
|
||||
namespace
|
||||
{
|
||||
template <class DevIface> DevIface *getAncestorAs(const Solid::Device &device)
|
||||
{
|
||||
for (Solid::Device parent = device.parent();
|
||||
parent.isValid();
|
||||
parent = parent.parent()) {
|
||||
if (parent.is<DevIface>()) {
|
||||
return parent.as<DevIface>();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SolidDeviceEngine::SolidDeviceEngine(QObject* parent, const QVariantList& args)
|
||||
: Plasma::DataEngine(parent, args),
|
||||
m_temperature(0),
|
||||
|
@ -204,7 +188,7 @@ bool SolidDeviceEngine::populateDeviceData(const QString &name)
|
|||
else {
|
||||
bool isRemovable = false;
|
||||
bool isHotpluggable = false;
|
||||
Solid::StorageDrive *drive = getAncestorAs<Solid::StorageDrive>(device);
|
||||
Solid::StorageDrive *drive = device.as<Solid::StorageDrive>();
|
||||
if (drive) {
|
||||
//remove check for isHotpluggable() when plasmoids are changed to check for both properties
|
||||
isRemovable = (drive->isRemovable() || drive->isHotpluggable());
|
||||
|
@ -568,7 +552,7 @@ void SolidDeviceEngine::deviceAdded(const QString& udi)
|
|||
}
|
||||
|
||||
if (device.is<Solid::OpticalDisc>()) {
|
||||
Solid::OpticalDrive *drive = getAncestorAs<Solid::OpticalDrive>(device);
|
||||
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
|
||||
if (drive) {
|
||||
connect(drive, SIGNAL(ejectRequested(QString)),
|
||||
this, SLOT(setUnmountingState(QString)));
|
||||
|
@ -742,7 +726,8 @@ bool SolidDeviceEngine::updateInUse(const QString &udi)
|
|||
if (storageaccess->isAccessible()) {
|
||||
setData(udi, I18N_NOOP("In Use"), true);
|
||||
} else {
|
||||
Solid::StorageDrive *drive = getAncestorAs<Solid::StorageDrive>(Solid::Device(udi));
|
||||
Solid::Device device = Solid::Device(udi);
|
||||
Solid::StorageDrive *drive = device.as<Solid::StorageDrive>();
|
||||
if (drive) {
|
||||
setData(udi, I18N_NOOP("In Use"), drive->isInUse());
|
||||
}
|
||||
|
@ -785,7 +770,7 @@ void SolidDeviceEngine::deviceRemoved(const QString& udi)
|
|||
}
|
||||
}
|
||||
else if (device.is<Solid::OpticalDisc>()) {
|
||||
Solid::OpticalDrive *drive = getAncestorAs<Solid::OpticalDrive>(device);
|
||||
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
|
||||
if (drive) {
|
||||
disconnect(drive, 0, this, 0);
|
||||
}
|
||||
|
|
|
@ -42,9 +42,6 @@ void SolidDeviceJob::start()
|
|||
else if (operation == "unmount") {
|
||||
if (device.is<Solid::OpticalDisc>()) {
|
||||
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
|
||||
if (!drive) {
|
||||
drive = device.parent().as<Solid::OpticalDrive>();
|
||||
}
|
||||
if (drive) {
|
||||
drive->eject();
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ void DeviceWrapper::runAction(QAction * action)
|
|||
}
|
||||
} else {
|
||||
if (isOpticalDisc() && m_forceEject) {
|
||||
Solid::OpticalDrive *drive = m_device.parent().as<Solid::OpticalDrive>();
|
||||
Solid::OpticalDrive *drive = m_device.as<Solid::OpticalDrive>();
|
||||
if (drive) {
|
||||
drive->eject();
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ void DeviceWrapper::runAction(QAction * action)
|
|||
}
|
||||
|
||||
if (isOpticalDisc()) {
|
||||
Solid::OpticalDrive *drive = m_device.parent().as<Solid::OpticalDrive>();
|
||||
Solid::OpticalDrive *drive = m_device.as<Solid::OpticalDrive>();
|
||||
if (drive) {
|
||||
drive->eject();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue