konqueror & kdesktop: removed "open/open in new tab/..." items for

encrypted media devices (either locked or unlocked) from popup menu.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/35/head
Michele Calgaro 5 years ago
parent 8ab67852cd
commit 8f12bba779
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -4789,7 +4789,12 @@ void KonqMainWindow::slotPopupMenu( KXMLGUIClient *client, const TQPoint &_globa
connectActionCollection( pPopupMenu->actionCollection() ); connectActionCollection( pPopupMenu->actionCollection() );
pPopupMenu->factory()->addClient( konqyMenuClient ); if (pPopupMenu->hasGroup("tabhandling"))
{
// "tabhandling" group in inserted in the popup menu if no encrypted media devices are part of "_items"
// see libkonq/konq_popupmenu.cc KonqPopupMenu::setup() method
pPopupMenu->factory()->addClient( konqyMenuClient );
}
if ( client ) if ( client )
pPopupMenu->factory()->addClient( client ); pPopupMenu->factory()->addClient( client );

@ -337,22 +337,22 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
m_ownActions.setWidget( this ); m_ownActions.setWidget( this );
const bool bIsLink = (kpf & IsLink); const bool bIsLink = (kpf & IsLink);
bool currentDir = false; bool currentDir = false;
bool sReading = true; bool sReading = true;
bool sDeleting = ( d->m_itemFlags & KParts::BrowserExtension::NoDeletion ) == 0; bool sDeleting = ( d->m_itemFlags & KParts::BrowserExtension::NoDeletion ) == 0;
bool sMoving = sDeleting; bool sMoving = sDeleting;
bool sWriting = sDeleting && m_lstItems.first()->isWritable(); bool sWriting = sDeleting && m_lstItems.first()->isWritable();
m_sMimeType = m_lstItems.first()->mimetype(); m_sMimeType = m_lstItems.first()->mimetype();
TQString mimeGroup = m_sMimeType.left(m_sMimeType.find('/')); TQString mimeGroup = m_sMimeType.left(m_sMimeType.find('/'));
mode_t mode = m_lstItems.first()->mode(); mode_t mode = m_lstItems.first()->mode();
bool isDirectory = S_ISDIR(mode); bool isDirectory = S_ISDIR(mode);
bool bTrashIncluded = false; bool isMediaFile = false;
bool mediaFiles = false; bool isEncryptedMediaFile = false;
bool isReallyLocal = m_lstItems.first()->isLocalFile(); bool isReallyLocal = m_lstItems.first()->isLocalFile();
bool isLocal = isReallyLocal bool isLocal = isReallyLocal || m_lstItems.first()->url().protocol()=="media" ||
|| m_lstItems.first()->url().protocol()=="media" m_lstItems.first()->url().protocol()=="system";
|| m_lstItems.first()->url().protocol()=="system"; bool isTrashIncluded = false;
bool isTrashLink = false; bool isTrashLink = false;
m_lstPopupURLs.clear(); m_lstPopupURLs.clear();
int id = 0; int id = 0;
@ -398,10 +398,10 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
if ( isLocal && !url.isLocalFile() && url.protocol() != "media" && url.protocol() != "system" ) if ( isLocal && !url.isLocalFile() && url.protocol() != "media" && url.protocol() != "system" )
isLocal = false; isLocal = false;
if ( !bTrashIncluded && ( if ( !isTrashIncluded && (
( url.protocol() == "trash" && url.path().length() <= 1 ) ( url.protocol() == "trash" && url.path().length() <= 1 )
|| url.url() == "system:/trash" || url.url() == "system:/trash/" ) ) { || url.url() == "system:/trash" || url.url() == "system:/trash/" ) ) {
bTrashIncluded = true; isTrashIncluded = true;
isLocal = false; isLocal = false;
} }
@ -416,8 +416,12 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
if ( sMoving ) if ( sMoving )
sMoving = KProtocolInfo::supportsMoving( url ); sMoving = KProtocolInfo::supportsMoving( url );
if ( (*it)->mimetype().startsWith("media/") ) if ( (*it)->mimetype().startsWith("media/") ) {
mediaFiles = true; isMediaFile = true;
if ( (*it)->mimetype().contains("encrypted")) {
isEncryptedMediaFile = true;
}
}
} }
// If a local path is available, monitor that instead of the given remote URL... // If a local path is available, monitor that instead of the given remote URL...
@ -469,13 +473,12 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
m_info.m_Writing = sWriting; m_info.m_Writing = sWriting;
m_info.m_Deleting = sDeleting; m_info.m_Deleting = sDeleting;
m_info.m_Moving = sMoving; m_info.m_Moving = sMoving;
m_info.m_TrashIncluded = bTrashIncluded; m_info.m_TrashIncluded = isTrashIncluded;
// isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link // isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
bool isCurrentTrash = ( m_lstItems.count() == 1 && bTrashIncluded ) || isTrashLink; bool isCurrentTrash = ( m_lstItems.count() == 1 && isTrashIncluded ) || isTrashLink;
bool isIntoTrash = ( url.protocol() == "trash" || url.url().startsWith( "system:/trash" ) ) && !isCurrentTrash; // trashed file, not trash:/ itself bool isIntoTrash = ( url.protocol() == "trash" || url.url().startsWith( "system:/trash" ) ) && !isCurrentTrash; // trashed file, not trash:/ itself
//kdDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded << endl; //kdDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " isTrashIncluded=" << isTrashIncluded << endl;
bool isSingleMedium = m_lstItems.count() == 1 && mediaFiles;
clear(); clear();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -486,7 +489,6 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
addMerge( "konqueror" ); addMerge( "konqueror" );
bool isKDesktop = TQCString( kapp->name() ) == "kdesktop"; bool isKDesktop = TQCString( kapp->name() ) == "kdesktop";
TDEAction *actNewWindow = 0;
if (( kpf & ShowProperties ) && isKDesktop && if (( kpf & ShowProperties ) && isKDesktop &&
!kapp->authorize("editable_desktop_icons")) !kapp->authorize("editable_desktop_icons"))
@ -496,20 +498,13 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
// Either 'newview' is in the actions we're given (probably in the tabhandling group) // Either 'newview' is in the actions we're given (probably in the tabhandling group)
// or we need to insert it ourselves (e.g. for kdesktop). In the first case, actNewWindow must remain 0. // or we need to insert it ourselves (e.g. for kdesktop). In the first case, actNewWindow must remain 0.
if ( ((kpf & ShowNewWindow) != 0) && sReading ) if ( ((kpf & ShowNewWindow) != 0) && sReading && !isEncryptedMediaFile)
{ {
TQString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" ); TQString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" );
actNewWindow = new TDEAction( openStr, "window-new", 0, TQT_TQOBJECT(this), TQT_SLOT( slotPopupNewView() ), &m_ownActions, "newview" ); TDEAction *actNewWindow = new TDEAction( openStr, "window-new", 0, TQT_TQOBJECT(this), TQT_SLOT( slotPopupNewView() ), &m_ownActions, "newview" );
} actNewWindow->setToolTip( i18n( "Open item in a new window" ) );
addAction( actNewWindow );
if ( actNewWindow && !isKDesktop ) addSeparator();
{
if (isCurrentTrash)
actNewWindow->setToolTip( i18n( "Open the trash in a new window" ) );
else if (isSingleMedium)
actNewWindow->setToolTip( i18n( "Open the medium in a new window") );
else
actNewWindow->setToolTip( i18n( "Open the document in a new window" ) );
} }
if ( S_ISDIR(mode) && sWriting && !isCurrentTrash ) // A dir, and we can create things into it if ( S_ISDIR(mode) && sWriting && !isCurrentTrash ) // A dir, and we can create things into it
@ -550,13 +545,10 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
addSeparator(); addSeparator();
} }
// "open in new window" is either provided by us, or by the tabhandling group if (!isEncryptedMediaFile)
if (actNewWindow)
{ {
addAction( actNewWindow ); addGroup( "tabhandling" ); // includes a separator
addSeparator();
} }
addGroup( "tabhandling" ); // includes a separator
if ( !bIsLink ) if ( !bIsLink )
{ {
@ -995,7 +987,7 @@ void KonqPopupMenu::setup(KonqPopupFlags kpf)
addPendingSeparator(); addPendingSeparator();
} }
if ( !isCurrentTrash && !isIntoTrash && !mediaFiles && sReading ) if ( !isCurrentTrash && !isIntoTrash && !isMediaFile && sReading )
addPlugins(); // now it's time to add plugins addPlugins(); // now it's time to add plugins
if ( KPropertiesDialog::canDisplay( m_lstItems ) && (kpf & ShowProperties) ) if ( KPropertiesDialog::canDisplay( m_lstItems ) && (kpf & ShowProperties) )

