#include <kmenubar.h>
#include <kmessagebox.h>
#include <kmimetypetrader.h>
+#include <kmodifierkeyinfo.h>
#include <knewfilemenu.h>
#include <konqmimedata.h>
#include <konq_operations.h>
#include "views/dolphinview.h"
#include "views/viewmodecontroller.h"
+K_GLOBAL_STATIC(KModifierKeyInfo, m_keyInfo)
+
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
const KFileItem& fileInfo,
const KUrl& baseUrl) :
m_customActions(),
m_popup(new KMenu(m_mainWindow)),
m_shiftPressed(false),
- m_keyInfo(),
m_removeAction(0)
{
// The context menu either accesses the URLs of the selected items
m_selectedUrls = view->selectedUrls();
m_selectedItems = view->selectedItems();
- if (m_keyInfo.isKeyPressed(Qt::Key_Shift) || m_keyInfo.isKeyLatched(Qt::Key_Shift)) {
- m_shiftPressed = true;
+ if (m_keyInfo != 0) {
+ 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(slotKeyModifierPressed(Qt::Key, bool)));
}
- connect(&m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)),
- this, SLOT(slotKeyModifierPressed(Qt::Key, bool)));
-
m_removeAction = new QAction(this);
connect(m_removeAction, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered()));
}
}
}
+void DolphinContextMenu::initializeModifierKeyInfo()
+{
+ // Access m_keyInfo, so that it gets instantiated by
+ // K_GLOBAL_STATIC
+ KModifierKeyInfo* keyInfo = m_keyInfo;
+ Q_UNUSED(keyInfo);
+}
+
void DolphinContextMenu::slotKeyModifierPressed(Qt::Key key, bool pressed)
{
m_shiftPressed = (key == Qt::Key_Shift) && pressed;