[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/languages/cpp/debugger
From: Hamish Rodda <rodda () kde ! org>
Date: 2008-06-26 5:50:01
Message-ID: 1214459401.459657.2962.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 824554 by rodda:
Port to kdev4 context menu extension system
Port the system for providing a "debug in kdevelop" button on drkonqi to qdbus
(Committed from within kdevelop4, it's starting to get really easy to use :)
M +42 -60 debuggerplugin.cpp
M +11 -9 debuggerplugin.h
--- trunk/KDE/kdevelop/languages/cpp/debugger/debuggerplugin.cpp #824553:824554
@@ -29,6 +29,8 @@
#include <QByteArray>
#include <QTimer>
#include <QMenu>
+#include <QDBusConnectionInterface>
+#include <QDBusInterface>
#include <kaction.h>
#include <kactioncollection.h>
@@ -58,6 +60,8 @@
#include <iproject.h>
#include <context.h>
#include <util/processlinemaker.h>
+#include <interfaces/context.h>
+#include <interfaces/contextmenuextension.h>
#include "variablewidget.h"
#include "gdbbreakpointwidget.h"
@@ -172,11 +176,7 @@
setupActions();
-// connect( core(), SIGNAL(contextMenu(Q3PopupMenu *, const KDevelop::Context \
*)),
-// this, SLOT(contextMenu(Q3PopupMenu *, const KDevelop::Context *)) );
-//
-// connect( core(), SIGNAL(stopButtonClicked(KDevPlugin*)),
-// this, SLOT(slotStop(KDevPlugin*)) );
+ setupDbus();
procLineMaker = new KDevelop::ProcessLineMaker(this);
@@ -333,61 +333,36 @@
ac->addAction("debug_toggle_breakpoint", action);
}
-void CppDebuggerPlugin::setupDcop()
+void CppDebuggerPlugin::setupDbus()
{
- /*QCStringList objects = kapp->dcopClient()->registeredApplications();
- for (QCStringList::Iterator it = objects.begin(); it != objects.end(); ++it)
- if ((*it).indexOf("drkonqi-") == 0)
- slotDCOPApplicationRegistered(*it);
+ QDBusConnection bus = QDBusConnection::sessionBus();
+ drkonqiInterface = new QDBusInterface("org.kde.Krash", "/krashinfo", QString(), \
bus, this); + connect(drkonqiInterface, SIGNAL(acceptDebuggingApplication()), \
this, SLOT(slotDebugExternalProcess())); + if \
(bus.interface()->isServiceRegistered( "org.kde.Krash" )) + \
slotDbusApplicationRegistered("org.kde.Krash");
- connect(kapp->dcopClient(), SIGNAL(applicationRegistered(const QByteArray&)), \
SLOT(slotDCOPApplicationRegistered(const QByteArray&)));
- kapp->dcopClient()->setNotifications(true);*/
+ connect(bus.interface(), SIGNAL(serviceRegistered(const QString&)), \
SLOT(slotDbusApplicationRegistered(const QString&))); }
-/*void CppDebuggerPlugin::slotDCOPApplicationRegistered(const QByteArray& appId)
+void CppDebuggerPlugin::slotDbusApplicationRegistered(const QString& interface)
{
- if (appId.indexOf("drkonqi-") == 0) {
- QByteArray answer;
- QByteArray replyType;
-
- kapp->dcopClient()->call(appId, "krashinfo", "appName()", QByteArray(), \
replyType, answer, true, 5000);
-
- QDataStream d(answer, QIODevice::ReadOnly);
- QByteArray appName;
- d >> appName;
-
- if (appName.length() && project() && \
project()->mainProgram().endsWith(appName)) {
- kapp->dcopClient()->send(appId, "krashinfo", \
"registerDebuggingApplication(QString)", i18n("Debug in &KDevelop"));
- connectDCOPSignal(appId, "krashinfo", "acceptDebuggingApplication()", \
"slotDebugExternalProcess()", true);
- }
- }
+ if (interface == "org.kde.Krash")
+ drkonqiInterface->call("registerDebuggingApplication", i18n("Debug in \
&KDevelop")); }
-ASYNC CppDebuggerPlugin::slotDebugExternalProcess()
+void CppDebuggerPlugin::slotDebugExternalProcess()
{
- QByteArray answer;
- QByteArray replyType;
+ QDBusReply<int> reply = drkonqiInterface->call("pid");
- kapp->dcopClient()->call(kapp->dcopClient()->senderId(), "krashinfo", "pid()", \
QByteArray(), replyType, answer, true, 5000);
-
- QDataStream d(answer, QIODevice::ReadOnly);
- int pid;
- d >> pid;
-
- if (attachProcess(pid) && m_drkonqi.isEmpty()) {
- m_drkonqi = kapp->dcopClient()->senderId();
+ if (reply.isValid()) {
+ attachProcess(reply.value());
QTimer::singleShot(15000, this, SLOT(slotCloseDrKonqi()));
- mainWindow()->raiseView(framestackWidget);
+ //mainWindow()->raiseView(framestackWidget);
}
- mainWindow()->main()->raise();
+ //mainWindow()->main()->raise();
}
-ASYNC CppDebuggerPlugin::slotDebugCommandLine(const QString& /command/)
-{
- KMessageBox::information(qApp->activeWindow(), "Asked to debug command line");
-}*/
-
void CppDebuggerPlugin::slotCloseDrKonqi()
{
/*kapp->dcopClient()->send(m_drkonqi, "MainApplication-Interface", "quit()", \
QByteArray()); @@ -396,8 +371,6 @@
CppDebuggerPlugin::~CppDebuggerPlugin()
{
- //kapp->dcopClient()->setNotifications(false);
-
delete controller;
delete floatingToolBar;
@@ -410,12 +383,17 @@
stateChanged("stopped");
}
-void CppDebuggerPlugin::contextMenu(QMenu *popup, const KDevelop::Context *context)
+KDevelop::ContextMenuExtension CppDebuggerPlugin::contextMenuExtension( \
KDevelop::Context* context ) {
- if (!context->hasType( KDevelop::Context::EditorContext ))
- return;
+ KDevelop::ContextMenuExtension menuExt = \
KDevelop::IPlugin::contextMenuExtension( context );
- const KDevelop::EditorContext *econtext = static_cast<const \
KDevelop::EditorContext*>(context); + if( context->type() != \
KDevelop::Context::EditorContext ) + return menuExt;
+
+ KDevelop::EditorContext *econtext = \
dynamic_cast<KDevelop::EditorContext*>(context); + if (!econtext)
+ return menuExt;
+
m_contextIdent = econtext->currentWord();
bool running = !(debuggerState_ & s_dbgNotStarted);
@@ -425,30 +403,34 @@
// surely debugging, not editing code or something. So, first
// menu items should be about debugging, not some copy/paste/cut
// things.
- if (!running)
- popup->addSeparator();
+ //if (!running)
+ //popup->addSeparator();
if (running)
{
- popup->addAction(m_runToCursor);
+ menuExt.addAction( KDevelop::ContextMenuExtension::DebugGroup, \
m_runToCursor); }
if (econtext->url().isLocalFile())
{
- popup->addAction(m_toggleBreakpoint);
+ menuExt.addAction( KDevelop::ContextMenuExtension::DebugGroup, \
m_toggleBreakpoint); }
if (!m_contextIdent.isEmpty())
{
// PORTING TODO
//QString squeezed = KStringHandler::csqueeze(m_contextIdent, 30);
- QAction* action = popup->addAction( i18n("Evaluate: %1", m_contextIdent),
- this, SLOT(contextEvaluate()));
+ QAction* action = new QAction( i18n("Evaluate: %1", m_contextIdent), this);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(contextEvaluate()));
action->setWhatsThis(i18n("<b>Evaluate expression</b><p>Shows the value of \
the expression under the cursor."));
- action = popup->addAction( i18n("Watch: %1", m_contextIdent), this, \
SLOT(contextWatch())); + menuExt.addAction( \
KDevelop::ContextMenuExtension::DebugGroup, action); +
+ action = new QAction( i18n("Watch: %1", m_contextIdent), this);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(contextWatch()));
action->setWhatsThis(i18n("<b>Watch expression</b><p>Adds an expression \
under the cursor to the Variables/Watch list.")); + menuExt.addAction( \
KDevelop::ContextMenuExtension::DebugGroup, action); }
- popup->addSeparator();
+ return menuExt;
}
--- trunk/KDE/kdevelop/languages/cpp/debugger/debuggerplugin.h #824553:824554
@@ -40,6 +40,7 @@
class QLabel;
class QMenu;
+class QDBusInterface;
class KDialog;
class ProcessWidget;
@@ -81,7 +82,9 @@
*/
void demandAttention() const;
- // BEGIN IRunProvider
+ virtual KDevelop::ContextMenuExtension contextMenuExtension( KDevelop::Context* \
); +
+ //BEGIN IRunProvider
virtual QStringList instrumentorsProvided() const;
virtual QString translatedInstrumentor(const QString& instrumentor) const;
virtual bool execute(const KDevelop::IRun& run, KJob* job);
@@ -90,9 +93,10 @@
Q_SIGNALS:
void finished(KJob* job);
void output(KJob* job, const QString& line, KDevelop::IRunProvider::OutputTypes \
type); + //END IRunProvider
public:
- // BEGIN IStatus
+ //BEGIN IStatus
virtual QString statusName() const;
Q_SIGNALS:
@@ -100,6 +104,7 @@
void showMessage(const QString & message, int timeout = 0);
void hideProgress();
void showProgress(int minimum, int maximum, int value);
+ //END IStatus
void raiseOutputViews();
void raiseFramestackViews();
@@ -115,13 +120,9 @@
void toggleBreakpoint(const KUrl& url, const KTextEditor::Cursor& cursor);
-//k_dcop:
-// virtual ASYNC slotDebugExternalProcess();
-// virtual ASYNC slotDebugCommandLine(const QString& command);
-
private Q_SLOTS:
- void setupDcop();
- void contextMenu(QMenu *popup, const KDevelop::Context *context);
+ void setupDbus();
+ void slotDebugExternalProcess();
void toggleBreakpoint();
void contextEvaluate();
void contextWatch();
@@ -137,7 +138,7 @@
void slotGotoSource(const QString &fileName, int lineNum);
- //void slotDCOPApplicationRegistered(const QByteArray &appId);
+ void slotDbusApplicationRegistered(const QString &service);
void slotCloseDrKonqi();
void slotDebuggerAbnormalExit();
@@ -169,6 +170,7 @@
QPointer<KToolBar> floatingToolBar;
KDevelop::ProcessLineMaker* procLineMaker;
KDevelop::ProcessLineMaker* gdbLineMaker;
+ QDBusInterface* drkonqiInterface;
QString m_contextIdent;
QByteArray m_drkonqi;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic