00001
#include <qwhatsthis.h>
00002
00003
00004
#include <kiconloader.h>
00005
#include <klocale.h>
00006
#include <kdevgenericfactory.h>
00007
#include <kprocess.h>
00008
#include <kdebug.h>
00009
#include <kaction.h>
00010
#include <kparts/part.h>
00011
#include <kdialogbase.h>
00012
00013
00014
#include "kdevcore.h"
00015
#include "kdevmainwindow.h"
00016
#include "kdevlanguagesupport.h"
00017
#include "kdevpartcontroller.h"
00018
#include "kdevproject.h"
00019
#include "kdevappfrontend.h"
00020
00021
#include "rubysupport_part.h"
00022
#include "rubyconfigwidget.h"
00023
#include "domutil.h"
00024
00025 typedef KDevGenericFactory<RubySupportPart> RubySupportFactory;
00026
static const KAboutData data(
"kdevrubysupport",
I18N_NOOP(
"Language"),
"1.0");
00027 K_EXPORT_COMPONENT_FACTORY( libkdevrubysupport,
RubySupportFactory( &data ) )
00028
00029
RubySupportPart::
RubySupportPart(
QObject *parent, const
char *name, const
QStringList& )
00030 :
KDevLanguageSupport ("KDevPart", "kdevpart", parent, name ? name : "
RubySupportPart" )
00031 {
00032 setInstance(RubySupportFactory::instance());
00033 setXMLFile(
"kdevrubysupport.rc");
00034
00035
KAction *action;
00036 action =
new KAction( i18n(
"&Run"),
"exec",Key_F9,
this, SLOT(slotRun()),actionCollection(),
"build_execute" );
00037 action->setToolTip(i18n(
"Run"));
00038 action->setWhatsThis(i18n(
"<b>Run</b><p>Starts an application."));
00039
00040
kdDebug() <<
"Creating RubySupportPart" <<
endl;
00041
00042 connect( core(), SIGNAL(projectConfigWidget(
KDialogBase*)),
00043
this, SLOT(projectConfigWidget(
KDialogBase*)) );
00044
00045
00046 }
00047
00048
00049 RubySupportPart::~RubySupportPart() {
00050 }
00051
00052
00053 void RubySupportPart::projectConfigWidget(
KDialogBase *dlg) {
00054
QVBox *vbox = dlg->
addVBoxPage(i18n(
"Ruby"));
00055
RubyConfigWidget *w =
new RubyConfigWidget(*
projectDom(), (
QWidget *)vbox,
"ruby config widget");
00056 connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) );
00057 }
00058
00059
00060 void RubySupportPart::slotRun () {
00061
QString file;
00062
KParts::ReadOnlyPart *ro_part = dynamic_cast<KParts::ReadOnlyPart*>(
partController()->
activePart());
00063
if(ro_part)
file = ro_part->
url().
path();
00064
00065
QString cmd =
interpreter() +
" " +
file;
00066
startApplication(cmd);
00067 }
00068
00069 QString RubySupportPart::interpreter() {
00070
QString prog = DomUtil::readEntry(*
projectDom(),
"/kdevrubysupport/run/interpreter");
00071
if (prog.isEmpty())
00072 prog =
"ruby";
00073
return prog;
00074 }
00075
00076
00077 void RubySupportPart::startApplication(
const QString &program) {
00078
kdDebug() <<
"starting application" << program <<
endl;
00079
appFrontend()->
startAppCommand(QString::QString(), program, TRUE);
00080 }
00081
00082
00083 KDevLanguageSupport::Features
RubySupportPart::features() {
00084
return Features(Classes | Functions);
00085 }
00086
00087
00088 KMimeType::List RubySupportPart::mimeTypes( )
00089 {
00090
KMimeType::List list;
00091
KMimeType::Ptr mime = KMimeType::mimeType(
"text/x-ruby" );
00092
if( mime )
00093 list << mime;
00094
return list;
00095 }
00096
00097
#include "rubysupport_part.moc"