summaryrefslogtreecommitdiffstats
path: root/kxsldbg/kxsldbg.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kxsldbg/kxsldbg.cpp
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kxsldbg/kxsldbg.cpp')
-rw-r--r--kxsldbg/kxsldbg.cpp173
1 files changed, 173 insertions, 0 deletions
diff --git a/kxsldbg/kxsldbg.cpp b/kxsldbg/kxsldbg.cpp
new file mode 100644
index 00000000..c28325a3
--- /dev/null
+++ b/kxsldbg/kxsldbg.cpp
@@ -0,0 +1,173 @@
+/*
+ * kxsldbg.cpp
+ *
+ * Copyright (C) 2001 <kurt@granroth.org>
+ */
+#include "kxsldbg.h"
+
+#include <kkeydialog.h>
+#include <kconfig.h>
+#include <klocale.h>
+
+#include <kedittoolbar.h>
+
+#include <kaction.h>
+#include <kstdaction.h>
+
+#include <klibloader.h>
+#include <kmessagebox.h>
+#include <kstatusbar.h>
+
+KXsldbg::KXsldbg()
+ : DCOPObject("KXsldbg"), KParts::MainWindow( 0L, "kxsldbg" )
+{
+ // set the shell's ui resource file
+ setXMLFile("kxsldbg_shell.rc");
+
+ // then, setup our actions
+ setupActions();
+
+ // and a status bar
+ statusBar()->show();
+ statusBar()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
+
+ // this routine will find and load our Part. it finds the Part by
+ // name which is a bad idea usually.. but it's alright in this
+ // case since our Part is made for this Shell
+ KLibFactory *factory = KLibLoader::self()->factory("libkxsldbgpart");
+ if (factory)
+ {
+ // now that the Part is loaded, we cast it to a Part to get
+ // our hands on it
+ m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,
+ "kxsldbg_part", "KParts::ReadOnlyPart" ));
+
+ if (m_part)
+ {
+ // tell the KParts::MainWindow that this is indeed the main widget
+ setCentralWidget(m_part->widget());
+
+ // and integrate the part's GUI with the shell's
+ createGUI(m_part);
+
+ // connect up signals
+ kapp->dcopClient()->attach();
+ connectDCOPSignal(0, 0, "debuggerPositionChanged(QString,int)", "newDebuggerPosition(QString,int)", false );
+ connectDCOPSignal(0, 0, "editorPositionChanged(QString,int,int)", "newCursorPosition(QString,int,int)", false );
+ }
+
+ }
+ else
+ {
+ // if we couldn't find our Part, we exit since the Shell by
+ // itself can't do anything useful
+ KMessageBox::error(this, i18n("Could not find our part."));
+ kapp->quit();
+ }
+}
+
+KXsldbg::~KXsldbg()
+{
+ if (m_part)
+ m_part->closeURL();
+
+ delete m_part;
+}
+
+void KXsldbg::quit()
+{
+ closeURL();
+ close();
+}
+
+bool KXsldbg::closeURL()
+{
+ if (m_part)
+ m_part->closeURL();
+
+ return true;
+}
+
+void KXsldbg::setupActions()
+{
+ KAction *act = KStdAction::quit(kapp, SLOT(quit()), actionCollection());
+ connect(act, SIGNAL(activated()), this, SLOT(quit()));
+
+ m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
+ m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
+
+ KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
+ KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
+}
+
+void KXsldbg::saveProperties(KConfig* /*config*/)
+{
+ // the 'config' object points to the session managed
+ // config file. anything you write here will be available
+ // later when this app is restored
+}
+
+void KXsldbg::readProperties(KConfig* /*config*/)
+{
+ // the 'config' object points to the session managed
+ // config file. this function is automatically called whenever
+ // the app is being restored. read in here whatever you wrote
+ // in 'saveProperties'
+}
+
+
+void KXsldbg::optionsShowToolbar()
+{
+ // this is all very cut and paste code for showing/hiding the
+ // toolbar
+ if (m_toolbarAction->isChecked())
+ toolBar()->show();
+ else
+ toolBar()->hide();
+}
+
+void KXsldbg::optionsShowStatusbar()
+{
+ // this is all very cut and paste code for showing/hiding the
+ // statusbar
+ if (m_statusbarAction->isChecked())
+ statusBar()->show();
+ else
+ statusBar()->hide();
+}
+
+void KXsldbg::optionsConfigureKeys()
+{
+ KKeyDialog::configure(actionCollection(), "kxsldbg_shell.rc");
+}
+
+void KXsldbg::optionsConfigureToolbars()
+{
+ saveMainWindowSettings(KGlobal::config(), "MainWindow");
+
+ // use the standard toolbar editor
+ KEditToolbar dlg(factory());
+ connect(&dlg, SIGNAL(newToolbarConfig()),
+ this, SLOT(applyNewToolbarConfig()));
+ dlg.exec();
+}
+
+void KXsldbg::applyNewToolbarConfig()
+{
+ applyMainWindowSettings(KGlobal::config(), "MainWindow");
+}
+
+
+void KXsldbg::newCursorPosition(const QString &file, int lineNumber, int columnNumber)
+{
+ statusBar()->clear();
+ statusBar()->message( i18n("File: %1 Line: %2 Col: %3").arg(file).arg(lineNumber).arg(columnNumber));
+}
+
+void KXsldbg::newDebuggerPosition(const QString &file, int lineNumber)
+{
+ // maybe do something extra here later
+ newCursorPosition(file, lineNumber);
+}
+
+#include "kxsldbg.moc"