Commit 75692f78 authored by Alexander Volkov's avatar Alexander Volkov

Correctly extend context menu of file view

Summary:
Overriding KDirOperator::activatedMenu() leads to incomplete
initialization of context menu, in particular "Create New"
menu remain empty. Extend context menu on
KDirOperator::contextMenuAboutToShow() signal.

Reviewers: #kde_applications, aacid

Reviewed By: #kde_applications, aacid

Differential Revision: https://phabricator.kde.org/D18184
parent 5bae62ad
......@@ -61,6 +61,8 @@ K3b::DirOperator::DirOperator(const QUrl& url, QWidget* parent )
connect( this, SIGNAL(fileSelected(KFileItem)),
this, SLOT(slotAddFilesToProject()) );
connect( this, &KDirOperator::contextMenuAboutToShow,
this, &DirOperator::extendContextMenu );
}
......@@ -123,22 +125,13 @@ QUrl K3b::DirOperator::currentUrl() const
}
void K3b::DirOperator::activatedMenu( const KFileItem&, const QPoint& pos )
void K3b::DirOperator::extendContextMenu( const KFileItem&, QMenu* menu )
{
// both from KDirOperator
setupMenu();
updateSelectionDependentActions();
// insert our own actions
KActionMenu* dirOpMenu = qobject_cast<KActionMenu*>( actionCollection()->action("popupMenu") );
if (!dirOpMenu) {
return;
}
QAction* firstAction = dirOpMenu->menu()->actions().first();
dirOpMenu->insertAction( firstAction, actionCollection()->action("add_file_to_project") );
dirOpMenu->insertSeparator( firstAction );
dirOpMenu->addSeparator();
dirOpMenu->addAction( m_bmPopup );
QAction* firstAction = menu->actions().first();
menu->insertAction( firstAction, actionCollection()->action("add_file_to_project") );
menu->insertSeparator( firstAction );
menu->addSeparator();
menu->addAction( m_bmPopup );
bool hasSelection = !selectedItems().isEmpty();
/*
......@@ -146,8 +139,6 @@ void K3b::DirOperator::activatedMenu( const KFileItem&, const QPoint& pos )
!view()->selectedItems()->isEmpty();
*/
actionCollection()->action("add_file_to_project")->setEnabled( hasSelection && k3bappcore->k3bMainWindow()->activeView() != 0 );
dirOpMenu->menu()->popup( pos );
}
......
......@@ -66,11 +66,8 @@ public:
public Q_SLOTS:
void slotAddFilesToProject();
protected Q_SLOTS:
/**
* reimplemented from KDirOperator
*/
void activatedMenu( const KFileItem&, const QPoint& );
private Q_SLOTS:
void extendContextMenu( const KFileItem&, QMenu* );
private:
KBookmarkMenu* m_bmMenu;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment