Browse Source

konqueror & kdesktop: default action for a media encrypted disk is

either lock or unlock based on the current locking status.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/35/head
Michele Calgaro 1 year ago
parent
commit
b75b318e14
Signed by: MicheleC GPG Key ID: 2A75B7CA8ADED5CF
2 changed files with 45 additions and 3 deletions
  1. +21
    -2
      konqueror/konq_mainwindow.cc
  2. +24
    -1
      libkonq/tdefileivi.cc

+ 21
- 2
konqueror/konq_mainwindow.cc View File

@@ -476,11 +476,9 @@ void KonqMainWindow::openURL( KonqView *_view, const KURL &_url,
const TQString &_serviceType, KonqOpenURLRequest& req,
bool trustedSource )
{
#ifndef NDEBUG // needed for req.debug()
kdDebug(1202) << "KonqMainWindow::openURL : url = '" << _url << "' "
<< "serviceType='" << _serviceType << "' req=" << req.debug()
<< " view=" << _view << endl;
#endif

KURL url( _url );
if (url.url().startsWith("$(")) {
@@ -543,6 +541,27 @@ void KonqMainWindow::openURL( KonqView *_view, const KURL &_url,
return;
}

// Default action for media encrypted disks is either lock or unlock based on current status
TQString lockingAction = TQString::null;
if (serviceType.contains("encrypted_locked")) {
lockingAction = "konqueror/servicemenus/media_unlock.desktop";
}
else if (serviceType.contains("encrypted_unlocked")) {
lockingAction = "konqueror/servicemenus/media_lock.desktop";
}
if (!lockingAction.isEmpty()) {
TQString lockingService = TDEGlobal::dirs()->findResource("data", lockingAction);
if (!lockingService.isEmpty()) {
TQValueList<KDEDesktopMimeType::Service> serviceList = KDEDesktopMimeType::userDefinedServices(lockingService, url.isLocalFile());
if (serviceList.count() == 1) {
KURL::List m_lstURLs;
m_lstURLs.append(url);
KDEDesktopMimeType::executeService(m_lstURLs, serviceList[0]);
return;
}
}
}

TQString nameFilter = detectNameFilter( url );
if ( !nameFilter.isEmpty() )
{


+ 24
- 1
libkonq/tdefileivi.cc View File

@@ -32,6 +32,8 @@
#include <kdebug.h>
#include <krun.h>
#include <kservice.h>
#include <kmimetype.h> // for KDEDesktopMimeType
#include <kstandarddirs.h>

#undef Bool

@@ -386,7 +388,28 @@ void KFileIVI::returnPressed()
if ( static_cast<KonqIconViewWidget*>(iconView())->isDesktop() ) {
KURL url = m_fileitem->url();
if (url.protocol() == "media") {
(void) new KRun( url, m_fileitem->mode(), m_fileitem->isLocalFile() );
TQString mimetype = m_fileitem->mimetype();
TQString lockingAction = TQString::null;
if (mimetype.contains("encrypted_locked")) {
lockingAction = "konqueror/servicemenus/media_unlock.desktop";
}
else if (mimetype.contains("encrypted_unlocked")) {
lockingAction = "konqueror/servicemenus/media_lock.desktop";
}
if (!lockingAction.isEmpty()) {
TQString lockingService = TDEGlobal::dirs()->findResource("data", lockingAction);
if (!lockingService.isEmpty()) {
TQValueList<KDEDesktopMimeType::Service> serviceList = KDEDesktopMimeType::userDefinedServices(lockingService, m_fileitem->isLocalFile());
if (serviceList.count() == 1) {
KURL::List m_lstURLs;
m_lstURLs.append(m_fileitem->url());
KDEDesktopMimeType::executeService(m_lstURLs, serviceList[0]);
}
}
}
else {
(void) new KRun( url, m_fileitem->mode(), m_fileitem->isLocalFile() );
}
}
else {
// When clicking on a link to e.g. $HOME from the desktop, we want to open $HOME


Loading…
Cancel
Save