diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 7d195df669..8fbcbf3f58 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -65,7 +65,8 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, m_customActions(), m_popup(new KMenu(m_mainWindow)), m_showDeleteCommand(false), - m_shiftIsPressed(false) + m_shiftPressed(false), + m_keyInfo() { // The context menu either accesses the URLs of the selected items // or the items itself. To increase the performance both lists are cached. @@ -74,6 +75,12 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, m_selectedItems = view->selectedItems(); m_showDeleteCommand = KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false); + + if (m_keyInfo.isKeyPressed(Qt::Key_Shift) || m_keyInfo.isKeyLatched(Qt::Key_Shift)) { + m_shiftPressed = true; + } + + connect(&m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)), this, SLOT(deleteOrTrashMenuEntry(Qt::Key, bool))); } DolphinContextMenu::~DolphinContextMenu() @@ -336,8 +343,8 @@ void DolphinContextMenu::insertDefaultItemActions() collection->action("delete")->setVisible(true); } - if(m_shiftIsPressed) { - deleteOrTrashMenuEntry(Qt::Key_Shift, m_shiftIsPressed); + if(m_shiftPressed) { + deleteOrTrashMenuEntry(Qt::Key_Shift, m_shiftPressed); } } @@ -432,11 +439,6 @@ void DolphinContextMenu::addCustomActions() } } -void DolphinContextMenu::setShiftIsPressed(bool pressed) -{ - m_shiftIsPressed = pressed; -} - void DolphinContextMenu::deleteOrTrashMenuEntry(Qt::Key key, bool pressed) { if(m_mainWindow->activeViewContainer()->url().isLocalFile() && !m_showDeleteCommand && key == Qt::Key_Shift) { diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h index 052149ba38..e5620203de 100644 --- a/src/dolphincontextmenu.h +++ b/src/dolphincontextmenu.h @@ -73,12 +73,11 @@ public: virtual ~DolphinContextMenu(); void setCustomActions(const QList& actions); - void setShiftIsPressed(bool pressed); /** Opens the context menu model. */ void open(); -public slots: +private slots: void deleteOrTrashMenuEntry(Qt::Key key, bool pressed); private: @@ -104,7 +103,6 @@ private: QAction* createPasteAction(); -private: KFileItemListProperties& capabilities(); void addServiceActions(KFileItemActions& fileItemActions); void addVersionControlActions(); @@ -139,7 +137,9 @@ private: QList m_customActions; QScopedPointer m_popup; bool m_showDeleteCommand; - bool m_shiftIsPressed; + bool m_shiftPressed; + + KModifierKeyInfo m_keyInfo; }; #endif diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 6f407a84a5..722a90f938 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -114,8 +114,7 @@ DolphinMainWindow::DolphinMainWindow(int id) : m_actionHandler(0), m_remoteEncoding(0), m_settingsDialog(0), - m_lastHandleUrlStatJob(0), - m_keyInfo(new KModifierKeyInfo) + m_lastHandleUrlStatJob(0) { setObjectName("Dolphin#"); @@ -1168,12 +1167,6 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item, const QList& customActions) { DolphinContextMenu contextMenu(this, item, url); - - if(m_keyInfo.isKeyPressed(Qt::Key_Shift) || m_keyInfo.isKeyLatched(Qt::Key_Shift)) { - contextMenu.setShiftIsPressed(true); - } - - connect(&m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)), &contextMenu, SLOT(deleteOrTrashMenuEntry(Qt::Key, bool))); contextMenu.setCustomActions(customActions); contextMenu.open(); } diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index cb0be1431c..d76cf0d5c0 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -31,12 +31,9 @@ #include #include #include -#include #include "views/dolphinview.h" -#include "dolphincontextmenu.h" - #include typedef KIO::FileUndoManager::CommandType CommandType; @@ -543,8 +540,6 @@ private: QPointer m_settingsDialog; KJob* m_lastHandleUrlStatJob; - - KModifierKeyInfo m_keyInfo; }; inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const