• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-baseapps API Reference
  • KDE Home
  • Contact Us
 

libkonq

  • sources
  • kde-4.14
  • kde-baseapps
  • lib
  • konq
konq_popupmenu.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 1998-2008 David Faure <faure@kde.org>
3  Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "konq_popupmenu.h"
22 #include <kfileitemlistproperties.h>
23 #include "konq_popupmenuplugin.h"
24 #include "konq_popupmenuinformation.h"
25 #include "konq_copytomenu.h"
26 #include "kfileitemactions.h"
27 #include "kfileitemactionplugin.h"
28 #include "kabstractfileitemactionplugin.h"
29 #include "kpropertiesdialog.h"
30 #include "knewmenu.h"
31 #include "konq_operations.h"
32 
33 #include <klocale.h>
34 #include <kbookmarkmanager.h>
35 #include <kbookmarkdialog.h>
36 #include <kdebug.h>
37 #include <krun.h>
38 #include <kprotocolmanager.h>
39 #include <kicon.h>
40 #include <kiconloader.h>
41 #include <kinputdialog.h>
42 #include <kglobalsettings.h>
43 #include <kmimetypetrader.h>
44 #include <kstandarddirs.h>
45 #include <kconfiggroup.h>
46 #include <kdesktopfile.h>
47 #include <kfileshare.h>
48 #include <kauthorized.h>
49 #include <kglobal.h>
50 #include <kacceleratormanager.h>
51 
52 #include <QFileInfo>
53 
54 /*
55  Test cases:
56  iconview file: background
57  iconview file: file (with and without servicemenus)
58  iconview file: directory
59  iconview remote protocol (e.g. ftp: or fish:)
60  iconview trash:/
61  sidebar directory tree
62  sidebar Devices / Hard Disc
63  khtml background
64  khtml link
65  khtml image (www.kde.org RMB on K logo)
66  khtmlimage (same as above, then choose View image, then RMB)
67  selected text in khtml
68  embedded katepart
69  folder on the desktop
70  trash link on the desktop
71  trashed file or directory
72  application .desktop file
73  Then the same after uninstalling kdeaddons/konq-plugins (arkplugin in particular)
74 */
75 
76 class KonqPopupMenuPrivate
77 {
78 public:
79  KonqPopupMenuPrivate(KonqPopupMenu* qq, KActionCollection & actions, QWidget* parentWidget)
80  : q(qq),
81  m_parentWidget(parentWidget),
82  m_itemFlags(KParts::BrowserExtension::DefaultPopupItems),
83  m_pMenuNew(0),
84  m_copyToMenu(parentWidget),
85  m_bookmarkManager(0),
86  m_actions(actions),
87  m_ownActionCollection(static_cast<QWidget *>(0))
88  {
89  }
90 
91  ~KonqPopupMenuPrivate()
92  {
93  qDeleteAll(m_ownActions);
94  }
95 
96  void addNamedAction(const QString& name);
97  void addGroup(const QString& name);
98  void addPlugins();
99  void init(KonqPopupMenu::Flags kpf, KParts::BrowserExtension::PopupFlags itemFlags);
100 
101  void slotPopupNewDir();
102  void slotPopupNewView();
103  void slotPopupEmptyTrashBin();
104  void slotConfigTrashBin();
105  void slotPopupRestoreTrashedItems();
106  void slotPopupAddToBookmark();
107  void slotPopupMimeType();
108  void slotPopupProperties();
109  void slotOpenShareFileDialog();
110  void slotShowOriginalFile();
111 
112  KonqPopupMenu* q;
113  QWidget* m_parentWidget;
114  QString m_urlTitle;
115  KParts::BrowserExtension::PopupFlags m_itemFlags;
116  KNewFileMenu *m_pMenuNew;
117  KUrl m_sViewURL;
118  KFileItemListProperties m_popupItemProperties;
119  KonqPopupMenuInformation m_popupMenuInfo; // only used by plugins
120  KFileItemActions m_menuActions;
121  KonqCopyToMenu m_copyToMenu;
122  KBookmarkManager* m_bookmarkManager;
123  KActionCollection &m_actions;
124  KActionCollection m_ownActionCollection; // only used by plugins; KDE5: pass m_ownActions instead
125  QList<KAction*> m_ownActions;
126  KParts::BrowserExtension::ActionGroupMap m_actionGroups;
127 };
128 
130 
131 KonqPopupMenu::KonqPopupMenu(const KFileItemList &items,
132  const KUrl& viewURL,
133  KActionCollection & actions,
134  KNewFileMenu * newMenu,
135  Flags kpf,
136  KParts::BrowserExtension::PopupFlags flags,
137  QWidget * parentWidget,
138  KBookmarkManager *mgr,
139  const KParts::BrowserExtension::ActionGroupMap& actionGroups)
140  : QMenu(parentWidget),
141  d(new KonqPopupMenuPrivate(this, actions, parentWidget))
142 {
143  d->m_actionGroups = actionGroups;
144  d->m_pMenuNew = newMenu;
145  d->m_sViewURL = viewURL;
146  d->m_bookmarkManager = mgr;
147  d->m_popupItemProperties.setItems(items);
148  d->m_menuActions.setParentWidget(parentWidget);
149  d->init(kpf, flags);
150 
151  KAcceleratorManager::manage(this);
152 }
153 
154 void KonqPopupMenuPrivate::addNamedAction(const QString& name)
155 {
156  QAction* act = m_actions.action(name);
157  if (act)
158  q->addAction(act);
159 }
160 
161 void KonqPopupMenuPrivate::init(KonqPopupMenu::Flags kpf, KParts::BrowserExtension::PopupFlags flags)
162 {
163  m_itemFlags = flags;
164  q->setFont(KGlobalSettings::menuFont());
165 
166  Q_ASSERT(m_popupItemProperties.items().count() >= 1);
167 
168  bool bTrashIncluded = false;
169 
170  const KFileItemList lstItems = m_popupItemProperties.items();
171  KFileItemList::const_iterator it = lstItems.constBegin();
172  const KFileItemList::const_iterator kend = lstItems.constEnd();
173  for ( ; it != kend; ++it )
174  {
175  const KUrl url = (*it).url();
176  if ( !bTrashIncluded && (
177  ( url.protocol() == "trash" && url.path().length() <= 1 ) ) ) {
178  bTrashIncluded = true;
179  }
180  }
181 
182  const bool isDirectory = m_popupItemProperties.isDirectory();
183  const bool sReading = m_popupItemProperties.supportsReading();
184  bool sDeleting = (m_itemFlags & KParts::BrowserExtension::NoDeletion) == 0
185  && m_popupItemProperties.supportsDeleting();
186  const bool sWriting = m_popupItemProperties.supportsWriting();
187  const bool sMoving = sDeleting && m_popupItemProperties.supportsMoving();
188  const bool isLocal = m_popupItemProperties.isLocal();
189 
190  KUrl url = m_sViewURL;
191  url.cleanPath();
192 
193  bool isTrashLink = false;
194  bool isCurrentTrash = false;
195  bool currentDir = false;
196  bool isSymLink = false;
197  bool isSymLinkInSameDir = false; // true for "ln -s foo bar", false for links to foo/sub or /foo
198 
199  //check if url is current directory
200  if ( lstItems.count() == 1 )
201  {
202  KFileItem firstPopupItem( lstItems.first() );
203  if (firstPopupItem.isLink()) {
204  isSymLink = true;
205  isSymLinkInSameDir = !firstPopupItem.linkDest().contains('/');
206  }
207  KUrl firstPopupURL( firstPopupItem.url() );
208  firstPopupURL.cleanPath();
209  //kDebug(1203) << "View path is " << url.url();
210  //kDebug(1203) << "First popup path is " << firstPopupURL.url();
211  currentDir = firstPopupURL.equals( url, KUrl::CompareWithoutTrailingSlash );
212  if ( firstPopupItem.isDesktopFile() ) {
213  KDesktopFile desktopFile( firstPopupItem.localPath() );
214  const KConfigGroup cfg = desktopFile.desktopGroup();
215  isTrashLink = ( cfg.readEntry("Type") == "Link" && cfg.readEntry("URL") == "trash:/" );
216  }
217 
218  if (isTrashLink) {
219  sDeleting = false;
220  }
221 
222  // isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
223  isCurrentTrash = (firstPopupURL.protocol() == "trash" && firstPopupURL.path().length() <= 1)
224  || isTrashLink;
225  }
226 
227  const bool isIntoTrash = (url.protocol() == "trash") && !isCurrentTrash; // trashed file, not trash:/ itself
228 
229  const bool bIsLink = (m_itemFlags & KParts::BrowserExtension::IsLink);
230 
231  //kDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded;
232 
234 
235  addGroup( "topactions" ); // used e.g. for ShowMenuBar. includes a separator at the end
236 
237  KAction * act;
238 
239  KAction *actNewWindow = 0;
240 
241 #if 0 // TODO in the desktop code itself.
242  if (( flags & KParts::BrowserExtension::ShowProperties ) && isOnDesktop &&
243  !KAuthorized::authorizeKAction("editable_desktop_icons"))
244  {
245  flags &= ~KParts::BrowserExtension::ShowProperties; // remove flag
246  }
247 #endif
248 
249  // Either 'newview' is in the actions we're given (probably in the tabhandling group)
250  // or we need to insert it ourselves (e.g. for the desktop).
251  // In the first case, actNewWindow must remain 0.
252  if ( ((kpf & KonqPopupMenu::ShowNewWindow) != 0) && sReading )
253  {
254  const QString openStr = i18n("&Open");
255  actNewWindow = new KAction(m_parentWidget /*for status tips*/);
256  m_ownActions.append(actNewWindow);
257  actNewWindow->setIcon( KIcon("window-new") );
258  actNewWindow->setText( openStr );
259  QObject::connect(actNewWindow, SIGNAL(triggered()), q, SLOT(slotPopupNewView()));
260  }
261 
262  if ( isDirectory && sWriting && !isCurrentTrash ) // A dir, and we can create things into it
263  {
264  const bool mkdirRequested = m_itemFlags & KParts::BrowserExtension::ShowCreateDirectory;
265  if ( (currentDir || mkdirRequested) && m_pMenuNew ) // Current dir -> add the "new" menu
266  {
267  // As requested by KNewFileMenu :
268  m_pMenuNew->checkUpToDate();
269  m_pMenuNew->setPopupFiles(m_popupItemProperties.urlList());
270 
271  q->addAction( m_pMenuNew );
272  q->addSeparator();
273  }
274  else if (mkdirRequested)
275  {
276  KAction *actNewDir = new KAction(m_parentWidget);
277  m_ownActions.append(actNewDir);
278  actNewDir->setIcon( KIcon("folder-new") );
279  actNewDir->setText( i18n( "Create &Folder..." ) );
280  QObject::connect(actNewDir, SIGNAL(triggered()), q, SLOT(slotPopupNewDir()));
281  q->addAction( actNewDir );
282  q->addSeparator();
283  }
284  } else if ( isIntoTrash ) {
285  // Trashed item, offer restoring
286  act = new KAction(m_parentWidget /*for status tips*/);
287  m_ownActions.append(act);
288  act->setText( i18n( "&Restore" ) );
289  act->setHelpText(i18n("Restores this file or directory, back to the location where it was deleted from initially"));
290  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupRestoreTrashedItems()));
291  q->addAction(act);
292  }
293 
294  if (m_itemFlags & KParts::BrowserExtension::ShowNavigationItems)
295  {
296  if (m_itemFlags & KParts::BrowserExtension::ShowUp)
297  addNamedAction( "go_up" );
298  addNamedAction( "go_back" );
299  addNamedAction( "go_forward" );
300  if (m_itemFlags & KParts::BrowserExtension::ShowReload)
301  addNamedAction( "reload" );
302  q->addSeparator();
303  }
304 
305  if (!currentDir && isSymLink && !isSymLinkInSameDir) {
306  // #65151: offer to open the target's parent dir
307  act = new KAction(m_parentWidget);
308  m_ownActions.append(act);
309  act->setText(isDirectory ? i18n("Show Original Directory") : i18n("Show Original File"));
310  act->setHelpText(i18n("Opens a new file manager window showing the target of this link, in its parent directory."));
311  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotShowOriginalFile()));
312  q->addAction(act);
313  }
314 
315  // "open in new window" is either provided by us, or by the tabhandling group
316  if (actNewWindow) {
317  q->addAction(actNewWindow);
318  q->addSeparator();
319  }
320  addGroup( "tabhandling" ); // includes a separator at the end
321 
322  if (m_itemFlags & KParts::BrowserExtension::ShowUrlOperations) {
323  if ( !currentDir && sReading ) {
324  if ( sDeleting ) {
325  addNamedAction( "cut" );
326  }
327  addNamedAction( "copy" );
328  }
329 
330  if ( isDirectory && sWriting ) {
331  if ( currentDir )
332  addNamedAction( "paste" );
333  else
334  addNamedAction( "pasteto" );
335  }
336  }
337  if ( isCurrentTrash )
338  {
339  act = new KAction(m_parentWidget);
340  m_ownActions.append(act);
341  act->setIcon( KIcon("trash-empty") );
342  act->setText( i18n( "&Empty Trash Bin" ) );
343  KConfig trashConfig( "trashrc", KConfig::SimpleConfig);
344  act->setEnabled( !trashConfig.group("Status").readEntry( "Empty", true ) );
345  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupEmptyTrashBin()));
346  q->addAction(act);
347  }
348  if ( isCurrentTrash )
349  {
350  act = new KAction(m_parentWidget);
351  m_ownActions.append(act);
352  act->setIcon( KIcon("trash-empty") );
353  act->setText( i18n( "&Configure Trash Bin" ) );
354  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotConfigTrashBin()));
355  q->addAction(act);
356  }
357 
358  // This is used by KHTML, see khtml_popupmenu.rc (copy, selectAll, searchProvider etc.)
359  // and by DolphinPart (rename, trash, delete)
360  addGroup( "editactions" );
361 
362  if (m_itemFlags & KParts::BrowserExtension::ShowTextSelectionItems) {
363  // OK, we have to stop here.
364 
365  // Anything else that is provided by the part
366  addGroup( "partactions" );
367  return;
368  }
369 
370  if ( !isCurrentTrash && !isIntoTrash && (m_itemFlags & KParts::BrowserExtension::ShowBookmark))
371  {
372  QString caption;
373  if (currentDir)
374  {
375  const bool httpPage = m_sViewURL.protocol().startsWith("http", Qt::CaseInsensitive);
376  if (httpPage)
377  caption = i18n("&Bookmark This Page");
378  else
379  caption = i18n("&Bookmark This Location");
380  }
381  else if (isDirectory)
382  caption = i18n("&Bookmark This Folder");
383  else if (bIsLink)
384  caption = i18n("&Bookmark This Link");
385  else
386  caption = i18n("&Bookmark This File");
387 
388  act = new KAction(m_parentWidget);
389  m_ownActions.append(act);
390  act->setObjectName( QLatin1String("bookmark_add" )); // for unittest
391  act->setIcon( KIcon("bookmark-new") );
392  act->setText( caption );
393  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupAddToBookmark()));
394  if (lstItems.count() > 1)
395  act->setEnabled(false);
396  if (KAuthorized::authorizeKAction("bookmarks"))
397  q->addAction( act );
398  if (bIsLink)
399  addGroup( "linkactions" ); // see khtml
400  }
401 
402  // "Open With" actions
403 
404  m_menuActions.setItemListProperties(m_popupItemProperties);
405 
406  if ( sReading ) {
407  m_menuActions.addOpenWithActionsTo(q, "DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'");
408 
409  QList<QAction *> previewActions = m_actionGroups.value("preview");
410  if (!previewActions.isEmpty()) {
411  if (previewActions.count() == 1) {
412  q->addAction(previewActions.first());
413  } else {
414  QMenu* subMenu = new QMenu(i18n("Preview In"), q);
415  subMenu->menuAction()->setObjectName( QLatin1String("preview_submenu" )); // for the unittest
416  q->addMenu(subMenu);
417  subMenu->addActions(previewActions);
418  }
419  }
420  }
421 
422  // Second block, builtin + user
423  m_menuActions.addServiceActionsTo(q);
424 
425  q->addSeparator();
426 
427  // Use the Dolphin setting for showing the "Copy To" and "Move To" actions
428  KSharedConfig::Ptr dolphin = KSharedConfig::openConfig("dolphinrc");
429 
430  // CopyTo/MoveTo menus
431  if (m_itemFlags & KParts::BrowserExtension::ShowUrlOperations &&
432  KConfigGroup(dolphin, "General").readEntry("ShowCopyMoveMenu", false)) {
433 
434  m_copyToMenu.setItems(lstItems);
435  m_copyToMenu.setReadOnly(sMoving == false);
436  m_copyToMenu.addActionsTo(q);
437  q->addSeparator();
438  }
439 
440  if (!isCurrentTrash && !isIntoTrash && sReading &&
441  (kpf & KonqPopupMenu::NoPlugins) == 0) {
442  addPlugins(); // now it's time to add plugins
443  }
444 
445  if ( (m_itemFlags & KParts::BrowserExtension::ShowProperties) && KPropertiesDialog::canDisplay( lstItems ) ) {
446  act = new KAction(m_parentWidget);
447  m_ownActions.append(act);
448  act->setObjectName( QLatin1String("properties" )); // for unittest
449  act->setText( i18n( "&Properties" ) );
450  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupProperties()));
451  q->addAction(act);
452  }
453 
454  while ( !q->actions().isEmpty() &&
455  q->actions().last()->isSeparator() )
456  delete q->actions().last();
457 
458  if ( isDirectory && isLocal ) {
459  if ( KFileShare::authorization() == KFileShare::Authorized ) {
460  q->addSeparator();
461  act = new KAction(m_parentWidget);
462  m_ownActions.append(act);
463  act->setText( i18n("Share") );
464  QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotOpenShareFileDialog()));
465  q->addAction(act);
466  }
467  }
468 
469  // Anything else that is provided by the part
470  addGroup( "partactions" );
471 }
472 
473 void KonqPopupMenuPrivate::slotOpenShareFileDialog()
474 {
475  KPropertiesDialog* dlg = new KPropertiesDialog( m_popupItemProperties.items(), m_parentWidget );
476  dlg->showFileSharingPage();
477  dlg->exec();
478 }
479 
480 KonqPopupMenu::~KonqPopupMenu()
481 {
482  delete d;
483  //kDebug(1203) << "~KonqPopupMenu leave";
484 }
485 
486 void KonqPopupMenu::setURLTitle( const QString& urlTitle )
487 {
488  d->m_urlTitle = urlTitle;
489 }
490 
491 KFileItemActions* KonqPopupMenu::fileItemActions() const
492 {
493  return &(d->m_menuActions);
494 }
495 
496 void KonqPopupMenuPrivate::slotPopupNewView()
497 {
498  Q_FOREACH(const KUrl& url, m_popupItemProperties.urlList()) {
499  (void) new KRun(url, m_parentWidget);
500  }
501 }
502 
503 void KonqPopupMenuPrivate::slotPopupNewDir()
504 {
505  if (m_popupItemProperties.urlList().empty())
506  return;
507 
508  KonqOperations::newDir(m_parentWidget, m_popupItemProperties.urlList().first());
509 }
510 
511 void KonqPopupMenuPrivate::slotPopupEmptyTrashBin()
512 {
513  KonqOperations::emptyTrash(m_parentWidget);
514 }
515 
516 void KonqPopupMenuPrivate::slotConfigTrashBin()
517 {
518  KRun::run("kcmshell4 kcmtrash", KUrl::List(), m_parentWidget);
519 }
520 
521 void KonqPopupMenuPrivate::slotPopupRestoreTrashedItems()
522 {
523  KonqOperations::restoreTrashedItems(m_popupItemProperties.urlList(), m_parentWidget);
524 }
525 
526 void KonqPopupMenuPrivate::slotPopupAddToBookmark()
527 {
528  KBookmarkGroup root;
529  if (m_popupItemProperties.urlList().count() == 1) {
530  const KUrl url = m_popupItemProperties.urlList().first();
531  const QString title = m_urlTitle.isEmpty() ? url.prettyUrl() : m_urlTitle;
532  KBookmarkDialog dlg(m_bookmarkManager, m_parentWidget);
533  dlg.addBookmark(title, url.url());
534  }
535  else
536  {
537  root = m_bookmarkManager->root();
538  Q_FOREACH(const KUrl& url, m_popupItemProperties.urlList()) {
539  root.addBookmark(url.prettyUrl(), url);
540  }
541  m_bookmarkManager->emitChanged(root);
542  }
543 }
544 
545 void KonqPopupMenuPrivate::slotPopupMimeType()
546 {
547  KonqOperations::editMimeType(m_popupItemProperties.mimeType(), m_parentWidget);
548 }
549 
550 void KonqPopupMenuPrivate::slotPopupProperties()
551 {
552  KPropertiesDialog::showDialog(m_popupItemProperties.items(), m_parentWidget, false);
553 }
554 
555 void KonqPopupMenuPrivate::addGroup(const QString& name)
556 {
557  QList<QAction *> actions = m_actionGroups.value(name);
558  q->addActions(actions);
559 }
560 
561 void KonqPopupMenuPrivate::addPlugins()
562 {
563  QString commonMimeType = m_popupItemProperties.mimeType();
564  if (commonMimeType.isEmpty()) {
565  commonMimeType = QLatin1String("application/octet-stream");
566  }
567  const KService::List konqPlugins = KMimeTypeTrader::self()->query(commonMimeType, "KonqPopupMenu/Plugin", "exist Library");
568 
569  if (!konqPlugins.isEmpty()) {
570  m_popupMenuInfo.setItemListProperties(m_popupItemProperties);
571  m_popupMenuInfo.setParentWidget(m_parentWidget);
572  KService::List::ConstIterator iterator = konqPlugins.begin();
573  const KService::List::ConstIterator end = konqPlugins.end();
574  for(; iterator != end; ++iterator) {
575  //kDebug() << (*iterator)->name() << (*iterator)->library();
576  KonqPopupMenuPlugin *plugin = (*iterator)->createInstance<KonqPopupMenuPlugin>(q);
577  if (!plugin)
578  continue;
579  plugin->setParent(q);
580  plugin->setup(&m_ownActionCollection, m_popupMenuInfo, q);
581  }
582  }
583 
584  const KService::List fileItemPlugins = KMimeTypeTrader::self()->query(commonMimeType, "KFileItemAction/Plugin", "exist Library");
585  if (!fileItemPlugins.isEmpty()) {
586  const KConfig config("kservicemenurc", KConfig::NoGlobals);
587  const KConfigGroup showGroup = config.group("Show");
588 
589  foreach (const KSharedPtr<KService>& service, fileItemPlugins) {
590  if (!showGroup.readEntry(service->desktopEntryName(), true)) {
591  // The plugin has been disabled
592  continue;
593  }
594 
595  // Old API (kdelibs-4.6.0 only)
596  KFileItemActionPlugin* plugin = service->createInstance<KFileItemActionPlugin>();
597  if (plugin) {
598  plugin->setParent(q);
599  q->addActions(plugin->actions(m_popupItemProperties, m_parentWidget));
600  }
601  // New API (kdelibs >= 4.6.1)
602  KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>();
603  if (abstractPlugin) {
604  abstractPlugin->setParent(q);
605  q->addActions(abstractPlugin->actions(m_popupItemProperties, m_parentWidget));
606  }
607  }
608  }
609 }
610 
611 void KonqPopupMenuPrivate::slotShowOriginalFile()
612 {
613  const KFileItem item = m_popupItemProperties.items().first();
614  const QString dest = item.linkDest();
615  KUrl destUrl = m_sViewURL;
616  if (dest.startsWith('/')) {
617  destUrl.setPath(dest);
618  } else {
619  destUrl.addPath(dest);
620  }
621  // Now destUrl points to the target file, let's go up to parent dir
622  destUrl.setPath(destUrl.directory());
623  KRun::runUrl(destUrl, "inode/directory", m_parentWidget);
624 }
625 
626 #include "konq_popupmenu.moc"
KonqOperations::newDir
static KIO::SimpleJob * newDir(QWidget *parent, const KUrl &baseUrl)
Ask for the name of a new directory and create it.
Definition: konq_operations.cpp:932
KNewFileMenu
QWidget
KonqPopupMenu::KonqPopupMenu
KonqPopupMenu(const KFileItemList &items, const KUrl &viewURL, KActionCollection &actions, KNewFileMenu *newMenu, Flags appFlags, KParts::BrowserExtension::PopupFlags partFlags, QWidget *parentWidget, KBookmarkManager *manager=0, const KParts::BrowserExtension::ActionGroupMap &actionGroups=KParts::BrowserExtension::ActionGroupMap())
Constructor.
Definition: konq_popupmenu.cpp:131
konq_popupmenuinformation.h
KonqPopupMenu::~KonqPopupMenu
~KonqPopupMenu()
Don't forget to destroy the object.
Definition: konq_popupmenu.cpp:480
QAction::setFont
void setFont(const QFont &font)
QWidget::addActions
void addActions(QList< QAction * > actions)
KonqPopupMenu::setURLTitle
void setURLTitle(const QString &urlTitle)
Set the title of the URL, when the popupmenu is opened for a single URL.
Definition: konq_popupmenu.cpp:486
KonqPopupMenuPlugin
Base class for KonqPopupMenu plugins.
Definition: konq_popupmenuplugin.h:43
QList::value
T value(int i) const
KonqOperations::emptyTrash
static void emptyTrash(QWidget *parent)
Empty the trash.
Definition: konq_operations.cpp:115
KonqCopyToMenu
This class adds "Copy To" and "Move To" submenus to a popupmenu.
Definition: konq_copytomenu.h:34
konq_operations.h
QList::count
int count(const T &value) const
QList::isEmpty
bool isEmpty() const
QObject::setObjectName
void setObjectName(const QString &name)
QString::isEmpty
bool isEmpty() const
konq_popupmenuplugin.h
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
konq_copytomenu.h
QList::first
T & first()
QString
QList< KAction * >
KonqPopupMenu::fileItemActions
KFileItemActions * fileItemActions() const
Definition: konq_popupmenu.cpp:491
KonqPopupMenu
This class implements the popup menu for URLs in konqueror and kdesktop It's usage is very simple : o...
Definition: konq_popupmenu.h:51
knewmenu.h
QMenu
QObject::setParent
void setParent(QObject *parent)
KonqPopupMenu::Flags
uint Flags
Flags set by the calling application (e.g.
Definition: konq_popupmenu.h:60
QLatin1String
konq_popupmenu.h
KonqPopupMenuPlugin::setup
virtual void setup(KActionCollection *actionCollection, const KonqPopupMenuInformation &popupMenuInfo, QMenu *menu)=0
Implement the setup method in the plugin in order to create actions in the given actionCollection and...
QAction
KonqPopupMenu::NoPlugins
Definition: konq_popupmenu.h:63
KonqPopupMenuInformation
Holds the information about the items shown by KonqPopupMenu.
Definition: konq_popupmenuinformation.h:43
QMenu::menuAction
QAction * menuAction() const
KonqOperations::editMimeType
static void editMimeType(const QString &mimeType, QWidget *parent)
Pop up properties dialog for mimetype mimeType.
Definition: konq_operations.cpp:92
KonqOperations::restoreTrashedItems
static void restoreTrashedItems(const KUrl::List &urls, QWidget *parent)
Restore trashed items.
Definition: konq_operations.cpp:121
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KonqPopupMenu::ShowNewWindow
Definition: konq_popupmenu.h:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:07:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkonq

Skip menu "libkonq"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kde-baseapps API Reference

Skip menu "kde-baseapps API Reference"
  • Libraries
  •   libkonq

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal