mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
WebView: disable context menu in preview mode
This commit is contained in:
parent
6afc84fd04
commit
88d719bb28
@ -1408,6 +1408,7 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
|||||||
m_editor->hide();
|
m_editor->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_webViewer->setInPreview(false);
|
||||||
m_webViewer->show();
|
m_webViewer->show();
|
||||||
|
|
||||||
// Fix the bug introduced by 051088be31dbffa3c04e2d382af15beec40d5fdb
|
// Fix the bug introduced by 051088be31dbffa3c04e2d382af15beec40d5fdb
|
||||||
@ -1434,6 +1435,7 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
|||||||
|
|
||||||
case Mode::EditPreview:
|
case Mode::EditPreview:
|
||||||
Q_ASSERT(m_editor);
|
Q_ASSERT(m_editor);
|
||||||
|
m_webViewer->setInPreview(true);
|
||||||
m_webViewer->show();
|
m_webViewer->show();
|
||||||
m_editor->show();
|
m_editor->show();
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ VWebView::VWebView(VFile *p_file, QWidget *p_parent)
|
|||||||
: QWebEngineView(p_parent),
|
: QWebEngineView(p_parent),
|
||||||
m_file(p_file),
|
m_file(p_file),
|
||||||
m_copyImageUrlActionHooked(false),
|
m_copyImageUrlActionHooked(false),
|
||||||
m_afterCopyImage(false)
|
m_afterCopyImage(false),
|
||||||
|
m_inPreview(false)
|
||||||
{
|
{
|
||||||
setAcceptDrops(false);
|
setAcceptDrops(false);
|
||||||
|
|
||||||
@ -40,6 +41,11 @@ VWebView::VWebView(VFile *p_file, QWidget *p_parent)
|
|||||||
|
|
||||||
void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
||||||
{
|
{
|
||||||
|
if (m_inPreview) {
|
||||||
|
QWebEngineView(p_event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMenu *menu = page()->createStandardContextMenu();
|
QMenu *menu = page()->createStandardContextMenu();
|
||||||
menu->setToolTipsVisible(true);
|
menu->setToolTipsVisible(true);
|
||||||
|
|
||||||
@ -108,6 +114,8 @@ void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
|||||||
|
|
||||||
hideUnusedActions(menu);
|
hideUnusedActions(menu);
|
||||||
|
|
||||||
|
p_event->accept();
|
||||||
|
|
||||||
menu->exec(p_event->globalPos());
|
menu->exec(p_event->globalPos());
|
||||||
delete menu;
|
delete menu;
|
||||||
}
|
}
|
||||||
@ -400,4 +408,3 @@ void VWebView::handleCopyAllAsAction(QAction *p_act)
|
|||||||
|
|
||||||
triggerPageAction(QWebEnginePage::Unselect);
|
triggerPageAction(QWebEnginePage::Unselect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ public:
|
|||||||
// @p_file could be NULL.
|
// @p_file could be NULL.
|
||||||
explicit VWebView(VFile *p_file, QWidget *p_parent = Q_NULLPTR);
|
explicit VWebView(VFile *p_file, QWidget *p_parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
void setInPreview(bool p_preview);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void editNote();
|
void editNote();
|
||||||
|
|
||||||
@ -64,6 +66,13 @@ private:
|
|||||||
|
|
||||||
// Target of Copy As.
|
// Target of Copy As.
|
||||||
QString m_copyTarget;
|
QString m_copyTarget;
|
||||||
|
|
||||||
|
// Whether in preview mode.
|
||||||
|
bool m_inPreview;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline void VWebView::setInPreview(bool p_preview)
|
||||||
|
{
|
||||||
|
m_inPreview = p_preview;
|
||||||
|
}
|
||||||
#endif // VWEBVIEW_H
|
#endif // VWEBVIEW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user