close the folder peek popups on triggering the "Open With" action

Close all open popups on "Open With" selected to maintain consistency with activating an item in the folder peek popup and in order not to occlude the dialog with the popup
1)Expose the KFileItemActions object in KonqPopupMenu
2)Add a method hideThisAndParentPopup() to hide the open popups without deletion;actually delete the popups only after executing the context menu in order to avoid a crash in contextMenuRequest() after deleting the popups

BUG:240414
FIXED-IN:4.8.2

reviewed by fredrikh
This commit is contained in:
Ignat Semenov 2012-03-06 19:37:03 +04:00
parent fe97f31823
commit 2f7a07157f
2 changed files with 23 additions and 0 deletions

View file

@ -77,6 +77,7 @@ PopupView::PopupView(const QModelIndex &index, const QPoint &pos,
m_itemActions(0),
m_showingMenu(false),
m_showPreview(showPreview),
m_delayedClose(false),
m_previewPlugins(previewPlugins)
{
setAttribute(Qt::WA_TranslucentBackground);
@ -363,6 +364,8 @@ void PopupView::contextMenuRequest(QWidget *widget, const QPoint &screenPos)
KBookmarkManager::userBookmarksManager(),
actionGroups);
connect(contextMenu->fileItemActions(), SIGNAL(openWithDialogAboutToBeShown()), this, SLOT(openWithDialogAboutToShow()));
m_showingMenu = true;
contextMenu->exec(screenPos);
delete contextMenu;
@ -371,6 +374,11 @@ void PopupView::contextMenuRequest(QWidget *widget, const QPoint &screenPos)
if (pasteTo) {
pasteTo->setEnabled(false);
}
if (m_delayedClose) {
m_delayedClose = false;
closeThisAndParentPopup();
}
}
KUrl::List PopupView::selectedUrls() const
@ -449,6 +457,12 @@ void PopupView::activated(const QModelIndex &index)
closeThisAndParentPopup();
}
void PopupView::openWithDialogAboutToShow()
{
m_delayedClose = true;
hideThisAndParentPopup();
}
void PopupView::setBusy(bool busy)
{
m_busy = busy;
@ -594,6 +608,12 @@ void PopupView::closeThisAndParentPopup() {
callOnParent("closeThisAndParentPopup");
}
void PopupView::hideThisAndParentPopup()
{
hide();
callOnParent("hideThisAndParentPopup");
}
void PopupView::cancelHideTimer()
{
m_hideTimer.stop();

View file

@ -80,11 +80,13 @@ private:
private slots:
void init();
void activated(const QModelIndex &index);
void openWithDialogAboutToShow();
void setBusy(bool);
void createBusyWidgetIfNeeded();
void contextMenuRequest(QWidget *widget, const QPoint &screenPos);
void maybeClose();
void closeThisAndParentPopup();
void hideThisAndParentPopup();
void cancelHideTimer();
void aboutToShowCreateNew();
void emptyTrashBin();
@ -120,6 +122,7 @@ private:
bool m_showingMenu;
bool m_showPreview;
bool m_busy;
bool m_delayedClose;
QStringList m_previewPlugins;
static QTime s_lastOpenClose;
};