]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Fancy dragged items. There are two bad parts of this story: the hardcoded value of
[dolphin.git] / src / dolphincontextmenu.cpp
index 4e2cb4f8629721cf66a9b78a998be5d5ffb9a154..f60d59298feec5c39c755d2f8d73a7ad671b0d58 100644 (file)
@@ -23,6 +23,7 @@
 #include "dolphinmainwindow.h"
 #include "dolphinsettings.h"
 #include "dolphinview.h"
+#include "dolphinviewcontainer.h"
 
 #include <kactioncollection.h>
 #include <kfileplacesmodel.h>
@@ -57,13 +58,14 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
 {
     // The context menu either accesses the URLs of the selected items
     // or the items itself. To increase the performance both lists are cached.
-    DolphinView* view = m_mainWindow->activeView();
+    DolphinView* view = m_mainWindow->activeViewContainer()->view();
     m_selectedUrls = view->selectedUrls();
     m_selectedItems = view->selectedItems();
 }
 
 DolphinContextMenu::~DolphinContextMenu()
-{}
+{
+}
 
 void DolphinContextMenu::open()
 {
@@ -110,9 +112,9 @@ void DolphinContextMenu::openTrashContextMenu()
     if (popup->exec(QCursor::pos()) == emptyTrashAction) {
         const QString text(i18n("Do you really want to empty the Trash? All items will get deleted."));
         const bool del = KMessageBox::warningContinueCancel(m_mainWindow,
-                         text,
-                         QString(),
-                         KGuiItem(i18n("Empty Trash"), KIcon("user-trash"))
+                                                            text,
+                                                            QString(),
+                                                            KGuiItem(i18n("Empty Trash"), KIcon("user-trash"))
                                                            ) == KMessageBox::Continue;
         if (del) {
             KonqOperations::emptyTrash(m_mainWindow);
@@ -179,7 +181,7 @@ void DolphinContextMenu::openItemContextMenu()
         const KUrl selectedUrl(m_fileInfo->url());
         if (selectedUrl.isValid()) {
             DolphinSettings::instance().placesModel()->addPlace(selectedUrl.fileName(),
-                    selectedUrl);
+                                                                selectedUrl);
         }
     } else if (serviceActions.contains(activatedAction)) {
         // one of the 'Actions' items has been selected
@@ -233,6 +235,12 @@ void DolphinContextMenu::openViewportContextMenu()
     viewModeMenu->addAction(previewsMode);
 
     popup->addMenu(viewModeMenu);
+
+    QAction* toggleViewsAction = 0;
+    if (m_mainWindow->isSplit()) {
+        toggleViewsAction = popup->addAction(i18n("Toggle Views"));
+    }
+
     popup->addSeparator();
 
     QAction* bookmarkAction = popup->addAction(KIcon("bookmark-folder"), i18n("Bookmark This Folder..."));
@@ -240,17 +248,18 @@ void DolphinContextMenu::openViewportContextMenu()
 
     QAction* propertiesAction = popup->addAction(i18n("Properties"));
 
-    QAction* activatedAction = popup->exec(QCursor::pos());
-    if (activatedAction == propertiesAction) {
-        const KUrl& url = m_mainWindow->activeView()->url();
-        KPropertiesDialog* dlg = new KPropertiesDialog(url);
-        dlg->exec();
-        delete dlg;
-    } else if (activatedAction == bookmarkAction) {
-        const KUrl& url = m_mainWindow->activeView()->url();
+    QAction* action = popup->exec(QCursor::pos());
+    if (action == propertiesAction) {
+        const KUrl& url = m_mainWindow->activeViewContainer()->url();
+        KPropertiesDialog dialog(url);
+        dialog.exec();
+    } else if (action == bookmarkAction) {
+        const KUrl& url = m_mainWindow->activeViewContainer()->url();
         if (url.isValid()) {
             DolphinSettings::instance().placesModel()->addPlace(url.fileName(), url);
         }
+    } else if ((toggleViewsAction != 0) && (action == toggleViewsAction)) {
+        m_mainWindow->toggleViews();
     }
 
     popup->deleteLater();
@@ -279,7 +288,7 @@ void DolphinContextMenu::insertDefaultItemActions(KMenu* popup)
     const KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
     const KConfigGroup kdeConfig(globalConfig, "KDE");
     bool showDeleteCommand = kdeConfig.readEntry("ShowDeleteCommand", false);
-    const KUrl& url = m_mainWindow->activeView()->url();
+    const KUrl& url = m_mainWindow->activeViewContainer()->url();
     if (url.isLocalFile()) {
         QAction* moveToTrashAction = collection->action("move_to_trash");
         popup->addAction(moveToTrashAction);
@@ -361,7 +370,7 @@ QList<QAction*> DolphinContextMenu::insertOpenWithItems(KMenu* popup,
 }
 
 QList<QAction*> DolphinContextMenu::insertActionItems(KMenu* popup,
-        QVector<KDesktopFileActions::Service>& actionsVector)
+                                                      QVector<KDesktopFileActions::Service>& actionsVector)
 {
     // Parts of the following code have been taken
     // from the class KonqOperations located in