[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/generic/runners/solid
From:       Jacopo De Simoi <wilderkde () gmail ! com>
Date:       2010-11-05 12:05:02
Message-ID: 20101105120502.3490AAC89B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1193281 by jacopods:

The eject syntax now actually works as expected


 M  +30 -3     devicewrapper.cpp  
 M  +4 -0      devicewrapper.h  
 M  +9 -1      solidrunner.cpp  


--- trunk/KDE/kdebase/workspace/plasma/generic/runners/solid/devicewrapper.cpp \
#1193280:1193281 @@ -74,7 +74,8 @@
             }
         }
         m_isEncryptedContainer = data["isEncryptedContainer"].toBool();
-    } else if (data["Device Types"].toStringList().contains("Storage Access")) {
+    } else {
+        if (data["Device Types"].toStringList().contains("Storage Access")) {
         m_isStorageAccess = true;
         if (data["Accessible"].toBool() == true) {
             m_isAccessible = true;
@@ -84,6 +85,12 @@
     } else {
         m_isStorageAccess = false;
     }
+        if (data["Device Types"].toStringList().contains("OpticalDisc")) {
+            m_isOpticalDisc = true;
+        } else {
+            m_isOpticalDisc = false;
+        }
+    }
 
     m_emblems = m_device.emblems();
 
@@ -115,15 +122,26 @@
     return m_isEncryptedContainer;
 }
 
+bool DeviceWrapper::isOpticalDisc() const {
+    return m_isOpticalDisc;
+}
+
 QString DeviceWrapper::description() const {
     return m_device.description();
 }
 
+void DeviceWrapper::setForceEject(bool force)
+{
+    m_forceEject = force;
+}
+
 QString DeviceWrapper::defaultAction() const {
 
     QString actionString;
 
-    if (m_isStorageAccess) {
+    if (m_isOpticalDisc && m_forceEject) {
+        actionString = i18n("Eject medium");
+    } else if (m_isStorageAccess) {
         if (!m_isEncryptedContainer) {
             if (!m_isAccessible) {
                 actionString = i18n("Mount the device");
@@ -154,6 +172,14 @@
             soliduiserver.asyncCall("showActionsDialog", id(), desktopFiles);
         }
     } else {
+        if (isOpticalDisc() && m_forceEject) {
+            Solid::OpticalDrive *drive = \
m_device.parent().as<Solid::OpticalDrive>(); +            if (drive) {
+                drive->eject();
+            }
+            return;
+        }
+
         if (m_device.is<Solid::StorageVolume>()) {
             Solid::StorageAccess *access = m_device.as<Solid::StorageAccess>();
             if (access) {
@@ -165,7 +191,8 @@
                 return;
             }
         }
-        if (m_device.is<Solid::OpticalDisc>()) {
+
+        if (isOpticalDisc()) {
             Solid::OpticalDrive *drive = \
m_device.parent().as<Solid::OpticalDrive>();  if (drive) {
                 drive->eject();
--- trunk/KDE/kdebase/workspace/plasma/generic/runners/solid/devicewrapper.h \
#1193280:1193281 @@ -43,11 +43,13 @@
     KIcon icon() const;
     bool isStorageAccess() const;
     bool isAccessible() const;
+    bool isOpticalDisc() const;
     bool isEncryptedContainer() const;
     QString description() const;
     QString defaultAction() const;
     void runAction(QAction *) ;
     QStringList actionIds() const;
+    void setForceEject(bool force);
     
     signals:
     void registerAction(QString &id, QString icon, QString text, QString desktop);
@@ -71,6 +73,8 @@
     bool m_isStorageAccess;
     bool m_isAccessible;
     bool m_isEncryptedContainer;
+    bool m_isOpticalDisc;
+    bool m_forceEject;
     QString m_description;
     QStringList m_actionIds;
     // Solid doesn't like multithreading that much
--- trunk/KDE/kdebase/workspace/plasma/generic/runners/solid/solidrunner.cpp \
#1193280:1193281 @@ -133,6 +133,8 @@
     bool onlyMounted = false;
     bool onlyMountable = false;
     bool onlyEncrypted = false;
+    bool onlyOptical = false;
+    bool forceEject = false;
     bool showDevices = false;
     if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "device") , \
Qt::CaseInsensitive)) {  showDevices = true;
@@ -148,6 +150,11 @@
             showDevices = true;
             onlyMounted = true;
             keywords.removeFirst();
+        } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", \
"eject") , Qt::CaseInsensitive)) { +            showDevices = true;
+            onlyOptical = true;
+            forceEject = true;
+            keywords.removeFirst();
         } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", \
"unlock") , Qt::CaseInsensitive)) {  showDevices = true;
             onlyMountable = true;
@@ -170,10 +177,11 @@
         if ((deviceDescription.isEmpty() && showDevices) || \
dev->description().contains(deviceDescription, Qt::CaseInsensitive)) {  // This is \
                getting quite messy indeed
             if (((!onlyEncrypted) || (onlyEncrypted && dev->isEncryptedContainer())) \
&& +                ((!onlyOptical) || (onlyOptical && dev->isOpticalDisc())) &&
                 ((onlyMounted && dev->isAccessible()) ||
                  (onlyMountable && dev->isStorageAccess() && !dev->isAccessible()) \
||  (!onlyMounted && !onlyMountable))) {
-
+                dev->setForceEject(forceEject);
                 Plasma::QueryMatch match = deviceMatch(dev);
                 if (dev->description().compare(deviceDescription, \
Qt::CaseInsensitive)) {  match.setType(Plasma::QueryMatch::ExactMatch);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic