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

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