mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
There is no need to burden DolphinMainWindow with internals of the context-menu.
CCMAIL: markg85@gmail.com svn path=/trunk/KDE/kdebase/apps/; revision=1176513
This commit is contained in:
parent
304e9524b6
commit
9a55b0d704
|
@ -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) {
|
||||
|
|
|
@ -73,12 +73,11 @@ public:
|
|||
virtual ~DolphinContextMenu();
|
||||
|
||||
void setCustomActions(const QList<QAction*>& 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<QAction*> m_customActions;
|
||||
QScopedPointer<KMenu> m_popup;
|
||||
bool m_showDeleteCommand;
|
||||
bool m_shiftIsPressed;
|
||||
bool m_shiftPressed;
|
||||
|
||||
KModifierKeyInfo m_keyInfo;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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<QAction*>& 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();
|
||||
}
|
||||
|
|
|
@ -31,12 +31,9 @@
|
|||
#include <ksortablelist.h>
|
||||
#include <kxmlguiwindow.h>
|
||||
#include <kactionmenu.h>
|
||||
#include <kmodifierkeyinfo.h>
|
||||
|
||||
#include "views/dolphinview.h"
|
||||
|
||||
#include "dolphincontextmenu.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
typedef KIO::FileUndoManager::CommandType CommandType;
|
||||
|
@ -543,8 +540,6 @@ private:
|
|||
QPointer<DolphinSettingsDialog> m_settingsDialog;
|
||||
|
||||
KJob* m_lastHandleUrlStatJob;
|
||||
|
||||
KModifierKeyInfo m_keyInfo;
|
||||
};
|
||||
|
||||
inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
|
||||
|
|
Loading…
Reference in a new issue