@ -154,4 +154,21 @@ bool KonqXMLGUIClient::hasAction() const
return d->hasAction; return d->hasAction;
} }
bool KonqXMLGUIClient::hasGroup(const TQString &name) const
{
if (name.isEmpty())
{
return false;
}
TQDomNodeList groups = m_doc.elementsByTagName("definegroup");
for (uint idx = 0; idx < groups.count(); ++idx)
{
TQDomElement group = groups.item(idx).toElement();
if (group.hasAttribute(d->attrName) && group.attribute(d->attrName) == name)
{
return true;
}
}
return false;
}

@ -34,24 +34,26 @@
class LIBKONQ_EXPORT KonqXMLGUIClient : public KXMLGUIClient class LIBKONQ_EXPORT KonqXMLGUIClient : public KXMLGUIClient
{ {
public: public:
KonqXMLGUIClient( ); KonqXMLGUIClient();
KonqXMLGUIClient( KXMLGUIClient *parent ); KonqXMLGUIClient(KXMLGUIClient *parent);
virtual ~KonqXMLGUIClient( ); virtual ~KonqXMLGUIClient();
/** /**
* Reimplemented for internal purpose * Reimplemented for internal purpose
*/ */
TQDomDocument domDocument( ) const; TQDomDocument domDocument() const;
TQDomElement DomElement() const; // KDE4: s/D/d/
TQDomElement DomElement( ) const; // KDE4: s/D/d/ // @return true if the group named "name" exists
bool hasGroup(const TQString &name) const;
protected: protected:
void addAction( TDEAction *action, const TQDomElement &menu = TQDomElement() ); void addAction(TDEAction *action, const TQDomElement &menu = TQDomElement());
void addAction( const char *name, const TQDomElement &menu = TQDomElement() ); void addAction(const char *name, const TQDomElement &menu = TQDomElement());
void addSeparator( const TQDomElement &menu = TQDomElement() ); void addSeparator(const TQDomElement &menu = TQDomElement());
/// only add a separator if an action is added afterwards /// only add a separator if an action is added afterwards
void addPendingSeparator(); void addPendingSeparator();
void addGroup( const TQString &grp ); void addGroup(const TQString &grp);
void addMerge( const TQString &name ); void addMerge(const TQString &name);
// @return true if addAction was called at least once // @return true if addAction was called at least once
bool hasAction() const; bool hasAction() const;

Loading…
Cancel
Save