Show a context menu for the diff view, with navigation and apply actions

parent 4dd5f0d9
......@@ -23,6 +23,7 @@
#include <QDialog>
#include <QLayout>
#include <QWidget>
#include <QMenu>
#include <QPainter>
#include <QPrinter>
#include <QPrintDialog>
......@@ -39,6 +40,7 @@
#include <KStandardAction>
#include <KStandardShortcut>
#include <KStandardGuiItem>
#include <KXMLGUIFactory>
#include <KIO/CopyJob>
#include <KIO/StatJob>
......@@ -79,6 +81,9 @@ KomparePart::KomparePart(QWidget* parentWidget, QObject* parent, const KAboutDat
readProperties( KSharedConfig::openConfig().data() );
m_view = new KompareView ( m_viewSettings, parentWidget );
m_view->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_view, &QWidget::customContextMenuRequested,
this, &KomparePart::onContextMenuRequested);
setWidget( m_view );
m_splitter = m_view->splitter();
......@@ -671,6 +676,13 @@ void KomparePart::slotSetStatus( enum Kompare::Status status )
}
}
void KomparePart::onContextMenuRequested(const QPoint& pos)
{
QMenu *popup = static_cast<QMenu*>(factory()->container(QStringLiteral("mainPopUp"), this));
if (popup)
popup->exec(m_view->mapToGlobal(pos));
}
void KomparePart::updateCaption()
{
QString source = m_info.source.toDisplayString();
......
......@@ -213,6 +213,9 @@ private:
// name now but it is private anyway so can not be used from outside
bool fetchURL( const QUrl& url, bool isSource );
private Q_SLOTS:
void onContextMenuRequested(const QPoint& pos);
private:
// Uhm why were these static again ???
// Ah yes, so multiple instances of kompare use the
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kompare_part" version="6" translationDomain="kompare">
<kpartgui name="kompare_part" version="7" translationDomain="kompare">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="file_save"/>
......@@ -45,4 +45,16 @@
<Action name="difference_apply"/>
<Action name="difference_applyall"/>
</ToolBar>
<Menu name="mainPopUp">
<Action name="difference_unapplyall"/>
<Action name="difference_unapply"/>
<Action name="difference_apply"/>
<Action name="difference_applyall"/>
<Separator/>
<Action name="difference_previousfile"/>
<Action name="difference_nextfile"/>
<Separator/>
<Action name="difference_previous"/>
<Action name="difference_next"/>
</Menu>
</kpartgui>
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